4#pragma GCC system_header
10#include <boost/property_tree/json_parser.hpp>
11#include <boost/property_tree/ptree.hpp>
13#include "TClonesArray.h"
17#include "TTimeStamp.h"
20#include "FairRootManager.h"
48#define WAIT_LIMIT 40000000
49#define UNKNOWN_RUNID 1000000
55namespace pt = boost::property_tree;
62 BmnDecoder(TString file =
"", TString outfile =
"", ULong_t nEvents = 0, ULong_t period = 8);
70 void InitMappers(std::function<
void(TString, TObject*)> branch_reg_fun);
108 d.header = eventHeader;
180 fTof400PlaceMapFileName = PlaceMap;
186 fTof701PlaceMapFileName = PlaceMap;
267 return (nSmpl == 128) ? 1542 : 1992;
283 const TTimeStamp TimeZero = TTimeStamp(time_t(0), 0);
284 Double_t workTime_cpu = 0.0;
285 Double_t workTime_real = 0.0;
289 std::map<DetectorId, bool> fDetectorSetup;
293 bool fApplyThreshold;
297 Int_t fTOF700ReferenceRun;
298 Int_t fTOF700ReferenceChamber;
303 ULong_t fNTotalEvents;
304 ULong_t fNSignalEvents;
305 UInt_t fStartEventId;
310 TTimeStamp fRunStartTime;
311 TTimeStamp fRunEndTime;
314 TTree* fRawTreeSpills;
317 TTree* fDigiTreeSpills;
318 string fDecoderConfigFileName;
319 TString fRootFileName;
320 TString fDigiFileName;
321 TString fCalibFileName;
322 TString fDigiRunHdrName;
323 TString fDchMapFileName;
324 TString fMwpcMapFileName;
325 TString fGemMapFileName;
326 TString fVspMapFileName;
327 TString fTof400PlaceMapFileName;
328 TString fTof400StripMapFileName;
329 TString fTof701PlaceMapFileName;
330 TString fTof701StripMapFileName;
331 TString fTof700MapFileName;
332 TString fTof700GeomFileName;
333 TString fZDCMapFileName;
334 TString fZDCCalibrationFileName;
335 TString fScWallMapFileName;
336 TString fScWallCalibrationFileName;
337 TString fFHCalMapFileName;
338 TString fFHCalCalibrationFileName;
339 TString fHodoMapFileName;
340 TString fHodoCalibrationFileName;
341 TString fNdetMapFileName;
342 TString fNdetCalibrationFileName;
343 TString fHgndMapFileName;
344 TString fHgndCalibrationFileName;
345 TString fECALMapFileName;
346 TString fECALCalibrationFileName;
347 TString fMSCMapFileName;
348 TString fSiliconMapFileName;
349 TString fSiBTMapFileName;
350 TString fCscMapFileName;
351 TString fTrigPlaceMapFileName;
352 TString fTrigChannelMapFileName;
354 TString fRawRunHdrName;
355 TString fMetadataName;
366 TClonesArray* adc128;
368 TClonesArray* vsp_raw;
371 TClonesArray* tqdc_tdc;
372 TClonesArray* tqdc_adc;
373 TClonesArray* tdc_hgnd;
382 TClonesArray* silicon;
387 TClonesArray* tof400;
388 TClonesArray* tof700;
389 TClonesArray* tof701;
391 TClonesArray* scwall;
399 TClonesArray* msc_copy;
400 TClonesArray* t0_copy;
406 Long64_t NRawTreeEvents;
407 Long64_t NRawTreeSpills;
438 UInt_t fPedEvCntrBySpill;
441 UInt_t fEvForPedestals;
442 UInt_t fEvForNoiseCorr;
447 bool fExportJsonBocks;
452 unordered_map<UInt_t, Long64_t> fTimeShifts;
453 Long64_t fT0SyncTime;
456 map<TTimeStamp, Int_t> leaps;
457 TTimeStamp utc_valid;
460 map<TTimeStamp, BmnSpillInfo> fSpillMap;
461 map<uint32_t, uint32_t> _dfl_run_id;
467 template<
typename BrType>
468 void Assignment_Fun(
const TString name, BrType** ob, TTree* tree =
nullptr)
471 FairRootManager* frm = FairRootManager::Instance();
472 *ob =
static_cast<BrType*
>(frm->GetObject(name));
473 LOG(debug) <<
"Getting: " << name <<
" p: " << ob;
475 TBranch* b = tree->GetBranch(name);
478 auto brAddr = b->GetAddress();
480 LOG(debug) <<
"Assigning branch " << b <<
" name " << name <<
" addr " << (
void*)brAddr;
481 *ob =
reinterpret_cast<BrType*
>(*(
reinterpret_cast<void**
>(brAddr)));
483 tree->SetBranchAddress(name, ob);
484 LOG(debug) <<
" Set branch " << b <<
" name " <<
name <<
" addr " << (
void*)*ob;
489 template<
typename BrType>
490 void Register_Fun(
const TString name, BrType** ob)
493 FairRootManager* frm = FairRootManager::Instance();
494 frm->Register(name, name +
"_dir", *ob, fSaveOutput);
496 TBranch* b = fDigiTree->Branch(name, ob);
497 LOGF(debug1,
"Register branch %p : %s", (
void*)b,
name.Data());
502 Int_t GetUTCShift(TTimeStamp t);
503 BmnStatus GetT0Info(Double_t& t0time, Double_t& t0width);
504 inline void FillWR(UInt_t iSerial, ULong64_t iEvent, Long64_t t_sec, Long64_t t_ns);
506 BmnStatus LoadCalibFile(TString& FileName);
507 BmnStatus SaveCalibFile(TString& FileName);
509 void CopyDataToPedMap(UInt_t ev);
const Float_t d
Z-ccordinate of the first GEM-station.
void InitMappers(std::function< void(TString, TObject *)> branch_reg_fun)
UInt_t GetBoundaryRun(UInt_t nSmpl)
void SetRawTree(TTree *tree)
void SetApplyThreshold(bool b)
BmnStatus DecodeOffline()
bool GetSaveOutput() const
void SetVspMapping(TString map)
TString GetSubNameAfterRunId(TString name)
void SetBmnSetup(BmnSetup v)
void SetTOF700ReferenceRun(Int_t n)
BmnStatus DecodeDataToDigiIterate()
void ConfigureStripMappers()
UInt_t GetPeriodId() const
void SetHgndMapping(TString map)
BmnNdetRaw2Digit * GetNdetMapper()
void SetTof700Geom(TString geom)
void SetRawRootFile(TString filename)
void SetForwardMode(bool v=true)
void SetFHCalCalibration(TString cal)
void SetHgndCalibration(TString cal)
void ClearSpillDigiArrays()
UInt_t GetNevents() const
void SetDetectorSetup(std::map< DetectorId, bool > setup)
void SetDigiRootFile(TString filename)
UInt_t GetEvForPedestals()
BmnSetup GetBmnSetup() const
TString GetDigiFileName()
void SetFHCalMapping(TString map)
void SetMSCMapping(TString map)
void SetECALCalibration(TString cal)
void SetZDCCalibration(TString cal)
void SetTof701Mapping(TString PlaceMap, TString StripMap)
TTimeStamp GetRunEndTime() const
void SetDecoderConfigFileName(string FileName)
void SetPeriodId(UInt_t v)
void SetMwpcMapping(TString map)
bool GetForwardMode() const
void SetUseCalibFile(bool v)
void SetECALMapping(TString map)
BmnHgndRaw2Digit * GetHgndMapper()
void * GetMapper(DetectorId id)
void SetNdetCalibration(TString cal)
void SetTrigPlaceMapping(TString map)
void SetGemMapping(TString map)
void SetZDCMapping(TString map)
BmnStatus DecodeDataToDigi()
BmnScWallRaw2Digit * GetScWallMapper()
Int_t GetRunIdFromFile(TString name)
BmnStatus PreInitOffline()
void SetHodoCalibration(TString cal)
unordered_map< UInt_t, Long64_t > GetTimeShifts()
void SetTof700Mapping(TString map)
BmnFHCalRaw2Digit * GetFHCalMapper()
void SetRawTreeSpills(TTree *tree)
void SetTrigChannelMapping(TString file)
BmnHodoRaw2Digit * GetHodoMapper()
void SetEvForPedestals(UInt_t v)
void SetScWallMapping(TString map)
void SetCSCMapping(TString map)
void SetDchMapping(TString map)
BmnDecoder(TString file="", TString outfile="", ULong_t nEvents=0, ULong_t period=8)
void RecalculatePedestals()
void SetSiliconMapping(TString map)
BmnECALRaw2Digit * GetECALMapper()
UInt_t GetEventId() const
void SetTof400Mapping(TString PlaceMap, TString StripMap)
void SetScWallCalibration(TString cal)
void SetTOF700ReferenceChamber(Int_t n)
TString GetRootFileName()
void SetHodoMapping(TString map)
void SetNdetMapping(TString map)
void SetSaveOutput(bool v)
void SetSiBTMapping(TString map)
bool GetUseCalibFile() const
BmnZDCRaw2Digit * GetZDCMapper()
DigiArrays GetDigiArraysObject()
TTimeStamp GetRunStartTime() const
void SetTaskMode(bool v=true)
vector< TClonesArray * > * GetTrigArrays()
a class to store JSON values
basic_json<> json
default specialization