10#include <ecl/modules/eclBhabhaTCollector/ECLBhabhaTCollectorModule.h>
13#include <ecl/dataobjects/ECLCalDigit.h>
14#include <ecl/dataobjects/ECLDigit.h>
15#include <ecl/dataobjects/ECLElementNumbers.h>
16#include <ecl/dbobjects/ECLCrystalCalib.h>
17#include <ecl/dbobjects/ECLReferenceCrystalPerCrateCalib.h>
18#include <ecl/digitization/EclConfiguration.h>
21#include <analysis/utility/PCmsLabTransform.h>
22#include <framework/dataobjects/EventMetaData.h>
23#include <framework/gearbox/Const.h>
24#include <mdst/dataobjects/ECLCluster.h>
25#include <mdst/dataobjects/HitPatternCDC.h>
26#include <mdst/dataobjects/Track.h>
46 m_ElectronicsDB(
"ECLCrystalElectronics"),
47 m_ElectronicsTimeDB(
"ECLCrystalElectronicsTime"),
48 m_FlightTimeDB(
"ECLCrystalFlightTime"),
49 m_PreviousCrystalTimeDB(
"ECLCrystalTimeOffset"),
50 m_CrateTimeDB(
"ECLCrateTimeOffset"),
51 m_RefCrystalsCalibDB(
"ECLReferenceCrystalPerCrateCalib"),
52 m_channelMapDB(
"ECLChannelMap")
54 setDescription(
"This module generates sum of all event times per crystal");
57 "Events with fabs(getTimeFit) > m_timeAbsMax "
58 "are excluded", (
short)80);
61 "First CellId to handle.", 1);
66 "If true, TTree 'tree' with more detailed event info is saved in "
67 "the output file specified by HistoManager",
74 addParam(
"skipTrgSel",
skipTrgSel,
"boolean to skip the trigger skim selection",
false);
77 "SVD bhabha t0 bias correction (ns)", 0.);
92 m_dbgTree_electrons =
new TTree(
"tree_electrons",
"Debug data for bhabha time calibration - one entry per electron");
98 &
m_tree_E1Etot)->SetTitle(
"Max Energy Crystal Fraction Energy of Cluster");
100 &
m_tree_E1E2)->SetTitle(
"Max Energy Crystal DIV second max energy crystal in cluster");
117 m_dbgTree_tracks =
new TTree(
"tree_tracks",
"Debug data for bhabha time calibration - one entry per track");
128 "Debug data for bhabha time calibration - one entry per electron - one entry per crystal");
140 m_dbgTree_event =
new TTree(
"tree_event",
"Debug data for bhabha time calibration - one entry per event");
147 "Debug data for bhabha time calibration - one entry per event after all the cuts");
165 "Debug data for bhabha time calibration - one entry per crystal per cluster entry after all cuts");
171 ->SetTitle(
"Time of a crystal within the cluster after application of previous calibrations except t0, ns");
191 "Debug data for bhabha time calibration - one entry per max E crystal entry after cuts");
200 &
m_tree_E1Etot)->SetTitle(
"Max Energy Crystal Fraction Energy of Cluster");
202 &
m_tree_E1E2)->SetTitle(
"Max Energy Crystal DIV second max energy crystal in cluster");
220 B2INFO(
"ECLBhabhaTCollector: Experiment = " <<
m_EventMetaData->getExperiment() <<
230 auto TimevsCrysPrevCrateCalibPrevCrystCalib =
new TH2F(
"TimevsCrysPrevCrateCalibPrevCrystCalib",
231 "Time t psi - ts - tcrate (previous calibs) vs crystal cell ID;crystal cell ID;Time t_psi with previous calib (ns)",
233 registerObject<TH2F>(
"TimevsCrysPrevCrateCalibPrevCrystCalib", TimevsCrysPrevCrateCalibPrevCrystCalib);
235 auto TimevsCratePrevCrateCalibPrevCrystCalib =
new TH2F(
"TimevsCratePrevCrateCalibPrevCrystCalib",
236 "Time t psi - ts - tcrate (previous calibs) vs crate ID;crate ID;Time t_psi previous calib (ns)",
237 52, 1, 52 + 1, nbins, min_t, max_t);
238 registerObject<TH2F>(
"TimevsCratePrevCrateCalibPrevCrystCalib", TimevsCratePrevCrateCalibPrevCrystCalib);
240 auto TimevsCrysNoCalibrations =
new TH2F(
"TimevsCrysNoCalibrations",
243 registerObject<TH2F>(
"TimevsCrysNoCalibrations", TimevsCrysNoCalibrations);
245 auto TimevsCrateNoCalibrations =
new TH2F(
"TimevsCrateNoCalibrations",
246 "Time tpsi vs crate ID;crate ID;Time t_psi (ns)", 52, 1, 52 + 1, nbins, min_t, max_t);
247 registerObject<TH2F>(
"TimevsCrateNoCalibrations", TimevsCrateNoCalibrations);
249 auto TimevsCrysPrevCrateCalibNoCrystCalib =
new TH2F(
"TimevsCrysPrevCrateCalibNoCrystCalib",
250 "Time tpsi - tcrate (previous calib) vs crystal cell ID;crystal cell ID;Time t_psi including previous crate calib (ns)",
252 registerObject<TH2F>(
"TimevsCrysPrevCrateCalibNoCrystCalib", TimevsCrysPrevCrateCalibNoCrystCalib);
254 auto TimevsCrateNoCrateCalibPrevCrystCalib =
new TH2F(
"TimevsCrateNoCrateCalibPrevCrystCalib",
255 "Time tpsi - ts (previous calib) vs crate ID;crate ID;Time t_psi including previous crystal calib (ns)",
256 52, 1, 52 + 1, nbins, min_t, max_t);
257 registerObject<TH2F>(
"TimevsCrateNoCrateCalibPrevCrystCalib", TimevsCrateNoCrateCalibPrevCrystCalib);
262 registerObject<TH1F>(
"TsDatabase", TsDatabase);
266 registerObject<TH1F>(
"TsDatabaseUnc", TsDatabaseUnc);
270 registerObject<TH1F>(
"TcrateDatabase", TcrateDatabase);
274 registerObject<TH1F>(
"TcrateUncDatabase", TcrateUncDatabase);
277 auto tcrateDatabase_ns =
new TH1F(
"tcrateDatabase_ns",
";crate id;tcrate derived from database", 52, 1, 52 + 1);
278 registerObject<TH1F>(
"tcrateDatabase_ns", tcrateDatabase_ns);
281 auto databaseCounter =
new TH1I(
"databaseCounter",
282 ";A database was read in;Number of times database was saved to histogram", 1, 1, 2);
283 registerObject<TH1I>(
"databaseCounter", databaseCounter);
286 auto numCrystalEntriesPerEvent =
new TH1F(
"numCrystalEntriesPerEvent",
287 ";Number crystal entries;Number of events", 15, 0, 15);
288 registerObject<TH1F>(
"numCrystalEntriesPerEvent", numCrystalEntriesPerEvent);
290 auto cutflow =
new TH1F(
"cutflow",
";Cut label number;Number of events passing cut", 20, 0, 20);
291 registerObject<TH1F>(
"cutflow", cutflow);
293 auto svdEventT0 =
new TH1D(
"svdEventT0",
";EventT0 from SVD", 200, -50, 50);
294 registerObject<TH1D>(
"svdEventT0", svdEventT0);
296 auto maxEcrsytalEnergyFraction =
new TH1F(
"maxEcrsytalEnergyFraction",
297 ";Maximum energy crystal energy / (sum) cluster energy;Number", 22, 0, 1.1);
298 registerObject<TH1F>(
"maxEcrsytalEnergyFraction", maxEcrsytalEnergyFraction);
300 auto refCrysIDzeroingCrate =
new TH1F(
"refCrysIDzeroingCrate",
";cell id;Boolean - is reference crystal",
302 registerObject<TH1F>(
"refCrysIDzeroingCrate", refCrysIDzeroingCrate);
304 auto SVDEventT0Correction =
new TH1F(
"SVDEventT0Correction",
";;SVD event t0 offset correction [ns]", 1, 1, 2);
305 registerObject<TH1F>(
"SVDEventT0Correction", SVDEventT0Correction);
316 " ns correction to SVD event t0 will be applied");
324 int cutIndexPassed = 0;
325 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
326 B2DEBUG(22,
"Cutflow: no cuts: index = " << cutIndexPassed);
336 B2WARNING(
"SoftwareTriggerResult required to select bhabha event is not found");
342 const std::map<std::string, int>& fresults =
m_TrgResult->getResults();
343 if (fresults.find(
"software_trigger_cut&skim&accept_bhabha") == fresults.end()) {
344 B2WARNING(
"Can't find required bhabha trigger identifier");
348 const bool eBhabha = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_bhabha") ==
350 B2DEBUG(22,
"eBhabha (trigger passed) = " << eBhabha);
360 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
361 B2DEBUG(22,
"Cutflow: Trigger cut passed: index = " << cutIndexPassed);
371 if (ECLchannelMapHasChanged) {
372 B2INFO(
"ECLBhabhaTCollectorModule::collect() " <<
LogVar(
"ECLchannelMapHasChanged", ECLchannelMapHasChanged));
374 B2FATAL(
"ECLBhabhaTCollectorModule::collect() : Can't initialize eclChannelMapper!");
398 B2DEBUG(29,
"Finished checking if previous crystal time payload has changed");
403 B2DEBUG(29,
"Finished checking if previous crate time payload has changed");
404 B2DEBUG(29,
"m_CrateTime size = " <<
m_CrateTime.size());
408 B2DEBUG(29,
"Finished checking if previous crate time payload has changed");
412 B2DEBUG(29,
"Finished checking if reference crystal cell ids payload has changed");
415 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrystalTimeOffset from the database"
418 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrateTimeOffset from the database"
421 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrystalElectronics from the database"
424 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrystalElectronicsTime from the database"
427 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrystalFlightTime from the database"
430 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLReferenceCrystalPerCrateCalib from the database"
442 vector<float> Crate_time_ns(52, 0.0);
447 Crate_time_ns[crateID_temp - 1] =
m_CrateTime[crysID] * TICKS_TO_NS;
457 for (
int crateID_temp = 1; crateID_temp <= 52; crateID_temp++) {
458 getObjectPtr<TH1F>(
"refCrysIDzeroingCrate")->Fill(
m_RefCrystalsCalib[crateID_temp - 1] + 0.001);
466 getObjectPtr<TH1F>(
"TcrateDatabase")->SetBinContent(crysID + 0.001,
m_CrateTime[crysID - 1]);
467 getObjectPtr<TH1F>(
"TcrateUncDatabase")->SetBinContent(crysID + 0.001,
m_CrateTimeUnc[crysID - 1]);
470 B2INFO(
"ECLBhabhaTCollector:: ECLCrystalTimeOffset from the database information:"
473 B2INFO(
"First event so print out previous ts values");
483 for (
int crateID_temp = 1; crateID_temp <= 52; crateID_temp++) {
484 getObjectPtr<TH1F>(
"tcrateDatabase_ns")->SetBinContent(crateID_temp + 0.001, Crate_time_ns[crateID_temp - 1]);
489 getObjectPtr<TH1I>(
"databaseCounter")->SetBinContent(1, 1);
501 double evt_t0_unc = -1;
502 double evt_t0_ECL_closestSVD = -1;
503 double evt_t0_ECL_minChi2 = -1;
509 }
else if (!
m_eventT0->hasTemporaryEventT0(Const::EDetector::SVD)) {
515 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
516 B2DEBUG(22,
"Cutflow: Event t0 exists: index = " << cutIndexPassed);
519 const auto bestSVDEventT0Candidate =
m_eventT0->getBestSVDTemporaryEventT0();
520 evt_t0 = bestSVDEventT0Candidate->eventT0;
521 evt_t0_unc = bestSVDEventT0Candidate->eventT0Uncertainty;
522 getObjectPtr<TH1D>(
"svdEventT0")->Fill(evt_t0);
529 if (
m_eventT0->hasTemporaryEventT0(Const::EDetector::ECL)) {
530 vector<EventT0::EventT0Component> evt_t0_list_ECL =
m_eventT0->getTemporaryEventT0s(Const::EDetector::ECL);
533 double smallest_SVD_ECL_t0_diff = fabs(evt_t0_list_ECL[0].eventT0 - evt_t0);
534 int smallest_SVD_ECL_t0_diff_idx = 0;
535 for (
long unsigned int ECLi = 0; ECLi < evt_t0_list_ECL.size(); ECLi++) {
536 double tempt_ECL_t0 = evt_t0_list_ECL[ECLi].eventT0;
537 if (fabs(tempt_ECL_t0 - evt_t0) < smallest_SVD_ECL_t0_diff) {
538 smallest_SVD_ECL_t0_diff = fabs(tempt_ECL_t0 - evt_t0);
539 smallest_SVD_ECL_t0_diff_idx = ECLi;
543 evt_t0_ECL_closestSVD = evt_t0_list_ECL[smallest_SVD_ECL_t0_diff_idx].eventT0;
544 B2DEBUG(26,
"evt_t0_ECL_closestSVD = " << evt_t0_ECL_closestSVD);
548 double smallest_ECL_t0_minChi2 = evt_t0_list_ECL[0].quality;
549 int smallest_ECL_t0_minChi2_idx = 0;
551 B2DEBUG(26,
"evt_t0_list_ECL[0].quality = " << evt_t0_list_ECL[0].quality
552 <<
", with ECL event t0 = " << evt_t0_list_ECL[0].eventT0);
554 for (
long unsigned int ECLi = 0; ECLi < evt_t0_list_ECL.size(); ECLi++) {
555 B2DEBUG(26,
"evt_t0_list_ECL[" << ECLi <<
"].quality = " << evt_t0_list_ECL[ECLi].quality
556 <<
", with ECL event t0 = " <<
557 evt_t0_list_ECL[ECLi].eventT0);
558 if (evt_t0_list_ECL[ECLi].quality < smallest_ECL_t0_minChi2) {
559 smallest_ECL_t0_minChi2 = evt_t0_list_ECL[ECLi].quality;
560 smallest_ECL_t0_minChi2_idx = ECLi;
564 evt_t0_ECL_minChi2 = evt_t0_list_ECL[smallest_ECL_t0_minChi2_idx].eventT0;
566 B2DEBUG(26,
"evt_t0_ECL_minChi2 = " << evt_t0_ECL_minChi2);
567 B2DEBUG(26,
"smallest_ECL_t0_minChi2_idx = " << smallest_ECL_t0_minChi2_idx);
585 int tempCrysID = eclCalDigit.getCellId() - 1;
586 m_EperCrys[tempCrysID] = eclCalDigit.getEnergy();
593 int tempCrysID = eclDigit.getCellId() - 1;
608 double maxp[2] = {0., 0.};
609 int maxiTrk[2] = { -1, -1};
610 int nTrkAll =
tracks.getEntries();
618 for (
int iTrk = 0; iTrk < nTrkAll; iTrk++) {
622 if (not tempTrackFit) {
continue;}
626 double z0 = tempTrackFit->
getZ0();
627 double d0 = tempTrackFit->
getD0();
682 if (charge > 0) {icharge = 1;}
683 if (p > maxp[icharge]) {
685 maxiTrk[icharge] = iTrk;
694 if (nTrkTight != 2) {
699 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
700 B2DEBUG(22,
"Cutflow: Two tight tracks: index = " << cutIndexPassed);
703 if (nTrkLoose != 2) {
708 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
709 B2DEBUG(22,
"Cutflow: No additional loose tracks: index = " << cutIndexPassed);
715 bool oppositelyChargedTracksPassed = maxiTrk[0] != -1 && maxiTrk[1] != -1;
716 if (!oppositelyChargedTracksPassed) {
721 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
722 B2DEBUG(22,
"Cutflow: Oppositely charged tracks: index = " << cutIndexPassed);
731 double trkEClustLab[2] = {0., 0.};
732 double trkEClustCOM[2] = {0., 0.};
735 ROOT::Math::PxPyPzEVector trkp4Lab[2];
736 ROOT::Math::PxPyPzEVector trkp4COM[2];
739 int crysIDMax[2] = { -1, -1 };
740 double crysEMax[2] = { -1, -1 };
741 double crysE2Max[2] = { -1, -1 };
742 int numClustersPerTrack[2] = { 0, 0 };
744 double clusterTime[2] = {0, 0};
748 vector<double> time_ECLCaldigits_bothClusters;
749 vector<int> cid_ECLCaldigits_bothClusters;
750 vector<double> E_ECLCaldigits_bothClusters;
751 vector<double> amp_ECLDigits_bothClusters;
752 vector<int> chargeID_ECLCaldigits_bothClusters;
754 for (
int icharge = 0; icharge < 2; icharge++) {
755 if (maxiTrk[icharge] > -1) {
756 B2DEBUG(22,
"looping over the 2 max pt tracks");
759 if (not tempTrackFit) {
continue;}
761 trkp4COM[icharge] = boostrotate.
rotateLabToCms() * trkp4Lab[icharge];
762 trkpLab[icharge] = trkp4Lab[icharge].P();
763 trkpCOM[icharge] = trkp4COM[icharge].P();
769 auto eclClusterRelationsFromTracks =
tracks[maxiTrk[icharge]]->getRelationsTo<
ECLCluster>();
770 for (
unsigned int clusterIdx = 0; clusterIdx < eclClusterRelationsFromTracks.size(); clusterIdx++) {
772 B2DEBUG(22,
"Looking at clusters. index = " << clusterIdx);
773 auto cluster = eclClusterRelationsFromTracks[clusterIdx];
774 bool goodClusterType =
false;
778 goodClusterType =
true;
779 numClustersPerTrack[icharge]++;
782 if (goodClusterType) {
784 clusterTime[icharge] = cluster->getTime();
786 auto eclClusterRelations = cluster->getRelationsTo<
ECLCalDigit>(
"ECLCalDigits");
789 for (
unsigned int ir = 0; ir < eclClusterRelations.size(); ir++) {
790 const auto calDigit = eclClusterRelations.object(ir);
791 int tempCrysID = calDigit->
getCellId() - 1;
798 if (tempE > crysEMax[icharge]) {
800 crysE2Max[icharge] = crysEMax[icharge];
802 crysEMax[icharge] = tempE;
803 crysIDMax[icharge] = tempCrysID;
806 if (tempE > crysE2Max[icharge] && tempCrysID != crysIDMax[icharge]) {
807 crysE2Max[icharge] = tempE;
814 B2DEBUG(26,
"calDigit(ir" << ir <<
") time = " << calDigit->getTime() <<
"ns , with E = " << tempE <<
" GeV");
815 time_ECLCaldigits_bothClusters.push_back(calDigit->getTime());
816 cid_ECLCaldigits_bothClusters.push_back(tempCrysID);
817 E_ECLCaldigits_bothClusters.push_back(tempE);
818 amp_ECLDigits_bothClusters.push_back(ecl_dig->
getAmp());
819 chargeID_ECLCaldigits_bothClusters.push_back(icharge);
824 trkEClustCOM[icharge] = trkEClustLab[icharge] * trkpCOM[icharge] / trkpLab[icharge];
829 E_DIV_p[icharge] = trkEClustCOM[icharge] / trkpCOM[icharge];
841 int numCrystalsPassingCuts = 0;
843 int crystalIDs[2] = { -1, -1};
844 int crateIDs[2] = { -1, -1};
845 double ts_prevCalib[2] = { -1, -1};
846 double tcrate_prevCalib[2] = { -1, -1};
847 double times_noPreviousCalibrations[2] = { -1, -1};
848 bool crystalCutsPassed[2] = {
false,
false};
849 double crystalEnergies[2] = { -1, -1};
850 double crystalEnergies2[2] = { -1, -1};
852 for (
int iCharge = 0; iCharge < 2; iCharge++) {
853 int crystal_idx = crysIDMax[iCharge];
863 auto amplitude = ecl_dig->
getAmp();
864 crystalEnergies[iCharge] = en;
867 double time = ecl_dig->
getTimeFit() * TICKS_TO_NS - evt_t0;
876 double energyTimeShift =
m_ECLTimeUtil->energyDependentTimeOffsetElectronic(amplitude *
m_Electronics[cid - 1]) * TICKS_TO_NS;
878 B2DEBUG(29,
"cellid = " << cid <<
", amplitude = " << amplitude <<
", time before t(E) shift = " << time <<
879 ", t(E) shift = " << energyTimeShift <<
" ns");
880 time -= energyTimeShift;
893 crystalIDs[iCharge] = cid;
898 tcrate_prevCalib[iCharge] =
m_CrateTime[cid - 1] * TICKS_TO_NS;
899 times_noPreviousCalibrations[iCharge] = time;
902 B2DEBUG(26,
"iCharge = " << iCharge);
903 B2DEBUG(26,
"crateIDs[iCharge] = " << crateIDs[iCharge]);
904 B2DEBUG(26,
"times_noPreviousCalibrations[iCharge] = " << times_noPreviousCalibrations[iCharge]);
905 B2DEBUG(26,
"tcrate_prevCalib[iCharge] = " << tcrate_prevCalib[iCharge]);
906 B2DEBUG(26,
"ts_prevCalib[iCharge] = " << ts_prevCalib[iCharge]);
909 crystalCutsPassed[iCharge] =
true;
913 crystalEnergies2[iCharge] = crysE2Max[iCharge];
941 getObjectPtr<TH1F>(
"maxEcrsytalEnergyFraction")->Fill(en / trkEClustLab[iCharge]);
951 bool E_DIV_p_instance_passed[2] = {
false,
false};
952 double E_DIV_p_CUT = 0.7;
953 for (
int icharge = 0; icharge < 2; icharge++) {
954 E_DIV_p_instance_passed[icharge] = E_DIV_p[icharge] > E_DIV_p_CUT;
956 if (!E_DIV_p_instance_passed[0] || !E_DIV_p_instance_passed[1]) {
961 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
962 B2DEBUG(22,
"Cutflow: E_i/p_i > " << E_DIV_p_CUT <<
": index = " << cutIndexPassed);
968 double invMassTrk = (trkp4Lab[0] + trkp4Lab[1]).M();
969 double invMass_CUT = 0.9;
978 bool invMassCutsPassed = invMassTrk > (invMass_CUT * boostrotate.
getCMSEnergy());
979 if (!invMassCutsPassed) {
984 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
985 B2DEBUG(22,
"Cutflow: m(track 1+2) > " << invMass_CUT <<
"*E_COM = " << invMass_CUT <<
" * " << boostrotate.
getCMSEnergy() <<
986 " : index = " << cutIndexPassed);
991 for (
int iCharge = 0; iCharge < 2; iCharge++) {
992 if (crystalCutsPassed[iCharge]) {
993 getObjectPtr<TH2F>(
"TimevsCrysPrevCrateCalibPrevCrystCalib")->Fill((crystalIDs[iCharge]) + 0.001,
994 times_noPreviousCalibrations[iCharge] - ts_prevCalib[iCharge] - tcrate_prevCalib[iCharge], 1);
995 getObjectPtr<TH2F>(
"TimevsCratePrevCrateCalibPrevCrystCalib")->Fill((crateIDs[iCharge]) + 0.001,
996 times_noPreviousCalibrations[iCharge] - ts_prevCalib[iCharge] - tcrate_prevCalib[iCharge], 1);
997 getObjectPtr<TH2F>(
"TimevsCrysNoCalibrations")->Fill((crystalIDs[iCharge]) + 0.001, times_noPreviousCalibrations[iCharge], 1);
998 getObjectPtr<TH2F>(
"TimevsCrateNoCalibrations")->Fill((crateIDs[iCharge]) + 0.001, times_noPreviousCalibrations[iCharge], 1);
999 getObjectPtr<TH2F>(
"TimevsCrysPrevCrateCalibNoCrystCalib")->Fill((crystalIDs[iCharge]) + 0.001,
1000 times_noPreviousCalibrations[iCharge] - tcrate_prevCalib[iCharge], 1);
1001 getObjectPtr<TH2F>(
"TimevsCrateNoCrateCalibPrevCrystCalib")->Fill((crateIDs[iCharge]) + 0.001,
1002 times_noPreviousCalibrations[iCharge] - ts_prevCalib[iCharge], 1);
1005 numCrystalsPassingCuts++;
1013 if (crystalCutsPassed[0] || crystalCutsPassed[1]) {
1016 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
1017 B2DEBUG(22,
"Cutflow: At least one crystal time and quality cuts passed: index = " << cutIndexPassed);
1019 getObjectPtr<TH1F>(
"numCrystalEntriesPerEvent")->Fill(numCrystalsPassingCuts);
1024 for (
int iCharge = 0; iCharge < 2; iCharge++) {
1025 if (crystalCutsPassed[iCharge]) {
1030 m_tree_time = times_noPreviousCalibrations[iCharge];
1034 m_tree_E1Etot = crystalEnergies[iCharge] / trkEClustLab[iCharge];
1035 m_tree_E1E2 = crystalEnergies[iCharge] / crystalEnergies2[iCharge];
1036 m_tree_E1p = crystalEnergies[iCharge] / trkpLab[iCharge];
1055 if (crystalCutsPassed[0] && crystalCutsPassed[1] &&
1056 numClustersPerTrack[0] == 1 && numClustersPerTrack[1] == 1) {
1077 B2DEBUG(26,
"SVD evt_t0 = " << evt_t0);
1082 for (
long unsigned int digit_i = 0; digit_i < time_ECLCaldigits_bothClusters.size(); digit_i++) {
1092 ts_prevCalib[chargeID_ECLCaldigits_bothClusters[digit_i]] -
1093 tcrate_prevCalib[chargeID_ECLCaldigits_bothClusters[digit_i]];
1094 m_tree_cid = cid_ECLCaldigits_bothClusters[digit_i];
1105 B2DEBUG(26,
"This was for event number = " <<
m_tree_evtNum);
Calibration collector module base class.
static const ChargedStable pion
charged pion particle
bool hasChanged()
Check whether the object has changed since the last call to hasChanged of the accessor).
double m_tree_d0
Track d0 for debug TTree output.
double m_tree_maxEcrystNegClust
Time of the highest energy crystal in the cluster associated to negatively charged track,...
std::vector< float > m_CrateTime
vector obtained from DB object
std::vector< int > m_eclDigitID
ECL digit id sorter.
double m_tree_timeF
ECL fitting time for debug TTree output.
double m_tree_E1Etot
Energy of crystal with maximum energy within ECL cluster divided by total cluster energy,...
double m_tree_tClustNeg
Cluster time of cluster associated to negatively charged track, ns for debug TTree output.
DBObjPtr< ECLCrystalCalib > m_CrateTimeDB
Time offset from crate time calibration (also this calibration) from database.
TTree * m_dbgTree_crystals
Debug TTree output per crystal.
StoreObjPtr< EventT0 > m_eventT0
StoreObjPtr for T0.
StoreArray< ECLDigit > m_eclDigitArray
Required input array of ECLDigits.
double m_tree_clustCrysE
crystal energy, only for the crystals that meet all the selection criteria for debug TTree output
std::vector< float > m_FlightTime
vector obtained from DB object
double m_tree_timetsPreviousTimeCalibs
Time for Ts distribution after application of previous time calibrations for debug TTree output.
double m_looseTrkD0
Loose track d0 minimum cut.
double m_tree_E1E2
Energy of crystal with maximum energy within ECL cluster divided by second most energetic crystal in ...
double m_tree_ECLDigitAmplitude
Amplitude (used to calculate energy) of an ECLDigit within a cluster, for debug TTree output.
double m_tree_tClustPos
Cluster time of cluster associated to positively charged track, ns for debug TTree output.
int m_tree_quality
ECL fit quality for debug TTree output.
bool m_saveTree
If true, save TTree with more detailed event info.
double m_tree_enNeg
Energy of cluster associated to negatively charged track, GeV for debug TTree output.
DBObjPtr< ECLCrystalCalib > m_ElectronicsTimeDB
Time offset from electronics calibration from database.
double m_tree_tClust
Cluster time of a cluster, ns for debug TTree output.
double m_E_DIV_p
Energy divided by momentum, for debug TTree output.
double m_tree_en
Energy of crystal with maximum energy within ECL cluster, GeV for debug TTree output.
int m_minCrystal
First CellId to handle.
std::vector< int > m_eclCalDigitID
ECL cal digit id sorter.
bool m_storeCalib
Boolean for whether or not to store the previous calibration calibration constants.
StoreArray< ECLCluster > m_eclClusterArray
Required input array of ECLClusters.
double m_tree_t0_ECLclosestSVD
EventT0 (from ECL) closest to SVD for debug TTree output.
short m_timeAbsMax
Events with abs(time) > m_timeAbsMax are excluded, mostly for histogram x-range purposes.
DBObjPtr< ECLReferenceCrystalPerCrateCalib > m_RefCrystalsCalibDB
Crystal IDs of the one reference crystal per crate from database.
int m_crystalCrate
Crate id for the crystal.
int m_tree_cid
ECL Cell ID (1..ECLElementNumbers::c_NCrystals) for debug TTree output.
double m_tree_time
Time for Ts distribution for debug TTree output.
double m_massInvTracks
invariant mass of the two tracks, for debug TTree output
double m_tree_nCDChits
Number of CDC hits along the track for debug TTree output.
double m_tree_enPlus
Energy of cluster associated to positively charged track, GeV for debug TTree output.
int m_tree_evtNum
Event number for debug TTree output.
double m_tightTrkZ0
Tight track z0 minimum cut.
DBObjPtr< Belle2::ECLChannelMap > m_channelMapDB
Mapper of ecl channels to various other objects, like crates.
std::vector< short > m_RefCrystalsCalib
vector obtained from DB object
double m_tree_t0_ECL_minChi2
EventT0 (from ECL) min chi2 for debug TTree output.
double m_tree_maxEcrystPosClust
Time of the highest energy crystal in the cluster associated to positively charged track,...
void collect() override
Select events and crystals and accumulate histograms.
std::vector< float > m_CrateTimeUnc
uncertainty vector obtained from DB object
TTree * m_dbgTree_allCuts
Debug TTree output after all cuts.
double m_tree_ECLCalDigitTime
Time of an ECLCalDigit within a cluster, ns for debug TTree output.
StoreArray< ECLCalDigit > m_eclCalDigitArray
Required input array of ECLCalDigits.
TTree * m_dbgTree_event
Debug TTree output per event.
double m_tree_z0
Track z0 for debug TTree output.
std::vector< float > m_EperCrys
ECL cal digit energy for each crystal.
bool skipTrgSel
flag to skip the trigger skim selection in the module
double m_tree_p
Track momentum for debug TTree output.
void prepare() override
Define histograms and read payloads from DB.
std::vector< float > m_PreviousCrystalTime
vector obtained from DB object
int m_maxCrystal
Last CellId to handle.
DBObjPtr< ECLCrystalCalib > m_PreviousCrystalTimeDB
Time offset from previous crystal time calibration (this calibration) from database.
double m_tightTrkD0
Tight track d0 minimum cut.
double m_tree_t0
EventT0 (not from ECL) for debug TTree output.
int m_tree_amp
Fitting amplitude from ECL for debug TTree output.
double m_tree_E1p
Energy of crystal with maximum energy within ECL cluster divided by total cluster energy divided by t...
TTree * m_dbgTree_evt_allCuts
Debug TTree output per event after all cuts.
std::vector< float > m_Electronics
vector obtained from DB object
void inDefineHisto() override
Replacement for defineHisto() in CalibrationCollector modules.
int m_charge
particle charge, for debug TTree output
TTree * m_dbgTree_electrons
Output tree with detailed event data.
std::vector< float > m_PreviousCrystalTimeUnc
vector obtained from DB object
std::unique_ptr< Belle2::ECL::ECLTimingUtilities > m_ECLTimeUtil
ECL timing tools.
StoreArray< Track > tracks
StoreArray for tracks.
TTree * m_dbgTree_crys_allCuts
Debug TTree output per crystal after all cuts.
double m_tree_clustCrysE_DIV_maxEcrys
ratio of crystal energy to energy of the crystal that has the maximum energy, only for the crystals t...
DBObjPtr< ECLCrystalCalib > m_FlightTimeDB
Time offset from flight time b/w IP and crystal from database.
DBObjPtr< ECLCrystalCalib > m_ElectronicsDB
electronics amplitude calibration from database Scale amplitudefor each crystal and for dead pre-amps
double m_tree_ECLCalDigitE
Energy of an ECLCalDigit within a cluster, GeV for debug TTree output.
StoreObjPtr< EventMetaData > m_EventMetaData
Event metadata.
double m_tree_t0_unc
EventT0 uncertainty for debug TTree output.
std::unique_ptr< Belle2::ECL::ECLChannelMapper > m_crystalMapper
ECL object for keeping track of mapping between crystals and crates etc.
virtual ~ECLBhabhaTCollectorModule()
Module destructor.
double m_hadronEventT0_TO_bhabhaEventT0_correction
correction to apply to SVD event t0 values in bhabha events to correct for SVD event t0 bias compared...
std::vector< float > m_ElectronicsTime
vector obtained from DB object
ECLBhabhaTCollectorModule()
Module constructor.
StoreObjPtr< SoftwareTriggerResult > m_TrgResult
Store array for Trigger selection.
TTree * m_dbgTree_tracks
Debug TTree output per track.
double m_looseTrkZ0
Loose track z0 minimum cut.
Class to store calibrated ECLDigits: ECLCalDigits.
int getCellId() const
Get Cell ID.
double getEnergy() const
Get Calibrated Energy.
@ c_nPhotons
CR is split into n photons (N1)
Class to store ECL digitized hits (output of ECLDigi) relation to ECLHit filled in ecl/modules/eclDig...
int getAmp() const
Get Fitting Amplitude.
int getQuality() const
Get Fitting Quality.
int getCellId() const
Get Cell ID.
int getTimeFit() const
Get Fitting Time.
static double getRF()
See m_rf.
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Values of the result of a track fit with a given particle hypothesis.
short getChargeSign() const
Return track charge (1 or -1).
ROOT::Math::PxPyPzEVector get4Momentum() const
Getter for the 4Momentum at the closest approach of the track in the r/phi projection.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
Class to store variables with their name which were sent to the logging service.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
@ c_accept
Accept this event.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.