9 #include <tracking/modules/svdROIFinder/SVDROIDQMModule.h>
10 #include <vxd/geometry/GeoCache.h>
12 #include <TDirectory.h>
31 , hInterDictionary(172, [](const
Belle2::
VxdID & vxdid) {
return (
size_t)vxdid.getID(); })
32 , hROIDictionary(172, [](
const Belle2::VxdID& vxdid) {
return (
size_t)vxdid.getID(); })
33 , hROIDictionaryEvt(172, [](
const Belle2::VxdID& vxdid) {
return (
size_t)vxdid.getID(); })
44 setDescription(
"Monitor of the ROIs creation on HLT");
45 setPropertyFlags(c_ParallelProcessingCertified);
47 addParam(
"SVDShaperDigitsName", m_SVDShaperDigitsName,
48 "name of the list of SVDShaperDigits", std::string(
""));
49 addParam(
"SVDRecoDigitsName", m_SVDRecoDigitsName,
50 "name of the list of SVDRecoDigits", std::string(
""));
52 addParam(
"InterceptsName", m_InterceptsName,
53 "name of the list of interceptions", std::string(
""));
55 addParam(
"ROIsName", m_ROIsName,
56 "name of the list of ROIs", std::string(
""));
60 void SVDROIDQMModule::defineHisto()
64 TDirectory* oldDir = gDirectory;
65 TDirectory* roiDir = oldDir->mkdir(
"SVDROIs");
66 m_InterDir = roiDir->mkdir(
"intercept");
67 m_ROIDir = roiDir->mkdir(
"roi");
69 hCellU =
new TH1F(
"hCellU",
"CellID U", 769, -0.5, 768.5);
70 hCellU->GetXaxis()->SetTitle(
"U cell ID");
71 hCellV =
new TH1F(
"hCellV",
"CellID V", 769, -0.5, 768.5);
72 hCellV->GetXaxis()->SetTitle(
"V cell ID");
75 hnInter =
new TH1F(
"hnInter",
"number of intercepts", 100, 0, 100);
78 hnROIs =
new TH1F(
"hnROIs",
"number of ROIs", 100, 0, 100);
79 harea =
new TH1F(
"harea",
"ROIs area", 100, 0, 100000);
80 hredFactor =
new TH1F(
"hredFactor",
"ROI reduction factor", 1000, 0, 1);
83 createHistosDictionaries();
89 void SVDROIDQMModule::initialize()
93 m_SVDShaperDigits.isOptional(m_SVDShaperDigitsName);
94 m_SVDRecoDigits.isOptional(m_SVDRecoDigitsName);
95 m_ROIs.isRequired(m_ROIsName);
96 m_Intercepts.isRequired(m_InterceptsName);
103 void SVDROIDQMModule::event()
108 for (
auto& it : m_SVDShaperDigits)
110 hCellU->Fill(it.getCellID());
112 hCellV->Fill(it.getCellID());
114 hnInter->Fill(m_Intercepts.getEntries());
116 for (
auto& it : m_Intercepts)
117 fillSensorInterHistos(&it);
120 for (
auto it = hROIDictionaryEvt.begin(); it != hROIDictionaryEvt.end(); ++it)
121 (it->second).value = 0;
124 double redFactor = 0;
126 for (
auto& it : m_ROIs) {
128 fillSensorROIHistos(&it);
131 const int nPixelsU = aSensorInfo.
getUCells();
132 const int nPixelsV = aSensorInfo.
getVCells();
134 int minU = it.getMinUid();
135 int minV = it.getMinVid();
136 int maxU = it.getMaxUid();
137 int maxV = it.getMaxVid();
139 int tmpROIarea = (maxU - minU) * (maxV - minV);
140 ROIarea += tmpROIarea;
141 redFactor += (double)tmpROIarea / (nPixelsU * nPixelsV * m_numModules);
145 hnROIs->Fill(m_ROIs.getEntries());
147 harea->Fill((
double)ROIarea);
149 hredFactor->Fill((
double)redFactor);
152 for (
auto it = hROIDictionaryEvt.begin(); it != hROIDictionaryEvt.end(); ++it) {
154 aROIHistoAccumulateAndFill.
fill(aROIHistoAccumulateAndFill.
hPtr, aROIHistoAccumulateAndFill.
value);
159 void SVDROIDQMModule::createHistosDictionaries()
171 std::set<Belle2::VxdID> svdLayers = m_geoCache.getLayers(VXD::SensorInfoBase::SVD);
172 std::set<Belle2::VxdID>::iterator itSvdLayers = svdLayers.begin();
174 while (itSvdLayers != svdLayers.end()) {
176 std::set<Belle2::VxdID> svdLadders = m_geoCache.getLadders(*itSvdLayers);
177 std::set<Belle2::VxdID>::iterator itSvdLadders = svdLadders.begin();
179 while (itSvdLadders != svdLadders.end()) {
181 std::set<Belle2::VxdID> svdSensors = m_geoCache.getSensors(*itSvdLadders);
182 std::set<Belle2::VxdID>::iterator itSvdSensors = svdSensors.begin();
184 while (itSvdSensors != svdSensors.end()) {
190 const int nPixelsU = wSensorInfo.
getUCells();
191 const int nPixelsV = wSensorInfo.
getVCells();
192 string sensorid = std::to_string(itSvdSensors->getLayerNumber()) +
"_" + std::to_string(itSvdSensors->getLadderNumber()) +
"_" +
193 std::to_string(itSvdSensors->getSensorNumber());
199 name =
"hNROIs_" + sensorid;
200 title =
"number of ROIs for sensor " + sensorid;
203 new TH1F(name.c_str(), title.c_str(), 25, 0, 25),
204 [](
const ROIid*,
double & val) {val++;},
205 [](TH1 * hPtr,
double & val) { hPtr->Fill(val); },
208 hROIDictionaryEvt.insert(pair< Belle2::VxdID, ROIHistoAccumulateAndFill& > ((
Belle2::VxdID)*itSvdSensors, *aHAAF));
217 name =
"hCoorU_" + sensorid;
218 title =
"U coordinate of the extrapolation in U for sensor " + sensorid;
219 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
223 new TH1F(name.c_str(), title.c_str(), 100, -5, 5),
224 [](TH1 * hPtr,
const SVDIntercept * inter) { hPtr->Fill(inter->getCoorU()); }
229 name =
"hCoorV_" + sensorid;
230 title =
"V coordinate of the extrapolation in V for sensor " + sensorid;
231 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
235 new TH1F(name.c_str(), title.c_str(), 100, -5, 5),
236 [](TH1 * hPtr,
const SVDIntercept * inter) { hPtr->Fill(inter->getCoorV()); }
242 name =
"hCoorU_vs_CoorV_" + sensorid;
243 title =
"U vs V intercept (cm) " + sensorid;
244 tmp2D =
new TH2F(name.c_str(), title.c_str(), 100, -5, 5, 100, -5, 5);
245 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
246 tmp2D->GetYaxis()->SetTitle(
"intercept V coor (cm)");
247 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
259 name =
"hStatErrU_" + sensorid;
260 title =
"stat error of the extrapolation in U for sensor " + sensorid;
261 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
265 new TH1F(name.c_str(), title.c_str(), 100, 0, 0.35),
266 [](TH1 * hPtr,
const SVDIntercept * inter) { hPtr->Fill(inter->getSigmaU()); }
270 name =
"hStatErrV_" + sensorid;
271 title =
"stat error of the extrapolation in V for sensor " + sensorid;
272 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
276 new TH1F(name.c_str(), title.c_str(), 100, 0, 0.35),
277 [](TH1 * hPtr,
const SVDIntercept * inter) { hPtr->Fill(inter->getSigmaV()); }
283 name =
"hResidU_" + sensorid;
284 title =
"U residuals = intercept - digit, for sensor " + sensorid;
285 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -5, 5);
286 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
294 for (
auto& it : SVDShaperDigits)
295 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
306 name =
"hResidV_" + sensorid;
307 title =
"V residuals = intercept - digit, for sensor " + sensorid;
308 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -5, 5);
309 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
317 for (
auto& it : SVDShaperDigits)
318 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
319 if (!it.isUStrip()) {
330 name =
"hResidU_vs_CoorU_" + sensorid;
331 title =
"U residual (cm) vs coor U (cm) " + sensorid;
332 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
333 tmp2D->GetYaxis()->SetTitle(
"U resid (cm)");
334 tmp2D->GetXaxis()->SetTitle(
"U coor (cm)");
335 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
343 for (
auto& it : SVDShaperDigits)
344 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && it.isUStrip()) {
347 hPtr->Fill(inter->
getCoorU(), resid);
354 name =
"hResidV_vs_CoorV_" + sensorid;
355 title =
"V residual (cm) vs coor V (cm) " + sensorid;
356 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
357 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
358 tmp2D->GetXaxis()->SetTitle(
"V coor (cm)");
359 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
367 for (
auto& it : SVDShaperDigits)
368 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (!it.isUStrip())) {
371 hPtr->Fill(inter->
getCoorV(), resid);
380 name =
"hResidU_vs_charge_" + sensorid;
381 title =
"U residual (cm) vs charge " + sensorid;
382 tmp2D =
new TH2F(name.c_str(), title.c_str(), 250, 0, 250, 100, -5, 5);
383 tmp2D->GetYaxis()->SetTitle(
"U resid (cm)");
384 tmp2D->GetXaxis()->SetTitle(
"charge");
385 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
393 for (
auto& it : SVDRecoDigits)
394 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (it.isUStrip())) {
397 hPtr->Fill(it.getCharge(), resid);
404 name =
"hResidV_vs_charge_" + sensorid;
405 title =
"V residual (cm) vs charge " + sensorid;
406 tmp2D =
new TH2F(name.c_str(), title.c_str(), 250, 0, 250, 100, -5, 5);
407 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
408 tmp2D->GetXaxis()->SetTitle(
"charge");
409 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
417 for (
auto& it : SVDRecoDigits)
418 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (!it.isUStrip())) {
421 hPtr->Fill(it.getCharge(), resid);
430 name =
"hCoorU_vs_UDigit_" + sensorid;
431 title =
"U intercept (cm) vs U Digit (ID) " + sensorid;
432 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
433 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
434 tmp2D->GetYaxis()->SetTitle(
"digit U coor (cm)");
435 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
443 for (
auto& it : SVDShaperDigits)
444 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (it.isUStrip())) {
454 name =
"hCoorV_vs_VDigit_" + sensorid;
455 title =
"V intercept (cm) vs V Digit (ID) " + sensorid;
456 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
457 tmp2D->GetXaxis()->SetTitle(
"intercept V coor (cm)");
458 tmp2D->GetYaxis()->SetTitle(
"digi V coor (cm)");
459 hInterDictionary.insert(pair< Belle2::VxdID, InterHistoAndFill >
467 for (
auto& it : SVDShaperDigits) {
468 if (((
int)it.getSensorID() == (
int)inter->
getSensorID()) && (!it.isUStrip())) {
488 name =
"hminU_" + sensorid;
489 title =
"ROI min in U for sensor " + sensorid;
490 hROIDictionary.insert(pair< Belle2::VxdID, ROIHistoAndFill >
494 new TH1F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU),
495 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMinUid()); }
499 name =
"hminV_" + sensorid;
500 title =
"ROI min in V for sensor " + sensorid;
501 hROIDictionary.insert(pair< Belle2::VxdID, ROIHistoAndFill >
505 new TH1F(name.c_str(), title.c_str(), nPixelsV, 0, nPixelsV),
506 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMinVid()); }
512 name =
"hmaxU_" + sensorid;
513 title =
"ROI max in U for sensor " + sensorid;
514 hROIDictionary.insert(pair< Belle2::VxdID, ROIHistoAndFill >
518 new TH1F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU),
519 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMaxUid()); }
523 name =
"hmaxV_" + sensorid;
524 title =
"ROI max in V for sensor " + sensorid;
525 hROIDictionary.insert(pair< Belle2::VxdID, ROIHistoAndFill >
529 new TH1F(name.c_str(), title.c_str(), nPixelsV, 0, nPixelsV),
530 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMaxVid()); }
537 name =
"hwidthU_" + sensorid;
538 title =
"ROI width in U for sensor " + sensorid;
539 hROIDictionary.insert(pair< Belle2::VxdID, ROIHistoAndFill >
543 new TH1F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU),
544 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMaxUid() - roi->getMinUid()); }
548 name =
"hwidthV_" + sensorid;
549 title =
"ROI width in V for sensor " + sensorid;
550 hROIDictionary.insert(pair< Belle2::VxdID, ROIHistoAndFill >
554 new TH1F(name.c_str(), title.c_str(), nPixelsV, 0, nPixelsV),
555 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMaxVid() - roi->getMinVid()); }
561 name =
"hROIcenter_" + sensorid;
562 title =
"ROI center " + sensorid;
563 tmp2D =
new TH2F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU, nPixelsV, 0, nPixelsV);
564 tmp2D->GetXaxis()->SetTitle(
" U (ID)");
565 tmp2D->GetYaxis()->SetTitle(
" V (ID)");
566 hROIDictionary.insert(pair< Belle2::VxdID, ROIHistoAndFill >
571 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill((roi->getMaxUid() + roi->getMinUid()) / 2, (roi->getMaxVid() + roi->getMinVid()) / 2); }
590 auto its = hInterDictionary.equal_range(inter->
getSensorID());
592 for (
auto it = its.first; it != its.second; ++it) {
594 aInterHistoAndFill.second(aInterHistoAndFill.first, inter);
599 void SVDROIDQMModule::fillSensorROIHistos(
const ROIid* roi)
602 auto its = hROIDictionary.equal_range(roi->getSensorID());
604 for (
auto it = its.first; it != its.second; ++it) {
606 aROIHistoAndFill.second(aROIHistoAndFill.first, roi);
609 auto itsEvt = hROIDictionaryEvt.equal_range(roi->getSensorID());
610 for (
auto it = itsEvt.first; it != itsEvt.second; ++it)
611 (it->second).accumulate(roi, (it->second).value);
614 void SVDROIDQMModule::endRun()
617 hCellU->Scale((
double)1 / n_events);
618 hCellV->Scale((
double)1 / n_events);
620 for (
auto it = hROIDictionaryEvt.begin(); it != hROIDictionaryEvt.end(); ++it)
621 delete &(it->second);
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
ROIid stores the U and V ids and the sensor id of the Region Of Interest.
SVDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an SVD ...
Creates basic DQM for ROI creation on ExpressReco
std::pair< TH1 *, std::function< void(TH1 *, const SVDIntercept *) > > InterHistoAndFill
typedef: histograms to be filled once per intercept + filling function
std::pair< TH1 *, std::function< void(TH1 *, const ROIid *) > > ROIHistoAndFill
typedef: histograms to be filled once per roi + filling function
Accessor to arrays stored in the data store.
double getCoorV() const
return the V 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.
int getVCells() const
Return number of pixel/strips in v direction.
int getUCells() const
Return number of pixel/strips 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.
struct: histograms to be filled once per event + filling fucntion + accumulate function
std::function< void(TH1 *, double &) > fill
fill function
TH1 * hPtr
histogram pointer
double value
value used to fill