13#include <dqm/analysis/modules/DQMHistAnalysisPXDTrackCharge.h>
17#include <vxd/geometry/GeoCache.h>
19#include <RooDataHist.h>
48 addParam(
"ColorAlert",
m_color,
"Whether to show the color alert",
true);
50 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: Constructor done.");
59 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: initialized.");
64 m_rfws =
new RooWorkspace(
"w");
65 m_rfws->factory(
"Landau::landau(x[0,100],ml[20,10,50],sl[5,1,30])");
66 m_rfws->factory(
"Gaussian::gauss(x,mg[0],sg[2,0.1,10])");
67 m_rfws->factory(
"FCONV::lxg(x,landau,gauss)");
74 for (
VxdID& aVxdID : sensors) {
79 std::string name =
"PXD_Track_Cluster_Charge_" + (std::string)aVxdID;
80 std::replace(name.begin(), name.end(),
'.',
'_');
82 if (aVxdID ==
VxdID(
"1.5.1")) {
83 for (
int s = 0; s < 6; s++) {
84 for (
int d = 0; d < 4; d++) {
89 (
"PXD TCCharge MPV " + name +
";Switcher;DCD;MPV").data(),
90 6, 0.5, 6.5, 4, 0.5, 4.5);
96 B2WARNING(
"No PXDModules in Geometry found! Use hard-coded setup.");
97 std::vector <string> mod = {
98 "1.1.1",
"1.1.2",
"1.2.1",
"1.2.2",
"1.3.1",
"1.3.2",
"1.4.1",
"1.4.2",
99 "1.5.1",
"1.5.2",
"1.6.1",
"1.6.2",
"1.7.1",
"1.7.2",
"1.8.1",
"1.8.2",
100 "2.1.1",
"2.1.2",
"2.2.1",
"2.2.2",
"2.3.1",
"2.3.2",
"2.4.1",
"2.4.2",
101 "2.5.1",
"2.5.2",
"2.6.1",
"2.6.2",
"2.7.1",
"2.7.2",
"2.8.1",
"2.8.2",
102 "2.9.1",
"2.9.2",
"2.10.1",
"2.10.2",
"2.11.1",
"2.11.2",
"2.12.1",
"2.12.2"
111 m_hTrackedClusters =
new TH1F(
"hPXDTrackedClusters",
"PXD Tracked Clusters/Event;Module", 40, 0, 40);
116 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
118 ax->SetBinLabel(i + 1, ModuleName);
120 }
else B2ERROR(
"no axis");
126 m_gCharge->SetName(
"Track_Cluster_Charge");
127 m_gCharge->SetTitle(
"Track Cluster Charge");
148 m_fMean->SetLineColor(kYellow);
162 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge: beginRun called.");
171 gStyle->SetOptStat(0);
172 gStyle->SetStatStyle(1);
173 gStyle->SetOptDate(22);
179 auto model =
m_rfws->pdf(
"lxg");
181 auto ml =
m_rfws->var(
"ml");
187 std::string name =
"Tracked_Clusters";
194 auto scale = hh2->GetBinContent(0);
197 for (
int i = 0; i < 64; i++) {
198 auto layer = (((i >> 5) & 0x1) + 1);
199 auto ladder = ((i >> 1) & 0xF);
200 auto sensor = ((i & 0x1) + 1);
239 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
241 if (canvas ==
nullptr)
continue;
243 std::string name =
"PXD_Track_Cluster_Charge_" + (std::string)
m_PXDModules[i];
244 std::replace(name.begin(), name.end(),
'.',
'_');
252 if (hh1->GetEntries() > 50) {
254 auto hdata =
new RooDataHist(hh1->GetName(), hh1->GetTitle(), *
m_x, (
const TH1*) hh1);
255 auto plot =
m_x->frame(RooFit::Title(hh1->GetTitle()));
256 model->fitTo(*hdata, RooFit::Range(
"signal"));
258 model->paramOn(plot, RooFit::Format(
"NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6, 0.9, 0.9));
259 hdata->plotOn(plot, RooFit::LineColor(kBlue));
260 model->plotOn(plot, RooFit::LineColor(kRed), RooFit::Range(
"signal"), RooFit::NormRange(
"signal"));
273 m_gCharge->SetPoint(p, i + 0.49, ml->getValV());
274 m_gCharge->SetPointError(p, 0.1, ml->getError());
299 canvas->Pad()->SetFrameFillColor(10);
301 if (hh1->GetEntries() < 100) {
303 canvas->Pad()->SetFillColor(kGray);
305 canvas->Pad()->SetFillColor(kGreen);
308 canvas->Pad()->SetFillColor(kWhite);
316 if (hh1->GetEntries() >= 1000) enough =
true;
321 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
328 for (
int s = 1; s <= 6; s++) {
329 for (
int d = 1; d <= 4; d++) {
330 std::string name =
"PXD_Track_Cluster_Charge_" + (std::string)
m_PXDModules[i] + Form(
"_sw%d_dcd%d", s, d);
331 std::replace(name.begin(), name.end(),
'.',
'_');
341 if (hh1->GetEntries() > 50) {
342 auto hdata =
new RooDataHist(hh1->GetName(), hh1->GetTitle(), *
m_x, (
const TH1*) hh1);
343 auto plot =
m_x->frame(RooFit::Title(hh1->GetTitle()));
344 model->fitTo(*hdata, RooFit::Range(
"signal"));
347 model->paramOn(plot, RooFit::Format(
"NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6, 0.9, 0.9));
348 hdata->plotOn(plot, RooFit::LineColor(kBlue));
349 model->plotOn(plot, RooFit::LineColor(kRed), RooFit::Range(
"signal"), RooFit::NormRange(
"signal"));
378 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
380 ax->SetBinLabel(i + 1, ModuleName);
382 }
else B2ERROR(
"no axis");
390 static std::map <int, TLatex*> ltmap;
393 tt =
new TLatex(it + 0.5, 0, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
394 tt->SetTextSize(0.035);
395 tt->SetTextAngle(90);
396 tt->SetTextAlign(12);
412 double maxi = mean + 15;
413 double mini = mean - 15;
442 if (fabs(data - 30.) > 20. || diff > 12) {
445 }
else if (fabs(data - 30) > 15. || diff > 8) {
463 B2DEBUG(99,
"DQMHistAnalysisPXDTrackCharge : endRun called");
469 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 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.