20 const unsigned int rad = 1;
54 #include <JANA/JApplication.h>
55 #include <JANA/JFactory.h>
86 TDirectory *
main = gDirectory;
87 gDirectory->mkdir(
"FDC_Efficiency")->cd();
88 gDirectory->mkdir(
"FDC_View")->cd();
90 for(
int icell=0; icell<24; icell++){
92 char hname_measured[256];
93 char hname_expected[256];
94 sprintf(hname_measured,
"fdc_wire_measured_cell[%d]", icell+1);
95 sprintf(hname_expected,
"fdc_wire_expected_cell[%d]", icell+1);
99 sprintf(hname_measured,
"fdc_pseudo_measured_cell[%d]", icell+1);
100 sprintf(hname_expected,
"fdc_pseudo_expected_cell[%d]", icell+1);
106 gDirectory->cd(
"/FDC_Efficiency");
107 gDirectory->mkdir(
"Track_Quality")->cd();
108 hChi2OverNDF =
new TH1I(
"hChi2OverNDF",
"hChi2OverNDF", 500, 0.0, 1.0);
110 hMom =
new TH1I(
"hMom",
"Momentum", 500, 0.0, 10);
111 hMom_accepted =
new TH1I(
"hMom_accepted",
"Momentum (accepted)", 500, 0.0, 10);
112 hTheta =
new TH1I(
"hTheta",
"Theta of Track", 500, 0.0, 50);
113 hTheta_accepted =
new TH1I(
"hTheta_accepted",
"Theta of Track (accepted)", 500, 0.0, 50);
114 hPhi =
new TH1I(
"hPhi",
"Phi of Track", 360, -180, 180);
115 hPhi_accepted =
new TH1I(
"hPhi_accepted",
"Phi of Track (accepted)", 360, -180, 180);
116 hCellsHit =
new TH1I(
"hCellsHit",
"Cells of FDC Contributing to Track", 25, -0.5, 24.5);
117 hCellsHit_accepted =
new TH1I(
"hCellsHit_accepted",
"Cells of FDC Contributing to Track (accepted)", 25, -0.5, 24.5);
118 hRingsHit =
new TH1I(
"hRingsHit",
"Rings of CDC Contributing to Track", 29, -0.5, 28.5);
119 hRingsHit_accepted =
new TH1I(
"hRingsHit_accepted",
"Rings of CDC Contributing to Track (accepted)", 25, -0.5, 24.5);
121 hRingsHit_vs_P =
new TH2I(
"hRingsHit_vs_P",
"Rings of CDC Contributing to Track vs P (accepted)", 25, -0.5, 24.5, 34, 0.6, 4);
123 gDirectory->cd(
"/FDC_Efficiency");
124 gDirectory->mkdir(
"Residuals")->cd();
125 hPseudoRes =
new TH1I(
"hPseudoRes",
"Pseudo Residual in R", 500, 0, 5);
127 for(
int icell=0; icell<24; icell++){
138 sprintf(hname_X,
"hPseudoResU_cell[%d]", icell+1);
139 sprintf(hname_Y,
"hPseudoResV_cell[%d]", icell+1);
140 hPseudoResU[icell+1] =
new TH1I(hname_X,
"Pseudo Residual along Wire", 600, -3, 3);
141 hPseudoResV[icell+1] =
new TH1I(hname_Y,
"Pseudo Residual perp. to Wire", 600, -3, 3);
142 for (
unsigned int r=0; r<
rad; r++){
143 sprintf(hname_XY,
"hPseudoResUvsV_cell[%d]_radius[%d]", icell+1, (r+1)*45/rad);
144 hPseudoResUvsV[icell+1][r] =
new TH2I(hname_XY,
"Pseudo Residual 2D", 200, -1, 1, 200, -1, 1);
147 sprintf(hname_X,
"hResVsT_cell[%d]", icell+1);
148 sprintf(hname_Y,
"hPseudoResVsT[%d]", icell+1);
149 hResVsT[icell+1] =
new TH2I(hname_X,
"Tracking Residual (Biased) Vs Wire Drift Time; DOCA (cm); Drift Time (ns)", 100, 0, 0.5, 400, -100, 300);
150 hPseudoResVsT[icell+1] =
new TH2I(hname_Y,
"Tracking Residual (Biased) Vs Pseudo Time; Residual (cm); Drift Time (ns)", 200, -0.5, 0.5, 400, -100, 300);
152 sprintf(hname_X,
"hWireTime_cell[%d]", icell+1);
153 sprintf(hname_Y,
"hWireTime_acc_cell[%d]", icell+1);
154 hWireTime[icell+1] =
new TH1I(hname_X,
"Timing of Hits", 600, -200, 400);
155 hWireTime_accepted[icell+1] =
new TH1I(hname_Y,
"Timing of Hits (accepted)", 600, -200, 400);
157 sprintf(hname_X,
"hCathodeTime_cell[%d]", icell+1);
158 sprintf(hname_Y,
"hCathodeTime_acc_cell[%d]", icell+1);
159 hCathodeTime[icell+1] =
new TH1I(hname_X,
"Timing of Cathode Clusters", 600, -200, 400);
160 hCathodeTime_accepted[icell+1] =
new TH1I(hname_Y,
"Timing of Cathode Clusters (accepted)", 600, -200, 400);
162 sprintf(hname_X,
"hPseudoTime_cell[%d]", icell+1);
163 sprintf(hname_Y,
"hPseudoTime_acc_cell[%d]", icell+1);
164 hPseudoTime[icell+1] =
new TH1I(hname_X,
"Timing of Pseudos", 600, -200, 400);
165 hPseudoTime_accepted[icell+1] =
new TH1I(hname_Y,
"Timing of Pseudos (accepted)", 600, -200, 400);
167 sprintf(hname_X,
"hPullTime_cell[%d]", icell+1);
168 hPullTime[icell+1] =
new TH1I(hname_X,
"Timing of Wire Hits (from pulls)", 600, -200, 400);
170 sprintf(hname_X,
"hDeltaTime_cell[%d]", icell+1);
171 hDeltaTime[icell+1] =
new TH1I(hname_X,
"Time Difference between Wires and Cathode Clusters", 200, -50, 50);
196 dgeom->GetFDCZ(fdcz);
199 dgeom->GetFDCRmin(fdcrmin);
202 dgeom->GetFDCRmax(fdcrmax);
213 vector< const DFDCHit *> locFDCHitVector;
214 loop->Get(locFDCHitVector);
215 vector< const DFDCPseudo *> locFDCPseudoVector;
216 loop->Get(locFDCPseudoVector);
220 map<int, map<int, set<const DFDCHit*> > > locSortedFDCHits;
221 for(
unsigned int hitNum = 0; hitNum < locFDCHitVector.size(); hitNum++){
222 const DFDCHit * locHit = locFDCHitVector[hitNum];
223 if (locHit->
plane != 2)
continue;
225 japp->RootFillLock(
this);
227 japp->RootFillUnLock(
this);
232 locSortedFDCHits[locHit->
gLayer][locHit->
element].insert(locHit);
238 map<int, set<const DFDCPseudo*> > locSortedFDCPseudos;
239 for(
unsigned int hitNum = 0; hitNum < locFDCPseudoVector.size(); hitNum++){
240 const DFDCPseudo * locPseudo = locFDCPseudoVector[hitNum];
241 locSortedFDCPseudos[locPseudo->
wire->
layer].insert(locPseudo);
243 japp->RootFillLock(
this);
247 japp->RootFillUnLock(
this);
252 vector<shared_ptr<const DSCHitMatchParams>> SCMatches;
253 vector<shared_ptr<const DTOFHitMatchParams>> TOFMatches;
254 vector<shared_ptr<const DBCALShowerMatchParams>> BCALMatches;
257 loop->GetSingle(detMatches);
260 vector <const DChargedTrack *> chargedTrackVector;
261 loop->Get(chargedTrackVector);
263 for (
unsigned int iTrack = 0; iTrack < chargedTrackVector.size(); iTrack++){
273 vector< int > cellsHit;
274 vector< int > ringsHit;
275 vector<DTrackFitter::pull_t> pulls = thisTimeBasedTrack->
pulls;
276 for (
unsigned int i = 0; i < pulls.size(); i++){
277 const DFDCPseudo * thisTrackFDCHit = pulls[i].fdc_hit;
278 if (thisTrackFDCHit != NULL){
280 if ( find(cellsHit.begin(), cellsHit.end(), thisTrackFDCHit->
wire->
layer) == cellsHit.end())
281 cellsHit.push_back(thisTrackFDCHit->
wire->
layer);
284 const DCDCTrackHit * thisTrackCDCHit = pulls[i].cdc_hit;
285 if (thisTrackCDCHit != NULL){
286 if ( find(ringsHit.begin(), ringsHit.end(), thisTrackCDCHit->
wire->
ring) == ringsHit.end())
287 ringsHit.push_back(thisTrackCDCHit->
wire->
ring);
290 unsigned int cells = cellsHit.size();
291 unsigned int rings = ringsHit.size();
293 if (cells == 0)
continue;
295 double theta_deg = thisTimeBasedTrack->momentum().Theta()*TMath::RadToDeg();
296 double phi_deg = thisTimeBasedTrack->momentum().Phi()*TMath::RadToDeg();
297 double tmom = thisTimeBasedTrack->pmag();
300 japp->RootFillLock(
this);
307 japp->RootFillUnLock(
this);
313 if (thisTimeBasedTrack->FOM < 1E-20)
345 unsigned int packageHit[4] = {0,0,0,0};
346 for (
unsigned int i = 0; i < cells; i++)
347 packageHit[(cellsHit[i] - 1) / 6]++;
349 unsigned int minCells = 4;
350 if (packageHit[0] < minCells && packageHit[1] < minCells && packageHit[2] < minCells && packageHit[3] < minCells)
continue;
353 japp->RootFillLock(
this);
362 japp->RootFillUnLock(
this);
367 for (
unsigned int cellIndex = 0; cellIndex <
fdcwires.size(); cellIndex ++){
368 unsigned int cellNum = cellIndex +1;
369 vector< DFDCWire * > wireByNumber =
fdcwires[cellIndex];
373 if (packageHit[cellIndex / 6] < minCells )
continue;
376 DVector3 plane_origin(0.0, 0.0, fdcz[cellIndex]);
377 DVector3 plane_normal(0.0, 0.0, 1.0);
378 DVector3 interPosition,trackDirection;
379 vector<DTrackFitter::Extrapolation_t>extrapolations=thisTimeBasedTrack->extrapolations.at(
SYS_FDC);
380 for (
unsigned int i=0;i<extrapolations.size();i++){
381 double dz=plane_origin.z()-extrapolations[i].position.z();
383 trackDirection=extrapolations[i].momentum;
384 trackDirection.SetMag(1.);
385 interPosition=extrapolations[i].position;
391 int packageIndex = (cellNum - 1) / 6;
392 if (interPosition.Perp() < fdcrmin[packageIndex] || interPosition.Perp() > fdcrmax)
continue;
397 for (
unsigned int wireIndex = 0; wireIndex < wireByNumber.size(); wireIndex++){
398 unsigned int wireNum = wireIndex+1;
399 DFDCWire * wire = wireByNumber[wireIndex];
400 double dz=wire->
origin.z()-interPosition.z();
401 interPosition+=(dz/trackDirection.z())*trackDirection;
402 double distanceToWire = (interPosition-wire->
origin).Perp();
403 bool expectHit =
false;
406 if (distanceToWire < 0.5 )
410 if(distanceToWire > 50.0)
415 if(distanceToWire > 20.0)
420 if(distanceToWire > 10.0)
428 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Expected Hits Vs DOCA", distanceToWire,
"Expected Hits", 100, 0 , 0.5);
429 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Expected Hits Vs Tracking FOM", thisTimeBasedTrack->FOM,
"Expected Hits", 100, 0 , 1.0);
430 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Expected Hits Vs theta", theta_deg,
"Expected Hits", 100, 0, 180);
431 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Expected Hits Vs phi", phi_deg,
"Measured Hits", 100, -180, 180);
432 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Expected Hits Vs p", tmom,
"Expected Hits", 100, 0 , 10.0);
433 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Expected Hits Vs Hit Cells", cells,
"Expected Hits", 25, -0.5 , 24.5);
438 japp->RootFillLock(
this);
441 japp->RootFillUnLock(
this);
445 if(!locSortedFDCHits[cellNum][wireNum].empty() || !locSortedFDCHits[cellNum][wireNum-1].empty() || !locSortedFDCHits[cellNum][wireNum+1].empty()){
450 if(!locSortedFDCHits[cellNum][wireNum].empty()){
452 for(set<const DFDCHit*>::iterator locIterator = locSortedFDCHits[cellNum][wireNum].begin(); locIterator != locSortedFDCHits[cellNum][wireNum].end(); ++locIterator){
453 const DFDCHit* locHit = * locIterator;
454 japp->RootFillLock(
this);
456 hResVsT[cellNum]->Fill(distanceToWire, locHit->
t);
457 japp->RootFillUnLock(
this);
461 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Measured Hits Vs DOCA", distanceToWire,
"Measured Hits", 100, 0 , 0.5);
462 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Measured Hits Vs Tracking FOM", thisTimeBasedTrack->FOM,
"Measured Hits", 100, 0 , 1.0);
463 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Measured Hits Vs theta", theta_deg,
"Measured Hits", 100, 0, 180);
464 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Measured Hits Vs phi", phi_deg,
"Measured Hits", 100, -180, 180);
465 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Measured Hits Vs p", tmom,
"Measured Hits", 100, 0 , 10.0);
466 Fill1DHistogram(
"FDC_Efficiency",
"Offline",
"Measured Hits Vs Hit Cells", cells,
"Measured Hits", 25, -0.5 , 24.5);
468 japp->RootFillLock(
this);
471 japp->RootFillUnLock(
this);
488 japp->RootFillLock(
this);
490 japp->RootFillUnLock(
this);
493 bool foundPseudo =
false;
494 if(!locSortedFDCPseudos[cellNum].empty()){
496 set<const DFDCPseudo*>& locPlanePseudos = locSortedFDCPseudos[cellNum];
498 for(set<const DFDCPseudo*>::iterator locIterator = locPlanePseudos.begin(); locIterator != locPlanePseudos.end(); ++locIterator)
501 if (locPseudo == NULL)
continue;
504 DVector2 interPosition2D(interPosition.X(), interPosition.Y());
506 DVector2 residual2D = (pseudoPosition - interPosition2D);
507 double residualR = residual2D.Mod();
513 double residualU = -1*(residual2D.Rotate(wire->
angle)).
X();
514 double residualV = -1*(residual2D.Rotate(wire->
angle)).Y();
517 japp->RootFillLock(
this);
523 unsigned int radius = interPosition2D.Mod()/(45/
rad);
526 japp->RootFillUnLock(
this);
528 if (foundPseudo)
continue;
537 japp->RootFillLock(
this);
545 japp->RootFillUnLock(
this);
static TH1I * hChi2OverNDF
DVector2 xy
rough x,y coordinates in lab coordinate system
static TH1I * hChi2OverNDF_accepted
~JEventProcessor_FDC_Efficiency()
static TH2D * fdc_pseudo_expected_cell[25]
static TH1I * hTheta_accepted
bool Get_TOFMatchParams(const DTrackingData *locTrack, vector< shared_ptr< const DTOFHitMatchParams > > &locMatchParams) const
static TH2I * hPseudoResVsT[25]
bool Get_SCMatchParams(const DTrackingData *locTrack, vector< shared_ptr< const DSCHitMatchParams > > &locMatchParams) const
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
static TH1I * hPseudoResU[25]
double t_v
time of the two cathode clusters
sprintf(text,"Post KinFit Cut")
static TH1I * hPhi_accepted
static vector< vector< DFDCWire * > > fdcwires
DMagneticFieldMap * GetBfield(unsigned int run_number=1)
const DTrackTimeBased * Get_TrackTimeBased(void) const
const DFDCWire * wire
DFDCWire for this wire.
static TH1I * hPseudoTime_accepted[25]
class DFDCPseudo: definition for a reconstructed point in the FDC
jerror_t fini(void)
Called after last event of last event source has been processed.
static TH1I * hWireTime_accepted[25]
static TH1I * hCellsHit_accepted
static TH1I * hPullTime[25]
static TH1D * fdc_wire_expected_cell[25]
static TH1I * hMom_accepted
static TH1I * hDeltaTime[25]
static TH2D * fdc_pseudo_measured_cell[25]
static TH2I * hPseudoResUvsV[25][rad]
DGeometry * GetDGeometry(unsigned int run_number)
JEventProcessor_FDC_Efficiency()
jerror_t init(void)
Called once at program start.
static TH1D * fdc_wire_measured_cell[25]
static TH2I * hResVsT[25]
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
static TH1I * hPseudoResV[25]
static TH1I * hCathodeTime_accepted[25]
static TH1I * hRingsHit_accepted
double time
time corresponding to this pseudopoint.
vector< DTrackFitter::pull_t > pulls
Holds pulls used in chisq calc. (not including off-diagonals)
bool Get_BCALMatchParams(const DTrackingData *locTrack, vector< shared_ptr< const DBCALShowerMatchParams > > &locMatchParams) const
static TH1I * hWireTime[25]
bool GetFDCWires(vector< vector< DFDCWire * > > &fdcwires) const
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
static TH2I * hRingsHit_vs_P
int main(int argc, char *argv[])
static TH1I * hCathodeTime[25]
static TH1I * hPseudoTime[25]
class DFDCHit: definition for a basic FDC hit data type.