13#include <dqm/analysis/modules/DQMHistAnalysisPXDTrackCharge.h>
17#include <vxd/geometry/GeoCache.h>
19#include <RooDataHist.h>
22#include <RooFitResult.h>
49 addParam(
"ColorAlert",
m_color,
"Whether to show the color alert",
true);
51 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: Constructor done.");
60 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: initialized.");
65 m_rfws =
new RooWorkspace(
"w");
66 m_rfws->factory(
"Landau::landau(x[0,100],ml[20,10,50],sl[5,1,30])");
67 m_rfws->factory(
"Gaussian::gauss(x,mg[0],sg[2,0.1,10])");
68 m_rfws->factory(
"FCONV::lxg(x,landau,gauss)");
75 for (
VxdID& aVxdID : sensors) {
80 std::string name =
"PXD_Track_Cluster_Charge_" + (std::string)aVxdID;
81 std::replace(name.begin(), name.end(),
'.',
'_');
83 if (aVxdID ==
VxdID(
"1.5.1")) {
84 for (
int s = 0; s < 6; s++) {
85 for (
int d = 0; d < 4; d++) {
90 (
"PXD TCCharge MPV " + name +
";Switcher;DCD;MPV").data(),
91 6, 0.5, 6.5, 4, 0.5, 4.5);
97 B2WARNING(
"No PXDModules in Geometry found! Use hard-coded setup.");
98 std::vector <string> mod = {
99 "1.1.1",
"1.1.2",
"1.2.1",
"1.2.2",
"1.3.1",
"1.3.2",
"1.4.1",
"1.4.2",
100 "1.5.1",
"1.5.2",
"1.6.1",
"1.6.2",
"1.7.1",
"1.7.2",
"1.8.1",
"1.8.2",
101 "2.1.1",
"2.1.2",
"2.2.1",
"2.2.2",
"2.3.1",
"2.3.2",
"2.4.1",
"2.4.2",
102 "2.5.1",
"2.5.2",
"2.6.1",
"2.6.2",
"2.7.1",
"2.7.2",
"2.8.1",
"2.8.2",
103 "2.9.1",
"2.9.2",
"2.10.1",
"2.10.2",
"2.11.1",
"2.11.2",
"2.12.1",
"2.12.2"
112 m_hTrackedClusters =
new TH1F(
"hPXDTrackedClusters",
"PXD Tracked Clusters/Event;Module", 40, 0, 40);
117 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
119 ax->SetBinLabel(i + 1, ModuleName);
121 }
else B2ERROR(
"no axis");
127 m_gCharge->SetName(
"Track_Cluster_Charge");
128 m_gCharge->SetTitle(
"Track Cluster Charge");
149 m_fMean->SetLineColor(kYellow);
163 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: beginRun called.");
172 gStyle->SetOptStat(0);
173 gStyle->SetStatStyle(1);
174 gStyle->SetOptDate(22);
180 auto model =
m_rfws->pdf(
"lxg");
182 auto ml =
m_rfws->var(
"ml");
188 std::string name =
"Tracked_Clusters";
195 auto scale = hh2->GetBinContent(0);
198 for (
int i = 0; i < 64; i++) {
199 auto layer = (((i >> 5) & 0x1) + 1);
200 auto ladder = ((i >> 1) & 0xF);
201 auto sensor = ((i & 0x1) + 1);
240 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
242 if (canvas ==
nullptr)
continue;
244 std::string name =
"PXD_Track_Cluster_Charge_" + (std::string)
m_PXDModules[i];
245 std::replace(name.begin(), name.end(),
'.',
'_');
253 if (hh1->GetEntries() > 50) {
255 auto hdata =
new RooDataHist(hh1->GetName(), hh1->GetTitle(), *
m_x, (
const TH1*) hh1);
256 auto plot =
m_x->frame(RooFit::Title(hh1->GetTitle()));
257 model->fitTo(*hdata, RooFit::Range(
"signal"));
259 model->paramOn(plot, RooFit::Format(
"NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6, 0.9, 0.9));
260 hdata->plotOn(plot, RooFit::LineColor(kBlue));
261 model->plotOn(plot, RooFit::LineColor(kRed), RooFit::Range(
"signal"), RooFit::NormRange(
"signal"));
274 m_gCharge->SetPoint(p, i + 0.49, ml->getValV());
275 m_gCharge->SetPointError(p, 0.1, ml->getError());
300 canvas->Pad()->SetFrameFillColor(10);
302 if (hh1->GetEntries() < 100) {
304 canvas->Pad()->SetFillColor(kGray);
306 canvas->Pad()->SetFillColor(kGreen);
309 canvas->Pad()->SetFillColor(kWhite);
317 if (hh1->GetEntries() >= 1000) enough =
true;
322 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
329 for (
int s = 1; s <= 6; s++) {
330 for (
int d = 1; d <= 4; d++) {
331 std::string name =
"PXD_Track_Cluster_Charge_" + (std::string)
m_PXDModules[i] + Form(
"_sw%d_dcd%d", s, d);
332 std::replace(name.begin(), name.end(),
'.',
'_');
342 if (hh1->GetEntries() > 50) {
343 auto hdata =
new RooDataHist(hh1->GetName(), hh1->GetTitle(), *
m_x, (
const TH1*) hh1);
344 auto plot =
m_x->frame(RooFit::Title(hh1->GetTitle()));
345 model->fitTo(*hdata, RooFit::Range(
"signal"));
348 model->paramOn(plot, RooFit::Format(
"NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6, 0.9, 0.9));
349 hdata->plotOn(plot, RooFit::LineColor(kBlue));
350 model->plotOn(plot, RooFit::LineColor(kRed), RooFit::Range(
"signal"), RooFit::NormRange(
"signal"));
379 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
381 ax->SetBinLabel(i + 1, ModuleName);
383 }
else B2ERROR(
"no axis");
391 static std::map <int, TLatex*> ltmap;
394 tt =
new TLatex(it + 0.5, 0, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
395 tt->SetTextSize(0.035);
396 tt->SetTextAngle(90);
397 tt->SetTextAlign(12);
413 double maxi = mean + 15;
414 double mini = mean - 15;
443 if (fabs(data - 30.) > 20. || diff > 12) {
446 }
else if (fabs(data - 30) > 15. || diff > 8) {
464 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge : endRun called");
470 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: 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)
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.
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)
DQMHistAnalysisPXDTrackChargeModule()
Constructor.
void terminate(void) override final
This method is called at the end of the event processing.
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.
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 facilitate easy access to sensor information of the VXD like coordinate transformations or p...
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference 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.