FairRoot/PandaRoot
PndEmcPSAParabolicBaseline.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 ------------------
14 #include "PndEmcWaveform.h"
15 #include <iostream>
16 
17 // Class Member definitions -----------
18 
19 void PndEmcPSAParabolicBaseline::Process(const PndEmcWaveform *waveform, Double_t &amplitude, Double_t &time)
20 {
21  const std::vector<Double_t> signal=waveform->GetSignal();
22  FitPeak(signal, amplitude, time);
23  Double_t baseline;
24  GetBaseline(signal,baseline);
25 // std::cout << "amplitude: " << amplitude << " baseline: " << baseline << std::endl;
26  amplitude -= baseline;
27 }
28 
30  Process(waveform,lAmplitude,lTime);
31  if(lAmplitude > 0){
32  return 1;
33  }else{
34  return 0;
35  }
36 }
37 void PndEmcPSAParabolicBaseline::GetHit(Int_t , Double_t &energy, Double_t &time){ //i //[R.K.03/2017] unused variable(s)
38  energy = lAmplitude;
39  time = lTime;
40 }
41 
42 void PndEmcPSAParabolicBaseline::FitPeak(const std::vector<Double_t> & signal, Double_t& ampl, Double_t& pos, Int_t peakBin) const
43 {
44  Int_t waveformLength=signal.size();
45 
46  ampl=pos=-1.;
47  if (peakBin>0 && peakBin<waveformLength-1)
48  {
49  long theBin(peakBin);
50 
51  Double_t pValue = signal[peakBin];
52  Double_t pPosition = Double_t(peakBin);
53 
54  Double_t leftValue = signal[theBin-1];
55  Double_t rightValue = signal[theBin+1];
56  if (leftValue<pValue && rightValue<pValue) {
57  Double_t d = 0.25*(rightValue-leftValue);
58  Double_t b = pValue-0.5*(leftValue+rightValue);
59  pValue += d*d/b;
60  pPosition += d/b;
61  }
62  ampl=pValue;
63  pos=pPosition;
64  }
65 }
66 
67 void PndEmcPSAParabolicBaseline::FitPeak(const std::vector<Double_t> & signal, Double_t& ampl, Double_t& pos, Int_t start, Int_t end) const
68 {
69  std::vector<Double_t>::const_iterator p;
70  p=max_element(signal.begin()+start,signal.begin()+end);
71  Int_t pPosition = distance(signal.begin(),p);
72  FitPeak(signal,ampl,pos,pPosition);
73 }
74 
75 void PndEmcPSAParabolicBaseline::FitPeak(const std::vector<Double_t> & signal, Double_t& ampl, Double_t& pos) const
76 {
77  std::vector<Double_t>::const_iterator p;
78  p=max_element(signal.begin(),signal.end());
79  Int_t pPosition = distance(signal.begin(),p);
80  FitPeak(signal,ampl,pos,pPosition);
81 }
82 void PndEmcPSAParabolicBaseline::GetBaseline(const std::vector<Double_t> & signal, Double_t &baseline) const
83 {
84  std::vector<Double_t>::const_iterator p;
85  p = signal.begin();
86  baseline = 0;
87  for(Int_t i =0; i<lBaselength;i++){
88  baseline += *p++;
89  }
90  baseline/=lBaselength;
91 }
92 
93 
TVector3 pos
Double_t p
Definition: anasim.C:58
TObjArray * d
virtual std::vector< double > GetSignal() const
Int_t i
Definition: run_full.C:25
TTree * b
virtual void Process(const PndEmcWaveform *waveform, Double_t &amplitude, Double_t &time)
Deprecated. Do not use.
Double_t
void GetBaseline(const std::vector< Double_t > &signal, Double_t &baseline) const
represents a simulated waveform in an emc crystal
Pulseshape analysis for ADC waveforms.
virtual void GetHit(Int_t i, Double_t &energy, Double_t &time)
Get energy and time of hit.
ClassImp(PndAnaContFact)
void FitPeak(const std::vector< Double_t > &signal, Double_t &ampl, Double_t &pos, Int_t peakBin) const
Double_t energy
Definition: plot_dirc.C:15