File indexing completed on 2025-08-03 08:21:00
0001 #ifndef DAQ_DAQMON_H
0002 #define DAQ_DAQMON_H
0003
0004 #include <TH2D.h>
0005 #include <onlmon/OnlMon.h>
0006
0007 #include <vector>
0008 #include <fstream>
0009 #include <sstream>
0010 #include <map>
0011 #include <string>
0012
0013 class Event;
0014 class TH1;
0015 class TH2;
0016 class runningMean;
0017 class GL1Manager;
0018 class Packet;
0019
0020 class DaqMon : public OnlMon
0021 {
0022 public:
0023 DaqMon(const std::string &name, const std::string& gl1_host = "gl1daq");
0024 virtual ~DaqMon();
0025
0026 int process_event(Event *evt);
0027 int Init();
0028 int BeginRun(const int runno);
0029 int Reset();
0030 int CaloPacketMap(int pnum);
0031 void loadpacketMapping(const std::string& filename);
0032 int getmapping(int packetid);
0033
0034 uint32_t previousdiff[200] = {0};
0035 uint32_t clockdiff[200] = {0};
0036
0037 private:
0038 std::map<int, int> packetMap;
0039
0040 protected:
0041 Long64_t evtcnt = 0;
0042 int gevtcnt = 0;
0043 int binindex = 0;
0044 int previndex = 0;
0045
0046 int idummy = 0;
0047 int packetlow = 6001;
0048 int packethigh = 12001;
0049 int packet_mbd_low = 1001;
0050 int packet_mbd_high = 1002;
0051 int packet_emcal_low = 6001;
0052 int packet_emcal_high = 6128;
0053 int packet_ihcal_low = 7001;
0054 int packet_ihcal_high = 7008;
0055 int packet_ohcal_low = 8001;
0056 int packet_ohcal_high = 8008;
0057 int packet_sepd_low = 9001;
0058 int packet_sepd_high = 9006;
0059 int packet_zdc = 12001;
0060
0061 int npackets_emcal = 128;
0062 int npackets_ihcal = 8;
0063 int npackets_ohcal = 8;
0064 int npackets_sepd= 6;
0065 int npackets_mbd= 2;
0066 int npackets_zdc= 1;
0067
0068 TH1 *daqhist1 = nullptr;
0069 TH2 *daqhist2 = nullptr;
0070 TH2* h_gl1_clock_diff= nullptr;
0071 TH2* h_fem_match= nullptr;
0072
0073
0074
0075
0076 GL1Manager *gl1mgr = {nullptr};
0077 std::string GL1host;
0078
0079 };
0080
0081 void DaqMon::loadpacketMapping(const std::string& filename) {
0082 std::ifstream file(filename);
0083 std::string line;
0084 int packetId, seb;
0085 std::getline(file, line);
0086 while (std::getline(file, line)) {
0087 std::istringstream iss(line);
0088 if (iss >> packetId >> seb) {
0089 packetMap[packetId] = seb;
0090 }
0091 }
0092 file.close();
0093 }
0094
0095 int DaqMon::getmapping(int packetid) {
0096 auto it = packetMap.find(packetid);
0097 if (it != packetMap.end()) {
0098 return it->second;
0099 } else {
0100 std::cerr << "Packet ID not found in the mapping." << std::endl;
0101 return -1;
0102 }
0103 }
0104
0105 #endif