ATLAS Offline Software
LArWaveCumul.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 #include <math.h>
8 
9 
10 // LArWaveCumul:: LArWaveCumul(const std::vector<double>& theVector,double dt, HWIdentifier channelID) :
11 // LArWave(theVector,dt), m_channelID(channelID)
12 // {
13 // unsigned nSamples = theVector.size() ;
14 // m_errors.resize(nSamples,0) ;
15 // m_triggers.resize(nSamples,0) ;
16 // }
17 
18 // LArWaveCumul::LArWaveCumul(const std::vector<double>& vAmpl, const std::vector<double>& vErr, const std::vector<int>& vTrig ,
19 // const double dt, const HWIdentifier channelID) : LArWave(vAmpl,dt), m_channelID(channelID),
20 // m_errors(vErr),m_triggers(vTrig) {
21 // unsigned int nSamples = vAmpl.size() ;
22 // }
23 
24 
25 // LArWaveCumul:: LArWaveCumul(const unsigned nSamples,const double dt, const HWIdentifier channelID) :
26 // LArWave(nSamples,dt), m_channelID(channelID)
27 // {
28 // m_errors.resize(nSamples,0) ;
29 // m_triggers.resize(nSamples,0) ;
30 // }
31 
32 
34  const std::vector<double>& Samples )
35 {
36  const unsigned int nSwave = getSize() ;
37  const unsigned int nSevt = Samples.size() ;
38  for ( unsigned int i=0 ; i<nSevt ; i++ ) {
39  //unsigned int k = delay + i*step ;
40  unsigned int k=(i+1)*step-(delay+1);
41  if (k<nSwave) {
42  double evt = Samples[i] ;
43  int N = m_triggers[k] ;
44  double amp2 = m_amplitudes[k]*m_amplitudes[k];
45  //double sum2 = N * ( m_errors[k]*m_errors[k] + amp2 );
46  double sum2 = (N-1)*m_errors[k]*m_errors[k] + N*amp2;
47 
48  double sum = m_amplitudes[k] * N ;
49  m_amplitudes[k] = ( sum + evt ) / (N+1) ;
50  //double arg = ( sum2 + evt*evt ) / (N+1) - m_amplitudes[k]*m_amplitudes[k] ;
51  double arg = ( ( sum2 + evt*evt ) - (N+1)*m_amplitudes[k]*m_amplitudes[k] )/N ;
52 
53  // Can happen due to underflow if m_errors is zero and evt is
54  // exactly the same as m_amplitudes.
55  if (arg < 0) arg = 0;
56  m_errors[k] = sqrt(arg);
57  m_triggers[k] = N + 1 ;
58 
59  }
60  }
61 }
62 
63 
64 
66  const std::vector<double>& SamplesSum ,
67  const std::vector<double>& Samples2Sum ,
68  unsigned nTriggers )
69 {
70  const unsigned int nSwave = getSize() ;
71  const unsigned int nSevt = SamplesSum.size() ;
72 
73  for ( unsigned int i=0 ; i<nSevt ; i++ ) {
74 
75  unsigned int k=(i+1)*step-(delay+1);
76 
77  if (k<nSwave ) {
78 
79  int N1 = m_triggers[k] ;
80  double sum1 = m_amplitudes[k] * N1 ;
81  //double sum12 = N1 * ( m_errors[k]*m_errors[k] + m_amplitudes[k]*m_amplitudes[k] ) ;
82  double sum12 = (N1-1)*m_errors[k]*m_errors[k] + N1*m_amplitudes[k]*m_amplitudes[k] ;
83 
84  int N2 = nTriggers ;
85  double sum2 = SamplesSum[i] ;
86  double sum22 = Samples2Sum[i] ;
87 
88  m_triggers[k] = N1+N2 ;
89  m_amplitudes[k] = (sum1+sum2)/m_triggers[k] ;
90  //m_errors[k] = sqrt( (sum12+sum22)/m_triggers[k] - m_amplitudes[k]*m_amplitudes[k] ) ;
91  m_errors[k] = sqrt( ( sum12+sum22-m_amplitudes[k]*m_amplitudes[k]*m_triggers[k] )/(m_triggers[k]-1) ) ;
92 
93  }
94 
95  }
96 
97 }
98 
99 // std::vector<double> LArWaveCumul::getErrors() const
100 // { return m_errors ; }
101 
102 // double LArWaveCumul::getError(unsigned int i) const
103 // { return (i<getSize()) ? m_errors[i] : -9.9999E+99 ; }
104 
105 // std::vector<int> LArWaveCumul::getTriggers() const
106 // { return m_triggers ; }
107 
108 // int LArWaveCumul::getTrigger(unsigned int i) const
109 // { return (i<getSize()) ? m_triggers[i] : -99999999 ; }
110 
LArWave::m_amplitudes
std::vector< double > m_amplitudes
Definition: LArWave.h:112
dqt_zlumi_pandas.N2
N2
Definition: dqt_zlumi_pandas.py:325
LArWave::getSize
size_t getSize() const
number of time samples
Definition: LArWave.h:62
LArWaveCumul::m_errors
std::vector< double > m_errors
Definition: LArWaveCumul.h:89
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
LArWaveCumul::addEvent
void addEvent(int delay, int step, const std::vector< double > &Samples)
add in set of channel responses for a given step/delay
Definition: LArWaveCumul.cxx:33
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
lumiFormat.i
int i
Definition: lumiFormat.py:85
dqt_zlumi_pandas.N1
int N1
Definition: dqt_zlumi_pandas.py:322
delay
double delay(std::size_t d)
Definition: JetTrigTimerTest.cxx:14
create_dcsc_inputs_sqlite.arg
list arg
Definition: create_dcsc_inputs_sqlite.py:48
LArWaveCumul::m_triggers
std::vector< int > m_triggers
Definition: LArWaveCumul.h:90
LArWaveCumul.h
LArCellBinning.step
step
Definition: LArCellBinning.py:158
LArWaveCumul::addAccumulatedEvent
void addAccumulatedEvent(int delay, int step, const std::vector< double > &SamplesSum, const std::vector< double > &Samples2Sum, unsigned nTriggers)
used when building from LArAccumulatedDigits
Definition: LArWaveCumul.cxx:65
fitman.k
k
Definition: fitman.py:528