BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
readHeaders.C
Go to the documentation of this file.
1#include <Rtypes.h>
2#include <TClonesArray.h>
3#include <TFile.h>
4#include <TMathBase.h>
5#include <TString.h>
6#include <TTimeStamp.h>
7#include <TTree.h>
8
9R__ADD_INCLUDE_PATH($VMCWORKDIR)
10#include "macro/run/bmnloadlibs.C"
11
12/**
13 * readHeaders
14 * Example of reading valuable content of the DigiRunHeader and BmnEventHeader
15 * @param fileName
16 * @param examples number of events to show
17 */
18void readHeaders(TString fileName = "", Int_t examples = 10)
19{
20 if (fileName == "") {
21 cout << "File not specified!" << endl;
22 return;
23 }
24 bmnloadlibs(); // load libraries
25
26 TFile* file = new TFile(fileName, "READ");
27 if (file->IsOpen() == false) {
28 printf("\nCannot open file %s !\n", fileName.Data());
29 return;
30 }
31 /**
32 * Reading Run Header for the whole run statistics:
33 * beam counters, run start/end time
34 */
35 printf("Run Header content:\n");
36 DigiRunHeader* rh = (DigiRunHeader*)file->Get("DigiRunHeader");
37
38 UInt_t PeriodId = rh->GetPeriodId();
39 UInt_t RunId = rh->GetRunId();
40 printf("\tPeriod: %u Run: %u\n", PeriodId, RunId);
41
42 Double_t BT = rh->GetBT(); // Beam Trigger
43 Double_t BTnBusy = rh->GetBTnBusy(); // BT & not Busy
44 // (BT & not Busy) normalized by Before&After protection ratio
45 Double_t TotalFlux = rh->GetBTAccepted();
46 printf("\tBeam Trigger : %f\n", BT);
47 printf("\tBeam Trigger and Not Busy : %f\n", BTnBusy);
48 printf("\tBeam Trigger Accepted Events (Flux): %f\n", TotalFlux);
49 TTimeStamp RunStartTime = rh->GetRunStartTime();
50 TTimeStamp RunEndTime = rh->GetRunEndTime();
51 printf("\tSTART : %s\n", RunStartTime.AsString());
52 printf("\tFINISH : %s\n", RunEndTime.AsString());
53 /**
54 * Reading Event Header for each event in the range:
55 * current spill statistics,
56 */
57 TTree* tree = (TTree*)file->Get("bmndata");
58 BmnEventHeader* eh = nullptr;
59 tree->SetBranchAddress("BmnEventHeader.", &eh);
60 Long64_t NEvents = tree->GetEntries();
61 Long64_t NExamples = examples; // Examples to show
62 NExamples = Min(NEvents, NExamples);
63 for (Int_t i = 0; i < NExamples; i++) {
64 tree->GetEntry(i);
65 BmnTrigInfo* ti = eh->GetTrigInfo();
66 printf("Event %u\n", eh->GetEventId());
67 printf("\tU40VE:\tCandidates %6u, Accepted %6u, Before %4u, After %6u, Rejected %6u\n", ti->GetTrigCand(),
68 ti->GetTrigAccepted(), ti->GetTrigBefo(), ti->GetTrigAfter(), ti->GetTrigRjct());
69 }
70
71 printf(" %lld events shown.\n To see more events change the second argument of the macro.\n", NExamples);
72}
int i
Definition P4_F32vec4.h:22
int Int_t
unsigned int UInt_t
double Double_t
long long Long64_t
#define R__ADD_INCLUDE_PATH(PATH)
UInt_t GetEventId()
Get the event ID for this event.
BmnTrigInfo & GetTrigInfo()
Get the spill statistics.
Class BmnTrigInfo Trigger counters of the current spill from U40VE card.
Definition BmnTrigInfo.h:15
UInt_t GetTrigAfter()
Definition BmnTrigInfo.h:38
UInt_t GetTrigRjct()
Definition BmnTrigInfo.h:42
UInt_t GetTrigBefo()
Definition BmnTrigInfo.h:34
UInt_t GetTrigAccepted()
Definition BmnTrigInfo.h:30
UInt_t GetTrigCand()
Definition BmnTrigInfo.h:26
uint64_t GetPeriodId()
Get the period ID for this run.
uint64_t GetRunId()
Get the run ID.
TTimeStamp GetRunEndTime()
TTimeStamp GetRunStartTime()
Double_t GetBTAccepted()
Get the (BT and not Busy) by live time.
uint64_t GetBT()
Get the BeamTrigger counter.
uint64_t GetBTnBusy()
Get the BT and not Busy.
T * Get(const char *namecycle)
virtual Bool_t IsOpen() const
const char * AsString(const Option_t *option="") const
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
virtual Long64_t GetEntries() const
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
void readHeaders(TString fileName="", Int_t examples=10)
readHeaders Example of reading valuable content of the DigiRunHeader and BmnEventHeader
Definition readHeaders.C:18