ATLAS Offline Software
Loading...
Searching...
No Matches
LArDeltaRespTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9
10// constructor
11LArDeltaRespTool::LArDeltaRespTool ( const std::string& type, const std::string& name,const IInterface* parent )
12 : AthAlgTool(type,name,parent),
13 m_Tdrift(0),
14 m_Fstep(0),
15 m_Tcal(0),
16 m_Omega0(0),
17 m_Taur(0),
18 m_Tstart(0)
19{
20 declareProperty("InjPointCorr",m_injPointCorr=true) ;
21 declareProperty("NormalizeCali",m_normalizeCali=true) ;
22 declareProperty("TimeOriginShift",m_timeOriginShift=false) ;
23 declareProperty("SubtractBaseline",m_subtractBaseline=true) ;
24}
25
26// destructor
28
30 const LArCaliWave &larCaliWave )
31{
32
33 m_gCali = larCaliWave;
34
35 m_Tdrift = larWFParam.tdrift();
36 m_Tcal = larWFParam.tcal();
37 m_Fstep = larWFParam.fstep();
38 m_Taur = larWFParam.taur();
39 m_Omega0 = larWFParam.omega0();
40
42
43 return m_gDelta;
44}
45
46
48{
49 LArWaveHelper wHelper;
50
51 // calib. signal at Mother Board :
52 LArWave gCaliMB(m_gCali), gDelta;
53
54 // shift gCaliMB to start point and remove baseline
55 m_Tstart = wHelper.getStart(gCaliMB) ;
56 double baseline = wHelper.getBaseline(gCaliMB,m_Tstart) ;
57 if ( m_subtractBaseline ) gCaliMB = gCaliMB + (-baseline) ;
58 if ( m_timeOriginShift ) gCaliMB = wHelper.translate(gCaliMB,-m_Tstart,baseline) ;
59
60 // normalization of calibration pulse
61 if ( m_normalizeCali ) {
62 ATH_MSG_VERBOSE ( "*** Normalisation \t|-> YES" );
63 double peak = gCaliMB.getSample( wHelper.getMax(gCaliMB) ) ;
64 ATH_MSG_VERBOSE ( "peak = " << peak );
65 if ( peak <=0 ) {
66 ATH_MSG_WARNING ( "Peak value <=0 , cannot normalize!" );
67 } else {
68 gCaliMB = gCaliMB * (1./peak) ;
69 }
70 } else {
71 ATH_MSG_VERBOSE ( "*** Normalisation \t|-> NO" );
72 }
73
74 // delta responde waveform prediction
75 ATH_MSG_VERBOSE ( "*** Delta response \t|-> m_Fstep = " << m_Fstep << " ns " );
76 ATH_MSG_VERBOSE ( "*** Delta response \t|-> m_Tcal = " << m_Tcal << " ns " );
77 ATH_MSG_VERBOSE ( "*** Delta response \t|-> m_Omega0 = " << m_Omega0 << " GHz" );
78 ATH_MSG_VERBOSE ( "*** Delta response \t|-> m_Taur = " << m_Taur << " ns " );
79
80 if ( ! m_injPointCorr ) {
81 // perform only exp->triangle correction
82 ATH_MSG_VERBOSE ( "*** Inj.Point Corr. \t|-> NO" );
83 gDelta = deltaResp ( gCaliMB ) ;
84 } else {
85 // perform exp->triangle and then injection point correction
86 ATH_MSG_VERBOSE ( "*** Inj.Point Corr. \t|-> YES" );
87 //gDelta = deltaResp ( gCaliMB ) ;
88 //gDelta = LArPhysWaveTool::injResp( gDelta ); // HOW TO MAKE THIS WORKING???
89 gDelta = injResp( deltaResp ( gCaliMB ) ) ;
90 }
91
92 //int deltaRespDAC = m_gCali.getDAC() ;
93 int deltaRespDAC = -3 ;
94
95 m_gDelta = LArCaliWave( gDelta.getWave() ,
96 m_gCali.getDt() ,
97 deltaRespDAC ,
98 m_gCali.getIsPulsedInt(),
99 m_gCali.getFlag() );
100
101}
102
103
105{
106 double fstep = m_Fstep;
107 double Tc = m_Tcal;
108 LArWaveHelper wHelper;
109 return ( w % deltaCorr() ) + w*((1.-fstep)/Tc) + wHelper.derive_smooth(w);
110}
111
113{
114 unsigned N = m_gCali.getSize() ;
115 double dt = m_gCali.getDt() ;
116 LArWave w(N,dt) ;
117 for ( unsigned i=0 ; i<N ; i++ ) w.setSample(i,deltaCorr(i*dt)) ;
118 return w ;
119}
120
121double LArDeltaRespTool::deltaCorr ( double t ) const
122{
123 double fstep = m_Fstep ;
124 double Tc = m_Tcal ;
125 return ((fstep*fstep-fstep)/(Tc*Tc)) * exp( -fstep*t/Tc );
126}
127
129 return w % injCorr() ;
130}
131
133 unsigned N = m_gCali.getSize() ;
134 double dt = m_gCali.getDt() ;
135 LArWave w(N,dt) ;
136 for ( unsigned i=0 ; i<N ; i++ ) w.setSample(i,injCorr(i*dt)) ;
137 return w ;
138}
139
140double LArDeltaRespTool::injCorr ( double t ) const {
141 double tau0 = 1./m_Omega0;
142 double taur = m_Taur;
143 double Delta = pow(taur,2.) - pow(2*tau0,2.) ;
144 if ( Delta > 0 ) {
145 double sqrtDelta = sqrt(Delta) ;
146 double taup = 0.5*( taur + sqrtDelta ) ;
147 double taum = 0.5*( taur - sqrtDelta ) ;
148 return ( exp(-t/taup) - exp(-t/taum) ) / ( taup - taum ) ;
149 } else if ( Delta < 0 ) {
150 double T = sqrt(-Delta) ;
151 double A = 2 * taur / ( pow(taur,2.) - Delta ) ;
152 double B = 2 * T / ( pow(taur,2.) - Delta ) ;
153 return 2 * exp(-A*t) * sin(B*t) / T ;
154 } else {
155 double tau = 0.5 * taur ;
156 return exp(-t/tau) * t / pow(tau,2.) ;
157 }
158#if 0
159 double taur2 = taur*taur, tau02 = tau0*tau0 ;
160 double taua = sqrt( 4.*tau02 - taur2 );
161 return (2./taua)*exp(-t*taur/(2.*tau02))*sin(t*taua/(2.*tau02));
162#endif
163}
#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
constexpr int pow(int base, int exp) noexcept
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)
LArDeltaRespTool(const std::string &type, const std::string &name, const IInterface *parent)
LArWave injResp(const LArWave &w) const
LArWave injCorr() const
virtual ~LArDeltaRespTool()
LArCaliWave makeLArDeltaResp(const LArWFParams &, const LArCaliWave &)
LArWave deltaCorr() const
static const int DEFAULT
LArWave deltaResp(const LArWave &) const
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
LArWave derive_smooth(const LArWave &theWave) const
smoothed derivative
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
const std::vector< double > & getWave() const
Wave parameters.
Definition LArWave.h:167
hold the test vectors and ease the comparison