PandaRoot
PndEmcAbsWaveformSimulator.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 #pragma once
14 
15 #ifndef PNDEMCABSWAVEFORMSIMULATOR_H_
16 #define PNDEMCABSWAVEFORMSIMULATOR_H_
17 
18 #include "TObject.h"
19 #include "TMath.h"
20 #include "TList.h"
22 
23 class TClonesArray;
24 class PndEmcWaveform;
25 class PndEmcWaveformData;
26 
27 #include "TROOT.h"
28 #include "TClonesArray.h"
29 
36 class PndEmcAbsWaveformSimulator : public TObject {
37  public:
41  virtual PndEmcWaveform *Simulate(PndEmcWaveformData *wfData, TClonesArray *arrayToStore = nullptr) { return CallModifiers(MakeWaveform(wfData, arrayToStore)); }
42 
44  virtual PndEmcWaveform *SimulateSinglePulse(Double_t hitEnergy, Double_t hitTime, TClonesArray *arrayToStore = nullptr, Int_t detId = -1, Int_t trackId = -1, Int_t hitIndex = -1)
45  {
46  return CallModifiers(MakeSingleWaveform(hitEnergy, hitTime, arrayToStore, detId, trackId, hitIndex));
47  }
48 
52  virtual PndEmcWaveform *Get1GevWaveform() = 0;
53 
57  virtual void GetAbsoluteTimeInterval(PndEmcWaveformData *wfData, Double_t &startTime, Double_t &activeTime) = 0; // in ns
58 
62  virtual Double_t GetTimeBeforeFirstHit(PndEmcWaveformData *) { return 0; } // in ns // wfData //[R.K.03/2017] unused variable(s)
63 
65  virtual Double_t GetScale() = 0;
66 
68  virtual Double_t GetTotalScale()
69  {
70  Double_t totalScale = GetScale();
71 
72  TIter iterModifiers(&fListOfWaveformModifiers);
73  while (PndEmcAbsWaveformModifier *wfmod = (PndEmcAbsWaveformModifier *)iterModifiers()) {
74  totalScale *= wfmod->GetScale();
75  }
76 
77  return totalScale;
78  }
79 
80  virtual Double_t GetSampleRate() { return fSampleRate; }
81 
82  virtual void AddModifier(PndEmcAbsWaveformModifier *wfModifier) { fListOfWaveformModifiers.Add(wfModifier); }
83 
84  protected:
86  PndEmcAbsWaveformSimulator(Double_t sampleRate) : fSampleRate(sampleRate){};
87 
88  virtual PndEmcWaveform *MakeWaveform(PndEmcWaveformData *wfData, TClonesArray *arrayToStore = nullptr) = 0;
89  virtual PndEmcWaveform *
90  MakeSingleWaveform(Double_t hitEnergy, Double_t hitTime, TClonesArray *arrayToStore = nullptr, Int_t detId = -1, Int_t trackId = -1, Int_t hitIndex = -1) = 0;
91 
92  /* sync adc clock with absolute time */
93  inline void SyncWithADCClock(Double_t &time) { time = TMath::Floor(time * fSampleRate) / fSampleRate; };
94 
96  {
97  TIter iterModifiers(&fListOfWaveformModifiers);
98  while (PndEmcAbsWaveformModifier *wfmod = (PndEmcAbsWaveformModifier *)iterModifiers()) {
99  wfmod->Modify(wf);
100  }
101  return wf;
102  }
103 
105  Double_t fSampleRate;
106 
108 };
109 
110 #endif
interface for waveform modifiers
virtual Double_t GetTimeBeforeFirstHit(PndEmcWaveformData *)
virtual void AddModifier(PndEmcAbsWaveformModifier *wfModifier)
virtual PndEmcWaveform * MakeSingleWaveform(Double_t hitEnergy, Double_t hitTime, TClonesArray *arrayToStore=nullptr, Int_t detId=-1, Int_t trackId=-1, Int_t hitIndex=-1)=0
virtual PndEmcWaveform * Get1GevWaveform()=0
Double_t fSampleRate
sampling rate of SADC. In 1/ns
ClassDef(PndEmcAbsWaveformSimulator, 3)
Abstract base class for waveform simulator.
virtual PndEmcWaveform * MakeWaveform(PndEmcWaveformData *wfData, TClonesArray *arrayToStore=nullptr)=0
virtual void GetAbsoluteTimeInterval(PndEmcWaveformData *wfData, Double_t &startTime, Double_t &activeTime)=0
represents a simulated waveform in an emc crystal
virtual PndEmcWaveform * Simulate(PndEmcWaveformData *wfData, TClonesArray *arrayToStore=nullptr)
virtual PndEmcWaveform * SimulateSinglePulse(Double_t hitEnergy, Double_t hitTime, TClonesArray *arrayToStore=nullptr, Int_t detId=-1, Int_t trackId=-1, Int_t hitIndex=-1)
represents a simulated waveform in an emc crystal, used by PndEmcFWEndcapTimebasedWaveforms ...
virtual PndEmcWaveform * CallModifiers(PndEmcWaveform *wf)
PndEmcAbsWaveformSimulator(Double_t sampleRate)
virtual Double_t GetScale()=0