9 #include <pxd/modules/pxdDQM/PXDDAQDQMModule.h>
11 #include <TDirectory.h>
13 #include <boost/format.hpp>
19 using namespace Belle2::PXD::PXDError;
38 std::string(
"pxdDAQ"));
43 TDirectory* oldDir = gDirectory;
49 hDAQErrorEvent =
new TH1D(
"PXDDAQError",
"PXDDAQError/Event;;Count", ONSEN_USED_TYPE_ERR, 0, ONSEN_USED_TYPE_ERR);
50 hDAQErrorDHC =
new TH2D(
"PXDDAQDHCError",
"PXDDAQError/DHC;DHC ID;", 16, 0, 16, ONSEN_USED_TYPE_ERR, 0, ONSEN_USED_TYPE_ERR);
51 hDAQErrorDHE =
new TH2D(
"PXDDAQDHEError",
"PXDDAQError/DHE;DHE ID;", 64, 0, 64, ONSEN_USED_TYPE_ERR, 0, ONSEN_USED_TYPE_ERR);
52 hDAQUseableModule =
new TH1D(
"PXDDAQUseableModule",
"PXDDAQUseableModule/DHE;DHE ID;", 64, 0, 64);
53 hDAQNotUseableModule =
new TH1D(
"PXDDAQNotUseableModule",
"PXDDAQNotUseableModule/DHE;DHE ID;", 64, 0, 64);
54 hDAQDHPDataMissing =
new TH1D(
"PXDDAQDHPDataMissing",
"PXDDAQDHPDataMissing/DHE*DHP;DHE ID;", 64 * 4, 0, 64);
55 hDAQEndErrorDHC =
new TH2D(
"PXDDAQDHCEndError",
"PXDDAQEndError/DHC;DHC ID;", 16, 0, 16, 32, 0, 32);
56 hDAQEndErrorDHE =
new TH2D(
"PXDDAQDHEEndError",
"PXDDAQEndError/DHE;DHE ID;", 64, 0, 64, 4 * 2 * 8, 0, 4 * 2 * 8);
62 for (
int i = 0; i < ONSEN_USED_TYPE_ERR; i++) {
63 const char* label = getPXDBitErrorName(i).c_str();
72 for (
VxdID& avxdid : sensors) {
77 TString buff = (std::string)avxdid;
78 TString bufful = buff;
79 buff.ReplaceAll(
".",
"_");
85 "TriggerGate DHE " + buff +
"; Trigger Gate; Counts", 192, 0, 192);
86 hDAQDHEReduction[avxdid] =
new TH1D(
"PXDDAQDHEDataReduction_" + bufful,
"Data Reduction DHE " + buff +
"; Raw/Red; Counts", 200, 0,
88 hDAQCM[avxdid] =
new TH2D(
"PXDDAQCM_" + bufful,
"Common Mode on DHE " + buff +
"; Gate+Chip*192; Common Mode", 192 * 4, 0, 192 * 4,
90 hDAQCM2[avxdid] =
new TH1D(
"PXDDAQCM2_" + bufful,
"Common Mode on DHE " + buff +
"; Common Mode", 64, 0, 64);
92 for (
int i = 0; i < 16; i++) {
93 hDAQDHCReduction[i] =
new TH1D((
"PXDDAQDHCDataReduction_" + str(format(
"%d") % i)).c_str(),
94 (
"Data Reduction DHC " + str(format(
" %d") % i) +
"; Raw/Red; Counts").c_str(), 200, 0,
100 hEODBAfterInjLER =
new TH1I(
"PXDEODBInjLER",
"PXDEODBInjLER/Time;Time in #mus;Events/Time (5 #mus bins)", 4000, 0, 20000);
101 hEODBAfterInjHER =
new TH1I(
"PXDEODBInjHER",
"PXDEODBInjHER/Time;Time in #mus;Events/Time (5 #mus bins)", 4000, 0, 20000);
102 hCM63AfterInjLER =
new TH1I(
"PXDCM63InjLER",
"PXDCM63InjLER/Time;Time in #mus;Events/Time (5 #mus bins)", 4000, 0, 20000);
103 hCM63AfterInjHER =
new TH1I(
"PXDCM63InjHER",
"PXDCM63InjHER/Time;Time in #mus;Events/Time (5 #mus bins)", 4000, 0, 20000);
104 hTruncAfterInjLER =
new TH1I(
"PXDTruncInjLER",
"PXDTruncInjLER/Time;Time in #mus;Events/Time (5 #mus bins)", 4000, 0, 20000);
105 hTruncAfterInjHER =
new TH1I(
"PXDTruncInjHER",
"PXDTruncInjHER/Time;Time in #mus;Events/Time (5 #mus bins)", 4000, 0, 20000);
106 hMissAfterInjLER =
new TH1I(
"PXDMissInjLER",
"PXDMissInjLER/Time;Time in #mus;Events/Time (5 #mus bins)", 4000, 0, 20000);
107 hMissAfterInjHER =
new TH1I(
"PXDMissInjHER",
"PXDMissInjHER/Time;Time in #mus;Events/Time (5 #mus bins)", 4000, 0, 20000);
108 hEODBTrgDiff =
new TH1I(
"PXDEODBTrgDiff",
"PXDEODBTrgDiff/DiffTime;DiffTime in #mus;Events/Time (1 #mus bins)", 2000, 0, 2000);
109 hCM63TrgDiff =
new TH1I(
"PXDCM63TrgDiff",
"PXDCM63TrgDiff/DiffTime;DiffTime in #mus;Events/Time (1 #mus bins)", 2000, 0, 2000);
110 hTruncTrgDiff =
new TH1I(
"PXDTruncTrgDiff",
"PXDTruncTrgDiff/DiffTime;DiffTime in #mus;Events/Time (1 #mus bins)", 2000, 0, 2000);
111 hMissTrgDiff =
new TH1I(
"PXDMissTrgDiff",
"PXDMissTrgDiff/DiffTime;DiffTime in #mus;Events/Time (1 #mus bins)", 2000, 0, 2000);
113 hDAQStat =
new TH1D(
"PXDDAQStat",
"PXDDAQStat", 20, 0, 20);
117 xa->SetBinLabel(0 + 1,
"EODB/HLT rej");
118 xa->SetBinLabel(1 + 1,
"Trunc 8%");
119 xa->SetBinLabel(2 + 1,
"HER Trunc");
120 xa->SetBinLabel(3 + 1,
"LER Trunc");
121 xa->SetBinLabel(4 + 1,
"CM63");
122 xa->SetBinLabel(5 + 1,
"HER CM63");
123 xa->SetBinLabel(6 + 1,
"LER CM63");
124 xa->SetBinLabel(7 + 1,
"HER CM63>1ms");
125 xa->SetBinLabel(8 + 1,
"LER CM63>1ms");
126 xa->SetBinLabel(9 + 1,
"HER Trunc>1ms");
127 xa->SetBinLabel(10 + 1,
"LER Trunc>1ms");
128 xa->SetBinLabel(11 + 1,
"MissFrame");
129 xa->SetBinLabel(12 + 1,
"Timeout");
130 xa->SetBinLabel(13 + 1,
"Link Down");
131 xa->SetBinLabel(14 + 1,
"Mismatch");
132 xa->SetBinLabel(15 + 1,
"HER MissFrame");
133 xa->SetBinLabel(16 + 1,
"LER MissFrame");
134 xa->SetBinLabel(17 + 1,
"HER MissFrame>1ms");
135 xa->SetBinLabel(18 + 1,
"LER MissFrame>1ms");
136 xa->SetBinLabel(19 + 1,
"unused");
163 for (
auto& it :
hDAQCM)
if (it.second) it.second->Reset();
164 for (
auto& it :
hDAQCM2)
if (it.second) it.second->Reset();
181 for (
auto& it :
hDAQCM2)
if (it.second) it.second->Fill(-1);
182 for (
auto& it :
hDAQCM)
if (it.second) it.second->Fill(-1, -1);
188 bool eodbFlag =
m_rawSVD.getEntries() == 0;
190 bool truncFlag =
false;
191 bool nolinkFlag =
false;
192 bool missingFlag =
false;
193 bool timeoutFlag =
false;
194 bool mismatchFlag =
false;
195 bool cm63Flag =
false;
197 B2DEBUG(20,
"Iterate PXD DAQ Status");
199 auto evt_emask = evt.getErrorMask();
200 for (
int i = 0; i < ONSEN_MAX_TYPE_ERR; i++) {
201 if (evt_emask[i])
hDAQErrorEvent->Fill(getPXDBitErrorName(i).c_str(), 1);
203 B2DEBUG(20,
"Iterate PXD Packets, Err " << evt_emask);
204 for (
auto& pkt : evt) {
205 B2DEBUG(20,
"Iterate PXD DHC in Pkt " << pkt.getPktIndex());
206 for (
auto& dhc : pkt) {
208 auto dhc_emask = dhc.getErrorMask();
209 for (
int i = 0; i < ONSEN_MAX_TYPE_ERR; i++) {
210 if (dhc_emask[i])
hDAQErrorDHC->Fill(dhc.getDHCID(), i);
212 unsigned int cmask = dhc.getEndErrorInfo();
213 for (
int i = 0; i < 32; i++) {
214 unsigned int mask = (1u << i);
218 float red = dhc.getRedCnt() ? float(dhc.getRawCnt()) / dhc.getRedCnt() : 0.;
219 B2DEBUG(98,
"==DHC " << dhc.getDHCID() <<
"(Raw)" << dhc.getRawCnt() <<
" / (Red)" << dhc.getRedCnt() <<
" = " << red);
220 if (red >= 40.) red = 39.999999999;
223 B2DEBUG(20,
"Iterate PXD DHE in DHC " << dhc.getDHCID() <<
" , Err " << dhc_emask);
224 for (
auto& dhe : dhc) {
226 auto dhe_emask = dhe.getErrorMask();
227 B2DEBUG(20,
"DHE " << dhe.getDHEID() <<
" , Err " << dhe_emask);
228 for (
int i = 0; i < ONSEN_MAX_TYPE_ERR; i++) {
229 if (dhe_emask[i])
hDAQErrorDHE->Fill(dhe.getDHEID(), i);
231 if (dhe.isUsable()) {
236 for (
int i = 0; i < 4; i++) {
237 if ((dhe.getDHPFoundMask() & (1 << i)) == 0)
hDAQDHPDataMissing->Fill(dhe.getDHEID() + i * 0.25);
239 for (
auto& dhp : dhe) {
240 truncFlag |= dhp.getTruncated();
242 unsigned int emask = dhe.getEndErrorInfo();
244 for (
int i = 0; i < 4 * 2; i++) {
245 auto sm = (emask >> i * 4) & 0xF;
248 missingFlag |= sm == 0x1;
249 timeoutFlag |= sm == 0x2;
250 nolinkFlag |= sm == 0x3;
252 mismatchFlag |= sm == 0x5;
253 truncFlag |= sm == 0x6;
258 float red = dhe.getRedCnt() ? float(dhe.getRawCnt()) / dhe.getRedCnt() : 0.;
259 B2DEBUG(98,
"==DHE " << dhe.getSensorID() <<
"(Raw)" << dhe.getRawCnt() <<
" / (Red)" << dhe.getRedCnt() <<
" = " << red);
260 if (red >= 40.) red = 39.999999999;
263 for (
auto cm = dhe.cm_begin(); cm < dhe.cm_end(); ++cm) {
265 if (
hDAQCM[dhe.getSensorID()])
hDAQCM[dhe.getSensorID()]->Fill(std::get<0>(*cm) * 192 + std::get<1>(*cm) / 4, std::get<2>(*cm));
266 if (
hDAQCM2[dhe.getSensorID()])
hDAQCM2[dhe.getSensorID()]->Fill(std::get<2>(*cm));
273 cm63Flag |= 63 == std::get<2>(*cm);
285 double lasttrig = it.GetTimeSincePrevTrigger(0) / 127.;
292 auto difference = it.GetTimeSinceLastInjection(0);
294 if (difference != 0x7FFFFFFF) {
295 double diff2 = difference / 127.;
296 if (it.GetIsHER(0)) {
302 if (diff2 > 1000)
hDAQStat->Fill(7);
307 if (diff2 > 1000)
hDAQStat->Fill(9);
312 if (diff2 > 1000)
hDAQStat->Fill(17);
321 if (diff2 > 1000)
hDAQStat->Fill(8);
326 if (diff2 > 1000)
hDAQStat->Fill(10);
331 if (diff2 > 1000)
hDAQStat->Fill(18);
342 if (missingFlag)
hDAQStat->Fill(11);
343 if (timeoutFlag)
hDAQStat->Fill(12);
345 if (mismatchFlag)
hDAQStat->Fill(14);
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
TH1I * hCM63AfterInjLER
Histogram of CM63 after LER injection.
void initialize() override final
Initialize.
std::map< VxdID, TH1D * > hDAQDHETriggerGate
DHE Trigger Gate ("start Row")
TH1D * hDAQNotUseableModule
Count Useable/unuseable decision.
StoreObjPtr< PXDDAQStatus > m_storeDAQEvtStats
Input array for DAQ Status.
TH1I * hTruncAfterInjHER
Histogram Truncation after HER injection.
StoreArray< RawSVD > m_rawSVD
Input array for SVD/x-check HLT EODB .
TH1D * hDAQErrorEvent
Remark: Because of DHH load balancing and sub event building, the very same DHE and DHC can show up i...
StoreArray< RawFTSW > m_rawTTD
Input array for TTD/FTSW.
TH1I * hEODBTrgDiff
Histogram of EODB after last trigger.
std::map< VxdID, TH2D * > hDAQCM
Common Mode per DHE to gate and DHP level.
TH1D * hDAQUseableModule
Count Useable/unuseable decision.
void defineHisto() override final
Define histograms.
TH1I * hMissTrgDiff
Histogram MissFrame after last trigger.
TH1I * hMissAfterInjHER
Histogram MissFrame after HER injection.
void event() override final
Event.
TH2D * hDAQErrorDHC
individual DHC errors
TH2D * hDAQEndErrorDHE
individual DHE END errors
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
TH1I * hCM63TrgDiff
Histogram of CM63 after last trigger.
TH1I * hCM63AfterInjHER
Histogram of CM63 after HER injection.
TH1I * hTruncTrgDiff
Histogram Truncation after last trigger.
std::map< VxdID, TH1D * > hDAQDHEReduction
DHE data reduction
TH1I * hEODBAfterInjHER
Histogram of EODB after HER injection.
TH2D * hDAQEndErrorDHC
individual DHC END errors
TH2D * hDAQErrorDHE
individual DHE errors
void beginRun() override final
Begin run.
std::map< VxdID, TH1D * > hDAQCM2
Common Mode per DHE to gate and DHP level.
VXD::GeoCache & m_vxdGeometry
the geometry
TH1I * hMissAfterInjLER
Histogram MissFrame after LER injection.
TH1D * hDAQDHPDataMissing
Count Missing DHP data.
std::map< int, TH1D * > hDAQDHCReduction
DHC data reduction
TH1D * hDAQStat
Histogram for Truncation etc Stats.
TH1I * hTruncAfterInjLER
Histogram Truncation after LER injection.
TH1I * hEODBAfterInjLER
Histogram of EODB after LER injection.
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.
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.
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.