Belle II Software development
PXDRawDQMChipsModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <pxd/modules/pxdDQM/PXDRawDQMChipsModule.h>
10#include <pxd/dataobjects/PXDRawHit.h>
11#include <vxd/geometry/GeoCache.h>
12
13#include <TDirectory.h>
14#include <boost/format.hpp>
15#include <string>
16
17using namespace std;
18using namespace Belle2;
19using namespace Belle2::PXD;
20using namespace Belle2::VXD;
21
22using boost::format;
23
24//-----------------------------------------------------------------
25// Register the Module
26//-----------------------------------------------------------------
27REG_MODULE(PXDRawDQMChips);
28
29//-----------------------------------------------------------------
30// Implementation
31//-----------------------------------------------------------------
32
34{
35 //Set module properties
36 setDescription("Monitor raw PXD");
38 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms will be placed",
39 std::string("pxdraw"));
40
41 addParam("PXDRawHitsName", m_storeRawHitsName, "The name of the StoreArray of PXDRawHits to be processed", string(""));
42}
43
45{
46 // Create a separate histogram directory and cd into it.
47 TDirectory* oldDir = gDirectory;
48 if (m_histogramDirectoryName != "") {
49 oldDir->mkdir(m_histogramDirectoryName.c_str());
50 oldDir->cd(m_histogramDirectoryName.c_str());
51 }
52
53
54 for (auto i = 0; i < 64; i++) {
55 auto layer = (((i >> 5) & 0x1) + 1);
56 auto ladder = ((i >> 1) & 0xF);
57 auto sensor = ((i & 0x1) + 1);
58
59 // Check if sensor exist
60 if (Belle2::VXD::GeoCache::getInstance().validSensorID(Belle2::VxdID(layer, ladder, sensor))) {
61 for (auto j = 0; j < eNumSwitcher; j++) {
62 for (auto k = 0; k < eNumDCD; k++) {
63 string s = str(format("Sensor %d:%d:%d (DHH ID %02Xh) Switcher %d DCD %d") % layer % ladder % sensor % i % j % k);
64 string s2 = str(format("_%d.%d.%d_%d_%d") % layer % ladder % sensor % j % k);
65
66 hrawPxdHitsCount[i][j][k] = new TH1F(("hrawPxdCount" + s2).c_str(), ("Pxd Raw Count " + s + ";Nr per Event").c_str(), 8192, 0,
67 8192);
68 hrawPxdHitsCharge[i][j][k] = new TH1F(("hrawPxdHitsCharge" + s2).c_str(),
69 ("Pxd Raw Hit Charge, " + s + ";Charge").c_str(), 256, 0, 256);
70 }
71 }
72 } else {
73 for (auto j = 0; j < eNumSwitcher; j++) {
74 for (auto k = 0; k < eNumDCD; k++) {
75 hrawPxdHitsCount[i][j][k] = NULL;
76 hrawPxdHitsCharge[i][j][k] = NULL;
77 }
78 }
79 }
80 }
81
82 // cd back to root directory
83 oldDir->cd();
84}
85
87{
88 REG_HISTOGRAM
90}
91
93{
94 // Just to make sure, reset all the histograms.
95 for (auto i = 0; i < eNumSensors; i++) {
96 for (auto j = 0; j < eNumSwitcher; j++) {
97 for (auto k = 0; k < eNumDCD; k++) {
98 if (hrawPxdHitsCount[i][j][k]) hrawPxdHitsCount[i][j][k]->Reset();
99 if (hrawPxdHitsCharge[i][j][k]) hrawPxdHitsCharge[i][j][k]->Reset();
100 }
101 }
102 }
103}
104
106{
107 uint nhits[eNumSensors][eNumSwitcher][eNumDCD] = {};
108
109 for (auto& it : m_storeRawHits) {
110 int dhh_id;
111 // calculate DHH id from Vxd Id
112 unsigned int layer, ladder, sensor;//, segment;
113 VxdID currentVxdId;
114 currentVxdId = it.getSensorID();
115 layer = currentVxdId.getLayerNumber();
116 ladder = currentVxdId.getLadderNumber();
117 sensor = currentVxdId.getSensorNumber();
118 // segment = currentVxdId.getSegmentNumber();// Frame nr? ... ignore
119 dhh_id = ((layer - 1) << 5) | ((ladder) << 1) | (sensor - 1);
120 if (dhh_id <= 0 || dhh_id >= 64) {
121 B2ERROR("SensorId (DHH ID) out of range: " << dhh_id);
122 continue;
123 }
124 int switcher = it.getRow() / 128; // TODO here must be: function for REAL inverse mapping
125 int dcd = it.getColumn() / 64; // TODO here must be: function for REAL inverse mapping
126 // TODO check switcher 0-6? DCD 0-4?
127 nhits[dhh_id][switcher][dcd]++;
128 if (hrawPxdHitsCharge[dhh_id][switcher][dcd]) hrawPxdHitsCharge[dhh_id][switcher][dcd]->Fill(it.getCharge());
129 }
130 for (auto i = 0; i < eNumSensors; i++) {
131 for (auto j = 0; j < eNumSwitcher; j++) {
132 for (auto k = 0; k < eNumDCD; k++) {
133 if (hrawPxdHitsCount[i][j][k]) hrawPxdHitsCount[i][j][k]->Fill(nhits[i][j][k]);
134 }
135 }
136 }
137}
HistoModule()
Constructor.
Definition HistoModule.h:32
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
virtual void initialize() override
Initialize.
virtual void event() override
Event.
TH1F * hrawPxdHitsCharge[eNumSensors][eNumSwitcher][eNumDCD]
Histogram raw pixel charge.
std::string m_storeRawHitsName
PXDRawHits StoreArray name.
TH1F * hrawPxdHitsCount[eNumSensors][eNumSwitcher][eNumDCD]
Histogram pixelcount/?
virtual void beginRun() override
Begin run.
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
PXDRawDQMChipsModule()
Constructor defining the parameters.
StoreArray< PXDRawHit > m_storeRawHits
Storearray for raw pixels.
virtual void defineHisto() override
Define histograms.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition GeoCache.cc:214
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:32
baseType getSensorNumber() const
Get the sensor id.
Definition VxdID.h:99
baseType getLadderNumber() const
Get the ladder id.
Definition VxdID.h:97
baseType getLayerNumber() const
Get the layer id.
Definition VxdID.h:95
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
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.
Definition GeoCache.h:33
Abstract base class for different kinds of events.
STL namespace.