ATLAS Offline Software
Loading...
Searching...
No Matches
LArPhysWaveTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8 const std::string& name,
9 const IInterface* parent )
10 : AthAlgTool(type,name,parent)
11{
12 // Declare additional interface
13 declareInterface<LArPhysWaveTool>(this);
14
15 // Prepare defaults property values
16 bool injPcorr[4] = { false , true , true , false } ;
17 m_injPointCorrLayer.clear();
18 for ( unsigned i=0;i<4;i++ ) m_injPointCorrLayer.push_back(injPcorr[i]) ;
19
20 bool injPtaur[4] = { false , false , true , false } ;
21 m_injPointUseTauR.clear();
22 for ( unsigned i=0;i<4;i++ ) m_injPointUseTauR.push_back(injPtaur[i]) ;
23
24 // Declare properties
25 declareProperty("InjPointCorr", m_injPointCorr=false);
26 declareProperty("InjPointCorrLayer",m_injPointCorrLayer);
27 declareProperty("InjPointUseTauR", m_injPointUseTauR);
28 declareProperty("NormalizeCali", m_normalizeCali=true);
29 declareProperty("TimeOriginShift", m_timeOriginShift=false);
30 declareProperty("SubtractBaseline", m_subtractBaseline=true);
31}
32
34
35
36
37StatusCode LArPhysWaveTool::makeLArPhysWave(const LArWFParams& larWFParam,
38 const LArCaliWave& larCaliWave,
39 int /*region*/, int layer,
40 LArPhysWave& predLArPhysWave,
41 float& MphysMcali) const {
42
43
44 // calib. signal at Mother Board :
45 LArWave gCaliMB(larCaliWave);
46 LArWave gPhys;
47 LArWaveHelper wHelper;
48
49 // shift gCaliMB to start point and remove baseline
50
51 unsigned tstart = wHelper.getStart(gCaliMB) ;
52 double baseline = wHelper.getBaseline(gCaliMB,tstart) ;
53 if ( m_subtractBaseline ) gCaliMB = gCaliMB + (-baseline) ;
54 if ( m_timeOriginShift ) gCaliMB = wHelper.translate(gCaliMB,-tstart,baseline) ;
55
56 // normalization of calibration pulse
57
58 if ( m_normalizeCali ) {
59 double peak = gCaliMB.getSample( wHelper.getMax(gCaliMB) ) ;
60 ATH_MSG_VERBOSE ( "*** Normalisation \t|-> YES (CaliWave peak = " << peak << ")" );
61 if ( peak <=0 ) {
62 ATH_MSG_WARNING ( "Peak value <=0 , cannot normalize!" );
63 } else {
64 gCaliMB = gCaliMB * (1./peak) ;
65 }
66 } else {
67 ATH_MSG_VERBOSE ( "*** Normalisation \t|-> NO" );
68 }
69
70 // ionisation waveform prediction
71
72 ATH_MSG_VERBOSE ( "*** Physics waveform\t|-> m_Tdrift = " << larWFParam.tdrift() << " ns " );
73 ATH_MSG_VERBOSE ( "*** Physics waveform\t|-> m_Fstep = " << larWFParam.fstep() << " ns " );
74 ATH_MSG_VERBOSE ( "*** Physics waveform\t|-> m_Tcal = " << larWFParam.tcal() << " ns " );
75 ATH_MSG_VERBOSE ( "*** Physics waveform\t|-> m_Omega0 = " << larWFParam.omega0() << " GHz" );
76 ATH_MSG_VERBOSE ( "*** Physics waveform\t|-> m_Taur = " << larWFParam.taur() << " ns " );
77
78 bool doInjPointCorr = ( ( ( layer>=0 && layer<4 && m_injPointCorrLayer[layer] ) || m_injPointCorr )
79 && larWFParam.omega0() != 0. ) ;
80
81 const unsigned N = gCaliMB.getSize();
82 const double dt = gCaliMB.getDt() ;
83
84
85 if ( ! doInjPointCorr ) {
86 // perform only exp->triangle correction
87 ATH_MSG_VERBOSE ( "*** Inj. Point Corr \t|-> NO" );
88 gPhys = exp2Tri ( gCaliMB,N,dt, larWFParam) ;
89 } else {
90 // perform exp->triangle and then injection point correction
91 ATH_MSG_VERBOSE ( "*** Inj. Point Corr \t|-> YES" );
92 if ( !m_injPointUseTauR[layer] ) {
93 //Copy LArWFParams and set Taur to 0
94 LArWFParams paramsNoTaur=larWFParam;
95 paramsNoTaur.setTaur(0);
96 ATH_MSG_VERBOSE ( "*** Inj. Point TauR \t|-> NO" );
97 gPhys = injResp ( exp2Tri ( gCaliMB,N,dt,paramsNoTaur),N,dt,paramsNoTaur);
98 }
99 else {
100 gPhys = injResp ( exp2Tri ( gCaliMB,N,dt,larWFParam),N,dt,larWFParam);
101 }
102 }
103
104 // compute Mphys/Mcal
105 if ( m_normalizeCali ) {
106 // caliwave is normalized to 1 => Mcali = 1
107 MphysMcali = gPhys.getSample( wHelper.getMax(gPhys) ) ;
108 } else {
109 MphysMcali = gPhys.getSample( wHelper.getMax(gPhys) ) /
110 gCaliMB.getSample( wHelper.getMax(gCaliMB) ) ;
111 }
112 ATH_MSG_VERBOSE ( "*** Physics waveform\t|-> m_MphysMcali = " << MphysMcali );
113
114 predLArPhysWave = LArPhysWave( gPhys.getWave(), larCaliWave.getDt() );
115
116 return StatusCode::SUCCESS;
117}
118
119LArWave LArPhysWaveTool::exp2Tri (const LArWave &w,const unsigned N, const double dt, const LArWFParams& params) const {
120 return w + ( w % caliPhysCorr(N,dt,params) ) ;
121}
122
123
124LArWave LArPhysWaveTool::caliPhysCorr(const unsigned N, const double dt, const LArWFParams& params) {
125 LArWave w(N,dt);
126 for ( unsigned i=0 ; i<N ; i++ ) {
127 w.setSample(i,caliPhysCorr(i*dt,params)) ;
128 }
129 return w ;
130}
131
132/* =====================================================================
133 * Function: Calibration to Ionisation correction function
134 * ===================================================================== */
135double LArPhysWaveTool::caliPhysCorr ( double t, const LArWFParams& params) {
136 const double fstep = params.fstep() ;
137 const double Tc = params.tcal() ;
138 const double Td = params.tdrift() ;
139 if ( t<Td ) {
140 if ( fstep==0. ) return ((1.-Tc/Td)-t/Td)/Tc ;
141 return (1.-fstep)/Tc * exp (-fstep*t/Tc)
142 +1./(fstep*Td) * ((1.-fstep)*exp(-fstep*t/Tc)-1.);
143 }
144 else {
145 if ( fstep==0. ) return ((1.-Tc/Td)-t/Td)/Tc
146 + ((t-Td)/Td+Tc/Td)/Tc ;
147 return (1.-fstep)/Tc * exp (-fstep*t/Tc)
148 +1./(fstep*Td) * ( (1.-fstep)*exp(-fstep*t/Tc) - 1. )
149 -1./(fstep*Td) * ( (1.-fstep)*exp(-fstep*(t-Td)/Tc) - 1. ) ;
150 }
151}
152
153// /******************************************************************
154// * Ionisation waveform prediction
155// * mode = 1 --> direct exponential to triangular, using wave W
156// * mode = 2 --> exponential to stepresp to triangular, using gCali
157// ******************************************************************/
158// LArPhysWave LArPhysWaveTool::physPred ( int mode , LArPhysWave W ) const {
159// if ( mode<1 || mode>2 ) mode=1;
160// if ( mode==1 ) return injResp ( exp2Tri ( W ) );
161// else return injResp ( step2Tri ( stepResp() ) ) ;
162// }
163// /*******************************************************************
164// * Ionisation waveform prediction (default)
165// ******************************************************************/
166// LArPhysWave LArPhysWaveTool::physPred ( LArPhysWave W ) const {
167// return physPred ( 1 , W ) ;
168// }
169/*******************************************************************
170 * Injection point correction
171 *******************************************************************/
172LArWave LArPhysWaveTool::injResp (const LArWave& w, unsigned N, double dt, const LArWFParams& params) const {
173 return w % injCorr(N,dt,params);
174}
175
176LArWave LArPhysWaveTool::stepResp (const LArCaliWave& gCali, const LArWFParams& params) const {
177 const unsigned N=gCali.getSize();
178 const double dt=gCali.getDt();
179
180 return gCali + gCali % stepCorr(N,dt,params) ;
181}
182LArWave LArPhysWaveTool::step2Tri (const LArWave& w, unsigned N, double dt, const LArWFParams& params) const {
183 return w + w % stepPhysCorr(N,dt,params.tdrift()) ;
184}
185/* =================================================================
186 * Function: Step response to Ionisation correction function
187 * =============================================================== */
188double LArPhysWaveTool::stepPhysCorr ( double t, const double Td) {
189 if ( t<0. || t>=Td ) return 0. ;
190 else return -1./Td ;
191}
192LArWave LArPhysWaveTool::stepPhysCorr(unsigned N, double dt, const double Td) {
193 LArWave w(N,dt) ;
194 for ( unsigned i=0 ; i<N ; i++ ) w.setSample(i,stepPhysCorr(i*dt,Td)) ;
195 return w ;
196}
197
198
199LArWave LArPhysWaveTool::stepCorr(unsigned N, double dt, const LArWFParams& params) {
200 LArWave w(N,dt) ;
201 for ( unsigned i=0 ; i<N ; i++ ) w.setSample(i,stepCorr(i*dt,params)) ;
202 return w ;
203}
204double LArPhysWaveTool::stepCorr (double t, const LArWFParams& params) {
205 const double fstep = params.fstep();
206 const double Tc = params.tcal();
207 return (1.-fstep)/Tc * exp( -fstep*t/Tc );
208}
209
210
211LArWave LArPhysWaveTool::injCorr(unsigned N, double dt, const LArWFParams& params) {
212 LArWave w(N,dt) ;
213 for ( unsigned i=0 ; i<N ; i++ ) w.setSample(i,injCorr(i*dt,params)) ;
214 return w ;
215}
216/* =================================================================
217 * Function: injection point correction function
218 * =============================================================== */
219double LArPhysWaveTool::injCorr ( double t, const LArWFParams& params) {
220 const double tau0 = 1./params.omega0();
221 const double taur = params.taur();
222 const double Delta = std::pow(taur,2) - std::pow(2*tau0,2) ;
223 if ( Delta > 0 ) {
224 double sqrtDelta = std::sqrt(Delta) ;
225 double taup = 0.5*( taur + sqrtDelta ) ;
226 double taum = 0.5*( taur - sqrtDelta ) ;
227 return ( exp(-t/taup) - exp(-t/taum) ) / ( taup - taum ) ;
228 } else if ( Delta < 0 ) {
229 double T = std::sqrt(-Delta) ;
230 double A = 2 * taur / ( std::pow(taur,2) - Delta ) ;
231 double B = 2 * T / ( std::pow(taur,2) - Delta ) ;
232 return 2 * exp(-A*t) * sin(B*t) / T ;
233 } else {
234 double tau = 0.5 * taur ;
235 return exp(-t/tau) * t / std::pow(tau,2) ;
236 }
237#if 0
238 double taur2 = taur*taur, tau02 = tau0*tau0 ;
239 double taua = sqrt( 4.*tau02 - taur2 );
240 return (2./taua)*exp(-t*taur/(2.*tau02))*sin(t*taua/(2.*tau02));
241#endif
242}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static Double_t Tc(Double_t t)
static Double_t taup
static Double_t tau0
@ baseline
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
LArWave stepResp(const LArCaliWave &gCali, const LArWFParams &params) const
StatusCode makeLArPhysWave(const LArWFParams &, const LArCaliWave &, int region, int layer, LArPhysWave &predLArPhysWave, float &MphysMcali) const
static double caliPhysCorr(double t, const LArWFParams &params)
virtual ~LArPhysWaveTool()
static LArWave injCorr(unsigned N, double dt, const LArWFParams &params)
static double stepPhysCorr(double t, const double dT)
LArWave step2Tri(const LArWave &w, unsigned N, double dt, const LArWFParams &params) const
LArPhysWaveTool(const std::string &type, const std::string &name, const IInterface *parent)
std::vector< bool > m_injPointCorrLayer
std::vector< bool > m_injPointUseTauR
LArWave injResp(const LArWave &w, unsigned N, double dt, const LArWFParams &params) const
static LArWave stepCorr(unsigned N, double dt, const LArWFParams &params)
LArWave exp2Tri(const LArWave &, const unsigned N, const double dt, const LArWFParams &params) const
void setTaur(double taur)
double omega0() const
double tdrift() const
double fstep() const
double tcal() const
double taur() const
LArWave translate(const LArWave &theWave, int nShift, double baseline=0.) const
double getBaseline(const LArWave &theWave, unsigned nBase) const
unsigned int getMax(const LArWave &theWave) const
return index of maximum sample
unsigned getStart(const LArWave &theWave) const
size_t getSize() const
number of time samples
Definition LArWave.h:62
const double & getSample(const unsigned int i) const
Amplitude per time bin.
Definition LArWave.h:53
const std::vector< double > & getWave() const
Wave parameters.
Definition LArWave.h:167
const double & getDt() const
delta time
Definition LArWave.h:50
hold the test vectors and ease the comparison