9#include <tracking/modules/roiFinding/pxd/ROIDQMModule.h>
11#include <tracking/dataobjects/ROIid.h>
12#include <tracking/dataobjects/PXDIntercept.h>
13#include <pxd/dataobjects/PXDDigit.h>
14#include <vxd/geometry/GeoCache.h>
16#include <TDirectory.h>
30ROIDQMModule::ROIDQMModule()
34 , m_hInterDictionary(40, [](const
Belle2::
VxdID & vxdid) {
return (
size_t)vxdid.getID(); })
35, m_hROIDictionary(40, [](
const Belle2::VxdID& vxdid) {
return (
size_t)vxdid.getID(); })
36, m_hROIDictionaryEvt(40, [](
const Belle2::VxdID& vxdid) {
return (
size_t)vxdid.getID(); })
41, m_hredFactor(
nullptr)
44 setDescription(
"Monitor of the ROI creation on HLT");
45 setPropertyFlags(c_ParallelProcessingCertified);
47 addParam(
"PXDDigitsName", m_PXDDigitsName,
48 "name of the list of PXDDigits", std::string(
""));
50 addParam(
"InterceptsName", m_InterceptsName,
51 "name of the list of Interceptions", std::string(
""));
53 addParam(
"ROIsName", m_ROIsName,
54 "name of the list of ROIs", std::string(
""));
62 TDirectory* oldDir = gDirectory;
63 oldDir->mkdir(
"intercept");
64 oldDir->cd(
"intercept");
71 m_hnInter =
new TH1F(
"hnInter",
"number of intercepts", 100, 0, 100);
74 m_hnROIs =
new TH1F(
"hnROIs",
"number of ROIs", 100, 0, 100);
75 m_harea =
new TH1F(
"harea",
"ROI area", 100, 0, 100000);
76 m_hredFactor =
new TH1F(
"hredFactor",
"ROI reduction factor", 1000, 0, 1);
104 (it->second).value = 0;
107 double redFactor = 0;
113 const int nPixelsU = aSensorInfo.
getUCells();
114 const int nPixelsV = aSensorInfo.
getVCells();
116 const int minU = it.getMinUid();
117 const int minV = it.getMinVid();
118 const int maxU = it.getMaxUid();
119 const int maxV = it.getMaxVid();
121 int tmpROIarea = (maxU - minU) * (maxV - minV);
122 ROIarea += tmpROIarea;
123 redFactor += (double)tmpROIarea / (nPixelsU * nPixelsV *
m_numModules);
129 m_harea->Fill((
double)ROIarea);
136 aROIHistoAccumulateAndFill.
fill(aROIHistoAccumulateAndFill.
hPtr, aROIHistoAccumulateAndFill.
value);
154 std::set<Belle2::VxdID>::iterator itPxdLayers = pxdLayers.begin();
156 while (itPxdLayers != pxdLayers.end()) {
159 std::set<Belle2::VxdID>::iterator itPxdLadders = pxdLadders.begin();
161 while (itPxdLadders != pxdLadders.end()) {
164 std::set<Belle2::VxdID>::iterator itPxdSensors = pxdSensors.begin();
166 while (itPxdSensors != pxdSensors.end()) {
172 const int nPixelsU = wSensorInfo.
getUCells();
173 const int nPixelsV = wSensorInfo.
getVCells();
174 std::string sensorid = std::to_string(itPxdSensors->getLayerNumber()) +
"_" + std::to_string(
175 itPxdSensors->getLadderNumber()) +
"_" +
176 std::to_string(itPxdSensors->getSensorNumber());
182 name =
"hNROIs_" + sensorid;
183 title =
"number of m_roiIDs for sensor " + sensorid;
186 new TH1F(name.c_str(), title.c_str(), 25, 0, 25),
187 [](
const ROIid*,
double & val) {val++;},
188 [](TH1 * hPtr,
double & val) { hPtr->Fill(val); },
200 name =
"hCoorU_" + sensorid;
201 title =
"U coordinate of the extrapolation in U for sensor " + sensorid;
206 new TH1F(name.c_str(), title.c_str(), 100, -5, 5),
207 [](TH1 * hPtr,
const PXDIntercept * inter) { hPtr->Fill(inter->getCoorU()); }
212 name =
"hCoorV_" + sensorid;
213 title =
"V coordinate of the extrapolation in V for sensor " + sensorid;
218 new TH1F(name.c_str(), title.c_str(), 100, -5, 5),
219 [](TH1 * hPtr,
const PXDIntercept * inter) { hPtr->Fill(inter->getCoorV()); }
225 name =
"hCoorU_vs_CoorV_" + sensorid;
226 title =
"U vs V intercept (cm) " + sensorid;
227 tmp2D =
new TH2F(name.c_str(), title.c_str(), 100, -5, 5, 100, -5, 5);
228 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
229 tmp2D->GetYaxis()->SetTitle(
"intercept V coor (cm)");
242 name =
"hStatErrU_" + sensorid;
243 title =
"stat error of the extrapolation in U for sensor " + sensorid;
248 new TH1F(name.c_str(), title.c_str(), 100, 0, 0.35),
249 [](TH1 * hPtr,
const PXDIntercept * inter) { hPtr->Fill(inter->getSigmaU()); }
253 name =
"hStatErrV_" + sensorid;
254 title =
"stat error of the extrapolation in V for sensor " + sensorid;
259 new TH1F(name.c_str(), title.c_str(), 100, 0, 0.35),
260 [](TH1 * hPtr,
const PXDIntercept * inter) { hPtr->Fill(inter->getSigmaV()); }
266 name =
"hResidU_" + sensorid;
267 title =
"U residuals = intercept - digit, for sensor " + sensorid;
268 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -5, 5);
276 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
277 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
278 hPtr->Fill(inter->getCoorU() - aSensorInfo.getUCellPosition(it.getUCellID(), it.getVCellID()));
285 name =
"hResidV_" + sensorid;
286 title =
"V residuals = intercept - digit, for sensor " + sensorid;
287 tmp1D =
new TH1F(name.c_str(), title.c_str(), 1000, -5, 5);
295 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
296 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
297 hPtr->Fill(inter->getCoorV() - aSensorInfo.getVCellPosition(it.getVCellID()));
304 name =
"hResidV_vs_ResidU_" + sensorid;
305 title =
"V vs U residuals = intercept - digit, for sensor " + sensorid;
306 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
307 tmp2D->GetXaxis()->SetTitle(
"U resid (cm)");
308 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
316 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
317 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
318 double residU = inter->getCoorU() - aSensorInfo.getUCellPosition(it.getUCellID(), it.getVCellID());
319 double residV = inter->getCoorV() - aSensorInfo.getVCellPosition(it.getVCellID());
320 hPtr->Fill(residU, residV);
327 name =
"hResidVm_vs_ResidU_" + sensorid;
328 title =
"V vs U residuals = intercept - digit, for sensor " + sensorid;
329 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
330 tmp2D->GetXaxis()->SetTitle(
"U resid (cm)");
331 tmp2D->GetYaxis()->SetTitle(
"V* resid (cm)");
339 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
340 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
341 double residU = inter->getCoorU() - aSensorInfo.getUCellPosition(it.getUCellID(), it.getVCellID());
342 double residV = inter->getCoorV() + aSensorInfo.getVCellPosition(it.getVCellID());
343 hPtr->Fill(residU, residV);
350 name =
"hResidV_vs_ResidUm_" + sensorid;
351 title =
"V vs U residuals = intercept - digit, for sensor " + sensorid;
352 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
353 tmp2D->GetXaxis()->SetTitle(
"U* resid (cm)");
354 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
362 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
363 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
364 double residU = inter->getCoorU() + aSensorInfo.getUCellPosition(it.getUCellID(), it.getVCellID());
365 double residV = inter->getCoorV() - aSensorInfo.getVCellPosition(it.getVCellID());
366 hPtr->Fill(residU, residV);
373 name =
"hResidVm_vs_ResidUm_" + sensorid;
374 title =
"V vs U residuals = intercept - digit, for sensor " + sensorid;
375 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
376 tmp2D->GetXaxis()->SetTitle(
"U* resid (cm)");
377 tmp2D->GetYaxis()->SetTitle(
"V* resid (cm)");
385 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
386 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
387 double residU = inter->getCoorU() + aSensorInfo.getUCellPosition(it.getUCellID(), it.getVCellID());
388 double residV = inter->getCoorV() + aSensorInfo.getVCellPosition(it.getVCellID());
389 hPtr->Fill(residU, residV);
397 name =
"hResidU_vs_CoorU_" + sensorid;
398 title =
"U residual (cm) vs coor U (cm) " + sensorid;
399 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
400 tmp2D->GetYaxis()->SetTitle(
"U resid (cm)");
401 tmp2D->GetXaxis()->SetTitle(
"U coor (cm)");
409 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
410 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
411 double resid = inter->getCoorU() - aSensorInfo.getUCellPosition(it.getUCellID(), it.getVCellID());
412 hPtr->Fill(inter->getCoorU(), resid);
419 name =
"hResidV_vs_CoorV_" + sensorid;
420 title =
"V residual (cm) vs coor V (cm) " + sensorid;
421 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
422 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
423 tmp2D->GetXaxis()->SetTitle(
"V coor (cm)");
431 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
432 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
433 double resid = inter->getCoorV() - aSensorInfo.getVCellPosition(it.getVCellID());
434 hPtr->Fill(inter->getCoorV(), resid);
442 name =
"hResidU_vs_CoorV_" + sensorid;
443 title =
"U residual (cm) vs coor V (cm) " + sensorid;
444 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
445 tmp2D->GetYaxis()->SetTitle(
"U resid (cm)");
446 tmp2D->GetXaxis()->SetTitle(
"V coor (cm)");
454 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
455 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
456 double resid = inter->getCoorU() - aSensorInfo.getUCellPosition(it.getUCellID(), it.getVCellID());
457 hPtr->Fill(inter->getCoorV(), resid);
464 name =
"hResidV_vs_CoorU_" + sensorid;
465 title =
"V residual (cm) vs coor U (cm) " + sensorid;
466 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
467 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
468 tmp2D->GetXaxis()->SetTitle(
"U coor (cm)");
476 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
477 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
478 double resid = inter->getCoorV() - aSensorInfo.getVCellPosition(it.getVCellID());
479 hPtr->Fill(inter->getCoorU(), resid);
489 name =
"hResidU_vs_charge_" + sensorid;
490 title =
"U residual (cm) vs charge " + sensorid;
491 tmp2D =
new TH2F(name.c_str(), title.c_str(), 250, 0, 250, 100, -5, 5);
492 tmp2D->GetYaxis()->SetTitle(
"U resid (cm)");
493 tmp2D->GetXaxis()->SetTitle(
"charge");
501 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
502 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
503 double resid = inter->getCoorU() - aSensorInfo.getUCellPosition(it.getUCellID(), it.getVCellID());
504 hPtr->Fill(it.getCharge(), resid);
511 name =
"hResidV_vs_charge_" + sensorid;
512 title =
"V residual (cm) vs charge " + sensorid;
513 tmp2D =
new TH2F(name.c_str(), title.c_str(), 250, 0, 250, 100, -5, 5);
514 tmp2D->GetYaxis()->SetTitle(
"V resid (cm)");
515 tmp2D->GetXaxis()->SetTitle(
"charge");
523 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
524 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
525 double resid = inter->getCoorV() - aSensorInfo.getVCellPosition(it.getVCellID());
526 hPtr->Fill(it.getCharge(), resid);
535 name =
"hCoorU_vs_UDigit_" + sensorid;
536 title =
"U intercept (cm) vs U Digit (ID) " + sensorid;
537 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
538 tmp2D->GetXaxis()->SetTitle(
"intercept U coor (cm)");
539 tmp2D->GetYaxis()->SetTitle(
"digit U coor (cm)");
547 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
548 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
549 hPtr->Fill(inter->getCoorU(), aSensorInfo.getUCellPosition(it.getUCellID(), it.getVCellID()));
557 name =
"hCoorV_vs_VDigit_" + sensorid;
558 title =
"V intercept (cm) vs V Digit (ID) " + sensorid;
559 tmp2D =
new TH2F(name.c_str(), title.c_str(), 1000, -5, 5, 1000, -5, 5);
560 tmp2D->GetXaxis()->SetTitle(
"intercept V coor (cm)");
561 tmp2D->GetYaxis()->SetTitle(
"digi V coor (cm)");
569 if ((
int)it.getSensorID() == (
int)inter->
getSensorID()) {
570 const VXD::SensorInfoBase& aSensorInfo = m_aGeometry.getSensorInfo(it.getSensorID());
571 hPtr->Fill(inter->getCoorV(), aSensorInfo.getVCellPosition(it.getVCellID()));
586 name =
"hminU_" + sensorid;
587 title =
"ROI min in U for sensor " + sensorid;
592 new TH1F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU),
593 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMinUid()); }
597 name =
"hminV_" + sensorid;
598 title =
"ROI min in V for sensor " + sensorid;
603 new TH1F(name.c_str(), title.c_str(), nPixelsV, 0, nPixelsV),
604 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMinVid()); }
610 name =
"hmaxU_" + sensorid;
611 title =
"ROI max in U for sensor " + sensorid;
616 new TH1F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU),
617 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMaxUid()); }
621 name =
"hmaxV_" + sensorid;
622 title =
"ROI max in V for sensor " + sensorid;
627 new TH1F(name.c_str(), title.c_str(), nPixelsV, 0, nPixelsV),
628 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMaxVid()); }
635 name =
"hwidthU_" + sensorid;
636 title =
"ROI width in U for sensor " + sensorid;
641 new TH1F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU),
642 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMaxUid() - roi->getMinUid()); }
646 name =
"hwidthV_" + sensorid;
647 title =
"ROI width in V for sensor " + sensorid;
652 new TH1F(name.c_str(), title.c_str(), nPixelsV, 0, nPixelsV),
653 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill(roi->getMaxVid() - roi->getMinVid()); }
659 name =
"hROIcenter_" + sensorid;
660 title =
"ROI center " + sensorid;
661 tmp2D =
new TH2F(name.c_str(), title.c_str(), nPixelsU, 0, nPixelsU, nPixelsV, 0, nPixelsV);
662 tmp2D->GetXaxis()->SetTitle(
" U (ID)");
663 tmp2D->GetYaxis()->SetTitle(
" V (ID)");
669 [](TH1 * hPtr,
const ROIid * roi) { hPtr->Fill((roi->getMaxUid() + roi->getMinUid()) / 2, (roi->getMaxVid() + roi->getMinVid()) / 2); }
690 for (
auto it = its.first; it != its.second; ++it) {
692 aInterHistoAndFill.second(aInterHistoAndFill.first, inter);
702 for (
auto it = its.first; it != its.second; ++it) {
704 aROIHistoAndFill.second(aROIHistoAndFill.first, roi);
708 for (
auto it = itsEvt.first; it != itsEvt.second; ++it)
709 (it->second).accumulate(roi, (it->second).value);
715 delete &(it->second);
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
void terminate(void) override final
This method is called at the end of the event processing.
int m_numModules
number of modules
StoreArray< PXDIntercept > m_pxdIntercept
the PXDIntercepts dataobjects collection
std::string m_InterceptsName
Name of the PXDIntercept StoreArray.
VXD::GeoCache & m_aGeometry
the geometry
TDirectory * m_ROIDir
ROI directory in the root file.
void fillSensorInterHistos(const PXDIntercept *inter)
fill histograms per sensor, filled once per intercept
void createHistosDictionaries()
create the dictionary
void initialize(void) override final
Initializer.
void fillSensorROIHistos(const ROIid *roi)
fill histograms per sensor, filled once per ROI
std::unordered_multimap< Belle2::VxdID, ROIHistoAndFill, std::function< size_t(const Belle2::VxdID &)> > m_hROIDictionary
map of histograms to be filled once per roi
void defineHisto() override final
define histograms
std::pair< TH1 *, std::function< void(TH1 *, const PXDIntercept *) > > 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
TH1F * m_hnROIs
number of ROIs
std::string m_ROIsName
Name of the ROIid StoreArray.
StoreArray< ROIid > m_roiIDs
the ROIids dataobjects collection
TH1F * m_hredFactor
reduction factor
std::unordered_multimap< Belle2::VxdID, InterHistoAndFill, std::function< size_t(const Belle2::VxdID &)> > m_hInterDictionary
map of histograms to be filled once per intercept
TDirectory * m_InterDir
intercepts directory in the root file
std::unordered_multimap< Belle2::VxdID, ROIHistoAccumulateAndFill &, std::function< size_t(const Belle2::VxdID &) > > m_hROIDictionaryEvt
map of histograms to be filled once per event
TH1F * m_hnInter
number of intercepts
StoreArray< PXDDigit > m_pxdDigits
the PXDDigits dataobjects collection
void event(void) override final
This method is called for each event.
ROIid stores the U and V ids and the sensor id of the Region Of Interest.
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
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
const std::set< Belle2::VxdID > & getSensors(Belle2::VxdID ladder) const
Return a set of all sensor IDs belonging to a given ladder.
const std::set< Belle2::VxdID > & getLadders(Belle2::VxdID layer) const
Return a set of all ladder IDs belonging to a given layer.
Base class to provide Sensor Information for PXD and SVD.
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 function + accumulate function
std::function< void(TH1 *, double &) > fill
fill function
TH1 * hPtr
histogram pointer
double value
value used to fill