36 #include <JANA/JApplication.h>
37 #include <JANA/JFactory.h>
52 VERBOSEHISTOGRAMS = 0;
55 gPARMS->SetDefaultParameter(
"BCAL_TDC_Timing:VERBOSE",
VERBOSE,
"Verbosity level");
56 gPARMS->SetDefaultParameter(
"BCAL_TDC_Timing:VERBOSEHISTOGRAMS", VERBOSEHISTOGRAMS,
"Create more histograms (default 0 for monitoring)");
90 vector<const DBCALGeometry *> BCALGeomVec;
91 loop->Get(BCALGeomVec);
92 if(BCALGeomVec.size() == 0)
93 throw JException(
"Could not load DBCALGeometry object!");
94 auto locBCALGeom = BCALGeomVec[0];
96 printf(
"locBCALGeom->GetBCAL_center()=%f\nZ_TARGET=%f\n",
97 locBCALGeom->GetBCAL_center(),
Z_TARGET);
131 vector<double> raw_channel_global_offset;
133 if(loop->GetCalib(
"/BCAL/channel_global_offset", raw_channel_global_offset))
134 jout <<
"Error loading /BCAL/channel_global_offset !" << endl;
136 japp->RootFillLock(
this);
141 "Offsets at time of running;CCDB Index;CCDB timing offset [ns]",
143 for (vector<double>::iterator iter = raw_channel_global_offset.begin(); iter != raw_channel_global_offset.end(); ++iter) {
147 "Offsets at time of running;CCDB Index;CCDB timing offset [ns]",
151 japp->RootFillUnLock(
this);
166 loop->GetSingle(trig);
174 bool locIsHDDMEvent = loop->GetJEvent().GetStatusBit(
kSTATUS_HDDM);
175 if (!locIsHDDMEvent) goodtrigger=0;
179 vector<const DBCALGeometry *> BCALGeomVec;
180 loop->Get(BCALGeomVec);
181 if(BCALGeomVec.size() == 0)
182 throw JException(
"Could not load DBCALGeometry object!");
183 auto locBCALGeom = BCALGeomVec[0];
185 vector<const DTrackFitter *> fitters;
188 if(fitters.size()<1){
189 _DBG_<<
"Unable to get a DTrackFinder object!"<<endl;
190 return RESOURCE_UNAVAILABLE;
198 vector<const DBCALHit *> bcal_hits;
199 loop->Get(bcal_hits);
200 double total_bcal_energy = 0.;
201 for(
unsigned int i=0; i<bcal_hits.size(); i++) {
202 total_bcal_energy += bcal_hits[i]->E;
204 if (total_bcal_energy > 12.) goodtrigger=0;
210 vector<const DBCALUnifiedHit *> bcalUnifiedHitVector;
211 loop->Get(bcalUnifiedHitVector);
223 double MIN_TDIFF = -10.0, MAX_TDIFF = 10.0, MAX_TDIFF_WIDE = 30.0;
224 const int ndtbins = 100;
225 double dtbins[ndtbins+1];
226 for (
int i=0; i<=ndtbins; i++) {
227 dtbins[i] = MIN_TDIFF + (MAX_TDIFF-MIN_TDIFF)/ndtbins*i;
229 const int ndtbinswide = 200;
230 double dtbinswide[ndtbinswide+1];
231 for (
int i=0; i<=ndtbinswide; i++) {
232 dtbinswide[i] = MIN_TDIFF + (MAX_TDIFF_WIDE-MIN_TDIFF)/ndtbinswide*i;
234 const int npeakbins = 100;
235 double peakbins[npeakbins+1] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,20,
236 21,23,24,26,28,30,32,34,36,39,42,44,48,51,54,58,62,66,71,76,
237 81,86,92,98,105,112,120,128,137,146,156,167,178,190,203,217,
238 231,247,264,281,300,321,343,366,390,417,445,475,507,541,578,
239 617,659,703,750,801,855,913,974,1040,1110,1185,1265,1351,1442,
240 1539,1643,1754,1872,1998,2133,2277,2430,2594,2769,2956,3155,
241 3368,3595,3837,4096};
243 for (
unsigned int i = 0; i < bcalUnifiedHitVector.size(); i++){
246 int the_tdc_cell = (bcalUnifiedHitVector[i]->module - 1) * 12 + (bcalUnifiedHitVector[i]->
layer - 1) * 4 + bcalUnifiedHitVector[i]->sector;
251 bcalUnifiedHitVector[i]->GetSingle(thisADCHit);
252 bcalUnifiedHitVector[i]->GetSingle(thisTDCHit);
258 if (thisADCHit != NULL && thisTDCHit != NULL){
260 sprintf(name,
"M%02iL%iS%i", bcalUnifiedHitVector[i]->module, bcalUnifiedHitVector[i]->
layer, bcalUnifiedHitVector[i]->sector);
261 if (bcalUnifiedHitVector[i]->end == 0){
263 pulse_peak, thisTDCHit->
t - thisADCHit->
t,
264 "Timewalk; Pulse Peak [ADC Counts]; t_{TDC} - t_{ADC} [ns]",
265 npeakbins, peakbins, ndtbinswide, dtbinswide);
266 Fill2DHistogram (
"BCAL_TDC_Timing",
"Timewalk_All",
"Upstream_Channel_Deltat",
267 the_tdc_cell, thisTDCHit->
t - thisADCHit->
t,
268 "BCAL Upstream t_{TDC}-t_{ADC}; cellID; t_{TDC} - t_{ADC} [ns] ",
269 576, 0.5, 576.5, ndtbins, MIN_TDIFF, MAX_TDIFF);
274 pulse_peak, thisTDCHit->
t - thisADCHit->
t,
275 "Timewalk; Pulse Peak [ADC Counts]; t_{TDC} - t_{ADC} [ns]",
276 npeakbins, peakbins, ndtbinswide, dtbinswide);
277 Fill2DHistogram (
"BCAL_TDC_Timing",
"Timewalk_All",
"Downstream_Channel_Deltat",
278 the_tdc_cell, thisTDCHit->
t - thisADCHit->
t,
279 "BCAL Upstream t_{TDC}-t_{ADC}; cellID; t_{TDC} - t_{ADC} [ns] ",
280 576, 0.5, 576.5, ndtbins, MIN_TDIFF, MAX_TDIFF);
284 if (bcalUnifiedHitVector[i]->has_TDC_hit){
285 double correctedTDCTime = bcalUnifiedHitVector[i]->t_TDC;
287 sprintf(name,
"M%02iL%iS%i", bcalUnifiedHitVector[i]->module, bcalUnifiedHitVector[i]->
layer, bcalUnifiedHitVector[i]->sector);
288 if (bcalUnifiedHitVector[i]->end == 0){
289 Fill2DHistogram (
"BCAL_TDC_Timing",
"Upstream_TimewalkVsPeak_Corrected", name,
290 pulse_peak, correctedTDCTime - bcalUnifiedHitVector[i]->t_ADC,
291 "Timewalk; Pulse Peak [ADC Counts]; t_{TDC} - t_{ADC} [ns]",
292 npeakbins, peakbins, ndtbins ,dtbins);
293 Fill2DHistogram (
"BCAL_TDC_Timing",
"Timewalk_All",
"Upstream_Channel_Deltat_TimewalkCorrected",
294 the_tdc_cell, correctedTDCTime - bcalUnifiedHitVector[i]->t_ADC,
295 "BCAL Upstream t_{TDC}-t_{ADC} corrected; cellID; t_{TDC} - t_{ADC} [ns] ",
296 576, 0.5, 576.5, ndtbins, MIN_TDIFF, MAX_TDIFF);
299 Fill2DHistogram (
"BCAL_TDC_Timing",
"Downstream_TimewalkVsPeak_Corrected", name,
300 pulse_peak, correctedTDCTime - bcalUnifiedHitVector[i]->t_ADC,
301 "Timewalk; Pulse Peak [ADC Counts]; t_{TDC} - t_{ADC} [ns]",
302 npeakbins, peakbins, ndtbins ,dtbins);
303 Fill2DHistogram (
"BCAL_TDC_Timing",
"Timewalk_All",
"Downstream_Channel_Deltat_TimewalkCorrected",
304 the_tdc_cell, correctedTDCTime - bcalUnifiedHitVector[i]->t_ADC,
305 "BCAL Downstream t_{TDC}-t_{ADC} corrected; cellID; t_{TDC} - t_{ADC} [ns] ",
306 576, 0.5, 576.5, ndtbins, MIN_TDIFF, MAX_TDIFF);
378 loop->GetSingle(thisRFBunch);
380 vector <const DChargedTrack *> chargedTrackVector;
381 loop->Get(chargedTrackVector);
383 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 1,
"Success profile;Step", 16, -0.5, 15.5);
384 for (
unsigned int iTrack = 0; iTrack < chargedTrackVector.size(); iTrack++){
387 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 2,
"Success profile;Step", 16, -0.5, 15.5);
389 int charge = chargedTrackVector[iTrack]->Get_Charge();
393 bestHypothesis = chargedTrackVector[iTrack]->Get_Hypothesis(
PiPlus);
396 bestHypothesis = chargedTrackVector[iTrack]->Get_Hypothesis(
PiMinus);
399 if (bestHypothesis == NULL)
continue;
400 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 3,
"Success profile;Step", 16, -0.5, 15.5);
410 if (bcalMatch == NULL)
continue;
411 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 4,
"Success profile;Step", 16, -0.5, 15.5);
412 if (scMatch == NULL)
continue;
413 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 5,
"Success profile;Step", 16, -0.5, 15.5);
415 double dDeltaZToShower = bcalMatch->dDeltaZToShower;
416 double dDeltaPhiToShower = bcalMatch->dDeltaPhiToShower;
419 dDeltaZToShower, dDeltaPhiToShower,
"BCAL Match;#Delta Z [cm]; #Delta#phi [rad]",
420 200, -25, 25, 200, -0.1, 0.1);
423 if (timeBasedTrack->
FOM < 0.0027)
continue;
424 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 6,
"Success profile;Step", 16, -0.5, 15.5);
425 if (timeBasedTrack->
Ndof < 10)
continue;
429 double P_track=timeBasedTrack->
momentum().Mag();
431 if (dEdx<2.5) dEdx_pion = 1;
434 const DBCALShower *thisShower = bcalMatch->dBCALShower;
437 char name[200], title[200];
439 double flightTime=0.;
441 double shower_x = thisShower->
x;
442 double shower_y = thisShower->
y;
444 double t_shower = thisShower->
t;
445 double E_shower = thisShower->
E;
446 double Z_shower = thisShower->
z;
459 DVector3 bcalpos(shower_x,shower_y,Z_shower);
460 double R=bcalpos.Perp();
461 double pathLength=0.;
465 flightTime,pathLength)){
467 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 7,
"Success profile;Step", 16, -0.5, 15.5);
469 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 8,
"Success profile;Step", 16, -0.5, 15.5);
472 sprintf(name,
"AllShowers_q%s", q);
473 sprintf(title,
"Charged shower; E_{shower} [GeV]; t_{Target} - t_{RF} [ns]");
475 E_shower, targetCenterTime - thisRFBunch->
dTime, title,
476 1000, 0.0, 5.0, 200, -10, 10);
477 sprintf(name,
"dEdxVsP_q%s", q);
478 sprintf(title,
"CDC dE/dx vs P; P [GeV]; dE/dx [keV/cm]");
480 P_track, dEdx, title,
481 200, 0.0, 5.0, 200, 0.0, 5.0);
482 sprintf(name,
"deltaTVsdEdx_q%s", q);
483 sprintf(title,
"PID; dE/dx [keV/cm]; t_{Target} - t_{RF} [ns]");
485 dEdx, targetCenterTime - thisRFBunch->
dTime, title,
486 200, 0.0, 5.0, 200, -10, 10);
488 sprintf(title,
"PID; P [GeV]; E/P");
490 P_track, E_shower, title,
491 200, 0.0, 5.0, 200, 0, 5.0);
492 sprintf(name,
"EoverPVsP_q%s", q);
493 sprintf(title,
"PID; P [GeV]; E [GeV]");
495 P_track, E_shower/P_track, title,
496 200, 0.0, 5.0, 200, 0, 2);
498 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 9,
"Success profile;Step", 16, -0.5, 15.5);
499 sprintf(name,
"PionShowers_q%s", q);
500 sprintf(title,
"Pion showers; E_{shower} [GeV]; t_{Target} - t_{RF} [ns]");
502 E_shower, targetCenterTime - thisRFBunch->
dTime, title,
503 1000, 0.0, 5.0, 200, -10, 10);
504 sprintf(name,
"PionShowersVsP_q%s", q);
505 sprintf(title,
"Pion showers; P [GeV]; t_{Target} - t_{RF} [ns]");
507 P_track, targetCenterTime - thisRFBunch->
dTime, title,
508 1000, 0.0, 5.0, 200, -10, 10);
509 sprintf(name,
"PionShowersVsZ_q%s", q);
510 sprintf(title,
"Pion showers; Z [cm]; t_{Target} - t_{RF} [ns]");
512 Z_shower, targetCenterTime - thisRFBunch->
dTime, title,
513 880, 0.0, 420.0, 200, -10, 10);
520 vector <const DBCALPoint*> pointVector;
521 thisShower->Get(pointVector);
523 int N_points = pointVector.size();
525 sprintf(name,
"NpointVsEshower_q%s", q);
526 sprintf(title,
"PID; E_{shower} [GeV]; N_{point}");
528 E_shower, N_points, title,
529 500, 0.0, 5.0, 50, 0, 50);
532 for (
unsigned int iPoint = 0; iPoint < pointVector.size(); iPoint++){
533 const DBCALPoint *thisPoint = pointVector[iPoint];
535 double rpoint = thisPoint->
r();
536 float E_point = thisPoint->
E();
537 double Z_point = thisPoint->
z();
540 float zmaxhall = 450;
541 float zminlocal = -250;
542 float zmaxlocal = 250;
543 Fill2DHistogram (
"BCAL_Global_Offsets",
"Z Position",
"AllPointsVsShower",
545 "Z_{Point} vs Z_{Shower};Z_{Shower} [cm];Z_{Point} [cm]",
546 225, zminhall, zmaxhall, 225, zminhall, zmaxhall);
549 flightTime,pathLength)){
553 char channame[255], layername[255], chargename[255];
556 sprintf(chargename,
"All_q%s", q);
558 double trackHitZ = proj_pos.z();
559 double localTrackHitZ = proj_pos.z() - locBCALGeom->GetBCAL_center();
560 double BCALHitZ = thisPoint->
z() +
Z_TARGET;
562 double deltaZ = trackHitZ-BCALHitZ;
563 double Deltat = thisPoint->
t_US() - thisPoint->
t_DS();
567 "Z_{Track} vs #Delta t;#Delta t = t_{US}-t_{DS};Z_{Track} [cm]",
568 480, -30, 30, 250, zminhall, zmaxhall);
571 "Z_{Track} vs #Delta t;#Delta t = t_{US}-t_{DS};Z_{Track} [cm]",
572 480, -30, 30, 250, zminhall, zmaxhall);
575 "Z_{Track} vs #Delta t;#Delta t = t_{US}-t_{DS};Z_{Track} [cm]",
576 480, -30, 30, 250, zminhall, zmaxhall);
577 sprintf(title,
"%s Z_{Track} vs #Delta t;#Delta t = t_{US}-t_{DS};Z_{Track} [cm]", channame);
579 Deltat, trackHitZ, title,
580 480, -30, 30, 250, zminhall, zmaxhall);
582 double trackTheta = 180/3.14159265358*atan2(timeBasedTrack->
pperp(),timeBasedTrack->
pz());
585 "#Delta t vs #theta_{Track};#theta_{Track} (deg);#Delta t = t_{US}-t_{DS} (ns)",
586 360,0,180, 480, -30, 30);
589 int the_cell = (thisPoint->
module() - 1) * 16 + (thisPoint->
layer() - 1) * 4 + thisPoint->
sector();
590 float Deltat_Zcorr = Deltat - (trackHitZ-212)/8.1;
591 sprintf(title,
"#Delta t (Hit) corrected for Z;#Delta t - Z_{Track}/v_{eff}");
593 Deltat_Zcorr, title, 70, -10, 14);
595 the_cell, Deltat_Zcorr,
596 "#Delta t (Hit) corrected for Z;#Delta t - Z_{Track}/v_{eff}",
597 768, 0.5, 768.5, 70, -10, 14);
601 "#Delta Z vs Z_{Track};Z_{Track} [cm];#Delta Z = Z_{Track} - Z_{Point}",
602 250, zminhall, zmaxhall, 100, -50, 50);
605 "#Delta Z vs Z_{Track};Z_{Track} [cm];#Delta Z = Z_{Track} - Z_{Point}",
606 250, zminhall, zmaxhall, 100, -50, 50);
609 "#Delta Z vs Z_{Track};Z_{Track} [cm];#Delta Z = Z_{Track} - Z_{Point}",
610 250, zminhall, zmaxhall, 100, -50, 50);
613 "#Delta Z vs Z_{Track};Z_{Track} [cm];#Delta Z = Z_{Track} - Z_{Point}",
614 250, zminhall, zmaxhall, 100, -50, 50);
618 "Z_{point} Vs. Z_{Track}; Z_{Track} [cm]; Z_{Point} [cm]",
619 500, zminhall, zmaxhall, 500, zminhall, zmaxhall);
622 "Z_{point} Vs. Z_{Track}; Z_{Track} [cm]; Z_{Point} [cm]",
623 500, zminhall, zmaxhall, 500, zminhall, zmaxhall);
626 "Z_{point} Vs. Z_{Track}; Z_{Track} [cm]; Z_{Point} [cm]",
627 500, zminhall, zmaxhall, 500, zminhall, zmaxhall);
630 "Z_{point} Vs. Z_{Track}; Z_{Track} [cm]; Z_{Point} [cm]",
631 500, zminhall, zmaxhall, 500, zminhall, zmaxhall);
634 vector <const DBCALUnifiedHit*> unifiedhitVector;
635 thisPoint->Get(unifiedhitVector);
636 int up = unifiedhitVector[0]->end;
637 int down = unifiedhitVector[1]->end;
640 float t_up = thisUnifiedhitup->
t;
641 float t_ADC_up = thisUnifiedhitup->
t_ADC;
642 float t_TDC_up = thisUnifiedhitup->
t_TDC;
643 float t_down = thisUnifiedhitdown->
t;
644 float t_ADC_down = thisUnifiedhitdown->
t_ADC;
645 float t_TDC_down = thisUnifiedhitdown->
t_TDC;
648 if (t_up == t_ADC_up && t_down == t_ADC_down)
sprintf(type,
"ADC");
649 if (t_up == t_TDC_up && t_down == t_TDC_down)
sprintf(type,
"TDC");
652 thisUnifiedhitup->GetSingle(thisADCHit_up);
654 thisUnifiedhitdown->GetSingle(thisADCHit_down);
657 float Deltat_raw = thisADCHit_up->
t_raw - thisADCHit_down->
t_raw;
658 float Deltat_raw_Zcorr = Deltat_raw - (trackHitZ-212)/8.1;
660 the_cell, Deltat_raw_Zcorr,
661 "#Delta t (Hit) corrected for Z;#Delta t_{raw} - Z_{Track}/v_{eff}",
662 768, 0.5, 768.5, 70, -10, 14);
663 sprintf(title,
"#Delta t (Hit) corrected for Z;#Delta t_{raw} - Z_{Track}/v_{eff}");
665 Deltat_raw_Zcorr, title, 70, -10, 14);
668 vector<const DBCALDigiHit*> digihits;
669 thisPoint->Get(digihits);
670 if (digihits.size()!=2) {
671 printf(
"Warning: BCAL_attenlength_gainratio: event %llu: wrong number of BCALDigiHit objects found %i\n",
672 (
long long unsigned int)eventnumber,(
int)digihits.size());
675 if (digihits[0]->end==digihits[1]->end) {
676 printf(
"Warning: BCAL_attenlength_gainratio: event %llu: two hits in same end of point\n",(
long long unsigned int)eventnumber);
679 float integralUS, integralDS;
681 if (digihits[0]->end==0) {
682 integralUS = digihits[0]->pulse_integral - ((float)digihits[0]->nsamples_integral*(
float)digihits[0]->pedestal)/
683 (
float)digihits[0]->nsamples_pedestal;
684 integralDS = digihits[1]->pulse_integral - ((float)digihits[1]->nsamples_integral*(
float)digihits[1]->pedestal)/
685 (
float)digihits[1]->nsamples_pedestal;
687 integralDS = digihits[0]->pulse_integral - ((float)digihits[0]->nsamples_integral*(
float)digihits[0]->pedestal)/
688 (
float)digihits[0]->nsamples_pedestal;
689 integralUS = digihits[1]->pulse_integral - ((float)digihits[1]->nsamples_integral*(
float)digihits[1]->pedestal)/
690 (
float)digihits[1]->nsamples_pedestal;
692 float intratio = (float)integralUS/(
float)integralDS;
693 float logintratio = log(intratio);
695 if (VERBOSEHISTOGRAMS) {
696 sprintf(title,
"Attenuation;Z_{Track} (cm);log of integral ratio US/DS");
697 Fill2DHistogram (
"BCAL_atten_gain",
"logintratiovsZtrack",
"AllPoints",
698 localTrackHitZ, logintratio, title,
699 250, zminlocal, zmaxlocal, 250, -3, 3);
700 sprintf(title,
"Attenuation (M%i,L%i,S%i);Z_{Track} (cm);log of integral ratio US/DS",
703 localTrackHitZ, logintratio, title,
704 250, zminlocal, zmaxlocal, 250, -3, 3);
710 double pointTime = thisPoint->
t();
713 double targetCenterTime = pointTime - flightTime - vertexTime;
716 if (E_point > 0.05) {
718 the_cell, targetCenterTime - thisRFBunch->
dTime,
719 "Charged shower points; CCDB Index; t_{Target} - t_{RF} [ns]",
720 768, 0.5, 768.5, 200, -10, 10);
721 sprintf(name ,
"deltaTVsCell_q%s", q);
723 the_cell, targetCenterTime - thisRFBunch->
dTime,
724 "Charged shower points; CCDB Index; t_{Target} - t_{RF} [ns]",
725 768, 0.5, 768.5, 200, -10, 10);
726 sprintf(name ,
"deltaTVsCell_q%s_Eweight", q);
728 the_cell, targetCenterTime - thisRFBunch->
dTime, E_point,
729 "Charged shower points (E weighted); CCDB Index; t_{Target} - t_{RF} [ns]",
730 768, 0.5, 768.5, 200, -10, 10);
731 sprintf(name ,
"deltaTVsCell_q%s_E2weight", q);
733 the_cell, targetCenterTime - thisRFBunch->
dTime, E_point*E_point,
734 "Charged shower points (E^{2} weighted); CCDB Index; t_{Target} - t_{RF} [ns]",
735 768, 0.5, 768.5, 200, -10, 10);
736 sprintf(name ,
"deltaTVsLayer_q%s", q);
738 thisPoint->
layer(), targetCenterTime - thisRFBunch->
dTime,
739 "Charged shower points; CCDB Index; t_{Target} - t_{RF} [ns]",
740 4, 0.5, 4.5, 200, -10, 10);
746 double fibLen = locBCALGeom->GetBCAL_length();
747 double c_effective = locBCALGeom->GetBCAL_c_effective();
748 double BCALtrackHitZ = trackHitZ - (locBCALGeom->GetBCAL_center() - fibLen/2);
749 double barproptime_up = BCALtrackHitZ / c_effective;
750 double barproptime_down = (fibLen-BCALtrackHitZ) / c_effective;
751 double hitup_TargetCenterTime = t_up - barproptime_up - flightTime - vertexTime;
752 double hitdown_TargetCenterTime = t_down - barproptime_down - flightTime - vertexTime;
753 double hittimediff = t_down - t_up - 2*localTrackHitZ/c_effective;
755 int the_cell = (thisPoint->
module() - 1) * 16 + (thisPoint->
layer() - 1) * 4 + thisPoint->
sector();
757 Fill2DHistogram(
"BCAL_Global_Offsets",
"Target Time",
"hitDeltaTVsChannel",
758 the_cell, hitup_TargetCenterTime - thisRFBunch->
dTime,
759 "Charged shower hit; CCDB Index; t_{Target} - t_{RF} [ns]",
760 1536, 0.5, 1536.5, 200, -10, 10);
761 Fill2DHistogram(
"BCAL_Global_Offsets",
"Target Time",
"hitDeltaTVsChannel",
762 the_cell+768, hitdown_TargetCenterTime - thisRFBunch->
dTime,
763 "Charged shower hit; CCDB Index; t_{Target} - t_{RF} [ns]",
764 1536, 0.5, 1536.5, 200, -10, 10);
766 the_cell, hittimediff,
767 "Charged shower hit; CCDB Index; t_{Target} - t_{RF} [ns]",
768 768, 0.5, 768.5, 200, -10, 10);
770 sprintf(title,
"Charged shower points; E_{point} [GeV]; t_{Target} - t_{RF} [ns]");
771 sprintf(name,
"AllHits_%s_q%s",type,q);
773 E_point, targetCenterTime - thisRFBunch->
dTime, title,
774 1000, 0.0, 2.0, 200, -10, 10);
776 sprintf(title,
"Charged shower points; peak [counts]; t_{Target} - t_{RF} [ns]");
777 sprintf(name,
"AllHits_%s_q%s",type,q);
779 pulse_peak_max, targetCenterTime - thisRFBunch->
dTime, title,
780 1000, 0.0, 4000, 200, -10, 10);
781 sprintf(name,
"AllHits_%s_q%s",type,q);
783 pulse_peak_min, targetCenterTime - thisRFBunch->
dTime, title,
784 1000, 0.0, 4000, 200, -10, 10);
788 sprintf(name,
"EpointVsEshower_q%s", q);
789 sprintf(title,
"PID; E_{shower} [GeV]; E_{point} [GeV]");
791 E_shower, E_point, title,
792 1000, 0.0, 5.0, 1000, 0, 2);
793 sprintf(name,
"EpointVsEshower_Layer%i_q%s", layer, q);
794 sprintf(title,
"PID; E_{shower} [GeV]; E_{point} [GeV]");
796 E_shower, E_point, title,
797 1000, 0.0, 5.0, 1000, 0, 2);
799 sprintf(name,
"AllPoints_q%s", q);
800 sprintf(title,
"Charged shower points; E_{point} [GeV]; t_{Target} - t_{RF} [ns]");
802 E_point, targetCenterTime - thisRFBunch->
dTime, title,
803 1000, 0.0, 2.0, 200, -10, 10);
804 sprintf(name,
"Layer%i_q%s", layer, q);
805 sprintf(title,
"Charged shower points, layer %i; E_{point} [GeV]; t_{Target} - t_{RF} [ns]", layer);
807 E_point, targetCenterTime - thisRFBunch->
dTime, title,
808 1000, 0.0, 2.0, 200, -10, 10);
809 sprintf(name,
"AllPoints_%s_q%s", type, q);
810 sprintf(title,
"Charged shower points; E_{point} [GeV]; t_{Target} - t_{RF} [ns]");
812 E_point, targetCenterTime - thisRFBunch->
dTime, title,
813 1000, 0.0, 2.0, 200, -10, 10);
814 sprintf(name,
"Layer%i_%s_q%s", layer, type, q);
815 sprintf(title,
"Charged shower points, layer %i; E_{point} [GeV]; t_{Target} - t_{RF} [ns]", layer);
817 E_point, targetCenterTime - thisRFBunch->
dTime, title,
818 1000, 0.0, 2.0, 200, -10, 10);
820 sprintf(name,
"AllPoints_q%s", q);
821 sprintf(title,
"Charged shower points; E_{shower} [GeV]; t_{Target} - t_{RF} [ns]");
822 Fill2DHistogram(
"BCAL_Global_Offsets",
"Points_deltaTVsShowerEnergy", name,
823 E_shower, targetCenterTime - thisRFBunch->
dTime, title,
824 1000, 0.0, 2.0, 200, -10, 10);
825 sprintf(name,
"Layer%i_q%s", layer, q);
826 sprintf(title,
"Charged shower points, layer %i; E_{shower} [GeV]; t_{Target} - t_{RF} [ns]", layer);
827 Fill2DHistogram(
"BCAL_Global_Offsets",
"Points_deltaTVsShowerEnergy", name,
828 E_shower, targetCenterTime - thisRFBunch->
dTime, title,
829 1000, 0.0, 2.0, 200, -10, 10);
847 char name[200], title[200];
848 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 10,
"Success profile;Step", 16, -0.5, 15.5);
850 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 11,
"Success profile;Step", 16, -0.5, 15.5);
851 vector<const DVertex*> locVertex;
852 loop->Get(locVertex);
862 vector <const DBCALShower *> locBCALShowers;
863 loop->Get(locBCALShowers);
864 vector<const DTrackTimeBased*> locTrackTimeBased;
865 loop->Get(locTrackTimeBased);
866 for (
unsigned int ibcalshower = 0; ibcalshower < locBCALShowers.size(); ibcalshower++){
867 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 12,
"Success profile;Step", 16, -0.5, 15.5);
868 const DBCALShower *bcalshower = locBCALShowers[ibcalshower];
869 double x = bcalshower->
x;
870 double y = bcalshower->
y;
871 double z = bcalshower->
z;
873 double R_shower = showerpos.Perp();
876 for (
unsigned int i=0; i < locTrackTimeBased.size() ; ++i) {
878 vector<DTrackFitter::Extrapolation_t>extrapolations=locTrackTimeBased[i]->extrapolations.at(
SYS_BCAL);
881 double dPhi = 180./3.14159265358*(trackpos.Phi()-showerpos.Phi());
882 double dZ = (trackpos.Z() - z);
884 sprintf(title,
"Shower-Track position difference;dZ [cm]; d#phi [degrees]");
887 200, -60.0, 60.0, 200, -30, 30);
889 if (TMath::Abs(dZ < 40.0) && TMath::Abs(dPhi) < 15) matched=1;
892 if (matched)
continue;
893 Fill1DHistogram(
"BCAL_Global_Offsets",
"Debug",
"Success", 13,
"Success profile;Step", 16, -0.5, 15.5);
895 float vertexX = locVertex[0]->dSpacetimeVertex.X();
896 float vertexY = locVertex[0]->dSpacetimeVertex.Y();
897 float vertexZ = locVertex[0]->dSpacetimeVertex.Z();
898 float xdiff = bcalshower->
x - vertexX;
899 float ydiff = bcalshower->
y - vertexY;
900 float zdiff = bcalshower->
z - vertexZ;
901 float pathLength =
sqrt(xdiff*xdiff + ydiff*ydiff + zdiff*zdiff);
908 double targetCenterTime = bcalshower->
t - flightTime - vertexTime;
909 double deltaTime = targetCenterTime - thisRFBunch->
dTime;
910 double E_shower = bcalshower->
E;
914 sprintf(name,
"AllShowers_q0");
915 sprintf(title,
"Neutral Showers; E_{shower} [GeV]; t_{Target} - t_{RF} [ns]");
917 E_shower, deltaTime, title,
918 1000, 0.0, 5.0, 200, -10, 10);
919 sprintf(name,
"AllShowersVsZ_q0");
920 sprintf(title,
"Neutral showers; Z [cm]; t_{Target} - t_{RF} [ns]");
922 bcalshower->
z, deltaTime, title,
923 880, 0.0, 440.0, 200, -10, 10);
926 vector <const DBCALPoint*> pointVector;
927 bcalshower->Get(pointVector);
928 int N_points = pointVector.size();
930 sprintf(name,
"NpointVsEshower_q0");
931 sprintf(title,
"PID; E_{shower} [GeV]; N_{point}");
933 E_shower, N_points, title,
934 500, 0.0, 5.0, 50, 0, 50);
936 for (
unsigned int iPoint = 0; iPoint < pointVector.size(); iPoint++){
937 const DBCALPoint *thisPoint = pointVector[iPoint];
938 float E_point = thisPoint->
E();
940 pathLength = thisPoint->
rho();
943 targetCenterTime = thisPoint->
t() - flightTime - vertexTime;
944 deltaTime = targetCenterTime - thisRFBunch->
dTime;
946 if (E_point > 0.05) {
947 int the_cell = (thisPoint->
module() - 1) * 16 + (thisPoint->
layer() - 1) * 4 + thisPoint->
sector();
948 Fill2DHistogram(
"BCAL_Global_Offsets",
"Target Time",
"deltaTVsCell_q0",
950 "Neutral shower points; CCDB Index; t_{Target} - t_{RF} [ns]",
951 768, 0.5, 768.5, 200, -10, 10);
952 Fill2DHistogram(
"BCAL_Global_Offsets",
"Target Time",
"deltaTVsCell_q0",
954 "Neutral shower points; CCDB Index; t_{Target} - t_{RF} [ns]",
955 768, 0.5, 768.5, 200, -10, 10);
957 the_cell, deltaTime, E_point,
958 "Neutral shower points (E weighted); CCDB Index; t_{Target} - t_{RF} [ns]",
959 768, 0.5, 768.5, 200, -10, 10);
961 the_cell, deltaTime, E_point*E_point,
962 "Neutral shower points (E^{2} weighted); CCDB Index; t_{Target} - t_{RF} [ns]",
963 768, 0.5, 768.5, 200, -10, 10);
968 sprintf(title,
"Neutral shower points; E_{point} [GeV]; t_{Target} - t_{RF} [ns]");
970 E_point, deltaTime, title,
971 1000, 0.0, 2.0, 200, -10, 10);
972 sprintf(name,
"Layer%i_q0", layer);
973 sprintf(title,
"Neutral shower points, layer %i; E_{point} [GeV]; t_{Target} - t_{RF} [ns]", layer);
975 E_point, deltaTime, title,
976 1000, 0.0, 2.0, 200, -10, 10);
989 sprintf(title,
"Neutral shower points; E_{shower} [GeV]; t_{Target} - t_{RF} [ns]");
990 Fill2DHistogram(
"BCAL_Global_Offsets",
"Points_deltaTVsShowerEnergy", name,
991 E_shower, deltaTime, title,
992 1000, 0.0, 2.0, 200, -10, 10);
993 sprintf(name,
"Layer%i_q0", layer);
994 sprintf(title,
"Neutral shower points, layer %i; E_{shower} [GeV]; t_{Target} - t_{RF} [ns]", layer);
995 Fill2DHistogram(
"BCAL_Global_Offsets",
"Points_deltaTVsShowerEnergy", name,
996 E_shower, deltaTime, title,
997 1000, 0.0, 2.0, 200, -10, 10);
1001 pathLength = thisPoint->
rho()*locBCALGeom->GetBCAL_inner_rad()/R_shower;
1004 targetCenterTime = thisPoint->
tInnerRadius() - flightTime - vertexTime;
1005 float altDeltaTime = targetCenterTime - thisRFBunch->
dTime;
1008 sprintf(name,
"AllPoints_q0");
1009 sprintf(title,
"Neutral shower points; E_{point} [GeV]; t_{Target} - t_{RF} [ns]");
1010 Fill2DHistogram(
"BCAL_Global_Offsets",
"Points_altDeltaTVsEnergy", name,
1011 E_point, altDeltaTime, title,
1012 1000, 0.0, 2.0, 200, -10, 10);
1013 sprintf(name,
"Layer%i_q0", layer);
1014 sprintf(title,
"Neutral shower points, layer %i; E_{point} [GeV]; t_{Target} - t_{RF} [ns]", layer);
1015 Fill2DHistogram(
"BCAL_Global_Offsets",
"Points_altDeltaTVsEnergy", name,
1016 E_point, altDeltaTime, title,
1017 1000, 0.0, 2.0, 200, -10, 10);
1029 sprintf(name,
"AllPoints_q0");
1030 sprintf(title,
"Neutral shower points; E_{shower} [GeV]; t_{Target} - t_{RF} [ns]");
1031 Fill2DHistogram(
"BCAL_Global_Offsets",
"Points_altDeltaTVsShowerEnergy", name,
1032 E_shower, altDeltaTime, title,
1033 1000, 0.0, 2.0, 200, -10, 10);
1034 sprintf(name,
"Layer%i_q0", layer);
1035 sprintf(title,
"Neutral shower points, layer %i; E_{shower} [GeV]; t_{Target} - t_{RF} [ns]", layer);
1036 Fill2DHistogram(
"BCAL_Global_Offsets",
"Points_altDeltaTVsShowerEnergy", name,
1037 E_shower, altDeltaTime, title,
1038 1000, 0.0, 2.0, 200, -10, 10);
bool ExtrapolateToRadius(double R, const vector< Extrapolation_t > &extraps, DVector3 &pos, DVector3 &mom, double &t, double &s) const
float t_TDC
Time of TDC hit that is closes t to the ADC time.
JEventProcessor_BCAL_TDC_Timing()
float tInnerRadius() const
sprintf(text,"Post KinFit Cut")
const DVector3 & position(void) const
const DTrackTimeBased * Get_TrackTimeBased(void) const
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t init(void)
Called once at program start.
DGeometry * GetDGeometry(unsigned int run_number)
float t_US() const
Return the time of US Hit.
float t_ADC
Time from fADC.
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
int Ndof
Number of degrees of freedom in the fit.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
shared_ptr< const DSCHitMatchParams > Get_SCHitMatchParams(void) const
const DVector3 & momentum(void) const
const DTrackFitter * fitter
shared_ptr< const DBCALShowerMatchParams > Get_BCALShowerMatchParams(void) const
~JEventProcessor_BCAL_TDC_Timing()
map< DetectorSystem_t, vector< DTrackFitter::Extrapolation_t > > extrapolations
unsigned int dNumParticleVotes
printf("string=%s", string)
bool GetTargetZ(double &z_target) const
z-location of center of target
float t_DS() const
Return the time of DS Hit.
jerror_t fini(void)
Called after last event of last event source has been processed.
float t_raw
Uncalibrated time in ns.
float t
Unified time, obtained from ADC and/or TDC and used for further analysis.