11 #include <svd/modules/svdCalibration/SVDChannelMappingModule.h>
12 #include <vxd/geometry/GeoCache.h>
30 , hInterDictionary(172, [](const
Belle2::
VxdID & vxdid) {
return (
size_t)vxdid.getID(); })
34 setDescription(
"SVD Channel Mapping Verification Module");
35 setPropertyFlags(c_ParallelProcessingCertified);
37 addParam(
"outputFileName", m_rootFileName,
"Name of output root file.", std::string(
"SVDChannelMapping.root"));
39 addParam(
"ShaperDigitsName", m_SVDShaperDigitsName,
40 "name of the list of SVDShaperDigits", std::string(
""));
42 addParam(
"ClustersName", m_SVDClustersName,
43 "name of the list of SVDClusters", std::string(
""));
45 addParam(
"InterceptsName", m_InterceptsName,
46 "name of the list of interceptions", std::string(
""));
52 void SVDChannelMappingModule::initialize()
55 m_histoList_digits =
new TList;
56 m_histoList_clusters =
new TList;
58 createHistosDictionaries();
60 m_shapers.isRequired(m_SVDShaperDigitsName);
61 m_clusters.isRequired(m_SVDClustersName);
62 m_Intercepts.isRequired(m_InterceptsName);
66 m_rootFilePtr =
new TFile(m_rootFileName.c_str(),
"RECREATE");
70 void SVDChannelMappingModule::event()
77 for (
auto& it : m_Intercepts)
78 fillSensorInterHistos(&it);
81 void SVDChannelMappingModule::createHistosDictionaries()
92 std::set<Belle2::VxdID> svdLayers = m_aGeometry.getLayers(VXD::SensorInfoBase::SVD);
93 std::set<Belle2::VxdID>::iterator itSvdLayers = svdLayers.begin();
95 while (itSvdLayers != svdLayers.end()) {
97 std::set<Belle2::VxdID> svdLadders = m_aGeometry.getLadders(*itSvdLayers);
98 std::set<Belle2::VxdID>::iterator itSvdLadders = svdLadders.begin();
100 while (itSvdLadders != svdLadders.end()) {
102 std::set<Belle2::VxdID> svdSensors = m_aGeometry.getSensors(*itSvdLadders);
103 std::set<Belle2::VxdID>::iterator itSvdSensors = svdSensors.begin();
105 while (itSvdSensors != svdSensors.end()) {
107 string sensorid = std::to_string(itSvdSensors->getLayerNumber()) +
"_" + std::to_string(itSvdSensors->getLadderNumber()) +
"_" +
108 std::to_string(itSvdSensors->getSensorNumber());
114 name =
"hCoorU_" + sensorid;
115 title =
"U coordinate of the extrapolation in U for sensor " + sensorid;
116 tmp1D =
new TH1F(name.c_str(), title.c_str(), 100, -2.9, 2.9);
117 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
122 [](TH1 * hPtr,
const SVDIntercept * inter) { hPtr->Fill(inter->getCoorU()); }
126 m_histoList_digits->Add(tmp1D);
128 name =
"hCoorV_" + sensorid;
129 title =
"V coordinate of the extrapolation in V for sensor " + sensorid;
130 tmp1D =
new TH1F(name.c_str(), title.c_str(), 100, -6.15, 6.15);
131 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
136 [](TH1 * hPtr,
const SVDIntercept * inter) { hPtr->Fill(inter->getCoorV()); }
140 m_histoList_digits->Add(tmp1D);
143 name =
"hCoorU_vs_CoorV_" + sensorid;
144 title =
"U vs V intercept (cm) " + sensorid;
145 tmp2D =
new TH2F(name.c_str(), title.c_str(), 100, -2.9, 2.9, 100, -6.15, 6.15);
146 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
147 tmp2D->GetYaxis()->SetTitle(
"intercept V coor (cm)");
148 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
153 [](TH1 * hPtr,
const SVDIntercept * inter) { hPtr->Fill(inter->getCoorU(), inter->getCoorV()); }
157 m_histoList_digits->Add(tmp2D);
160 name =
"hStatErrU_" + sensorid;
161 title =
"stat error of the extrapolation in U for sensor " + sensorid;
162 tmp1D =
new TH1F(name.c_str(), title.c_str(), 100, 0, 0.35);
163 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
168 [](TH1 * hPtr,
const SVDIntercept * inter) { hPtr->Fill(inter->getSigmaU()); }
172 m_histoList_digits->Add(tmp1D);
174 name =
"hStatErrV_" + sensorid;
175 title =
"stat error of the extrapolation in V for sensor " + sensorid;
176 tmp1D =
new TH1F(name.c_str(), title.c_str(), 100, 0, 0.35);
177 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
182 [](TH1 * hPtr,
const SVDIntercept * inter) { hPtr->Fill(inter->getSigmaV()); }
186 m_histoList_digits->Add(tmp1D);
191 name =
"hDigitResidU_" + sensorid;
192 title =
"U residuals = intercept - digit, for sensor " + sensorid;
193 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -2.9, 2.9);
194 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
202 for (
auto& it : SVDShaperDigits)
203 if ((
int)it.getSensorID() == (
int)inter->getSensorID()) {
206 hPtr->Fill(inter->getCoorU() - aSensorInfo.
getUCellPosition(it.getCellID()));
213 m_histoList_digits->Add(tmp1D);
216 name =
"hDigitResidV_" + sensorid;
217 title =
"V residuals = intercept - digit, for sensor " + sensorid;
218 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -6.15, 6.15);
219 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
227 for (
auto& it : SVDShaperDigits)
228 if ((
int)it.getSensorID() == (
int)inter->getSensorID()) {
229 if (!it.isUStrip()) {
231 hPtr->Fill(inter->getCoorV() - aSensorInfo.
getVCellPosition(it.getCellID()));
238 m_histoList_digits->Add(tmp1D);
241 name =
"hDigitResidU_vs_DigitU_" + sensorid;
242 title =
"U residual (cm) vs digit U (cm) " + sensorid;
243 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -2.9, 2.9, 1000, -2.9, 2.9);
244 tmp2D->GetYaxis()->SetTitle(
"U resid (cm)");
245 tmp2D->GetXaxis()->SetTitle(
"U digit (cm)");
246 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
254 for (
auto& it : SVDShaperDigits)
255 if (((
int)it.getSensorID() == (
int)inter->getSensorID()) && it.isUStrip()) {
257 double resid = inter->getCoorU() - aSensorInfo.
getUCellPosition(it.getCellID());
264 m_histoList_digits->Add(tmp2D);
266 name =
"hDigitResidV_vs_DigitV_" + sensorid;
267 title =
"V residual (cm) vs digit V (cm) " + sensorid;
268 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -6.15, 6.15, 1000, -6.15, 6.15);
269 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
270 tmp2D->GetXaxis()->SetTitle(
"V digit (cm)");
271 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
279 for (
auto& it : SVDShaperDigits)
280 if (((
int)it.getSensorID() == (
int)inter->getSensorID()) && (!it.isUStrip())) {
282 double resid = inter->getCoorV() - aSensorInfo.
getVCellPosition(it.getCellID());
289 m_histoList_digits->Add(tmp2D);
293 name =
"hCoorU_vs_DigitU_" + sensorid;
294 title =
"U intercept (cm) vs U digit (cm) " + sensorid;
295 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -2.9, 2.9, 1000, -2.9, 2.9);
296 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
297 tmp2D->GetYaxis()->SetTitle(
"digit U coor (cm)");
298 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
306 for (
auto& it : SVDShaperDigits)
307 if (((
int)it.getSensorID() == (
int)inter->getSensorID()) && (it.isUStrip())) {
309 hPtr->Fill(inter->getCoorU(), aSensorInfo.
getUCellPosition(it.getCellID()));
315 m_histoList_digits->Add(tmp2D);
317 name =
"hCoorV_vs_DigitV_" + sensorid;
318 title =
"V intercept (cm) vs V digit (ID) " + sensorid;
319 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -6.15, 6.15, 1000, -6.15, 6.15);
320 tmp2D->GetXaxis()->SetTitle(
"intercept V coor (cm)");
321 tmp2D->GetYaxis()->SetTitle(
"digi V coor (cm)");
322 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
330 for (
auto& it : SVDShaperDigits) {
331 if (((
int)it.getSensorID() == (
int)inter->getSensorID()) && (!it.isUStrip())) {
333 hPtr->Fill(inter->getCoorV(), aSensorInfo.
getVCellPosition(it.getCellID()));
340 m_histoList_digits->Add(tmp2D);
345 name =
"hClusterResidU_" + sensorid;
346 title =
"U residuals = intercept - cluster, for sensor " + sensorid;
347 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -2.9, 2.9);
348 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
356 for (
auto& it : SVDClusters)
357 if ((
int)it.getSensorID() == (
int)inter->getSensorID()) {
358 if (it.isUCluster()) {
359 hPtr->Fill(inter->getCoorU() - it.getPosition());
366 m_histoList_clusters->Add(tmp1D);
369 name =
"hClusterResidV_" + sensorid;
370 title =
"V residuals = intercept - cluster, for sensor " + sensorid;
371 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -6.15, 6.15);
372 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
380 for (
auto& it : SVDClusters)
381 if ((
int)it.getSensorID() == (
int)inter->getSensorID()) {
382 if (!it.isUCluster()) {
383 hPtr->Fill(inter->getCoorV() - it.getPosition());
390 m_histoList_clusters->Add(tmp1D);
393 name =
"hClusterResidU_vs_ClusterU_" + sensorid;
394 title =
"U residual (cm) vs cluster U (cm) " + sensorid;
395 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -2.9, 2.9, 1000, -2.9, 2.9);
396 tmp2D->GetYaxis()->SetTitle(
"U resid (cm)");
397 tmp2D->GetXaxis()->SetTitle(
"U cluster (cm)");
398 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
406 for (
auto& it : SVDClusters)
407 if (((
int)it.getSensorID() == (
int)inter->getSensorID()) && it.isUCluster()) {
408 double resid = inter->getCoorU() - it.getPosition();
409 hPtr->Fill(it.getPosition(), resid);
415 m_histoList_clusters->Add(tmp2D);
417 name =
"hClusterResidV_vs_ClusterV_" + sensorid;
418 title =
"V residual (cm) vs cluster V (cm) " + sensorid;
419 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -6.15, 6.15, 1000, -6.15, 6.15);
420 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
421 tmp2D->GetXaxis()->SetTitle(
"V cluster (cm)");
422 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
430 for (
auto& it : SVDClusters)
431 if (((
int)it.getSensorID() == (
int)inter->getSensorID()) && (!it.isUCluster())) {
432 double resid = inter->getCoorV() - it.getPosition();
433 hPtr->Fill(it.getPosition(), resid);
439 m_histoList_clusters->Add(tmp2D);
443 name =
"hCoorU_vs_ClusterU_" + sensorid;
444 title =
"U intercept (cm) vs U cluster (cm) " + sensorid;
445 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -2.9, 2.9, 1000, -2.9, 2.9);
446 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
447 tmp2D->GetYaxis()->SetTitle(
"cluster U coor (cm)");
448 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
456 for (
auto& it : SVDClusters)
457 if (((
int)it.getSensorID() == (
int)inter->getSensorID()) && (it.isUCluster())) {
458 hPtr->Fill(inter->getCoorU(), it.getPosition());
464 m_histoList_clusters->Add(tmp2D);
466 name =
"hCoorV_vs_ClusterV_" + sensorid;
467 title =
"V intercept (cm) vs V cluster (ID) " + sensorid;
468 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -6.15, 6.15, 1000, -6.15, 6.15);
469 tmp2D->GetXaxis()->SetTitle(
"intercept V coor (cm)");
470 tmp2D->GetYaxis()->SetTitle(
"cluster V coor (cm)");
471 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
479 for (
auto& it : SVDClusters) {
480 if (((
int)it.getSensorID() == (
int)inter->getSensorID()) && (!it.isUCluster())) {
481 hPtr->Fill(inter->getCoorV(), it.getPosition());
488 m_histoList_clusters->Add(tmp2D);
499 void SVDChannelMappingModule::fillSensorInterHistos(
const SVDIntercept* inter)
502 auto its = hInterDictionary.equal_range(inter->getSensorID());
504 for (
auto it = its.first; it != its.second; ++it) {
506 aInterHistoAndFill.second(aInterHistoAndFill.first, inter);
511 void SVDChannelMappingModule::terminate()
514 if (m_rootFilePtr != NULL) {
518 TDirectory* oldDir = gDirectory;
521 TDirectory* dir_digits = oldDir->mkdir(
"digits");
523 TIter nextH_digits(m_histoList_digits);
524 while ((obj = nextH_digits()))
527 TDirectory* dir_clusters = oldDir->mkdir(
"clusters");
529 TIter nextH_clusters(m_histoList_clusters);
530 while ((obj = nextH_clusters()))