14 #include <dqm/analysis/modules/DQMHistAnalysisPXDTrackCharge.h>
18 #include <vxd/geometry/GeoCache.h>
20 #include <RooDataHist.h>
21 #include <RooAbsPdf.h>
37 DQMHistAnalysisPXDTrackChargeModule::DQMHistAnalysisPXDTrackChargeModule()
49 addParam(
"RefHistoFile",
m_refFileName,
"Reference histrogram file name", std::string(
"refHisto.root"));
50 addParam(
"ColorAlert",
m_color,
"Whether to show the color alert",
true);
52 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: Constructor done.");
61 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: initialized.");
71 m_rfws =
new RooWorkspace(
"w");
72 m_rfws->factory(
"Landau::landau(x[0,100],ml[20,10,50],sl[5,1,30])");
73 m_rfws->factory(
"Gaussian::gauss(x,mg[0],sg[2,0.1,10])");
74 m_rfws->factory(
"FCONV::lxg(x,landau,gauss)");
81 for (
VxdID& aVxdID : sensors) {
86 std::string name =
"PXD_Track_Cluster_Charge_" + (std::string)aVxdID;
87 std::replace(name.begin(), name.end(),
'.',
'_');
89 if (aVxdID ==
VxdID(
"1.5.1")) {
90 for (
int s = 0; s < 6; s++) {
91 for (
int d = 0; d < 4; d++) {
96 (
"PXD TCCharge MPV " + name +
";Switcher;DCD;MPV").data(),
97 6, 0.5, 6.5, 4, 0.5, 4.5);
106 m_hTrackedClusters =
new TH1F(
"hPXDTrackedClusters",
"PXD Tracked Clusters/Event;Module", 40, 0, 40);
111 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
113 ax->SetBinLabel(i + 1, ModuleName);
115 }
else B2ERROR(
"no axis");
121 m_gCharge->SetName(
"Track_Cluster_Charge");
122 m_gCharge->SetTitle(
"Track Cluster Charge");
143 m_fMean->SetLineColor(kYellow);
157 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: beginRun called.");
166 gStyle->SetOptStat(0);
167 gStyle->SetStatStyle(1);
168 gStyle->SetOptDate(22);
174 auto model =
m_rfws->pdf(
"lxg");
176 auto ml =
m_rfws->var(
"ml");
182 std::string name =
"Tracked_Clusters";
189 auto scale = hh2->GetBinContent(0);
192 for (
int i = 0; i < 64; i++) {
193 auto layer = (((i >> 5) & 0x1) + 1);
194 auto ladder = ((i >> 1) & 0xF);
195 auto sensor = ((i & 0x1) + 1);
217 href2->SetLineStyle(3);
218 href2->SetLineColor(kBlack);
219 href2->Draw(
"same,hist");
234 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
236 if (canvas ==
nullptr)
continue;
238 std::string name =
"PXD_Track_Cluster_Charge_" + (std::string)
m_PXDModules[i];
239 std::replace(name.begin(), name.end(),
'.',
'_');
247 if (hh1->GetEntries() > 50) {
249 auto hdata =
new RooDataHist(hh1->GetName(), hh1->GetTitle(), *
m_x, (
const TH1*) hh1);
250 auto plot =
m_x->frame(RooFit::Title(hh1->GetTitle()));
251 model->fitTo(*hdata, RooFit::Range(
"signal"));
253 model->paramOn(plot, RooFit::Format(
"NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6, 0.9, 0.9));
254 hdata->plotOn(plot, RooFit::LineColor(kBlue));
255 model->plotOn(plot, RooFit::LineColor(kRed), RooFit::Range(
"signal"), RooFit::NormRange(
"signal"));
268 m_gCharge->SetPoint(p, i + 0.49, ml->getValV());
269 m_gCharge->SetPointError(p, 0.1, ml->getError());
279 B2DEBUG(20,
"Draw Normalized " << hist2->GetName());
280 hist2->SetLineStyle(3);
281 hist2->SetLineColor(kBlack);
286 TH1* h = (TH1*)hist2->Clone();
288 if (abs(hist2->GetEntries()) > 0) h->Scale(hh1->GetEntries() / hist2->GetEntries());
291 h->Draw(
"same,hist");
295 canvas->Pad()->SetFrameFillColor(10);
297 if (hh1->GetEntries() < 100) {
299 canvas->Pad()->SetFillColor(kGray);
301 canvas->Pad()->SetFillColor(kGreen);
304 canvas->Pad()->SetFillColor(kWhite);
312 if (hh1->GetEntries() >= 1000) enough =
true;
317 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
324 for (
int s = 1; s <= 6; s++) {
325 for (
int d = 1; d <= 4; d++) {
326 std::string name =
"PXD_Track_Cluster_Charge_" + (std::string)
m_PXDModules[i] + Form(
"_sw%d_dcd%d", s, d);
327 std::replace(name.begin(), name.end(),
'.',
'_');
337 if (hh1->GetEntries() > 50) {
338 auto hdata =
new RooDataHist(hh1->GetName(), hh1->GetTitle(), *
m_x, (
const TH1*) hh1);
339 auto plot =
m_x->frame(RooFit::Title(hh1->GetTitle()));
340 model->fitTo(*hdata, RooFit::Range(
"signal"));
343 model->paramOn(plot, RooFit::Format(
"NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6, 0.9, 0.9));
344 hdata->plotOn(plot, RooFit::LineColor(kBlue));
345 model->plotOn(plot, RooFit::LineColor(kRed), RooFit::Range(
"signal"), RooFit::NormRange(
"signal"));
374 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
376 ax->SetBinLabel(i + 1, ModuleName);
378 }
else B2ERROR(
"no axis");
386 auto tt =
new TLatex(it + 0.5, 0, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
387 tt->SetTextSize(0.035);
388 tt->SetTextAngle(90);
389 tt->SetTextAlign(12);
403 double maxi = mean + 15;
404 double mini = mean - 15;
433 if (fabs(data - 30.) > 20. || diff > 12) {
436 }
else if (fabs(data - 30) > 15. || diff > 8) {
454 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge : endRun called");
460 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: 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.
static TH1 * findHistInFile(TFile *file, const std::string &histname)
Find histogram in specific TFile (e.g.
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.
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)
void terminate(void) override final
This method is called at the end of the event processing.
std::string m_refFileName
Reference Histogram Root file name.
TCanvas * m_cCharge
Final Canvas.
bool m_color
Whether to use the color code for warnings and errors.
double m_rangeLow
fit range lo edge for landau
std::map< VxdID, std::array< std::array< TCanvas *, 4 >, 6 > > m_cChargeModASIC
Final Canvases for Fit and Ref per ASIC.
std::map< VxdID, TH2F * > m_hChargeModASIC2d
Final Canvas Fit and Ref per ASIC.
void initialize(void) override final
Initializer.
void endRun(void) override final
This method is called if the current run ends.
~DQMHistAnalysisPXDTrackChargeModule()
Destructor.
MonitoringObject * m_monObj
Monitoring Object.
TLine * m_line_up
TLine object for upper limit of track cluster charge.
TF1 * m_fMean
Fit the Mean for all modules.
TGraphErrors * m_gCharge
Graph covering all modules.
std::vector< VxdID > m_PXDModules
IDs of all PXD Modules to iterate over.
std::string m_histogramDirectoryName
name of histogram directory
RooRealVar * m_x
RooFit variable.
RooWorkspace * m_rfws
RooFit Workspace.
TLine * m_line_mean
TLine object for mean of track cluster charge.
double m_rangeHigh
fit range hi edge for landau
TLine * m_line_low
TLine object for lower limit of track cluster charge.
std::vector< int > m_excluded
Indizes of excluded PXD Modules.
TH1F * m_hTrackedClusters
Histogram for TrackedClusters.
TCanvas * m_cTrackedClusters
Final Canvas for TrackedClusters.
std::map< VxdID, TCanvas * > m_cChargeMod
Final Canvases for Fit and Ref.
void beginRun(void) override final
Called when entering a new run.
void event(void) override final
This method is called for each event.
std::map< VxdID, TCanvas * > m_cChargeModASIC2d
Final Canvas Fit and Ref per ASIC.
TFile * m_refFile
The pointer to the reference file.
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.
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.