FairRoot/PandaRoot
PndEmcPSAParabolic.cxx
Go to the documentation of this file.
1 //-----------------------------------------------------------
2 //
3 // Description:
4 // Pulseshape analysis for ADC waveforms
5 // (see header file for more details)
6 //
7 // Dima Melnychuk
8 //
9 //-----------------------------------------------------------
10 
11 
12 // This Class' Header ------------------
13 #include "PndEmcPSAParabolic.h"
14 #include "PndEmcWaveform.h"
15 
16 // Class Member definitions -----------
17 
18 void PndEmcPSAParabolic::Process(const PndEmcWaveform *waveform, Double_t &amplitude, Double_t &time)
19 {
20  const std::vector<Double_t> signal=waveform->GetSignal();
21  FitPeak(signal, amplitude, time);
22 }
23 
25  Process(waveform,lAmplitude,lTime);
26  if(lAmplitude > 0){
27  return 1;
28  }else{
29  return 0;
30  }
31 }
32 void PndEmcPSAParabolic::GetHit(Int_t , Double_t &energy, Double_t &time){ // i //[R.K.03/2017] unused variable(s)
33  energy = lAmplitude;
34  time = lTime;
35 }
36 
37 void PndEmcPSAParabolic::FitPeak(const std::vector<Double_t> & signal, Double_t& ampl, Double_t& pos, Int_t peakBin) const
38 {
39  Int_t waveformLength=signal.size();
40 
41  ampl=pos=-1.;
42  if (peakBin>0 && peakBin<waveformLength-1)
43  {
44  long theBin(peakBin);
45 
46  Double_t pValue = signal[peakBin];
47  Double_t pPosition = Double_t(peakBin);
48 
49  Double_t leftValue = signal[theBin-1];
50  Double_t rightValue = signal[theBin+1];
51  if (leftValue<pValue && rightValue<pValue) {
52  Double_t d = 0.25*(rightValue-leftValue);
53  Double_t b = pValue-0.5*(leftValue+rightValue);
54  pValue += d*d/b;
55  pPosition += d/b;
56  }
57  ampl=pValue;
58  pos=pPosition;
59  }
60 }
61 
62 void PndEmcPSAParabolic::FitPeak(const std::vector<Double_t> & signal, Double_t& ampl, Double_t& pos, Int_t start, Int_t end) const
63 {
64  std::vector<Double_t>::const_iterator p;
65  p=max_element(signal.begin()+start,signal.begin()+end);
66  Int_t pPosition = distance(signal.begin(),p);
67  FitPeak(signal,ampl,pos,pPosition);
68 }
69 
70 void PndEmcPSAParabolic::FitPeak(const std::vector<Double_t> & signal, Double_t& ampl, Double_t& pos) const
71 {
72  std::vector<Double_t>::const_iterator p;
73  p=max_element(signal.begin(),signal.end());
74  Int_t pPosition = distance(signal.begin(),p);
75  FitPeak(signal,ampl,pos,pPosition);
76 }
TVector3 pos
virtual void Process(const PndEmcWaveform *waveform, Double_t &amplitude, Double_t &time)
Deprecated. Do not use.
Double_t p
Definition: anasim.C:58
TObjArray * d
virtual std::vector< double > GetSignal() const
TTree * b
void FitPeak(const std::vector< Double_t > &signal, Double_t &ampl, Double_t &pos, Int_t peakBin) const
Double_t
represents a simulated waveform in an emc crystal
Double_t energy
Definition: plot_dirc.C:15
virtual void GetHit(Int_t i, Double_t &energy, Double_t &time)
Get energy and time of hit.