11 #include <pxd/modules/pxdDQM/PXDInjectionDQMModule.h>
12 #include "TDirectory.h"
31 setDescription(
"Monitor Occupancy after Injection");
32 setPropertyFlags(c_ParallelProcessingCertified);
33 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of the directory where histograms will be placed",
34 std::string(
"PXDINJ"));
35 addParam(
"PXDRawHitsName", m_PXDRawHitsName,
"Name of PXD raw hits", std::string(
""));
36 addParam(
"PXDClusterName", m_PXDClustersName,
"Name of PXD clusters", std::string(
""));
37 addParam(
"eachModule", m_eachModule,
"create for each module",
false);
38 addParam(
"offlineStudy", m_offlineStudy,
"use finest binning and larger range",
false);
39 addParam(
"useClusters", m_useClusters,
"use cluster instead of raw hits",
false);
40 addParam(
"createMaxHist", m_createMaxHist,
"create histo with max occupancy (not mp save!!!)",
false);
44 void PXDInjectionDQMModule::defineHisto()
46 TDirectory* oldDir = gDirectory;
47 if (m_histogramDirectoryName !=
"") {
48 oldDir->mkdir(m_histogramDirectoryName.c_str());
49 oldDir->cd(m_histogramDirectoryName.c_str());
53 hOccAfterInjLER =
new TH1F(
"PXDOccInjLER",
"PXDOccInjLER/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
54 hOccAfterInjHER =
new TH1F(
"PXDOccInjHER",
"PXDOccInjHER/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
55 hEOccAfterInjLER =
new TH1I(
"PXDEOccInjLER",
"PXDEOccInjLER/Time;Time in #mus;Triggers/Time (0.5 #mus bins)", 100000, 0, 50000);
56 hEOccAfterInjHER =
new TH1I(
"PXDEOccInjHER",
"PXDEOccInjHER/Time;Time in #mus;Triggers/Time (0.5 #mus bins)", 100000, 0, 50000);
57 if (m_createMaxHist) {
58 hMaxOccAfterInjLER =
new TH1F(
"PXDMaxOccInjLER",
"PXDMaxOccInjLER/Time;Time in #mus;Triggers/Time (0.5 #mus bins)", 100000, 0,
60 hMaxOccAfterInjHER =
new TH1F(
"PXDMaxOccInjHER",
"PXDMaxOccInjHER/Time;Time in #mus;Triggers/Time (0.5 #mus bins)", 100000, 0,
65 hOccAfterInjLER =
new TH1F(
"PXDOccInjLER",
"PXDOccInjLER/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
66 hOccAfterInjHER =
new TH1F(
"PXDOccInjHER",
"PXDOccInjHER/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
67 hEOccAfterInjLER =
new TH1I(
"PXDEOccInjLER",
"PXDEOccInjLER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
68 hEOccAfterInjHER =
new TH1I(
"PXDEOccInjHER",
"PXDEOccInjHER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
69 if (m_createMaxHist) {
70 hMaxOccAfterInjLER =
new TH1F(
"PXDMaxOccInjLER",
"PXDMaxOccInjLER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
71 hMaxOccAfterInjHER =
new TH1F(
"PXDMaxOccInjHER",
"PXDMaxOccInjHER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
77 std::vector<VxdID> sensors = m_vxdGeometry.getListOfSensors();
78 for (
VxdID& avxdid : sensors) {
80 if (info.getType() != VXD::SensorInfoBase::PXD)
continue;
83 TString buff = (std::string)avxdid;
84 TString bufful = buff;
85 bufful.ReplaceAll(
".",
"_");
90 hOccModAfterInjLER[avxdid] =
new TH1F(
"PXDOccInjLER_" + bufful,
91 "PXDOccModInjLER " + buff +
"/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
92 hOccModAfterInjHER[avxdid] =
new TH1F(
"PXDOccInjHER_" + bufful,
93 "PXDOccModInjHER " + buff +
"/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
94 if (m_createMaxHist) {
95 hMaxOccModAfterInjLER[avxdid] =
new TH1F(
"PXDMaxOccInjLER_" + bufful,
96 "PXDMaxOccModInjLER " + buff +
"/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
97 hMaxOccModAfterInjHER[avxdid] =
new TH1F(
"PXDMaxOccInjHER_" + bufful,
98 "PXDMaxOccModInjHER " + buff +
"/Time;Time in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
101 hOccModAfterInjLER[avxdid] =
new TH1F(
"PXDOccInjLER_" + bufful,
102 "PXDOccModInjLER " + buff +
"/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
103 hOccModAfterInjHER[avxdid] =
new TH1F(
"PXDOccInjHER_" + bufful,
104 "PXDOccModInjHER " + buff +
"/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
105 if (m_createMaxHist) {
106 hMaxOccModAfterInjLER[avxdid] =
new TH1F(
"PXDMaxOccInjLER_" + bufful,
107 "PXDMaxOccModInjLER " + buff +
"/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
108 hMaxOccModAfterInjHER[avxdid] =
new TH1F(
"PXDMaxOccInjHER_" + bufful,
109 "PXDMaxOccModInjHER " + buff +
"/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
122 hTriggersAfterTrigger =
new TH1I(
"PXDTriggersAfterLast",
123 "PXD Trigger after Last Trigger;Time diff in #mus;Count/Time (0.5 #mus bins)", 100000, 0, 50000);
124 hTriggersPerBunch =
new TH1I(
"PXDTriggerBunch",
"PXD Trigger per Bunch;Bunch/4;Triggers", 1280, 0, 1280);
131 void PXDInjectionDQMModule::initialize()
134 m_rawTTD.isOptional();
136 m_storeClusters.isRequired(m_PXDClustersName);
138 m_storeRawHits.isRequired(m_PXDRawHitsName);
142 void PXDInjectionDQMModule::beginRun()
145 if (hOccAfterInjLER) hOccAfterInjLER->Reset();
146 if (hOccAfterInjHER) hOccAfterInjHER->Reset();
147 if (hEOccAfterInjLER) hEOccAfterInjLER->Reset();
148 if (hEOccAfterInjHER) hEOccAfterInjHER->Reset();
149 if (hMaxOccAfterInjLER) hMaxOccAfterInjLER->Reset();
150 if (hMaxOccAfterInjHER) hMaxOccAfterInjHER->Reset();
151 for (
auto& a : hOccModAfterInjLER)
if (a.second) a.second->Reset();
152 for (
auto& a : hOccModAfterInjHER)
if (a.second) a.second->Reset();
153 for (
auto& a : hMaxOccModAfterInjLER)
if (a.second) a.second->Reset();
154 for (
auto& a : hMaxOccModAfterInjHER)
if (a.second) a.second->Reset();
155 for (
auto& a : hOccModAfterInjLERGate)
if (a.second) a.second->Reset();
156 for (
auto& a : hOccModAfterInjHERGate)
if (a.second) a.second->Reset();
159 hTriggersAfterTrigger->Reset();
160 hTriggersPerBunch->Reset();
163 void PXDInjectionDQMModule::event()
166 for (
auto& it : m_rawTTD) {
167 B2DEBUG(29,
"TTD FTSW : " << hex << it.GetTTUtime(0) <<
" " << it.GetTTCtime(0) <<
" EvtNr " << it.GetEveNo(0) <<
" Type " <<
168 (it.GetTTCtimeTRGType(0) & 0xF) <<
" TimeSincePrev " << it.GetTimeSincePrevTrigger(0) <<
" TimeSinceInj " <<
169 it.GetTimeSinceLastInjection(0) <<
" IsHER " << it.GetIsHER(0) <<
" Bunch " << it.GetBunchNumber(0));
172 hTriggersAfterTrigger->Fill(it.GetTimeSincePrevTrigger(0) / 127.);
173 hTriggersPerBunch->Fill(it.GetBunchNumber(0));
175 auto difference = it.GetTimeSinceLastInjection(0);
177 if (difference != 0x7FFFFFFF) {
179 unsigned int all = 0;
180 std::map <VxdID, int> freq;
182 for (
auto& p : m_storeClusters) {
183 freq[p.getSensorID()]++;
187 for (
auto& p : m_storeRawHits) {
188 freq[p.getSensorID()]++;
192 float diff2 = difference / 127.;
193 if (it.GetIsHER(0)) {
194 hOccAfterInjHER->Fill(diff2, all);
195 hEOccAfterInjHER->Fill(diff2);
197 if (m_createMaxHist) {
198 auto bin = hMaxOccAfterInjHER->FindBin(diff2);
199 auto value = hMaxOccAfterInjHER->GetBinContent(bin);
200 if (all > value) hMaxOccAfterInjHER->SetBinContent(bin, all);
202 for (
auto& a : hOccModAfterInjHER) {
203 if (a.second) a.second->Fill(diff2, freq[a.first]);
205 if (m_createMaxHist) {
206 for (
auto& a : hMaxOccModAfterInjHER) {
208 auto bin = a.second->FindBin(diff2);
209 auto value = a.second->GetBinContent(bin);
210 if (freq[a.first] > value) a.second->SetBinContent(bin, freq[a.first]);
215 hOccAfterInjLER->Fill(diff2, all);
216 hEOccAfterInjLER->Fill(diff2);
218 if (m_createMaxHist) {
219 auto bin = hMaxOccAfterInjLER->FindBin(diff2);
220 auto value = hMaxOccAfterInjLER->GetBinContent(bin);
221 if (all > value) hMaxOccAfterInjLER->SetBinContent(bin, all);
223 for (
auto& a : hOccModAfterInjLER) {
224 if (a.second) a.second->Fill(diff2, freq[a.first]);
226 if (m_createMaxHist) {
227 for (
auto& a : hMaxOccModAfterInjLER) {
229 auto bin = a.second->FindBin(diff2);
230 auto value = a.second->GetBinContent(bin);
231 if (freq[a.first] > value) a.second->SetBinContent(bin, freq[a.first]);