12 #include <JANA/JApplication.h>
13 #include <JANA/JFactory.h>
41 int LH_module=(mod-1)%2;
42 int package=(mod-1)/12;
43 int cell=(mod-1-package*12)/2;
45 int rotation = -45 + 90*LH_module -60*cell;
46 if(rotation<-180)rotation+=360;
51 if(rotation>0)crate=3;
54 if(rotation>0)crate=2;
83 if(crate==1)act_crate=
"ROCFDC4";
84 if(crate==2)act_crate=
"ROCFDC13";
85 if(crate==3)act_crate=
"ROCFDC14";
88 if(act_slot>10)act_slot+=2;
93 return crate*12+slot+1;
121 fBeamEventCounter = 0;
122 dMaxDIRCChannels = 108*64;
125 BEAM_EVENTS_TO_KEEP = 1000000000;
128 DO_TDC_ADC_ALIGN = 0;
133 DO_HIGH_RESOLUTION = 0;
140 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:DO_ROUGH_TIMING", DO_ROUGH_TIMING,
"Set to > 0 to do rough timing of all detectors");
141 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:DO_CDC_TIMING", DO_CDC_TIMING,
"Set to > 0 to do CDC Per channel Alignment");
142 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:DO_TDC_ADC_ALIGN", DO_TDC_ADC_ALIGN,
"Set to > 0 to do TDC/ADC alignment of SC,TOF,TAGM,TAGH");
143 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:DO_TRACK_BASED", DO_TRACK_BASED,
"Set to > 0 to do Track Based timing corrections");
144 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:DO_HIGH_RESOLUTION", DO_HIGH_RESOLUTION,
"Set to > 0 to increase the resolution of the track Based timing corrections");
145 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:DO_VERIFY", DO_VERIFY,
"Set to > 0 to verify timing with current constants");
146 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:REQUIRE_BEAM", REQUIRE_BEAM,
"Set to 0 to skip beam current check");
147 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:BEAM_EVENTS_TO_KEEP", BEAM_EVENTS_TO_KEEP,
"Set to the number of beam on events to use");
148 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:DO_OPTIONAL", DO_OPTIONAL,
"Set to >0 to enable optional histograms ");
149 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:DO_REACTION", DO_REACTION,
"Set to >0 to run DReaction");
150 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:USE_RF_BUNCH", USE_RF_BUNCH,
"Set to 0 to disable use of 2 vote RF Bunch");
151 gPARMS->SetDefaultParameter(
"HLDETECTORTIMING:NO_TRACKS", NO_TRACKS,
"Don't use tracking information for timing calibrations");
155 if (DO_ROUGH_TIMING > 0 || DO_CDC_TIMING > 0 || DO_TDC_ADC_ALIGN > 0 || DO_TRACK_BASED > 0) DO_VERIFY = 0;
158 if(DO_TDC_ADC_ALIGN){
159 NBINS_TDIFF = 2800; MIN_TDIFF = -150.0; MAX_TDIFF = 550.0;
162 NBINS_TDIFF = 200; MIN_TDIFF = -40.0; MAX_TDIFF = 40.0;
170 if (DO_HIGH_RESOLUTION) {
171 NBINS_TAGGER_TIME = 400; MIN_TAGGER_TIME = -20; MAX_TAGGER_TIME = 20;
172 NBINS_MATCHING = 1000; MIN_MATCHING_T = -10; MAX_MATCHING_T = 10;
174 NBINS_TAGGER_TIME = 1600; MIN_TAGGER_TIME = -200; MAX_TAGGER_TIME = 400;
176 NBINS_MATCHING = 800; MIN_MATCHING_T = -100; MAX_MATCHING_T = 100;
178 }
else if (DO_VERIFY){
179 NBINS_TAGGER_TIME = 200; MIN_TAGGER_TIME = -20; MAX_TAGGER_TIME = 20;
180 NBINS_MATCHING = 1000; MIN_MATCHING_T = -10; MAX_MATCHING_T = 10;
182 NBINS_TAGGER_TIME = 100; MIN_TAGGER_TIME = -50; MAX_TAGGER_TIME = 50;
183 NBINS_MATCHING = 100; MIN_MATCHING_T = -10; MAX_MATCHING_T = 10;
186 NBINS_RF_COMPARE = 200; MIN_RF_COMPARE = -2.2; MAX_RF_COMPARE = 2.2;
211 loop->GetSingle(locTrigger);
219 vector<const DParticleID *> locParticleID_algos;
220 loop->Get(locParticleID_algos);
221 if(locParticleID_algos.size()<1){
222 _DBG_<<
"Unable to get a DParticleID object! NO PID will be done!"<<endl;
223 return RESOURCE_UNAVAILABLE;
225 auto locParticleID = locParticleID_algos[0];
231 vector<const DDIRCGeometry*> locDIRCGeometryVec;
232 loop->Get(locDIRCGeometryVec);
233 const DDIRCGeometry* locDIRCGeometry = locDIRCGeometryVec[0];
237 loop->GetSingle(dDIRCLut);
240 vector<const DEPICSvalue *> epicsValues;
241 loop->Get(epicsValues);
242 for(
unsigned int j = 0; j < epicsValues.size(); j++){
244 if (strcmp((thisValue->
name).c_str(),
"IBCAD00CRCUR6") == 0){
245 BEAM_CURRENT = thisValue->
fval;
248 "Beam Current; Beam Current [nA]; Entries",
257 if (BEAM_CURRENT < 10.0) {
259 0,
"Beam On Events (0 = no beam, 1 = beam > 10nA)",
267 1,
"Beam On Events (0 = no beam, 1 = beam > 10nA)",
272 if (fBeamEventCounter >= BEAM_EVENTS_TO_KEEP) {
273 cout<<
"Maximum number of Beam Events reached" << endl;
279 vector<const DCDCHit *> cdcHitVector;
280 vector<const DFDCHit *> fdcHitVector;
281 vector<const DSCHit *> scHitVector;
282 vector<const DBCALUnifiedHit *> bcalUnifiedHitVector;
283 vector<const DTOFHit *> tofHitVector;
284 vector<const DFCALHit *> fcalHitVector;
285 vector<const DCCALHit *> ccalHitVector;
286 vector<const DDIRCPmtHit *> dircPmtHitVector;
287 vector<const DTAGMHit *> tagmHitVector;
288 vector<const DTAGHHit *> taghHitVector;
289 vector<const DPSHit *> psHitVector;
290 vector<const DPSCHit *> pscHitVector;
292 loop->Get(cdcHitVector);
293 loop->Get(fdcHitVector);
294 loop->Get(scHitVector);
295 loop->Get(bcalUnifiedHitVector);
296 loop->Get(tofHitVector);
297 loop->Get(fcalHitVector);
298 loop->Get(ccalHitVector);
299 loop->Get(dircPmtHitVector);
300 loop->Get(psHitVector);
301 loop->Get(pscHitVector);
302 loop->Get(tagmHitVector,
"Calib");
303 loop->Get(taghHitVector,
"Calib");
307 loop->GetSingle(locTTabUtilities);
311 float xMin = -500, xMax = 1500;
312 for (i = 0; i < cdcHitVector.size(); i++){
313 Fill1DHistogram (
"HLDetectorTiming",
"CDC",
"CDCHit time", cdcHitVector[i]->t,
314 "CDCHit time;t [ns];", nBins, xMin, xMax);
315 if(DO_VERIFY || DO_CDC_TIMING){
317 Fill2DHistogram(
"HLDetectorTiming",
"CDC",
"CDCHit time per Straw Raw",
318 cdcHitVector[i]->t, GetCCDBIndexCDC(cdcHitVector[i]),
319 "Hit time for each CDC wire; t [ns]; CCDB Index",
320 750, -500, 1000, nStraws, 0.5, nStraws + 0.5);
324 for (i = 0; i < fdcHitVector.size(); i++){
325 if(fdcHitVector[i]->type == 0 ) {
326 Fill1DHistogram (
"HLDetectorTiming",
"FDC",
"FDCHit Wire time", fdcHitVector[i]->t,
327 "FDCHit Wire time;t [ns];", nBins, xMin, xMax);
330 int module = 2 * fdcHitVector[i]->gLayer - 1;
331 if(fdcHitVector[i]->element > 48)
333 Fill2DHistogram (
"HLDetectorTiming",
"FDC",
"FDCHit Wire time vs. module",
334 module, fdcHitVector[i]->t,
335 "FDCHit Wire time; module/slot; t [ns];",
336 48, 0.5, 48.5, 400, -200, 600);
340 Fill1DHistogram (
"HLDetectorTiming",
"FDC",
"FDCHit Cathode time", fdcHitVector[i]->t,
341 "FDCHit Cathode time;t [ns];", nBins, xMin, xMax);
345 for (i = 0; i < scHitVector.size(); i++){
347 Fill1DHistogram (
"HLDetectorTiming",
"SC",
"SCHit time", scHitVector[i]->t,
348 "SCHit time;t [ns];", nBins, xMin, xMax);
351 for (i = 0; i < dircPmtHitVector.size(); i++){
352 Fill1DHistogram (
"HLDetectorTiming",
"DIRC",
"DIRCHit time", dircPmtHitVector[i]->t,
353 "DIRCHit time;t [ns];", nBins, xMin, xMax);
356 Fill2DHistogram (
"HLDetectorTiming",
"DIRC",
"DIRCHit North Per Channel TDC Hit Time",
357 dircPmtHitVector[i]->ch, dircPmtHitVector[i]->t,
358 "DIRCHit North Per Channel TDC Hit Time; channel ID; t_{TDC} [ns] ",
362 Fill2DHistogram (
"HLDetectorTiming",
"DIRC",
"DIRCHit South Per Channel TDC Hit Time",
364 "DIRCHit South Per Channel TDC Hit Time; channel ID; t_{TDC} [ns] ",
370 for (i = 0; i < bcalUnifiedHitVector.size(); i++){
371 int the_cell = (bcalUnifiedHitVector[i]->module - 1) * 16 + (bcalUnifiedHitVector[i]->
layer - 1) * 4 + bcalUnifiedHitVector[i]->sector;
373 int the_tdc_cell = (bcalUnifiedHitVector[i]->module - 1) * 12 + (bcalUnifiedHitVector[i]->
layer - 1) * 4 + bcalUnifiedHitVector[i]->sector;
377 bcalUnifiedHitVector[i]->GetSingle(thisADCHit);
378 bcalUnifiedHitVector[i]->GetSingle(thisTDCHit);
380 if (thisADCHit != NULL){
381 Fill1DHistogram (
"HLDetectorTiming",
"BCAL",
"BCALHit ADC time", thisADCHit->
t,
382 "BCALHit ADC time; t_{ADC} [ns]; Entries", nBins, xMin, xMax);
385 if (bcalUnifiedHitVector[i]->end == 0){
386 Fill2DHistogram (
"HLDetectorTiming",
"BCAL",
"BCALHit Upstream Per Channel ADC Hit Time",
387 the_cell, thisADCHit->
t,
388 "BCALHit Upstream Per Channel Hit Time; cellID; t_{ADC} [ns] ",
389 768, 0.5, 768.5, 250, -50, 50);
392 Fill2DHistogram (
"HLDetectorTiming",
"BCAL",
"BCALHit Downstream Per Channel ADC Hit Time",
393 the_cell, thisADCHit->
t,
394 "BCALHit Downstream Per Channel Hit Time; cellID; t_{ADC} [ns] ",
395 768, 0.5, 768.5, 250, -50, 50);
400 if (thisTDCHit != NULL){
401 Fill1DHistogram (
"HLDetectorTiming",
"BCAL",
"BCALHit TDC time", thisTDCHit->
t,
402 "BCALHit TDC time; t_{TDC} [ns]; Entries", nBins, xMin, xMax);
405 if (bcalUnifiedHitVector[i]->end == 0){
406 Fill2DHistogram (
"HLDetectorTiming",
"BCAL",
"BCALHit Upstream Per Channel TDC Hit Time",
407 the_tdc_cell, thisTDCHit->
t,
408 "BCALHit Upstream Per Channel TDC Hit Time; cellID; t_{TDC} [ns] ",
409 576, 0.5, 576.5, 350, -50, 300);
412 Fill2DHistogram (
"HLDetectorTiming",
"BCAL",
"BCALHit Downstream Per Channel TDC Hit Time",
413 the_tdc_cell, thisTDCHit->
t,
414 "BCALHit Downstream Per Channel TDC Hit Time; cellID; t_{TDC} [ns] ",
415 576, 0.5, 576.5, 350, -50, 300);
420 if (thisADCHit != NULL && thisTDCHit != NULL){
421 if (bcalUnifiedHitVector[i]->end == 0){
422 Fill2DHistogram (
"HLDetectorTiming",
"BCAL",
"BCALHit Upstream Per Channel TDC-ADC Hit Time",
423 the_tdc_cell, thisTDCHit->
t - thisADCHit->
t,
424 "BCALHit Upstream Per Channel TDC-ADC Hit Time; cellID; t_{TDC} - t_{ADC} [ns] ",
425 576, 0.5, 576.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
428 Fill2DHistogram (
"HLDetectorTiming",
"BCAL",
"BCALHit Downstream Per Channel TDC-ADC Hit Time",
429 the_tdc_cell, thisTDCHit->
t - thisADCHit->
t,
430 "BCALHit Downstream Per Channel TDC-ADC Hit Time; cellID; t_{TDC} - t_{ADC} [ns] ",
431 576, 0.5, 576.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
436 for (i = 0; i < tofHitVector.size(); i++){
437 Fill1DHistogram (
"HLDetectorTiming",
"TOF",
"TOFHit time", tofHitVector[i]->t,
438 "TOFHit time;t [ns];", nBins, xMin, xMax);
441 for (i = 0; i < psHitVector.size(); i++){
442 int nColumns = 145*2;
443 Fill1DHistogram (
"HLDetectorTiming",
"PS",
"PSHit time", psHitVector[i]->t,
444 "PSHit time;t [ns];", nBins, xMin, xMax);
447 psHitVector[i]->t, psHitVector[i]->
column+psHitVector[i]->arm*nColumns/2,
448 "Hit time for each PS column; t [ns]; CCDB Index",
449 nBins, xMin, xMax, nColumns, 0.5, nColumns + 0.5);
453 double fcalHitETot = 0;
454 double fcalHitEwtT = 0;
455 for (i = 0; i < fcalHitVector.size(); i++){
456 fcalHitETot += fcalHitVector[i]->E;
457 fcalHitEwtT += fcalHitVector[i]->E * fcalHitVector[i]->t;
459 fcalHitEwtT /= fcalHitETot;
462 vector<const DFCALGeometry*> fcalGeomVect;
463 loop->Get( fcalGeomVect );
464 if (fcalGeomVect.size() < 1){
465 cout <<
"FCAL Geometry not available?" << endl;
466 return OBJECT_NOT_AVAILABLE;
470 for (i = 0; i < fcalHitVector.size(); i++){
471 Fill1DHistogram (
"HLDetectorTiming",
"FCAL",
"FCALHit time", fcalHitVector[i]->t,
472 "FCALHit time;t [ns];", nBins, xMin, xMax);
475 fcalHitVector[i]->row, fcalHitVector[i]->
column,
476 "FCAL Hit Occupancy; column; row",
477 61, -1.5, 59.5, 61, -1.5, 59.5);
478 double locTime = ( fcalHitVector[i]->t - fcalHitEwtT )*
k_to_nsec;
481 fcalHitVector[i]->row, fcalHitVector[i]->
column, locTime,
482 "FCAL Hit Local Time [ns]; column; row",
483 61, -1.5, 59.5, 61, -1.5, 59.5);
486 Fill2DHistogram(
"HLDetectorTiming",
"FCAL",
"FCALHit Per Channel Time",
487 fcalGeom.
channel(fcalHitVector[i]->row, fcalHitVector[i]->column), fcalHitVector[i]->t,
488 "FCAL Per Channel Hit time; channel; t [ns]",
493 Fill1DHistogram (
"HLDetectorTiming",
"FCAL",
"FCAL total energy", fcalHitETot,
494 "FCAL total energy;", 400, 0, 8000);
498 double ccalHitETot = 0;
499 double ccalHitEwtT = 0;
500 for (i = 0; i < ccalHitVector.size(); i++){
501 ccalHitETot += ccalHitVector[i]->E;
502 ccalHitEwtT += ccalHitVector[i]->E * ccalHitVector[i]->t;
504 ccalHitEwtT /= ccalHitETot;
507 vector<const DCCALGeometry*> ccalGeomVect;
508 loop->Get( ccalGeomVect );
509 if (ccalGeomVect.size() < 1){
510 cout <<
"CCAL Geometry not available?" << endl;
512 for (i = 0; i < ccalHitVector.size(); i++){
513 Fill1DHistogram (
"HLDetectorTiming",
"CCAL",
"CCALHit time", ccalHitVector[i]->t,
514 "CCALHit time;t [ns];", nBins, xMin, xMax);
517 for (i = 0; i < ccalHitVector.size(); i++) {
519 ccalHitVector[i]->row, ccalHitVector[i]->
column,
520 "CCAL Hit Occupancy; column; row",
521 13, -1.5, 11.5, 13, -1.5, 11.5);
522 double locTime = ( ccalHitVector[i]->t - ccalHitEwtT )*
k_to_nsec;
525 ccalHitVector[i]->row, ccalHitVector[i]->
column, locTime,
526 "CCAL Hit Local Time [ns]; column; row",
527 13, -1.5, 11.5, 13, -1.5, 11.5);
532 for (i = 0; i < tagmHitVector.size(); i++){
533 Fill1DHistogram (
"HLDetectorTiming",
"TAGM",
"TAGMHit time", tagmHitVector[i]->t,
534 "TAGMHit time;t [ns];", nBins, xMin, xMax);
536 for (i = 0; i < taghHitVector.size(); i++){
537 Fill1DHistogram (
"HLDetectorTiming",
"TAGH",
"TAGHHit time", taghHitVector[i]->t,
538 "TAGHHit time;t [ns];", nBins, xMin, xMax);
545 for (i = 0; i < scHitVector.size(); i++){
546 int nSCCounters = 30;
547 const DSCHit *thisSCHit = scHitVector[i];
549 Fill1DHistogram (
"HLDetectorTiming",
"SC",
"SCHit ADC time", scHitVector[i]->t,
550 "SCHit ADC only time;t [ns];", nBins, xMin, xMax);
552 for (
auto hit = scHitVector.begin(); hit != scHitVector.end(); hit++){
553 if ((*hit)->has_TDC && !(*hit)->has_fADC){
554 if (scHitVector[i]->sector == (*hit)->sector){
556 scHitVector[i]->sector, (*hit)->t_TDC - scHitVector[i]->t_fADC,
557 "SC #Deltat TDC-ADC; Sector ;t_{TDC} - t_{ADC} [ns]", nSCCounters, 0.5, nSCCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
563 Fill1DHistogram (
"HLDetectorTiming",
"SC",
"SCHit TDC time", scHitVector[i]->t,
564 "SCHit TDC only time;t [ns];", nBins, xMin, xMax);
567 Fill1DHistogram (
"HLDetectorTiming",
"SC",
"SCHit Matched time", scHitVector[i]->t,
568 "SCHit Matched ADC/TDC time;t [ns];", nBins, xMin, xMax);
569 Fill1DHistogram (
"HLDetectorTiming",
"SC",
"SCHit ADC time", scHitVector[i]->t_fADC,
570 "SCHit ADC only time;t [ns];", nBins, xMin, xMax);
571 Fill1DHistogram (
"HLDetectorTiming",
"SC",
"SCHit TDC time", scHitVector[i]->t_TDC,
572 "SCHit TDC only time;t [ns];", nBins, xMin, xMax);
575 scHitVector[i]->sector, scHitVector[i]->t_TDC - scHitVector[i]->t_fADC,
576 "SC #Deltat TDC-ADC; Sector ;t_{TDC} - t_{ADC} [ns]", nSCCounters, 0.5, nSCCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
580 for (i = 0; i < tagmHitVector.size(); i++){
582 const DTAGMHit *thisTAGMHit = tagmHitVector[i];
583 int nTAGMCounters = 122;
586 Fill1DHistogram (
"HLDetectorTiming",
"TAGM",
"TAGMHit ADC time", tagmHitVector[i]->t,
587 "TAGMHit ADC only time;t [ns];", nBins, xMin, xMax);
589 for (
auto hit = tagmHitVector.begin(); hit != tagmHitVector.end(); hit++){
590 if ((*hit)->has_TDC && !(*hit)->has_fADC){
592 Fill2DHistogram(
"HLDetectorTiming",
"TAGM",
"TAGMHit TDC_ADC Difference",
593 GetCCDBIndexTAGM(tagmHitVector[i]), (*hit)->t - tagmHitVector[i]->time_fadc,
595 "TAGM #Deltat TDC-ADC; Column ;t_{TDC} - t_{ADC} [ns]", nTAGMCounters, 0.5, nTAGMCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
601 Fill1DHistogram (
"HLDetectorTiming",
"TAGM",
"TAGMHit TDC time", tagmHitVector[i]->t,
602 "TAGMHit TDC only time;t [ns];", nBins, xMin, xMax);
605 Fill1DHistogram (
"HLDetectorTiming",
"TAGM",
"TAGMHit Matched time", tagmHitVector[i]->t,
606 "TAGMHit Matched ADC/TDC time;t [ns];", nBins, xMin, xMax);
607 Fill1DHistogram (
"HLDetectorTiming",
"TAGM",
"TAGMHit ADC time", tagmHitVector[i]->time_fadc,
608 "TAGMHit ADC only time;t [ns];", nBins, xMin, xMax);
609 Fill1DHistogram (
"HLDetectorTiming",
"TAGM",
"TAGMHit TDC time", tagmHitVector[i]->t,
610 "TAGMHit TDC only time;t [ns];", nBins, xMin, xMax);
612 Fill2DHistogram(
"HLDetectorTiming",
"TAGM",
"TAGMHit TDC_ADC Difference",
613 GetCCDBIndexTAGM(tagmHitVector[i]), tagmHitVector[i]->t - tagmHitVector[i]->time_fadc,
614 "TAGM #Deltat TDC-ADC; Column ;t_{TDC} - t_{ADC} [ns]", nTAGMCounters, 0.5, nTAGMCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
616 Fill2DHistogram(
"HLDetectorTiming",
"TAGM",
"TAGM Per Channel TDC Time",
618 "TAGM Per Channel TDC time; Column ;t_{TDC} [ns]", nTAGMCounters, 0.5, nTAGMCounters + 0.5, 100, -50, 50);
624 for (i = 0; i < taghHitVector.size(); i++){
626 const DTAGHHit *thisTAGHHit = taghHitVector[i];
627 int nTAGHCounters = 274;
630 Fill1DHistogram (
"HLDetectorTiming",
"TAGH",
"TAGHHit ADC time", taghHitVector[i]->t,
631 "TAGHHit ADC only time;t [ns];", nBins, xMin, xMax);
633 for (
auto hit = taghHitVector.begin(); hit != taghHitVector.end(); hit++){
634 if ((*hit)->has_TDC && !(*hit)->has_fADC){
635 if (taghHitVector[i]->counter_id == (*hit)->counter_id){
636 Fill2DHistogram(
"HLDetectorTiming",
"TAGH",
"TAGHHit TDC_ADC Difference",
637 taghHitVector[i]->counter_id, (*hit)->time_tdc - taghHitVector[i]->time_fadc,
638 "TAGH #Deltat TDC-ADC; Counter ID ;t_{TDC} - t_{ADC} [ns]", nTAGHCounters, 0.5, nTAGHCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
644 Fill1DHistogram (
"HLDetectorTiming",
"TAGH",
"TAGHHit TDC time", taghHitVector[i]->t,
645 "TAGHHit TDC only time;t [ns];", nBins, xMin, xMax);
648 Fill1DHistogram (
"HLDetectorTiming",
"TAGH",
"TAGHHit Matched time", taghHitVector[i]->t,
649 "TAGHHit Matched ADC/TDC time;t [ns];", nBins, xMin, xMax);
650 Fill1DHistogram (
"HLDetectorTiming",
"TAGH",
"TAGHHit ADC time", taghHitVector[i]->time_fadc,
651 "TAGHHit ADC only time;t [ns];", nBins, xMin, xMax);
652 Fill1DHistogram (
"HLDetectorTiming",
"TAGH",
"TAGHHit TDC time", taghHitVector[i]->time_tdc,
653 "TAGHHit TDC only time;t [ns];", nBins, xMin, xMax);
656 Fill2DHistogram(
"HLDetectorTiming",
"TAGH",
"TAGHHit TDC_ADC Difference",
657 taghHitVector[i]->counter_id, taghHitVector[i]->time_tdc - taghHitVector[i]->time_fadc,
658 "TAGH #Deltat TDC-ADC; Counter ID ;t_{TDC} - t_{ADC} [ns]", nTAGHCounters, 0.5, nTAGHCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
661 for (i = 0; i < tofHitVector.size(); i++){
662 const DTOFHit *thisTOFHit = tofHitVector[i];
663 int nTOFCounters = 176;
665 Fill1DHistogram (
"HLDetectorTiming",
"TOF",
"TOFHit ADC time", tofHitVector[i]->t,
666 "TOFHit ADC only time;t [ns];", nBins, xMin, xMax);
668 for (
auto hit = tofHitVector.begin(); hit != tofHitVector.end(); hit++){
669 if ((*hit)->has_TDC && !(*hit)->has_fADC){
670 if (GetCCDBIndexTOF(tofHitVector[i]) == GetCCDBIndexTOF(*hit)){
671 Fill2DHistogram(
"HLDetectorTiming",
"TOF",
"TOFHit TDC_ADC Difference",
672 GetCCDBIndexTOF(tofHitVector[i]), (*hit)->t_TDC - tofHitVector[i]->t_fADC,
673 "TOF #Deltat TDC-ADC; CDCB Index ;t_{TDC} - t_{ADC} [ns]", nTOFCounters, 0.5, nTOFCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
679 Fill1DHistogram (
"HLDetectorTiming",
"TOF",
"TOFHit TDC time", tofHitVector[i]->t,
680 "TOFHit TDC only time;t [ns];", nBins, xMin, xMax);
683 Fill1DHistogram (
"HLDetectorTiming",
"TOF",
"TOFHit Matched time", tofHitVector[i]->t,
684 "TOFHit Matched ADC/TDC time;t [ns];", nBins, xMin, xMax);
685 Fill1DHistogram (
"HLDetectorTiming",
"TOF",
"TOFHit ADC time", tofHitVector[i]->t_fADC,
686 "TOFHit ADC only time;t [ns];", nBins, xMin, xMax);
687 Fill1DHistogram (
"HLDetectorTiming",
"TOF",
"TOFHit TDC time", tofHitVector[i]->t_TDC,
688 "TOFHit TDC only time;t [ns];", nBins, xMin, xMax);
690 Fill2DHistogram(
"HLDetectorTiming",
"TOF",
"TOFHit TDC_ADC Difference",
691 GetCCDBIndexTOF(tofHitVector[i]), tofHitVector[i]->t_TDC - tofHitVector[i]->t_fADC,
692 "TOF #Deltat TDC-ADC; CDCB Index ;t_{TDC} - t_{ADC} [ns]", nTOFCounters, 0.5, nTOFCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
695 for (i = 0; i < pscHitVector.size(); i++){
696 int nPSCCounters = 16;
697 const DPSCHit *thisPSCHit = pscHitVector[i];
699 Fill1DHistogram (
"HLDetectorTiming",
"PS",
"PSCHit ADC time", pscHitVector[i]->t,
700 "PSCHit ADC only time;t [ns];", nBins, xMin, xMax);
702 for (
auto hit = pscHitVector.begin(); hit != pscHitVector.end(); hit++){
703 if ((*hit)->has_TDC && !(*hit)->has_fADC){
704 if ( (pscHitVector[i]->arm == (*hit)->arm) && (pscHitVector[i]->module == (*hit)->module) ) {
706 pscHitVector[i]->module+pscHitVector[i]->arm*nPSCCounters/2, (*hit)->time_tdc - pscHitVector[i]->time_fadc,
707 "PSC #Deltat TDC-ADC; Sector ;t_{TDC} - t_{ADC} [ns]", nPSCCounters, 0.5, nPSCCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
713 Fill1DHistogram (
"HLDetectorTiming",
"PS",
"PSCHit TDC time", pscHitVector[i]->t,
714 "PSCHit TDC only time;t [ns];", nBins, xMin, xMax);
717 Fill1DHistogram (
"HLDetectorTiming",
"PS",
"PSCHit Matched time", pscHitVector[i]->t,
718 "PSCHit Matched ADC/TDC time;t [ns];", nBins, xMin, xMax);
719 Fill1DHistogram (
"HLDetectorTiming",
"PS",
"PSCHit ADC time", pscHitVector[i]->time_fadc,
720 "PSCHit ADC only time;t [ns];", nBins, xMin, xMax);
721 Fill1DHistogram (
"HLDetectorTiming",
"PS",
"PSCHit TDC time", pscHitVector[i]->time_tdc,
722 "PSCHit TDC only time;t [ns];", nBins, xMin, xMax);
725 pscHitVector[i]->module+pscHitVector[i]->arm*nPSCCounters/2, pscHitVector[i]->time_tdc - pscHitVector[i]->time_fadc,
726 "PSC #Deltat TDC-ADC; Sector ;t_{TDC} - t_{ADC} [ns]", nPSCCounters, 0.5, nPSCCounters + 0.5, NBINS_TDIFF, MIN_TDIFF, MAX_TDIFF);
737 float nBinsE = 160, EMin = 3.0, EMax = 12.0;
743 loop->GetSingle(thisRFBunch,
"CalorimeterOnly");
745 loop->GetSingle(thisRFBunch,
"Calibrations");
750 for (
unsigned int j = 0 ; j < tagmHitVector.size(); j++){
751 int nTAGMColumns = 122;
752 if(tagmHitVector[j]->has_fADC){
755 sprintf(name,
"Column %.3i Row %.1i", tagmHitVector[j]->
column, tagmHitVector[j]->row);
756 sprintf(title,
"TAGM Column %i t_{ADC} - t_{RF}; t_{ADC} - t_{RF} [ns]; Entries", tagmHitVector[j]->
column);
759 tagmHitVector[j]->time_fadc - locShiftedTime,
761 NBINS_RF_COMPARE, MIN_RF_COMPARE, MAX_RF_COMPARE);
764 if(tagmHitVector[j]->has_TDC){
767 sprintf(name,
"Column %.3i Row %.1i", tagmHitVector[j]->
column, tagmHitVector[j]->row);
768 sprintf(title,
"TAGM Column %i t_{TDC} - t_{RF}; t_{TDC} - t_{RF} [ns]; Entries", tagmHitVector[j]->
column);
771 tagmHitVector[j]->t - locShiftedTime,
773 NBINS_RF_COMPARE, MIN_RF_COMPARE, MAX_RF_COMPARE);
778 "#Deltat TAGM-RFBunch; CCDB Index ;t_{TAGM} - t_{SC @ target} [ns]",
779 nTAGMColumns, 0.5, nTAGMColumns + 0.5, NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME);
780 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - RFBunch Time",
781 tagmHitVector[j]->t - thisRFBunch->
dTime, tagmHitVector[j]->E,
782 "Tagger - RFBunch Time; #Deltat_{Tagger - SC} [ns]; Energy [GeV]",
783 NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME, nBinsE, EMin, EMax);
784 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - RFBunch 1D Time",
785 tagmHitVector[j]->t - thisRFBunch->
dTime,
786 "Tagger - RFBunch Time; #Deltat_{Tagger - RFBunch} [ns]; Entries",
789 if (tagmHitVector[j]->row == 0){
790 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"TAGM - RFBunch 1D Time",
791 tagmHitVector[j]->t - thisRFBunch->
dTime,
792 "TAGM - RFBunch Time; #Deltat_{TAGM - RFBunch} [ns]; Entries",
799 for (
unsigned int j = 0 ; j < taghHitVector.size(); j++){
800 int nTAGHCounters = 274;
802 if(taghHitVector[j]->has_fADC){
805 sprintf(name,
"Counter ID %.3i", taghHitVector[j]->counter_id);
806 sprintf(title,
"TAGH Counter ID %i t_{ADC} - t_{RF}; t_{ADC} - t_{RF} [ns]; Entries", taghHitVector[j]->counter_id);
809 taghHitVector[j]->time_fadc - locShiftedTime,
811 NBINS_RF_COMPARE, MIN_RF_COMPARE, MAX_RF_COMPARE);
813 if(taghHitVector[j]->has_TDC){
816 sprintf(name,
"Counter ID %.3i", taghHitVector[j]->counter_id);
817 sprintf(title,
"TAGH Counter ID %i t_{TDC} - t_{RF}; t_{TDC} - t_{RF} [ns]; Entries", taghHitVector[j]->counter_id);
820 taghHitVector[j]->time_tdc - locShiftedTime,
822 NBINS_RF_COMPARE, MIN_RF_COMPARE, MAX_RF_COMPARE);
826 taghHitVector[j]->counter_id, taghHitVector[j]->t - thisRFBunch->
dTime,
827 "#Deltat TAGH-RFBunch; Counter ID ;t_{TAGH} - t_{RFBunch} [ns]",
828 nTAGHCounters, 0.5, nTAGHCounters + 0.5, NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME);
830 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - RFBunch Time",
831 taghHitVector[j]->t - thisRFBunch->
dTime, taghHitVector[j]->E,
832 "Tagger - RFBunch Time; #Deltat_{Tagger - RFBunch} [ns]; Energy [GeV]",
833 NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME, nBinsE, EMin, EMax);
835 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - RFBunch 1D Time",
836 taghHitVector[j]->t - thisRFBunch->
dTime,
837 "Tagger - RFBunch Time; #Deltat_{Tagger - RFBunch} [ns]; Entries",
842 vector<const DNeutralShower *> neutralShowerVector;
843 loop->Get(neutralShowerVector);
849 for (i = 0; i < neutralShowerVector.size(); i++){
850 double locPathLength = (neutralShowerVector[i]->dSpacetimeVertex.Vect() - locTargetCenter).Mag();
851 double locDeltaT = neutralShowerVector[i]->dSpacetimeVertex.T() - locPathLength/29.9792458 - thisRFBunch->
dTime;
855 if(neutralShowerVector[i]->dDetectorSystem ==
SYS_FCAL) {
856 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"FCAL - RF Time vs. Energy (Neutral)", neutralShowerVector[i]->dEnergy, locDeltaT,
857 "Shower Energy [GeV]; t_{FCAL} - t_{RF} at Target (Neutral); t_{FCAL} - t_{RF} [ns]; Entries",
858 100, 0., 10., NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
859 if(neutralShowerVector[i]->dEnergy > 0.2) {
860 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"FCAL - RF Time (Neutral)", locDeltaT,
861 "t_{FCAL} - t_{RF} at Target (Neutral); t_{FCAL} - t_{RF} [ns]; Entries",
862 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
865 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"BCAL - RF Time vs. Energy (Neutral)", neutralShowerVector[i]->dEnergy, locDeltaT,
866 "Shower Energy [GeV];t_{BCAL} - t_{RF} at Target (Neutral); t_{BCAL} - t_{RF} [ns]; Entries",
867 100, 0., 10., NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
868 if(neutralShowerVector[i]->dEnergy > 0.1) {
869 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"BCAL - RF Time (Neutral)", locDeltaT,
870 "t_{BCAL} - t_{RF} at Target (Neutral); t_{BCAL} - t_{RF} [ns]; Entries",
871 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
877 vector<const DCCALShower *> ccalShowerVector;
878 loop->Get(ccalShowerVector);
880 for (i = 0; i < ccalShowerVector.size(); i++){
881 DVector3 locShowerPos(ccalShowerVector[i]->
x, ccalShowerVector[i]->
y, ccalShowerVector[i]->z);
883 double locPathLength = (locShowerPos - locTargetCenter).Mag();
884 double locDeltaT = ccalShowerVector[i]->time - locPathLength/29.9792458 - thisRFBunch->
dTime;
886 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"CCAL - RF Time vs. Energy (Neutral)", ccalShowerVector[i]->E, locDeltaT,
887 "Shower Energy [GeV];t_{CCAL} - t_{RF} at Target (Neutral); t_{CCAL} - t_{RF} [ns]; Entries",
888 100, 0., 10., 200, -20, 20);
891 if(ccalShowerVector[i]->E > 0.1) {
892 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"CCAL - RF Time (Neutral)", locDeltaT,
893 "t_{CCAL} - t_{RF} at Target (Neutral); t_{CCAL} - t_{RF} [ns]; Entries",
903 if (!DO_TRACK_BASED && !DO_VERIFY )
return NOERROR;
908 vector<const DChargedTrack *> chargedTrackVector;
909 loop->Get(chargedTrackVector);
911 for (i = 0; i < chargedTrackVector.size(); i++){
914 if (chargedTrackVector[i]->Get_Charge() > 0)
continue;
917 if (pionHypothesis == NULL)
continue;
920 double trackingFOM = TMath::Prob(locTrackTimeBased->chisq, locTrackTimeBased->Ndof);
925 float trackingFOMCut = 2.87E-7;
926 int trackingNDFCut = 5;
928 if(trackingFOM < trackingFOMCut)
continue;
929 if( locTrackTimeBased->Ndof < trackingNDFCut)
continue;
940 if (locSCHitMatchParams == NULL)
continue;
946 float flightTimeCorrectedSCTime = locSCHitMatchParams->dHitTime - locSCHitMatchParams->dFlightTime - targetCenterCorrection;
949 sprintf(name,
"Sector %.2i", locSCHitMatchParams->dSCHit->sector);
950 sprintf(title,
"SC Sector %i t_{Target} - t_{RF}; t_{Target} - t_{RF} [ns]; Entries", locSCHitMatchParams->dSCHit->sector);
952 double locSCDeltaT = flightTimeCorrectedSCTime - thisRFBunch->
dTime;
954 flightTimeCorrectedSCTime - locShiftedTime,
956 NBINS_RF_COMPARE, MIN_RF_COMPARE, MAX_RF_COMPARE);
958 flightTimeCorrectedSCTime - thisRFBunch->
dTime,
959 "t_{SC} - t_{RF} at Target; t_{SC} - t_{RF} at Target [ns]; Entries",
960 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
967 DVector3 IntersectionPoint, IntersectionMomentum;
968 vector<DTrackFitter::Extrapolation_t> extrapolations = locTrackTimeBased->extrapolations.at(
SYS_START);
969 shared_ptr<DSCHitMatchParams> locSCHitMatchParams2;
970 bool sc_match_pid = locParticleID->Cut_MatchDistance(extrapolations, locSCHitMatchParams->dSCHit, locSCHitMatchParams->dSCHit->t, locSCHitMatchParams2,
971 true, &IntersectionPoint, &IntersectionMomentum);
972 double locSCzIntersection = IntersectionPoint.z();
973 if( locSCzIntersection < 83. ) {
975 flightTimeCorrectedSCTime - locShiftedTime,
977 NBINS_RF_COMPARE, MIN_RF_COMPARE, MAX_RF_COMPARE);
979 flightTimeCorrectedSCTime - thisRFBunch->
dTime,
980 "t_{SC} - t_{RF} at Target; t_{SC} - t_{RF} at Target [ns]; Entries",
981 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
982 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"SC - RF Time vs. Sector",
983 locSCHitMatchParams->dSCHit->sector, locSCDeltaT,
984 "t_{SC} - t_{RF} at Target; Sector; t_{SC} - t_{RF} at Target [ns];",
985 30, 0.5, 30.5, 800, -20., 20.);
991 vector<DTrackFitter::pull_t> pulls = thisTimeBasedTrack->
pulls;
992 double earliestCDCTime = 10000.;
993 double earliestFDCTime = 10000.;
994 for (
size_t iPull = 0; iPull < pulls.size(); iPull++){
995 if ( pulls[iPull].
cdc_hit !=
nullptr && pulls[iPull].tdrift < earliestCDCTime) earliestCDCTime = pulls[iPull].tdrift;
996 if ( pulls[iPull].fdc_hit !=
nullptr && pulls[iPull].tdrift < earliestFDCTime) earliestFDCTime = pulls[iPull].tdrift;
1000 vector < const DCDCTrackHit *> cdcTrackHitVector;
1002 if (cdcTrackHitVector.size() != 0){
1003 float earliestTime = 10000;
1004 for (
unsigned int iCDC = 0; iCDC < cdcTrackHitVector.size(); iCDC++){
1005 if (cdcTrackHitVector[iCDC]->tdrift < earliestTime) earliestTime = cdcTrackHitVector[iCDC]->tdrift;
1008 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"Earliest CDC Time Minus Matched SC Time",
1009 earliestTime - locSCHitMatchParams->dHitTime,
1010 "Earliest CDC Time Minus Matched SC Time; t_{CDC} - t_{SC} [ns];",
1015 for (
unsigned int j = 0 ; j < tagmHitVector.size(); j++){
1016 int nTAGMColumns = 122;
1018 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"TAGM - SC Target Time",
1019 GetCCDBIndexTAGM(tagmHitVector[j]), tagmHitVector[j]->t - flightTimeCorrectedSCTime,
1020 "#Deltat TAGM-SC; Column ;t_{TAGM} - t_{SC @ target} [ns]", nTAGMColumns, 0.5, nTAGMColumns + 0.5, NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME);
1021 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - SC Target Time",
1022 tagmHitVector[j]->t - flightTimeCorrectedSCTime, tagmHitVector[j]->E,
1023 "Tagger - SC Target Time; #Deltat_{Tagger - SC} [ns]; Energy [GeV]",
1024 NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME, nBinsE, EMin, EMax);
1025 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - SC 1D Target Time",
1026 tagmHitVector[j]->t - flightTimeCorrectedSCTime,
1027 "Tagger - SC Time at Target; #Deltat_{Tagger - SC} [ns]; Entries",
1031 for (
unsigned int j = 0 ; j < taghHitVector.size(); j++){
1032 int nTAGHCounters = 274;
1033 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"TAGH - SC Target Time",
1034 taghHitVector[j]->counter_id, taghHitVector[j]->t - flightTimeCorrectedSCTime,
1035 "#Deltat TAGH-SC; Counter ID ;t_{TAGH} - t_{SC @ target} [ns]", nTAGHCounters, 0.5, nTAGHCounters + 0.5, NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME);
1037 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - SC Target Time",
1038 taghHitVector[j]->t - flightTimeCorrectedSCTime, taghHitVector[j]->E,
1039 "Tagger - SC Target Time; #Deltat_{Tagger - SC} [ns]; Energy [GeV]",
1040 NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME, nBinsE, EMin, EMax);
1042 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - SC 1D Target Time",
1043 taghHitVector[j]->t - flightTimeCorrectedSCTime,
1044 "Tagger - SC Time at Target; #Deltat_{Tagger - SC} [ns]; Entries",
1048 if (locTOFHitMatchParams != NULL){
1050 float flightTimeCorrectedTOFTime = locTOFHitMatchParams->dHitTime - locTOFHitMatchParams->dFlightTime - targetCenterCorrection;
1051 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"TOF - SC Target Time",
1052 flightTimeCorrectedTOFTime - flightTimeCorrectedSCTime,
1053 "t_{TOF} - t_{SC} at Target; t_{TOF} - t_{SC} at Target [ns]; Entries",
1054 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
1056 flightTimeCorrectedTOFTime - thisRFBunch->
dTime,
1057 "t_{TOF} - t_{RF} at Target; t_{TOF} - t_{RF} at Target [ns]; Entries",
1058 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
1060 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"Earliest Flight-time Corrected FDC Time",
1062 "Earliest Flight-time corrected FDC Time; t_{FDC} [ns];",
1067 loop->GetSingle(locDetectorMatches);
1069 shared_ptr<const DDIRCMatchParams> locDIRCMatchParams;
1070 bool foundDIRC = locParticleID->
Get_DIRCMatchParams(locTrackTimeBased, locDetectorMatches, locDIRCMatchParams);
1073 if(foundDIRC && locTOFHitMatchParams->dDeltaXToHit < 10.0 && locTOFHitMatchParams->dDeltaYToHit < 10.0) {
1076 TVector3 posInBar = locDIRCMatchParams->dExtrapolatedPos;
1077 TVector3 momInBar = locDIRCMatchParams->dExtrapolatedMom;
1078 double locExpectedThetaC = locDIRCMatchParams->dExpectedThetaC;
1079 double locExtrapolatedTime = locDIRCMatchParams->dExtrapolatedTime;
1080 int locBar = locDIRCGeometry->
GetBar(posInBar.Y());
1082 Particle_t locPID = locTrackTimeBased->PID();
1084 double locAngle = dDIRCLut->
CalcAngle(momInBar, locMass);
1088 map<shared_ptr<const DDIRCMatchParams>, vector<const DDIRCPmtHit*> > locDIRCTrackMatchParamsMap;
1090 map<Particle_t, double> logLikelihoodSum;
1093 for(uint loc_i=0; loc_i<dircPmtHitVector.size(); loc_i++) {
1094 vector<pair<double, double>> locDIRCPhotons = dDIRCLut->
CalcPhoton(dircPmtHitVector[loc_i], locExtrapolatedTime, posInBar, momInBar, locExpectedAngle, locAngle, locPID, logLikelihoodSum);
1095 double locHitTime = dircPmtHitVector[loc_i]->t - locExtrapolatedTime;
1096 int locChannel = dircPmtHitVector[loc_i]->ch%dMaxDIRCChannels;
1098 if(locDIRCPhotons.size() > 0) {
1100 for(uint loc_j = 0; loc_j<locDIRCPhotons.size(); loc_j++) {
1101 double locDeltaT = locDIRCPhotons[loc_j].first - locHitTime;
1104 Fill2DHistogram (
"HLDetectorTiming",
"DIRC",
"DIRCHit North Per Channel t_{DIRC} - t_{track}",
1105 locChannel, locDeltaT,
1106 "DIRCHit North Per Channel t_{DIRC} - t_{track}; channel ID; t_{DIRC} - t_{track} [ns] ",
1110 Fill2DHistogram (
"HLDetectorTiming",
"DIRC",
"DIRCHit South Per Channel t_{DIRC} - t_{track}",
1112 "DIRCHit South Per Channel t_{DIRC} - t_{track}; channel ID; t_{DIRC} - t_{track} [ns] ",
1121 if (locBCALShowerMatchParams != NULL){
1122 float flightTimeCorrectedBCALTime = locBCALShowerMatchParams->dBCALShower->t - locBCALShowerMatchParams->dFlightTime - targetCenterCorrection;
1123 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"BCAL - SC Target Time",
1124 flightTimeCorrectedBCALTime - flightTimeCorrectedSCTime,
1125 "t_{BCAL} - t_{SC} at Target; t_{BCAL} - t_{SC} [ns]; Entries",
1126 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
1128 flightTimeCorrectedBCALTime - thisRFBunch->
dTime,
1129 "t_{BCAL} - t_{RF} at Target; t_{BCAL} - t_{RF} [ns]; Entries",
1130 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
1132 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"BCAL - SC Target Time Vs Correction",
1133 locBCALShowerMatchParams->dFlightTime, flightTimeCorrectedBCALTime - flightTimeCorrectedSCTime,
1134 "t_{BCAL} - t_{SC} at Target; Flight time [ns]; t_{BCAL} - t_{SC} [ns]",
1135 100, 0, 20, 50, -10, 10);
1137 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"Earliest Flight-time Corrected CDC Time",
1139 "Earliest Flight-time Corrected CDC Time; t_{CDC} [ns];",
1142 if (locFCALShowerMatchParams != NULL){
1143 float flightTimeCorrectedFCALTime = locFCALShowerMatchParams->dFCALShower->getTime() - locFCALShowerMatchParams->dFlightTime - targetCenterCorrection;
1144 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"FCAL - SC Target Time",
1145 flightTimeCorrectedFCALTime - flightTimeCorrectedSCTime,
1146 "t_{FCAL} - t_{SC} at Target; t_{FCAL} - t_{SC} [ns]; Entries",
1147 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
1149 flightTimeCorrectedFCALTime - thisRFBunch->
dTime,
1150 "t_{FCAL} - t_{RF} at Target; t_{FCAL} - t_{RF} [ns]; Entries",
1151 NBINS_MATCHING, MIN_MATCHING_T, MAX_MATCHING_T);
1158 vector<const DAnalysisResults*> locAnalysisResultsVector;
1159 loop->Get(locAnalysisResultsVector);
1161 deque<const DParticleCombo*> locPassedParticleCombos;
1162 locAnalysisResultsVector[0]->Get_PassedParticleCombos(locPassedParticleCombos);
1164 for (i=0; i < locPassedParticleCombos.size(); i++){
1165 double taggerTime = locPassedParticleCombos[i]->Get_ParticleComboStep(0)->Get_InitialParticle_Measured()->time();
1168 for (
unsigned int j = 0 ; j < tagmHitVector.size(); j++){
1169 if (taggerTime == tagmHitVector[j]->t){
1170 int nTAGMColumns = 122;
1172 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"TAGM - RFBunch Time p2pi",
1174 "#Deltat TAGM-RFBunch; Column ;t_{TAGM} - t_{SC @ target} [ns]",
1175 nTAGMColumns, 0.5, nTAGMColumns + 0.5, NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME);
1176 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - RFBunch Time p2pi",
1177 tagmHitVector[j]->t - thisRFBunch->
dTime, tagmHitVector[j]->E,
1178 "Tagger - RFBunch Time; #Deltat_{Tagger - SC} [ns]; Energy [GeV]",
1179 NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME, nBinsE, EMin, EMax);
1180 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - RFBunch 1D Time p2pi",
1181 tagmHitVector[j]->t - thisRFBunch->
dTime,
1182 "Tagger - RFBunch Time; #Deltat_{Tagger - RFBunch} [ns]; Entries",
1187 for (
unsigned int j = 0 ; j < taghHitVector.size(); j++){
1188 if (taggerTime == taghHitVector[j]->t){
1189 int nTAGHCounters = 274;
1190 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"TAGH - RFBunch Time p2pi",
1191 taghHitVector[j]->counter_id, taghHitVector[j]->t - thisRFBunch->
dTime,
1192 "#Deltat TAGH-RFBunch; Counter ID ;t_{TAGH} - t_{RFBunch} [ns]",
1193 nTAGHCounters, 0.5, nTAGHCounters + 0.5, NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME);
1195 Fill2DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - RFBunch Time p2pi",
1196 taghHitVector[j]->t - thisRFBunch->
dTime, taghHitVector[j]->E,
1197 "Tagger - RFBunch Time; #Deltat_{Tagger - RFBunch} [ns]; Energy [GeV]",
1198 NBINS_TAGGER_TIME,MIN_TAGGER_TIME,MAX_TAGGER_TIME, nBinsE, EMin, EMax);
1200 Fill1DHistogram(
"HLDetectorTiming",
"TRACKING",
"Tagger - RFBunch 1D Time p2pi",
1201 taghHitVector[j]->t - thisRFBunch->
dTime,
1202 "Tagger - RFBunch Time; #Deltat_{Tagger - RFBunch} [ns]; Entries",
1225 TH2I *fdc_time_module_hist = (TH2I*)gDirectory->Get(
"HLDetectorTiming/FDC/FDCHit Wire time vs. module");
1226 if(fdc_time_module_hist != NULL) {
1229 for(
int ibin=1; ibin<=48; ibin++){
1232 ss << act_crate <<
"/" << act_slot;
1233 fdc_time_module_hist->GetXaxis()->SetBinLabel(ibin, ss.str().c_str());
1235 fdc_time_module_hist->LabelsOption(
"v");
1257 int plane = thisHit->
plane;
1258 int bar = thisHit->
bar;
1259 int end = thisHit->
end;
1261 int CCDBIndex = plane * 88 + end * 44 + bar;
1271 int row = thisHit->
row;
1274 int CCDBIndex = column + row;
1275 if (column > 9) CCDBIndex += 5;
1276 if (column > 27) CCDBIndex += 5;
1277 if (column > 81) CCDBIndex += 5;
1278 if (column > 99) CCDBIndex += 5;
1285 int ring = thisHit->
ring;
1286 int straw = thisHit->
straw;
1288 int CCDBIndex = GetCCDBIndexCDC(ring, straw);
1295 int StartIndex[28] = {0, 42, 84, 138, 192, 258, 324, 404, 484, 577, 670, 776, 882, 1005, 1128, 1263, 1398, 1544, 1690, 1848, 2006, 2176, 2346, 2528, 2710, 2907, 3104, 3313};
1297 int CCDBIndex = StartIndex[ring - 1] + straw;
vector< pair< double, double > > CalcPhoton(const DDIRCPmtHit *locDIRCHit, double locFlightTime, TVector3 posInBar, TVector3 momInBar, map< Particle_t, double > locExpectedAngle, double locAngle, Particle_t locPID, map< Particle_t, double > &logLikelihoodSum, int &nPhotonsThetaC, double &meanThetaC, double &meanDeltaT, bool &isGood) const
jerror_t fini(void)
Called after last event of last event source has been processed.
int GetCCDBIndexTOF(const DTOFHit *)
double CalcAngle(TVector3 momInBar, double locMass) const
bool Get_DIRCTrackMatchParamsMap(map< shared_ptr< const DDIRCMatchParams >, vector< const DDIRCPmtHit * > > &locDIRCTrackMatchParamsMap)
sprintf(text,"Post KinFit Cut")
const DVector3 & position(void) const
const DTrackTimeBased * Get_TrackTimeBased(void) const
uint32_t Get_L1FrontPanelTriggerBits(void) const
int GetCCDBIndexTAGM(const DTAGMHit *)
shared_ptr< const DTOFHitMatchParams > Get_TOFHitMatchParams(void) const
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
bool Get_IsPhysicsEvent(void) const
int GetCCDBIndexCDC(const DCDCHit *)
~JEventProcessor_HLDetectorTiming()
DGeometry * GetDGeometry(unsigned int run_number)
static const int DIRC_MAX_CHANNELS
bool Get_DIRCMatchParams(const DTrackingData *locTrack, shared_ptr< const DDIRCMatchParams > &locMatchParams) const
int GetCCDBIndexBCAL(const DBCALHit *)
Not implimented.
shared_ptr< const DSCHitMatchParams > Get_SCHitMatchParams(void) const
void cdc_hit(Int_t &, Int_t &, Int_t &, Int_t[], Int_t, Int_t, Int_t, Int_t, Int_t, Int_t)
static double ParticleMass(Particle_t p)
shared_ptr< const DFCALShowerMatchParams > Get_FCALShowerMatchParams(void) const
vector< DTrackFitter::pull_t > pulls
Holds pulls used in chisq calc. (not including off-diagonals)
int channel(int row, int column) const
static int Get_FDCTDC_crate_slot(int mod, string &act_crate, int &act_slot)
JEventProcessor_HLDetectorTiming()
shared_ptr< const DBCALShowerMatchParams > Get_BCALShowerMatchParams(void) const
File: DTOFHit.h Created: Tue Jan 18 16:15:26 EST 2011 Creator: B. Zihlmann Purpose: Container class t...
int GetCCDBIndexTAGM(unsigned int column, unsigned int row)
map< Particle_t, double > CalcExpectedAngles(TVector3 momInBar) const
unsigned int dNumParticleVotes
double Step_TimeToNearInputTime(double locTimeToStep, double locTimeToStepTo) const
DRFTime_factory * dRFTimeFactory
jerror_t init(void)
Called once at program start.
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
bool GetTargetZ(double &z_target) const
z-location of center of target
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
int numActiveBlocks() const
A DEPICSvalue object holds information for a single EPICS value read from the data stream...
int GetBar(float y) const