9 #include <pxd/modules/pxdDQM/PXDInjectionDQMModule.h>
10 #include "TDirectory.h"
29 setDescription(
"Monitor Occupancy after Injection");
30 setPropertyFlags(c_ParallelProcessingCertified);
31 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of the directory where histograms will be placed",
32 std::string(
"PXDINJ"));
33 addParam(
"PXDRawHitsName", m_PXDRawHitsName,
"Name of PXD raw hits", std::string(
""));
34 addParam(
"PXDClusterName", m_PXDClustersName,
"Name of PXD clusters", std::string(
""));
35 addParam(
"eachModule", m_eachModule,
"create for each module",
false);
36 addParam(
"offlineStudy", m_offlineStudy,
"use finest binning and larger range",
false);
37 addParam(
"useClusters", m_useClusters,
"use cluster instead of raw hits",
false);
38 addParam(
"createMaxHist", m_createMaxHist,
"create histo with max occupancy (not mp save!!!)",
false);
39 addParam(
"createGateHist", m_createGateHist,
"create 2d histo with gate against occupancy",
false);
43 void PXDInjectionDQMModule::defineHisto()
45 TDirectory* oldDir = gDirectory;
46 if (m_histogramDirectoryName !=
"") {
47 oldDir->mkdir(m_histogramDirectoryName.c_str());
48 oldDir->cd(m_histogramDirectoryName.c_str());
52 hOccAfterInjLER =
new TH1F(
"PXDOccInjLER",
"PXDOccInjLER/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
53 hOccAfterInjHER =
new TH1F(
"PXDOccInjHER",
"PXDOccInjHER/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
54 hEOccAfterInjLER =
new TH1I(
"PXDEOccInjLER",
"PXDEOccInjLER/Time;Time in #mus;Triggers/Time (0.5 #mus bins)", 100000, 0, 50000);
55 hEOccAfterInjHER =
new TH1I(
"PXDEOccInjHER",
"PXDEOccInjHER/Time;Time in #mus;Triggers/Time (0.5 #mus bins)", 100000, 0, 50000);
56 if (m_createMaxHist) {
57 hMaxOccAfterInjLER =
new TH1F(
"PXDMaxOccInjLER",
"PXDMaxOccInjLER/Time;Time in #mus;Triggers/Time (0.5 #mus bins)", 100000, 0,
59 hMaxOccAfterInjHER =
new TH1F(
"PXDMaxOccInjHER",
"PXDMaxOccInjHER/Time;Time in #mus;Triggers/Time (0.5 #mus bins)", 100000, 0,
62 if (m_createGateHist) {
63 hOccAfterInjLERGate =
new TH2F(
"PXDOccInjLERGate",
"PXDOccInjLERGate;Time;Gate", 1000, 0, 10000, 192, 0, 192);
64 hOccAfterInjHERGate =
new TH2F(
"PXDOccInjHERGate",
"PXDOccInjHERGate;Time;Gate", 1000, 0, 10000, 192, 0, 192);
67 hOccAfterInjLER =
new TH1F(
"PXDOccInjLER",
"PXDOccInjLER/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
68 hOccAfterInjHER =
new TH1F(
"PXDOccInjHER",
"PXDOccInjHER/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
69 hEOccAfterInjLER =
new TH1I(
"PXDEOccInjLER",
"PXDEOccInjLER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
70 hEOccAfterInjHER =
new TH1I(
"PXDEOccInjHER",
"PXDEOccInjHER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
71 if (m_createMaxHist) {
72 hMaxOccAfterInjLER =
new TH1F(
"PXDMaxOccInjLER",
"PXDMaxOccInjLER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
73 hMaxOccAfterInjHER =
new TH1F(
"PXDMaxOccInjHER",
"PXDMaxOccInjHER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
75 if (m_createGateHist) {
76 hOccAfterInjLERGate =
new TH2F(
"PXDOccInjLERGate",
"PXDOccInjLERGate;Time;Gate", 1000, 0, 10000, 192, 0, 192);
77 hOccAfterInjHERGate =
new TH2F(
"PXDOccInjHERGate",
"PXDOccInjHERGate;Time;Gate", 1000, 0, 10000, 192, 0, 192);
82 std::vector<VxdID> sensors = m_vxdGeometry.getListOfSensors();
83 for (
VxdID& avxdid : sensors) {
85 if (info.getType() != VXD::SensorInfoBase::PXD)
continue;
88 TString buff = (std::string)avxdid;
89 TString bufful = buff;
90 bufful.ReplaceAll(
".",
"_");
95 hOccModAfterInjLER[avxdid] =
new TH1F(
"PXDOccInjLER_" + bufful,
96 "PXDOccModInjLER " + buff +
"/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
97 hOccModAfterInjHER[avxdid] =
new TH1F(
"PXDOccInjHER_" + bufful,
98 "PXDOccModInjHER " + buff +
"/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
99 if (m_createMaxHist) {
100 hMaxOccModAfterInjLER[avxdid] =
new TH1F(
"PXDMaxOccInjLER_" + bufful,
101 "PXDMaxOccModInjLER " + buff +
"/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
102 hMaxOccModAfterInjHER[avxdid] =
new TH1F(
"PXDMaxOccInjHER_" + bufful,
103 "PXDMaxOccModInjHER " + buff +
"/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
105 if (m_createGateHist) {
106 hOccModAfterInjLERGate[avxdid] =
new TH2F(
"PXDOccInjLERGate_" + bufful,
"PXDOccInjLERGate " + buff +
";Time;Gate", 1000, 0, 10000,
109 hOccModAfterInjHERGate[avxdid] =
new TH2F(
"PXDOccInjHERGate_" + bufful,
"PXDOccInjHERGate " + buff +
";Time;Gate", 1000, 0, 10000,
114 hOccModAfterInjLER[avxdid] =
new TH1F(
"PXDOccInjLER_" + bufful,
115 "PXDOccModInjLER " + buff +
"/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
116 hOccModAfterInjHER[avxdid] =
new TH1F(
"PXDOccInjHER_" + bufful,
117 "PXDOccModInjHER " + buff +
"/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
118 if (m_createMaxHist) {
119 hMaxOccModAfterInjLER[avxdid] =
new TH1F(
"PXDMaxOccInjLER_" + bufful,
120 "PXDMaxOccModInjLER " + buff +
"/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
121 hMaxOccModAfterInjHER[avxdid] =
new TH1F(
"PXDMaxOccInjHER_" + bufful,
122 "PXDMaxOccModInjHER " + buff +
"/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
124 if (m_createGateHist) {
125 hOccModAfterInjLERGate[avxdid] =
new TH2F(
"PXDOccInjLERGate_" + bufful,
"PXDOccInjLERGate " + buff +
";Time;Gate", 1000, 0, 10000,
128 hOccModAfterInjHERGate[avxdid] =
new TH2F(
"PXDOccInjHERGate_" + bufful,
"PXDOccInjHERGate " + buff +
";Time;Gate", 1000, 0, 10000,
143 hTriggersAfterTrigger =
new TH1I(
"PXDTriggersAfterLast",
144 "PXD Trigger after Last Trigger;Time diff in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
145 hTriggersPerBunch =
new TH1I(
"PXDTriggerBunch",
"PXD Trigger per Bunch;Bunch/4;Triggers", 1280, 0, 1280);
152 void PXDInjectionDQMModule::initialize()
155 m_rawTTD.isOptional();
157 m_storeClusters.isRequired(m_PXDClustersName);
159 m_storeRawHits.isRequired(m_PXDRawHitsName);
163 void PXDInjectionDQMModule::beginRun()
166 if (hOccAfterInjLER) hOccAfterInjLER->Reset();
167 if (hOccAfterInjHER) hOccAfterInjHER->Reset();
168 if (hEOccAfterInjLER) hEOccAfterInjLER->Reset();
169 if (hEOccAfterInjHER) hEOccAfterInjHER->Reset();
170 if (hMaxOccAfterInjLER) hMaxOccAfterInjLER->Reset();
171 if (hMaxOccAfterInjHER) hMaxOccAfterInjHER->Reset();
172 if (hOccAfterInjLERGate) hOccAfterInjLERGate->Reset();
173 if (hOccAfterInjHERGate) hOccAfterInjHERGate->Reset();
174 for (
auto& a : hOccModAfterInjLER)
if (a.second) a.second->Reset();
175 for (
auto& a : hOccModAfterInjHER)
if (a.second) a.second->Reset();
176 for (
auto& a : hMaxOccModAfterInjLER)
if (a.second) a.second->Reset();
177 for (
auto& a : hMaxOccModAfterInjHER)
if (a.second) a.second->Reset();
178 for (
auto& a : hOccModAfterInjLERGate)
if (a.second) a.second->Reset();
179 for (
auto& a : hOccModAfterInjHERGate)
if (a.second) a.second->Reset();
182 hTriggersAfterTrigger->Reset();
183 hTriggersPerBunch->Reset();
186 void PXDInjectionDQMModule::event()
189 for (
auto& it : m_rawTTD) {
190 B2DEBUG(29,
"TTD FTSW : " << hex << it.GetTTUtime(0) <<
" " << it.GetTTCtime(0) <<
" EvtNr " << it.GetEveNo(0) <<
" Type " <<
191 (it.GetTTCtimeTRGType(0) & 0xF) <<
" TimeSincePrev " << it.GetTimeSincePrevTrigger(0) <<
" TimeSinceInj " <<
192 it.GetTimeSinceLastInjection(0) <<
" IsHER " << it.GetIsHER(0) <<
" Bunch " << it.GetBunchNumber(0));
195 hTriggersAfterTrigger->Fill(it.GetTimeSincePrevTrigger(0) / 127.);
196 hTriggersPerBunch->Fill(it.GetBunchNumber(0));
198 auto difference = it.GetTimeSinceLastInjection(0);
200 if (difference != 0x7FFFFFFF) {
202 unsigned int all = 0;
203 std::map <VxdID, int> freq;
205 for (
auto& p : m_storeClusters) {
206 freq[p.getSensorID()]++;
210 for (
auto& p : m_storeRawHits) {
211 freq[p.getSensorID()]++;
215 float diff2 = difference / 127.;
216 if (it.GetIsHER(0)) {
217 hOccAfterInjHER->Fill(diff2, all);
218 hEOccAfterInjHER->Fill(diff2);
220 if (m_createMaxHist) {
221 auto bin = hMaxOccAfterInjHER->FindBin(diff2);
222 auto value = hMaxOccAfterInjHER->GetBinContent(bin);
223 if (all > value) hMaxOccAfterInjHER->SetBinContent(bin, all);
225 for (
auto& a : hOccModAfterInjHER) {
226 if (a.second) a.second->Fill(diff2, freq[a.first]);
228 if (m_createMaxHist) {
229 for (
auto& a : hMaxOccModAfterInjHER) {
231 auto bin = a.second->FindBin(diff2);
232 auto value = a.second->GetBinContent(bin);
233 if (freq[a.first] > value) a.second->SetBinContent(bin, freq[a.first]);
237 if (hOccAfterInjHERGate) {
245 for (
auto& p : m_storeRawHits) {
246 hOccAfterInjHERGate->Fill(diff2, p.getRow() / 4);
247 hOccModAfterInjHERGate[p.getSensorID()]->Fill(diff2, p.getRow() / 4);
252 hOccAfterInjLER->Fill(diff2, all);
253 hEOccAfterInjLER->Fill(diff2);
255 if (m_createMaxHist) {
256 auto bin = hMaxOccAfterInjLER->FindBin(diff2);
257 auto value = hMaxOccAfterInjLER->GetBinContent(bin);
258 if (all > value) hMaxOccAfterInjLER->SetBinContent(bin, all);
260 for (
auto& a : hOccModAfterInjLER) {
261 if (a.second) a.second->Fill(diff2, freq[a.first]);
263 if (m_createMaxHist) {
264 for (
auto& a : hMaxOccModAfterInjLER) {
266 auto bin = a.second->FindBin(diff2);
267 auto value = a.second->GetBinContent(bin);
268 if (freq[a.first] > value) a.second->SetBinContent(bin, freq[a.first]);
273 if (hOccAfterInjLERGate) {
281 for (
auto& p : m_storeRawHits) {
282 hOccAfterInjLERGate->Fill(diff2, p.getRow() / 4);
283 hOccModAfterInjLERGate[p.getSensorID()]->Fill(diff2, p.getRow() / 4);
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
The PXD Occupancy after Injection DQM module.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Base class to provide Sensor Information for PXD and SVD.
Class to uniquely identify a any structure of the PXD and SVD.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Namespace to provide code needed by both Vertex Detectors, PXD and SVD, and also testbeam telescopes.
Abstract base class for different kinds of events.