9#include <dqm/analysis/modules/DQMHistAnalysisCDCDedx.h>
22 B2DEBUG(20,
"DQMHistAnalysisCDCDedx: Constructor done.");
23 setDescription(
"Module to draw and compute values related to dEdx for CDC. ");
26 addParam(
"mmode",
m_mode,
"default monitoring mode is basic", std::string(
"basic"));
28 Double_t stops[
m_NRGBs] = { 0.00, 0.00, 0.34, 0.61, 0.84, 1.00 };
29 Double_t red[
m_NRGBs] = { 0.00, 0.00, 0.00, 0.87, 1.00, 0.51 };
30 Double_t green[
m_NRGBs] = { 0.00, 0.00, 0.81, 1.00, 0.20, 0.00 };
31 Double_t blue[
m_NRGBs] = { 0.00, 0.51, 1.00, 0.12, 0.00, 0.00 };
41 gStyle->SetOptStat(0);
44 B2DEBUG(20,
"DQMHistAnalysisCDCDedx: initialized.");
47 m_c_ir_dedx =
new TCanvas(
"CDCDedx/m_c_ir_dedx",
"", 1400, 500);
50 m_c_pr_dedx =
new TCanvas(
"CDCDedx/c_CDCdedxMean",
"", 800, 800);
52 f_gaus =
new TF1(
"f_gaus",
"gaus", 0.0, 2.5);
53 f_gaus->SetLineColor(kRed);
56 l_line->SetLineColor(kRed);
60 m_text_dedx =
new TPaveText(0.60, 0.60, 0.85, 0.89,
"NBNDC");
72 m_text_dedx_ir =
new TPaveText(0.609, 0.720, 0.942, 0.911,
"NBNDC");
75 m_text_mean =
new TPaveText(0.60, 0.82, 0.85, 0.89,
"NBNDC");
78 m_text_sigma =
new TPaveText(0.60, 0.82, 0.85, 0.89,
"NBNDC");
81 m_lego =
new TLegend(0.45, 0.77, 0.60, 0.89);
82 m_legoI =
new TLegend(0.40, 0.77, 0.55, 0.89);
95 B2DEBUG(20,
"DQMHistAnalysisCDCDedx: beginRun called.");
104 B2DEBUG(20,
"DQMHistAnalysisCDCDedx: event called.");
158 B2DEBUG(20,
"DQMHistAnalysisCDCDedx : endRun called");
165 B2DEBUG(20,
"DQMHistAnalysisCDCDedx : terminate called");
193 TH1D* h_Meta = (TH1D*)
findHist(
"CDCDedx/hMeta");
195 if (h_Meta !=
nullptr) {
196 m_nallevt = int(h_Meta->GetBinContent(1));
198 m_nhadevt = int(h_Meta->GetBinContent(3));
200 std::string title = h_Meta->GetTitle();
203 m_last = title.find(
", Run:");
206 m_first = title.find(
", Run:");
207 m_last = title.find(
", RG:");
214 m_exp = std::stoi(expN.c_str());
215 m_run = std::stoi(runN.c_str());
216 m_dbrg = std::stof(runGain.c_str());
228 TH1* h_dEdx =
findHist(
"CDCDedx/hdEdx");
229 if (h_dEdx !=
nullptr) {
231 double meanerr = 0.0;
232 double sigmaerr = 0.0;
239 if (h_dEdx->Integral() > 250) {
242 m_mean = h_dEdx->GetFunction(
"f_gaus")->GetParameter(1);
243 m_sigma = h_dEdx->GetFunction(
"f_gaus")->GetParameter(2);
244 meanerr = h_dEdx->GetFunction(
"f_gaus")->GetParError(1);
245 sigmaerr = h_dEdx->GetFunction(
"f_gaus")->GetParError(2);
248 h_dEdx->SetFillColor(kYellow);
249 h_dEdx->SetTitle(
"CDC-dEdx");
304 TH2D* hdEdxIRScat = (TH2D*)
findHist(
"CDCDedx/hdEdxvsEvt");
305 if (hdEdxIRScat !=
nullptr) {
309 if (hdEdxIRScat->GetEntries() > 0) {
310 hdEdxIRScat->GetXaxis()->SetRange(hdEdxIRScat->FindFirstBinAbove(0, 1), hdEdxIRScat->FindLastBinAbove(0, 1));
314 hdEdxIRScat->SetTitle(
"CDC-dE/dx Intra-run variation");
315 hdEdxIRScat->Draw(
"");
328 TH2D* hdEdxIRScatC = (TH2D*)
findHist(
"CDCDedx/hdEdxvsEvt");
330 if (hdEdxIRScatC !=
nullptr) {
335 int fbin = hdEdxIRScatC->FindFirstBinAbove(0, 1);
336 int lbin = hdEdxIRScatC->FindLastBinAbove(0, 1);
337 int nbin = lbin - fbin + 1;
339 if (nbin <= 0) nbin = 1;
342 m_hdEdxIRMean =
new TH1F(
"m_hdEdxIRMean",
"", nbin, 0.5, nbin + 0.5);
343 m_hdEdxIRMean->SetTitle(
"CDC-dE/dx gain(#mu): intra-run variation;Events(M);dE/dx (#mu_{fit})");
346 m_hdEdxIRSigma =
new TH1F(
"m_hdEdxIRSigma",
"", nbin, 0.5, nbin + 0.5);
347 m_hdEdxIRSigma->SetTitle(
"CDC-dE/dx reso.(#sigma): intra-run variation;Events(M);dE/dx (#sigma_{fit})");
382 TH2D* hdEdxVsP = (TH2D*)
findHist(
"CDCDedx/hdEdxVsP");
383 if (hdEdxVsP !=
nullptr) {
391 hdEdxVsP->SetTitle(
"CDC-dEdx band plot");
392 hdEdxVsP->SetMinimum(0.10);
393 hdEdxVsP->Draw(
"col");
415 TH2D* hdEdxvsPhi = (TH2D*)
findHist(
"CDCDedx/hdEdxvsPhi");
416 if (hdEdxvsPhi !=
nullptr) {
421 hdEdxvsPhi->SetTitle(
"CDC-dEdx vs Phi");
422 hdEdxvsPhi->Draw(
"col");
429 TH2D* hdEdxvsCosth = (TH2D*)
findHist(
"CDCDedx/hdEdxvsCosth");
430 if (hdEdxvsCosth !=
nullptr) {
435 hdEdxvsCosth->SetTitle(
"CDC-dEdx vs Costh");
436 hdEdxvsCosth->Draw(
"col");
446 TH2D* hinjtimeHer = (TH2D*)
findHist(
"CDCDedx/hinjtimeHer");
447 TH2D* hinjtimeLer = (TH2D*)
findHist(
"CDCDedx/hinjtimeLer");
449 if (hinjtimeHer !=
nullptr && hinjtimeLer !=
nullptr) {
455 hinjtimeHer->SetFillColor(kBlue);
456 hinjtimeHer->SetTitle(
"Time since m_last injection (HER)");
457 hinjtimeHer->Draw(
"box");
460 hinjtimeLer->SetFillColor(kRed);
461 hinjtimeLer->Draw(
"same box");
466 m_lego->AddEntry(hinjtimeHer,
"HER",
"f");
467 m_lego->AddEntry(hinjtimeLer,
"LER",
"f");
478 TH2D* hdEdxITHer = (TH2D*)
findHist(
"CDCDedx/hinjtimeHer");
479 TH2D* hdEdxITLer = (TH2D*)
findHist(
"CDCDedx/hinjtimeLer");
481 if (hdEdxITHer !=
nullptr && hdEdxITLer !=
nullptr) {
485 int fbin = hdEdxITHer->FindFirstBinAbove(0, 1);
486 int lbin = hdEdxITHer->FindLastBinAbove(0, 1);
487 int nbin = (lbin - fbin + 1) / 2;
488 if (nbin <= 0)nbin = 1;
494 m_hMeanHer =
new TH1F(
"m_hMeanHer",
"CDC-dE/dx gain(#mu);Injection time (ms);dE/dx (#mu_{fit})", nbin, 0.5, nbin + 0.5);
495 m_hSigmaHer =
new TH1F(
"m_hSigmaHer",
"CDC-dE/dx reso.(#sigma);Injection time (ms);dE/dx (#sigma_{fit})", nbin, 0.5, nbin + 0.5);
497 m_hMeanLer =
new TH1F(
"m_hMeanLer",
"CDC-dE/dx gain(#mu);Injection time (ms);dE/dx (#mu_{fit})", nbin, 0.5, nbin + 0.5);
498 m_hSigmaLer =
new TH1F(
"m_hSigmaLer",
"CDC-dE/dx reso.(#sigma);Injection time (ms);dE/dx (#sigma_{fit})", nbin, 0.5, nbin + 0.5);
548 TH2D* hWires = (TH2D*)
findHist(
"CDCDedx/hWires");
549 TH2D* hWireStatus = (TH2D*)
findHist(
"CDCDedx/hWireStatus");
550 if (hWires !=
nullptr && hWireStatus !=
nullptr) {
554 hWires->SetMarkerColor(kGray);
557 std::string s_ndead = hWireStatus->GetTitle();
558 int m_ndead = atof(s_ndead.c_str());
562 hWireStatus->SetMarkerColor(kRed);
563 hWireStatus->SetMarkerStyle(7);
564 hWireStatus->Draw(
"same");
571 m_text_dedxWire->AddText(Form(
"Dead: %d (%0.02f%%)", m_ndead, (100.0 * m_ndead / c_nSenseWires)));
586 int fbin = hdEdx->FindFirstBinAbove(0, 1);
588 for (
int ibin = 0; ibin < nbin; ibin++) {
589 int localbin = ibin + fbin;
591 m_hdEdxIRInd = (TH1*)hdEdx->ProjectionY(Form(
"htemp_%d", localbin), localbin, localbin);
593 double mean = 0.0, meanerr = 0.0;
594 double sigma = 0.0, sigmaerr = 0.0;
599 mean =
m_hdEdxIRInd->GetFunction(
"f_gaus")->GetParameter(1);
600 meanerr =
m_hdEdxIRInd->GetFunction(
"f_gaus")->GetParError(1);
601 sigma =
m_hdEdxIRInd->GetFunction(
"f_gaus")->GetParameter(2);
602 sigmaerr =
m_hdEdxIRInd->GetFunction(
"f_gaus")->GetParError(2);
605 hmean->SetBinContent(ibin + 1, mean);
606 hmean->SetBinError(ibin + 1, meanerr);
607 hsigma->SetBinContent(ibin + 1, sigma);
608 hsigma->SetBinError(ibin + 1, sigmaerr);
610 hmean->SetMarkerStyle(20);
611 hmean->SetMarkerSize(1.10);
612 hsigma->SetMarkerStyle(20);
613 hsigma->SetMarkerSize(1.10);
620 pt->AddText(
"CDC dE/dx (e^{+}e^{-})");
621 pt->AddText(Form(
"Exp/Run: %d/%d",
m_exp,
m_run));
623 pt->AddText(Form(
"Events: %0.02fM",
double(
m_nbhabhaevt / 1e6)));
625 pt->AddText(Form(
"Events: %0.02fK",
double(
m_nbhabhaevt / 1e3)));
634 if (temphist !=
nullptr) {
635 temphist->GetXaxis()->SetRange(temphist->FindFirstBinAbove(0, 1), temphist->FindLastBinAbove(0, 1));
636 int fs = temphist->Fit(
f_gaus,
"QR");
640 double mean = temphist->GetFunction(
"f_gaus")->GetParameter(1);
641 double width = temphist->GetFunction(
"f_gaus")->GetParameter(2);
642 temphist->GetXaxis()->SetRangeUser(mean - 5.0 * width, mean + 5.0 * width);
643 fs = temphist->Fit(
f_gaus,
"QR",
"", mean - 3.0 * width, mean + 3.0 * width);
644 if (fs != 0)status =
"Failed";
646 temphist->GetXaxis()->SetRangeUser(mean - 5.0 * width, mean + 5.0 * width);
657 gStyle->SetNumberContours(
m_NCont);
666 obj->SetFillColor(TColor::GetColor(
"#FFFF99"));
667 obj->SetFillStyle(1001);
668 obj->SetLineColor(TColor::GetColor(
"#000000"));
669 obj->SetLineWidth(1);
670 obj->SetTextAlign(12);
671 obj->SetTextColor(kBlack);
672 obj->SetTextFont(82);
673 obj->SetTextSize(0.03157895);
684 obj->SetTitleOffset(1.15,
"x");
685 obj->SetTitleSize(.040,
"x");
686 obj->SetTitleOffset(1.15,
"y");
687 obj->SetTitleSize(.040,
"y");
689 obj->SetLabelOffset(0.015,
"x");
690 obj->SetLabelSize(.040,
"x");
691 obj->SetLabelOffset(0.015,
"y");
692 obj->SetLabelSize(.040,
"y");
694 obj->SetTickLength(0.03,
"x");
695 obj->SetTickLength(0.02,
"y");
703 if (l != 0)gPad->SetLeftMargin(l);
704 if (r != 0)gPad->SetRightMargin(r);
705 if (t != 0)gPad->SetTopMargin(t);
706 if (b != 0)gPad->SetBottomMargin(b);
DQMHistAnalysisCDCDedxModule()
constructor
void drawDedxInjTime()
function to draw the dEdx vs injection time
void drawDedxCosPhi()
function to draw dEdx vs costh and phi
void initialize() override final
init function for default values
void drawBandPlot()
function to dedx bands P
TLine * l_line
line for dedx mean
void setTextStyle(TPaveText *obj)
function to add text style
void drawWireStatus()
function to draw ADC-based dead wire status of CDC
TH1F * m_hdEdxIRMean
histogram for dE/dx mean vs events per run
TCanvas * m_c_pr_dedx
dedx dist+fit
int m_nhadevt
hadron events
TPaveText * m_text_dedx_fit
add dE/dx fit information
void setHistStyle(TH1 *obj)
function to set the style of histogram
TPaveText * m_text_mean
add dE/dx mean information
TH1 * m_hdEdxIRInd
histogram to calculate dE/dx mean and sigma in bins
TLegend * m_legoI
legends for LER/HER for mean and sigma
std::string m_status
fit status
MonitoringObject * m_monObj
MonitoringObject for mirabelle.
TLegend * m_lego
legends for LER/HER
TH1F * m_hSigmaHer
histogram for dE/dx sigma vs injection time (HER)
void terminate() override final
terminating at the end of last run
void drawDedxInjTimeBin()
function to draw the mean/reso of dedx vs injection time
void event() override final
event by event function
Int_t m_pal
number of colors
TPaveText * m_text_sigma
add dE/dx sigma information
unsigned m_last
substring last value
TCanvas * m_c_ir_dedx
intra-run dedx status
void setHistPars(TH2D *&hist, TH1F *&hmean, TH1F *&hsigma, int nbin)
function to set the mean and sigma histograms
static const Int_t m_NCont
Total number of colors in the table.
TPaveText * m_text_dedxWire
add Wire information
void endRun() override final
end of each run
TH1F * m_hSigmaLer
histogram for dE/dx sigma vs injection time (LER)
void setPadStyle(double l, double r, double t, double b)
function to reset pad margins
Int_t m_palarr[m_NCont]
array of colors
void getMetadata()
function to get metadata from histogram
void setBEvtInfo(TPaveText *pt)
function to set the bhabha event info
void fitHistogram(TH1 *&temphist, std::string &status)
function to fit gaussian dist.
double m_dbrg
previous run gain
unsigned m_first
substring start value
void beginRun() override final
begin each run
TPaveText * m_text_dedx_ir
add dE/dx intra run information
int m_nbhabhaevt
bhabha events
void drawDedxPR()
function to draw dEdx+Fit
TPaveText * m_text_bandplot
add hadron event information
void drawDedxIR()
function to draw dEdx+Fit for run variation
TPaveText * m_text_dedx
add dE/dx bhabha event information
TH1F * m_hdEdxIRSigma
histogram for dE/dx sigma vs events per run
static const Int_t m_NRGBs
Number of end point colors that will form the gradients.
TH1F * m_hMeanLer
histogram for dE/dx mean vs injection time (LER)
TH1F * m_hMeanHer
histogram for dE/dx mean vs injection time (HER)
std::string m_mode
monitoring mode all/basic
void setPlotStyle()
function to add plot style
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)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
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.
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.