Belle II Software  release-08-01-10
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 
22 PXDBadSensorTagModule::PXDBadSensorTagModule() :
23  Module()
24 {
25  //Set module properties
26  setDescription("Mark bad-data PXD modules");
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 
33 {
34  //Register output collections
35  m_storeRawHits.isRequired(m_PXDRawHitsName);
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 
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
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
std::string m_PXDRawHitsName
The name of the StoreArray of PXDRawHits to be generated.
void initialize() override final
Initialize the module.
int m_0cut
Minimum charge for a digit to carry.
std::map< VxdID, int > m_cut
Cuts fore each module.
StoreObjPtr< PXDDAQStatus > m_storeDAQEvtStats
Output array for DAQ Status.
std::string m_PXDDAQEvtStatsName
The name of the StoreObjPtr of PXDDAQStatus to be generated.
void event() override final
Event.
std::vector< std::vector< int > > m_nrHitsCut
Cuts parameter fore each module.
StoreArray< PXDRawHit > m_storeRawHits
Input array for PXD Raw Hits.
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
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Abstract base class for different kinds of events.