-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathconvertTreeTo02object.C
More file actions
35 lines (30 loc) · 1.13 KB
/
convertTreeTo02object.C
File metadata and controls
35 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include "TFile.h"
#include "TTree.h"
#include "TLeaf.h"
#include <stdio.h>
#endif
#include "DataFormatsTOF/CalibInfoTOF.h"
void convertTreeTo02object()
{
TFile* fout = TFile::Open("TOFcalibTreeOut.root", "RECREATE");
TTree* tout = new TTree("calibTOF", "Calib TOF infos");
TFile* f = TFile::Open("TOFcalibTree.root");
TTree* t = (TTree*)f->Get("aodTree");
std::vector<o2::dataformats::CalibInfoTOF> mCalibInfoTOF;
tout->Branch("TOFCalibInfo", &mCalibInfoTOF);
Printf("The tree has %lld entries", t->GetEntries());
for (int ientry = 1; ientry <= t->GetEntries(); ientry++) {
if (ientry % 100 == 0)
Printf("processing event %d", ientry);
//for (int ientry = 1; ientry <= 3; ientry++){
t->GetEntry(ientry);
for (int i = 0; i < t->GetLeaf("nhits")->GetValue(); i++) {
mCalibInfoTOF.emplace_back(t->GetLeaf("index")->GetValue(i), t->GetLeaf("timestamp")->GetValue(), t->GetLeaf("time")->GetValue(i) - t->GetLeaf("texp")->GetValue(i), t->GetLeaf("tot")->GetValue(i), 0);
}
tout->Fill();
mCalibInfoTOF.clear();
}
fout->cd();
tout->Write();
}