9#include "pxd/modules/pxdDQM/PXDDQMClustersModule.h"
11#include <framework/core/HistoModule.h>
12#include <framework/gearbox/Unit.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/datastore/RelationArray.h>
17#include <pxd/dataobjects/PXDDigit.h>
18#include <pxd/dataobjects/PXDCluster.h>
19#include <pxd/geometry/SensorInfo.h>
21#include <vxd/geometry/GeoCache.h>
22#include <vxd/geometry/SensorInfoBase.h>
23#include <vxd/geometry/GeoTools.h>
24#include <pxd/unpacking/PXDMappingLookup.h>
25#include <pxd/reconstruction/PXDGainCalibrator.h>
27#include <boost/format.hpp>
29#include "TDirectory.h"
50 "Recommended Number of events for monitorin is 40 kEvents or more to fill all histograms "
55 "cut on pixel charge for accepting good pixel, default >= 12", 12);
57 "cut on cluster seed for accepting good cluster, default >= 12", 12);
59 "cut on cluster size accepting good cluster, default <= 4", 4);
61 "cut on cluster charge for accepting good cluster, default >= 12", 12);
63 std::string(
"PXDDQMClusters"));
74 if (gTools->getNumberOfLayers() == 0) {
75 B2FATAL(
"Missing geometry for VXD, check steering file.");
77 if (gTools->getNumberOfPXDLayers() == 0) {
78 B2WARNING(
"Missing geometry for PXD, PXD-DQM is skipped.");
83 TDirectory* oldDir = gDirectory;
90 int nPXDSensors = gTools->getNumberOfPXDSensors();
91 int nPXDChips = gTools->getTotalPXDChips();
94 m_hitMapCounts =
new TH1D(
"DQM_PXD_PixelHitmapCounts",
"PXD Integrated number of fired pixels per sensor",
95 nPXDSensors, 0, nPXDSensors);
99 m_hitMapFilterCounts =
new TH1D(
"DQM_PXD_PixelHitmapFilterCounts",
"PXD Integrated number of filtered pixels per sensor",
100 nPXDSensors, 0, nPXDSensors);
104 m_hitMapClCounts =
new TH1D(
"DQM_PXD_ClusterHitmapCounts",
"PXD Integrated number of clusters per sensor",
105 nPXDSensors, 0, nPXDSensors);
109 m_hitMapClFilterCounts =
new TH1D(
"DQM_PXD_ClusterHitmapFilterCounts",
"PXD Integrated number of filtered clusters per sensor",
110 nPXDSensors, 0, nPXDSensors);
115 m_hitMapCountsChip =
new TH1D(
"DQM_PXD_PixelHitmapCountsChip",
"PXD Integrated number of fired pixels per chip",
116 nPXDChips, 0, nPXDChips);
119 m_hitMapClCountsChip =
new TH1D(
"DQM_PXD_ClusterHitmapCountsChip",
"PXD Integrated number of clusters per chip",
120 nPXDChips, 0, nPXDChips);
123 for (
int i = 0; i < nPXDChips; i++) {
124 VxdID id = gTools->getChipIDFromPXDIndex(i);
126 int iLadder =
id.getLadderNumber();
127 int iSensor =
id.getSensorNumber();
128 int iChip = gTools->getPXDChipNumber(
id);
129 int IsU = gTools->isPXDSideU(
id);
130 TString AxisTicks = Form(
"%i_%i_%i_u%iDCD", iLayer, iLadder, iSensor, iChip);
132 AxisTicks = Form(
"%i_%i_%i_v%iSWB", iLayer, iLadder, iSensor, iChip);
137 for (
int i = 0; i < nPXDSensors; i++) {
138 VxdID id = gTools->getSensorIDFromPXDIndex(i);
140 int iLadder =
id.getLadderNumber();
141 int iSensor =
id.getSensorNumber();
142 TString AxisTicks = Form(
"%i_%i_%i", iLayer, iLadder, iSensor);
167 m_seed.resize(nPXDSensors);
168 for (
int i = 0; i < nPXDSensors; i++) {
169 VxdID id = gTools->getSensorIDFromPXDIndex(i);
171 int iLadder =
id.getLadderNumber();
172 int iSensor =
id.getSensorNumber();
173 VxdID sensorID(iLayer, iLadder, iSensor);
175 string sensorDescr = str(format(
"%1%_%2%_%3%") % iLayer % iLadder % iSensor);
181 string name = str(format(
"DQM_PXD_%1%_Fired") % sensorDescr);
182 string title = str(format(
"PXD Sensor %1% Fired pixels") % sensorDescr);
183 m_fired[i] =
new TH1D(name.c_str(), title.c_str(), 50, 0, 50);
184 m_fired[i]->GetXaxis()->SetTitle(
"# of fired pixels");
185 m_fired[i]->GetYaxis()->SetTitle(
"counts");
189 name = str(format(
"DQM_PXD_%1%_GoodFired") % sensorDescr);
190 title = str(format(
"PXD Sensor %1% Good Fired pixels") % sensorDescr);
191 m_goodfired[i] =
new TH1D(name.c_str(), title.c_str(), 50, 0, 50);
192 m_goodfired[i]->GetXaxis()->SetTitle(
"# of fired pixels");
197 name = str(format(
"DQM_PXD_%1%_Clusters") % sensorDescr);
198 title = str(format(
"PXD Sensor %1% Number of clusters") % sensorDescr);
199 m_clusters[i] =
new TH1D(name.c_str(), title.c_str(), 20, 0, 20);
200 m_clusters[i]->GetXaxis()->SetTitle(
"# of clusters");
201 m_clusters[i]->GetYaxis()->SetTitle(
"counts");
205 name = str(format(
"DQM_PXD_%1%_GoodClusters") % sensorDescr);
206 title = str(format(
"PXD Sensor %1% Number of good clusters") % sensorDescr);
207 m_goodclusters[i] =
new TH1D(name.c_str(), title.c_str(), 20, 0, 20);
213 name = str(format(
"DQM_PXD_%1%_StartRow") % sensorDescr);
214 title = str(format(
"PXD Sensor %1% Start row distribution") % sensorDescr);
216 m_startRow[i] =
new TH1D(name.c_str(), title.c_str(), nVPixels / 4, 0.0, nVPixels);
217 m_startRow[i]->GetXaxis()->SetTitle(
"start row [pitch units]");
222 name = str(format(
"DQM_PXD_%1%_AverageSeedByStartRow") % sensorDescr);
223 title = str(format(
"PXD Sensor %1% Average seed charge by distance from the start row") % sensorDescr);
224 m_chargStartRow[i] =
new TH1D(name.c_str(), title.c_str(), nVPixels / 4, 0.0, nVPixels);
225 m_chargStartRow[i]->GetXaxis()->SetTitle(
"distance from the start row [pitch units]");
227 name = str(format(
"DQM_PXD_%1%_SeedCountsByStartRow") % sensorDescr);
228 title = str(format(
"PXD Sensor %1% Seed charge count by distance from the start row") % sensorDescr);
229 m_startRowCount[i] =
new TH1D(name.c_str(), title.c_str(), nVPixels / 4, 0.0, nVPixels);
230 m_startRowCount[i]->GetXaxis()->SetTitle(
"distance from the start row [pitch units]");
235 name = str(format(
"DQM_PXD_%1%_ClusterCharge") % sensorDescr);
236 title = str(format(
"PXD Sensor %1% Cluster Charge") % sensorDescr);
237 m_clusterCharge[i] =
new TH1D(name.c_str(), title.c_str(), 256, 0, 256);
243 name = str(format(
"DQM_PXD_%1%_ClusterEnergy") % sensorDescr);
244 title = str(format(
"PXD Sensor %1% Cluster Energy") % sensorDescr);
245 m_clusterEnergy[i] =
new TH1D(name.c_str(), title.c_str(), 100, 0, 50);
251 name = str(format(
"DQM_PXD_%1%_PixelSignal") % sensorDescr);
252 title = str(format(
"PXD Sensor %1% Pixel Signal") % sensorDescr);
253 m_pixelSignal[i] =
new TH1D(name.c_str(), title.c_str(), 256, 0, 256);
254 m_pixelSignal[i]->GetXaxis()->SetTitle(
"signal of pixels [ADU]");
259 name = str(format(
"DQM_PXD_%1%_ClusterSizeU") % sensorDescr);
260 title = str(format(
"PXD Sensor %1% Cluster Size U") % sensorDescr);
261 m_clusterSizeU[i] =
new TH1D(name.c_str(), title.c_str(), 10, 0, 10);
267 name = str(format(
"DQM_PXD_%1%_ClusterSizeV") % sensorDescr);
268 title = str(format(
"PXD Sensor %1% Cluster Size V") % sensorDescr);
269 m_clusterSizeV[i] =
new TH1D(name.c_str(), title.c_str(), 10, 0, 10);
275 name = str(format(
"DQM_PXD_%1%_ClusterSizeUV") % sensorDescr);
276 title = str(format(
"PXD Sensor %1% Cluster Size U+V") % sensorDescr);
285 name = str(format(
"PXD_%1%_PixelHitmapU") % sensorDescr);
286 title = str(format(
"PXD Sensor %1% Pixel Hitmap in U") % sensorDescr);
287 m_hitMapU[i] =
new TH1D(name.c_str(), title.c_str(), nUPixels, 0, nUPixels);
288 m_hitMapU[i]->GetXaxis()->SetTitle(
"u position [pitch units]");
289 m_hitMapU[i]->GetYaxis()->SetTitle(
"hits");
291 name = str(format(
"PXD_%1%_PixelHitmapV") % sensorDescr);
292 title = str(format(
"PXD Sensor %1% Pixel Hitmap in V") % sensorDescr);
293 m_hitMapV[i] =
new TH1D(name.c_str(), title.c_str(), nVPixels, 0, nVPixels);
294 m_hitMapV[i]->GetXaxis()->SetTitle(
"v position [pitch units]");
295 m_hitMapV[i]->GetYaxis()->SetTitle(
"hits");
297 name = str(format(
"PXD_%1%_PixelHitmap") % sensorDescr);
298 title = str(format(
"PXD Sensor %1% Pixel Hitmap") % sensorDescr);
299 m_hitMap[i] =
new TH2D(name.c_str(), title.c_str(), nUPixels, 0, nUPixels, nVPixels, 0, nVPixels);
300 m_hitMap[i]->GetXaxis()->SetTitle(
"u position [pitch units]");
301 m_hitMap[i]->GetYaxis()->SetTitle(
"v position [pitch units]");
302 m_hitMap[i]->GetZaxis()->SetTitle(
"hits");
308 name = str(format(
"PXD_%1%_HitmapClstU") % sensorDescr);
309 title = str(format(
"PXD Sensor %1% Hitmap Clusters in U") % sensorDescr);
310 m_hitMapUCl[i] =
new TH1D(name.c_str(), title.c_str(), nUPixels, 0, nUPixels);
311 m_hitMapUCl[i]->GetXaxis()->SetTitle(
"u position [pitch units]");
314 name = str(format(
"PXD_%1%_HitmapClstV") % sensorDescr);
315 title = str(format(
"PXD Sensor %1% Hitmap Clusters in V") % sensorDescr);
316 m_hitMapVCl[i] =
new TH1D(name.c_str(), title.c_str(), nVPixels, 0, nVPixels);
317 m_hitMapVCl[i]->GetXaxis()->SetTitle(
"v position [pitch units]");
320 name = str(format(
"PXD_%1%_HitmapClst") % sensorDescr);
321 title = str(format(
"PXD Sensor %1% Hitmap Clusters") % sensorDescr);
322 m_hitMapCl[i] =
new TH2D(name.c_str(), title.c_str(), nUPixels, 0, nUPixels, nVPixels, 0, nVPixels);
323 m_hitMapCl[i]->GetXaxis()->SetTitle(
"u position [pitch units]");
324 m_hitMapCl[i]->GetYaxis()->SetTitle(
"v position [pitch units]");
330 name = str(format(
"PXD_%1%_Seed") % sensorDescr);
331 title = str(format(
"PXD Sensor %1% Seed charge") % sensorDescr);
332 m_seed[i] =
new TH1D(name.c_str(), title.c_str(), 256, 0, 256);
333 m_seed[i]->GetXaxis()->SetTitle(
"seed charge of clusters [ADU]");
334 m_seed[i]->GetYaxis()->SetTitle(
"count");
349 if (gTools->getNumberOfPXDLayers() != 0) {
353 RelationArray relPXDClusterDigits(storePXDClusters, storePXDDigits);
365 if (gTools->getNumberOfPXDLayers() == 0)
return;
374 for (
int i = 0; i < gTools->getNumberOfPXDSensors(); i++) {
404 if (gTools->getNumberOfPXDLayers() == 0)
return;
411 if (!storePXDDigits || !storePXDDigits.
getEntries())
return;
413 int firstPXDLayer = gTools->getFirstPXDLayer();
414 int lastPXDLayer = gTools->getLastPXDLayer();
415 int nPXDSensors = gTools->getNumberOfPXDSensors();
419 vector< int > Pixels(nPXDSensors);
420 vector< int > GoodPixels(nPXDSensors);
421 for (
const PXDDigit& digit : storePXDDigits) {
422 int iLayer = digit.getSensorID().getLayerNumber();
423 if ((iLayer < firstPXDLayer) || (iLayer > lastPXDLayer))
continue;
424 int iLadder = digit.getSensorID().getLadderNumber();
425 int iSensor = digit.getSensorID().getSensorNumber();
426 VxdID sensorID(iLayer, iLadder, iSensor);
427 int index = gTools->getPXDSensorIndex(sensorID);
431 int indexChip = gTools->getPXDChipIndex(sensorID, kTRUE, iChip);
434 indexChip = gTools->getPXDChipIndex(sensorID, kFALSE, iChip);
439 if (digit.getCharge() >=
m_CutMinCharge && digit.getCharge() < 255) {
444 if (
m_hitMap[index] !=
nullptr)
m_hitMap[index]->Fill(digit.getUCellID(), digit.getVCellID());
447 for (
int i = 0; i < nPXDSensors; i++) {
448 if (
m_fired[i] !=
nullptr && Pixels[i] > 0)
m_fired[i]->Fill(Pixels[i]);
453 vector< int > Clusters(nPXDSensors);
454 vector< int > GoodClusters(nPXDSensors);
455 for (
const PXDCluster& cluster : storePXDClusters) {
456 int iLayer = cluster.getSensorID().getLayerNumber();
457 if ((iLayer < firstPXDLayer) || (iLayer > lastPXDLayer))
continue;
458 int iLadder = cluster.getSensorID().getLadderNumber();
459 int iSensor = cluster.getSensorID().getSensorNumber();
460 VxdID sensorID(iLayer, iLadder, iSensor);
461 int index = gTools->getPXDSensorIndex(sensorID);
465 int indexChip = gTools->getPXDChipIndex(sensorID, kTRUE, iChip);
468 indexChip = gTools->getPXDChipIndex(sensorID, kFALSE, iChip);
482 if (
m_seed[index] !=
nullptr)
m_seed[index]->Fill(cluster.getSeedCharge());
487 GoodClusters[index]++;
499 for (
int i = 0; i < nPXDSensors; i++) {
506 std::map<VxdID, unsigned short> startRows;
507 for (
int index = 0; index < nPXDSensors; index++) {
508 VxdID id = gTools->getSensorIDFromPXDIndex(index);
511 if (dhe !=
nullptr) {
514 startRows.insert(std::make_pair(
id, startRow));
516 B2WARNING(
"No PXDDAQDHEStatus for VXD Sensor " <<
id <<
" found.");
521 for (
auto& cluster : storePXDClusters) {
522 VxdID sensorID = cluster.getSensorID();
523 int index = gTools->getPXDSensorIndex(sensorID);
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...
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
The PXD DAQ DHE Status class.
unsigned short getStartRow(void) const
get Trigger Start Row
std::vector< TH1D * > m_goodfired
Filtered fired pixels per event.
TH1D * m_hitMapClFilterCounts
Hitmaps of filtered Clusters.
void initialize() override final
Initialize.
std::string m_relPXDClusterDigitName
PXDClustersToPXDDigits RelationArray name.
std::vector< TH1D * > m_hitMapUCl
Hitmaps clusters for u.
std::vector< TH2D * > m_hitMapCl
Hitmaps clusters.
std::vector< TH1D * > m_fired
Fired pixels per event.
int m_CutMinSeedCharge
cut for accepting to filtered hitmap histogram, using cluster seed
std::vector< TH1D * > m_clusterSizeUV
Cluster size.
StoreObjPtr< PXDDAQStatus > m_storeDAQEvtStats
Input array for DAQ Status.
std::vector< TH2D * > m_hitMap
Hitmaps pixels.
std::vector< TH1D * > m_clusterEnergy
Deposited energy of clusters.
std::string m_storePXDClustersName
PXDClusters StoreArray name.
std::vector< TH1D * > m_hitMapVCl
Hitmaps clusters for v.
std::vector< TH1D * > m_chargStartRow
Cluster seed charge by distance from the start row.
std::vector< TH1D * > m_startRow
Start row distribution.
TH1D * m_hitMapFilterCounts
Hitmaps of filtered Digits.
void defineHisto() override final
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
int m_CutMinCharge
cut for accepting filtered pixel
std::vector< TH1D * > m_hitMapU
Hitmaps pixels for u.
void event() override final
Event.
std::vector< TH1D * > m_pixelSignal
Charge of pixels.
std::vector< TH1D * > m_clusterSizeV
v cluster size
PXDDQMClustersModule()
Constructor.
TH1D * m_hitMapCounts
Hitmaps of Digits.
TH1D * m_hitMapCountsChip
Hitmaps of digits on chips.
TH1D * m_hitMapClCounts
Hitmaps of Clusters.
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
int m_CutMinClusterCharge
cut for accepting filtered cluster, using cluster charge
std::vector< TH1D * > m_startRowCount
counter for Cluster seed charge by distance from the start row
std::vector< TH1D * > m_hitMapV
Hitmaps pixels for v.
std::vector< TH1D * > m_goodclusters
filtered Clusters per event
std::vector< TH1D * > m_clusterSizeU
u cluster size
std::vector< TH1D * > m_clusters
Clusters per event.
void beginRun() override final
Begin run.
int m_CutMaxClusterSize
cut for accepting to filtered hitmap histogram, maximum cluster size
std::vector< TH1D * > m_seed
Seed.
TH1D * m_hitMapClCountsChip
Hitmaps of clusters on chips.
std::vector< TH1D * > m_clusterCharge
Charge of clusters.
std::string m_storePXDDigitsName
PXDDigits StoreArray name.
float getADUToEnergy(VxdID id, unsigned int uid, unsigned int vid) const
Get conversion factor from ADU to energy.
static PXDGainCalibrator & getInstance()
Main (and only) way to access the PXDGainCalibrator.
static int getDCDID(const int u, const int v, const VxdID sensorID)
get ID of DCD for giving pixel, range: 1..4.
static int getSWBID(const int v)
get ID of SWB for giving pixel, range: 1..6.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Low-level class to create/modify relations between StoreArrays.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
static const double keV
[kiloelectronvolt]
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
static GeoCache & getInstance()
Return a reference to the singleton instance.
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
int getVCells() const
Return number of pixel/strips in v direction.
int getUCells() const
Return number of pixel/strips in u direction.
int getVCellID(double v, bool clamp=false) const
Return the corresponding pixel/strip ID of a given v coordinate.
int getUCellID(double u, double v=0, bool clamp=false) const
Return the corresponding pixel/strip ID of a given u coordinate.
Class to uniquely identify a any structure of the PXD and SVD.
baseType getLayerNumber() const
Get the layer id.
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.
Abstract base class for different kinds of events.