Belle II Software  release-05-01-25
PXDInjectionVetoEmulatorModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Benjamin Schwenker *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <pxd/modules/pxdSimulation/PXDInjectionVetoEmulatorModule.h>
12 #include <vxd/geometry/GeoCache.h>
13 #include <vxd/geometry/GeoTools.h>
14 
15 #include <vector>
16 
17 #include <TRandom3.h>
18 
19 using namespace Belle2;
20 using namespace std;
21 
22 //-----------------------------------------------------------------
23 // Register the Module
24 //-----------------------------------------------------------------
25 REG_MODULE(PXDInjectionVetoEmulator)
26 
27 //-----------------------------------------------------------------
28 // Implementation
29 //-----------------------------------------------------------------
30 
32  , m_nGates(0)
33 {
34  // Set module properties
35  setDescription("The module emulates the timing for gated mode operation of PXD.");
36  setPropertyFlags(c_ParallelProcessingCertified);
37 
38  addParam("PXDIBTimingName", m_PXDIBTimingName,
39  "The name of the StoreObjPtr of generated Injection Bg timing", std::string(""));
40  addParam("minTimePXD", m_minTimePXD,
41  "Minimum time for the first passage of a noise bunch that can deposit charge in the PXD in nano seconds", -20000.0);
42  addParam("maxTimePXD", m_maxTimePXD,
43  "Maximum time for the first passage of a noise bunch that can deposit charge in the PXD in nano seconds", -10000.0);
44  addParam("noiseBunchRevolutionTime",
45  m_revolutionTime, "Noise bunch revolution time in ns", 10000.0);
46  addParam("pxdGatedModeLumiFraction",
47  m_pxdGatedModeLumiFraction, "Fraction of events which are affected by PXD gated mode", 0.2);
48 
49 }
50 
52 {
53  //Register output collections
54  m_storePXDIBTiming.registerInDataStore(m_PXDIBTimingName, DataStore::EStoreFlags::c_ErrorIfAlreadyRegistered);
55 
56  // Get number of PXD gates
57  auto gTools = VXD::GeoCache::getInstance().getGeoTools();
58  m_nGates = gTools->getNumberOfPXDReadoutGates();
59 }
60 
62 {
63  m_storePXDIBTiming.create();
64 
65  // Sample the TriggerGate for this event
66  // TriggerGate is read (sampled-cleared) at t=0
67  int triggerGate = gRandom->Integer(m_nGates);
68  m_storePXDIBTiming->setTriggerGate(triggerGate);
69 
70  // Sample the gating flag for this event
71  bool isGated = false;
72  if (gRandom->Rndm() < m_pxdGatedModeLumiFraction) {isGated = true;}
73  m_storePXDIBTiming->setGated(isGated);
74 
75  // Sample gating start times
76  if (isGated) {
77  float time = 0;
78  // Time when tracks from noise bunches hit PXD
79  time = gRandom->Rndm() * (m_maxTimePXD - m_minTimePXD) + m_minTimePXD;
80  // PXD accumulates charge from four passges of noisy bunches.
81  m_storePXDIBTiming->getGatingStartTimes().push_back(time);
82  m_storePXDIBTiming->getGatingStartTimes().push_back(time + m_revolutionTime);
83  m_storePXDIBTiming->getGatingStartTimes().push_back(time + 2 * m_revolutionTime);
84  m_storePXDIBTiming->getGatingStartTimes().push_back(time + 3 * m_revolutionTime);
85  }
86 
87 }
Belle2::PXDInjectionVetoEmulatorModule
The module produces a StoreObjPtr of PXDInjectionBGTiming containing PXD timing for gated mode operat...
Definition: PXDInjectionVetoEmulatorModule.h:38
Belle2::VXD::GeoTools::getNumberOfPXDReadoutGates
unsigned short getNumberOfPXDReadoutGates(unsigned short=0) const
Get number of PXD readout gates.
Definition: GeoTools.h:177
Belle2::PXDInjectionVetoEmulatorModule::initialize
void initialize() override final
Initialize the Module.
Definition: PXDInjectionVetoEmulatorModule.cc:51
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::PXDInjectionVetoEmulatorModule::event
void event() override final
This method is the core of the module.
Definition: PXDInjectionVetoEmulatorModule.cc:61
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::VXD::GeoCache::getInstance
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:215
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::VXD::GeoCache::getGeoTools
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Definition: GeoCache.h:149