12 #include <klm/eklm/modules/EKLMTimeCalibration/EKLMTimeCalibrationCollectorModule.h>
15 #include <klm/dataobjects/eklm/EKLMHit2d.h>
18 #include <framework/gearbox/Unit.h>
19 #include <tracking/dataobjects/ExtHit.h>
31 m_TransformData(
nullptr),
36 setDescription(
"Module for EKLM time calibration (data collection).");
37 setPropertyFlags(c_ParallelProcessingCertified);
38 addParam(
"UseEventT0", m_UseEventT0,
"Calibrate relatively to event T0.",
59 t =
new TTree(
"calibration_data",
"");
60 t->Branch(
"time", &
m_ev.
time,
"time/F");
61 t->Branch(
"dist", &
m_ev.
dist,
"dist/F");
62 t->Branch(
"npe", &
m_ev.
npe,
"npe/F");
63 t->Branch(
"strip", &
m_Strip,
"strip/I");
64 registerObject<TTree>(
"calibration_data", t);
74 std::multimap<int, ExtHit*> mapExtHit;
75 std::multimap<int, ExtHit*>::iterator it, itLower, itUpper;
76 ExtHit* extHit, *entryHit[2], *exitHit[2];
77 const HepGeom::Transform3D* tr;
78 TTree* calibrationData = getObjectPtr<TTree>(
"calibration_data");
82 B2ERROR(
"Event T0 is not determined. "
83 "Cannot collect data for EKLM time calibration.");
87 for (i = 0; i < n; i++) {
90 for (j = 0; j < n2; j++) {
91 if (extHits[j]->getDetectorID() != Const::EDetector::EKLM)
95 mapExtHit.insert(std::pair<int, ExtHit*>(extHits[j]->getCopyID(),
100 for (i = 0; i < n; i++) {
103 if (digits.size() != 2)
104 B2FATAL(
"Wrong number of related KLMDigits.");
109 if (digits[0]->getNPhotoelectrons() == 0 || digits[1]->getNPhotoelectrons() == 0)
111 for (j = 0; j < 2; j++) {
112 entryHit[j] =
nullptr;
113 exitHit[j] =
nullptr;
115 digits[j]->getSection(), digits[j]->getLayer(),
116 digits[j]->getSector(), digits[j]->getPlane(),
117 digits[j]->getStrip());
118 itLower = mapExtHit.lower_bound(vol);
119 itUpper = mapExtHit.upper_bound(vol);
120 for (it = itLower; it != itUpper; ++it) {
124 if (entryHit[j] ==
nullptr) {
125 entryHit[j] = extHit;
128 entryHit[j] = extHit;
132 if (exitHit[j] ==
nullptr) {
144 if (entryHit[0] ==
nullptr || exitHit[0] ==
nullptr ||
145 entryHit[1] ==
nullptr || exitHit[1] ==
nullptr)
147 for (j = 0; j < 2; j++) {
148 hitTime = 0.5 * (entryHit[j]->
getTOF() + exitHit[j]->
getTOF());
150 hitTime = hitTime +
m_EventT0->getEventT0();
155 hitGlobal.setX(hitPosition.X() /
Unit::mm * CLHEP::mm);
156 hitGlobal.setY(hitPosition.Y() /
Unit::mm * CLHEP::mm);
157 hitGlobal.setZ(hitPosition.Z() /
Unit::mm * CLHEP::mm);
159 hitLocal = (*tr) * hitGlobal;
160 m_ev.
time = digits[j]->getTime() - hitTime;
162 m_ev.
npe = digits[j]->getNPhotoelectrons();
164 digits[j]->getSection(), digits[j]->getLayer(),
165 digits[j]->getSector(), digits[j]->getPlane(),
166 digits[j]->getStrip());
167 calibrationData->Fill();