Belle II Software development
DQMHistAnalysisPXDInjection.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8//+
9// File : DQMHistAnalysisPXDInjection.cc
10// Description : DQM module, which gives histograms showing occupancies after injection
11//-
12
13
14#include <dqm/analysis/modules/DQMHistAnalysisPXDInjection.h>
15#include <TROOT.h>
16
17using namespace std;
18using namespace Belle2;
19
20//-----------------------------------------------------------------
21// Register the Module
22//-----------------------------------------------------------------
23REG_MODULE(DQMHistAnalysisPXDInjection);
24
25//-----------------------------------------------------------------
26// Implementation
27//-----------------------------------------------------------------
28
30{
31 // This module CAN NOT be run in parallel!
32 setDescription("DQM Analysis for PXD Hits after Injection");
33
34 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms were placed",
35 std::string("PXDINJ"));
36 B2DEBUG(1, "DQMHistAnalysisPXDInjection: Constructor done.");
37}
38
40{
41
42 gROOT->cd(); // this seems to be important, or strange things happen
43
45 TString("/c_PXDInjectionLER")); // different name, as we have the other module
47 TString("/c_PXDInjectionHER")); // which makes this hist for ALL detectors (SVD, ECl, TOP)
48 m_hInjectionLERPXD = new TH1F("HitInjectionLERPXD", "PXD Hits after LER Injection;Time in #mus;Mean Hits/event", 4000, 0, 20000);
49 m_hInjectionHERPXD = new TH1F("HitInjectionHERPXD", "PXD Hits after HER Injection;Time in #mus;Mean Hits/event", 4000, 0, 20000);
50 const VXD::GeoCache& vxdGeometry = VXD::GeoCache::getInstance();
51 std::vector<VxdID> vxdsensors = vxdGeometry.getListOfSensors();
52 for (const auto& avxdid : vxdsensors) {
53 VXD::SensorInfoBase info = vxdGeometry.getSensorInfo(avxdid);
54 if (info.getType() != VXD::SensorInfoBase::PXD) continue;
55 m_sensors.push_back(avxdid);
56 }
57
58 for (const auto& avxdid : m_sensors) {
59 TString buff = (std::string)avxdid;
60 TString bufful = buff;
61 bufful.ReplaceAll(".", "_");
62
63 m_cInjectionLERPXDMod[avxdid] = new TCanvas(m_histogramDirectoryName + "/c_PXDInjectionLER_" + bufful);
64 m_cInjectionHERPXDMod[avxdid] = new TCanvas(m_histogramDirectoryName + "/c_PXDInjectionHER_" + bufful);
65 m_hInjectionLERPXDMod[avxdid] = new TH1F("HitInjectionLERPXD_" + bufful,
66 "PXD Hits after LER Injection " + buff + "/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
67 m_hInjectionHERPXDMod[avxdid] = new TH1F("HitInjectionHERPXD_" + bufful,
68 "PXD Hits after HER Injection " + buff + "/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
69 m_cInjectionLERPXDModNorm[avxdid] = new TCanvas(m_histogramDirectoryName + "/c_PXDInjectionLERNorm_" + bufful);
70 m_cInjectionHERPXDModNorm[avxdid] = new TCanvas(m_histogramDirectoryName + "/c_PXDInjectionHERNorm_" + bufful);
71 m_hInjectionLERPXDModNorm[avxdid] = new TH1F("HitInjectionLERPXDNorm_" + bufful,
72 "PXD Hits after LER Injection " + buff + " normalized to 1.1.x/Time;Time in #mus;factor", 4000, 0, 20000);
73 m_hInjectionHERPXDModNorm[avxdid] = new TH1F("HitInjectionHERPXDNorm_" + bufful,
74 "PXD Hits after HER Injection " + buff + " normalized to 1.1.x/Time;Time in #mus;factor", 4000, 0, 20000);
75 }
76
77 B2DEBUG(1, "DQMHistAnalysisPXDInjection: initialized.");
78}
79
80
82{
83 B2DEBUG(1, "DQMHistAnalysisPXDInjection: beginRun called.");
84
85// m_cInjectionLERPXD->Clear(); // FIXME, unclear if this lets to crashes on new run?
86// m_cInjectionLERPXDOcc->Clear();
87// m_cInjectionLERECL->Clear();
88// m_cInjectionHERPXD->Clear();
89// m_cInjectionHERPXDOcc->Clear();
90// m_cInjectionHERECL->Clear();
91}
92
93
95{
96 //Finding only one of them should only happen in very strange situations...
97 if (auto Triggers = findHist(m_histogramDirectoryName, "PXDEOccInjLER"); Triggers != nullptr) {
98 if (auto Hits = findHist(m_histogramDirectoryName, "PXDOccInjLER"); Hits != nullptr) {
99 m_hInjectionLERPXD->Divide(Hits, Triggers);
100 }
101 auto RefMod_fw = findHist(m_histogramDirectoryName, "PXDOccInjLER_1_1_1");
102 auto RefMod_bw = findHist(m_histogramDirectoryName, "PXDOccInjLER_1_1_2");
103
104 // assume trigger is the same for all modules (makes sense :-)
105 for (const auto& avxdid : m_sensors) {
106 TString buff = (std::string)avxdid;
107 TString bufful = buff;
108 bufful.ReplaceAll(".", "_");
109
110 if (auto Hits = findHist(m_histogramDirectoryName, ("PXDOccInjLER_" + bufful).Data()); Hits != nullptr) {
111 m_hInjectionLERPXDMod[avxdid]->Divide(Hits, Triggers);
112 if (avxdid.getSensorNumber() == 1 && RefMod_fw) {
113 m_hInjectionLERPXDModNorm[avxdid]->Divide(Hits, RefMod_fw);
114 } else if (avxdid.getSensorNumber() == 2 && RefMod_bw) {
115 m_hInjectionLERPXDModNorm[avxdid]->Divide(Hits, RefMod_bw);
116 }
117 }
118
119 }
120
121 }
122
123 //Finding only one of them should only happen in very strange situations...
124 if (auto Triggers = findHist(m_histogramDirectoryName, "PXDEOccInjHER"); Triggers != nullptr) {
125 if (auto Hits = findHist(m_histogramDirectoryName, "PXDOccInjHER");
126 Hits != 0) {
127 m_hInjectionHERPXD->Divide(Hits, Triggers);
128 }
129 auto RefMod_fw = findHist(m_histogramDirectoryName, "PXDOccInjHER_1_1_1");
130 auto RefMod_bw = findHist(m_histogramDirectoryName, "PXDOccInjHER_1_1_2");
131
132 // assume trigger is the same for all modules (makes sense :-)
133 for (const auto& avxdid : m_sensors) {
134 TString buff = (std::string)avxdid;
135 TString bufful = buff;
136 bufful.ReplaceAll(".", "_");
137 if (auto Hits = findHist(m_histogramDirectoryName, ("PXDOccInjHER_" + bufful).Data());
138 Hits != nullptr) {
139 m_hInjectionHERPXDMod[avxdid]->Divide(Hits, Triggers);
140 if (avxdid.getSensorNumber() == 1 && RefMod_fw) {
141 m_hInjectionHERPXDModNorm[avxdid]->Divide(Hits, RefMod_fw);
142 } else if (avxdid.getSensorNumber() == 2 && RefMod_bw) {
143 m_hInjectionHERPXDModNorm[avxdid]->Divide(Hits, RefMod_bw);
144 }
145 }
146
147
148 }
149 }
150
151 m_cInjectionLERPXD->Clear();
152 m_cInjectionLERPXD->cd(0);
153 m_cInjectionLERPXD->Pad()->SetLogy();
154 m_hInjectionLERPXD->Draw("hist");
155
156 m_cInjectionHERPXD->Clear();
157 m_cInjectionHERPXD->cd(0);
158 m_cInjectionHERPXD->Pad()->SetLogy();
159 m_hInjectionHERPXD->Draw("hist");
160
161 for (const auto& avxdid : m_sensors) {
162 m_cInjectionHERPXDMod[avxdid]->Clear();
163 m_cInjectionHERPXDMod[avxdid]->cd(0);
164 m_cInjectionHERPXDMod[avxdid]->Pad()->SetLogy();
165 m_hInjectionHERPXDMod[avxdid]->Draw("hist");
166 m_cInjectionHERPXDModNorm[avxdid]->Clear();
167 m_cInjectionHERPXDModNorm[avxdid]->cd(0);
168 m_hInjectionHERPXDModNorm[avxdid]->Draw("hist");
169 m_cInjectionLERPXDMod[avxdid]->Clear();
170 m_cInjectionLERPXDMod[avxdid]->cd(0);
171 m_cInjectionLERPXDMod[avxdid]->Pad()->SetLogy();
172 m_hInjectionLERPXDMod[avxdid]->Draw("hist");
173 m_cInjectionLERPXDModNorm[avxdid]->Clear();
174 m_cInjectionLERPXDModNorm[avxdid]->cd(0);
175 m_hInjectionLERPXDModNorm[avxdid]->Draw("hist");
176 }
177}
178
179
181{
186
187 for (const auto& avxdid : m_sensors) {
188 if (m_cInjectionLERPXDMod[avxdid]) delete m_cInjectionLERPXDMod[avxdid];
189 if (m_cInjectionHERPXDMod[avxdid]) delete m_cInjectionHERPXDMod[avxdid];
190 if (m_hInjectionLERPXDMod[avxdid]) delete m_hInjectionLERPXDMod[avxdid];
191 if (m_hInjectionHERPXDMod[avxdid]) delete m_hInjectionHERPXDMod[avxdid];
192 if (m_cInjectionLERPXDModNorm[avxdid]) delete m_cInjectionLERPXDModNorm[avxdid];
193 if (m_cInjectionHERPXDModNorm[avxdid]) delete m_cInjectionHERPXDModNorm[avxdid];
194 if (m_hInjectionLERPXDModNorm[avxdid]) delete m_hInjectionLERPXDModNorm[avxdid];
195 if (m_hInjectionHERPXDModNorm[avxdid]) delete m_hInjectionHERPXDModNorm[avxdid];
196 }
197}
DQMHistAnalysisModule()
Constructor / Destructor.
static TH1 * findHist(const std::string &dirname, const std::string &histname="", bool onlyIfUpdated=false)
Find histogram.
void terminate(void) override final
This method is called at the end of the event processing.
std::map< VxdID, TCanvas * > m_cInjectionLERPXDModNorm
Canvases per sensor for LER normalized.
std::map< VxdID, TH1F * > m_hInjectionHERPXDModNorm
Histogram per sensor for HER normalized.
void initialize(void) override final
Initializer.
std::map< VxdID, TCanvas * > m_cInjectionHERPXDModNorm
Canvases per sensor for HER normalized.
std::string m_histogramDirectoryName
name of histogram directory
std::map< VxdID, TCanvas * > m_cInjectionLERPXDMod
Canvases per sensor for LER.
std::map< VxdID, TH1F * > m_hInjectionHERPXDMod
Histogram per sensor for HER.
std::map< VxdID, TH1F * > m_hInjectionLERPXDMod
Histogram per sensor for LER.
std::map< VxdID, TH1F * > m_hInjectionLERPXDModNorm
Histogram per sensor for LER normalized.
std::vector< VxdID > m_sensors
List of PXD sensors.
std::map< VxdID, TCanvas * > m_cInjectionHERPXDMod
Canvases per sensor for HER.
void beginRun(void) override final
Called when entering a new run.
void event(void) override final
This method is called for each event.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Class to facilitate easy access to sensor information of the VXD like coordinate transformations or p...
Definition GeoCache.h:38
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
Definition GeoCache.cc:59
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference to the SensorInfo of a given SensorID.
Definition GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition GeoCache.cc:214
Base class to provide Sensor Information for PXD and SVD.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.