I have an analysis script that takes as input a root file and creates a new root file containing a tree with one branch that my script fills. However, I noticed that if I hadd two of my input root files and run the script on that input, the output I obtain is different than what I get if I run my analysis script on those two individual input root files, and then hadd those two output root files. But these definitely should be the same; I have TH2Ds in my output files that match regardless of where the hadding occurs. I’m not sure how to hadd these output file trees properly?
The relevant code in my script:
int hitsPer1cmVoxel;
TFile* outfile = new TFile(Form("CRTana_%s",input_crtfile.c_str()),"recreate");
TTree *tree = new TTree("tree","tree of hits per voxel");
tree->Branch("hitsPer1cmVoxel", &hitsPer1cmVoxel, "hitsPer1cmVoxel/I");
...
for (int i = 1; i <= (xyzBins[0]/voxelSize[0]); i++) {
for (int j = 1; j <= (xyzBins[1]/voxelSize[0]); j++) {
for (int k = 1; k <= (xyzBins[2]/voxelSize[0]); k++) {
hitsPer1cmVoxel = hitcount_xyz_th3d[0]->GetBinContent(i, j, k);
tree->Fill();
}
}
}
outfile->Write();
outfile->Close();
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.16/00
Platform: Ubuntu
Compiler: g++