From 0476c9e27d5d8bc8ab67c72abc27c41fcffa3fe5 Mon Sep 17 00:00:00 2001 From: zampolli Date: Tue, 29 Jan 2019 12:30:46 +0100 Subject: [PATCH] Macro to convert CPass output in O2 format --- .../TOF/prototyping/convertTreeTo02object.C | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Detectors/TOF/prototyping/convertTreeTo02object.C diff --git a/Detectors/TOF/prototyping/convertTreeTo02object.C b/Detectors/TOF/prototyping/convertTreeTo02object.C new file mode 100644 index 0000000000000..17bf73ba68074 --- /dev/null +++ b/Detectors/TOF/prototyping/convertTreeTo02object.C @@ -0,0 +1,26 @@ +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 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("time")->GetValue(i) - t->GetLeaf("texp")->GetValue(i), t->GetLeaf("tot")->GetValue(i) ); + } + tout->Fill(); + mCalibInfoTOF.clear(); + } + + + fout->cd(); + tout->Write(); +}