ATLAS Offline Software
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 
8 const int LArDeltaRespTool::DEFAULT=-1;
9 
10 // constructor
11 LArDeltaRespTool::LArDeltaRespTool ( const std::string& type, const std::string& name,const IInterface* 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 ,
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 
121 double 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 
140 double 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 }
LArWave
Definition: LArWave.h:31
LArDeltaRespTool::injCorr
LArWave injCorr() const
Definition: LArDeltaRespTool.cxx:132
LArWFParams::taur
double taur() const
Definition: LArWFParams.h:271
LArDeltaRespTool::m_subtractBaseline
bool m_subtractBaseline
Definition: LArDeltaRespTool.h:43
LArDeltaRespTool::deltaResp
LArWave deltaResp(const LArWave &) const
Definition: LArDeltaRespTool.cxx:104
LArDeltaRespTool::m_Tcal
double m_Tcal
Definition: LArDeltaRespTool.h:45
LArDeltaRespTool::m_gCali
LArCaliWave m_gCali
Definition: LArDeltaRespTool.h:41
LArDeltaRespTool::m_injPointCorr
bool m_injPointCorr
Definition: LArDeltaRespTool.h:43
LArWave::getSize
size_t getSize() const
number of time samples
Definition: LArWave.h:62
LArWaveHelper::getStart
unsigned getStart(const LArWave &theWave) const
Definition: LArWaveHelper.cxx:409
LArWave::getFlag
unsigned getFlag() const
flag: ...
Definition: LArWave.h:178
LArDeltaRespTool.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArWave::getWave
const std::vector< double > & getWave() const
Wave parameters.
Definition: LArWave.h:167
LArWaveHelper::getBaseline
double getBaseline(const LArWave &theWave, unsigned nBase) const
Definition: LArWaveHelper.cxx:347
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
LArWave::getDt
const double & getDt() const
delta time
Definition: LArWave.h:50
LArWaveHelper::translate
LArWave translate(const LArWave &theWave, int nShift, double baseline=0.) const
Definition: LArWaveHelper.cxx:11
LArWaveHelper
Definition: LArWaveHelper.h:14
LArDeltaRespTool::~LArDeltaRespTool
virtual ~LArDeltaRespTool()
LArWFParams
Definition: LArWFParams.h:20
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
LArDeltaRespTool::m_gDelta
LArCaliWave m_gDelta
Definition: LArDeltaRespTool.h:41
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
LArWaveHelper::getMax
unsigned int getMax(const LArWave &theWave) const
return index of maximum sample
Definition: LArWaveHelper.cxx:89
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
LArDeltaRespTool::m_Tdrift
double m_Tdrift
Definition: LArDeltaRespTool.h:45
LArDeltaRespTool::injResp
LArWave injResp(const LArWave &w) const
Definition: LArDeltaRespTool.cxx:128
LArCaliWave::getIsPulsedInt
int getIsPulsedInt() const
isPulsed value
Definition: LArCaliWave.h:163
dqt_zlumi_alleff_HIST.A
A
Definition: dqt_zlumi_alleff_HIST.py:110
LArDeltaRespTool::deltaCorr
LArWave deltaCorr() const
Definition: LArDeltaRespTool.cxx:112
LArWFParams::tcal
double tcal() const
Definition: LArWFParams.h:267
LArWFParams::fstep
double fstep() const
Definition: LArWFParams.h:268
LArPhysWaveTool.h
LArCaliWave
Definition: LArCaliWave.h:44
LArDeltaRespTool::makeLArDeltaResp
LArCaliWave makeLArDeltaResp(const LArWFParams &, const LArCaliWave &)
Definition: LArDeltaRespTool.cxx:29
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloNoise_fillDB.dt
dt
Definition: CaloNoise_fillDB.py:58
baseline
@ baseline
Definition: SUSYToolsTester.cxx:94
LArDeltaRespTool::m_Tstart
unsigned m_Tstart
Definition: LArDeltaRespTool.h:46
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LArDeltaRespTool::m_Fstep
double m_Fstep
Definition: LArDeltaRespTool.h:45
LArDeltaRespTool::m_Omega0
double m_Omega0
Definition: LArDeltaRespTool.h:45
LArWFParams::omega0
double omega0() const
Definition: LArWFParams.h:270
LArDeltaRespTool::DEFAULT
static const int DEFAULT
Definition: LArDeltaRespTool.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
LArDeltaRespTool::LArDeltaRespTool
LArDeltaRespTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: LArDeltaRespTool.cxx:11
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
LArWFParams::tdrift
double tdrift() const
Definition: LArWFParams.h:269
LArDeltaRespTool::m_timeOriginShift
bool m_timeOriginShift
Definition: LArDeltaRespTool.h:43
LArDeltaRespTool::m_normalizeCali
bool m_normalizeCali
Definition: LArDeltaRespTool.h:43
LArDeltaRespTool::m_Taur
double m_Taur
Definition: LArDeltaRespTool.h:45
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArWaveHelper::derive_smooth
LArWave derive_smooth(const LArWave &theWave) const
smoothed derivative
Definition: LArWaveHelper.cxx:270
LArDeltaRespTool::compute_deltaresp
void compute_deltaresp()
Definition: LArDeltaRespTool.cxx:47
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
AthAlgTool
Definition: AthAlgTool.h:26
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35