Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-05 08:16:06

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