11 #include <top/modules/collectors/TOPAsicShiftsBS13dCollectorModule.h>
12 #include <top/geometry/TOPGeometryPar.h>
41 setDescription(
"A collector for calibration of carrier shifts of BS13d.");
42 setPropertyFlags(c_ParallelProcessingCertified);
45 addParam(
"timeOffset", m_timeOffset,
"time offset", 0.0);
46 addParam(
"nx", m_nx,
"number of histogram bins (bin size ~8 ns)", 50);
47 addParam(
"requireRecBunch", m_requireRecBunch,
48 "if True, require reconstructed bunch (to be used on cdst files only!)",
54 void TOPAsicShiftsBS13dCollectorModule::prepare()
57 m_topDigits.isRequired();
58 if (m_requireRecBunch) {
59 m_recBunch.isRequired();
61 m_recBunch.isOptional();
64 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
65 double timeStep = geo->getNominalTDC().getSyncTimeBase() / 6;
66 double xmi = - m_nx * timeStep / 2;
67 double xma = m_nx * timeStep / 2;
69 auto time_vs_BS =
new TH2F(
"time_vs_BS",
"time vs BS, slot 13",
70 16, 0.0, 512.0, m_nx, xmi, xma);
71 time_vs_BS->SetXTitle(
"channel number");
72 time_vs_BS->SetYTitle(
"time [ns]");
73 registerObject<TH2F>(
"time_vs_BS", time_vs_BS);
75 auto timeReference =
new TH1F(
"time_reference",
"time, slot 13(a, b, c)",
77 timeReference->SetXTitle(
"time [ns]");
78 timeReference->SetYTitle(
"entries per bin [arbitrary]");
79 registerObject<TH1F>(
"time_reference", timeReference);
81 for (
unsigned i = 0; i < 4; i++) {
82 string name =
"time_carr_" + to_string(i);
83 string title =
"time, slot 13d, carrier " + to_string(i);
84 auto h =
new TH1F(name.c_str(), title.c_str(), m_nx, xmi, xma);
85 h->SetXTitle(
"time [ns]");
86 h->SetYTitle(
"entries per bin [arbitrary]");
87 registerObject<TH1F>(name, h);
93 void TOPAsicShiftsBS13dCollectorModule::collect()
96 if (m_requireRecBunch) {
97 if (not m_recBunch.isValid())
return;
98 if (not m_recBunch->isReconstructed())
return;
101 auto time_vs_BS = getObjectPtr<TH2F>(
"time_vs_BS");
102 auto timeReference = getObjectPtr<TH1F>(
"time_reference");
103 std::vector<TH1F*> timeCarriers;
104 for (
unsigned i = 0; i < 4; i++) {
105 string name =
"time_carr_" + to_string(i);
106 auto h = getObjectPtr<TH1F>(name);
107 timeCarriers.push_back(h);
110 for (
const auto& digit : m_topDigits) {
111 if (digit.getModuleID() != 13)
continue;
112 if (digit.getHitQuality() != TOPDigit::c_Good)
continue;
113 double time = digit.getTime() - m_timeOffset;
114 time_vs_BS->Fill(digit.getChannel(), time);
115 if (digit.getBoardstackNumber() < 3) {
116 timeReference->Fill(time);
118 auto c = digit.getCarrierNumber();
119 timeCarriers[c]->Fill(time);