Belle II Software development
PXDHotPixelMaskCollectorModule.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/pxdHotPixelMaskCollector/PXDHotPixelMaskCollectorModule.h>
10#include <vxd/geometry/GeoCache.h>
11
12#include <boost/format.hpp>
13
14#include <TH1I.h>
15
16using namespace std;
17using boost::format;
18using namespace Belle2;
19
20
21//-----------------------------------------------------------------
22// Register the Module
23//-----------------------------------------------------------------
24REG_MODULE(PXDHotPixelMaskCollector);
25
26//-----------------------------------------------------------------
27// Implementation
28//-----------------------------------------------------------------
29
31{
32 // Set module properties
33 setDescription("Calibration Collector Module for PXD hot pixel masking from digits");
35
36 addParam("zeroSuppressionCut", m_0cut, "Minimum charge (in ADU) for detecting a hit", 0);
37 addParam("digitsName", m_storeDigitsName, "PXDDigit collection name", string(""));
38}
39
40void PXDHotPixelMaskCollectorModule::prepare() // Do your initialise() stuff here
41{
42 m_pxdDigit.isRequired();
43
45
46 if (gTools->getNumberOfPXDLayers() == 0) {
47 B2WARNING("Missing geometry for PXD, PXD-masking is skiped.");
48 }
49
50 //-------------------------------------------------------------------------------------------------
51 // PXDHits: Histogram the number of PXDDigits per event (assuming Belle 2 PXD with < 2% occupancy)
52 //-------------------------------------------------------------------------------------------------
53 auto hPXDHits = new TH1I("hPXDHits",
54 "Number of hits in PXD per events used for masking, distribution parameters found by PXDHotPixelMaskCollectorModule", 200000, 0,
55 200000);
56 hPXDHits->GetXaxis()->SetTitle("Number of hits");
57 hPXDHits->GetYaxis()->SetTitle("Events");
58 registerObject<TH1I>("PXDHits", hPXDHits);
59
60 //--------------------------------------------------------
61 // PXDHitCounts: Count the number of PXDDigits per sensor
62 //--------------------------------------------------------
63 int nPXDSensors = gTools->getNumberOfPXDSensors();
64 auto hPXDHitCounts = new TH1I("hPXDHitCounts",
65 "Number of hits in PXD sensors for masking, distribution parameters found by PXDHotPixelMaskCollectorModule", nPXDSensors, 0,
66 nPXDSensors);
67
68 hPXDHitCounts->GetXaxis()->SetTitle("SensorID");
69 hPXDHitCounts->GetYaxis()->SetTitle("Number of hits");
70 for (int i = 0; i < nPXDSensors; i++) {
71 VxdID id = gTools->getSensorIDFromPXDIndex(i);
72 string sensorDescr = id;
73 hPXDHitCounts->GetXaxis()->SetBinLabel(i + 1, str(format("%1%") % sensorDescr).c_str());
74 }
75 registerObject<TH1I>("PXDHitCounts", hPXDHitCounts);
76
77 // Fill PXDHitMap with empty histos for all sensors
78 for (int i = 0; i < nPXDSensors; i++) {
79 VxdID id = gTools->getSensorIDFromPXDIndex(i);
80 string sensorDescr = id;
81
82 //----------------------------------------------------------------
83 // Hitmaps: Number of hits per sensor and pixel
84 //----------------------------------------------------------------
85 string name = str(format("PXD_%1%_PixelHitmap") % id.getID());
86 string title = str(format("PXD Sensor %1% Pixel Hitmap from PXDHotPixelMaskCollector") % sensorDescr);
87
88 // Data object creation --------------------------------------------------
89 auto hsensorhitmap = new TH1I(name.c_str(), title.c_str(), 250 * 768, 0, 250 * 768);
90
91 // Data object registration ----------------------------------------------
92 registerObject<TH1I>(name.c_str(), hsensorhitmap); // Does the registerInDatastore for you
93 }
94
95}
96
97void PXDHotPixelMaskCollectorModule::collect() // Do your event() stuff here
98{
99
100 // Histogram pxd hits per event
101 TH1I* collector_hits = getObjectPtr<TH1I>("PXDHits");
102
103 // Even if there is no input StoreArray, we still want to fill zero hits
104 if (!m_pxdDigit)
105 collector_hits->Fill(0);
106 else
107 collector_hits->Fill(m_pxdDigit.getEntries());
108
109 auto& geo = VXD::GeoCache::getInstance();
110 auto gTools = geo.getGeoTools();
111
112 // Count hits per sensor
113 TH1I* collector_pxdhitcounts = getObjectPtr<TH1I>("PXDHitCounts");
114
115 for (auto& digit : m_pxdDigit) {
116 // Zero-suppression cut
117 if (digit.getCharge() < m_0cut) continue;
118
119 // Increment counter for hit pixel
120 string name = str(format("PXD_%1%_PixelHitmap") % digit.getSensorID().getID());
121 TH1I* collector_sensorhitmap = getObjectPtr<TH1I>(name.c_str());
122 collector_sensorhitmap->Fill(digit.getUCellID() * 768 + digit.getVCellID());
123 collector_pxdhitcounts->Fill(gTools->getPXDSensorIndex(digit.getSensorID()));
124 }
125}
Calibration collector module base class.
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
int m_0cut
Minimum charge (ADU) for detecting a hit.
PXDHotPixelMaskCollectorModule()
Constructor: Sets the description, the properties and the parameters of the module.
StoreArray< PXDDigit > m_pxdDigit
< Required input for PXDigits
std::string m_storeDigitsName
Name of the collection to use for PXDDigits.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Definition: GeoCache.h:142
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
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:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:60
Abstract base class for different kinds of events.
STL namespace.