11 #include <top/modules/TOPLaserCalibratorCollector/TOPLaserCalibratorCollectorModule.h>
18 #include <top/dataobjects/TOPDigit.h>
19 #include <top/dataobjects/TOPRawDigit.h>
20 #include <top/dataobjects/TOPSimHit.h>
32 setDescription(
"Collector module for the TOP ChannelT0 calibration and the quality monitoring using laser and pulser data");
33 setPropertyFlags(c_ParallelProcessingCertified);
35 addParam(
"useReferencePulse", m_useReferencePulse,
"Use the pulser as reference",
bool(
false));
36 addParam(
"refChannel", m_refChannel,
"Channel to be used as reference");
37 addParam(
"refSlot", m_refSlot,
"Slot to be used as reference");
38 addParam(
"pulserDeltaT", m_pulserDeltaT,
"Approximate time difference between the two calpulses, in ns",
float(21.8));
39 addParam(
"pulserDeltaTTolerance", m_pulserDeltaTTolerance,
"Window around the nominal deltaT used to select a double pulse, in ns ",
41 addParam(
"storeMCTruth", m_storeMCTruth,
" Store the TOPSimHits information instead of the TOPDigit one. \
42 If this option is used, useReferencePulse will be automatically set to false.");
53 auto hitTree =
new TTree(
"hitTree",
"hitTree");
54 hitTree->Branch<
short>(
"channel", &
m_channel);
55 hitTree->Branch<
short>(
"slot", &
m_slot);
56 hitTree->Branch<
float>(
"hitTime", &
m_hitTime);
57 hitTree->Branch<
float>(
"dVdt", &
m_dVdt);
58 hitTree->Branch<
float>(
"refTime", &
m_refTime);
60 hitTree->Branch<
float>(
"width", &
m_width);
61 hitTree->Branch<
short>(
"sample", &
m_sample);
62 hitTree->Branch<
short>(
"window", &
m_window);
63 hitTree->Branch<
int>(
"event", &
m_event);
66 registerObject<TTree>(
"hitTree", hitTree);
81 float refTimes[16] = {0.};
82 std::vector<bool> refTimesValid(16,
true);
87 std::vector<float> calPulseTimes[16];
89 if (digit.getHitQuality() != TOPDigit::c_CalPulse or digit.getChannel() !=
m_refChannel)
91 calPulseTimes[digit.getModuleID() - 1].push_back(digit.getTime());
94 for (
int i = 0; i < 16; i++) {
95 refTimesValid[i] =
false;
96 auto& calTimes = calPulseTimes[i];
97 if (calTimes.size() < 2)
continue;
98 std::sort(calTimes.begin(), calTimes.end());
99 for (
unsigned k = 0; k < calTimes.size() - 1; k++) {
100 auto t1 = calTimes[k];
101 auto t2 = calTimes[k + 1];
104 refTimesValid[i] =
true;
112 TTree* hitTree = getObjectPtr<TTree>(
"hitTree");
116 if (digit.getHitQuality() == TOPDigit::c_Junk)
continue;
118 m_slot = digit.getModuleID();
119 m_dVdt = 0.5 * TMath::Sqrt(-2.*TMath::Log(0.5)) * digit.getPulseHeight() / digit.getPulseWidth();
130 m_width = digit.getPulseWidth();
133 const auto* simHit = digit.getRelated<
TOPSimHit>();
134 if (not simHit)
continue;
141 const auto* rawDigit = digit.getRelated<
TOPRawDigit>();
142 if (rawDigit)
m_window = rawDigit->getASICWindow();
143 m_sample = digit.getModulo256Sample();