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