Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:58

0001 #ifndef BBC_BBCMON_H
0002 #define BBC_BBCMON_H
0003 
0004 #include <onlmon/OnlMon.h>
0005 #include "BbcMonDefs.h"
0006 #include <onlmon/triggerEnum.h>
0007 
0008 #include <string>
0009 #include <ctime>
0010 
0011 class Event;
0012 class TH1;
0013 class TH2;
0014 class TF1;
0015 class TH2Poly;
0016 class MbdEvent;
0017 class MbdGeom;
0018 class MbdOut;
0019 class MbdPmtContainer;
0020 //class GL1Manager;
0021 class eventReceiverClient;
0022 class RunDBodbc;
0023 // class OnlMonDB;
0024 
0025 class BbcMon : public OnlMon
0026 {
0027  public:
0028   explicit BbcMon(const std::string &name = "BBCMON");
0029   virtual ~BbcMon();
0030 
0031   int process_event(Event *evt) override;
0032   int Init() override;                     // Done once at start of server
0033   int BeginRun(const int runno) override;  // Done at every start of run
0034   int EndRun(const int runno) override;    // Done at the end of every run
0035   int Reset() override;
0036 
0037   void set_GL1(const int g) { useGL1 = g; }
0038   void set_skipto(const int s) { skipto = s; }
0039 
0040  protected:
0041   int DBVarInit();
0042 
0043   MbdEvent *bevt{nullptr};
0044 
0045   int useGL1{1};    // whether to use the GL1 data
0046   uint64_t triggervec{0};
0047   uint64_t triginput{0};
0048   uint64_t trigraw{0};
0049   uint64_t triglive{0};
0050   uint64_t trigscaled{0};
0051   //uint64_t gl1_bco{0};
0052   uint64_t trigmask{0};       // accepted triggers
0053   uint64_t mbdtrig{0};        // main mbd trigger
0054   uint64_t mbdwidebest{0};    // best of mbdns n>=1or2, or |z|<150, or zdcns
0055   uint64_t mbdbest{0};        // best mbd trigger
0056   uint64_t mbdns{0};          // mbdns n>=1 or 2 bit
0057   uint64_t mbdnsvtx10{0};     // mbdns vtx<10 bit
0058   uint64_t mbdnsvtx30{0};     // mbdns vtx<30 bit
0059   uint64_t mbdnsvtx150{0};     // mbdns vtx<150 bit
0060   uint64_t zdcns{0};          // zdcns
0061   uint64_t emcal{0};          // all emcal triggers, no bbc
0062   uint64_t hcal{0};           // all hcal triggers, no bbc
0063   uint64_t emcalmbd{0};       // all emcal triggers, with bbc
0064   uint64_t hcalmbd{0};        // all hcal triggers, with bbc
0065   uint64_t orig_trigmask{0};  // store for recovering from runs with one trigger defined
0066   eventReceiverClient *erc{nullptr};
0067   int      skipto{0};
0068   //GL1Manager *gl1mgr{nullptr};
0069   RunDBodbc *rdb{nullptr};
0070 
0071   uint64_t GetMinBiasTrigBit(uint64_t trigs_enabled);
0072   uint64_t GetMinBiasWideTrigBit(uint64_t trigs_enabled);
0073 
0074   int evtcnt{0};
0075   // OnlMonDB *dbvars = nullptr;
0076 
0077   MbdGeom *_mbdgeom{nullptr};  // contains positions of BBC PMTs
0078   MbdOut *m_mbdout{nullptr};
0079   MbdPmtContainer *m_mbdpmts{nullptr};
0080 
0081   // vtx to MCR variables
0082   int fillnumber{0};
0083   int sendflag{0};      // 0 = don't send, 1 = send
0084   std::string sendflagfname;
0085   int GetFillNumber();
0086   int GetSendFlag();
0087   int UpdateSendFlag(const int flag);
0088   std::time_t prev_send_time{0};
0089   std::time_t tstart{0};
0090 
0091   // vtx reset variables
0092   int zresetflag{0};      // 0 = don't reset, 1 = reset
0093   std::string zresetflagfname;
0094   int GetZResetFlag();
0095   int UpdateZResetFlag(const int flag);
0096 
0097   // kludge to work around situations when gl1 events are being received
0098   int gl1badflag{0};   // 0 = normal, 1 = gl1 bad, accept all events
0099   std::string gl1badflagfname;
0100   int GetGL1BadFlag();
0101   int UpdateGL1BadFlag(const int flag);
0102 
0103   TH1 *bbc_trigs{nullptr};
0104   TH2 *bbc_adc{nullptr};
0105   TH2 *bbc_tdc{nullptr};
0106   TH2 *bbc_tdc_overflow{nullptr};
0107   TH1 *bbc_tdc_overflow_each[128] = {};  // should be [nPMT_BBC], need to fix
0108   TH1 *bbc_south_nhit{nullptr};
0109   TH1 *bbc_north_nhit{nullptr};
0110   TH1 *bbc_nhit_emcal[2]{nullptr,nullptr};
0111   TH1 *bbc_nhit_hcal[2]{nullptr,nullptr};
0112   TH1 *bbc_nhit_emcalmbd[2]{nullptr,nullptr};
0113   TH1 *bbc_nhit_hcalmbd[2]{nullptr,nullptr};
0114 
0115   TH1 * bbc_zvertex_autoupdate[TriggerEnum::NUM_MBD_TRIGGERS]{nullptr};  // BBCMON_NTRIGS = 16, for all triggers
0116   unsigned int bbc_last_update_ticker[TriggerEnum::NUM_MBD_TRIGGERS]{0};  // last update ticker for zvtx autoupdate
0117 
0118   TH2 *bbc_tdc_armhittime{nullptr};
0119   TH1 *bbc_nevent_counter{nullptr};
0120 
0121   TH1 *bbc_zvertex{nullptr};        // whatever primary trigger is
0122   TH1 *bbc_zvertex_alltrigger{nullptr};  // all triggers
0123   TH1 *bbc_zvertex_short{nullptr};  // Used for short time scales, exclusively wide trigs
0124   TH1 *bbc_zvertex_prime_short{nullptr};  // Used for short time scales, primary trig
0125   TH1 *bbc_zvertex_ns{nullptr};     // no vtx cut
0126   TH1 *bbc_zvertex_10{nullptr};     // 10 cm cut
0127   TH1 *bbc_zvertex_30{nullptr};
0128   TH1 *bbc_zvertex_60{nullptr};
0129   TH1 *bbc_zvertex_ns_chk{nullptr};     // for checking the vertex cut only
0130   TH1 *bbc_zvertex_10_chk{nullptr};     // for checking the vertex cut only
0131   TH1 *bbc_zvertex_30_chk{nullptr};
0132   TH1 *bbc_zvertex_60_chk{nullptr};
0133   TH1 *bbc_zvertex_zdcns{nullptr};  // ZDCNS triggers
0134   TH1 *bbc_zvertex_emcal{nullptr};  // EMCAL triggers
0135   TH1 *bbc_zvertex_hcal{nullptr};   // HCAL triggers
0136   TH1 *bbc_zvertex_emcalmbd{nullptr};  // EMCAL triggers, w/ BBC
0137   TH1 *bbc_zvertex_hcalmbd{nullptr};   // HCAL triggers, w/ BBC
0138   TF1 *f_zvtx{nullptr};             // Used for fitting central vertex peak
0139   // TH1 *bbc_zvertex_bbll1_novtx = nullptr;
0140   // TH1 *bbc_zvertex_bbll1_narrowvtx = nullptr;  // Run11 pp
0141 
0142   TH2 *bbc_tzero_zvtx{nullptr};
0143   TH1 *bbc_avr_hittime{nullptr};
0144   TH1 *bbc_south_hittime{nullptr};
0145   TH1 *bbc_north_hittime{nullptr};
0146   TH1 *bbc_south_chargesum{nullptr};
0147   TH1 *bbc_north_chargesum{nullptr};
0148   TH1 *bbc_prescale_hist{nullptr};
0149 
0150   TH1 *bbc_runvtx{nullptr};       // vtx, running vertex measurement
0151   TH1 *bbc_runvtxerr{nullptr};    // vtxerr, running vertex measurement
0152   TH1 *bbc_runvtxtime{nullptr};   // time, running vertex measurement
0153 
0154   // TH2 *bbc_tmax[2] = {};  // [0 == time ch, 1 == chg ch], max sample in evt vs ch
0155   TH2 *bbc_time_wave{nullptr};    // raw waveforms, time ch
0156   TH2 *bbc_charge_wave{nullptr};  // raw waveforms, charge ch
0157   // TH2 *bbc_trange = nullptr;       // subtracted tdc at maxsamp vs ch
0158 
0159   TH2Poly *bbc_south_hitmap{nullptr};  // hitmap
0160   TH2Poly *bbc_north_hitmap{nullptr};  // hitmap
0161   const unsigned int zvtx_autoupdate_ticker = 1000;
0162 
0163 };
0164 
0165 #endif /* BBC_BBCMON_H */