Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CaloWaveformSim.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CaloWaveformSim.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef CALOWAVEFORMSIM_H
4 #define CALOWAVEFORMSIM_H
5 
6 #include <calobase/TowerInfoDefs.h>
7 #include <caloreco/CaloTowerDefs.h>
8 #include <fun4all/SubsysReco.h>
9 
11 
12 #include <gsl/gsl_randist.h>
13 #include <gsl/gsl_rng.h>
14 
15 #include <string>
16 #include <vector>
17 
18 class PHCompositeNode;
19 class TProfile;
20 class PHG4Hit;
23 class TRandom3;
24 class TTree;
25 class CDBTTree;
26 class TowerInfoContainer;
27 
29 {
30  public:
31  CaloWaveformSim(const std::string &name = "CaloWaveformSim");
32 
33  ~CaloWaveformSim() override;
34 
35  enum NoiseType
36  {
40  };
41 
42  int Init(PHCompositeNode *topNode) override;
43 
47  int process_event(PHCompositeNode *topNode) override;
48 
50  int End(PHCompositeNode *topNode) override;
51 
53  {
54  m_dettype = dettype;
55  return;
56  }
58  {
60  return;
61  }
62  void set_fieldname(const std::string &fieldname)
63  {
64  m_fieldname = fieldname;
65  return;
66  }
67  void set_calibName(const std::string &calibName)
68  {
69  m_calibName = calibName;
70  m_overrideCalibName = true;
71  return;
72  }
73  void set_overrideCalibName(bool overrideCalibName)
74  {
75  m_overrideCalibName = overrideCalibName;
76  return;
77  }
78  void set_overrideFieldName(bool overrideFieldName)
79  {
80  m_overrideFieldName = overrideFieldName;
81  return;
82  }
83  void set_templatefile(const std::string &templatefile)
84  {
85  m_templatefile = templatefile;
86  return;
87  }
88  void set_nsamples(int _nsamples)
89  {
90  m_nsamples = _nsamples;
91  return;
92  }
93  void set_pedestalsamples(int _pedestalsamples)
94  {
95  m_pedestalsamples = _pedestalsamples;
96  return;
97  }
98  void set_noise_type(NoiseType noiseType)
99  {
100  m_noiseType = noiseType;
101  return;
102  }
103  void set_fixpedestal(int _fixpedestal)
104  {
105  m_fixpedestal = _fixpedestal;
106  return;
107  }
108  void set_gaussian_noise(int _gaussian_noise)
109  {
110  m_gaussian_noise = _gaussian_noise;
111  return;
112  }
113  void set_deltaT(float _deltaT)
114  {
115  m_deltaT = _deltaT;
116  return;
117  }
118  void set_timewidth(float _timewidth)
119  {
120  m_timeshiftwidth = _timewidth;
121  return;
122  }
123  void set_peakpos(float _peakpos)
124  {
125  m_peakpos = _peakpos;
126  return;
127  }
128  // for CEMC light yield correction
130 
131  private:
134  std::string m_fieldname{"Femc_datadriven_qm1_correction"};
135  std::string m_calibName{"cemc_pi0_twrSlope_v1"};
136  bool m_overrideCalibName{false};
137  bool m_overrideFieldName{false};
138  CDBTTree *cdbttree{nullptr};
139  std::string m_templatefile{"waveformtemptempohcalcosmic.root"};
140  TProfile *h_template{nullptr};
143 
144  std::vector<std::vector<float>> m_waveforms = {{}};
145  int m_runNumber{0};
146  int m_nsamples{31};
147  int m_nchannels{24576};
149  float m_sampletime{50. / 3.};
150  int m_fixpedestal{1500};
152  float m_deltaT{100.};
153  float m_timeshiftwidth{0.};
154  float m_peakpos{6.};
155  gsl_rng *m_RandomGenerator{nullptr};
156 
159  float m_sampling_fraction = {1.0};
160  void maphitetaphi(PHG4Hit *g4hit, unsigned short &etabin, unsigned short &phibin, float &correction);
161  unsigned int (*encode_tower)(const unsigned int etabin, const unsigned int phibin){TowerInfoDefs::encode_emcal};
162  unsigned int (*decode_tower)(const unsigned int tower_key){TowerInfoDefs::decode_emcal};
163  double template_function(double *x, double *par);
164  void CreateNodeTree(PHCompositeNode *topNode);
165 
167 
169 };
170 
171 #endif // CALOWAVEFORMSIM_H