13#include <dqm/analysis/modules/DQMHistAnalysisPXDEff.h>
16#include <TGraphAsymmErrors.h>
17#include <vxd/geometry/GeoCache.h>
40 addParam(
"binsU",
m_u_bins,
"histogram bins in u direction, needs to be the same as in PXDDQMEfficiency",
int(16));
41 addParam(
"binsV",
m_v_bins,
"histogram bins in v direction, needs to be the same as in PXDDQMEfficiency",
int(48));
43 std::string(
"PXDEFF"));
50 addParam(
"excluded",
m_excluded,
"the list of excluded modules, indices from 0 to 39", std::vector<int>());
51 B2DEBUG(1,
"DQMHistAnalysisPXDEff: Constructor done.");
56 B2DEBUG(99,
"DQMHistAnalysisPXDEffModule: initialized.");
63 for (
const auto& aVxdID : sensors) {
76 B2WARNING(
"No PXDModules in Geometry found! Use hard-coded setup.");
77 std::vector <string> mod = {
78 "1.1.1",
"1.1.2",
"1.2.1",
"1.2.2",
"1.3.1",
"1.3.2",
"1.4.1",
"1.4.2",
79 "1.5.1",
"1.5.2",
"1.6.1",
"1.6.2",
"1.7.1",
"1.7.2",
"1.8.1",
"1.8.2",
80 "2.1.1",
"2.1.2",
"2.2.1",
"2.2.2",
"2.3.1",
"2.3.2",
"2.4.1",
"2.4.2",
81 "2.5.1",
"2.5.2",
"2.6.1",
"2.6.2",
"2.7.1",
"2.7.2",
"2.8.1",
"2.8.2",
82 "2.9.1",
"2.9.2",
"2.10.1",
"2.10.2",
"2.11.1",
"2.11.2",
"2.12.1",
"2.12.2"
94 auto buff = (std::string)aPXDModule;
95 replace(buff.begin(), buff.end(),
'.',
'_');
98 TString histTitle =
"PXD Hit Efficiency on Module " + (std::string)aPXDModule +
";Pixel in U;Pixel in V";
100 m_eEffModules[aPXDModule] =
new TEfficiency((
"ePXDHitEff_" + buff).c_str(), histTitle,
112 for (
int i = 0; i < (int)
m_nrxbins; i++) {
134 m_eEffAllUpdate =
new TEfficiency(
"ePXDHitEffAllUpdate",
"PXD Integral and last-updated Efficiency per module;PXD Module;",
148 B2DEBUG(1,
"DQMHistAnalysisPXDEff: initialized.");
154 B2DEBUG(1,
"DQMHistAnalysisPXDEff: beginRun called.");
162 if (single_cmap.second) single_cmap.second->Clear();
183 double dummy, loerr = 0, lowarn = 0;
193 double dummy, loerr = 0, lowarn = 0;
233 if (nhit < minentries) {
254 bool warn_flag = (
m_eEffAll->GetEfficiency(bin) +
m_eEffAll->GetEfficiencyErrorUp(bin) <
265 bool error_flag = (
m_eEffAll->GetEfficiency(bin) +
m_eEffAll->GetEfficiencyErrorUp(bin) <
277 auto ax = gr->GetXaxis();
280 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
282 ax->SetBinLabel(i + 1, ModuleName);
298 bool updateinner =
false, updateouter =
false;
300 auto buff = (std::string)aPXDModule;
301 replace(buff.begin(), buff.end(),
'.',
'_');
303 std::string locationHits =
"track_hits_" + buff;
304 std::string locationMatches =
"matched_cluster_" + buff;
309 if (Hits ==
nullptr && Matches ==
nullptr)
continue;
315 if (Hits && Matches) {
318 m_eEffModules[aPXDModule]->SetPassedHistogram(*Matches,
"f");
328 int s = (2 - aPXDModule.getSensorNumber()) *
m_v_bins;
329 int l = (aPXDModule.getLadderNumber() - 1) *
m_u_bins;
330 if (
m_hInnerMap && aPXDModule.getLayerNumber() == 1) {
332 for (
int u = 0; u <
m_u_bins; u++) {
333 for (
int v = 0; v <
m_v_bins; v++) {
334 auto b = h->GetBin(u + 1, v + 1);
335 m_hInnerMap->Fill(u + l, v + s, h->GetBinContent(b));
339 if (
m_hOuterMap && aPXDModule.getLayerNumber() == 2) {
341 for (
int u = 0; u <
m_u_bins; u++) {
342 for (
int v = 0; v <
m_v_bins; v++) {
343 auto b = h->GetBin(u + 1, v + 1);
344 m_hOuterMap->Fill(u + l, v + s, h->GetBinContent(b));
350 B2WARNING(
"only one plot upd " << aPXDModule);
383 bool error_flag =
false;
384 bool warn_flag =
false;
387 double imatch = 0.0, ihit = 0.0;
388 double imatchL1 = 0.0, ihitL1 = 0.0;
389 double imatchL2 = 0.0, ihitL2 = 0.0;
392 std::map <VxdID, bool> updated{};
393 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
400 double nmatch = Combined->GetBinContent(i * 2 + 2);
401 double nhit = Combined->GetBinContent(i * 2 + 1);
416 double var_e = nmatch / nhit;
462 double scale_min = 1.0;
463 for (
int i = 0; i < gr->GetN(); i++) {
464 gr->SetPointEXhigh(i, 0.);
465 gr->SetPointEXlow(i, 0.);
468 gr->GetPoint(i, x, y);
469 gr->SetPoint(i, x - 0.01, y);
470 auto val = y - gr->GetErrorYlow(i);
473 if (scale_min > val) scale_min = val;
476 if (scale_min == 1.0) scale_min = 0.0;
477 if (scale_min > 0.9) scale_min = 0.9;
478 auto ay = gr->GetYaxis();
479 if (ay) ay->SetRangeUser(scale_min, 1.0);
484 gr->SetMarkerStyle(8);
489 static std::map <int, TLatex*> ltmap;
492 tt =
new TLatex(it + 0.5, scale_min, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
493 tt->SetTextSize(0.035);
494 tt->SetTextAngle(90);
495 tt->SetTextAlign(12);
524 auto gr3 =
dynamic_cast<TGraphAsymmErrors*
>(
m_eEffAll->GetPaintedGraph());
526 for (
int i = 0; i < gr3->GetN(); i++) {
528 gr3->GetPoint(i, x, y);
529 gr3->SetPoint(i, x + 0.2, y);
533 double scale_min = 1.0;
535 for (
int i = 0; i < gr->GetN(); i++) {
536 gr->SetPointEXhigh(i, 0.);
537 gr->SetPointEXlow(i, 0.);
540 gr->GetPoint(i, x, y);
541 gr->SetPoint(i, x - 0.2, y);
542 auto val = y - gr->GetErrorYlow(i);
545 if (scale_min > val) scale_min = val;
548 if (scale_min == 1.0) scale_min = 0.0;
549 if (scale_min > 0.9) scale_min = 0.9;
550 auto ay = gr->GetYaxis();
551 if (ay) ay->SetRangeUser(scale_min, 1.0);
554 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
558 gr->GetPoint(i, x, y);
563 gr->SetLineColor(kBlack);
565 gr->SetMarkerStyle(33);
567 }
else scale_min = 0.0;
568 if (gr3) gr3->Draw(
"P");
571 static std::map <int, TLatex*> ltmap;
574 tt =
new TLatex(it + 0.5, scale_min, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
575 tt->SetTextSize(0.035);
576 tt->SetTextAngle(90);
577 tt->SetTextAlign(12);
595 double var_efficiency = ihit > 0 ? imatch / ihit : 0.0;
596 double var_efficiencyL1 = ihitL1 > 0 ? imatchL1 / ihitL1 : 0.0;
597 double var_efficiencyL2 = ihitL2 > 0 ? imatchL2 / ihitL2 : 0.0;
599 m_monObj->setVariable(
"efficiency", var_efficiency);
600 m_monObj->setVariable(
"efficiencyL1", var_efficiencyL1);
601 m_monObj->setVariable(
"efficiencyL2", var_efficiencyL2);
602 m_monObj->setVariable(
"nmodules", ieff);
616 B2DEBUG(1,
"DQMHistAnalysisPXDEff: terminate called");
int registerEpicsPV(const std::string &pvname, const std::string &keyname="")
EPICS related Functions.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
static void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
static void UpdateCanvas(const std::string &name, bool updated=true)
Mark canvas as updated (or not)
DQMHistAnalysisModule()
Constructor / Destructor.
EStatus
Status flag of histogram/canvas.
@ c_StatusTooFew
Not enough entries/event to judge.
static EStatus makeStatus(bool enough, bool warn_flag, bool error_flag)
Helper function to judge the status for coloring and EPICS.
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.
void setEpicsPV(const std::string &keyname, double value)
Write value to a EPICS PV.
static TH1 * findHist(const std::string &dirname, const std::string &histname="", bool onlyIfUpdated=false)
Find histogram.
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 interval.
std::map< VxdID, TEfficiency * > m_eEffModules
Individual efficiency for each module, 2d histogram.
bool m_perModuleAlarm
use alarm level per module
TCanvas * m_cEffAll
Final Canvas.
std::map< VxdID, TCanvas * > m_cEffModules
Individual efficiency for each module, canvas.
void initialize(void) override final
Initializer.
int m_nrxbins
Number of bins in efficiency plot, all modules plus layer and summary.
int m_u_bins
u binning for 2d plots
TH1 * m_hEffAllLastTotal
TH1, last state, total.
TH1 * m_hEffAllLastPassed
TH1, last state, passed.
TH2F * m_hOuterMap
Full Eff Map Outer Layer.
bool check_warn_level(int bin, const std::string &name)
Check bin/name for warn condition.
void setLabels(TGraphAsymmErrors *gr)
Set module labels for TGraphAsymmErrors.
TEfficiency * m_eEffAll
One bin for each module in the geometry.
MonitoringObject * m_monObj
Monitoring Object.
bool check_error_level(int bin, const std::string &name)
Check bin/name for error condition.
std::vector< VxdID > m_PXDModules
IDs of all PXD Modules to iterate over.
DQMHistAnalysisPXDEffModule()
Constructor.
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
std::map< std::string, double > m_warnlevelmod
warn level for alarm per module
TEfficiency * m_eEffAllUpdate
Efficiency, last state, updated.
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< std::string, double > m_errorlevelmod
error level for alarm per module
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
bool updateEffBins(int bin, int nhit, int nmatch, int minentries)
Update bin in efficiency plots with condition on nhits.
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.
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.
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.