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");
51 B2DEBUG(1,
"DQMHistAnalysisPXDEff: Constructor done.");
56 B2DEBUG(99,
"DQMHistAnalysisPXDEffModule: initialized.");
63 for (
VxdID& 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;
307 std::string locationMatches =
"matched_cluster_" + buff;
312 auto Hits =
findHist(locationHits,
true);
313 auto Matches =
findHist(locationMatches,
true);
315 if (Hits ==
nullptr && Matches ==
nullptr)
continue;
317 if (Hits ==
nullptr) Hits =
findHist(locationHits);
318 if (Matches ==
nullptr) Matches =
findHist(locationMatches);
321 if (Hits && Matches) {
324 m_eEffModules[aPXDModule]->SetPassedHistogram(*Matches,
"f");
334 int s = (2 - aPXDModule.getSensorNumber()) *
m_v_bins;
335 int l = (aPXDModule.getLadderNumber() - 1) *
m_u_bins;
336 if (
m_hInnerMap && aPXDModule.getLayerNumber() == 1) {
338 for (
int u = 0; u <
m_u_bins; u++) {
339 for (
int v = 0; v <
m_v_bins; v++) {
340 auto b = h->GetBin(u + 1, v + 1);
341 m_hInnerMap->Fill(u + l, v + s, h->GetBinContent(b));
345 if (
m_hOuterMap && aPXDModule.getLayerNumber() == 2) {
347 for (
int u = 0; u <
m_u_bins; u++) {
348 for (
int v = 0; v <
m_v_bins; v++) {
349 auto b = h->GetBin(u + 1, v + 1);
350 m_hOuterMap->Fill(u + l, v + s, h->GetBinContent(b));
356 B2WARNING(
"only one plot upd " << aPXDModule);
389 bool error_flag =
false;
390 bool warn_flag =
false;
393 double imatch = 0.0, ihit = 0.0;
394 double imatchL1 = 0.0, ihitL1 = 0.0;
395 double imatchL2 = 0.0, ihitL2 = 0.0;
398 std::map <VxdID, bool> updated{};
399 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
406 double nmatch = Combined->GetBinContent(i * 2 + 2);
407 double nhit = Combined->GetBinContent(i * 2 + 1);
422 double var_e = nmatch / nhit;
468 double scale_min = 1.0;
469 for (
int i = 0; i < gr->GetN(); i++) {
470 gr->SetPointEXhigh(i, 0.);
471 gr->SetPointEXlow(i, 0.);
474 gr->GetPoint(i, x, y);
475 gr->SetPoint(i, x - 0.01, y);
476 auto val = y - gr->GetErrorYlow(i);
479 if (scale_min > val) scale_min = val;
482 if (scale_min == 1.0) scale_min = 0.0;
483 if (scale_min > 0.9) scale_min = 0.9;
484 auto ay = gr->GetYaxis();
485 if (ay) ay->SetRangeUser(scale_min, 1.0);
490 gr->SetMarkerStyle(8);
495 static std::map <int, TLatex*> ltmap;
498 tt =
new TLatex(it + 0.5, scale_min, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
499 tt->SetTextSize(0.035);
500 tt->SetTextAngle(90);
501 tt->SetTextAlign(12);
529 auto gr3 = (TGraphAsymmErrors*)
m_eEffAll->GetPaintedGraph()->Clone();
531 for (
int i = 0; i < gr3->GetN(); i++) {
533 gr3->GetPoint(i, x, y);
534 gr3->SetPoint(i, x + 0.2, y);
538 double scale_min = 1.0;
540 for (
int i = 0; i < gr->GetN(); i++) {
541 gr->SetPointEXhigh(i, 0.);
542 gr->SetPointEXlow(i, 0.);
545 gr->GetPoint(i, x, y);
546 gr->SetPoint(i, x - 0.2, y);
547 auto val = y - gr->GetErrorYlow(i);
550 if (scale_min > val) scale_min = val;
553 if (scale_min == 1.0) scale_min = 0.0;
554 if (scale_min > 0.9) scale_min = 0.9;
555 auto ay = gr->GetYaxis();
556 if (ay) ay->SetRangeUser(scale_min, 1.0);
559 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
563 gr->GetPoint(i, x, y);
568 gr->SetLineColor(kBlack);
570 gr->SetMarkerStyle(33);
572 }
else scale_min = 0.0;
573 if (gr3) gr3->Draw(
"P");
576 std::map <int, TLatex*> ltmap;
579 tt =
new TLatex(it + 0.5, scale_min, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
580 tt->SetTextSize(0.035);
581 tt->SetTextAngle(90);
582 tt->SetTextAlign(12);
599 double var_efficiency = ihit > 0 ? imatch / ihit : 0.0;
600 double var_efficiencyL1 = ihitL1 > 0 ? imatchL1 / ihitL1 : 0.0;
601 double var_efficiencyL2 = ihitL2 > 0 ? imatchL2 / ihitL2 : 0.0;
620 B2DEBUG(1,
"DQMHistAnalysisPXDEff: terminate called");
The base class for the histogram analysis module.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
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.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
void UpdateCanvas(std::string name, bool updated=true)
Mark canvas as updated (or not)
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 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.
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.
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
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.