9#include <dqm/analysis/modules/DQMHistAnalysisPXDBow.h>
11#include <tracking/dbobjects/ROICalculationParameters.h>
12#include <vxd/geometry/GeoCache.h>
32 std::string(
"PXDBow/"));
34 "Layer_ladder_sensor numbers of the module which residual histogram will be plotted on the DQM, if empty all histogram are plotted",
37 "minimum number of entries needed to calculate the mean in the delta distribution of the sagitta",
40 "threshold for the warning related to the sagitta",
43 "threshold for the error related to the sagitta",
46 "threshold for the warning related to the roi",
48 B2DEBUG(20,
"DQMHistAnalysisPXDBow: Constructor done.");
54 B2DEBUG(20,
"DQMHistAnalysisPXDBow: initialized.");
61 for (
VxdID& aVxdID : sensors) {
66 auto buff = (std::string)aVxdID;
67 replace(buff.begin(), buff.end(),
'.',
'_');
74 registerEpicsPV(
"PXD:meanResV:" + buff,
"meanResV:" + (std::string)aVxdID);
75 registerEpicsPV(
"PXD:sigmaResV:" + buff,
"sigmaResV:" + (std::string)aVxdID);
76 registerEpicsPV(
"PXD:sagitta:" + buff,
"sagitta:" + (std::string)aVxdID);
83 B2WARNING(
"No PXDModules in Geometry found!");
87 B2WARNING(
"Invalid moduleName, only empty value or PXD forward modules (eg \"2.2.1\") are acceptable, nameModule parameter set to default (empty)");
91 B2INFO(
"Plotting the histogram for all forward sensors");
93 auto buff = (std::string)aPXDModule;
94 replace(buff.begin(), buff.end(),
'.',
'_');
98 B2INFO(
"Plotting histogram for module " <<
m_moduleName);
100 replace(buff.begin(), buff.end(),
'.',
'_');
109 B2DEBUG(20,
"DQMHistAnalysisPXDBow : beginRun called");
112 pair.second->Clear();
117 if (!roiParams.
isValid()) B2WARNING(
"Cannot get roi parameters, ROI v half size defined as default (0.1 cm)");
118 else m_roiThreshold = roiParams->getSigmaSystV() * roiParams->getNumSigmaTotV() / 2;
124 auto buff = (std::string)aPXDModule;
125 std::replace(buff.begin(), buff.end(),
'.',
'_');
129 if (hS != NULL && hV != NULL) {
130 bool enough =
false, warnflag =
false, errorflag =
false;
131 B2DEBUG(20,
"Histos sagitta" << buff <<
" and resV_" << buff <<
" found");
136 double meanResV = hV->GetMean();
137 double stdResV = hV->GetStdDev();
138 double resV = std::abs(meanResV) + 3 * stdResV;
139 double bowAmplitude = hS->GetMean();
152 plotCanvas(enough, errorflag, warnflag, buff);
154 }
else B2DEBUG(20,
"Histo sagitta/resV_" << buff <<
" not found");
164 m_hResV[buff].SetName((std::string(
"ResV_") + buff).c_str());
165 m_hResV[buff].SetTitle((std::string(
"v residuals ") + buff).c_str());
bool isValid() const
Check whether a valid object was obtained from the database.
Class for accessing objects in the database.
static bool hasDeltaPar(const std::string &dirname, const std::string &histname)
Check if Delta histogram parameters exist for histogram.
int registerEpicsPV(const std::string &pvname, const std::string &keyname="")
EPICS related Functions.
static void addDeltaPar(const std::string &dirname, const std::string &histname, HistDelta::EDeltaType t, int p, unsigned int a=1)
Add Delta histogram parameters.
static void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
TH1 * getDelta(const std::string &fullname, int n=0, bool onlyIfUpdated=true)
Get Delta histogram.
DQMHistAnalysisModule()
Constructor / Destructor.
EStatus
Status flag of histogram/canvas.
static EStatus makeStatus(bool enough, bool warn_flag, bool error_flag)
Helper function to judge the status for coloring and EPICS.
void setEpicsPV(const std::string &keyname, double value)
Write value to a EPICS PV.
float m_statThreshold
Threshold values for statistic flag on the plotted histograms.
void initialize() override final
Initializer.
float m_sagittaThreshold
Threshold values for warning flag on the sagitta.
void event() override final
This method is called for each event.
std::map< std::string, TCanvas * > m_cResV
Data members.
std::vector< VxdID > m_PXDModules
vector for the IDs of all forward PXD Modules to iterate over
std::string m_histogramDirectoryName
Parameters accessible from basf2 scripts.
DQMHistAnalysisPXDBowModule()
Public functions.
std::string m_moduleName
name of the module which distribution will be plotted on the dqm, if empty all forward modules will b...
void beginRun() override final
Called when entering a new run.
std::map< std::string, TH1F > m_hResV
The final histograms.
float m_roiThreshold
Threshold values for warning flag on the resV, the value is related on the dimesion of the ROI.
void plotCanvas(bool enough, bool errorflag, bool warnflag, std::string buff)
Plot the histogram of the module with ID buff and colorize the canvas using the stat,...
float m_sagittaErrorThreshold
Threshold values for error flag on the sagitta.
void setDescription(const std::string &description)
Sets the description of the module.
Class to facilitate easy access to sensor information of the VXD like coordinate transformations or p...
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference to the SensorInfo of a given SensorID.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Base class to provide Sensor Information for PXD and SVD.
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.
Abstract base class for different kinds of events.