Belle II Software  release-08-01-10
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.");
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
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_PXDIBTimingName
The name of the StoreObjPtr of PXDInjectionBGTiming to be generated.
double m_minTimePXD
Minimal global time for injection veto for PXD.
double m_revolutionTime
Revolution time of noise bunches.
double m_maxTimePXD
Maximal global time for injection veto for PXD.
int m_nGates
Number of readout gates (or total number of Switcher channels)
StoreObjPtr< PXDInjectionBGTiming > m_storePXDIBTiming
Output object for injection Bkg timing for PXD.
PXDInjectionVetoEmulatorModule()
Constructor: Sets the description, the properties and the parameters of the module.
double m_pxdGatedModeLumiFraction
Fraction of time in the PXD Gated Mode for the PXD readout.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Definition: GeoCache.h:147
REG_MODULE(arichBtest)
Register the Module.
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
Abstract base class for different kinds of events.