File indexing completed on 2025-08-06 08:17:27
0001
0002
0003 #ifndef RAWBCOLUMI_FUN4ALLSTREAMINGLUMICOUNTINGINPUTMANAGER_H
0004 #define RAWBCOLUMI_FUN4ALLSTREAMINGLUMICOUNTINGINPUTMANAGER_H
0005
0006 #include <fun4allraw/InputManagerType.h>
0007
0008 #include <fun4all/Fun4AllInputManager.h>
0009
0010 #include <TTree.h>
0011 #include <map>
0012 #include <set>
0013 #include <string>
0014 class SingleStreamingInputv2;
0015 class Gl1Packet;
0016 class PHCompositeNode;
0017 class SyncObject;
0018 class TH1;
0019 class TTree;
0020 class Fun4AllStreamingLumiCountingInputManager : public Fun4AllInputManager
0021 {
0022 public:
0023 Fun4AllStreamingLumiCountingInputManager(const std::string &name = "DUMMY", const std::string &dstnodename = "DST", const std::string &topnodename = "TOP");
0024 ~Fun4AllStreamingLumiCountingInputManager() override;
0025 int fileopen(const std::string & ) override { return 0; }
0026
0027 int fileclose() override;
0028 int run(const int nevents = 0) override;
0029
0030 void Print(const std::string &what = "ALL") const override;
0031 int ResetEvent() override;
0032 int PushBackEvents(const int i) override;
0033 int GetSyncObject(SyncObject **mastersync) override;
0034 int SyncIt(const SyncObject *mastersync) override;
0035 int HasSyncObject() const override { return 1; }
0036 std::string GetString(const std::string &what) const override;
0037 void registerStreamingInput(SingleStreamingInputv2 *evtin, InputManagerType::enu_subsystem);
0038 int FillGl1();
0039 void AddGl1RawHit(uint64_t bclk, Gl1Packet *hit);
0040 void AddGl1Window(uint64_t bclk, int negative_window, int positive_window);
0041 void AddGl1BunchNumber(uint64_t bclk, int bunch_number);
0042 void SetNegativeWindow(const unsigned int i);
0043 void SetPositiveWindow(const unsigned int i);
0044 void Streaming(bool b = true) { m_StreamingFlag = b; }
0045 void SetOutputFileName(const std::string &fileName);
0046 void SetEndofEvent(bool flag = false, bool flag2 = false)
0047 {
0048 m_alldone_flag = flag;
0049 m_lastevent_flag = flag2;
0050 }
0051 void SetEventNumber(int num) { m_event_number = num; }
0052
0053 private:
0054 struct Gl1RawHitInfo
0055 {
0056 std::vector<Gl1Packet *> Gl1RawHitVector;
0057 unsigned int EventFoundCounter{0};
0058 };
0059
0060 void createLuminosityHistos();
0061
0062 SyncObject *m_SyncObject{nullptr};
0063 PHCompositeNode *m_topNode{nullptr};
0064
0065 int m_RunNumber{0};
0066 unsigned int m_negative_bco_window{0};
0067 unsigned int m_positive_bco_window{0};
0068 uint64_t m_rawgl1scaler{0};
0069
0070 bool m_alldone_flag = {false};
0071 bool m_lastevent_flag = {false};
0072 int m_event_number{0};
0073 int m_diffBCO{0};
0074 bool m_gl1_registered_flag{false};
0075 bool m_StreamingFlag{false};
0076 bool flat_overflow{false};
0077 uint64_t bco_temp = 0;
0078
0079 std::vector<SingleStreamingInputv2 *> m_Gl1InputVector;
0080 std::map<uint64_t, Gl1RawHitInfo> m_Gl1RawHitMap;
0081 std::map<uint64_t, std::pair<uint64_t, uint64_t>> m_BCOWindows;
0082 std::map<uint64_t, int> m_BCOBunchNumber;
0083 std::map<int, long> m_bunchnumber_MBDNS_raw;
0084 std::map<int, long> m_bunchnumber_MBDNS_live;
0085 std::map<int, long> m_bunchnumber_MBDNS_scaled;
0086 std::map<int, long> m_bunchnumber_ZDCCoin_raw;
0087
0088
0089
0090 TH1 *h_lumibco{nullptr};
0091 TH1 *h_bunchnumber{nullptr};
0092 TH1 *h_bunchnumber_occur{nullptr};
0093 TH1 *h_diffbco{nullptr};
0094 TH1 *h_gl1p_MBDSN_bunchid_raw{nullptr};
0095 TH1 *h_gl1p_MBDSN_bunchid_live{nullptr};
0096 TH1 *h_gl1p_MBDSN_bunchid_scaled{nullptr};
0097 TH1 *h_gl1p_rawgl1scaler{nullptr};
0098 TH1 *h_gl1p_ZDCCoin_bunchid_raw{nullptr};
0099 uint64_t m_bco_trim{};
0100 uint64_t m_lower_bound{};
0101 uint64_t m_upper_bound{};
0102 int m_bunch_number{};
0103 TTree *ttree = nullptr;
0104 TFile *tfile = nullptr;
0105 std::string m_outputFileName = "/sphenix/user/xuzhiwan/luminosity/streaming-macro/macro/output.root";
0106 };
0107
0108 #endif