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"));
51 addParam(
"excluded",
m_excluded,
"the list of excluded modules, indices from 0 to 39");
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_eEffModules[aPXDModule] =
new TEfficiency((
"ePXDHitEff_" + buff).c_str(), histTitle,
117 for (
int i = 0; i < (int)
m_nrxbins; i++) {
139 m_eEffAllUpdate =
new TEfficiency(
"ePXDHitEffAllUpdate",
"PXD Integral and last-updated Efficiency per module;PXD Module;",
153 B2DEBUG(1,
"DQMHistAnalysisPXDEff: initialized.");
159 B2DEBUG(1,
"DQMHistAnalysisPXDEff: beginRun called.");
167 if (single_cmap.second) single_cmap.second->Clear();
188 double dummy, loerr = 0, lowarn = 0;
198 double dummy, loerr = 0, lowarn = 0;
238 if (nhit < minentries) {
259 bool warn_flag = (
m_eEffAll->GetEfficiency(bin) +
m_eEffAll->GetEfficiencyErrorUp(bin) <
270 bool error_flag = (
m_eEffAll->GetEfficiency(bin) +
m_eEffAll->GetEfficiencyErrorUp(bin) <
282 auto ax = gr->GetXaxis();
285 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
287 ax->SetBinLabel(i + 1, ModuleName);
303 bool updateinner =
false, updateouter =
false;
305 auto buff = (std::string)aPXDModule;
306 replace(buff.begin(), buff.end(),
'.',
'_');
308 std::string locationHits =
"track_hits_" + buff;
312 std::string locationMatches =
"matched_cluster_" + buff;
317 auto Hits = (TH1*)
findHist(locationHits,
true);
318 auto Matches = (TH1*)
findHist(locationMatches,
true);
320 if (Hits ==
nullptr && Matches ==
nullptr)
continue;
322 if (Hits ==
nullptr) Hits = (TH1*)
findHist(locationHits);
323 if (Matches ==
nullptr) Matches = (TH1*)
findHist(locationMatches);
326 if (Hits && Matches) {
329 m_eEffModules[aPXDModule]->SetPassedHistogram(*Matches,
"f");
339 int s = (2 - aPXDModule.getSensorNumber()) *
m_v_bins;
340 int l = (aPXDModule.getLadderNumber() - 1) *
m_u_bins;
341 if (
m_hInnerMap && aPXDModule.getLayerNumber() == 1) {
343 for (
int u = 0; u <
m_u_bins; u++) {
344 for (
int v = 0; v <
m_v_bins; v++) {
345 auto b = h->GetBin(u + 1, v + 1);
346 m_hInnerMap->Fill(u + l, v + s, h->GetBinContent(b));
350 if (
m_hOuterMap && aPXDModule.getLayerNumber() == 2) {
352 for (
int u = 0; u <
m_u_bins; u++) {
353 for (
int v = 0; v <
m_v_bins; v++) {
354 auto b = h->GetBin(u + 1, v + 1);
355 m_hOuterMap->Fill(u + l, v + s, h->GetBinContent(b));
361 B2WARNING(
"only one plot upd " << aPXDModule);
394 bool error_flag =
false;
395 bool warn_flag =
false;
398 double imatch = 0.0, ihit = 0.0;
399 double imatchL1 = 0.0, ihitL1 = 0.0;
400 double imatchL2 = 0.0, ihitL2 = 0.0;
403 std::map <VxdID, bool> updated{};
404 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
411 double nmatch = Combined->GetBinContent(i * 2 + 2);
412 double nhit = Combined->GetBinContent(i * 2 + 1);
427 double var_e = nmatch / nhit;
473 double scale_min = 1.0;
474 for (
int i = 0; i < gr->GetN(); i++) {
475 gr->SetPointEXhigh(i, 0.);
476 gr->SetPointEXlow(i, 0.);
479 gr->GetPoint(i, x, y);
480 gr->SetPoint(i, x - 0.01, y);
481 auto val = y - gr->GetErrorYlow(i);
484 if (scale_min > val) scale_min = val;
487 if (scale_min == 1.0) scale_min = 0.0;
488 if (scale_min > 0.9) scale_min = 0.9;
489 auto ay = gr->GetYaxis();
490 if (ay) ay->SetRangeUser(scale_min, 1.0);
495 gr->SetMarkerStyle(8);
500 auto tt =
new TLatex(it + 0.5, scale_min, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
501 tt->SetTextSize(0.035);
502 tt->SetTextAngle(90);
503 tt->SetTextAlign(12);
527 auto gr3 = (TGraphAsymmErrors*)
m_eEffAll->GetPaintedGraph()->Clone();
529 for (
int i = 0; i < gr3->GetN(); i++) {
531 gr3->GetPoint(i, x, y);
532 gr3->SetPoint(i, x + 0.2, y);
536 double scale_min = 1.0;
538 for (
int i = 0; i < gr->GetN(); i++) {
539 gr->SetPointEXhigh(i, 0.);
540 gr->SetPointEXlow(i, 0.);
543 gr->GetPoint(i, x, y);
544 gr->SetPoint(i, x - 0.2, y);
545 auto val = y - gr->GetErrorYlow(i);
548 if (scale_min > val) scale_min = val;
551 if (scale_min == 1.0) scale_min = 0.0;
552 if (scale_min > 0.9) scale_min = 0.9;
553 auto ay = gr->GetYaxis();
554 if (ay) ay->SetRangeUser(scale_min, 1.0);
557 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
561 gr->GetPoint(i, x, y);
566 gr->SetLineColor(kBlack);
568 gr->SetMarkerStyle(33);
570 }
else scale_min = 0.0;
571 if (gr3) gr3->Draw(
"P");
574 auto 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);
591 double var_efficiency = ihit > 0 ? imatch / ihit : 0.0;
592 double var_efficiencyL1 = ihitL1 > 0 ? imatchL1 / ihitL1 : 0.0;
593 double var_efficiencyL2 = ihitL2 > 0 ? imatchL2 / ihitL2 : 0.0;
612 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.
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).
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
EStatus
Status flag of histogram/canvas.
@ c_StatusTooFew
Not enough entries/event to judge.
EStatus makeStatus(bool enough, bool warn_flag, bool error_flag)
Helper function to judge the status for coloring and EPICS.
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, TEfficiency * > m_eEffModules
Individual efficiency for each module, 2d histogram.
~DQMHistAnalysisPXDEffModule()
Destructor.
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.
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_warn_level(int bin, std::string name)
Check bin/name for warn condition.
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
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
bool check_error_level(int bin, std::string name)
Check bin/name for error condition.
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.
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.