Belle II Software  release-06-02-00
PXDInjectionVetoEmulatorModule.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/pxdSimulation/PXDInjectionVetoEmulatorModule.h>
10 #include <vxd/geometry/GeoCache.h>
11 #include <vxd/geometry/GeoTools.h>
12 
13 #include <vector>
14 
15 #include <TRandom3.h>
16 
17 using namespace Belle2;
18 using namespace std;
19 
20 //-----------------------------------------------------------------
21 // Register the Module
22 //-----------------------------------------------------------------
23 REG_MODULE(PXDInjectionVetoEmulator)
24 
25 //-----------------------------------------------------------------
26 // Implementation
27 //-----------------------------------------------------------------
28 
30  , m_nGates(0)
31 {
32  // Set module properties
33  setDescription("The module emulates the timing for gated mode operation of PXD.");
34  setPropertyFlags(c_ParallelProcessingCertified);
35 
36  addParam("PXDIBTimingName", m_PXDIBTimingName,
37  "The name of the StoreObjPtr of generated Injection Bg timing", std::string(""));
38  addParam("minTimePXD", m_minTimePXD,
39  "Minimum time for the first passage of a noise bunch that can deposit charge in the PXD in nano seconds", -20000.0);
40  addParam("maxTimePXD", m_maxTimePXD,
41  "Maximum time for the first passage of a noise bunch that can deposit charge in the PXD in nano seconds", -10000.0);
42  addParam("noiseBunchRevolutionTime",
43  m_revolutionTime, "Noise bunch revolution time in ns", 10000.0);
44  addParam("pxdGatedModeLumiFraction",
45  m_pxdGatedModeLumiFraction, "Fraction of events which are affected by PXD gated mode", 0.2);
46 
47 }
48 
50 {
51  //Register output collections
52  m_storePXDIBTiming.registerInDataStore(m_PXDIBTimingName, DataStore::EStoreFlags::c_ErrorIfAlreadyRegistered);
53 
54  // Get number of PXD gates
55  auto gTools = VXD::GeoCache::getInstance().getGeoTools();
56  m_nGates = gTools->getNumberOfPXDReadoutGates();
57 }
58 
60 {
61  m_storePXDIBTiming.create();
62 
63  // Sample the TriggerGate for this event
64  // TriggerGate is read (sampled-cleared) at t=0
65  int triggerGate = gRandom->Integer(m_nGates);
66  m_storePXDIBTiming->setTriggerGate(triggerGate);
67 
68  // Sample the gating flag for this event
69  bool isGated = false;
70  if (gRandom->Rndm() < m_pxdGatedModeLumiFraction) {isGated = true;}
71  m_storePXDIBTiming->setGated(isGated);
72 
73  // Sample gating start times
74  if (isGated) {
75  float time = 0;
76  // Time when tracks from noise bunches hit PXD
77  time = gRandom->Rndm() * (m_maxTimePXD - m_minTimePXD) + m_minTimePXD;
78  // PXD accumulates charge from four passges of noisy bunches.
79  m_storePXDIBTiming->getGatingStartTimes().push_back(time);
80  m_storePXDIBTiming->getGatingStartTimes().push_back(time + m_revolutionTime);
81  m_storePXDIBTiming->getGatingStartTimes().push_back(time + 2 * m_revolutionTime);
82  m_storePXDIBTiming->getGatingStartTimes().push_back(time + 3 * m_revolutionTime);
83  }
84 
85 }
Base class for Modules.
Definition: Module.h:72
The module produces a StoreObjPtr of PXDInjectionBGTiming containing PXD timing for gated mode operat...
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Definition: GeoCache.h:147
unsigned short getNumberOfPXDReadoutGates(unsigned short=0) const
Get number of PXD readout gates.
Definition: GeoTools.h:167
#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.