Belle II Software development
SVDClusterCalibrationsMonitorModule.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 <svd/modules/svdCalibration/SVDClusterCalibrationsMonitorModule.h>
10#include <vxd/geometry/GeoCache.h>
11#include <framework/datastore/StoreObjPtr.h>
12#include <framework/dataobjects/EventMetaData.h>
13
14using namespace Belle2;
15
16//-----------------------------------------------------------------
17// Register the Module
18//-----------------------------------------------------------------
19REG_MODULE(SVDClusterCalibrationsMonitor);
20
21//-----------------------------------------------------------------
22// Implementation
23//-----------------------------------------------------------------
24
26{
27 // Set module properties
28 setDescription("Module to produce a list of histograms showing the uploaded calibration constants");
29
30 // Parameter definitions
31 addParam("outputFileName", m_rootFileName, "Name of output root file.", std::string("SVDClusterCalibrationMonitor_output.root"));
32}
33
35{
36
37 m_rootFilePtr = new TFile(m_rootFileName.c_str(), "RECREATE");
38 //tree initialization
39 m_tree = new TTree("calibCls", "RECREATE");
40 b_run = m_tree->Branch("run", &m_run, "run/i");
41 b_layer = m_tree->Branch("layer", &m_layer, "layer/i");
42 b_ladder = m_tree->Branch("ladder", &m_ladder, "ladder/i");
43 b_sensor = m_tree->Branch("sensor", &m_sensor, "sensor/i");
44 b_side = m_tree->Branch("side", &m_side, "side/i");
45 b_clsSNR = m_tree->Branch("clsSNR", &m_clsSNR, "clsSNR/F");
46 b_clsSeedSNR = m_tree->Branch("clsSeedSNR", &m_clsSeedSNR, "clsSeedSNR/F");
47 b_clsAdjSNR = m_tree->Branch("clsAdjSNR", &m_clsAdjSNR, "clsAdjSNR/F");
48 b_clsScaleErr1 = m_tree->Branch("clsScaleErr1", &m_clsScaleErr1, "clsScaleErr1/F");
49 b_clsScaleErr2 = m_tree->Branch("clsScaleErr2", &m_clsScaleErr2, "clsScaleErr2/F");
50 b_clsScaleErr3 = m_tree->Branch("clsScaleErr3", &m_clsScaleErr3, "clsScaleErr3/F");
51 b_clsScaleErr4 = m_tree->Branch("clsScaleErr4", &m_clsScaleErr4, "clsScaleErr4/F");
52 b_clsScaleErr5 = m_tree->Branch("clsScaleErr5", &m_clsScaleErr5, "clsScaleErr5/F");
53 b_clsTimeFunc = m_tree->Branch("clsTimeFunc", &m_clsTimeFunc, "clsTimeFunc/i");
54 b_clsTimeMin = m_tree->Branch("clsTimeMin", &m_clsTimeMin, "clsTimeMin/F");
55
56
57 if (! m_ClusterCal.isValid())
58 B2WARNING("No valid SVDClustering for the requested IoV");
59
60
62 TH1F hClsSNR("clusterMinSNR__L@layerL@ladderS@sensor@view",
63 "Cluster minimum SNR in @layer.@ladder.@sensor @view/@side",
64 100, -0.5, 99.5);
65 hClsSNR.GetXaxis()->SetTitle("cls min SNR");
66 m_hClsSNR = new SVDHistograms<TH1F>(hClsSNR);
67
68 TH1F hClsSeedSNR("clusterSeedSNR__L@layerL@ladderS@sensor@view",
69 "Cluster Seed minimum SNR in @layer.@ladder.@sensor @view/@side",
70 100, -0.5, 99.5);
71 hClsSeedSNR.GetXaxis()->SetTitle("cls seed SNR");
72 m_hClsSeedSNR = new SVDHistograms<TH1F>(hClsSeedSNR);
73
74
75
76 TH1F hClsAdjSNR("clusterAdjSNR__L@layerL@ladderS@sensor@view",
77 "Cluster Adj minimum SNR in @layer.@ladder.@sensor @view/@side",
78 100, -0.5, 99.5);
79 hClsAdjSNR.GetXaxis()->SetTitle("cls adj SNR");
80 m_hClsAdjSNR = new SVDHistograms<TH1F>(hClsAdjSNR);
81
82
83 //CLUSTER POSITION ERROR SCALE FACTORS
84 TH1F hClsScaleErr1("clusterScaleErr1__L@layerL@ladderS@sensor@view",
85 "Cluster Position Error Scale Factor for Size 1 in @layer.@ladder.@sensor @view/@side",
86 100, -0.5, 9.5);
87 hClsScaleErr1.GetXaxis()->SetTitle("scale factor");
88 m_hClsScaleErr1 = new SVDHistograms<TH1F>(hClsScaleErr1);
89
90 TH1F hClsScaleErr2("clusterScaleErr2__L@layerL@ladderS@sensor@view",
91 "Cluster Position Error Scale Factor for Size 2 in @layer.@ladder.@sensor @view/@side",
92 100, -0.5, 9.5);
93 hClsScaleErr2.GetXaxis()->SetTitle("scale factor");
94 m_hClsScaleErr2 = new SVDHistograms<TH1F>(hClsScaleErr2);
95
96 TH1F hClsScaleErr3("clusterScaleErr3__L@layerL@ladderS@sensor@view",
97 "Cluster Position Error Scale Factor for Size 3 in @layer.@ladder.@sensor @view/@side",
98 100, -0.5, 9.5);
99 hClsScaleErr3.GetXaxis()->SetTitle("scale factor");
100 m_hClsScaleErr3 = new SVDHistograms<TH1F>(hClsScaleErr3);
101
102 TH1F hClsScaleErr4("clusterScaleErr4__L@layerL@ladderS@sensor@view",
103 "Cluster Position Error Scale Factor for Size 4 in @layer.@ladder.@sensor @view/@side",
104 100, -0.5, 9.5);
105 hClsScaleErr4.GetXaxis()->SetTitle("scale factor");
106 m_hClsScaleErr4 = new SVDHistograms<TH1F>(hClsScaleErr4);
107
108 TH1F hClsScaleErr5("clusterScaleErr5__L@layerL@ladderS@sensor@view",
109 "Cluster Position Error Scale Factor for Size > 4 in @layer.@ladder.@sensor @view/@side",
110 100, -0.5, 9.5);
111 hClsScaleErr5.GetXaxis()->SetTitle("scale factor");
112 m_hClsScaleErr5 = new SVDHistograms<TH1F>(hClsScaleErr5);
113
114
115 //CLUSTER TIME CUTS
116 TH1F hClsTimeFuncVersion("clusterTimeSelFunction__L@layerL@ladderS@sensor@view",
117 "Cluster Time Selection Function Version in @layer.@ladder.@sensor @view/@side",
118 5, -0.5, 4.5);
119 hClsTimeFuncVersion.GetXaxis()->SetTitle("cls time selection function ID");
120 m_hClsTimeFuncVersion = new SVDHistograms<TH1F>(hClsTimeFuncVersion);
121
122 //CLUSTER TIME CUTS
123 TH1F hClsTimeMin("clusterMinTimeS__L@layerL@ladderS@sensor@view",
124 "Cluster Minimum Time in @layer.@ladder.@sensor @view/@side",
125 200, -100.5, 99.5);
126 hClsTimeMin.GetXaxis()->SetTitle("cls min time (ns)");
127 m_hClsTimeMin = new SVDHistograms<TH1F>(hClsTimeMin);
128
129
130
131}
132
134{
135
137 m_run = meta->getRun();
138
139 if (!m_ClusterCal.isValid())
140 return;
141
142 //call for a geometry instance
144 std::set<Belle2::VxdID> svdLayers = aGeometry.getLayers(VXD::SensorInfoBase::SVD);
145 std::set<Belle2::VxdID>::iterator itSvdLayers = svdLayers.begin();
146
147 while ((itSvdLayers != svdLayers.end()) && (itSvdLayers->getLayerNumber() != 7)) { //loop on Layers
148
149 std::set<Belle2::VxdID> svdLadders = aGeometry.getLadders(*itSvdLayers);
150 std::set<Belle2::VxdID>::iterator itSvdLadders = svdLadders.begin();
151
152 while (itSvdLadders != svdLadders.end()) { //loop on Ladders
153
154 std::set<Belle2::VxdID> svdSensors = aGeometry.getSensors(*itSvdLadders);
155 std::set<Belle2::VxdID>::iterator itSvdSensors = svdSensors.begin();
156 B2DEBUG(1, " svd sensor info " << * (svdSensors.begin()));
157
158 while (itSvdSensors != svdSensors.end()) { //loop on sensors
159 B2DEBUG(1, " svd sensor info " << *itSvdSensors);
160
161 m_layer = itSvdSensors->getLayerNumber();
162 m_ladder = itSvdSensors->getLadderNumber();
163 m_sensor = itSvdSensors->getSensorNumber();
165
166 for (m_side = 0; m_side < 2; m_side++) {
167
169 m_hClsSNR->fill(theVxdID, m_side, m_clsSNR);
170
173
175 m_hClsAdjSNR->fill(theVxdID, m_side, m_clsAdjSNR);
176
179
188
189
192
195
196 m_tree->Fill();
197
198 }
199 ++itSvdSensors;
200 }
201 ++itSvdLadders;
202 }
203 ++itSvdLayers;
204 }
205
206}
207
209{
210 B2RESULT("******************************************");
211 B2RESULT("** UNIQUE IDs of calibration DB objects **");
212 B2RESULT("");
213 if (m_ClusterCal.isValid())
214 B2RESULT(" - SVDClusterCalibrations:" << m_ClusterCal.getUniqueID());
215 else
216 B2WARNING("No valid SVDClusterCalibrations for the requested IoV");
217
218 if (m_rootFilePtr != nullptr) {
219
220 m_rootFilePtr->cd();
221
222 //write the tree
223 m_tree->Write();
224
225
226 m_rootFilePtr->mkdir("snr_cuts");
227 m_rootFilePtr->mkdir("time_cuts");
228 m_rootFilePtr->mkdir("scale_factor");
229
231
232 for (auto layer : geoCache.getLayers(VXD::SensorInfoBase::SVD))
233 for (auto ladder : geoCache.getLadders(layer))
234 for (Belle2::VxdID sensor : geoCache.getSensors(ladder))
235 for (int view = SVDHistograms<TH1F>::VIndex ; view < SVDHistograms<TH1F>::UIndex + 1; view++) {
236
237 //writing the histograms to root:
238
239 m_rootFilePtr->cd("snr_cuts");
240 (m_hClsSNR->getHistogram(sensor, view))->Write();
241 (m_hClsSeedSNR->getHistogram(sensor, view))->Write();
242 (m_hClsAdjSNR->getHistogram(sensor, view))->Write();
243
244
245 m_rootFilePtr->cd("time_cuts");
246 (m_hClsTimeFuncVersion->getHistogram(sensor, view))->Write();
247 (m_hClsTimeMin->getHistogram(sensor, view))->Write();
248
249 m_rootFilePtr->cd("scale_factor");
250 (m_hClsScaleErr1->getHistogram(sensor, view))->Write();
251 (m_hClsScaleErr2->getHistogram(sensor, view))->Write();
252 (m_hClsScaleErr3->getHistogram(sensor, view))->Write();
253 (m_hClsScaleErr4->getHistogram(sensor, view))->Write();
254 (m_hClsScaleErr5->getHistogram(sensor, view))->Write();
255
256
257 }
258
259 m_rootFilePtr->Close();
260 B2RESULT("The rootfile containing the list of histograms has been filled and closed [Cluster].");
261
262
263 }
264}
265
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
TTree * m_tree
pointer at tree containing the mean and RMS of calibration constants
float m_clsScaleErr1
cluster size 1 pos err scale factor SNR
SVDHistograms< TH1F > * m_hClsSeedSNR
cluster seed SNR histo
TBranch * b_clsScaleErr1
cluster size 1 pos err scale factor SNR
SVDHistograms< TH1F > * m_hClsScaleErr3
cluster size 3, position error scale factor histo
SVDHitTimeSelection m_HitTimeCut
hit time cuts payload
virtual void event() override
fill trees and histograms
TBranch * b_clsScaleErr5
cluster size 5 pos err scale factor SNR
virtual void endRun() override
print the payloads uniqueID and write tree and histograms to the rootfile
TBranch * b_clsScaleErr4
cluster size 4 pos err scale factor SNR
SVDHistograms< TH1F > * m_hClsTimeMin
cluster cut minimum time histo
float m_clsScaleErr4
cluster size 4 pos err scale factor SNR
SVDClustering m_ClusterCal
cluster calibrations payload
SVDHistograms< TH1F > * m_hClsScaleErr1
cluster size 1, position error scale factor histo
TBranch * b_clsScaleErr2
cluster size 2 pos err scale factor SNR
SVDClusterCalibrationsMonitorModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void beginRun() override
initialize the TTrees and check validities of payloads
float m_clsScaleErr5
cluster size 5 pos err scale factor SNR
SVDHistograms< TH1F > * m_hClsScaleErr2
cluster size 2, position error scale factor histo
SVDCoGOnlyErrorScaleFactors m_CoGOnlySF
scale factors for the CoGOnly algorithm
float m_clsScaleErr2
cluster size 2 pos err scale factor SNR
TBranch * b_clsScaleErr3
cluster size 3 pos err scale factor SNR
SVDHistograms< TH1F > * m_hClsScaleErr5
cluster size 5, position error scale factor histo
SVDHistograms< TH1F > * m_hClsScaleErr4
cluster size 4, position error scale factor histo
TFile * m_rootFilePtr
pointer at root file used for storing histograms
SVDHistograms< TH1F > * m_hClsTimeFuncVersion
cluster cut time function version histo
float m_clsScaleErr3
cluster size 3 pos err scale factor SNR
SVDHistograms< TH1F > * m_hClsAdjSNR
cluster adj SNR histo
double getMinClusterSNR(const Belle2::VxdID &sensorID, const bool &isU) const
Return the minimum SNR for the cluster.
double getMinSeedSNR(const Belle2::VxdID &sensorID, const bool &isU) const
Return the minimum SNR for the seed.
Definition: SVDClustering.h:54
double getMinAdjSNR(const Belle2::VxdID &sensorID, const bool &isU) const
Return the minimum SNR for the adjacent.
Definition: SVDClustering.h:75
TString getUniqueID()
returns the unique ID of the payload
bool isValid()
returns true if the m_aDBObtPtr is valid in the requested IoV
double getCorrectedClusterPositionError(const Belle2::VxdID &sensorID, const bool &isU, const int &size, const double &raw_error) const
Return the corrected cluster position error.
template class for SVd histograms
Definition: SVDHistograms.h:24
void fill(const VxdID &vxdID, int view, Types ... args)
fill the histogram for
Definition: SVDHistograms.h:77
H * getHistogram(const VxdID &vxdID, int view)
get a reference to the histogram for
Definition: SVDHistograms.h:56
float getMinClusterTime(const Belle2::VxdID &sensorID, const bool &isU) const
Return the min value of the cluster time to use it for reconstruction.
int getTimeSelectionFunction(const Belle2::VxdID &sensorID, const bool &isU) const
Return the version of the function used to determine whether the cluster time is acceptable at the SP...
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
Definition: GeoCache.cc:176
const std::set< Belle2::VxdID > & getSensors(Belle2::VxdID ladder) const
Return a set of all sensor IDs belonging to a given ladder.
Definition: GeoCache.cc:204
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
const std::set< Belle2::VxdID > & getLadders(Belle2::VxdID layer) const
Return a set of all ladder IDs belonging to a given layer.
Definition: GeoCache.cc:193
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
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
Abstract base class for different kinds of events.