BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
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 "BmnMSCMatrix.h"
21#include "BmnMetadataRaw.h"
22#include "BmnSpillHeader.h"
23#include "BmnT0Raw.h"
24#include "BmnTrigRaw2Digit.h"
25#include "DigiRunHeader.h"
26
27using std::map;
28using std::unique_ptr;
29using std::vector;
30namespace pt = boost::property_tree;
31
33{
34 public:
35 BmnMetadataDecoder(vector<string> file = {}, string outfile = "", ULong_t period = 8, BmnSetup setup = kBMNSETUP);
36 virtual ~BmnMetadataDecoder();
37
38 void ClearDigiArrays();
47
48 void SetRawTree(TTree* tree) { fRawTree = tree; }
49
51
52 void SetRunId(UInt_t v) { fRunId = v; }
53
55
56 UInt_t GetRunId() const { return fRunId; }
57
58 UInt_t GetPeriodId() const { return fPeriodId; }
59
61
62 BmnSetup GetBmnSetup() const { return fBmnSetup; }
63
65
66 void SetOutFileName(string filename) { fOutFileName = filename; }
67
68 void SetDecoderConfigFileName(string FileName) { fDecoderConfigFileName = FileName; }
69
70 void SetT0RawStorageFileName(string FileName) { fT0RawStorageFileName = FileName; }
71
73
74 BmnStatus SetTarDirectory(string DirName);
75
76 void SetTarFileNames(vector<string> FileNames) { fTarFileNames = FileNames; }
77
79
80 static BmnStatus ReadSpillStat(const string& FileName,
81 const vector<string>& EvtTrNames = {// "BT", "MBT", "CCT1", "CCT2"};
82 "BT'", "MBT", "CCT1", "nFD"});
83
84 private:
85 const TTimeStamp TimeZero = TTimeStamp(time_t(0), 0);
90
91 pt::ptree conf;
92
95 // for event
98 // for run
101
103 // TTree* fRawTreeSpills;
109 string fDigiDir;
110 vector<string> fDigiFileNames;
111 vector<string> fRawMetaFileNames;
112 string fTarDir;
113 vector<string> fTarFileNames;
120
123
124 unique_ptr<DigiRunHeader> digiRunHeader;
125 // BmnMetadataRaw* metadata;
126 // Spill tree arrays
129
130 // Digi arrays
133
134 // header array
137
138 /** TRC bit map */
140 /** MSC map */
142 /** Raw T0 module map (from Sergeev txt) */
145
148 unique_ptr<BmnTrigRaw2Digit> fTrigMapper;
149
150 map<SysPoint, BmnSpillInfo> fSpillMap;
151
153 // map: <serial, channel> -> index in the list (inside spillHeader->ScalersVec(), and MSC matrix)
154 map<std::pair<uint32_t, uint16_t>, uint16_t> scalers2index_map;
155 map<uint16_t, uint16_t> trcIdx2scalerIdx;
156 // map: name -> index in the list
159
160 unique_ptr<TFile> fT0RawStorageFile;
161 unique_ptr<TTree> fT0RawStorageTree;
162 unique_ptr<std::map<TTimeStamp, int64_t>> fT0RawStorageTsMap; // T0 storage (ts->i_entry) map
164
165 void AddT0Raw2Headers(BmnT0Raw* el);
167 boost::dynamic_bitset<>& bitVecSpill,
168 boost::dynamic_bitset<>& bitVecBusy);
169
172
174};
175
176#endif
__m128 v
Definition P4_F32vec4.h:1
unsigned long ULong_t
unsigned int UInt_t
double Double_t
long long Long64_t
#define ClassDef(name, id)
BmnStatus
Define status code.
Definition BmnEnums.h:93
BmnSetup
Define experimental setup.
Definition BmnEnums.h:165
@ kBMNSETUP
Definition BmnEnums.h:166
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
Storage for all MSC counters of the spill.
unique_ptr< TFile > fT0RawStorageFile
const TTimeStamp TimeZero
void SetPeriodId(UInt_t v)
unique_ptr< TTree > fT0RawStorageTree
T0ChMap fRawT0Map
Raw T0 module map (from Sergeev txt).
void SetMSCMapping(TString map)
UInt_t GetPeriodId() const
static BmnStatus ReadSpillStat(const string &FileName, const vector< string > &EvtTrNames={ "BT'", "MBT", "CCT1", "nFD"})
vector< string > fRawMetaFileNames
void SetT0RawStorageFileName(string FileName)
vector< string > fTarFileNames
vector< string > scalers_index2name_map
BmnMetadataDecoder(vector< string > file={}, string outfile="", ULong_t period=8, BmnSetup setup=kBMNSETUP)
vector< string > fDigiFileNames
void GenerateBusyRanges(BmnMSCMatrix< uint8_t > *matrix, boost::dynamic_bitset<> &bitVecSpill, boost::dynamic_bitset<> &bitVecBusy)
map< uint16_t, uint16_t > trcIdx2scalerIdx
BmnStatus SetTarDirectory(string DirName)
BmnEventHeader * inEventHeader
void AddT0Raw2Headers(BmnT0Raw *el)
BmnStatus SetDigiDirectory(string fDigiDir)
UInt_t GetRunId() const
BmnSpillHeader * spillHeader
void SetRunId(UInt_t v)
void SetOutFileName(string filename)
map< SysPoint, BmnSpillInfo > fSpillMap
NameChMap fTrcBitMap
TRC bit map.
void SetRawTree(TTree *tree)
void SetDecoderConfigFileName(string FileName)
unique_ptr< DigiRunHeader > digiRunHeader
map< std::pair< uint32_t, uint16_t >, uint16_t > scalers2index_map
TString GetSubNameAfterRunId(TString name)
unique_ptr< BmnTrigRaw2Digit > fTrigMapper
BmnSetup GetBmnSetup() const
unique_ptr< std::map< TTimeStamp, int64_t > > fT0RawStorageTsMap
void SetBmnSetup(BmnSetup v)
void SetTarFileNames(vector< string > FileNames)
Name2SerCh fScalersMap
MSC map.
TClonesArray * fT0RawStorageArr
Class BmnMetadataRaw for the configuration and raw spill information.
T0 module spill settings and counts.
Definition BmnT0Raw.h:70
friend friend class TClonesArray