File indexing completed on 2025-08-05 08:17:26
0001 #ifndef TRIGGER_CALOTRIGGEREMULATOR_H
0002 #define TRIGGER_CALOTRIGGEREMULATOR_H
0003
0004 #include "TriggerDefs.h"
0005
0006 #include <fun4all/SubsysReco.h>
0007
0008 #include <map>
0009 #include <string>
0010 #include <vector>
0011
0012
0013 class CDBHistos;
0014 class CDBTTree;
0015 class TriggerPrimitiveContainer;
0016 class LL1Out;
0017 class Event;
0018 class TowerInfoContainer;
0019 class CaloPacketContainer;
0020 class PHCompositeNode;
0021 class TH1;
0022
0023 class CaloTriggerEmulator : public SubsysReco
0024 {
0025 public:
0026
0027 explicit CaloTriggerEmulator(const std::string &name);
0028
0029
0030 ~CaloTriggerEmulator() override = default;
0031
0032
0033 int Init(PHCompositeNode *) override;
0034
0035
0036 int InitRun(PHCompositeNode *) override;
0037
0038
0039 int process_event(PHCompositeNode *) override;
0040 int process_sim();
0041 int process_offline();
0042
0043
0044 int End(PHCompositeNode *) override;
0045
0046
0047 int ResetEvent(PHCompositeNode *) override;
0048
0049
0050 void GetNodes(PHCompositeNode *);
0051
0052
0053 void CreateNodes(PHCompositeNode *);
0054
0055
0056 int process_waveforms();
0057
0058
0059 int process_primitives();
0060
0061 int process_organizer();
0062
0063 int process_trigger();
0064
0065 unsigned int getBits(unsigned int sum, TriggerDefs::TriggerId tid);
0066
0067 int Download_Calibrations();
0068
0069
0070 void setTriggerType(const std::string &name);
0071 void setTriggerType(TriggerDefs::TriggerId triggerid);
0072
0073 void setOptMaskFile(const std::string &filename) { m_optmask_file = filename; }
0074
0075 void setEmcalLUTFile(const std::string &filename) { m_emcal_lutname = filename; }
0076 void setHcalinLUTFile(const std::string &filename) { m_hcalin_lutname = filename; }
0077 void setHcaloutLUTFile(const std::string &filename) { m_hcalout_lutname = filename; }
0078
0079 void useMax(bool max) { m_use_max = max; }
0080
0081 void useEMCALDefaultLUT(bool def) { m_default_lut_emcal = def; }
0082 void useHCALINDefaultLUT(bool def) { m_default_lut_hcalin = def; }
0083 void useHCALOUTDefaultLUT(bool def) { m_default_lut_hcalout = def; }
0084
0085 void setTriggerSample(int s) { m_trig_sample = s; }
0086 void setTriggerDelay(int d) { m_trig_sub_delay = d + 1; }
0087
0088 void useHCALIN(bool use);
0089 void useHCALOUT(bool use);
0090 void useEMCAL(bool use);
0091
0092 void setNSamples(int nsamples) { m_nsamples = nsamples; }
0093 void setThreshold(int threshold) { m_threshold = threshold; }
0094 void setJetThreshold(int t1, int t2, int t3, int t4)
0095 {
0096 m_threshold_jet[0] = t1;
0097 m_threshold_jet[1] = t2;
0098 m_threshold_jet[2] = t3;
0099 m_threshold_jet[3] = t4;
0100 return;
0101 }
0102 void setPhotonThreshold(int t1, int t2, int t3, int t4)
0103 {
0104 m_threshold_photon[0] = t1;
0105 m_threshold_photon[1] = t2;
0106 m_threshold_photon[2] = t3;
0107 m_threshold_photon[3] = t4;
0108 return;
0109 }
0110
0111 void setPairThreshold(int t1, int t2, int t3, int t4)
0112 {
0113 m_threshold_pair[0] = t1;
0114 m_threshold_pair[1] = t2;
0115 m_threshold_pair[2] = t3;
0116 m_threshold_pair[3] = t4;
0117 return;
0118 }
0119
0120 bool CheckFiberMasks(TriggerDefs::TriggerPrimKey key);
0121 void LoadFiberMasks();
0122 void SetIsData(bool isd) { m_isdata = isd; }
0123 bool CheckChannelMasks(TriggerDefs::TriggerSumKey key);
0124
0125 void identify();
0126
0127 private:
0128 std::string m_ll1_nodename;
0129 std::string m_prim_nodename;
0130 std::string m_waveform_nodename;
0131
0132 std::string m_optmask_file;
0133
0134 std::string m_emcal_lutname;
0135 std::string m_hcalin_lutname;
0136 std::string m_hcalout_lutname;
0137
0138
0139 std::string m_trigger{"NONE"};
0140
0141 TriggerDefs::TriggerId m_triggerid = TriggerDefs::TriggerId::noneTId;
0142
0143 bool m_use_max{true};
0144 bool m_do_hcalin{false};
0145 bool m_do_hcalout{false};
0146 bool m_do_emcal{false};
0147
0148 bool m_default_lut_hcalin{false};
0149 bool m_default_lut_hcalout{false};
0150 bool m_default_lut_emcal{false};
0151
0152 bool m_force_hcalin{false};
0153 bool m_force_hcalout{false};
0154 bool m_force_emcal{false};
0155
0156
0157 Event *m_event{nullptr};
0158 TowerInfoContainer *m_waveforms_hcalin{nullptr};
0159 TowerInfoContainer *m_waveforms_hcalout{nullptr};
0160 TowerInfoContainer *m_waveforms_emcal{nullptr};
0161 CaloPacketContainer *m_hcal_packets{nullptr};
0162 CaloPacketContainer *m_emcal_packets{nullptr};
0163
0164
0165 LL1Out *m_ll1out_photon{nullptr};
0166
0167 LL1Out *m_ll1out_pair{nullptr};
0168
0169 LL1Out *m_ll1out_jet{nullptr};
0170
0171 TriggerPrimitiveContainer *m_primitives_photon{nullptr};
0172
0173 TriggerPrimitiveContainer *m_primitives_pair{nullptr};
0174
0175 TriggerPrimitiveContainer *m_primitives_jet{nullptr};
0176
0177 TriggerPrimitiveContainer *m_primitives_hcalin{nullptr};
0178
0179 TriggerPrimitiveContainer *m_primitives_hcalout{nullptr};
0180
0181 TriggerPrimitiveContainer *m_primitives_emcal{nullptr};
0182
0183 TriggerPrimitiveContainer *m_primitives_hcal_ll1{nullptr};
0184
0185 TriggerPrimitiveContainer *m_primitives_emcal_ll1{nullptr};
0186
0187 TriggerPrimitiveContainer *m_primitives_emcal_2x2_ll1{nullptr};
0188
0189
0190
0191
0192
0193 unsigned int m_l1_hcal_table[4096]{};
0194 unsigned int m_l1_adc_table[1024]{};
0195 unsigned int m_l1_8x8_table[1024]{};
0196 unsigned int m_l1_slewing_table[4096]{};
0197
0198 std::map<unsigned int, TH1 *> h_emcal_lut{};
0199 std::map<unsigned int, TH1 *> h_hcalin_lut{};
0200 std::map<unsigned int, TH1 *> h_hcalout_lut{};
0201
0202 CDBTTree *cdbttree_adcmask{nullptr};
0203 CDBHistos *cdbttree_emcal{nullptr};
0204 CDBHistos *cdbttree_hcalin{nullptr};
0205 CDBHistos *cdbttree_hcalout{nullptr};
0206
0207 std::map<unsigned int, std::vector<unsigned int>> m_peak_sub_ped_emcal{};
0208 std::map<unsigned int, std::vector<unsigned int>> m_peak_sub_ped_hcalin{};
0209 std::map<unsigned int, std::vector<unsigned int>> m_peak_sub_ped_hcalout{};
0210
0211
0212 int m_nevent{0};
0213 int m_photon_npassed{0};
0214 int m_jet_npassed{0};
0215 int m_pair_npassed{0};
0216
0217 int m_n_sums;
0218 int m_n_primitives;
0219 int m_trig_sub_delay;
0220 int m_trig_sample{-1};
0221
0222 unsigned int m_threshold{1};
0223 unsigned int m_threshold_jet[4] = {0};
0224 unsigned int m_threshold_pair[4] = {0};
0225 unsigned int m_threshold_photon[4] = {0};
0226
0227 int m_isdata{1};
0228 int m_useoffline{false};
0229
0230 int m_nsamples{16};
0231
0232
0233 int m_packet_low_hcalout = 8001;
0234 int m_packet_high_hcalout = 8008;
0235 int m_packet_low_hcalin = 7001;
0236 int m_packet_high_hcalin = 7008;
0237 int m_packet_low_emcal = 6001;
0238 int m_packet_high_emcal = 6128;
0239
0240 std::string m_fieldname{""};
0241
0242 std::vector<unsigned int> m_masks_fiber{};
0243 std::vector<unsigned int> m_masks_channel{};
0244 std::map<TriggerDefs::DetectorId, int> m_prim_map{};
0245 std::map<TriggerDefs::TriggerId, int> m_prim_ll1_map{};
0246 std::map<TriggerDefs::TriggerId, std::vector<std::string>> m_det_map{};
0247 };
0248
0249 #endif