FairRoot/PandaRoot
PndEmcWaveform.h
Go to the documentation of this file.
1 //==========================================================================
2 // PndEmcWaveform.h
3 //
4 // Class to hold waveforms created from Emc Hits
5 //
6 // Hits will be converted to waveforms using the standard
7 // formula for an exponential decay convoluted with CR-RC (or CR-2RC)
8 // shaping.
9 //
10 // Public functions:
11 //
12 // AddElecNoise(Double_t)
13 // Adds gaussian noise with width
14 // given by the Double_t parameter.
15 //
16 // Digitise(Double_t) Simple digitisation, given
17 // the value of one bit in energy
18 // equivalent units.
19 //
20 // AddElecNoiseAndDigitse(Double_t, Double_t) Do both
21 //
22 // AddShapedElecNoiseAndDigitse(Double_t, Double_t) Do both, but with
23 // noise tyhat is not just plain gaussian, but passed through the
24 // shaping. Only use for detailed studies- this is like
25 // adding a Hit to *every bin* and is very slow if you are doing
26 // a calorimiter's worth.
27 //
28 // GetScale() Return the maximum peak of a 1 GeV hit.
29 //
30 // Software developed for the BaBar Detector at the SLAC B-Factory.
31 // Adapted for the PANDA experiment at GSI
32 //
33 // P.D.Strother Imperial College
34 // Dima Melnichuk - adaption for PANDA
35 //=======================================================================
36 //#pragma once
37 #ifndef PNDEMCWAVEFORM_H
38 #define PNDEMCWAVEFORM_H
39 
40 #include <vector>
41 #include "TObject.h"
42 #include "PndEmcTwoCoordIndex.h"
43 #include "PndEmcCRRCPulseshape.h"
44 #include "PndEmcCR2RCPulseshape.h"
45 #include "PndEmcHit.h"
46 #include "FairTimeStamp.h"
47 #include "TGraphErrors.h"
48 #define TIMEBASEDSIM
49 
50 class PndEmcHit;
51 
56 class PndEmcWaveform: public FairTimeStamp
57 {
58 
60 
61  public:
62 
63  // Constructors
65  PndEmcWaveform(int trackId, long detId, const std::vector<Double_t>& signal, Int_t hitIndex=-1);
66  PndEmcWaveform(long detId, const std::vector<Double_t>& signal, const FairMultiLinkedData& links);
67 
68  PndEmcWaveform(Int_t trackId,Long_t detId, Double_t sampleRate, Long_t waveform_length=64, Int_t hitIndex=-1, Double_t time=0. );
69 
70  // Destructor:
71 
72  virtual ~PndEmcWaveform();
73 
74  // Copy generated by compiler:
75  //PndEmcWaveform(const PndEmcWaveform& copy);
76 
77  //virtual PndEmcWaveform& operator=(const PndEmcWaveform& copy);
78 
79  // Selectors
80 
81  long GetDetectorId() const {return fDetectorId;}
82  int GetTrackId() const {return fTrackId;}
83  Short_t GetModule() const { return (fDetectorId/100000000);};
84  PndEmcTwoCoordIndex* GetTCI() const;
85  virtual std::vector<double> GetSignal() const { return fSignal ;};
86  virtual std::vector<Double_t> GetSignalError() const { return fSignalError; }
87 
88  Int_t GetHitIndex() const {return fHitIndex;}
89 
90  //Operators
91  virtual bool operator == (const PndEmcWaveform& otherWave) const;
92  virtual bool operator < (const PndEmcWaveform& otherWave) const;
93  virtual bool operator != (const PndEmcWaveform& otherWave) const;
94  virtual bool equal(FairTimeStamp* data);
95  PndEmcWaveform& operator += (const PndEmcWaveform& otherWave);
96 
97 
98 
99 
100  Double_t GetSampleRate() const { return fSampleRate; } //in s^(-1)
101  Double_t GetScale(Double_t sampleRate, PndEmcAbsPulseshape *pulseshape) const;
102  Double_t GetNormalisation(Double_t sampleRate, PndEmcAbsPulseshape *pulseshape) const;
103  Int_t GetWaveformLength() const {return fWaveformLength;}
104 
105 
106 
107 
108 
109  // Modifiers
110 
111  void SetSampleRate(Double_t rate) {fSampleRate = rate;}; //in s^(-1)
112 
113  void UpdateWaveform(PndEmcHit *hit, Double_t pePerMeV, Bool_t usePhotonStatistic, Double_t excessNoiseFactor, Double_t firstADCBinTime, Double_t sampleRate, PndEmcAbsPulseshape *pulseshape, Double_t=0);
114  void MakeWaveform(Double_t energy, Double_t time, Double_t pePerMeV, Bool_t usePhotonStatistic, Double_t excessNoiseFactor, Double_t firstADCBinTime, Double_t sampleRate, PndEmcAbsPulseshape *pulseshape, Double_t=0);
115 
116  void AddElecNoise(Double_t);
117  void Digitise(Double_t);
119  //void AddElecNoiseAndDigitise(Double_t,Double_t, Double_t* noise);
120  // Both add noise and digitise. The first Double_t is the noise width (GeV),
121  // the second is the one bit resolution
122 
123  void AddShapedElecNoiseAndDigitise(Double_t noise_width,Double_t oneBitResolution, PndEmcAbsPulseshape *pulseshape, Double_t firstADCBinTime, Double_t sampleRate,Double_t=0);
124  // Add shaped noise and digitise.
125 
126  void SetWaveform(std::vector<Double_t>&signal,Int_t length);
127  Double_t Max();
128 
129  virtual void clearAndReset();
130  virtual void Clear(Option_t *){fSignal.clear();};
131 
132  Double_t GetActiveTime() const { return GetTimeStamp() + (fWaveformLength-1)/fSampleRate*1.0e9; }//nano seconds
133  Int_t GetPileupCount() const {return fEvt.size() - 1; }
134 
135  void AddEvt(Int_t evtNo) { fEvt.push_back(evtNo);}
136  const std::vector<Int_t>& GetEvtList() const { return fEvt; }
137 
138  TGraphErrors* ToTGraph() const ;
139 
141  Double_t Integral() const ;
142 
143  protected:
144  Int_t fTrackId;
145  Int_t fDetectorId;
147  std::vector<Double_t> fSignal; // Signal after FADC
148  std::vector<Double_t> fSignalError; // Signal after FADC
149  Int_t fHitIndex;
150 
151  Double_t fSampleRate; //in s^(-1)
153 
154  std::vector<Int_t> fEvt;//combined waveforms from which events, for check.
155 
156  //for pileup
160 
162 
163 };
164 #endif
void SetWaveform(std::vector< Double_t > &signal, Int_t length)
virtual bool operator!=(const PndEmcWaveform &otherWave) const
Double_t Integral() const
Double_t GetActiveTime() const
static Double_t BarrelOverlapTime
void AddShapedElecNoiseAndDigitise(Double_t noise_width, Double_t oneBitResolution, PndEmcAbsPulseshape *pulseshape, Double_t firstADCBinTime, Double_t sampleRate, Double_t=0)
PndEmcWaveform & operator+=(const PndEmcWaveform &otherWave)
static Double_t ShashylikOverlapTime
interface for waveform modifiers
virtual std::vector< double > GetSignal() const
virtual bool operator==(const PndEmcWaveform &otherWave) const
virtual void Clear(Option_t *)
Int_t GetHitIndex() const
virtual ~PndEmcWaveform()
Double_t GetBaseline() const
stores crystal index coordinates (x,y) or (theta,phi)
virtual bool operator<(const PndEmcWaveform &otherWave) const
ClassDef(PndEmcAbsWaveformModifier, 1)
static Double_t ForwardOverlapTime
Double_t GetNormalisation(Double_t sampleRate, PndEmcAbsPulseshape *pulseshape) const
Double_t GetScale(Double_t sampleRate, PndEmcAbsPulseshape *pulseshape) const
virtual std::vector< Double_t > GetSignalError() const
void AddElecNoise(Double_t)
Double_t fSampleRate
Double_t
int GetTrackId() const
PndEmcTwoCoordIndex * GetTCI() const
void Digitise(Double_t)
const std::vector< Int_t > & GetEvtList() const
void AddElecNoiseAndDigitise(Double_t, Double_t, Double_t=0)
void UpdateWaveform(PndEmcHit *hit, Double_t pePerMeV, Bool_t usePhotonStatistic, Double_t excessNoiseFactor, Double_t firstADCBinTime, Double_t sampleRate, PndEmcAbsPulseshape *pulseshape, Double_t=0)
std::vector< Double_t > fSignal
long GetDetectorId() const
Int_t GetWaveformLength() const
represents a simulated waveform in an emc crystal
virtual bool equal(FairTimeStamp *data)
represents the deposited energy of one emc crystal from simulation
Definition: PndEmcHit.h:26
virtual void clearAndReset()
pulseshape interface
Int_t GetPileupCount() const
void AddEvt(Int_t evtNo)
Short_t GetModule() const
Double_t fBaselineValue
Double_t GetSampleRate() const
PndSdsMCPoint * hit
Definition: anasim.C:70
std::vector< Int_t > fEvt
std::vector< Double_t > fSignalError
void MakeWaveform(Double_t energy, Double_t time, Double_t pePerMeV, Bool_t usePhotonStatistic, Double_t excessNoiseFactor, Double_t firstADCBinTime, Double_t sampleRate, PndEmcAbsPulseshape *pulseshape, Double_t=0)
void SetSampleRate(Double_t rate)
TGraphErrors * ToTGraph() const
Double_t energy
Definition: plot_dirc.C:15