Belle II Software development
TOPRecoManager.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/reconstruction_cpp/TOPRecoManager.h>
10#include <framework/logging/Logger.h>
11
12namespace Belle2 {
17 namespace TOP {
18
20 {
21 static TOPRecoManager instance;
22 return instance;
23 }
24
26 {
27 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
28 for (unsigned moduleID = 1; moduleID <= geo->getNumModules(); moduleID++) {
29 m_yScanners.push_back(YScanner(moduleID));
30 m_inverseRaytracers.push_back(InverseRaytracer(moduleID, m_yScanners.back().getCosTotal()));
31 m_fastRaytracers.push_back(FastRaytracer(moduleID));
32 m_backgroundPDFs.push_back(BackgroundPDF(moduleID));
33 }
34 }
35
37 {
38 const auto& collection = getInstance().inverseRaytracers();
39 unsigned k = moduleID - 1;
40 if (k < collection.size()) {
41 collection[k].clear();
42 return &collection[k];
43 }
44
45 B2ERROR("TOPRecoManager::getInverseRaytracer: invalid moduleID" << LogVar("moduleID", moduleID));
46 return 0;
47 }
48
50 {
51 const auto& collection = getInstance().fastRaytracers();
52 unsigned k = moduleID - 1;
53 if (k < collection.size()) {
54 collection[k].clear();
55 return &collection[k];
56 }
57
58 B2ERROR("TOPRecoManager::getFastRaytracer: invalid moduleID" << LogVar("moduleID", moduleID));
59 return 0;
60 }
61
63 {
64 const auto& collection = getInstance().yScanners();
65 unsigned k = moduleID - 1;
66 if (k < collection.size()) {
67 collection[k].clear();
68 return &collection[k];
69 }
70
71 B2ERROR("TOPRecoManager::getYScanner: invalid moduleID" << LogVar("moduleID", moduleID));
72 return 0;
73 }
74
75
77 {
78 const auto& collection = getInstance().backgroundPDFs();
79 unsigned k = moduleID - 1;
80 if (k < collection.size()) {
81 return &collection[k];
82 }
83
84 B2ERROR("TOPRecoManager::getBackgroundPDF: invalid moduleID" << LogVar("moduleID", moduleID));
85 return 0;
86 }
87
89 const TOPAsicMask& asicMask)
90 {
91 const auto& mapper = TOPGeometryPar::Instance()->getChannelMapper();
92 for (auto& yScanner : getInstance().yScanners()) {
93 auto& pixelMasks = yScanner.pixelMasks();
94 int moduleID = pixelMasks.getModuleID();
95 unsigned numChannels = pixelMasks.getNumPixels();
96 for (unsigned channel = 0; channel < numChannels; channel++) {
97 int pixelID = mapper.getPixelID(channel);
98 pixelMasks.set(pixelID, mask->isActive(moduleID, channel) and asicMask.isActive(moduleID, channel));
99 }
100 }
101 getInstance().m_redoBkg = true;
102
103 B2INFO("TOPRecoManager: new channel masks have been passed to reconstruction");
104 }
105
107 {
108 const auto& mapper = TOPGeometryPar::Instance()->getChannelMapper();
109 for (auto& yScanner : getInstance().yScanners()) {
110 auto& pixelMasks = yScanner.pixelMasks();
111 int moduleID = pixelMasks.getModuleID();
112 unsigned numChannels = pixelMasks.getNumPixels();
113 for (unsigned channel = 0; channel < numChannels; channel++) {
114 if (channelT0->isCalibrated(moduleID, channel)) continue;
115 int pixelID = mapper.getPixelID(channel);
116 pixelMasks.setPixelOff(pixelID);
117 }
118 }
119 getInstance().m_redoBkg = true;
120
121 B2INFO("TOPRecoManager: channelT0-uncalibrated channels have been masked off");
122 }
123
125 {
126 const auto& ch_mapper = TOPGeometryPar::Instance()->getChannelMapper();
127 const auto& fe_mapper = TOPGeometryPar::Instance()->getFrontEndMapper();
128 for (auto& yScanner : getInstance().yScanners()) {
129 auto& pixelMasks = yScanner.pixelMasks();
130 int moduleID = pixelMasks.getModuleID();
131 unsigned numChannels = pixelMasks.getNumPixels();
132 for (unsigned channel = 0; channel < numChannels; channel++) {
133 const auto* fe = fe_mapper.getMap(moduleID, channel / 128);
134 if (not fe) {
135 B2ERROR("TOPRecoManager::setUncalibratedChannelsOff no front-end map found");
136 continue;
137 }
138 auto scrodID = fe->getScrodID();
139 const auto* sampleTimes = timebase->getSampleTimes(scrodID, channel);
140 if (sampleTimes->isCalibrated()) continue;
141 int pixelID = ch_mapper.getPixelID(channel);
142 pixelMasks.setPixelOff(pixelID);
143 }
144 }
145 getInstance().m_redoBkg = true;
146
147 B2INFO("TOPRecoManager: timebase-uncalibrated channels have been masked off");
148 }
149
151 {
152 const double minEffi = 0.1;
153 const double maxEffi = 2.0;
154 for (auto& yScanner : getInstance().yScanners()) {
155 auto& pixelEfficiencies = yScanner.pixelEfficiencies();
156 int moduleID = pixelEfficiencies.getModuleID();
157 int numPixels = pixelEfficiencies.getNumPixels();
158 for (int pixelID = 1; pixelID <= numPixels; pixelID++) {
159 double effi = TOPGeometryPar::Instance()->getRelativePixelEfficiency(moduleID, pixelID);
160 if (effi < minEffi) {
161 B2WARNING("TOPRecoManager::setChannelEffi: relative pixel efficiency found rather small"
162 << LogVar("slot", moduleID)
163 << LogVar("pixel", pixelID)
164 << LogVar("efficiency", effi)
165 << " -> will set it to " << minEffi);
166 effi = minEffi;
167 } else if (effi > maxEffi) {
168 B2WARNING("TOPRecoManager::setChannelEffi: relative pixel efficiency found rather large"
169 << LogVar("slot", moduleID)
170 << LogVar("pixel", pixelID)
171 << LogVar("efficiency", effi)
172 << " -> will set it to " << maxEffi);
173 effi = maxEffi;
174 }
175 pixelEfficiencies.set(pixelID, effi);
176 }
177 }
178 getInstance().m_redoBkg = true;
179
180 B2INFO("TOPRecoManager: new relative pixel efficiencies have been passed to reconstruction");
181 }
182
183 void TOPRecoManager::setMirrorCenter(int moduleID, double xc, double yc)
184 {
187 auto& yScanners = getInstance().yScanners();
188 unsigned k = moduleID - 1;
189 if (k < yScanners.size()) {
190 inverseRaytracers[k].setMirrorCenter(xc, yc);
191 fastRaytracers[k].setMirrorCenter(xc, yc);
192 yScanners[k].setMirrorCenter(xc, yc);
193 return;
194 }
195
196 B2ERROR("TOPRecoManager::setMirrorCenter: invalid moduleID" << LogVar("moduleID", moduleID));
197 }
198
199
200 } // namespace TOP
202} // namespace Belle2
203
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Class to store bit fields of masked ASICs, as reported in raw data.
Definition: TOPAsicMask.h:23
Parametrization of background PDF in pixels of single module.
Definition: BackgroundPDF.h:23
Fast photon propagation in quartz optics.
Definition: FastRaytracer.h:26
Utility for solving inverse ray-tracing problem.
double getRelativePixelEfficiency(int moduleID, int pixelID) const
Returns relative pixel efficiency (including CE, RQE and threshold efficiency)
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
const ChannelMapper & getChannelMapper() const
Returns default channel mapper (mapping of channels to pixels)
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
const FrontEndMapper & getFrontEndMapper() const
Returns front-end mapper (mapping of SCROD's to positions within TOP modules)
Singleton class providing pre-constructed reconstruction objects.
std::vector< YScanner > & yScanners()
Interface to y-scanners of all modules.
static const InverseRaytracer * getInverseRaytracer(int moduleID)
Returns inverse ray-tracer of a given module.
static void setMirrorCenter(int moduleID, double xc, double yc)
Sets the mirror center-of-curvature.
std::vector< YScanner > m_yScanners
collection of y-scanners
std::vector< BackgroundPDF > m_backgroundPDFs
collection of background PDF's
std::vector< InverseRaytracer > & inverseRaytracers()
Interface to inverse ray-tracers of all modules.
void set()
Sets the reconstruction object collections.
static void setChannelMask(const DBObjPtr< TOPCalChannelMask > &mask, const TOPAsicMask &asicMask)
Sets channel masks.
std::vector< InverseRaytracer > m_inverseRaytracers
collection of inverse raytracers
std::vector< FastRaytracer > m_fastRaytracers
collection of fast raytracers
static const YScanner * getYScanner(int moduleID)
Returns y-scanner of a given module.
std::vector< FastRaytracer > & fastRaytracers()
Interface to fast ray-tracers of all modules.
static void setChannelEffi()
Sets relative efficiencies of pixels.
static const FastRaytracer * getFastRaytracer(int moduleID)
Returns fast ray-tracer of a given module.
std::vector< BackgroundPDF > & backgroundPDFs()
Interface to background PDF's of all modules.
static const BackgroundPDF * getBackgroundPDF(int moduleID)
Returns background PDF of a given module.
static TOPRecoManager & getInstance()
Returns instance of the class.
bool m_redoBkg
flag to signal whether backgroundPDF has to be redone
static void setUncalibratedChannelsOff(const DBObjPtr< TOPCalChannelT0 > &channelT0)
Sets uncalibrated channels off.
Utility for expanding the PDF in y direction.
Definition: YScanner.h:33
Class to store variables with their name which were sent to the logging service.
bool isActive(int moduleID, unsigned channel) const
Returns true if channel is not explicitely labeled as masked.
Definition: TOPAsicMask.cc:17
Abstract base class for different kinds of events.