File indexing completed on 2025-12-17 09:22:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef G4WAVEFORMSIM_CALOWAVEFORMSIM_H
0011 #define G4WAVEFORMSIM_CALOWAVEFORMSIM_H
0012
0013 #include <calobase/TowerInfoDefs.h>
0014 #include <caloreco/CaloTowerDefs.h>
0015 #include <fun4all/SubsysReco.h>
0016 #include <g4detectors/LightCollectionModel.h>
0017 #include <gsl/gsl_randist.h>
0018 #include <gsl/gsl_rng.h>
0019 #include <string>
0020 #include <vector>
0021
0022 class PHCompositeNode;
0023 class TProfile;
0024 class PHG4Hit;
0025 class PHG4CylinderCellGeom_Spacalv1;
0026 class PHG4CylinderGeom_Spacalv3;
0027 class TTree;
0028 class CDBTTree;
0029 class TowerInfoContainer;
0030
0031 class CaloWaveformSim : public SubsysReco
0032 {
0033 public:
0034 CaloWaveformSim(const std::string &name = "CaloWaveformSim");
0035 ~CaloWaveformSim() override;
0036
0037 int InitRun(PHCompositeNode *topNode) override;
0038 int process_event(PHCompositeNode *topNode) override;
0039 int End(PHCompositeNode *topNode) override;
0040
0041
0042 void set_detector_type(CaloTowerDefs::DetectorSystem dettype) { m_dettype = dettype; }
0043 void set_detector(const std::string &detector) { m_detector = detector; }
0044
0045
0046 void set_fieldname(const std::string &fieldname)
0047 {
0048 m_fieldname = fieldname;
0049 m_overrideFieldName = true;
0050 }
0051 void set_calibName(const std::string &calibName)
0052 {
0053 m_calibName = calibName;
0054 m_overrideCalibName = true;
0055 }
0056 void set_directURL_calib(const std::string &url)
0057 {
0058 m_giveDirectURL = true;
0059 m_directURL = url;
0060 }
0061 void set_overrideCalibName(bool overrideCalib) { m_overrideCalibName = overrideCalib; }
0062 void set_overrideFieldName(bool overrideField) { m_overrideFieldName = overrideField; }
0063
0064
0065 void set_MC_fieldname(const std::string &MC_fieldname)
0066 {
0067 m_MC_fieldname = MC_fieldname;
0068 m_overrideMCFieldName = true;
0069 }
0070 void set_MC_calibName(const std::string &MC_calibName)
0071 {
0072 m_MC_calibName = MC_calibName;
0073 m_overrideMCCalibName = true;
0074 }
0075 void set_directURL_MCcalib(const std::string &url)
0076 {
0077 m_giveDirectURL_MC = true;
0078 m_directURL_MC = url;
0079 }
0080 void set_overrideMCFieldName(bool overrideField) { m_overrideMCFieldName = overrideField; }
0081 void set_overrideMCCalibName(bool overrideCalib) { m_overrideMCCalibName = overrideCalib; }
0082
0083
0084 void set_fieldname_time(const std::string &fieldname_time)
0085 {
0086 m_fieldname_time = fieldname_time;
0087 m_overrideTimeFieldName = true;
0088 }
0089 void set_calibName_time(const std::string &calibName_time)
0090 {
0091 m_calibName_time = calibName_time;
0092 m_overrideTimeCalibName = true;
0093 }
0094 void set_directURL_timecalib(const std::string &url)
0095 {
0096 m_giveDirectURL_time = true;
0097 m_directURL_time = url;
0098 }
0099 void set_dotimecalib(bool dotimecalib) { m_dotimecalib = dotimecalib; }
0100 void set_overrideTimeFieldName(bool overrideField) { m_overrideTimeFieldName = overrideField; }
0101 void set_overrideTimeCalibName(bool overrideCalib) { m_overrideTimeCalibName = overrideCalib; }
0102
0103
0104 void set_MC_fieldname_time(const std::string &MC_fieldname_time)
0105 {
0106 m_MC_fieldname_time = MC_fieldname_time;
0107 m_overrideMCTimeFieldName = true;
0108 }
0109 void set_MC_calibName_time(const std::string &MC_calibName_time)
0110 {
0111 m_MC_calibName_time = MC_calibName_time;
0112 m_overrideMCTimeCalibName = true;
0113 }
0114 void set_directURL_MCtimecalib(const std::string &url)
0115 {
0116 m_giveDirectURL_MC_time = true;
0117 m_directURL_MC_time = url;
0118 }
0119 void set_smear_const(float val)
0120 {
0121 m_smear_const = true;
0122 factor_const = val;
0123 }
0124 void set_overrideMCTimeFieldName(bool overrideField) { m_overrideMCTimeFieldName = overrideField; }
0125 void set_overrideMCTimeCalibName(bool overrideCalib) { m_overrideMCTimeCalibName = overrideCalib; }
0126
0127
0128 void set_templatefile(const std::string &templatefile) { m_templatefile = templatefile; }
0129 void set_nsamples(int nsamples) { m_nsamples = nsamples; }
0130 void set_pedestalsamples(int pedestalsamples) { m_pedestalsamples = pedestalsamples; }
0131 void set_sampletime(float sampletime) { m_sampletime = sampletime; }
0132 void set_nchannels(int nchannels) { m_nchannels = nchannels; }
0133 void set_sampling_fraction(float fraction) { m_sampling_fraction = fraction; }
0134
0135
0136 void set_deltaT(float deltaT) { m_deltaT = deltaT; }
0137 void set_timewidth(float timewidth) { m_timeshiftwidth = timewidth; }
0138 void set_peakpos(float peakpos) { m_peakpos = peakpos; }
0139 void set_highgain(bool highgain = true) { m_highgain = highgain; }
0140 void set_gain(int gain) { m_gain = gain; }
0141 void set_pedestal_scale(float scale) { m_pedestal_scale = scale; }
0142
0143
0144 enum NoiseType
0145 {
0146 NOISE_NONE = 0,
0147 NOISE_GAUSSIAN = 1,
0148 NOISE_TREE = 2
0149 };
0150 void set_noise_type(NoiseType noiseType) { m_noiseType = noiseType; }
0151 void set_fixpedestal(int fixpedestal) { m_fixpedestal = fixpedestal; }
0152 void set_gaussian_noise(int gaussian_noise) { m_gaussian_noise = gaussian_noise; }
0153
0154
0155 LightCollectionModel &get_light_collection_model() { return light_collection_model; }
0156
0157 private:
0158 CaloTowerDefs::DetectorSystem m_dettype{CaloTowerDefs::CEMC};
0159 std::string m_detector{"CEMC"};
0160
0161
0162 std::string m_fieldname{"Femc_datadriven_qm1_correction"};
0163 std::string m_calibName{"cemc_pi0_twrSlope_v1"};
0164 bool m_overrideCalibName{false};
0165 bool m_overrideFieldName{false};
0166 bool m_giveDirectURL{false};
0167 std::string m_directURL{""};
0168
0169 std::string m_MC_fieldname{"Femc_datadriven_qm1_correction"};
0170 std::string m_MC_calibName{"cemc_pi0_twrSlope_v1"};
0171 bool m_overrideMCFieldName{false};
0172 bool m_overrideMCCalibName{false};
0173 bool m_giveDirectURL_MC{false};
0174 std::string m_directURL_MC{""};
0175
0176 bool m_smear_const{false};
0177 float factor_const{0.};
0178
0179
0180 std::string m_fieldname_time{"time"};
0181 std::string m_calibName_time{"CEMC_meanTime"};
0182 bool m_overrideTimeFieldName{false};
0183 bool m_overrideTimeCalibName{false};
0184 bool m_dotimecalib{true};
0185 bool m_giveDirectURL_time{false};
0186 std::string m_directURL_time{""};
0187
0188 std::string m_MC_fieldname_time{"time"};
0189 std::string m_MC_calibName_time{"CEMC_meanTime"};
0190 bool m_overrideMCTimeFieldName{false};
0191 bool m_overrideMCTimeCalibName{false};
0192 bool m_giveDirectURL_MC_time{false};
0193 std::string m_directURL_MC_time{""};
0194
0195
0196 std::string m_templatefile{"waveformtemptempohcalcosmic.root"};
0197 int m_nsamples{31};
0198 int m_pedestalsamples{31};
0199 float m_sampletime{50. / 3.};
0200 int m_nchannels{24576};
0201 float m_sampling_fraction{1.0f};
0202
0203
0204 TowerInfoContainer *m_CaloWaveformContainer{nullptr};
0205 TowerInfoContainer *m_PedestalContainer{nullptr};
0206
0207
0208 int m_fixpedestal{1500};
0209 int m_gaussian_noise{3};
0210 float m_deltaT{100.};
0211 float m_timeshiftwidth{0.};
0212 bool m_highgain{false};
0213 int m_gain{1};
0214 float m_peakpos{6.};
0215 float m_pedestal_scale{1.};
0216
0217 gsl_rng *m_RandomGenerator{nullptr};
0218 PHG4CylinderCellGeom_Spacalv1 *geo{nullptr};
0219 const PHG4CylinderGeom_Spacalv3 *layergeom{nullptr};
0220 std::vector<std::vector<float>> m_waveforms;
0221 int m_runNumber{0};
0222
0223 unsigned int (*encode_tower)(unsigned int, unsigned int){TowerInfoDefs::encode_emcal};
0224 unsigned int (*decode_tower)(unsigned int){TowerInfoDefs::decode_emcal};
0225
0226 CDBTTree *cdbttree{nullptr}, *cdbttree_MC{nullptr};
0227 CDBTTree *cdbttree_time{nullptr}, *cdbttree_MC_time{nullptr};
0228 TProfile *h_template{nullptr};
0229 LightCollectionModel light_collection_model;
0230
0231 NoiseType m_noiseType{NOISE_TREE};
0232
0233 void CreateNodeTree(PHCompositeNode *topNode);
0234 void maphitetaphi(PHG4Hit *g4hit,
0235 unsigned short &etabin,
0236 unsigned short &phibin,
0237 float &correction);
0238 double template_function(double *x, double *par);
0239 };
0240
0241 #endif