BmnRoot
Loading...
Searching...
No Matches
BmnMetadataDecoder.h
Go to the documentation of this file.
1#ifndef BMNMETADATADECODER_H
2#define BMNMETADATADECODER_H 1
3
4#include <fstream>
5#include <map>
6#include <vector>
7// Boost
8#include <boost/property_tree/json_parser.hpp>
9#include <boost/property_tree/ptree.hpp>
10// ROOT
11#include <TChain.h>
12#include <TClonesArray.h>
13#include <TFile.h>
14#include <TPRegexp.h>
15#include <TString.h>
16#include <TTimeStamp.h>
17#include <TTree.h>
18// BmnRoot
19#include "BmnEventHeader.h"
20#include "BmnMetadataRaw.h"
21#include "BmnSpillHeader.h"
22#include "BmnTrigRaw2Digit.h"
23#include "DigiRunHeader.h"
24
25using std::map;
26using std::vector;
27namespace pt = boost::property_tree;
28
29class BmnMetadataDecoder : public TObject
30{
31 public:
32 BmnMetadataDecoder(vector<string> file = {}, string outfile = "", ULong_t period = 8, BmnSetup setup = kBMNSETUP);
33 virtual ~BmnMetadataDecoder();
34
35 void ClearDigiArrays();
43 void ResetDecoder(TString file);
46
47 void SetRawTree(TTree* tree) { fRawTree = tree; }
48
49 TTree* GetDigiTree() { return fDigiTree; }
50
51 void SetRunId(UInt_t v) { fRunId = v; }
52
53 void SetPeriodId(UInt_t v) { fPeriodId = v; }
54
55 UInt_t GetRunId() const { return fRunId; }
56
57 UInt_t GetPeriodId() const { return fPeriodId; }
58
59 void SetBmnSetup(BmnSetup v) { fBmnSetup = v; }
60
61 BmnSetup GetBmnSetup() const { return fBmnSetup; }
62
63 void SetMSCMapping(TString map) { fMSCMapFileName = map; }
64
65 void SetRawRootFile(TString filename) { fRootFileName = filename; }
66
67 void SetOutFileName(string filename) { fOutFileName = filename; }
68
69 void SetDecoderConfigFileName(string FileName) { fDecoderConfigFileName = FileName; }
70
71 BmnStatus SetDigiDirectory(string fDigiDir);
72
73 BmnStatus SetTarDirectory(string DirName);
74
75 void SetTarFileNames(vector<string> FileNames) { fTarFileNames = FileNames; }
76
77 TString GetSubNameAfterRunId(TString name);
78
79 private:
80 const TTimeStamp TimeZero = TTimeStamp(time_t(0), 0);
81 Double_t workTime_cpu = 0.0;
82 Double_t workTime_real = 0.0;
83 bool get_run_interval_from_file = true;
84 bool get_filenames_from_db = false;
85
86 pt::ptree conf;
87
88 UInt_t fRunId;
89 UInt_t fPeriodId;
90 // for event
91 Long64_t fTime_s;
92 Long64_t fTime_ns;
93 // for run
94 SysPoint fRunStartTime;
95 SysPoint fRunEndTime;
96
97 TTree* fRawTree;
98 // TTree* fRawTreeSpills;
99 TTree* fRawTreeSpillsT0;
100 TTree* fDigiTree;
101 TTree* fDigiTreeSpills;
102 string fDecoderConfigFileName;
103 string fDigiDir;
104 vector<string> fDigiFileNames;
105 string fTarDir;
106 vector<string> fTarFileNames;
107 TString fMSCMapFileName;
108 TString fRootFileName;
109 string fOutFileName;
110 TString fDigiRunHdrName;
111 TString fSubName;
112 TString fRawRunHdrName;
113 TString fMetadataName;
114
115 TFile* fDigiFileOut;
116 TFile* fCalibFile;
117
118 unique_ptr<DigiRunHeader> digiRunHeader;
119 // BmnMetadataRaw* metadata;
120 // Spill tree arrays
121 TClonesArray* msc;
122 TClonesArray* t0raw;
123
124 // Digi arrays
125 TClonesArray* msc_copy;
126 TClonesArray* t0_copy;
127
128 // header array
129 BmnEventHeader* inEventHeader;
130 BmnSpillHeader* spillHeader;
131
133 NameChMap fTrcBitMap;
135 Name2SerCh fScalersMap;
137 T0ChMap fRawT0Map;
138 BmnMetadataRaw metadata;
139
140 BmnSetup fBmnSetup;
141 TString fPeriodSetupExt;
142 unique_ptr<BmnTrigRaw2Digit> fTrigMapper;
143
144 map<SysPoint, BmnSpillInfo> fSpillMap;
145
146 SerCh2Name scalers2name_map;
147 // map: <serial, channel> -> index in the list (inside spillHeader->ScalersVec(), and MSC matrix)
148 map<std::pair<uint32_t, uint16_t>, uint16_t> scalers2index_map;
149 map<uint16_t, uint16_t> trcIdx2scalerIdx;
150 // map: name -> index in the list
151 NameChMap scalers_name2index_map;
152 vector<string> scalers_index2name_map;
153
154 BmnStatus LoadConfig();
155
156 ClassDef(BmnMetadataDecoder, 1);
157};
158
159#endif
__m128 v
Definition P4_F32vec4.h:1
BmnStatus
Definition BmnEnums.h:24
BmnSetup
Definition BmnEnums.h:89
@ kBMNSETUP
Definition BmnEnums.h:90
std::chrono::time_point< SysClock > SysPoint
std::unordered_map< std::string, std::pair< uint32_t, uint16_t > > Name2SerCh
Definition BmnAliases.h:9
std::map< std::pair< uint32_t, uint16_t >, std::string > SerCh2Name
Definition BmnAliases.h:10
std::map< T0MapKey, uint16_t > T0ChMap
Definition BmnAliases.h:6
std::unordered_map< std::string, uint16_t > NameChMap
Definition BmnAliases.h:7
void SetRawRootFile(TString filename)
void SetPeriodId(UInt_t v)
void SetMSCMapping(TString map)
UInt_t GetPeriodId() const
BmnStatus SetTarDirectory(string DirName)
BmnStatus SetDigiDirectory(string fDigiDir)
UInt_t GetRunId() const
void SetRunId(UInt_t v)
void ResetDecoder(TString file)
void SetOutFileName(string filename)
void SetRawTree(TTree *tree)
void SetDecoderConfigFileName(string FileName)
BmnStatus DecodeDataToDigiIterate()
TString GetSubNameAfterRunId(TString name)
BmnSetup GetBmnSetup() const
void SetBmnSetup(BmnSetup v)
void SetTarFileNames(vector< string > FileNames)
Definition setup.py:1