Belle II Software development
TOPAsicShiftsBS13dCollectorModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <top/modules/collectors/TOPAsicShiftsBS13dCollectorModule.h>
10#include <top/geometry/TOPGeometryPar.h>
11#include <string>
12#include <vector>
13#include <TH1F.h>
14#include <TH2F.h>
15
16using namespace std;
17
18namespace Belle2 {
24 using namespace TOP;
25
26 //-----------------------------------------------------------------
28 //-----------------------------------------------------------------
29
30 REG_MODULE(TOPAsicShiftsBS13dCollector);
31
32 //-----------------------------------------------------------------
33 // Implementation
34 //-----------------------------------------------------------------
35
37 {
38 // set module description and processing properties
39 setDescription("A collector for calibration of carrier shifts of BS13d.");
41
42 // module parameters
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!)",
47 false);
48
49 }
50
51
53 {
54
55 m_topDigits.isRequired();
57 m_recBunch.isRequired();
58 } else {
59 m_recBunch.isOptional();
60 }
61
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;
66
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);
72
73 auto timeReference = new TH1F("time_reference", "time, slot 13(a, b, c)",
74 m_nx, xmi, xma);
75 timeReference->SetXTitle("time [ns]");
76 timeReference->SetYTitle("entries per bin [arbitrary]");
77 registerObject<TH1F>("time_reference", timeReference);
78
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);
86 }
87
88 }
89
90
92 {
93
95 if (not m_recBunch.isValid()) return;
96 if (not m_recBunch->isReconstructed()) return;
97 }
98
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);
106 }
107
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);
115 } else {
116 auto c = digit.getCarrierNumber();
117 timeCarriers[c]->Fill(time);
118 }
119 }
120
121 }
122
123
125} // end namespace Belle2
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
StoreObjPtr< TOPRecBunch > m_recBunch
reconstructed bunch
bool m_requireRecBunch
if true, require reconstructed bunch
StoreArray< TOPDigit > m_topDigits
collection of TOP digits
const TOPNominalTDC & getNominalTDC() const
Returns nominal time-to-digit conversion parameters.
Definition: TOPGeometry.h:218
double getSyncTimeBase() const
Returns synchonization time base (time width of c_syncWindows)
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
virtual void collect() final
Replacement for event().
virtual void prepare() final
Replacement for initialize().
Abstract base class for different kinds of events.
STL namespace.