9 #include <svd/modules/svdCalibration/SVDChannelMappingModule.h>
10 #include <vxd/geometry/GeoCache.h>
28 , hInterDictionary(172, [](const
Belle2::
VxdID & vxdid) {
return (
size_t)vxdid.getID(); })
32 setDescription(
"SVD Channel Mapping Verification Module");
33 setPropertyFlags(c_ParallelProcessingCertified);
35 addParam(
"outputFileName", m_rootFileName,
"Name of output root file.", std::string(
"SVDChannelMapping.root"));
37 addParam(
"ShaperDigitsName", m_SVDShaperDigitsName,
38 "name of the list of SVDShaperDigits", std::string(
""));
40 addParam(
"ClustersName", m_SVDClustersName,
41 "name of the list of SVDClusters", std::string(
""));
43 addParam(
"InterceptsName", m_InterceptsName,
44 "name of the list of interceptions", std::string(
""));
50 void SVDChannelMappingModule::initialize()
53 m_histoList_digits =
new TList;
54 m_histoList_clusters =
new TList;
56 createHistosDictionaries();
58 m_shapers.isRequired(m_SVDShaperDigitsName);
59 m_clusters.isRequired(m_SVDClustersName);
60 m_Intercepts.isRequired(m_InterceptsName);
64 m_rootFilePtr =
new TFile(m_rootFileName.c_str(),
"RECREATE");
68 void SVDChannelMappingModule::event()
75 for (
auto& it : m_Intercepts)
76 fillSensorInterHistos(&it);
79 void SVDChannelMappingModule::createHistosDictionaries()
90 std::set<Belle2::VxdID> svdLayers = m_aGeometry.getLayers(VXD::SensorInfoBase::SVD);
91 std::set<Belle2::VxdID>::iterator itSvdLayers = svdLayers.begin();
93 while (itSvdLayers != svdLayers.end()) {
95 std::set<Belle2::VxdID> svdLadders = m_aGeometry.getLadders(*itSvdLayers);
96 std::set<Belle2::VxdID>::iterator itSvdLadders = svdLadders.begin();
98 while (itSvdLadders != svdLadders.end()) {
100 std::set<Belle2::VxdID> svdSensors = m_aGeometry.getSensors(*itSvdLadders);
101 std::set<Belle2::VxdID>::iterator itSvdSensors = svdSensors.begin();
103 while (itSvdSensors != svdSensors.end()) {
105 string sensorid = std::to_string(itSvdSensors->getLayerNumber()) +
"_" + std::to_string(itSvdSensors->getLadderNumber()) +
"_" +
106 std::to_string(itSvdSensors->getSensorNumber());
112 name =
"hCoorU_" + sensorid;
113 title =
"U coordinate of the extrapolation in U for sensor " + sensorid;
114 tmp1D =
new TH1F(name.c_str(), title.c_str(), 100, -2.9, 2.9);
115 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
124 m_histoList_digits->Add(tmp1D);
126 name =
"hCoorV_" + sensorid;
127 title =
"V coordinate of the extrapolation in V for sensor " + sensorid;
128 tmp1D =
new TH1F(name.c_str(), title.c_str(), 100, -6.15, 6.15);
129 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
138 m_histoList_digits->Add(tmp1D);
141 name =
"hCoorU_vs_CoorV_" + sensorid;
142 title =
"U vs V intercept (cm) " + sensorid;
143 tmp2D =
new TH2F(name.c_str(), title.c_str(), 100, -2.9, 2.9, 100, -6.15, 6.15);
144 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
145 tmp2D->GetYaxis()->SetTitle(
"intercept V coor (cm)");
146 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
155 m_histoList_digits->Add(tmp2D);
158 name =
"hStatErrU_" + sensorid;
159 title =
"stat error of the extrapolation in U for sensor " + sensorid;
160 tmp1D =
new TH1F(name.c_str(), title.c_str(), 100, 0, 0.35);
161 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
170 m_histoList_digits->Add(tmp1D);
172 name =
"hStatErrV_" + sensorid;
173 title =
"stat error of the extrapolation in V for sensor " + sensorid;
174 tmp1D =
new TH1F(name.c_str(), title.c_str(), 100, 0, 0.35);
175 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
184 m_histoList_digits->Add(tmp1D);
189 name =
"hDigitResidU_" + sensorid;
190 title =
"U residuals = intercept - digit, for sensor " + sensorid;
191 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -2.9, 2.9);
192 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
200 for (
auto& it : SVDShaperDigits)
201 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
211 m_histoList_digits->Add(tmp1D);
214 name =
"hDigitResidV_" + sensorid;
215 title =
"V residuals = intercept - digit, for sensor " + sensorid;
216 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -6.15, 6.15);
217 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
225 for (
auto& it : SVDShaperDigits)
226 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
227 if (!it.isUStrip()) {
236 m_histoList_digits->Add(tmp1D);
239 name =
"hDigitResidU_vs_DigitU_" + sensorid;
240 title =
"U residual (cm) vs digit U (cm) " + sensorid;
241 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -2.9, 2.9, 1000, -2.9, 2.9);
242 tmp2D->GetYaxis()->SetTitle(
"U resid (cm)");
243 tmp2D->GetXaxis()->SetTitle(
"U digit (cm)");
244 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
252 for (
auto& it : SVDShaperDigits)
253 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && it.isUStrip()) {
262 m_histoList_digits->Add(tmp2D);
264 name =
"hDigitResidV_vs_DigitV_" + sensorid;
265 title =
"V residual (cm) vs digit V (cm) " + sensorid;
266 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -6.15, 6.15, 1000, -6.15, 6.15);
267 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
268 tmp2D->GetXaxis()->SetTitle(
"V digit (cm)");
269 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
277 for (
auto& it : SVDShaperDigits)
278 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (!it.isUStrip())) {
287 m_histoList_digits->Add(tmp2D);
291 name =
"hCoorU_vs_DigitU_" + sensorid;
292 title =
"U intercept (cm) vs U digit (cm) " + sensorid;
293 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -2.9, 2.9, 1000, -2.9, 2.9);
294 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
295 tmp2D->GetYaxis()->SetTitle(
"digit U coor (cm)");
296 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
304 for (
auto& it : SVDShaperDigits)
305 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (it.isUStrip())) {
313 m_histoList_digits->Add(tmp2D);
315 name =
"hCoorV_vs_DigitV_" + sensorid;
316 title =
"V intercept (cm) vs V digit (ID) " + sensorid;
317 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -6.15, 6.15, 1000, -6.15, 6.15);
318 tmp2D->GetXaxis()->SetTitle(
"intercept V coor (cm)");
319 tmp2D->GetYaxis()->SetTitle(
"digi V coor (cm)");
320 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
328 for (
auto& it : SVDShaperDigits) {
329 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (!it.isUStrip())) {
338 m_histoList_digits->Add(tmp2D);
343 name =
"hClusterResidU_" + sensorid;
344 title =
"U residuals = intercept - cluster, for sensor " + sensorid;
345 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -2.9, 2.9);
346 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
354 for (
auto& it : SVDClusters)
355 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
356 if (it.isUCluster()) {
357 hPtr->Fill(inter->
getCoorU() - it.getPosition());
364 m_histoList_clusters->Add(tmp1D);
367 name =
"hClusterResidV_" + sensorid;
368 title =
"V residuals = intercept - cluster, for sensor " + sensorid;
369 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -6.15, 6.15);
370 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
378 for (
auto& it : SVDClusters)
379 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
380 if (!it.isUCluster()) {
381 hPtr->Fill(inter->
getCoorV() - it.getPosition());
388 m_histoList_clusters->Add(tmp1D);
391 name =
"hClusterResidU_vs_ClusterU_" + sensorid;
392 title =
"U residual (cm) vs cluster U (cm) " + sensorid;
393 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -2.9, 2.9, 1000, -2.9, 2.9);
394 tmp2D->GetYaxis()->SetTitle(
"U resid (cm)");
395 tmp2D->GetXaxis()->SetTitle(
"U cluster (cm)");
396 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
404 for (
auto& it : SVDClusters)
405 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && it.isUCluster()) {
406 double resid = inter->
getCoorU() - it.getPosition();
407 hPtr->Fill(it.getPosition(), resid);
413 m_histoList_clusters->Add(tmp2D);
415 name =
"hClusterResidV_vs_ClusterV_" + sensorid;
416 title =
"V residual (cm) vs cluster V (cm) " + sensorid;
417 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -6.15, 6.15, 1000, -6.15, 6.15);
418 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
419 tmp2D->GetXaxis()->SetTitle(
"V cluster (cm)");
420 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
428 for (
auto& it : SVDClusters)
429 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (!it.isUCluster())) {
430 double resid = inter->
getCoorV() - it.getPosition();
431 hPtr->Fill(it.getPosition(), resid);
437 m_histoList_clusters->Add(tmp2D);
441 name =
"hCoorU_vs_ClusterU_" + sensorid;
442 title =
"U intercept (cm) vs U cluster (cm) " + sensorid;
443 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -2.9, 2.9, 1000, -2.9, 2.9);
444 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
445 tmp2D->GetYaxis()->SetTitle(
"cluster U coor (cm)");
446 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
454 for (
auto& it : SVDClusters)
455 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (it.isUCluster())) {
456 hPtr->Fill(inter->
getCoorU(), it.getPosition());
462 m_histoList_clusters->Add(tmp2D);
464 name =
"hCoorV_vs_ClusterV_" + sensorid;
465 title =
"V intercept (cm) vs V cluster (ID) " + sensorid;
466 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -6.15, 6.15, 1000, -6.15, 6.15);
467 tmp2D->GetXaxis()->SetTitle(
"intercept V coor (cm)");
468 tmp2D->GetYaxis()->SetTitle(
"cluster V coor (cm)");
469 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
477 for (
auto& it : SVDClusters) {
478 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (!it.isUCluster())) {
479 hPtr->Fill(inter->
getCoorV(), it.getPosition());
486 m_histoList_clusters->Add(tmp2D);
497 void SVDChannelMappingModule::fillSensorInterHistos(
const SVDIntercept* inter)
500 auto its = hInterDictionary.equal_range(inter->
getSensorID());
502 for (
auto it = its.first; it != its.second; ++it) {
504 aInterHistoAndFill.second(aInterHistoAndFill.first, inter);
509 void SVDChannelMappingModule::terminate()
512 if (m_rootFilePtr !=
nullptr) {
516 TDirectory* oldDir = gDirectory;
519 TDirectory* dir_digits = oldDir->mkdir(
"digits");
521 TIter nextH_digits(m_histoList_digits);
522 while ((obj = nextH_digits()))
525 TDirectory* dir_clusters = oldDir->mkdir(
"clusters");
527 TIter nextH_clusters(m_histoList_clusters);
528 while ((obj = nextH_clusters()))
The Channel Mapping Check Module.
std::pair< TH1 *, std::function< void(TH1 *, const SVDIntercept *) > > InterHistoAndFill
typedef: histograms to be filled once per intercept + filling function
SVDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an SVD ...
Accessor to arrays stored in the data store.
double getSigmaV() const
return the statistical error on the V coordinate of the intercept
double getCoorV() const
return the V coordinate of the intercept
double getSigmaU() const
return the statistical error on the U coordinate of the intercept
VxdID::baseType getSensorID() const
return the sensor ID
double getCoorU() const
return the U coordinate of the intercept
Base class to provide Sensor Information for PXD and SVD.
double getVCellPosition(int vID) const
Return the position of a specific strip/pixel in v direction.
double getUCellPosition(int uID, int vID=-1) const
Return the position of a specific strip/pixel in u direction.
Class to uniquely identify a any structure of the PXD and SVD.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.