Skip to content

Commit f515f50

Browse files
preghenellasawenzel
authored andcommitted
Added macro to read event info from a Pythia8 heavy-ion simulation header
1 parent 6c8704f commit f515f50

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
void
2+
read_event_info(const char *fname)
3+
{
4+
5+
auto fin = TFile::Open(fname);
6+
auto tin = (TTree*)fin->Get("o2sim");
7+
auto head = new o2::dataformats::MCEventHeader;
8+
tin->SetBranchAddress("MCEventHeader.", &head);
9+
10+
bool isvalid;
11+
12+
for (int iev = 0; iev < tin->GetEntries(); ++iev) {
13+
14+
tin->GetEntry(iev);
15+
16+
std::cout << " ---------------" << std::endl;
17+
auto name = head->getInfo<std::string>("generator", isvalid);
18+
if (isvalid) std::cout << "generator = " << name << std::endl;
19+
auto Bimpact = head->getInfo<double>("Bimpact", isvalid);
20+
if (isvalid) std::cout << " Bimpact = " << Bimpact << std::endl;
21+
auto Ncoll = head->getInfo<int>("Ncoll", isvalid);
22+
if (isvalid) std::cout << " Ncoll = " << Ncoll << std::endl;
23+
auto Npart = head->getInfo<int>("Npart", isvalid);
24+
if (isvalid) std::cout << " Npart = " << Npart << std::endl;
25+
}
26+
27+
}

0 commit comments

Comments
 (0)