ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ZdcSignalSinc Class Reference

#include <ZdcSignalSinc.h>

Collaboration diagram for ZdcSignalSinc:

Public Types

enum  Status {
  e_OK =0, e_noData, e_wrongFrac, e_Overflow,
  e_wrongSignal, e_noSignal, e_localMinimum
}
 

Public Member Functions

 ZdcSignalSinc (int)
 
 ~ZdcSignalSinc ()
 
 ZdcSignalSinc (const ZdcSignalSinc &)=delete
 
ZdcSignalSincoperator= (const ZdcSignalSinc &)=delete
 
int process (double *, double gain=1., double ped=0., double frac=1., bool corr=true)
 
int getError () const
 
int getWarning () const
 
double getTime () const
 
double getAmp () const
 

Private Member Functions

double waveform (double t)
 
double findpeak (int)
 
double findpeak ()
 
double fraction (double, double)
 

Private Attributes

const int m_n_Slices
 
const double m_AmpThresh
 
const double m_tClock
 
const double m_Pi
 
double m_Time
 
double m_Amp
 
int m_Err
 
int m_Warn
 
double * m_buf
 
int m_p
 
int m_np
 
double m_tim [3] {}
 
double m_wfm [3] {}
 
double m_dt
 
int m_AAAA
 

Detailed Description

Definition at line 14 of file ZdcSignalSinc.h.

Member Enumeration Documentation

◆ Status

Enumerator
e_OK 
e_noData 
e_wrongFrac 
e_Overflow 
e_wrongSignal 
e_noSignal 
e_localMinimum 

Definition at line 16 of file ZdcSignalSinc.h.

Constructor & Destructor Documentation

◆ ZdcSignalSinc() [1/2]

ZdcSignalSinc::ZdcSignalSinc ( int  nSlc)

Definition at line 11 of file ZdcSignalSinc.cxx.

12  : m_n_Slices(nSlc)
13  , m_AmpThresh(5.)
14  , m_tClock (25.)
15  , m_Pi(4*atan(double(1.)))
16 {
17  m_buf = new double[m_n_Slices];
18  m_Time = 0.;
19  m_Amp = 0.;
20  m_Err = e_noData;
21  m_Warn = 0;
22 
23  m_p = 0;
24  m_np = 0;
25 
26  m_wfm[0] = 0. ;
27  m_wfm[1] = 0. ;
28  m_wfm[2] = 0. ;
29 
30  m_tim[0] = 0. ;
31  m_tim[1] = 0. ;
32  m_tim[2] = 0. ;
33 
34  m_dt = 0.;
35 
36  m_AAAA = 0;
37 
38 }

◆ ~ZdcSignalSinc()

ZdcSignalSinc::~ZdcSignalSinc ( )

Definition at line 40 of file ZdcSignalSinc.cxx.

40 { delete[] m_buf;}

◆ ZdcSignalSinc() [2/2]

ZdcSignalSinc::ZdcSignalSinc ( const ZdcSignalSinc )
delete

Member Function Documentation

◆ findpeak() [1/2]

double ZdcSignalSinc::findpeak ( )
private

Definition at line 201 of file ZdcSignalSinc.cxx.

201  {
202  if (m_dt<0.001) return m_tim[1];
203 
204  if (m_wfm[0]<m_wfm[1]) {
205  if (m_wfm[2]<=m_wfm[1]) {
206  m_dt /=2.;
207  double t1 = m_tim[1]-m_dt;
208  double f1 = waveform(t1);
209  if (f1>m_wfm[1]) {
210  m_tim[2] = m_tim[1]; m_wfm[2] = m_wfm[1];
211  m_tim[1] = t1; m_wfm[1] = f1;
212  } else {
213  double t2 = m_tim[1]+m_dt;
214  double f2 = waveform(t2);
215  if (f2>m_wfm[1]) {
216  m_tim[0] = m_tim[1]; m_wfm[0] = m_wfm[1];
217  m_tim[1] = t2; m_wfm[1] = f2;
218  } else {
219  m_tim[0] = t1; m_wfm[0] = f1;
220  m_tim[2] = t2; m_wfm[2] = f2;
221  }
222  }
223  } else {
224  m_tim[0] = m_tim[1]; m_wfm[0] = m_wfm[1];
225  m_tim[1] = m_tim[2]; m_wfm[1] = m_wfm[2];
226  m_tim[2] += m_dt; m_wfm[2] = waveform(m_tim[2]);
227  }
228  } else {
229  if (m_wfm[2]<=m_wfm[1]) {
230  m_tim[2] = m_tim[1]; m_wfm[2] = m_wfm[1];
231  m_tim[1] = m_tim[0]; m_wfm[1] = m_wfm[0];
232  m_tim[0] -= m_dt; m_wfm[0] = waveform(m_tim[0]);
233  return findpeak();
234  } else {
236  return 0.;
237  }
238  }
239  return findpeak();
240 }

◆ findpeak() [2/2]

double ZdcSignalSinc::findpeak ( int  im)
private

Definition at line 192 of file ZdcSignalSinc.cxx.

192  {
193 
194  m_tim[0] = im; m_tim[1]=im+0.5; m_tim[2]=im+1.;
195  for (int i=0;i<3;i++) m_wfm[i]=waveform(m_tim[i]);
196  m_dt = 0.5;
197  double t = findpeak();
198  return t;
199 }

◆ fraction()

double ZdcSignalSinc::fraction ( double  frac,
double  tpeak 
)
private

Definition at line 166 of file ZdcSignalSinc.cxx.

166  {
167  m_tim[0] = 0.; m_wfm[0] = waveform(m_tim[0]);
168  m_tim[1] = tpeak; m_wfm[1] = waveform(m_tim[1]);
169  m_dt = tpeak/2.;
170  double thr = frac*m_wfm[1];
171  while(m_wfm[0]>thr) {
172  m_tim[0] -= 0.1;
173  m_wfm[0] = waveform(m_tim[0]);
174  if (m_tim[0]<-2.) {
175  m_tim[0] = 0.;
176  m_wfm[0] = waveform(m_tim[0]);
178  break;
179  }
180  }
181 
182  while (m_dt>0.001) {
183  double t = m_tim[0] + m_dt;
184  double f = waveform(t);
185  if (f>thr) {m_tim[1] = t; m_wfm[1] = f;}
186  else {m_tim[0] = t; m_wfm[0] = f;}
187  m_dt /= 2.;
188  }
189  return (m_tim[0]+m_tim[1])/2.;
190 }

◆ getAmp()

double ZdcSignalSinc::getAmp ( ) const

Definition at line 154 of file ZdcSignalSinc.cxx.

154 {return m_Amp;}

◆ getError()

int ZdcSignalSinc::getError ( ) const

Definition at line 151 of file ZdcSignalSinc.cxx.

151 {return m_Err;}

◆ getTime()

double ZdcSignalSinc::getTime ( ) const

Definition at line 153 of file ZdcSignalSinc.cxx.

153 {return m_Time;}

◆ getWarning()

int ZdcSignalSinc::getWarning ( ) const

Definition at line 152 of file ZdcSignalSinc.cxx.

152 {return m_Warn;}

◆ operator=()

ZdcSignalSinc& ZdcSignalSinc::operator= ( const ZdcSignalSinc )
delete

◆ process()

int ZdcSignalSinc::process ( double *  buf,
double  gain = 1.,
double  ped = 0.,
double  frac = 1.,
bool  corr = true 
)

Definition at line 42 of file ZdcSignalSinc.cxx.

43  {
44 
45  m_Time = 0.;
46  m_Amp = 0.;
47  m_Err = e_OK;
48  m_Warn = 0;
49 
50  if (ped==0) ped=buf[0];
51  for (double *p=m_buf;p<m_buf+m_n_Slices;p++) {
52  double a = *(buf++);
53  //std::cout << "ZDC+++ A" << a << std::endl;
54  if (a>1015) {
55  m_Err = e_Overflow;
56  return m_Err;
57  }
58  *p = a-ped;
59  }
60  if (frac<=0.) {
62  return m_Err;
63  }
64 
65  int imax = -1;
66  if (m_buf[0 ]-m_buf[1 ]>m_AmpThresh) {
67  imax = 0;
68  m_Warn += 1;
69  }
70 
72  if (imax<0) {
73  imax = m_n_Slices-1;
74  m_Warn += 2;
75  } else {
77  return m_Err;
78  }
79  }
80 
81  for (int i=1;i<m_n_Slices-1;i++) {
82  double da1 = m_buf[i]-m_buf[i-1];
83  double da2 = m_buf[i]-m_buf[i+1];
84  if (da1>0. && da2>=0.) {
85  if (da1>m_AmpThresh || da2>m_AmpThresh) {
86  if (imax<0) imax = i;
87  else {
89  return m_Err;
90  }
91  }
92  }
93  }
94 
95  if (imax<0) {
96  m_Err = e_noSignal;
97  return m_Err;
98  }
99 
100  if (imax==1) m_Warn += 4;
101 
102  if (imax>=2) {
103  // printf("%d %f %f\n",imax,m_buf[imax-2],m_AmpThresh);
104  if (m_buf[imax-2]>m_AmpThresh) m_p = imax-2;
105  else m_p = imax-1;
106  } else m_p = imax;
107 
108  m_np = m_n_Slices-m_p;
109 
110  double t_peak = findpeak(imax-m_p);
111  if (m_Err) return m_Err;
112 
113  if (frac>=1.) m_Time = t_peak;
114  else m_Time = fraction(frac,t_peak);
115  m_Amp = waveform(t_peak);
116 
117  //std::cout << "ZDC+++ m_AMP " << m_Amp << std::endl;
118 
119  /*
120  printf("aap: %d %d %d ",imax, m_p, m_np);
121  for (int i=0;i<m_n_Slices;i++) printf("%6.1f ",m_buf[i]);
122  printf(" %6.1f %6.1f %6.1f\n",t_peak*m_tClock,m_Time*m_tClock,m_Amp);
123  */
124 
125  if (gain==1.) {
126  if (m_Amp<200.) m_Warn += 8;
127  if (m_Amp>900.) m_Warn += 16;
128  } else {
129  if (m_Amp< 50.) m_Warn += 8;
130  if (m_Amp>250.) m_Warn += 16;
131  }
132  m_Amp *= gain;
134  if (corr) {
135  int off = int(10.+m_Time/m_tClock)-10;
136  double t = m_Time - off*m_tClock;
137 
138  if (t< 5.) t = 0.056836274872111 + 1.532763686481279 *t
139  + 0.229808343735056 *t*t - 0.0365636647119192 *t*t*t;
140  else if (t<16.) t = -1.28974955223497 + 2.653578699334604 *t
141  - 0.1371240146140209*t*t + 0.00281211806384422*t*t*t;
142  else t = -42.18688740322650 + 8.61752055701946 *t
143  - 0.4259239806065329*t*t + 0.00753849507486617*t*t*t;
144 
145  m_Time = off*m_tClock + t;
146  }
147 
148  return m_Err;
149 }

◆ waveform()

double ZdcSignalSinc::waveform ( double  t)
private

Definition at line 156 of file ZdcSignalSinc.cxx.

156  {
157  double f = 0.;
158  for (int i=0; i<m_np; i++) {
159  double x = m_Pi*(t-i);
160  if (x) f += m_buf[m_p+i]*sin(x)/x;
161  else f += m_buf[m_p+i];
162  }
163  return f;
164 }

Member Data Documentation

◆ m_AAAA

int ZdcSignalSinc::m_AAAA
private

Definition at line 54 of file ZdcSignalSinc.h.

◆ m_Amp

double ZdcSignalSinc::m_Amp
private

Definition at line 38 of file ZdcSignalSinc.h.

◆ m_AmpThresh

const double ZdcSignalSinc::m_AmpThresh
private

Definition at line 34 of file ZdcSignalSinc.h.

◆ m_buf

double* ZdcSignalSinc::m_buf
private

Definition at line 44 of file ZdcSignalSinc.h.

◆ m_dt

double ZdcSignalSinc::m_dt
private

Definition at line 53 of file ZdcSignalSinc.h.

◆ m_Err

int ZdcSignalSinc::m_Err
private

Definition at line 39 of file ZdcSignalSinc.h.

◆ m_n_Slices

const int ZdcSignalSinc::m_n_Slices
private

Definition at line 33 of file ZdcSignalSinc.h.

◆ m_np

int ZdcSignalSinc::m_np
private

Definition at line 47 of file ZdcSignalSinc.h.

◆ m_p

int ZdcSignalSinc::m_p
private

Definition at line 46 of file ZdcSignalSinc.h.

◆ m_Pi

const double ZdcSignalSinc::m_Pi
private

Definition at line 36 of file ZdcSignalSinc.h.

◆ m_tClock

const double ZdcSignalSinc::m_tClock
private

Definition at line 35 of file ZdcSignalSinc.h.

◆ m_tim

double ZdcSignalSinc::m_tim[3] {}
private

Definition at line 53 of file ZdcSignalSinc.h.

◆ m_Time

double ZdcSignalSinc::m_Time
private

Definition at line 37 of file ZdcSignalSinc.h.

◆ m_Warn

int ZdcSignalSinc::m_Warn
private

Definition at line 40 of file ZdcSignalSinc.h.

◆ m_wfm

double ZdcSignalSinc::m_wfm[3] {}
private

Definition at line 53 of file ZdcSignalSinc.h.


The documentation for this class was generated from the following files:
ZdcSignalSinc::m_tClock
const double m_tClock
Definition: ZdcSignalSinc.h:35
ZdcSignalSinc::m_Pi
const double m_Pi
Definition: ZdcSignalSinc.h:36
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ZdcSignalSinc::e_noSignal
@ e_noSignal
Definition: ZdcSignalSinc.h:17
ZdcSignalSinc::fraction
double fraction(double, double)
Definition: ZdcSignalSinc.cxx:166
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
ZdcSignalSinc::findpeak
double findpeak()
Definition: ZdcSignalSinc.cxx:201
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
python.atlas_oh.im
im
Definition: atlas_oh.py:167
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
x
#define x
ZdcSignalSinc::m_Warn
int m_Warn
Definition: ZdcSignalSinc.h:40
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
read_hist_ntuple.f2
f2
Definition: read_hist_ntuple.py:20
ZdcSignalSinc::m_Amp
double m_Amp
Definition: ZdcSignalSinc.h:38
ZdcSignalSinc::m_Time
double m_Time
Definition: ZdcSignalSinc.h:37
ZdcSignalSinc::m_tim
double m_tim[3]
Definition: ZdcSignalSinc.h:53
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.DecayParser.buf
buf
print ("=> [%s]"cmd)
Definition: DecayParser.py:27
ZdcSignalSinc::m_p
int m_p
Definition: ZdcSignalSinc.h:46
ZdcSignalSinc::m_AAAA
int m_AAAA
Definition: ZdcSignalSinc.h:54
checkxAOD.frac
frac
Definition: Tools/PyUtils/bin/checkxAOD.py:257
ZdcSignalSinc::m_dt
double m_dt
Definition: ZdcSignalSinc.h:53
ZdcSignalSinc::e_wrongFrac
@ e_wrongFrac
Definition: ZdcSignalSinc.h:16
hist_file_dump.f
f
Definition: hist_file_dump.py:135
ZdcSignalSinc::waveform
double waveform(double t)
Definition: ZdcSignalSinc.cxx:156
imax
int imax(int i, int j)
Definition: TileLaserTimingTool.cxx:33
ZdcSignalSinc::m_AmpThresh
const double m_AmpThresh
Definition: ZdcSignalSinc.h:34
ZdcSignalSinc::m_n_Slices
const int m_n_Slices
Definition: ZdcSignalSinc.h:33
ZdcSignalSinc::e_localMinimum
@ e_localMinimum
Definition: ZdcSignalSinc.h:17
ZdcSignalSinc::e_noData
@ e_noData
Definition: ZdcSignalSinc.h:16
ZdcSignalSinc::m_Err
int m_Err
Definition: ZdcSignalSinc.h:39
ZdcSignalSinc::e_wrongSignal
@ e_wrongSignal
Definition: ZdcSignalSinc.h:17
Example_ReadSampleNoise.ped
ped
Definition: Example_ReadSampleNoise.py:45
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
a
TList * a
Definition: liststreamerinfos.cxx:10
ZdcSignalSinc::m_buf
double * m_buf
Definition: ZdcSignalSinc.h:44
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
ZdcSignalSinc::e_Overflow
@ e_Overflow
Definition: ZdcSignalSinc.h:16
ZdcSignalSinc::e_OK
@ e_OK
Definition: ZdcSignalSinc.h:16
ZdcSignalSinc::m_np
int m_np
Definition: ZdcSignalSinc.h:47
ZdcSignalSinc::m_wfm
double m_wfm[3]
Definition: ZdcSignalSinc.h:53
read_hist_ntuple.f1
f1
Definition: read_hist_ntuple.py:4