FairRoot/PandaRoot
PndEmcMultiWaveformSimulator.cxx
Go to the documentation of this file.
2 #include "PndEmcWaveform.h"
3 #include "PndEmcMultiWaveform.h"
4 #include "PndEmcWaveformData.h"
5 #include "PndEmcAbsPulseshape.h"
7 
8 #include "TClonesArray.h"
9 #include "TList.h"
10 
11 #include <vector>
12 
13 
15 {
16 }
17 
18 PndEmcMultiWaveformSimulator::PndEmcMultiWaveformSimulator(Double_t sampleRate, PndEmcAbsPulseshape* pulseshape, Int_t wfMultiplicity) : PndEmcFullStackedWaveformSimulator(sampleRate, pulseshape), fWfMultiplicity(wfMultiplicity)
19 {
20 }
21 
22 
24 {
26  PndEmcMultiWaveform* multiWaveform = MultiplyWaveform(singleWaveform, arrayToStore);
27 
28  delete singleWaveform;
29  return multiWaveform;
30 }
31 
32 
33 PndEmcWaveform* PndEmcMultiWaveformSimulator::MakeSingleWaveform(Double_t hitEnergy, Double_t hitTime, TClonesArray* arrayToStore, Int_t detId, Int_t trackId, Int_t hitIndex)
34 {
35  PndEmcWaveform* singleWaveform = PndEmcFullStackedWaveformSimulator::MakeSingleWaveform(hitEnergy, hitTime, NULL, detId, trackId, hitIndex);
36  PndEmcMultiWaveform* multiWaveform = MultiplyWaveform(singleWaveform, arrayToStore);
37 
38  delete singleWaveform;
39  return multiWaveform;
40 }
41 
42 
53 {
54  fIndexList.push_back(wfIndex);
56 }
57 
65 {
66  PndEmcMultiWaveform* multiWaveform = dynamic_cast<PndEmcMultiWaveform*>(wf);
67  Int_t count = 0;
68  TIter iterModifiers(&fListOfWaveformModifiers);
69 
70  while(PndEmcAbsWaveformModifier* wfmod = (PndEmcAbsWaveformModifier*) iterModifiers()) {
71  if(fIndexList[count]>=0) {
72  multiWaveform->SetActiveWaveform(fIndexList[count]);
73  }
74  wfmod->Modify(wf);
75  ++count;
76  }
77  return wf;
78 }
79 
87 {
88  Double_t totalScale = GetScale();
89 
90  TIter iterModifiers(&fListOfWaveformModifiers);
91  Int_t count = 0;
92 
93  while(PndEmcAbsWaveformModifier* wfmod = (PndEmcAbsWaveformModifier*) iterModifiers()) {
94  if(fIndexList[count] == wfIndex || fIndexList[count]<0) {
95  totalScale *= wfmod->GetScale();
96  }
97  ++count;
98  }
99  return totalScale;
100 }
101 
102 
110 PndEmcMultiWaveform* PndEmcMultiWaveformSimulator::MultiplyWaveform(const PndEmcWaveform* singleWaveform, TClonesArray* arrayToStore)
111 {
112  const std::vector<Double_t>& signal = singleWaveform->GetSignal();
113 
114  PndEmcMultiWaveform* multiWaveform = NULL;
115 
116  if(NULL!=arrayToStore) {
117  multiWaveform = new ((*arrayToStore)[arrayToStore->GetEntriesFast()]) PndEmcMultiWaveform(singleWaveform->GetTrackId(), singleWaveform->GetDetectorId(), signal.size(), singleWaveform->GetHitIndex());
118  } else {
119  multiWaveform = new PndEmcMultiWaveform(singleWaveform->GetTrackId(), singleWaveform->GetDetectorId(), signal.size(), singleWaveform->GetHitIndex());
120  }
121 
122  for(Int_t iWf = 0; iWf<fWfMultiplicity; ++iWf) {
123  multiWaveform->SetWaveform(signal, signal.size(), iWf);
124  }
125 
126  multiWaveform->SetLinks(singleWaveform->GetLinks());
127  multiWaveform->SetTimeStamp(singleWaveform->GetTimeStamp());
128  multiWaveform->SetSampleRate(singleWaveform->GetSampleRate()); //converting form ns into s;
129 
130  return multiWaveform;
131 }
virtual PndEmcWaveform * MakeWaveform(PndEmcWaveformData *wfData, TClonesArray *arrayToStore=NULL)
Create PndEmcWaveform.
interface for waveform modifiers
virtual std::vector< double > GetSignal() const
virtual PndEmcWaveform * MakeWaveform(PndEmcWaveformData *wfData, TClonesArray *arrayToStore=NULL)
Create PndEmcWaveform.
virtual void AddModifier(PndEmcAbsWaveformModifier *wfModifier)
Int_t GetHitIndex() const
virtual void AddModifier(PndEmcAbsWaveformModifier *wfModifier, Int_t wfIndex)
Add a modifier (PndEmcAbsWaveformModifier)
void SetWaveform(const std::vector< Double_t > &signal, Int_t length, Int_t Waveform)
Double_t
int GetTrackId() const
long GetDetectorId() const
represents a simulated waveform in an emc crystal
Class to hold multiple waveforms from one Emc Hit / ADC readout.
virtual PndEmcWaveform * MakeSingleWaveform(Double_t hitEnergy, Double_t hitTime, TClonesArray *arrayToStore=NULL, Int_t detId=-1, Int_t trackId=-1, Int_t hitIndex=-1)
Create a PndEmcWaveform from the given parameters of a single hit.
pulseshape interface
int count
represents a simulated waveform in an emc crystal, used by PndEmcFWEndcapTimebasedWaveforms ...
PndEmcMultiWaveform * MultiplyWaveform(const PndEmcWaveform *singleWaveform, TClonesArray *arrayToStore)
Creates a PndEmcMultiWaveform from a PndEmcWaveform.
Double_t GetSampleRate() const
void SetActiveWaveform(Int_t active=1)
virtual PndEmcWaveform * MakeSingleWaveform(Double_t hitEnergy, Double_t hitTime, TClonesArray *arrayToStore=NULL, Int_t detId=-1, Int_t trackId=-1, Int_t hitIndex=-1)
Create a PndEmcWaveform from the given parameters of a single hit.
void SetSampleRate(Double_t rate)
virtual PndEmcWaveform * CallModifiers(PndEmcWaveform *wf)
Call modifiers on waveform wf.