ATLAS Offline Software
Loading...
Searching...
No Matches
TileDigitsFromPulse.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5//****************************************************************************
6// Filename : TileDigitsFromPulse.h
7// Author : Simon Molander <simon.molander@cern.ch>
8// Created : Feb 2013
9//
10// DESCRIPTION
11//
12// Create TileDigits from pulse simulator
13//
14// Properties (JobOption Parameters):
15//
16// OutputDigitsContainer string Name of container with TileDigits to write
17// ImperfectionMean double Mean value of pulse shape broadening
18// ImperfectionRMS double RMS of pulse shape broadening
19// InTimeAmp double Amplitude of in-time pulse
20// OutOfTimeAmp double Amplitude of out-of-time pulse
21// InTimeOffset double In-time pulse offset from nominal time
22// OutOfTimeOffset double Out-of-time pulse offset from nominal time
23// UseGaussNoise bool Set to TRUE in order to create noise from double gaussian
24// GaussNoiseAmpOne double Amplitude of first gaussian of double gaussian noise.
25// GaussNoiseSigmaOne double Standard deviation of first gaussian of double gaussian noise.
26// GaussNoiseAmpTwo double Amplitude of second gaussian of double gaussian noise.
27// GaussNoiseSigmaTwo double Standard deviation of second gaussian of double gaussian noise.
28// UseInTimeAmpDist bool Set to TRUE in order to use a distribution for the in-time amplitude instead of a const.
29// UseOutOfTimeAmpDist bool Set to TRUE in order to use a distribution for the out-of-time amplitude instead of a const.
30// InTimeAmpDistFileName string Filename of file to use for amplitude distribution of in-time pulses
31// OutOfTimeAmpDistFileName string Filename of file to use for amplitude distribution of out-of-time pulses
32// PileUpFraction float Probability that an out-of-time component will be added
33// GaussianC2CPhaseVariation float RMS for the in-time pulse offset (channel-to-channel phase variation)
34// ChannelSpecificPedestal bool Set to TRUE in order to use a channel specific value for the pedestal
35// ChannelSpecificNoise bool Set to TRUE in order to add channel specific noise
36// OutOfTimeOffsetHistogramFile string Filename of file containing histogram of pile-up timing distribution
37// OutOfTimeOffsetHistogramName string name of the histogram to use for pile-up timing distribution
38// AmpDistLowerLimit int Set all bins lower than this to zero. Default = 135.
39// InTimeAmpDistHistogramName string Name of the histogram to use for in-time amplitude distribution
40// OutOfTimeAmpDistHistogramName string Name of the histogram to use for out-of-time amplitude distribution
41//
42// BUGS:
43//
44// History:
45//
46//
47//****************************************************************************
48
49#ifndef TILESIMALGS_TILEDIGITSFROMPULSE_H
50#define TILESIMALGS_TILEDIGITSFROMPULSE_H
51
52// Tile includes
56
57// Athena includes
60
61// Gaudi includes
62#include "GaudiKernel/ServiceHandle.h"
63#include "GaudiKernel/Algorithm.h"
64#include "GaudiKernel/ToolHandle.h"
65
66#include "CLHEP/Random/RandomEngine.h"
67
68//C++ STL includes
69#include <vector>
70#include <string>
71#include <array>
72#include "Gaudi/Property.h"
73
74//Simulation includes
77class TilePulseShape;
78
79class TileHWID;
80class TileInfo;
81class IAthRNGSvc;
82
83class TH1F;
84class TFile;
85class TRandom3;
86
92public:
93 // Constructor
94 TileDigitsFromPulse(const std::string& name, ISvcLocator* pSvcLocator);
95
96 //Destructor
97 virtual ~TileDigitsFromPulse();
98
99 //Gaudi Hooks
100 virtual StatusCode initialize() override;
101 virtual StatusCode execute(const EventContext& ctx) override;
102 virtual StatusCode finalize() override;
103
104private:
105 std::string m_outputContainer;
106
108
109 // TileInfo
110 Gaudi::Property<std::string> m_infoName{this, "TileInfoName", "TileInfo"};
113
116
117 ToolHandle<TileCondToolNoiseSample> m_tileToolNoiseSample{this,
118 "TileCondToolNoiseSample", "TileCondToolNoiseSample", "Tile sample noise tool"};
119
121 "TileDigitsContainer", "TileDigitsCnt", "Output Tile digits container key"};
122
124 "TileRawChannelContainer", "TrueAmp", "Output Tile raw channel container key"};
125
126 ServiceHandle <IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""};
128 Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName", "Tile_DigitsMaker", ""};
129
130
131 //Parameters
132 Gaudi::Property<double> m_imperfectionMean{this, "ImperfectionMean", 1.01};
133 Gaudi::Property<double> m_imperfectionRms{this, "ImperfectionRms", 0.02};
134 Gaudi::Property<double> m_inTimeAmp{this, "InTimeAmp", 300.};
135 Gaudi::Property<double> m_ootAmp{this, "OutOfTimeAmp", 150.};
136 Gaudi::Property<double> m_itOffset{this, "InTimeOffset", 0.};
137 Gaudi::Property<double> m_ootOffset{this, "OutOfTimeOffset", 50.};
138 Gaudi::Property<double> m_ped_HG{this, "PedestalValueHG", 100};
139 Gaudi::Property<double> m_ped_LG{this, "PedestalValueLG", 100};
140 Gaudi::Property<bool> m_gaussNoise{this, "UseGaussNoise", false};
141 Gaudi::Property<double> m_GNAmpOne{this, "GaussNoiseAmpOne", 1 / 1.039};
142 Gaudi::Property<double> m_GNSigmaOne{this, "GaussNoiseSigmaOne", 1.6};
143 Gaudi::Property<double> m_GNAmpTwo{this, "GaussNoiseAmpTwo", 0.039};
144 Gaudi::Property<double> m_GNSigmaTwo{this, "GaussNoiseSigmaTwo", 3.6};
145 Gaudi::Property<bool> m_useItADist{this, "UseInTimeAmpDist", false};
146 Gaudi::Property<double> m_itAPulseProb{this, "InTimeAmpPulseProb", 0};
147 Gaudi::Property<bool> m_useOotADist{this, "UseOutOfTimeAmpDist", false};
148 Gaudi::Property<float> m_pileUpFraction{this, "PileUpFraction", 1};
149 Gaudi::Property<float> m_gausC2C{this, "GaussianC2CPhaseVariation", 0};
150 Gaudi::Property<double> m_gaussianPulseTimingVariation{
151 this, "GaussianPulseTimingVariation", 0.0
152 };
153 Gaudi::Property<std::string> m_itADistFileName{this, "InTimeAmpDistFileName", ""};
154 Gaudi::Property<std::string> m_ootADistFileName{this, "OutOfTimeAmpDistFileName", ""};
155 Gaudi::Property<bool> m_chanPed{this, "ChannelSpecificPedestal", false};
156 Gaudi::Property<bool> m_chanNoise{this, "ChannelSpecificNoise", false};
157 Gaudi::Property<std::string> m_ootOffsetFileName{this, "OutOfTimeOffsetHistogramFile", ""};
158 Gaudi::Property<std::string> m_ootOffsetHistName{this, "OutOfTimeOffsetHistogramName", ""};
159 Gaudi::Property<int> m_AmpDistLowLim{this, "AmpDistLowerLimit", 135};
160 Gaudi::Property<std::string> m_itADistHistName{this, "InTimeAmpDistHistogramName", "h_Eopt_hi"};
161 Gaudi::Property<std::string> m_ootADistHistName{this, "OutOfTimeAmpDistHistogramName", "h_Eopt_hi"};
162
163 Gaudi::Property<bool> m_simQIE{this, "SimulateQIE", false};
164 Gaudi::Property<bool> m_simPulseChain{this, "SimulatePulseChain", false};
165 Gaudi::Property<bool> m_useGainDependentUndershoot{
166 this, "UseGainDependentUndershoot", false
167 };
168 Gaudi::Property<bool> m_useRecursiveUndershoot{
169 this, "UseRecursiveUndershoot", false
170 };
171
172 Gaudi::Property<int> m_seed{this, "RandomSeed", 4357};
173 Gaudi::Property<int> m_BunchSpacing{this, "BunchSpacing", 25};
174 Gaudi::Property<int> m_nSamples{this, "NSamples", 7};
175 Gaudi::Property<int> m_nPul{this, "NPulses", 21};
176 int m_nPul_eff{}; //Used for symetrization of PU in computation
177 std::vector<std::vector<std::vector<std::vector<float>>>> m_PUAmp; // Pulse amplitude history (in HG ADC counts)
178 std::vector<std::vector<std::vector<std::vector<double>>>> m_pulseTimeOffsets; // Pulse arrival-time history in ns
179
180 // Recursive accumulation of the long undershoot
181 std::vector<std::vector<std::vector<std::array<double, 2>>>> m_accumulatedUndershoot; // Accumulated undershoot per channel and gain (LG, HG)
182 std::array<double, 2> m_tailDecayPerBC{}; // Exponential decay factor over 25 ns, exp(-25/tau)
183 std::array<double, 2> m_tailAtAccumulation{}; // Normalized tail amplitude when a pulse enters the accumulator
184 std::array<int, 2> m_firstAccumulatedIndex{}; // Index of the first pulse included in the accumulated undershoot
185 std::array<int, 2> m_firstRelevantIndex{}; // Index of the first pulse contributing to the current sample
186 int m_pulseHistorySize{}; // Number of pulse amplitudes retained in the history
187
188 Gaudi::Property<bool> m_PhaseII{this, "TilePhaseII", false}; //Use parameters of TilePhaseII if the option is set to true
189 Gaudi::Property<bool> m_bigain{this, "Bigain", false}; //If true, save the two gains in the ntuples
190
191 Gaudi::Property<bool> m_simPUwPoisson{this, "SimulatePileUpWithPoiss", false}; //If true, simulate PU overlapping amplitudes n times, with n being generated with a poissonian distribution
192 Gaudi::Property<int> m_avgMuForPU{this, "AvgMuForPileUpSimulation", 40}; //Mean of the poissonian distribution to generate the number of interactions per bunch crossing for PU simulation
193 Gaudi::Property<std::string> m_pileupAmpDistFileName{this, "PileUpAmpDistFileName", ""};
194
195 //Members for simulator
199
200 //Histograms for distribution
201 TH1F* m_ootDist;
202 TH1F* m_itDist;
203 TFile* m_itFile;
204 TFile* m_ootFile;
207 bool m_useOffsetHisto{false};
209 std::vector<std::vector<TH1F*>> m_pileup_AmpDists;
210
211 //Internal methods
212 bool makeDist(TFile*& file, TH1F*& hist, const std::string& fileName, const std::string& histName="h_Eopt_hi");
213 bool makeDist(TFile*& file, std::vector<std::vector<TH1F*>>& hists, const std::string& fileName);
214
215 void addPileUp(double &n_inTimeAmp, double ootAmp, int gain, int ros, int drawer, int channel);
216 void addPileUpSample(int gain, int ros, int drawer, int channel);
217 double generatePulseTimeOffset();
218
219 float m_sample_tru = 0;
220
221 std::unique_ptr<TRandom3> m_random;
222};
223
224#endif // TILESIMALGS_TILEDIGITSFROMPULSE_H
225
Property holding a SG store/key/clid from which a WriteHandle is made.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
manage multiple RandomEngines in thread-safe way.
Definition IAthRNGSvc.h:28
Property holding a SG store/key/clid from which a WriteHandle is made.
Gaudi::Property< float > m_gausC2C
RMS for the in-time pulse offset (channel-to-channel phase variation).
TFile * m_pileup_AmpDistFile
File containing amplitude histograms for PU pulses.
Gaudi::Property< double > m_ped_HG
Pedestal value for HG if specific channel pedestal is not used.
TFile * m_itFile
File that holds the distribution of in-time amplitudes.
Gaudi::Property< bool > m_useRecursiveUndershoot
Recursively accumulate the long undershoot in continuous readout.
Gaudi::Property< bool > m_useGainDependentUndershoot
Use gain-dependent analytical undershoot parameters.
SG::WriteHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
Gaudi::Property< double > m_ootOffset
Out-of-time pulse offset from nominal time.
Gaudi::Property< std::string > m_ootADistFileName
Filename of file to use for amplitude distribution of out-of-time pulses.
void addPileUp(double &n_inTimeAmp, double ootAmp, int gain, int ros, int drawer, int channel)
Fill vector with pile-up amplitudes.
const TileHWID * m_tileHWID
std::array< int, 2 > m_firstAccumulatedIndex
Gaudi::Property< double > m_ped_LG
Pedestal value for LG if specific channel pedestal is not used.
virtual StatusCode initialize() override
initialize method
virtual StatusCode finalize() override
finalize method
Gaudi::Property< float > m_pileUpFraction
Probability that an out-of-time component will be added.
Gaudi::Property< std::string > m_infoName
std::string m_outputContainer
Name of the output TileDigitsContainer.
Gaudi::Property< bool > m_useOotADist
Set to TRUE in order to use a distribution for the out-of-time amplitude instead of a constant value.
Gaudi::Property< double > m_itOffset
In-time pulse offset from nominal time.
TH1F * m_ootDist
Histogram to hold the distribution of out-of-time amplitudes.
Gaudi::Property< bool > m_chanPed
Use channel specific pedestal value if true.
TFile * m_ootFile
File that holds the distribution of out-of-time amplitudes.
TileFragHash::TYPE m_rChType
Type of TileRawChannels (Digitizar, OF1, OF2, Fit, etc.)(see TileFragHash.h).
TileSampleBuffer * m_buf
Buffer class to hold generated pulses.
ToolHandle< TileCondToolNoiseSample > m_tileToolNoiseSample
virtual StatusCode execute(const EventContext &ctx) override
execute method
TFile * m_ootOffsetFile
File that holds the distribution of out-of-time timing offsets.
std::vector< std::vector< std::vector< std::vector< double > > > > m_pulseTimeOffsets
Gaudi::Property< double > m_GNSigmaOne
Standard deviation of first gaussian of double gaussian noise.
Gaudi::Property< std::string > m_itADistHistName
Name of histogram for in-time amplitude distribution.
Gaudi::Property< std::string > m_pileupAmpDistFileName
Filename for PU amplitude distribution histograms.
void addPileUpSample(int gain, int ros, int drawer, int channel)
Fill only a BC with pile-up amplitude.
std::vector< std::vector< std::vector< std::vector< float > > > > m_PUAmp
Gaudi::Property< std::string > m_ootOffsetFileName
File name for offset timing distribution histogram.
std::unique_ptr< TRandom3 > m_random
Gaudi::Property< int > m_nPul
number of pileup pulses
Gaudi::Property< double > m_imperfectionMean
Mean value of pulse shape broadening.
Gaudi::Property< double > m_GNSigmaTwo
Standard deviation of second gaussian of double gaussian noise.
Gaudi::Property< int > m_seed
bool m_useOffsetHisto
Internally used to keep track of wether a histogram has been opened or not.
TileRawChannelUnit::UNIT m_rChUnit
Units used for the TileRawChannels (ADC, pCb, etc.)(see TileInfo.h).
const TileInfo * m_tileInfo
std::vector< std::vector< std::vector< std::array< double, 2 > > > > m_accumulatedUndershoot
Gaudi::Property< int > m_BunchSpacing
Time between pulses in ms 25, 50 or 75.
double generatePulseTimeOffset()
Generate a pulse arrival-time variation in ns.
TH1F * m_ootOffsetDist
Histogram to hold the distribution of out-of-time timing offsets.
SG::WriteHandleKey< TileDigitsContainer > m_digitsContainerKey
Gaudi::Property< bool > m_gaussNoise
Set to TRUE in order to create noise from double gaussian.
Gaudi::Property< std::string > m_itADistFileName
Filename of file to use for amplitude distribution of in-time pulses.
Gaudi::Property< bool > m_bigain
Gaudi::Property< double > m_itAPulseProb
Probability to add an in-time pulse.
Gaudi::Property< double > m_GNAmpOne
Amplitude of first gaussian of double gaussian noise.
TilePulseShape * m_ps[2]
Class for defining pulse.
Gaudi::Property< double > m_imperfectionRms
RMS of pulse shape broadening.
ServiceHandle< IAthRNGSvc > m_rndmSvc
Random number service to use.
Gaudi::Property< double > m_gaussianPulseTimingVariation
RMS of individual pulse arrival-time variations in ns.
Gaudi::Property< int > m_avgMuForPU
TileSampleGenerator * m_tsg
Pulse generating class.
Gaudi::Property< int > m_nSamples
number of read out samples
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Gaudi::Property< double > m_GNAmpTwo
Amplitude of second gaussian of double gaussian noise.
Gaudi::Property< int > m_AmpDistLowLim
Set all bins to the left of this bin to 0 in the amplitude distribution histograms.
bool makeDist(TFile *&file, TH1F *&hist, const std::string &fileName, const std::string &histName="h_Eopt_hi")
Method to read distribution from file.
std::array< double, 2 > m_tailAtAccumulation
TH1F * m_itDist
Histogram to hold the distribution of in-time amplitudes.
Gaudi::Property< std::string > m_ootOffsetHistName
Name of the histogram for timing offset distribution.
Gaudi::Property< bool > m_chanNoise
Add channel specific noise.
Gaudi::Property< bool > m_simPulseChain
Simulate continous output of readout for HL-LHC paradigm.
Gaudi::Property< bool > m_useItADist
Set to TRUE in order to use a distribution for the in-time amplitude instead of a constant value.
Gaudi::Property< bool > m_PhaseII
std::array< int, 2 > m_firstRelevantIndex
TileDigitsFromPulse(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< std::vector< TH1F * > > m_pileup_AmpDists
Matrix of PU amplitude distribution histograms (PU per partition and channel).
std::array< double, 2 > m_tailDecayPerBC
Gaudi::Property< bool > m_simQIE
Raw PMT pulses are generated if the option is set to true.
Gaudi::Property< bool > m_simPUwPoisson
Gaudi::Property< double > m_inTimeAmp
Amplitude of in-time pulse.
Gaudi::Property< double > m_ootAmp
Amplitude of out-of-time pulse.
Gaudi::Property< std::string > m_ootADistHistName
Name of histogram for out-of-time amplitude distribution.
TYPE
initialize
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
TFile * file