Hey everyone,
I’m a bit lost with “simple” root functions. I want to multiply all entries of a branch of a TTree with 1.24. Here is what I tried:
void HNL_modifyEfficiency(const char * fileName = "HNLNtuple.root", const char * treeName = "outTree") {
float eff;
TFile file(fileName,"READ");
TTree *tt = (TTree*)file.Get(treeName);
tt->SetBranchAddress("eff", &eff);
for(int i = 0; i < tt->GetEntries(); i++){
tt->GetEntry(i);
eff = eff * 1.24;
tt->Fill();
}
TFile *ff = new TFile("HNLNtuple_plus1Sigma.root","recreate");
tt->Write();
ff->Close();
}
What am I doing wrong?
Cheers
Christian
couet
2
This question was already asked on this forum, for instance here:
cappelt
3
Thanks for the hint.
just to document it here again how I’ve done it:
TFile file(fileName,"READ");
TTree *inTree = (TTree*)file.Get(treeName);
TFile::Open("HNLNtuple_plus1Sigma.root","RECREATE");
TTree *outTree = new TTree("outTree", "outTree");
inTree -> SetBranchAddress("eff", &eff);
outTree -> Branch("eff", &effNew);
for(int i = 0; i < inTree->GetEntries(); i++){
inTree->GetEntry(i);
effNew = eff * 1.24;
outTree->Fill();
}
outTree->Write();
system
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.