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