9 #include <top/modules/collectors/TOPAsicShiftsBS13dCollectorModule.h>
10 #include <top/geometry/TOPGeometryPar.h>
36 TOPAsicShiftsBS13dCollectorModule::TOPAsicShiftsBS13dCollectorModule()
39 setDescription(
"A collector for calibration of carrier shifts of BS13d.");
40 setPropertyFlags(c_ParallelProcessingCertified);
43 addParam(
"timeOffset", m_timeOffset,
"time offset", 0.0);
44 addParam(
"nx", m_nx,
"number of histogram bins (bin size ~8 ns)", 50);
45 addParam(
"requireRecBunch", m_requireRecBunch,
46 "if True, require reconstructed bunch (to be used on cdst files only!)",
52 void TOPAsicShiftsBS13dCollectorModule::prepare()
55 m_topDigits.isRequired();
56 if (m_requireRecBunch) {
57 m_recBunch.isRequired();
59 m_recBunch.isOptional();
62 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
63 double timeStep = geo->getNominalTDC().getSyncTimeBase() / 6;
64 double xmi = - m_nx * timeStep / 2;
65 double xma = m_nx * timeStep / 2;
67 auto time_vs_BS =
new TH2F(
"time_vs_BS",
"time vs BS, slot 13",
68 16, 0.0, 512.0, m_nx, xmi, xma);
69 time_vs_BS->SetXTitle(
"channel number");
70 time_vs_BS->SetYTitle(
"time [ns]");
71 registerObject<TH2F>(
"time_vs_BS", time_vs_BS);
73 auto timeReference =
new TH1F(
"time_reference",
"time, slot 13(a, b, c)",
75 timeReference->SetXTitle(
"time [ns]");
76 timeReference->SetYTitle(
"entries per bin [arbitrary]");
77 registerObject<TH1F>(
"time_reference", timeReference);
79 for (
unsigned i = 0; i < 4; i++) {
80 string name =
"time_carr_" + to_string(i);
81 string title =
"time, slot 13d, carrier " + to_string(i);
82 auto h =
new TH1F(name.c_str(), title.c_str(), m_nx, xmi, xma);
83 h->SetXTitle(
"time [ns]");
84 h->SetYTitle(
"entries per bin [arbitrary]");
85 registerObject<TH1F>(name, h);
91 void TOPAsicShiftsBS13dCollectorModule::collect()
94 if (m_requireRecBunch) {
95 if (not m_recBunch.isValid())
return;
96 if (not m_recBunch->isReconstructed())
return;
99 auto time_vs_BS = getObjectPtr<TH2F>(
"time_vs_BS");
100 auto timeReference = getObjectPtr<TH1F>(
"time_reference");
101 std::vector<TH1F*> timeCarriers;
102 for (
unsigned i = 0; i < 4; i++) {
103 string name =
"time_carr_" + to_string(i);
104 auto h = getObjectPtr<TH1F>(name);
105 timeCarriers.push_back(h);
108 for (
const auto& digit : m_topDigits) {
109 if (digit.getModuleID() != 13)
continue;
110 if (digit.getHitQuality() != TOPDigit::c_Good)
continue;
111 double time = digit.getTime() - m_timeOffset;
112 time_vs_BS->Fill(digit.getChannel(), time);
113 if (digit.getBoardstackNumber() < 3) {
114 timeReference->Fill(time);
116 auto c = digit.getCarrierNumber();
117 timeCarriers[c]->Fill(time);
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.