Belle II Software  release-06-02-00
PXDBadSensorTagModule.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/pxdHelper/PXDBadSensorTagModule.h>
10 #include <framework/core/ModuleParam.templateDetails.h>
11 
12 
13 using namespace std;
14 using namespace Belle2;
15 using namespace Belle2::PXD;
16 using namespace Belle2::PXD::PXDError;
17 
18 
19 REG_MODULE(PXDBadSensorTag)
20 
21 
23  Module()
24 {
25  //Set module properties
26  setDescription("Mark bad-data PXD modules");
27  setPropertyFlags(c_ParallelProcessingCertified);
28  addParam("zeroSuppressionCut", m_0cut, "Minimum charge for a raw hit to carry", 0);
29  addParam("nrHitsCut", m_nrHitsCut, "Cut on nr hits per module [[id1,cut1],[id1,cut2],...]");
30 }
31 
32 void PXDBadSensorTagModule::initialize()
33 {
34  //Register output collections
35  m_storeRawHits.isRequired(m_PXDRawHitsName);
36  m_storeDAQEvtStats.isRequired(m_PXDDAQEvtStatsName);
37 
38  for (auto& m : m_nrHitsCut) {
39  if (m.size() != 2) { B2ERROR("Wrong nr of Parameter " << m.size()); continue;}
40  m_cut[VxdID(m[0])] = m[1];
41  }
42 }
43 
44 void PXDBadSensorTagModule::event()
45 {
46  std::map <VxdID, int> freq;// count the number of RawHits per sensor
47  for (auto& p : m_storeRawHits) {
48  if (p.getCharge() < m_0cut) continue;// only count above some threshold
49  freq[p.getSensorID()]++;
50  }
51 
52  for (auto& p : *m_storeDAQEvtStats) {
53  for (auto& c : p) {
54  for (auto& e : c) {
55  if (freq[e.getSensorID()] > m_cut[e.getSensorID()]) {
56  e.markUnusable();
57  }
58  }
59  }
60  }
61 }
Base class for Modules.
Definition: Module.h:72
The PXD bad sensor tagger module.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Abstract base class for different kinds of events.