9#include <dqm/analysis/modules/DQMHistAnalysisPXDER.h>
11#include <pxd/geometry/SensorInfo.h>
12#include <vxd/geometry/SensorInfoBase.h>
13#include <vxd/geometry/GeoCache.h>
15#include <boost/format.hpp>
40 std::string(
"PXDER"));
41 addParam(
"RefHistoFile",
m_refFileName,
"Reference histrogram file name", std::string(
"refHisto.root"));
87 VxdID sensorID(iLayer, iLadder, iSensor);
89 string sensorDescr = str(format(
"%1%_%2%_%3%") % iLayer % iLadder % iSensor);
93 m_fired.emplace_back(str(format(
"DQMER_PXD_%1%_Fired") % sensorDescr));
98 m_clusters.emplace_back(str(format(
"DQMER_PXD_%1%_Clusters") % sensorDescr));
103 m_startRow.emplace_back(str(format(
"DQMER_PXD_%1%_StartRow") % sensorDescr));
108 m_chargStartRow.emplace_back(str(format(
"DQMER_PXD_%1%_AverageSeedByStartRow") % sensorDescr));
112 m_startRowCount.emplace_back(str(format(
"DQMER_PXD_%1%_SeedCountsByStartRow") % sensorDescr));
117 m_clusterCharge.emplace_back(str(format(
"DQMER_PXD_%1%_ClusterCharge") % sensorDescr));
122 m_pixelSignal.emplace_back(str(format(
"DQMER_PXD_%1%_PixelSignal") % sensorDescr));
127 m_clusterSizeU.emplace_back(str(format(
"DQMER_PXD_%1%_ClusterSizeU") % sensorDescr));
132 m_clusterSizeV.emplace_back(str(format(
"DQMER_PXD_%1%_ClusterSizeV") % sensorDescr));
137 m_clusterSizeUV.emplace_back(str(format(
"DQMER_PXD_%1%_ClusterSizeUV") % sensorDescr));
147 m_fFiredFlag =
new TH1I(
"DQMER_PXD_FiredFlag",
"DQM ER PXD Fired Flag",
151 m_fClustersFlag =
new TH1I(
"DQMER_PXD_ClustersFlag",
"DQM ER PXD Clusters Flag",
155 m_fStartRowFlag =
new TH1I(
"DQMER_PXD_StartRowFlag",
"DQM ER PXD Start Row Flag",
159 m_fChargStartRowFlag =
new TH1I(
"DQMER_PXD_ChargStartRowFlag",
"DQM ER PXD Charg Start Row Flag",
175 m_fClusterChargeFlag =
new TH1I(
"DQMER_PXD_ClusterChargeFlag",
"DQM ER PXD Cluster Charge Flag",
179 m_fPixelSignalFlag =
new TH1I(
"DQMER_PXD_PixelSignalFlag",
"DQM ER PXD Pixel Signal Flag",
183 m_fClusterSizeUFlag =
new TH1I(
"DQMER_PXD_ClasterSizeUFlag",
"DQM ER PXD Cluster Size U Flag",
187 m_fClusterSizeVFlag =
new TH1I(
"DQMER_PXD_ClasterSizeVFlag",
"DQM ER PXD Cluster Size V Flag",
191 m_fClusterSizeUVFlag =
new TH1I(
"DQMER_PXD_ClasterSizeUVFlag",
"DQM ER PXD Cluster Size UV Flag",
201 TString AxisTicks = Form(
"%i_%i_%i", iLayer, iLadder, iSensor);
204 m_fFiredFlag->GetXaxis()->SetBinLabel(i + 1, AxisTicks.Data());
265 double m_NoOfEvents = 1., m_NoOfEventsRef = 1.;
271 SetFlag(2, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
273 SetFlag(2, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
275 SetFlag(100, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
277 SetFlag(100, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
279 SetFlag(100, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
281 SetFlag(5, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
283 SetFlag(5, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
285 SetFlag(2, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
287 SetFlag(2, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
289 SetFlag(2, i, pars, (
double)m_NoOfEvents / m_NoOfEventsRef,
304 if (tempcounter == Index) {
305 Layer = layer.getLayerNumber();
306 Ladder = ladder.getLadderNumber();
307 Sensor = sensor.getSensorNumber();
317 const std::string& name_refhist, TH1I* flaghist)
320 float WarningLevel = 6.0;
321 float ErrorLevel = 10.0;
323 TH1* hist =
nullptr, *refhist =
nullptr;
326 if (!hist)
return -1;
329 if (!refhist)
return -1;
333 auto temp = std::unique_ptr<TH1F>(
new TH1F(
"temp",
"temp", hist->GetNbinsX(), hist->GetXaxis()->GetXmin(),
334 hist->GetXaxis()->GetXmax()));
338 for (
int j = 0; j < hist->GetNbinsX(); j++) {
339 double val = hist->GetBinContent(j + 1);
342 temp->SetBinContent(j + 1, val);
343 flagInt += temp->GetBinContent(j + 1);
344 flagrInt += refhist->GetBinContent(j + 1);
348 flaghist->SetBinContent(bin + 1, -1);
351 double flag = temp->GetMean();
352 double flagErr = temp->GetMeanError();
353 double flagRMS = temp->GetRMS();
354 double flagRMSErr = temp->GetRMSError();
355 double flagr = refhist->GetMean();
356 double flagrErr = refhist->GetMeanError();
357 double flagrRMS = refhist->GetRMS();
358 double flagrRMSErr = refhist->GetRMSError();
359 TString strDebugInfo = Form(
"Conditions for Flag--->\n source %f %f+-%f %f+-%f\n referen %f %f+-%f %f+-%f\n",
360 flagInt, flag, flagErr, flagRMS, flagRMSErr,
361 flagrInt, flagr, flagrErr, flagrRMS, flagrRMSErr
363 B2DEBUG(130, strDebugInfo.Data());
365 if ((fabs(flag - flagr) > ErrorLevel * (flagErr + flagrErr)) ||
366 (fabs(flagRMS - flagrRMS) > ErrorLevel * (flagRMSErr + flagrRMSErr)) ||
367 (fabs(flagInt - flagrInt) > ErrorLevel * (
sqrt(flagInt) +
sqrt(flagrInt)))
369 flaghist->SetBinContent(bin + 1, 2);
370 }
else if ((fabs(flag - flagr) > WarningLevel * (flagErr + flagrErr)) ||
371 (fabs(flagRMS - flagrRMS) > WarningLevel * (flagRMSErr + flagrRMSErr)) ||
372 (fabs(flagInt - flagrInt) > WarningLevel * (
sqrt(flagInt) +
sqrt(flagrInt)))
374 flaghist->SetBinContent(bin + 1, 1);
376 flaghist->SetBinContent(bin + 1, 0);
379 }
else if (Type == 2) {
380 if (fabs(flagInt - flagrInt) > ErrorLevel * (
sqrt(flagInt) +
sqrt(flagrInt))) {
381 flaghist->SetBinContent(bin + 1, 2);
382 }
else if (fabs(flagInt - flagrInt) > WarningLevel * (
sqrt(flagInt) +
sqrt(flagrInt))) {
383 flaghist->SetBinContent(bin + 1, 1);
385 flaghist->SetBinContent(bin + 1, 0);
388 }
else if (Type == 3) {
389 if (fabs(flag - flagr) > ErrorLevel * (flagErr + flagrErr)) {
390 flaghist->SetBinContent(bin + 1, 2);
391 }
else if (fabs(flag - flagr) > WarningLevel * (flagErr + flagrErr)) {
392 flaghist->SetBinContent(bin + 1, 1);
394 flaghist->SetBinContent(bin + 1, 0);
397 }
else if (Type == 4) {
398 if (fabs(flagRMS - flagrRMS) > ErrorLevel * (flagRMSErr + flagrRMSErr)) {
399 flaghist->SetBinContent(bin + 1, 2);
400 }
else if (fabs(flagRMS - flagrRMS) > WarningLevel * (flagRMSErr + flagrRMSErr)) {
401 flaghist->SetBinContent(bin + 1, 1);
403 flaghist->SetBinContent(bin + 1, 0);
406 }
else if (Type == 5) {
407 if ((fabs(flag - flagr) > ErrorLevel * (flagErr + flagrErr)) ||
408 (fabs(flagInt - flagrInt) > ErrorLevel * (
sqrt(flagInt) +
sqrt(flagrInt)))
410 flaghist->SetBinContent(bin + 1, 2);
411 }
else if ((fabs(flag - flagr) > WarningLevel * (flagErr + flagrErr)) ||
412 (fabs(flagInt - flagrInt) > WarningLevel * (
sqrt(flagInt) +
sqrt(flagrInt)))
414 flaghist->SetBinContent(bin + 1, 1);
416 flaghist->SetBinContent(bin + 1, 0);
419 }
else if (Type == 9) {
420 flagInt = temp->GetBinContent(bin + 1);
421 flagrInt = refhist->GetBinContent(bin + 1);
422 if (fabs(flagInt - flagrInt) > ErrorLevel * (
sqrt(flagInt) +
sqrt(flagrInt))) {
423 flaghist->SetBinContent(bin + 1, 2);
424 }
else if (fabs(flagInt - flagrInt) > WarningLevel * (
sqrt(flagInt) +
sqrt(flagrInt))) {
425 flaghist->SetBinContent(bin + 1, 1);
427 flaghist->SetBinContent(bin + 1, 0);
430 }
else if (Type == 10) {
431 float flag2 = refhist->Chi2Test(temp.get());
432 flaghist->SetBinContent(bin + 1, 0);
434 flaghist->SetBinContent(bin + 1, 2);
436 flaghist->SetBinContent(bin + 1, 1);
438 }
else if (Type == 100) {
439 flaghist->SetBinContent(bin + 1, 0);
442 flaghist->SetBinContent(bin + 1, -3);
445 strDebugInfo = Form(
"SetFlag---> %f, type %i\n", flaghist->GetBinContent(bin + 1), Type);
446 B2DEBUG(130, strDebugInfo.Data());
The base class for the histogram analysis module.
static TH1 * findHistInFile(TFile *file, const std::string &histname)
Find histogram in specific TFile (e.g.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
int c_nPXDLayers
Number of PXD layers on Belle II.
void terminate(void) override final
Terminator.
std::string m_refFileName
Reference Histogram Root file name.
void initialize() override final
Initializer.
std::vector< std::string > m_chargStartRow
Cluster seed charge by distance from the start row.
std::vector< std::string > m_startRow
Start row distribution.
std::vector< std::string > m_ref_clusterCharge
Charge of clusters.
TH1I * m_fClusterSizeUFlag
Flags of u cluster size.
int c_firstVXDLayer
First VXD layer on Belle II.
std::vector< std::string > m_ref_clusterSizeV
v cluster size
int c_lastVXDLayer
Last VXD layer on Belle II.
std::vector< std::string > m_clusterSizeU
u cluster size
TH1I * m_fPixelSignalFlag
Flags of Charge of pixels.
std::vector< std::string > m_ref_startRow
Start row distribution.
int c_lastPXDLayer
Last PXD layer on Belle II.
std::vector< std::string > m_ref_clusterSizeU
u cluster size
std::vector< std::string > m_clusters
Clusters per event.
std::vector< std::string > m_ref_startRowCount
counter for Cluster seed charge by distance from the start row
TH1I * m_fStartRowFlag
Flags of Start row distribution.
TH1I * m_fClusterSizeUVFlag
Flags of Cluster size.
~DQMHistAnalysisPXDERModule()
Destructor.
std::vector< std::string > m_clusterSizeUV
Cluster size.
int c_firstPXDLayer
First PXD layer on Belle II.
TH1I * m_fStartRowCountFlag
Flags of counter for Cluster seed charge by distance from the start row.
TH1I * m_fChargStartRowFlag
Flags of Cluster seed charge by distance from the start row.
void event() override final
This method is called for each event.
TH1I * m_fClusterSizeVFlag
Flags of v cluster size.
TH1I * m_fClustersFlag
Flags of Clusters per event.
std::vector< std::string > m_startRowCount
counter for Cluster seed charge by distance from the start row
DQMHistAnalysisPXDERModule()
Constructor.
std::string m_histogramDirectoryName
Function return flag histogram filled based on condition from TH1I source.
std::vector< std::string > m_clusterSizeV
v cluster size
std::vector< std::string > m_pixelSignal
Charge of pixels.
std::vector< std::string > m_ref_clusterSizeUV
Cluster size.
std::vector< std::string > m_ref_clusters
Clusters per event.
void beginRun() override final
Called when entering a new run.
TH1I * m_fClusterChargeFlag
Flags of Charge of clusters.
int SetFlag(int Type, int bin, const double *pars, double ratio, const std::string &name_hist, const std::string &name_refhist, TH1I *flaghist)
Function return flag histogram filled based on condition from TH1F source.
std::vector< std::string > m_fired
Hitmaps of Digits.
TH1I * m_fFiredFlag
Basic Directory in output file.
std::vector< std::string > m_ref_chargStartRow
Cluster seed charge by distance from the start row.
std::vector< std::string > m_ref_pixelSignal
Charge of pixels.
int c_nPXDSensors
Number of PXD sensors on Belle II.
std::vector< std::string > m_clusterCharge
Charge of clusters.
void getIDsFromIndex(const int Index, int &Layer, int &Ladder, int &Sensor) const
Function return index of sensor in plots.
int c_nVXDLayers
Number of pixels on PXD v direction.
std::vector< std::string > m_ref_fired
Fired pixels per event.
int c_firstSVDLayer
First SVD layer on Belle II.
int c_nSVDLayers
Number of SVD layers on Belle II.
int c_lastSVDLayer
Last SVD layer on Belle II.
TFile * m_refFile
The pointer to the reference file.
void setDescription(const std::string &description)
Sets the description of the module.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
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.
static GeoCache & getInstance()
Return a reference to the singleton instance.
const std::set< Belle2::VxdID > & getLadders(Belle2::VxdID layer) const
Return a set of all ladder IDs belonging to a given layer.
Class to uniquely identify a any structure of the PXD and SVD.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.