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