Belle II Software  release-06-01-15
SVDZeroSuppressionEmulatorModule.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 <svd/modules/svdSimulation/SVDZeroSuppressionEmulatorModule.h>
10 
11 using namespace Belle2;
12 using namespace std;
13 
14 //-----------------------------------------------------------------
15 // Register the Module
16 //-----------------------------------------------------------------
17 REG_MODULE(SVDZeroSuppressionEmulator)
18 
19 //-----------------------------------------------------------------
20 // Implementation
21 //-----------------------------------------------------------------
22 
24 {
25  setDescription("Filters out SVDShaperDigit with less than 1 (default) sample is below a certain threshold, by default set at SN = 3.");
26  setPropertyFlags(c_ParallelProcessingCertified);
27 
28  addParam("FADCmode", m_FADCmode,
29  "FADC mode: if true the approximation to integer is done", bool(true));
30  addParam("ShaperDigits", m_storeShaperDigitsName,
31  "ShaperDigits collection name", string(""));
32  addParam("ShaperDigitsIN", m_SVDShaperDigitsIN,
33  "Kept ShaperDigits collection name", string(""));
34  addParam("ShaperDigitsOUT", m_SVDShaperDigitsOUT,
35  "ShaperDigits collection name", string(""));
36  addParam("SNthreshold", m_cutSN,
37  "minimum SN to be kept", float(3));
38  addParam("numberOfSamples", m_nSample,
39  "number of samples above threshold to be kept ", int(1));
40  addParam("createOUTStripsList", m_createOutside,
41  "create the StoreArray of outside strips", bool(false));
42 
43 
44 }
45 
46 
47 SVDZeroSuppressionEmulatorModule::~SVDZeroSuppressionEmulatorModule()
48 {
49 }
50 
51 
53 {
54  m_storeShaper.isRequired(m_storeShaperDigitsName);
55 
56  if (m_storeShaperDigitsName == m_SVDShaperDigitsIN) {
57  m_selectorIN.registerSubset(m_storeShaper);
58  } else {
59  m_selectorIN.registerSubset(m_storeShaper, m_SVDShaperDigitsIN, DataStore::c_WriteOut);
60  m_selectorIN.inheritAllRelations();
61  }
62 
63  if (m_createOutside) {
64  if (m_storeShaperDigitsName == m_SVDShaperDigitsOUT) {
65  m_selectorOUT.registerSubset(m_storeShaper);
66  } else {
67  m_selectorOUT.registerSubset(m_storeShaper, m_SVDShaperDigitsOUT);
68  m_selectorOUT.inheritAllRelations();
69  }
70  }
71 
72 }
73 
74 
76 {
77 
78  // If no digits, nothing to do
79  if (!m_storeShaper || !m_storeShaper.getEntries()) return;
80 
81  m_selectorIN.select([&](const SVDShaperDigit * shaper) { return this->passesZS(shaper) ;});
82 
83  if (m_createOutside)
84  m_selectorOUT.select([&](const SVDShaperDigit * shaper) { return ! this->passesZS(shaper) ;});
85 
86  B2DEBUG(10, " shaper digits = " << m_storeShaper.getEntries() <<
87  ", shaper digits IN = " << (((StoreArray<SVDShaperDigit>*)(m_selectorIN.getSubSet()))->getEntries()));
88 
89  if (m_createOutside)
90  B2DEBUG(10, " shaper digits = " << m_storeShaper.getEntries() <<
91  ", shaper digits IN = " << (((StoreArray<SVDShaperDigit>*)(m_selectorIN.getSubSet()))->getEntries()) <<
92  ", shaper digits OUT = " << (((StoreArray<SVDShaperDigit>*)(m_selectorOUT.getSubSet()))->getEntries()));
93 
94 }
95 
96 
98 {
99 
100  VxdID thisSensorID = shaper->getSensorID();
101  bool thisSide = shaper->isUStrip();
102  int thisCellID = shaper->getCellID();
103 
104  float noise = m_NoiseCal.getNoise(thisSensorID, thisSide, thisCellID);
105  float cutMinSignal = m_cutSN * noise;
106 
107  // B2INFO("before = "<<cutMinSignal);
108  if (m_FADCmode) {
109  cutMinSignal = cutMinSignal + 0.5;
110  cutMinSignal = (int)cutMinSignal;
111  }
112  // B2INFO("after = "<<cutMinSignal);
113  if (shaper->passesZS(m_nSample, cutMinSignal))
114  return true;
115 
116  return false;
117 };
118 
@ c_WriteOut
Object/array should be saved by output modules.
Definition: DataStore.h:70
Base class for Modules.
Definition: Module.h:72
The SVD ShaperDigit class.
bool passesZS(int nSamples, float cutMinSignal) const
does the strip pass the ZS cut?
VxdID getSensorID() const
Get the sensor ID.
short int getCellID() const
Get strip ID.
bool isUStrip() const
Get strip direction.
This module filters out strips that do not pass a ZS cut from the SVDShaperDigit StoreArray.
virtual void initialize() override
Initialize the SVDZeroSuppressionEmulator.
virtual void event() override
This method is the core of the SVDZeroSuppressionEmulator.
bool passesZS(const SVDShaperDigit *)
returns true if the strip passes the ZS cut
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
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
Abstract base class for different kinds of events.