Belle II Software development
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#include <pxd/dataobjects/PXDInjectionBGTiming.h>
13
14#include <vector>
15
16#include <TRandom3.h>
17
18using namespace Belle2;
19using namespace std;
20
21//-----------------------------------------------------------------
22// Register the Module
23//-----------------------------------------------------------------
24REG_MODULE(PXDInjectionVetoEmulator);
25
26//-----------------------------------------------------------------
27// Implementation
28//-----------------------------------------------------------------
29
31 , m_nGates(0)
32{
33 // Set module properties
34 setDescription("The module emulates the timing for gated mode operation of PXD.");
36
37 addParam("PXDIBTimingName", m_PXDIBTimingName,
38 "The name of the StoreObjPtr of generated Injection Bg timing", std::string(""));
39 addParam("minTimePXD", m_minTimePXD,
40 "Minimum time for the first passage of a noise bunch that can deposit charge in the PXD in nano seconds", -20000.0);
41 addParam("maxTimePXD", m_maxTimePXD,
42 "Maximum time for the first passage of a noise bunch that can deposit charge in the PXD in nano seconds", -10000.0);
43 addParam("noiseBunchRevolutionTime",
44 m_revolutionTime, "Noise bunch revolution time in ns", 10000.0);
45 addParam("pxdGatedModeLumiFraction",
46 m_pxdGatedModeLumiFraction, "Fraction of events which are affected by PXD gated mode", 0.2);
47
48}
49
51{
52 //Register output collections
54
55 // Get number of PXD gates
57 m_nGates = gTools->getNumberOfPXDReadoutGates();
58}
59
61{
62 m_storePXDIBTiming.create();
63
64 // Sample the TriggerGate for this event
65 // TriggerGate is read (sampled-cleared) at t=0
66 int triggerGate = gRandom->Integer(m_nGates);
67 m_storePXDIBTiming->setTriggerGate(triggerGate);
68
69 // Sample the gating flag for this event
70 bool isGated = false;
71 if (gRandom->Rndm() < m_pxdGatedModeLumiFraction) {isGated = true;}
72 m_storePXDIBTiming->setGated(isGated);
73
74 // Sample gating start times
75 if (isGated) {
76 float time = 0;
77 // Time when tracks from noise bunches hit PXD
78 time = gRandom->Rndm() * (m_maxTimePXD - m_minTimePXD) + m_minTimePXD;
79 // PXD accumulates charge from four passges of noisy bunches.
80 m_storePXDIBTiming->getGatingStartTimes().push_back(time);
81 m_storePXDIBTiming->getGatingStartTimes().push_back(time + m_revolutionTime);
82 m_storePXDIBTiming->getGatingStartTimes().push_back(time + 2 * m_revolutionTime);
83 m_storePXDIBTiming->getGatingStartTimes().push_back(time + 3 * m_revolutionTime);
84 }
85
86}
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition DataStore.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
Module()
Constructor.
Definition Module.cc:30
@ 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:141
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.