14 #include <dqm/analysis/modules/DQMHistAnalysisPXDEff.h>
17 #include <TGraphAsymmErrors.h>
18 #include <vxd/geometry/GeoCache.h>
41 addParam(
"binsU",
m_u_bins,
"histogram bins in u direction, needs to be the same as in PXDDQMEfficiency",
int(16));
42 addParam(
"binsV",
m_v_bins,
"histogram bins in v direction, needs to be the same as in PXDDQMEfficiency",
int(48));
44 std::string(
"PXDEFF"));
52 B2DEBUG(1,
"DQMHistAnalysisPXDEff: Constructor done.");
61 B2DEBUG(99,
"DQMHistAnalysisPXDEffModule: initialized.");
68 for (
VxdID& aVxdID : sensors) {
81 B2WARNING(
"No PXDModules in Geometry found! Use hard-coded setup.");
82 std::vector <string> mod = {
83 "1.1.1",
"1.1.2",
"1.2.1",
"1.2.2",
"1.3.1",
"1.3.2",
"1.4.1",
"1.4.2",
84 "1.5.1",
"1.5.2",
"1.6.1",
"1.6.2",
"1.7.1",
"1.7.2",
"1.8.1",
"1.8.2",
85 "2.1.1",
"2.1.2",
"2.2.1",
"2.2.2",
"2.3.1",
"2.3.2",
"2.4.1",
"2.4.2",
86 "2.5.1",
"2.5.2",
"2.6.1",
"2.6.2",
"2.7.1",
"2.7.2",
"2.8.1",
"2.8.2",
87 "2.9.1",
"2.9.2",
"2.10.1",
"2.10.2",
"2.11.1",
"2.11.2",
"2.12.1",
"2.12.2"
99 auto buff = (std::string)aPXDModule;
100 replace(buff.begin(), buff.end(),
'.',
'_');
103 TString histTitle =
"PXD Hit Efficiency on Module " + (std::string)aPXDModule +
";Pixel in U;Pixel in V";
105 m_hEffModules[aPXDModule] =
new TEfficiency((
"ePXDHitEff_" + buff).c_str(), histTitle,
129 m_hEffAll =
new TEfficiency(
"ePXDHitEffAll",
"PXD Integrated Efficiency of each module;PXD Module;",
140 auto ax = gr->GetXaxis();
143 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
145 ax->SetBinLabel(i + 1, ModuleName);
152 m_hEffAllUpdate =
new TEfficiency(
"ePXDHitEffAllUpdate",
"PXD Integral and last-updated Efficiency per module;PXD Module;",
160 auto ax = gr->GetXaxis();
163 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
165 ax->SetBinLabel(i + 1, ModuleName);
176 B2DEBUG(1,
"DQMHistAnalysisPXDEff: initialized.");
182 B2DEBUG(1,
"DQMHistAnalysisPXDEff: beginRun called.");
188 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
200 double dummy, loerr = 0, lowarn = 0;
214 if (single_cmap.second) single_cmap.second->Clear();
228 for (
unsigned int i = 1; i <=
m_PXDModules.size(); i++) {
231 TString buff = (std::string)aPXDModule;
232 buff.ReplaceAll(
".",
"_");
235 TString locationHits =
"track_hits_" + buff;
239 Hits = (TH1*)
findHist(locationHits.Data());
240 TString locationMatches =
"matched_cluster_" + buff;
244 Matches = (TH1*)
findHist(locationMatches.Data());
247 if (Hits ==
nullptr || Matches ==
nullptr) {
248 B2ERROR(
"Missing histogram for sensor " << aPXDModule);
252 m_hEffModules[aPXDModule]->SetPassedHistogram(*Matches,
"f");
260 int s = (2 - aPXDModule.getSensorNumber()) *
m_v_bins;
261 int l = (aPXDModule.getLadderNumber() - 1) *
m_u_bins;
262 if (
m_hInnerMap && aPXDModule.getLayerNumber() == 1) {
263 for (
int u = 0; u <
m_u_bins; u++) {
264 for (
int v = 0; v <
m_v_bins; v++) {
265 auto b = h->GetBin(u + 1, v + 1);
266 m_hInnerMap->Fill(u + l, v + s, h->GetBinContent(b));
270 if (
m_hOuterMap && aPXDModule.getLayerNumber() == 2) {
271 for (
int u = 0; u <
m_u_bins; u++) {
272 for (
int v = 0; v <
m_v_bins; v++) {
273 auto b = h->GetBin(u + 1, v + 1);
274 m_hOuterMap->Fill(u + l, v + s, h->GetBinContent(b));
296 TString locationHits =
"PXD_Eff_combined";
300 TH1* Combined = (TH1*)
findHist(locationHits.Data());
302 double stat_data = 0;
303 bool error_flag =
false;
304 bool warn_flag =
false;
307 double imatch = 0.0, ihit = 0.0;
310 std::map <VxdID, bool> updated{};
311 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
314 if (Combined ==
nullptr) {
319 double nmatch = Combined->GetBinContent(i * 2 + 2);
320 double nhit = Combined->GetBinContent(i * 2 + 1);
321 if (nmatch > 10 && nhit > 10) {
325 double var_e = nmatch / nhit;
346 updated[aModule] =
true;
353 updated[aModule] =
true;
385 double scale_min = 1.0;
386 for (
int i = 0; i < gr->GetN(); i++) {
387 gr->SetPointEXhigh(i, 0.);
388 gr->SetPointEXlow(i, 0.);
391 gr->GetPoint(i, x, y);
392 gr->SetPoint(i, x - 0.01, y);
393 auto val = y - gr->GetErrorYlow(i);
396 if (scale_min > val) scale_min = val;
399 if (scale_min == 1.0) scale_min = 0.0;
400 if (scale_min > 0.9) scale_min = 0.9;
403 auto ay = gr->GetYaxis();
404 if (ay) ay->SetRangeUser(scale_min, 1.0);
405 auto ax = gr->GetXaxis();
408 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
410 ax->SetBinLabel(i + 1, ModuleName);
416 gr->SetMarkerStyle(8);
421 auto tt =
new TLatex(it + 0.5, scale_min, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
422 tt->SetTextAngle(90);
423 tt->SetTextAlign(12);
432 }
else if (warn_flag) {
440 m_cEffAll->Pad()->SetFrameFillColor(kWhite - 1);
441 m_cEffAll->Pad()->SetFrameFillStyle(1001);
460 auto gr3 = (TGraphAsymmErrors*)
m_hEffAll->GetPaintedGraph()->Clone();
462 for (
int i = 0; i < gr3->GetN(); i++) {
464 gr3->GetPoint(i, x, y);
465 gr3->SetPoint(i, x + 0.2, y);
469 double scale_min = 1.0;
471 for (
int i = 0; i < gr->GetN(); i++) {
472 gr->SetPointEXhigh(i, 0.);
473 gr->SetPointEXlow(i, 0.);
476 gr->GetPoint(i, x, y);
477 gr->SetPoint(i, x - 0.2, y);
478 auto val = y - gr->GetErrorYlow(i);
481 if (scale_min > val) scale_min = val;
484 if (scale_min == 1.0) scale_min = 0.0;
485 if (scale_min > 0.9) scale_min = 0.9;
488 auto ay = gr->GetYaxis();
489 if (ay) ay->SetRangeUser(scale_min, 1.0);
490 auto ax = gr->GetXaxis();
493 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
495 ax->SetBinLabel(i + 1, ModuleName);
498 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
502 gr->GetPoint(i, x, y);
507 gr->SetLineColor(kBlack);
509 gr->SetMarkerStyle(33);
511 }
else scale_min = 0.0;
512 if (gr3) gr3->Draw(
"P");
515 auto tt =
new TLatex(it + 0.5, scale_min, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
516 tt->SetTextSize(0.035);
517 tt->SetTextAngle(90);
518 tt->SetTextAlign(12);
529 }
else if (warn_flag) {
551 double var_efficiency = ihit > 0 ? imatch / ihit : 0.0;
557 if (stat_data != 0)
setEpicsPV(
"Overall", var_efficiency);
562 B2DEBUG(1,
"DQMHistAnalysisPXDEff: terminate called");
The base class for the histogram analysis module.
int registerEpicsPV(std::string pvname, std::string keyname="", bool update_pvs=true)
EPICS related Functions.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
void UpdateCanvas(std::string name, bool updated=true)
Mark canvas as updated (or not)
static MonitoringObject * getMonitoringObject(const std::string &histname)
Get MonitoringObject with given name (new object is created if non-existing)
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.
TCanvas * m_cOuterMap
Full Eff Map Outer Layer.
TCanvas * m_cInnerMap
Full Eff Map Inner Layer.
void terminate(void) override final
This method is called at the end of the event processing.
int m_minEntries
Update entry intervall.
std::map< VxdID, double > m_warnlevelmod
warn level for alarm per module
~DQMHistAnalysisPXDEffModule()
Destructor.
bool m_perModuleAlarm
use alarm level per module
TCanvas * m_cEffAll
Final Canvas.
TEfficiency * m_hEffAll
One bin for each module in the geometry.
std::map< VxdID, TCanvas * > m_cEffModules
Individual efficiency for each module, canvas.
void initialize(void) override final
Initializer.
TEfficiency * m_hEffAllUpdate
Efficiency, last state, updated.
int m_u_bins
u binning for 2d plots
std::map< VxdID, double > m_errorlevelmod
error level for alarm per module
TH1 * m_hEffAllLastTotal
TH1, last state, total.
TH1 * m_hEffAllLastPassed
TH1, last state, passed.
TH2F * m_hOuterMap
Full Eff Map Outer Layer.
MonitoringObject * m_monObj
Monitoring Object.
std::vector< VxdID > m_PXDModules
IDs of all PXD Modules to iterate over.
std::string m_histogramDirectoryName
name of histogram directory
TCanvas * m_cEffAllUpdate
Final Canvas for Update.
TH2F * m_hInnerMap
Full Eff Map Inner Layer.
double m_confidence
confidence level for error bars
int m_v_bins
v binning for 2d plots
TH1F * m_hWarnLine
TLine object for warning limit.
double m_errorlevel
error level for alarm
std::map< VxdID, TEfficiency * > m_hEffModules
Individual efficiency for each module, 2d histogram.
TH1F * m_hErrorLine
TLine object for error error.
std::vector< int > m_excluded
Indizes of excluded PXD Modules.
bool m_alarmAdhoc
generate alarm from adhoc values
double m_warnlevel
warn level for alarm
void beginRun(void) override final
Called when entering a new run.
void event(void) override final
This method is called for each event.
void setDescription(const std::string &description)
Sets the description of the module.
void setVariable(const std::string &var, float val, float upErr=-1., float dwErr=-1)
set value to float variable (new variable is made if not yet existing)
void addCanvas(TCanvas *canv)
Add Canvas to monitoring object.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne 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.
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.
baseType getSensorNumber() const
Get the sensor id.
baseType getLadderNumber() const
Get the ladder id.
baseType getLayerNumber() const
Get the layer id.
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.