9#include <dqm/analysis/modules/DQMHistAnalysisCDCDedx.h>
11#include <boost/format.hpp>
25 B2DEBUG(20,
"DQMHistAnalysisCDCDedx: Constructor done.");
26 setDescription(
"Module to draw and compute values related to dEdx for CDC. ");
29 addParam(
"mmode",
m_mode,
"default monitoring mode is basic", std::string(
"basic"));
31 Double_t stops[
m_NRGBs] = { 0.00, 0.00, 0.34, 0.61, 0.84, 1.00 };
32 Double_t red[
m_NRGBs] = { 0.00, 0.00, 0.00, 0.87, 1.00, 0.51 };
33 Double_t green[
m_NRGBs] = { 0.00, 0.00, 0.81, 1.00, 0.20, 0.00 };
34 Double_t blue[
m_NRGBs] = { 0.00, 0.51, 1.00, 0.12, 0.00, 0.00 };
44 gStyle->SetOptStat(0);
47 B2DEBUG(20,
"DQMHistAnalysisCDCDedx: initialized.");
50 m_c_ir_dedx =
new TCanvas(
"CDCDedx/c_ir_dedx",
"", 1400, 500);
53 m_c_pr_dedx =
new TCanvas(
"CDCDedx/c_CDCdedxMean",
"", 800, 800);
55 f_gaus =
new TF1(
"f_gaus",
"gaus", 0.0, 2.5);
56 f_gaus->SetLineColor(kRed);
59 l_line->SetLineColor(kRed);
63 m_text_dedx =
new TPaveText(0.60, 0.60, 0.85, 0.89,
"NBNDC");
75 m_text_dedx_ir =
new TPaveText(0.609, 0.720, 0.942, 0.911,
"NBNDC");
78 m_text_mean =
new TPaveText(0.60, 0.82, 0.85, 0.89,
"NBNDC");
81 m_text_sigma =
new TPaveText(0.60, 0.82, 0.85, 0.89,
"NBNDC");
84 m_lego =
new TLegend(0.45, 0.77, 0.60, 0.89);
85 m_legoI =
new TLegend(0.40, 0.77, 0.55, 0.89);
98 B2DEBUG(20,
"DQMHistAnalysisCDCDedx: beginRun called.");
107 B2DEBUG(20,
"DQMHistAnalysisCDCDedx: event called.");
161 B2DEBUG(20,
"DQMHistAnalysisCDCDedx : endRun called");
168 B2DEBUG(20,
"DQMHistAnalysisCDCDedx : terminate called");
196 TH1D* h_Meta = (TH1D*)
findHist(
"CDCDedx/hMeta");
198 if (h_Meta !=
nullptr) {
199 m_nallevt = int(h_Meta->GetBinContent(1));
201 m_nhadevt = int(h_Meta->GetBinContent(3));
203 std::string title = h_Meta->GetTitle();
206 m_last = title.find(
", Run:");
209 m_first = title.find(
", Run:");
210 m_last = title.find(
", RG:");
217 m_exp = std::stoi(expN.c_str());
218 m_run = std::stoi(runN.c_str());
219 m_dbrg = std::stof(runGain.c_str());
231 TH1* h_dEdx =
findHist(
"CDCDedx/hdEdx");
232 if (h_dEdx !=
nullptr) {
234 double meanerr = 0.0;
235 double sigmaerr = 0.0;
242 if (h_dEdx->Integral() > 250) {
245 m_mean = h_dEdx->GetFunction(
"f_gaus")->GetParameter(1);
246 m_sigma = h_dEdx->GetFunction(
"f_gaus")->GetParameter(2);
247 meanerr = h_dEdx->GetFunction(
"f_gaus")->GetParError(1);
248 sigmaerr = h_dEdx->GetFunction(
"f_gaus")->GetParError(2);
251 h_dEdx->SetFillColor(kYellow);
252 h_dEdx->SetTitle(
"CDC-dEdx");
261 m_monObj->setVariable(
"CDCDedxMeanErr", meanerr);
262 m_monObj->setVariable(
"CDCDedxResoErr", sigmaerr);
307 TH2D* hdEdxIRScat = (TH2D*)
findHist(
"CDCDedx/hdEdxvsEvt");
308 if (hdEdxIRScat !=
nullptr) {
312 if (hdEdxIRScat->GetEntries() > 0) {
313 hdEdxIRScat->GetXaxis()->SetRange(hdEdxIRScat->FindFirstBinAbove(0, 1), hdEdxIRScat->FindLastBinAbove(0, 1));
317 hdEdxIRScat->SetTitle(
"CDC-dE/dx Intra-run variation");
318 hdEdxIRScat->Draw(
"");
331 TH2D* hdEdxIRScatC = (TH2D*)
findHist(
"CDCDedx/hdEdxvsEvt");
333 if (hdEdxIRScatC !=
nullptr) {
338 int fbin = hdEdxIRScatC->FindFirstBinAbove(0, 1);
339 int lbin = hdEdxIRScatC->FindLastBinAbove(0, 1);
340 int nbin = lbin - fbin + 1;
342 if (nbin <= 0) nbin = 1;
345 m_hdEdxIRMean =
new TH1F(
"m_hdEdxIRMean",
"", nbin, 0.5, nbin + 0.5);
346 m_hdEdxIRMean->SetTitle(
"CDC-dE/dx gain(#mu): intra-run variation;Events(M);dE/dx (#mu_{fit})");
349 m_hdEdxIRSigma =
new TH1F(
"m_hdEdxIRSigma",
"", nbin, 0.5, nbin + 0.5);
350 m_hdEdxIRSigma->SetTitle(
"CDC-dE/dx reso.(#sigma): intra-run variation;Events(M);dE/dx (#sigma_{fit})");
385 TH2D* hdEdxVsP = (TH2D*)
findHist(
"CDCDedx/hdEdxVsP");
386 if (hdEdxVsP !=
nullptr) {
394 hdEdxVsP->SetTitle(
"CDC-dEdx band plot");
395 hdEdxVsP->SetMinimum(0.10);
396 hdEdxVsP->Draw(
"col");
418 TH2D* hdEdxvsPhi = (TH2D*)
findHist(
"CDCDedx/hdEdxvsPhi");
419 if (hdEdxvsPhi !=
nullptr) {
424 hdEdxvsPhi->SetTitle(
"CDC-dEdx vs Phi");
425 hdEdxvsPhi->Draw(
"col");
432 TH2D* hdEdxvsCosth = (TH2D*)
findHist(
"CDCDedx/hdEdxvsCosth");
433 if (hdEdxvsCosth !=
nullptr) {
438 hdEdxvsCosth->SetTitle(
"CDC-dEdx vs Costh");
439 hdEdxvsCosth->Draw(
"col");
449 TH2D* hinjtimeHer = (TH2D*)
findHist(
"CDCDedx/hinjtimeHer");
450 TH2D* hinjtimeLer = (TH2D*)
findHist(
"CDCDedx/hinjtimeLer");
452 if (hinjtimeHer !=
nullptr && hinjtimeLer !=
nullptr) {
458 hinjtimeHer->SetFillColor(kBlue);
459 hinjtimeHer->SetTitle(
"Time since m_last injection (HER)");
460 hinjtimeHer->Draw(
"box");
463 hinjtimeLer->SetFillColor(kRed);
464 hinjtimeLer->Draw(
"same box");
469 m_lego->AddEntry(hinjtimeHer,
"HER",
"f");
470 m_lego->AddEntry(hinjtimeLer,
"LER",
"f");
481 TH2D* hdEdxITHer = (TH2D*)
findHist(
"CDCDedx/hinjtimeHer");
482 TH2D* hdEdxITLer = (TH2D*)
findHist(
"CDCDedx/hinjtimeLer");
484 if (hdEdxITHer !=
nullptr && hdEdxITLer !=
nullptr) {
488 int fbin = hdEdxITHer->FindFirstBinAbove(0, 1);
489 int lbin = hdEdxITHer->FindLastBinAbove(0, 1);
490 int nbin = (lbin - fbin + 1) / 2;
491 if (nbin <= 0)nbin = 1;
497 m_hMeanHer =
new TH1F(
"m_hMeanHer",
"CDC-dE/dx gain(#mu);Injection time (ms);dE/dx (#mu_{fit})", nbin, 0.5, nbin + 0.5);
498 m_hSigmaHer =
new TH1F(
"m_hSigmaHer",
"CDC-dE/dx reso.(#sigma);Injection time (ms);dE/dx (#sigma_{fit})", nbin, 0.5, nbin + 0.5);
500 m_hMeanLer =
new TH1F(
"m_hMeanLer",
"CDC-dE/dx gain(#mu);Injection time (ms);dE/dx (#mu_{fit})", nbin, 0.5, nbin + 0.5);
501 m_hSigmaLer =
new TH1F(
"m_hSigmaLer",
"CDC-dE/dx reso.(#sigma);Injection time (ms);dE/dx (#sigma_{fit})", nbin, 0.5, nbin + 0.5);
551 TH2D* hWires = (TH2D*)
findHist(
"CDCDedx/hWires");
552 TH2D* hWireStatus = (TH2D*)
findHist(
"CDCDedx/hWireStatus");
553 if (hWires !=
nullptr && hWireStatus !=
nullptr) {
557 hWires->SetMarkerColor(kGray);
560 std::string s_ndead = hWireStatus->GetTitle();
561 int m_ndead = atof(s_ndead.c_str());
562 m_monObj->setVariable(
"CDCDedxDeadWires", m_ndead);
565 hWireStatus->SetMarkerColor(kRed);
566 hWireStatus->SetMarkerStyle(7);
567 hWireStatus->Draw(
"same");
574 m_text_dedxWire->AddText(Form(
"Dead: %d (%0.02f%%)", m_ndead, (100.0 * m_ndead / c_nSenseWires)));
589 int fbin = hdEdx->FindFirstBinAbove(0, 1);
591 for (
int ibin = 0; ibin < nbin; ibin++) {
592 int localbin = ibin + fbin;
594 m_hdEdxIRInd = (TH1*)hdEdx->ProjectionY(Form(
"htemp_%d", localbin), localbin, localbin);
596 double mean = 0.0, meanerr = 0.0;
597 double sigma = 0.0, sigmaerr = 0.0;
602 mean =
m_hdEdxIRInd->GetFunction(
"f_gaus")->GetParameter(1);
603 meanerr =
m_hdEdxIRInd->GetFunction(
"f_gaus")->GetParError(1);
604 sigma =
m_hdEdxIRInd->GetFunction(
"f_gaus")->GetParameter(2);
605 sigmaerr =
m_hdEdxIRInd->GetFunction(
"f_gaus")->GetParError(2);
608 hmean->SetBinContent(ibin + 1, mean);
609 hmean->SetBinError(ibin + 1, meanerr);
610 hsigma->SetBinContent(ibin + 1, sigma);
611 hsigma->SetBinError(ibin + 1, sigmaerr);
613 hmean->SetMarkerStyle(20);
614 hmean->SetMarkerSize(1.10);
615 hsigma->SetMarkerStyle(20);
616 hsigma->SetMarkerSize(1.10);
623 pt->AddText(
"CDC dE/dx (e^{+}e^{-})");
624 pt->AddText(Form(
"Exp/Run: %d/%d",
m_exp,
m_run));
626 pt->AddText(Form(
"Events: %0.02fM",
double(
m_nbhabhaevt / 1e6)));
628 pt->AddText(Form(
"Events: %0.02fK",
double(
m_nbhabhaevt / 1e3)));
637 if (temphist !=
nullptr) {
638 temphist->GetXaxis()->SetRange(temphist->FindFirstBinAbove(0, 1), temphist->FindLastBinAbove(0, 1));
639 int fs = temphist->Fit(
f_gaus,
"QR");
643 double mean = temphist->GetFunction(
"f_gaus")->GetParameter(1);
644 double width = temphist->GetFunction(
"f_gaus")->GetParameter(2);
645 temphist->GetXaxis()->SetRangeUser(mean - 5.0 * width, mean + 5.0 * width);
646 fs = temphist->Fit(
f_gaus,
"QR",
"", mean - 3.0 * width, mean + 3.0 * width);
647 if (fs != 0)status =
"Failed";
649 temphist->GetXaxis()->SetRangeUser(mean - 5.0 * width, mean + 5.0 * width);
660 gStyle->SetNumberContours(
m_NCont);
669 obj->SetFillColor(TColor::GetColor(
"#FFFF99"));
670 obj->SetFillStyle(1001);
671 obj->SetLineColor(TColor::GetColor(
"#000000"));
672 obj->SetLineWidth(1);
673 obj->SetTextAlign(12);
674 obj->SetTextColor(kBlack);
675 obj->SetTextFont(82);
676 obj->SetTextSize(0.03157895);
687 obj->SetTitleOffset(1.15,
"x");
688 obj->SetTitleSize(.040,
"x");
689 obj->SetTitleOffset(1.15,
"y");
690 obj->SetTitleSize(.040,
"y");
692 obj->SetLabelOffset(0.015,
"x");
693 obj->SetLabelSize(.040,
"x");
694 obj->SetLabelOffset(0.015,
"y");
695 obj->SetLabelSize(.040,
"y");
697 obj->SetTickLength(0.03,
"x");
698 obj->SetTickLength(0.02,
"y");
706 if (l != 0)gPad->SetLeftMargin(l);
707 if (r != 0)gPad->SetRightMargin(r);
708 if (t != 0)gPad->SetTopMargin(t);
709 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
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).
DQMHistAnalysisModule()
Constructor / Destructor.
void setDescription(const std::string &description)
Sets the description of the module.
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.