14#include <dqm/analysis/modules/DQMHistAnalysisSVDEfficiency.h>
15#include <vxd/geometry/GeoCache.h>
40 B2DEBUG(10,
"DQMHistAnalysisSVDEfficiency: Constructor done.");
42 setDescription(
"DQM Analysis Module that computes the average SVD sensor efficiency.");
44 addParam(
"RefHistoFile",
m_refFileName,
"Reference histogram file name", std::string(
"SVDrefHisto.root"));
45 addParam(
"effLevel_Error",
m_effError,
"Efficiency error (%) level (red)",
double(0.9));
46 addParam(
"effLevel_Warning",
m_effWarning,
"Efficiency WARNING (%) level (orange)",
double(0.94));
47 addParam(
"statThreshold",
m_statThreshold,
"minimal number of tracks per sensor to set green/red alert",
double(100));
48 addParam(
"samples3",
m_3Samples,
"if True 3 samples histograms analysis is performed",
bool(
false));
51 "If true you can set the range of the efficiency histogram with 'efficiencyMax' and 'efficiencyMin' parameters.",
62 B2DEBUG(10,
"DQMHistAnalysisSVDEfficiency: initialize");
65 m_legProblem =
new TPaveText(0.62, 0.22, 0.88, 0.35,
"brNDC");
72 m_legWarning =
new TPaveText(0.62, 0.22, 0.88, 0.35,
"brNDC");
79 m_legNormal =
new TPaveText(0.62, 0.22, 0.88, 0.35,
"brNDC");
85 m_legEmpty =
new TPaveText(0.62, 0.22, 0.88, 0.35,
"brNDC");
87 m_legEmpty->AddText(
"check again in a few minutes");
97 for (
VxdID& aVxdID : sensors) {
138 "Summary of SVD efficiencies (%), @view/@side Side for 3 samples");
145 "Summary of SVD efficiencies errors (%), @view/@side Side for 3 samples");
153 TH1* hnEvnts =
findHist(
"SVDExpReco/SVDDQM_nEvents");
154 if (hnEvnts == NULL) {
155 B2INFO(
"no events, nothing to do here");
160 std::tuple<std::vector<TText*>, std::vector<TText*>> moduleNumbers =
textModuleNumbers();
165 m_ly =
new TLine(0, 0, 0, 210);
166 m_ly->SetLineStyle(kDashed);
167 m_ly->SetLineWidth(2);
169 m_lx =
new TLine(0, 0, 210, 0);
170 m_lx->SetLineStyle(kDashed);
171 m_lx->SetLineWidth(2);
173 m_arrowy =
new TArrow(0, 0, 0, 10, 0.01,
"|>");
178 m_arrowx =
new TArrow(0, 0, 10, 0, 0.01,
"|>");
187 B2DEBUG(10,
"DQMHistAnalysisSVDEfficiency: beginRun called.");
228 double effErrorLo = 0.;
229 double effWarnLo = 0.;
233 B2DEBUG(10,
" SVD efficiency thresholds taken from EPICS configuration file:");
234 B2DEBUG(10,
" EFFICIENCY: normal > " <<
m_effWarning <<
" > warning > " <<
m_effError <<
" > error with minimum statistics of " <<
240 B2DEBUG(10,
"DQMHistAnalysisSVDEfficiency: event called.");
243 TH1* hnEvnts =
findHist(
"SVDExpReco/SVDDQM_nEvents",
true);
244 if (hnEvnts == NULL) {
245 B2INFO(
"no events, nothing to do here");
248 B2DEBUG(10,
"SVDExpReco/SVDDQM_nEvents found");
251 TString tmp = hnEvnts->GetTitle();
252 Int_t pos = tmp.Last(
'~');
253 if (pos == -1) pos = 0;
255 TString runID = tmp(pos, tmp.Length() - pos);
256 B2INFO(
"DQMHistAnalysisSVDEfficiencyModule::runID = " << runID);
258 gStyle->SetOptStat(0);
259 gStyle->SetPaintTextFormat(
"2.1f");
287 Float_t erreffU = -1;
288 Float_t erreffV = -1;
291 TH2F* found_tracksU = (TH2F*)
findHist(
"SVDEfficiency/TrackHitsU");
292 TH2F* matched_clusU = (TH2F*)
findHist(
"SVDEfficiency/MatchedHitsU");
294 TH2F* found_tracksV = (TH2F*)
findHist(
"SVDEfficiency/TrackHitsV");
295 TH2F* matched_clusV = (TH2F*)
findHist(
"SVDEfficiency/MatchedHitsV");
297 if (matched_clusU != NULL && found_tracksU != NULL && matched_clusV != NULL && found_tracksV != NULL) {
298 B2DEBUG(10,
"Before loop on sensors, size :" <<
m_SVDModules.size());
301 for (
unsigned int i = 0; i <
m_SVDModules.size(); i++) {
306 float numU = matched_clusU->GetBinContent(bin);
307 float denU = found_tracksU->GetBinContent(bin);
310 B2DEBUG(10,
"effU = " << numU <<
"/" << denU <<
" = " << effU);
313 erreffU = std::sqrt(effU * (1 - effU) / denU);
316 float numV = matched_clusV->GetBinContent(bin);
317 float denV = found_tracksV->GetBinContent(bin);
320 B2DEBUG(10,
"effV = " << numV <<
"/" << denV <<
" = " << effV);
323 erreffV = std::sqrt(effV * (1 - effV) / denV);
349 if (matched_clusU == NULL || found_tracksU == NULL) {
350 B2INFO(
"Histograms needed for U-side Efficiency computation are not found");
366 if (matched_clusV == NULL || found_tracksV == NULL) {
367 B2INFO(
"Histograms needed for V-side Efficiency computation are not found");
479 TH2F* found3_tracksU = (TH2F*)
findHist(
"SVDEfficiency/TrackHits3U");
480 TH2F* matched3_clusU = (TH2F*)
findHist(
"SVDEfficiency/MatchedHits3U");
482 TH2F* found3_tracksV = (TH2F*)
findHist(
"SVDEfficiency/TrackHits3V");
483 TH2F* matched3_clusV = (TH2F*)
findHist(
"SVDEfficiency/MatchedHits3V");
485 if (matched3_clusU != NULL && found3_tracksU != NULL && matched3_clusV != NULL && found3_tracksV != NULL) {
486 B2DEBUG(10,
"Before loop on sensors, size :" <<
m_SVDModules.size());
489 for (
unsigned int i = 0; i <
m_SVDModules.size(); i++) {
494 float numU = matched3_clusU->GetBinContent(bin);
495 float denU = found3_tracksU->GetBinContent(bin);
498 B2DEBUG(10,
"effU = " << numU <<
"/" << denU <<
" = " << effU);
501 erreffU = std::sqrt(effU * (1 - effU) / denU);
504 float numV = matched3_clusV->GetBinContent(bin);
505 float denV = found3_tracksV->GetBinContent(bin);
508 B2DEBUG(10,
"effV = " << numV <<
"/" << denV <<
" = " << effV);
511 erreffV = std::sqrt(effV * (1 - effV) / denV);
538 if (matched3_clusU == NULL || found3_tracksU == NULL) {
539 B2INFO(
"Histograms needed for Efficiency computation are not found");
555 if (matched3_clusV == NULL || found3_tracksV == NULL) {
556 B2INFO(
"Histograms needed for Efficiency computation are not found");
662 B2DEBUG(10,
"DQMHistAnalysisSVDEfficiency: endRun called");
667 B2DEBUG(10,
"DQMHistAnalysisSVDEfficiency: terminate called");
716 return 2 + 1 + sensor;
718 return 6 + 1 + sensor;
720 return 11 + 1 + sensor;
727 std::vector<TText*> ladders;
728 std::vector<TText*> sensors;
730 const double rLayer[4] = {40, 70, 110, 160};
731 const double nLadders[4] = {7, 10, 12, 16};
732 const double nSensors[4] = {2, 3, 4, 5};
733 const double position[4] = {0.8, 1.2, 1., 0.8};
734 const double delta[4] = {9, 8, 8, 8};
735 const double inclination[4] = {-17, -5, -13, -12};
737 double pi = TMath::Pi();
739 for (
int layer = 0; layer < 4; layer ++) {
740 for (
int ladder = 1; ladder <= nLadders[layer]; ladder++) {
741 double deltaText = delta[layer] + position[layer];
742 double r = rLayer[layer] + (deltaText) * nSensors[layer];
743 double phi = 2 * pi / nLadders[layer];
744 double dphiThisPoint = (ladder - 1) * phi - phi / 2 + inclination[layer] * pi / 180.;
745 double dphiNextPoint = dphiThisPoint + phi;
746 double minX = r * TMath::Cos(dphiThisPoint);
747 double maxX = (r + deltaText) * TMath::Cos(dphiNextPoint);
748 double minY = r * TMath::Sin(dphiThisPoint);
749 double maxY = (r + deltaText) * TMath::Sin(dphiNextPoint);
751 double xcen = (minX + maxX) / 2.;
752 double ycen = (minY + maxY) / 2.;
754 double angle = TMath::ATan2(ycen, xcen) * 180. / TMath::Pi() - 90.;
755 if (ycen < 0) angle = TMath::ATan2(ycen, xcen) * 180. / TMath::Pi() + 90;
757 TText* t =
new TText(xcen, ycen, Form(
"%d.%d", layer + 3, ladder));
759 t->SetTextAngle(angle);
760 t->SetTextSize(0.025);
762 ladders.push_back(t);
764 for (
int sensor = 1; sensor <= nSensors[layer]; sensor++) {
765 if ((layer == 0 && ladder == 4) || (layer == 1 && ladder == 5) || (layer == 2 && ladder == 6) || (layer == 3 && ladder == 7)) {
766 double rs = rLayer[layer] + (delta[layer]) * (sensor - 1);
767 double xcens = rs * TMath::Cos(dphiThisPoint);
768 double ycens = rs * TMath::Sin(dphiThisPoint);
770 double angles = TMath::ATan2(ycens, xcens) * 180. / pi - 90.;
771 if (ycen < 0) angles = TMath::ATan2(ycens, xcens) * 180. / pi + 90;
773 TText* ts =
new TText(xcens, ycens, Form(
"%d ", sensor));
774 ts->SetTextAlign(31);
775 ts->SetTextAngle(angles);
776 ts->SetTextSize(0.018);
778 sensors.push_back(ts);
784 return std::make_tuple(ladders, sensors);
821 B2INFO(
"efficiency status not set properly: " << status);
The base class for the histogram analysis module.
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).
@ c_ColorDefault
default for non-coloring
@ c_StatusDefault
default for non-coloring
@ c_StatusTooFew
Not enough entries/event to judge.
@ c_StatusError
Analysis result: Severe issue found.
@ c_StatusWarning
Analysis result: Warning, there may be minor issues.
@ c_StatusGood
Analysis result: Good.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.
TCanvas * m_cEfficiencyErrRPhiViewU
efficiency U error plot canvas
TCanvas * m_cEfficiencyErrRPhiViewV3Samples
efficiency V error plot canvas for 3 samples
SVDSummaryPlots * m_hEfficiency3Samples
efficiency histo for 3 samples
std::string m_refFileName
Data members.
int m_efficiencyMin
Minimum of the efficiency histogram.
void initialize() override final
Initializer.
TCanvas * m_cEfficiencyErrV3Samples
efficiency V error plot canvas for 3 samples
TCanvas * m_cEfficiencyErrRPhiViewV
efficiency V error plot canvas
TPaveText * m_legEmpty
efficiency plot legend, empty
double m_statThreshold
minimal number of tracks per sensor to set green or red frame
TCanvas * m_cEfficiencyErrU
efficiency U error plot canvas
Int_t findBinY(Int_t layer, Int_t sensor)
find Y bin corresponding to sensor, efficiency plot
~DQMHistAnalysisSVDEfficiencyModule()
Destructor.
TCanvas * m_cEfficiencyRPhiViewV3Samples
efficiency V plot canvas for 3 samples
SVDSummaryPlots * m_hEfficiency
efficiency histo
std::vector< VxdID > m_SVDModules
IDs of all SVD Modules to iterate over.
effStatus m_effUstatus
number representing the status of the efficiency U side
SVDSummaryPlots * m_hEfficiencyErr3Samples
efficiency error histo for 3 samples
std::string m_pvPrefix
string prefix for EPICS PVs
double m_effWarning
warning level of the efficiency
double m_effError
error level of the efficiency
void terminate() override final
This method is called at the end of the event processing.
TPaveText * m_legWarning
efficiency plot legend, warning
void event() override final
This method is called for each event.
TCanvas * m_cEfficiencyV
efficiency V plot canvas
bool m_3Samples
if true enable 3 samples histograms analysis
TCanvas * m_cEfficiencyU
efficiency U plot canvas
TArrow * m_arrowx
x-axis direction
TCanvas * m_cEfficiencyU3Samples
efficiency U plot canvas for 3 samples
void endRun() override final
This method is called if the current run ends.
TCanvas * m_cEfficiencyErrU3Samples
efficiency U error plot canvas for 3 samples
void setStatusOfCanvas(int status, TCanvas *canvas, bool plotLeg)
set status of Canvas
bool m_setEfficiencyRange
set the range of the efficiency histogram
std::vector< TText * > m_sensorsText
list of sensors to write on the cancas
effStatus m_effVstatus
number representing the status of the efficiency V side
void drawText()
draw text on the RPhi view
void beginRun() override final
Called when entering a new run.
TCanvas * m_cEfficiencyRPhiViewU
efficiency U plot canvas
TPaveText * m_legNormal
efficiency plot legend, normal
TArrow * m_arrowy
y-axis direction
std::vector< TText * > m_laddersText
list of ladders to write on the canvas
TCanvas * m_cEfficiencyV3Samples
efficiency V plot canvas for 3 samples
TCanvas * m_cEfficiencyErrV
efficiency V error plot canvas
TCanvas * m_cEfficiencyRPhiViewV
efficiency V plot canvas
int m_efficiencyMax
Maximum of the efficiency histogram.
TPaveText * m_legProblem
efficiency plot legend, problem
std::tuple< std::vector< TText * >, std::vector< TText * > > textModuleNumbers()
create vectors of TText to write on the canvas
TCanvas * m_cEfficiencyErrRPhiViewU3Samples
efficiency U error plot canvas for 3 samples
SVDSummaryPlots * m_hEfficiencyErr
efficiency error histo
TCanvas * m_cEfficiencyRPhiViewU3Samples
efficiency U plot canvas for 3 samples
DQMHistAnalysisSVDEfficiencyModule()
Constructor.
TFile * m_refFile
The pointer to the reference file.
void setDescription(const std::string &description)
Sets the description of the module.
class to summarize SVD quantities per sensor and side
void setStats(bool stats=true)
set histograms stat
TH2Poly * getPoly(int view, int min=-1111, int max=-1111)
Create the TH2Poly version of the plot.
void fill(int layer, int ladder, int sensor, int view, float value)
fill the histogram for
TH2F * getHistogram(int view)
get a reference to the histogram for
void setMinimum(Int_t value=0)
set histogram minimum
void setRunID(const TString &runID)
set run ids in title
void reset()
Reset histograms.
void setMaximum(Int_t value=0)
set histogram maximum
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.
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.