13 #include "pxd/modules/pxdDQM/PXDDQMExpressRecoModule.h"
15 #include <pxd/geometry/SensorInfo.h>
16 #include <vxd/geometry/GeoCache.h>
17 #include <vxd/geometry/SensorInfoBase.h>
18 #include <vxd/geometry/GeoTools.h>
19 #include <pxd/unpacking/PXDMappingLookup.h>
21 #include <boost/format.hpp>
23 #include "TDirectory.h"
43 setDescription(
"PXD DQM module for Express Reco "
44 "Recommended Number of events for monitor is 40 kEvents or more to fill all histograms "
47 setPropertyFlags(c_ParallelProcessingCertified);
48 addParam(
"CutPXDCharge", m_CutPXDCharge,
49 "cut for accepting to hitmap histogram, using strips only, default = 0.0 ", m_CutPXDCharge);
50 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of the directory where histograms will be placed",
51 std::string(
"PXDER"));
55 PXDDQMExpressRecoModule::~PXDDQMExpressRecoModule()
63 void PXDDQMExpressRecoModule::defineHisto()
65 auto gTools = VXD::GeoCache::getInstance().getGeoTools();
66 if (gTools->getNumberOfLayers() == 0) {
67 B2FATAL(
"Missing geometry for VXD, check steering file.");
69 if (gTools->getNumberOfPXDLayers() == 0) {
70 B2WARNING(
"Missing geometry for PXD, PXD-DQM is skiped.");
75 TDirectory* oldDir = gDirectory;
76 if (m_histogramDirectoryName !=
"") {
77 oldDir->mkdir(m_histogramDirectoryName.c_str());
78 oldDir->cd(m_histogramDirectoryName.c_str());
82 int nPXDSensors = gTools->getNumberOfPXDSensors();
83 int nPXDChips = gTools->getTotalPXDChips();
86 m_hitMapCounts =
new TH1D(
"DQMER_PXD_PixelHitmapCounts",
"DQM ER PXD Integrated number of fired pixels per sensor",
87 nPXDSensors, 0, nPXDSensors);
88 m_hitMapCounts->GetXaxis()->SetTitle(
"Sensor ID");
89 m_hitMapCounts->GetYaxis()->SetTitle(
"counts");
90 m_hitMapClCounts =
new TH1D(
"DQMER_PXD_ClusterHitmapCounts",
"DQM ER PXD Integrated number of clusters per sensor",
91 nPXDSensors, 0, nPXDSensors);
92 m_hitMapClCounts->GetXaxis()->SetTitle(
"Sensor ID");
93 m_hitMapClCounts->GetYaxis()->SetTitle(
"counts");
95 m_hitMapCountsChip =
new TH1D(
"DQMER_PXD_PixelHitmapCountsChip",
"DQM ER PXD Integrated number of fired pixels per chip",
96 nPXDChips, 0, nPXDChips);
97 m_hitMapCountsChip->GetXaxis()->SetTitle(
"Chip ID");
98 m_hitMapCountsChip->GetYaxis()->SetTitle(
"counts");
99 m_hitMapClCountsChip =
new TH1D(
"DQMER_PXD_ClusterHitmapCountsChip",
"DQM ER PXD Integrated number of clusters per chip",
100 nPXDChips, 0, nPXDChips);
101 m_hitMapClCountsChip->GetXaxis()->SetTitle(
"Chip ID");
102 m_hitMapClCountsChip->GetYaxis()->SetTitle(
"counts");
103 for (
int i = 0; i < nPXDChips; i++) {
104 VxdID id = gTools->getChipIDFromPXDIndex(i);
106 int iLadder =
id.getLadderNumber();
107 int iSensor =
id.getSensorNumber();
108 int iChip = gTools->getPXDChipNumber(
id);
109 int IsU = gTools->isPXDSideU(
id);
110 TString AxisTicks = Form(
"%i_%i_%i_u%iDCD", iLayer, iLadder, iSensor, iChip);
112 AxisTicks = Form(
"%i_%i_%i_v%iSWB", iLayer, iLadder, iSensor, iChip);
113 m_hitMapCountsChip->GetXaxis()->SetBinLabel(i + 1, AxisTicks.Data());
114 m_hitMapClCountsChip->GetXaxis()->SetBinLabel(i + 1, AxisTicks.Data());
117 for (
int i = 0; i < nPXDSensors; i++) {
118 VxdID id = gTools->getSensorIDFromPXDIndex(i);
120 int iLadder =
id.getLadderNumber();
121 int iSensor =
id.getSensorNumber();
122 TString AxisTicks = Form(
"%i_%i_%i", iLayer, iLadder, iSensor);
123 m_hitMapCounts->GetXaxis()->SetBinLabel(i + 1, AxisTicks.Data());
124 m_hitMapClCounts->GetXaxis()->SetBinLabel(i + 1, AxisTicks.Data());
127 m_fired.resize(nPXDSensors);
128 m_clusters.resize(nPXDSensors);
133 m_clusterCharge.resize(nPXDSensors);
134 m_pixelSignal.resize(nPXDSensors);
135 m_clusterSizeU.resize(nPXDSensors);
136 m_clusterSizeV.resize(nPXDSensors);
137 m_clusterSizeUV.resize(nPXDSensors);
138 for (
int i = 0; i < nPXDSensors; i++) {
139 VxdID id = gTools->getSensorIDFromPXDIndex(i);
141 int iLadder =
id.getLadderNumber();
142 int iSensor =
id.getSensorNumber();
143 VxdID sensorID(iLayer, iLadder, iSensor);
145 string sensorDescr = str(format(
"%1%_%2%_%3%") % iLayer % iLadder % iSensor);
149 string name = str(format(
"DQMER_PXD_%1%_Fired") % sensorDescr);
150 string title = str(format(
"DQM ER PXD Sensor %1% Fired pixels") % sensorDescr);
151 m_fired[i] =
nullptr;
152 m_fired[i] =
new TH1D(name.c_str(), title.c_str(), 200, 0, 200);
153 m_fired[i]->SetCanExtend(TH1::kAllAxes);
154 m_fired[i]->GetXaxis()->SetTitle(
"# of fired pixels");
155 m_fired[i]->GetYaxis()->SetTitle(
"counts");
159 name = str(format(
"DQMER_PXD_%1%_Clusters") % sensorDescr);
160 title = str(format(
"DQM ER PXD Sensor %1% Number of clusters") % sensorDescr);
161 m_clusters[i] =
nullptr;
162 m_clusters[i] =
new TH1D(name.c_str(), title.c_str(), 200, 0, 200);
163 m_clusters[i]->SetCanExtend(TH1::kAllAxes);
164 m_clusters[i]->GetXaxis()->SetTitle(
"# of clusters");
165 m_clusters[i]->GetYaxis()->SetTitle(
"counts");
194 name = str(format(
"DQMER_PXD_%1%_ClusterCharge") % sensorDescr);
195 title = str(format(
"DQM ER PXD Sensor %1% Cluster Charge") % sensorDescr);
196 m_clusterCharge[i] =
new TH1D(name.c_str(), title.c_str(), 256, 0, 256);
197 m_clusterCharge[i]->GetXaxis()->SetTitle(
"charge of clusters [ADU]");
198 m_clusterCharge[i]->GetYaxis()->SetTitle(
"counts");
202 name = str(format(
"DQMER_PXD_%1%_PixelSignal") % sensorDescr);
203 title = str(format(
"DQM ER PXD Sensor %1% Pixel Signal") % sensorDescr);
204 m_pixelSignal[i] =
new TH1D(name.c_str(), title.c_str(), 256, 0, 256);
205 m_pixelSignal[i]->GetXaxis()->SetTitle(
"signal of pixels [ADU]");
206 m_pixelSignal[i]->GetYaxis()->SetTitle(
"counts");
210 name = str(format(
"DQMER_PXD_%1%_ClusterSizeU") % sensorDescr);
211 title = str(format(
"DQM ER PXD Sensor %1% Cluster Size U") % sensorDescr);
212 m_clusterSizeU[i] =
new TH1D(name.c_str(), title.c_str(), 10, 0, 10);
213 m_clusterSizeU[i]->GetXaxis()->SetTitle(
"size of u clusters");
214 m_clusterSizeU[i]->GetYaxis()->SetTitle(
"counts");
218 name = str(format(
"DQMER_PXD_%1%_ClusterSizeV") % sensorDescr);
219 title = str(format(
"DQM ER PXD Sensor %1% Cluster Size V") % sensorDescr);
220 m_clusterSizeV[i] =
new TH1D(name.c_str(), title.c_str(), 10, 0, 10);
221 m_clusterSizeV[i]->GetXaxis()->SetTitle(
"size of v clusters");
222 m_clusterSizeV[i]->GetYaxis()->SetTitle(
"counts");
226 name = str(format(
"DQMER_PXD_%1%_ClusterSizeUV") % sensorDescr);
227 title = str(format(
"DQM ER PXD Sensor %1% Cluster Size U+V") % sensorDescr);
228 m_clusterSizeUV[i] =
new TH1D(name.c_str(), title.c_str(), 10, 0, 10);
229 m_clusterSizeUV[i]->GetXaxis()->SetTitle(
"size of u+v clusters");
230 m_clusterSizeUV[i]->GetYaxis()->SetTitle(
"counts");
237 void PXDDQMExpressRecoModule::initialize()
242 auto gTools = VXD::GeoCache::getInstance().getGeoTools();
243 if (gTools->getNumberOfPXDLayers() != 0) {
245 m_storePXDDigits.isOptional(m_storePXDDigitsName);
246 m_storePXDClusters.isOptional(m_storePXDClustersName);
250 void PXDDQMExpressRecoModule::beginRun()
252 auto gTools = VXD::GeoCache::getInstance().getGeoTools();
253 if (gTools->getNumberOfPXDLayers() == 0)
return;
255 if (m_hitMapCounts !=
nullptr) m_hitMapCounts->Reset();
256 if (m_hitMapClCounts !=
nullptr) m_hitMapClCounts->Reset();
257 if (m_hitMapCountsChip !=
nullptr) m_hitMapCountsChip->Reset();
258 if (m_hitMapClCountsChip !=
nullptr) m_hitMapClCountsChip->Reset();
260 for (
int i = 0; i < gTools->getNumberOfPXDSensors(); i++) {
261 if (m_fired[i] !=
nullptr) m_fired[i]->Reset();
262 if (m_clusters[i] !=
nullptr) m_clusters[i]->Reset();
267 if (m_clusterCharge[i] !=
nullptr) m_clusterCharge[i]->Reset();
268 if (m_pixelSignal[i] !=
nullptr) m_pixelSignal[i]->Reset();
269 if (m_clusterSizeU[i] !=
nullptr) m_clusterSizeU[i]->Reset();
270 if (m_clusterSizeV[i] !=
nullptr) m_clusterSizeV[i]->Reset();
271 if (m_clusterSizeUV[i] !=
nullptr) m_clusterSizeUV[i]->Reset();
277 void PXDDQMExpressRecoModule::event()
279 auto gTools = VXD::GeoCache::getInstance().getGeoTools();
280 if (gTools->getNumberOfPXDLayers() == 0)
return;
283 if (!m_storePXDDigits || !m_storePXDDigits.getEntries())
return;
285 int nPXDSensors = gTools->getNumberOfPXDSensors();
289 vector< int > Pixels(nPXDSensors);
290 for (
const PXDDigit& digit : m_storePXDDigits) {
291 int iLayer = digit.getSensorID().getLayerNumber();
292 int iLadder = digit.getSensorID().getLadderNumber();
293 int iSensor = digit.getSensorID().getSensorNumber();
294 VxdID sensorID(iLayer, iLadder, iSensor);
295 int index = gTools->getPXDSensorIndex(sensorID);
298 int iChip = PXDMappingLookup::getDCDID(digit.getUCellID(), digit.getVCellID(), sensorID);
299 int indexChip = gTools->getPXDChipIndex(sensorID, kTRUE, iChip);
300 if (m_hitMapCountsChip !=
nullptr) m_hitMapCountsChip->Fill(indexChip);
301 iChip = PXDMappingLookup::getSWBID(digit.getVCellID());
302 indexChip = gTools->getPXDChipIndex(sensorID, kFALSE, iChip);
303 if (m_hitMapCountsChip !=
nullptr) m_hitMapCountsChip->Fill(indexChip);
305 if (m_pixelSignal[index] !=
nullptr) m_pixelSignal[index]->Fill(digit.getCharge());
306 if ((m_hitMapCounts !=
nullptr) && (digit.getCharge() > m_CutPXDCharge))
307 m_hitMapCounts->Fill(index);
309 for (
int i = 0; i < nPXDSensors; i++) {
310 if (m_fired[i] !=
nullptr) m_fired[i]->Fill(Pixels[i]);
313 vector< int > counts(nPXDSensors);
315 for (
const PXDCluster& cluster : m_storePXDClusters) {
316 int iLayer = cluster.getSensorID().getLayerNumber();
317 int iLadder = cluster.getSensorID().getLadderNumber();
318 int iSensor = cluster.getSensorID().getSensorNumber();
319 VxdID sensorID(iLayer, iLadder, iSensor);
320 int index = gTools->getPXDSensorIndex(sensorID);
324 int indexChip = gTools->getPXDChipIndex(sensorID, kTRUE, iChip);
325 if (m_hitMapClCountsChip !=
nullptr) m_hitMapClCountsChip->Fill(indexChip);
327 indexChip = gTools->getPXDChipIndex(sensorID, kFALSE, iChip);
328 if (m_hitMapClCountsChip !=
nullptr) m_hitMapClCountsChip->Fill(indexChip);
329 if (m_hitMapClCounts !=
nullptr) m_hitMapClCounts->Fill(index);
330 if (m_clusterCharge[index] !=
nullptr) m_clusterCharge[index]->Fill(cluster.getCharge());
331 if (m_clusterSizeU[index] !=
nullptr) m_clusterSizeU[index]->Fill(cluster.getUSize());
332 if (m_clusterSizeV[index] !=
nullptr) m_clusterSizeV[index]->Fill(cluster.getVSize());
333 if (m_clusterSizeUV[index] !=
nullptr) m_clusterSizeUV[index]->Fill(cluster.getSize());
335 for (
int i = 0; i < nPXDSensors; i++) {
336 if (m_clusters[i] !=
nullptr)
337 m_clusters[i]->Fill(counts[i]);