9 #include <pxd/modules/pxdDQM/PXDRawDQMModule.h>
10 #include <vxd/geometry/GeoCache.h>
12 #include <TDirectory.h>
13 #include <boost/format.hpp>
35 setDescription(
"Monitor raw PXD");
36 setPropertyFlags(c_ParallelProcessingCertified);
37 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of the directory where histograms will be placed",
38 std::string(
"pxdraw"));
40 addParam(
"RawPXDsName", m_storeRawPxdrarrayName,
"The name of the StoreArray of RawPXDs to be processed",
string(
""));
41 addParam(
"PXDRawHitsName", m_storeRawHitsName,
"The name of the StoreArray of PXDRawHits to be processed",
string(
""));
42 addParam(
"PXDRawAdcsName", m_storeRawAdcsName,
"The name of the StoreArray of PXDRawAdcs to be processed",
string(
""));
45 void PXDRawDQMModule::defineHisto()
48 TDirectory* oldDir = gDirectory;
49 if (m_histogramDirectoryName !=
"") {
50 oldDir->mkdir(m_histogramDirectoryName.c_str());
51 oldDir->cd(m_histogramDirectoryName.c_str());
54 hrawPxdPackets =
new TH1F(
"hrawPxdPackets",
"Pxd Raw Packet Nr;Nr per Event", 16, 0, 16);
55 hrawPxdPacketSize =
new TH1F(
"hrawPxdPacketSize",
"Pxd Raw Packetsize;Words per packet", 1024, 0, 1024);
56 hrawPxdHitMapAll =
new TH2F(
"hrawPxdHitMapAll",
57 "Pxd Raw Hit Map Overview;column+(ladder-1)*300+100;row+850*((layer-1)*2+(sensor-1))", 3700 / 50, 0, 3700, 3500 / 50, 0, 3500);
62 hrawPxdHitsCount =
new TH1F(
"hrawPxdCount",
"Pxd Raw Count ;Nr per Event", 8192, 0, 8192);
63 for (
auto i = 0; i < 64; i++) {
64 auto layer = (((i >> 5) & 0x1) + 1);
65 auto ladder = ((i >> 1) & 0xF);
66 auto sensor = ((i & 0x1) + 1);
70 string s = str(format(
"Sensor %d:%d:%d (DHH ID %02Xh)") % layer % ladder % sensor % i);
71 string s2 = str(format(
"_%d.%d.%d") % layer % ladder % sensor);
73 hrawPxdHitMap[i] =
new TH2F((
"hrawPxdHitMap" + s2).c_str(),
74 (
"Pxd Raw Hit Map, " + s +
";column;row").c_str(), 250,
76 hrawPxdChargeMap[i] =
new TH2F((
"hrawPxdChargeMap" + s2).c_str(),
77 (
"Pxd Raw Charge Map, " + s +
";column;row").c_str(), 250, 0, 250, 768, 0, 768);
78 hrawPxdHitsCharge[i] =
new TH1F((
"hrawPxdHitsCharge" + s2).c_str(),
79 (
"Pxd Raw Hit Charge, " + s +
";Charge").c_str(), 256, 0, 256);
80 hrawPxdHitTimeWindow[i] =
new TH1F((
"hrawPxdHitTimeWindow" + s2).c_str(),
81 (
"Pxd Raw Hit Time Window (framenr*192-gate_of_hit), " + s +
";Time [a.u.]").c_str(), 2048, -256, 2048 - 256);
82 hrawPxdGateTimeWindow[i] =
new TH1F((
"hrawPxdGateTimeWindow" + s2).c_str(),
83 (
"Pxd Raw Gate Time Window (framenr*192-triggergate_of_hit), " + s +
";Time [a.u.]").c_str(), 2048, -256, 2048 - 256);
85 hrawPxdHitMap[i] = NULL;
86 hrawPxdChargeMap[i] = NULL;
87 hrawPxdHitsCharge[i] = NULL;
88 hrawPxdHitTimeWindow[i] = NULL;
89 hrawPxdGateTimeWindow[i] = NULL;
97 void PXDRawDQMModule::initialize()
100 m_storeRawPxdrarray.isOptional(m_storeRawPxdrarrayName);
101 m_storeRawHits.isRequired(m_storeRawHitsName);
102 m_storeRawAdcs.isRequired(m_storeRawAdcsName);
103 m_storeDAQEvtStats.isRequired();
106 void PXDRawDQMModule::beginRun()
109 if (hrawPxdPackets) hrawPxdPackets->Reset();
110 if (hrawPxdPacketSize) hrawPxdPacketSize->Reset();
111 if (hrawPxdHitsCount) hrawPxdHitsCount->Reset();
112 if (hrawPxdHitMapAll) hrawPxdHitMapAll->Reset();
113 if (hrawPxdAdcMapAll) hrawPxdAdcMapAll->Reset();
114 for (
int i = 0; i < 64; i++) {
115 if (hrawPxdHitMap[i]) hrawPxdHitMap[i]->Reset();
116 if (hrawPxdChargeMap[i]) hrawPxdChargeMap[i]->Reset();
117 if (hrawPxdHitsCharge[i]) hrawPxdHitsCharge[i]->Reset();
118 if (hrawPxdHitTimeWindow[i]) hrawPxdHitTimeWindow[i]->Reset();
119 if (hrawPxdGateTimeWindow[i]) hrawPxdGateTimeWindow[i]->Reset();
123 void PXDRawDQMModule::event()
125 hrawPxdPackets->Fill(m_storeRawPxdrarray.getEntries());
127 for (
auto& it : m_storeRawPxdrarray) {
128 if (hrawPxdPacketSize) hrawPxdPacketSize->Fill(it.size());
131 if (hrawPxdHitsCount) hrawPxdHitsCount->Fill(m_storeRawHits.getEntries());
133 for (
auto& it : m_storeRawHits) {
135 VxdID currentVxdId = it.getSensorID();
141 const PXDDAQDHEStatus* dhe = (*m_storeDAQEvtStats).findDHE(currentVxdId);
142 if (dhe ==
nullptr) {
143 B2ERROR(
"No DHE found for SensorId: " << currentVxdId);
150 if (dhh_id == 0 || dhh_id >= 64) {
151 B2ERROR(
"SensorId (DHH ID) out of range: " << dhh_id);
154 if (hrawPxdHitMap[dhh_id]) hrawPxdHitMap[dhh_id]->Fill(it.getColumn(), it.getRow());
155 if (hrawPxdHitMapAll) hrawPxdHitMapAll->Fill(it.getColumn() + ladder * 300 - 200,
156 100 + it.getRow() + 850 * (layer + layer + sensor - 3));
157 if (hrawPxdChargeMap[dhh_id]) hrawPxdChargeMap[dhh_id]->Fill(it.getColumn(), it.getRow(), it.getCharge());
158 if (hrawPxdHitsCharge[dhh_id]) hrawPxdHitsCharge[dhh_id]->Fill(it.getCharge());
161 if (hrawPxdHitTimeWindow[dhh_id]) hrawPxdHitTimeWindow[dhh_id]->Fill(it.getFrameNr() * 192 - it.getRow() / 4);
162 if (hrawPxdGateTimeWindow[dhh_id]) hrawPxdGateTimeWindow[dhh_id]->Fill(it.getFrameNr() * 192 - startGate);
165 if (hrawPxdAdcMapAll) {
166 for (
auto& it : m_storeRawAdcs) {
169 unsigned int layer, ladder, sensor;
171 currentVxdId = it.getSensorID();
176 dhh_id = ((layer - 1) << 5) | ((ladder) << 1) | (sensor - 1);
177 if (dhh_id <= 0 || dhh_id >= 64) {
178 B2ERROR(
"SensorId (DHH ID) out of range: " << dhh_id);
182 unsigned int chip_offset;
183 chip_offset = it.getChip() * 64;
184 const unsigned char* data = &it.getData()[0];
185 for (
int row = 0; row < 768; row++) {
186 for (
int col = 0; col < 64; col++) {
187 hrawPxdAdcMapAll->Fill(col + chip_offset + ladder * 300 - 200, 100 + row + 850 * (layer + layer + sensor - 3), *(data++));
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
The PXD DAQ DHE Status class.
unsigned short getTriggerGate(void) const
get Trigger Gate
unsigned short getDHEID(void) const
Get DHE ID of sensor.
static GeoCache & getInstance()
Return a reference to the singleton instance.
bool validSensorID(Belle2::VxdID id) const
Check that id is a valid sensor number.
Class to uniquely identify a any structure of the PXD and SVD.
baseType getSensorNumber() const
Get the sensor id.
baseType getLadderNumber() const
Get the ladder id.
baseType getLayerNumber() const
Get the layer id.
#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.