From 94a25dc66d040ddea4ea143036e8a7ba0ce7427b Mon Sep 17 00:00:00 2001
From: "Stephen A. Wood" <saw@jlab.org>
Date: Fri, 8 Nov 2013 15:51:25 -0500
Subject: [PATCH] Tests and reports for Drift Chamber efficiency   Clone some
 DC tests from ENGINE test files to podd   style cuts.  Make changes to source
 code to support these tests.   Correct hits in plane line in example report
 file.

---
 examples/hodtest_cuts.def    | 60 +++++++++++++++++++++++++++++++++---
 examples/report.template     |  2 +-
 src/THcDC.cxx                | 19 ++++--------
 src/THcDC.h                  |  8 ++---
 src/THcDriftChamberPlane.cxx |  1 +
 5 files changed, 68 insertions(+), 22 deletions(-)

diff --git a/examples/hodtest_cuts.def b/examples/hodtest_cuts.def
index f6003c2..8d0581f 100644
--- a/examples/hodtest_cuts.def
+++ b/examples/hodtest_cuts.def
@@ -2,16 +2,68 @@
 #
 
 Block: RawDecode
-
-Pedestal_event    g.evtyp==4
 RawDecode_master  1
+Pedestal_event    g.evtyp==4
 
 Block: Decode
 Decode_master     !Pedestal_event
 
 Block: CoarseTracking
-CoarseTracking_master !Pedestal_event
+
+hfoundtrack	H.dc.ntrack != 0
+hfound1track	H.dc.ntrack == 1
+hfound2track	H.dc.ntrack == 2
+hfound3track	H.dc.ntrack == 3
+hfound4track	H.dc.ntrack == 4
+
+goodhdc1x1	(H.dc.1x1.nhit > 0) && (H.dc.1x1.nhit < 3)
+goodhdc1y1	(H.dc.1y1.nhit > 0) && (H.dc.1y1.nhit < 3)
+goodhdc1u1	(H.dc.1u1.nhit > 0) && (H.dc.1u1.nhit < 3)
+goodhdc1v1	(H.dc.1v1.nhit > 0) && (H.dc.1v1.nhit < 3)
+goodhdc1y2	(H.dc.1y2.nhit > 0) && (H.dc.1y2.nhit < 3)
+goodhdc1x2	(H.dc.1x2.nhit > 0) && (H.dc.1x2.nhit < 3)
+
+goodhdc2x1	(H.dc.2x1.nhit > 0) && (H.dc.2x1.nhit < 3)
+goodhdc2y1	(H.dc.2y1.nhit > 0) && (H.dc.2y1.nhit < 3)
+goodhdc2u1	(H.dc.2u1.nhit > 0) && (H.dc.2u1.nhit < 3)
+goodhdc2v1	(H.dc.2v1.nhit > 0) && (H.dc.2v1.nhit < 3)
+goodhdc2y2	(H.dc.2y2.nhit > 0) && (H.dc.2y2.nhit < 3)
+goodhdc2x2	(H.dc.2x2.nhit > 0) && (H.dc.2x2.nhit < 3)
+
+goodhdc1	goodhdc1x1 && goodhdc1y1 && goodhdc1u1 && goodhdc1v1 && goodhdc1y2 && goodhdc1x2
+goodhdc2	goodhdc2x1 && goodhdc2y1 && goodhdc2u1 && goodhdc2v1 && goodhdc2y2 && goodhdc2x2
+bothgoodhdc	goodhdc1 && goodhdc2
+
+realhdc1x1	goodhdc1x1 && (H.dc.nsp != 0)
+realhdc1y1	goodhdc1y1 && (H.dc.nsp != 0)
+realhdc1u1	goodhdc1u1 && (H.dc.nsp != 0)
+realhdc1v1	goodhdc1v1 && (H.dc.nsp != 0)
+realhdc1y2	goodhdc1y2 && (H.dc.nsp != 0)
+realhdc1x2	goodhdc1x2 && (H.dc.nsp != 0)
+realhdc2x1	goodhdc2x1 && (H.dc.nsp != 0)
+realhdc2y1	goodhdc2y1 && (H.dc.nsp != 0)
+realhdc2u1	goodhdc2u1 && (H.dc.nsp != 0)
+realhdc2v1	goodhdc2v1 && (H.dc.nsp != 0)
+realhdc2y2	goodhdc2y2 && (H.dc.nsp != 0)
+realhdc2x2	goodhdc2x2 && (H.dc.nsp != 0)
+
+#hlowchi2	(hschi2perdeg<10) && hcleantrack
+
+hlowchi2	1
+
+hdcres_1	(H.dc.residual[0] < 1000) && hlowchi2
+hdcres_2	(H.dc.residual[1] < 1000) && hlowchi2
+hdcres_3	(H.dc.residual[2] < 1000) && hlowchi2
+hdcres_4	(H.dc.residual[3] < 1000) && hlowchi2
+hdcres_5	(H.dc.residual[4] < 1000) && hlowchi2
+hdcres_6	(H.dc.residual[5] < 1000) && hlowchi2
+hdcres_7	(H.dc.residual[6] < 1000) && hlowchi2
+hdcres_8	(H.dc.residual[7] < 1000) && hlowchi2
+hdcres_9	(H.dc.residual[8] < 1000) && hlowchi2
+hdcres_10	(H.dc.residual[9] < 1000) && hlowchi2
+hdcres_11	(H.dc.residual[10] < 1000) && hlowchi2
+hdcres_12	(H.dc.residual[11] < 1000) && hlowchi2
 
 Block: CoarseReconstruct
-RawCoarseReconstruct !Pedestal_event
+CourseReconstruct 1
 
diff --git a/examples/report.template b/examples/report.template
index 53b51a8..0125992 100644
--- a/examples/report.template
+++ b/examples/report.template
@@ -30,7 +30,7 @@ The names of the HMS drift chamber planes are: {hdc_plane_names}
 
 DC Events: {hdc_tot_events}
 Hit in chamber: {hdc_cham_hits[0]/hdc_tot_events:%.3f} {hdc_cham_hits[1]/hdc_tot_events:%.3f}
-Hit in plane: {hdc_hits_per_plane[0]/hdc_tot_events:%.3f} {hdc_hits_per_plane[1]/hdc_tot_events:%.3f} {hdc_hits_per_plane[2]/hdc_tot_events:%.3f} {hdc_hits_per_plane[3]/hdc_tot_events:%.3f} {hdc_hits_per_plane[4]/hdc_tot_events:%.3f} {hdc_hits_per_plane[5]/hdc_tot_events:%.3f} {hdc_hits_per_plane[6]/hdc_tot_events:%.3f} {hdc_hits_per_plane[7]/hdc_tot_events:%.3f} {hdc_hits_per_plane[8]/hdc_tot_events:%.3f} {hdc_hits_per_plane[9]/hdc_tot_events:%.3f} {hdc_hits_per_plane[10]/hdc_tot_events:%.3f} {hdc_hits_per_plane[11]/hdc_tot_events:%.3f}
+Hit in plane: {hdc_events[0]/hdc_tot_events:%.3f} {hdc_events[1]/hdc_tot_events:%.3f} {hdc_events[2]/hdc_tot_events:%.3f} {hdc_events[3]/hdc_tot_events:%.3f} {hdc_events[4]/hdc_tot_events:%.3f} {hdc_events[5]/hdc_tot_events:%.3f} {hdc_events[6]/hdc_tot_events:%.3f} {hdc_events[7]/hdc_tot_events:%.3f} {hdc_events[8]/hdc_tot_events:%.3f} {hdc_events[9]/hdc_tot_events:%.3f} {hdc_events[10]/hdc_tot_events:%.3f} {hdc_events[11]/hdc_tot_events:%.3f}
 
 Run #{gen_run_number}
 first event = {gen_run_starting_event:%7d}
diff --git a/src/THcDC.cxx b/src/THcDC.cxx
index 30ecae9..9015cf3 100644
--- a/src/THcDC.cxx
+++ b/src/THcDC.cxx
@@ -23,8 +23,6 @@
 #include "TMath.h"
 #include "TVectorD.h"
 
-#include "THaTrackProj.h"
-
 #include <cstring>
 #include <cstdio>
 #include <cstdlib>
@@ -40,7 +38,6 @@ THcDC::THcDC(
 {
   // Constructor
 
-  //  fTrackProj = new TClonesArray( "THaTrackProj", 5 );
   fNPlanes = 0;			// No planes until we make them
 
   fXCenter = NULL;
@@ -333,6 +330,7 @@ Int_t THcDC::DefineVariables( EMode mode )
   RVarDef vars[] = {
     { "nhit", "Number of DC hits",  "fNhits" },
     { "ntrack", "Number of Tracks", "fNDCTracks" },
+    { "nsp", "Number of Space Points", "fNSp" },
     { "x", "X at focal plane", "fDCTracks.THcDCTrack.GetX()"},
     { "y", "Y at focal plane", "fDCTracks.THcDCTrack.GetY()"},
     { "xp", "YP at focal plane", "fDCTracks.THcDCTrack.GetXP()"},
@@ -361,10 +359,6 @@ THcDC::~THcDC()
   for (vector<THcDriftChamber*>::iterator ip = fChambers.begin();
        ip != fChambers.end(); ip++) delete *ip;
 
-  if (fTrackProj) {
-    fTrackProj->Clear();
-    delete fTrackProj; fTrackProj = 0;
-  }
   delete fDCTracks;
 }
 
@@ -549,7 +543,7 @@ void THcDC::LinkStubs()
   //                     stubs.
 
   std::vector<THcSpacePoint*> fSp;
-  Int_t fNSp=0;
+  fNSp=0;
   fSp.clear();
   fSp.reserve(10);
   // Make a vector of pointers to the SpacePoints
@@ -985,19 +979,18 @@ void THcDC::EffInit()
   // variables can be used in end of run reports.
 
   delete [] fNChamHits;  fNChamHits = new Int_t [fNChambers];
-  delete [] fHitsPerPlane; fHitsPerPlane = new Int_t [fNPlanes];
+  delete [] fPlaneEvents; fPlaneEvents = new Int_t [fNPlanes];
   
   fTotEvents = 0;
   for(Int_t i=0;i<fNChambers;i++) {
     fNChamHits[i] = 0;
   }
   for(Int_t i=0;i<fNPlanes;i++) {
-    fHitsPerPlane[i] = 0;
+    fPlaneEvents[i] = 0;
   }
   gHcParms->Define(Form("%sdc_tot_events",fPrefix),"Total DC Events",fTotEvents);
   gHcParms->Define(Form("%sdc_cham_hits[%d]",fPrefix,fNChambers),"N events with hits per chamber",*fNChamHits);
-  gHcParms->Define(Form("%sdc_hits_per_plane[%d]",fPrefix,fNPlanes),"N events with hits per plane",*fHitsPerPlane);
-  cout << Form("%sdc_hits_per_plane[%d]",fPrefix,fNPlanes) << endl;
+  gHcParms->Define(Form("%sdc_events[%d]",fPrefix,fNPlanes),"N events with hits per plane",*fPlaneEvents);
 }
 
 //_____________________________________________________________________________
@@ -1010,7 +1003,7 @@ void THcDC::Eff()
     if(fChambers[i]->GetNHits()>0) fNChamHits[i]++;
   }
   for(Int_t i=0;i<fNPlanes;i++) {
-    if(fPlanes[i]->GetNHits() > 0) fHitsPerPlane[i]++;
+    if(fPlanes[i]->GetNHits() > 0) fPlaneEvents[i]++;
   }
   return;
 }
diff --git a/src/THcDC.h b/src/THcDC.h
index 041b2eb..fb727a9 100644
--- a/src/THcDC.h
+++ b/src/THcDC.h
@@ -36,8 +36,8 @@ public:
 
   //  Int_t GetNHits() const { return fNhit; }
   
-  Int_t GetNTracks() const { return fTrackProj->GetLast()+1; }
-  const TClonesArray* GetTrackHits() const { return fTrackProj; }
+  //  Int_t GetNTracks() const { return fNDCTracks; }
+  //  const TClonesArray* GetTrackHits() const { return fTrackProj; }
 
   Int_t GetNWires(Int_t plane) const { return fNWires[plane-1];}
   Int_t GetNChamber(Int_t plane) const { return fNChamber[plane-1];}
@@ -97,7 +97,7 @@ protected:
 
   // Per-event data
   Int_t fNhits;
-  Int_t ntracks_fp;		/* Change this to fN something */
+  Int_t fNSp;                   // Number of space points
   Double_t* fResiduals;         //[fNPlanes] Array of residuals
 
   Double_t fNSperChan;		/* TDC bin size */
@@ -141,7 +141,7 @@ protected:
   // For accumulating statitics for efficiencies
   Int_t fTotEvents;
   Int_t* fNChamHits;
-  Int_t* fHitsPerPlane;
+  Int_t* fPlaneEvents;
 
   // Useful derived quantities
   // double tan_angle, sin_angle, cos_angle;
diff --git a/src/THcDriftChamberPlane.cxx b/src/THcDriftChamberPlane.cxx
index fb97cc9..4bdf51b 100644
--- a/src/THcDriftChamberPlane.cxx
+++ b/src/THcDriftChamberPlane.cxx
@@ -236,6 +236,7 @@ Int_t THcDriftChamberPlane::DefineVariables( EMode mode )
      "fHits.THcDCHit.GetTime()"},
     {"dist","Drift distancess",
      "fHits.THcDCHit.GetDist()"},
+    {"nhit", "Number of hits", "GetNHits()"},
     { 0 }
   };
 
-- 
GitLab