Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:38

0001 #ifndef TRIGGER_MBDTRIGGEREMULATOR_H
0002 #define TRIGGER_MBDTRIGGEREMULATOR_H
0003 
0004 #include "TriggerDefs.h"
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <map>
0009 #include <string>
0010 #include <vector>
0011 
0012 // Forward declarations
0013 class CDBHistos;
0014 class TriggerPrimitiveContainer;
0015 class LL1Out;
0016 class Event;
0017 class CaloPacketContainer;
0018 class PHCompositeNode;
0019 class TH1;
0020 
0021 class MBDTriggerEmulator : public SubsysReco
0022 {
0023  public:
0024   //! constructor
0025   explicit MBDTriggerEmulator(const std::string &name);
0026 
0027   //! destructor
0028   ~MBDTriggerEmulator() override = default;
0029 
0030   //! full initialization
0031   int Init(PHCompositeNode *) override;
0032 
0033   //! full initialization
0034   int InitRun(PHCompositeNode *) override;
0035 
0036   //! event processing method
0037   int process_event(PHCompositeNode *) override;
0038 
0039   //! end of run method
0040   int End(PHCompositeNode *) override;
0041 
0042   //! reset variables
0043   int ResetEvent(PHCompositeNode *) override;
0044 
0045   //! Get Nodes
0046   void GetNodes(PHCompositeNode *);
0047 
0048   //! Create Nodes
0049   void CreateNodes(PHCompositeNode *);
0050 
0051   //! MakePrimitives
0052   int process_waveforms();
0053   int process_raw();
0054 
0055   //! MakeTriggerOutput
0056   int process_primitives();
0057 
0058   int process_trigger();
0059 
0060   int Download_Calibrations();
0061 
0062   void useMax(bool max) { m_use_max = max; }
0063 
0064   void setTriggerSample(int s) { m_trig_sample = s; }
0065   void setTriggerDelay(int d) { m_trig_sub_delay = d + 1; }
0066 
0067   void setNSamples(int nsamples) { m_nsamples = nsamples; }
0068 
0069   void identify();
0070 
0071   void setChargeLUTFile(const std::string &filename) { m_mbd_charge_lutname = filename; }
0072   void setTimeLUTFile(const std::string &filename) { m_mbd_time_lutname = filename; }
0073   void setSlewingLUTFile(const std::string &filename) { m_mbd_slewing_lutname = filename; }
0074 
0075  protected:
0076   std::string m_ll1_nodename;
0077   std::string m_prim_nodename;
0078   std::string m_waveform_nodename;
0079 
0080   std::string m_mbd_charge_lutname;
0081   std::string m_mbd_time_lutname;
0082   std::string m_mbd_slewing_lutname;
0083 
0084   TriggerDefs::TriggerId m_triggerid{TriggerDefs::TriggerId::mbdTId};
0085 
0086   bool m_use_max{true};
0087 
0088   bool m_default_lut_mbd{false};
0089 
0090   CaloPacketContainer *m_waveforms_mbd{nullptr};
0091 
0092   Event *m_event{nullptr};
0093   //! LL1 Out
0094   LL1Out *m_ll1out_mbd{nullptr};
0095 
0096   TriggerPrimitiveContainer *m_primitives_mbd{nullptr};
0097 
0098   /* std::map<unsigned int, TH1> h_mbd_charge_lut; */
0099   /* std::map<unsigned int, TH1> h_mbd_time_lut; */
0100   /* std::map<unsigned int, TH1> h_mbd_slewing_lut; */
0101 
0102   std::map<unsigned int, TH1 *> h_mbd_charge_lut{};
0103   std::map<unsigned int, TH1 *> h_mbd_time_lut{};
0104   std::map<unsigned int, TH1 *> h_mbd_slewing_lut{};
0105 
0106   CDBHistos *cdbttree_mbd_charge{nullptr};
0107   CDBHistos *cdbttree_mbd_time{nullptr};
0108   CDBHistos *cdbttree_mbd_slewing{nullptr};
0109 
0110   //! Trigger primitives
0111   unsigned int m_trig_charge[8]{};
0112   unsigned int m_trig_nhit;
0113   unsigned int m_trig_time[4]{};
0114 
0115   //! Trigger primitives
0116   unsigned int m2_trig_charge[4][8]{};
0117   unsigned int m2_trig_nhit[4]{};
0118   unsigned int m2_trig_time[4][4]{};
0119 
0120   //! Trigger ouputs
0121   std::vector<std::vector<unsigned int> *> m_word_mbd{};
0122   unsigned int m_out_tsum[2]{};
0123   unsigned int m_out_tavg[2]{};
0124   unsigned int m_out_trem[2]{};
0125   unsigned int m_out_nhit[2]{};
0126   unsigned int m_out_vtx_sub;
0127   unsigned int m_out_vtx_add;
0128 
0129   unsigned int m_nhit1, m_nhit2, m_timediff1, m_timediff2, m_timediff3;
0130 
0131   std::map<unsigned int, std::vector<unsigned int> > m_peak_sub_ped_mbd{};
0132 
0133   //! Verbosity.
0134   int m_nevent;
0135   int m_mbd_npassed;
0136 
0137   int m_n_sums;
0138   int m_n_primitives;
0139   int m_trig_sub_delay;
0140   int m_trig_sample{-1};
0141 
0142   unsigned int m_threshold{1};
0143   int m_isdata{1};
0144   int m_useoffline{false};
0145   int m_nsamples = 16;
0146   int m_idx{8};
0147 };
0148 
0149 #endif