11 #include <pxd/modules/pxdDQM/PXDRawDQMChipsModule.h>
12 #include <vxd/geometry/GeoCache.h>
14 #include <TDirectory.h>
15 #include <boost/format.hpp>
37 setDescription(
"Monitor raw PXD");
38 setPropertyFlags(c_ParallelProcessingCertified);
39 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of the directory where histograms will be placed",
40 std::string(
"pxdraw"));
42 addParam(
"PXDRawHitsName", m_storeRawHitsName,
"The name of the StoreArray of PXDRawHits to be processed",
string(
""));
45 void PXDRawDQMChipsModule::defineHisto()
48 TDirectory* oldDir = gDirectory;
49 if (m_histogramDirectoryName !=
"") {
50 oldDir->mkdir(m_histogramDirectoryName.c_str());
51 oldDir->cd(m_histogramDirectoryName.c_str());
55 for (
auto i = 0; i < 64; i++) {
56 auto layer = (((i >> 5) & 0x1) + 1);
57 auto ladder = ((i >> 1) & 0xF);
58 auto sensor = ((i & 0x1) + 1);
62 for (
auto j = 0; j < eNumSwitcher; j++) {
63 for (
auto k = 0; k < eNumDCD; k++) {
64 string s = str(format(
"Sensor %d:%d:%d (DHH ID %02Xh) Switcher %d DCD %d") % layer % ladder % sensor % i % j % k);
65 string s2 = str(format(
"_%d.%d.%d_%d_%d") % layer % ladder % sensor % j % k);
67 hrawPxdHitsCount[i][j][k] =
new TH1F((
"hrawPxdCount" + s2).c_str(), (
"Pxd Raw Count " + s +
";Nr per Event").c_str(), 8192, 0,
69 hrawPxdHitsCharge[i][j][k] =
new TH1F((
"hrawPxdHitsCharge" + s2).c_str(),
70 (
"Pxd Raw Hit Charge, " + s +
";Charge").c_str(), 256, 0, 256);
74 for (
auto j = 0; j < eNumSwitcher; j++) {
75 for (
auto k = 0; k < eNumDCD; k++) {
76 hrawPxdHitsCount[i][j][k] = NULL;
77 hrawPxdHitsCharge[i][j][k] = NULL;
87 void PXDRawDQMChipsModule::initialize()
90 m_storeRawHits.isRequired(m_storeRawHitsName);
93 void PXDRawDQMChipsModule::beginRun()
96 for (
auto i = 0; i < eNumSensors; i++) {
97 for (
auto j = 0; j < eNumSwitcher; j++) {
98 for (
auto k = 0; k < eNumDCD; k++) {
99 if (hrawPxdHitsCount[i][j][k]) hrawPxdHitsCount[i][j][k]->Reset();
100 if (hrawPxdHitsCharge[i][j][k]) hrawPxdHitsCharge[i][j][k]->Reset();
106 void PXDRawDQMChipsModule::event()
108 uint nhits[eNumSensors][eNumSwitcher][eNumDCD] = {};
110 for (
auto& it : m_storeRawHits) {
113 unsigned int layer, ladder, sensor;
115 currentVxdId = it.getSensorID();
120 dhh_id = ((layer - 1) << 5) | ((ladder) << 1) | (sensor - 1);
121 if (dhh_id <= 0 || dhh_id >= 64) {
122 B2ERROR(
"SensorId (DHH ID) out of range: " << dhh_id);
125 int switcher = it.getRow() / 128;
126 int dcd = it.getColumn() / 64;
128 nhits[dhh_id][switcher][dcd]++;
129 if (hrawPxdHitsCharge[dhh_id][switcher][dcd]) hrawPxdHitsCharge[dhh_id][switcher][dcd]->Fill(it.getCharge());
131 for (
auto i = 0; i < eNumSensors; i++) {
132 for (
auto j = 0; j < eNumSwitcher; j++) {
133 for (
auto k = 0; k < eNumDCD; k++) {
134 if (hrawPxdHitsCount[i][j][k]) hrawPxdHitsCount[i][j][k]->Fill(nhits[i][j][k]);