Belle II Software development
TOPCommonT0BFCollectorModule.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/TOPCommonT0BFCollectorModule.h>
10#include <top/geometry/TOPGeometryPar.h>
11
12// framework aux
13#include <TH1F.h>
14
15using namespace std;
16
17namespace Belle2 {
23 using namespace TOP;
24
25 //-----------------------------------------------------------------
27 //-----------------------------------------------------------------
28
29 REG_MODULE(TOPCommonT0BFCollector);
30
31 //-----------------------------------------------------------------
32 // Implementation
33 //-----------------------------------------------------------------
34
36 {
37 // set module description and processing properties
38 setDescription("A collector for common T0 calibration with a fit of bunch finder residuals (method BF)");
40
41 // module parameters
42 addParam("bunchesPerSSTclk", m_bunchesPerSSTclk,
43 "number of bunches per SST clock period", 24);
44 addParam("nx", m_nx, "number of histogram bins", 200);
45
46 }
47
48
50 {
51
52 m_recBunch.isRequired();
53
54 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
55 m_bunchTimeSep = geo->getNominalTDC().getSyncTimeBase() / m_bunchesPerSSTclk;
56
57 auto h1a = new TH1F("offset_a", "current offset; offset [ns]",
59 registerObject<TH1F>("offset_a", h1a);
60
61 auto h1b = new TH1F("offset_b", "current offset; offset [ns]",
62 m_nx, 0.0, m_bunchTimeSep);
63 registerObject<TH1F>("offset_b", h1b);
64
65 }
66
67
69 {
70
71 if (not m_recBunch.isValid()) return;
72 if (not m_recBunch->isReconstructed()) return;
73 if (m_recBunch->getNumTracks() != 2) return;
74
75 auto h1a = getObjectPtr<TH1F>("offset_a");
76 auto h1b = getObjectPtr<TH1F>("offset_b");
77 auto offset = m_recBunch->getCurrentOffset();
78 if (m_commonT0->isCalibrated()) offset += m_commonT0->getT0();
79
80 // wrap-around into [-1/2, 1/2] of bunch cycle
81 auto a = offset - round(offset / m_bunchTimeSep) * m_bunchTimeSep;
82 h1a->Fill(a);
83
84 // wrap-around into [0, 1] of bunch cycle
85 auto b = offset - round(offset / m_bunchTimeSep - 0.5) * m_bunchTimeSep;
86 h1b->Fill(b);
87
88 }
89
91}
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
DBObjPtr< TOPCalCommonT0 > m_commonT0
common T0 calibration constants
int m_bunchesPerSSTclk
number of bunches per SST clock
double m_bunchTimeSep
bunch separation in time [ns]
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.