ATLAS Offline Software
Loading...
Searching...
No Matches
AFP_PileUpTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef AFP_DIGITIZATION_TOOL_H
6#define AFP_DIGITIZATION_TOOL_H
7
9
10#include "Gaudi/Property.h"
11#include "GaudiKernel/ServiceHandle.h"
14
15#include "AFP_SimEv/AFP_TDSimHitCollection.h" //readhandle template param
16#include "AFP_SimEv/AFP_SIDSimHitCollection.h" //readhandle template param
17#include "AFP_DigiEv/AFP_TDDigiCollection.h" //unique_ptr template param
18#include "AFP_DigiEv/AFP_SiDigiCollection.h" //unique_ptr template param
19#include "xAODForward/AFPToFHitContainer.h" //writehandle template param
20
21#include "xAODForward/AFPSiHitContainer.h" //writehandle template param
22#include "HitManagement/TimedHitCollection.h" //template
23
24#include "AthenaKernel/IAthRNGSvc.h" //svc handle template param
25
26
27#include "TH1F.h" //array member
28#include "TF1.h" //member
29
30#include <string>
31#include <vector>
32#include <utility> /* pair */
33#include <memory> /* unique_ptr */
34
35class AFP_TDSimHit;
36class AFP_SIDSimHit;
37
38namespace CLHEP {
39 class HepRandomEngine;
40}
41
42
44
45public:
46 AFP_PileUpTool(const std::string& type,
47 const std::string& name,
48 const IInterface* parent);
49
50 virtual ~AFP_PileUpTool() {};
51
52 virtual StatusCode initialize() override final;
53 virtual StatusCode finalize() override final;
54
56 StatusCode recoSiHits(const EventContext& ctx, std::unique_ptr<AFP_SiDigiCollection>& siDigiCollection) const;
57
59 StatusCode recoToFHits(const EventContext& ctx, std::unique_ptr<AFP_TDDigiCollection>& digitCollection) const;
60
61 StatusCode recoAll(const EventContext& ctx, std::unique_ptr<AFP_TDDigiCollection>& digitCollection, std::unique_ptr<AFP_SiDigiCollection>& siDigiCollection) const;
62
64 virtual StatusCode prepareEvent(const EventContext& ctx, const unsigned int nInputEvents) override final;
65
67 virtual StatusCode processBunchXing(int bunchXing,
68 SubEventIterator bSubEvents,
69 SubEventIterator eSubEvents
70 ) override final;
73 // virtual bool toProcess(int bunchXing) const;
74
76 virtual StatusCode mergeEvent(const EventContext& ctx) override final;
77
78 virtual StatusCode processAllSubEvents(const EventContext& ctx) override final;
79
81
82 StatusCode fillTDDigiCollection(AFP_TDSimHitCollection& AFP_TDSimHitColl, CLHEP::HepRandomEngine* rndEngine, const EventContext& ctx);
83 StatusCode fillTDDigiCollection(TimedHitCollection<AFP_TDSimHit>& thpcAFP, CLHEP::HepRandomEngine*, const EventContext& ctx, std::unique_ptr<AFP_TDDigiCollection>& digitCollection);
84
85 StatusCode fillSiDigiCollection(AFP_SIDSimHitCollection& AFP_SIDSimHitColl, const EventContext& ctx);
86 StatusCode fillSiDigiCollection(TimedHitCollection<AFP_SIDSimHit>& thpcAFP, const EventContext& ctx, std::unique_ptr<AFP_SiDigiCollection>& siDigiCollection);
87
88
89 void createTDDigi(int Station, int Detector, int SensitiveElement, float GlobalTime, float WafeLength, CLHEP::HepRandomEngine* rndEngine);
90 StatusCode StoreTDDigi(const EventContext& ctx, std::unique_ptr<AFP_TDDigiCollection>& digitCollection) const;
91
92 void createSiDigi(const EventContext& ctx, int Station, int Detector, int PixelRow, int PixelCol, float PreStepX, float PreStepY, float PreStepZ, float PostStepX, float PostStepY, float PostStepZ, float DepEnergy);
93 StatusCode StoreSiDigi(const EventContext& ctx, std::unique_ptr<AFP_SiDigiCollection>& siDigiCollection);
94
95
96 void setupQuantumEff();
97 void setupTDCOffsets();
98
100 double generateSiNoise(CLHEP::HepRandomEngine* rndEngine) const;
102 double generateSiCCE(CLHEP::HepRandomEngine* rndEngine) const;
104 int charge2tot(int) const;
106 int tot2charge(int) const;
108 void addSignalFunc(TH1F &, double) const;
110 double getQE(double ) const;
114 bool isPhotoelectronInduced(double, CLHEP::HepRandomEngine*) const;
116 void addPhotoconvTimeSmear(double &, CLHEP::HepRandomEngine*) const;
118 double getTDC(const TH1F &) const;
120 double getADC(const TH1F &, const double) const;
121
122 double SignalFun(double Time, double RiseTime, double FallTime, double offset = 0.0) const;
123// double SiSignalFun(double Time, double RiseTime, double FallTime);
124
129 Gaudi::Property<std::string> m_totToChargeTransfExpr{this, "TotToChargeTransfExpr", "1909 + x*363 + x*x*141", "Function that transforms time-over-threshold to charge"};
130 Gaudi::Property<std::string> m_totToChargeTransfName{this, "TotToChargeTransfName", "TotToChargeTransfFunction", "Name of the function that transforms time-over-threshold to charge"};
132
133 ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "mergeSvc", "PileUpMergeSvc", ""};
134 ServiceHandle<IAthRNGSvc> m_randomSvc{this, "RndmSvc", "AthRNGSvc", ""};
135 Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName", "AFPRndEng", ""};
136
137 BooleanProperty m_onlyUseContainerName{this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."};
138 SG::ReadHandleKey<AFP_TDSimHitCollection> m_TDSimHitCollectionKey{this, "TDSimHitCollectionName", "AFP_TDSimHitCollection"};
140 SG::WriteHandleKey<AFP_TDDigiCollection> m_TDDigiCollectionKey{this, "TDDigiCollectionName", "AFP_TDDigiCollection", "Name of the Collection to hold the output from the AFP digitization, TD part"};
141 SG::WriteHandleKey<xAOD::AFPToFHitContainer> m_AFPHitsContainerNameToF{this, "AFPHitsContainerNameToF", "AFPToFHitContainer"};
142
143 SG::ReadHandleKey<AFP_SIDSimHitCollection> m_SIDSimHitCollectionKey{this, "SIDSimHitCollectionName", "AFP_SIDSimHitCollection"};
145 SG::WriteHandleKey<AFP_SiDigiCollection> m_SiDigiCollectionKey{this, "SiDigiCollectionName", "AFP_SiDigiCollection", "Name of the Collection to hold the output from the AFP digitization, SiD part"};
146 SG::WriteHandleKey<xAOD::AFPSiHitContainer> m_AFPSiHitsContainerName{this, "AFPSiHitsContainerName", "AFPSiHitContainer",""};
147
148
149 Gaudi::Property<double> m_CollectionEff{this, "CollectionEff", 0.6, "Collection efficiency"};
150 Gaudi::Property<double> m_ConversionSpr{this, "ConversionSpr", 40.0, " Photon-Electron conversion spread in ps"};
151 Gaudi::Property<double> m_RiseTime{this, "RiseTime", 400., "Pulse rise time in ps"};
152 Gaudi::Property<double> m_FallTime{this, "FallTime", 1200., "Pulse fall time in ps"};
153 Gaudi::Property<double> m_TofSignalTimeRangeLength{this, "TofSignalTimeRangeLength", 4000., "in ps"};
154 Gaudi::Property<double> m_TimeOffset{this, "TimeOffset", 104500., "Offset reflecting time that proton travels from IP to AFP"};
155 Gaudi::Property<double> m_CfSignalDelay{this, "CfSignalDelay", 200., "Pulse delay for const. frac. discrimination"};
156 Gaudi::Property<double> m_CfdThr{this, "CfdThr", 0.5, "Constant fraction threshold"};
157 Gaudi::Property<double> m_SiT_ChargeCollEff{this, "SiT_ChargeCollEff", 0.55, "CCE, adjusted to describe data"};
158 Gaudi::Property<double> m_SiT_ChargeCollEffSigma{this, "SiT_ChargeCollEffSigma", 0.2, "sigma(CCE), adjusted to describe data"};
159 Gaudi::Property<double> m_SiT_NoiseMu{this, "SiT_NoiseMu", 160., "unit = number of eh pairs"};
160 Gaudi::Property<double> m_SiT_NoiseSigma{this, "SiT_NoiseSigma", 10., "unit = number of eh pairs"};
161 Gaudi::Property<double> m_SiT_Energy2ChargeFactor{this, "SiT_Energy2ChargeFactor", 1000000./3.6, "number of eh pairs per MeV"};
162 Gaudi::Property<int> m_SiT_ToTThresholdForHit{this, "SiT_ChargeThresholdForHit", 1, ""};
163
164 enum QEFF_VER { QE1=1, QE2=2, nQEffOpts=3 };
165 Gaudi::Property<int> m_QEffVer{this, "QEffVer", 1, "quantum efficiency version; QE1=1, QE2=2, nQEffOpts=3"};
166
169
170 double m_QuantumEff_PMT[82]{};
171 double m_TDC_offsets[4][4][4]{}; // station, train, bar
172 int m_ChargeVsTot_LUT[16]{}; // look-up table for charge2tot conversion, 16 = n. of bits
173
174 const int m_ArrSize; // 645120 = 4 x 6 x 336 x 80
175 std::vector<float> m_deposited_charge;
176 std::vector<float> m_deposited_energy;
177
179 std::vector<double> m_SignalVect;
180
182 TH1F m_SignalHist[4][4][4]{}; // station, train, bar
183
184protected:
185
187 void newXAODHitToF (std::unique_ptr<xAOD::AFPToFHitContainer>& tofHitContainer, std::unique_ptr<AFP_TDDigiCollection>& collection) const;
188
190 void newXAODHitSi (std::unique_ptr<xAOD::AFPSiHitContainer>& xAODSiHit, std::unique_ptr<AFP_SiDigiCollection>& collection) const;
191
192 std::unique_ptr<AFP_TDDigiCollection> m_digitCollection;
193 std::unique_ptr<AFP_SiDigiCollection> m_SiDigiCollection;
194
195};
196
197#endif
AtlasHitsVector< AFP_SIDSimHit > AFP_SIDSimHitCollection
AtlasHitsVector< AFP_SiDigi > AFP_SiDigiCollection
float getTDC(const AFP_SiDigi &digi)
Definition AFP_SiDigi.h:25
float getADC(const AFP_SiDigi &digi)
Definition AFP_SiDigi.h:29
AtlasHitsVector< AFP_TDDigi > AFP_TDDigiCollection
AtlasHitsVector< AFP_TDSimHit > AFP_TDSimHitCollection
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition IPileUpTool.h:22
the preferred mechanism to access information from the different event stores in a pileup job.
helper base class IPileUpTool::toProcess().
int m_ChargeVsTot_LUT[16]
TF1 m_totToChargeTransformation
double getQE(double) const
Provides quantum efficiency for given wavelength (in nm)
StatusCode StoreTDDigi(const EventContext &ctx, std::unique_ptr< AFP_TDDigiCollection > &digitCollection) const
std::vector< float > m_deposited_energy
StatusCode fillTDDigiCollection(AFP_TDSimHitCollection &AFP_TDSimHitColl, CLHEP::HepRandomEngine *rndEngine, const EventContext &ctx)
Gaudi::Property< int > m_QEffVer
Gaudi::Property< double > m_CfdThr
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
std::unique_ptr< AFP_TDDigiCollection > m_digitCollection
AFP_SIDSimHitCollection m_mergedSIDSimHitList
virtual StatusCode initialize() override final
SG::ReadHandleKey< AFP_TDSimHitCollection > m_TDSimHitCollectionKey
virtual StatusCode finalize() override final
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Gaudi::Property< double > m_TofSignalTimeRangeLength
void createSiDigi(const EventContext &ctx, int Station, int Detector, int PixelRow, int PixelCol, float PreStepX, float PreStepY, float PreStepZ, float PostStepX, float PostStepY, float PostStepZ, float DepEnergy)
virtual StatusCode prepareEvent(const EventContext &ctx, const unsigned int nInputEvents) override final
called before the subevts loop. Not (necessarily) able to access SubEvents
void resetSignalHistograms()
Invokes Reset() on all m_SignalHist objects.
double m_QuantumEff_PMT[82]
std::unique_ptr< AFP_SiDigiCollection > m_SiDigiCollection
double m_TDC_offsets[4][4][4]
StatusCode fillSiDigiCollection(AFP_SIDSimHitCollection &AFP_SIDSimHitColl, const EventContext &ctx)
SG::WriteHandleKey< xAOD::AFPSiHitContainer > m_AFPSiHitsContainerName
SG::WriteHandleKey< xAOD::AFPToFHitContainer > m_AFPHitsContainerNameToF
Gaudi::Property< double > m_SiT_Energy2ChargeFactor
int tot2charge(int) const
Function that converts discrete time-over-threshold to discrete charge.
Gaudi::Property< std::string > m_totToChargeTransfName
Gaudi::Property< double > m_SiT_NoiseMu
std::string m_TDSimHitCollectionName
void addPhotoconvTimeSmear(double &, CLHEP::HepRandomEngine *) const
Modifies the hit time passed as an argument by the photoconversion time smearing.
virtual StatusCode mergeEvent(const EventContext &ctx) override final
return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase...
AFP_PileUpTool(const std::string &type, const std::string &name, const IInterface *parent)
std::vector< double > m_SignalVect
vector with pre-calculated single signal from the photoelectron
double SignalFun(double Time, double RiseTime, double FallTime, double offset=0.0) const
BooleanProperty m_onlyUseContainerName
void newXAODHitSi(std::unique_ptr< xAOD::AFPSiHitContainer > &xAODSiHit, std::unique_ptr< AFP_SiDigiCollection > &collection) const
Method that creates a new AFPSiHit and sets it valus according to digi collection.
void addSignalFunc(TH1F &, double) const
Adds pre-calculated single photoelectron signal function stored in m_SignalVect to the passed histogr...
Gaudi::Property< double > m_SiT_ChargeCollEffSigma
Gaudi::Property< double > m_RiseTime
int charge2tot(int) const
Function that converts quasi-continous charge to discrete time-over-threshold.
void newXAODHitToF(std::unique_ptr< xAOD::AFPToFHitContainer > &tofHitContainer, std::unique_ptr< AFP_TDDigiCollection > &collection) const
Method that creates a new AFPToFHit and sets it valus according to digi collection.
Gaudi::Property< int > m_SiT_ToTThresholdForHit
virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
called for each active bunch-crossing to process current SubEvents bunchXing is in ns
Gaudi::Property< double > m_SiT_ChargeCollEff
TH1F m_SignalHist[4][4][4]
array of histograms storing final signals in the PMTs
Gaudi::Property< std::string > m_totToChargeTransfExpr
Function that transforms time-over-threshold to charge.
double generateSiCCE(CLHEP::HepRandomEngine *rndEngine) const
Function that provides charge collection efficiency.
Gaudi::Property< double > m_FallTime
std::vector< float > m_deposited_charge
bool isPhotoelectronInduced(double, CLHEP::HepRandomEngine *) const
Returns random response if the photon of given wavelegth induces the photoelectron.
const int m_ArrSize
SG::WriteHandleKey< AFP_TDDigiCollection > m_TDDigiCollectionKey
StatusCode recoAll(const EventContext &ctx, std::unique_ptr< AFP_TDDigiCollection > &digitCollection, std::unique_ptr< AFP_SiDigiCollection > &siDigiCollection) const
virtual ~AFP_PileUpTool()
ServiceHandle< IAthRNGSvc > m_randomSvc
std::string m_SIDSimHitCollectionName
Gaudi::Property< double > m_ConversionSpr
SG::WriteHandleKey< AFP_SiDigiCollection > m_SiDigiCollectionKey
void createTDDigi(int Station, int Detector, int SensitiveElement, float GlobalTime, float WafeLength, CLHEP::HepRandomEngine *rndEngine)
Gaudi::Property< double > m_CollectionEff
StatusCode StoreSiDigi(const EventContext &ctx, std::unique_ptr< AFP_SiDigiCollection > &siDigiCollection)
double generateSiNoise(CLHEP::HepRandomEngine *rndEngine) const
Function that provides random noise (in charge units)
Gaudi::Property< double > m_SiT_NoiseSigma
Gaudi::Property< std::string > m_randomStreamName
SG::ReadHandleKey< AFP_SIDSimHitCollection > m_SIDSimHitCollectionKey
Gaudi::Property< double > m_CfSignalDelay
AFP_TDSimHitCollection m_mergedTDSimHitList
StatusCode recoToFHits(const EventContext &ctx, std::unique_ptr< AFP_TDDigiCollection > &digitCollection) const
Creates xAOD for time-of-flight detector.
StatusCode recoSiHits(const EventContext &ctx, std::unique_ptr< AFP_SiDigiCollection > &siDigiCollection) const
Creates xAOD for silicon detector.
Gaudi::Property< double > m_TimeOffset
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Support class for PropertyMgr.
Definition Property.h:23
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
STL class.
=============================================================================
STL namespace.
#define private