in the my analysis I use to build response matrices (i.e. 2D histograms, reco vs truth) with instructions like these:
t_reco->BuildIndex( "eventNumber" ); t_truth->BuildIndex( "eventNumber" ); t_reco->AddFriend( t_truth ); TH2D * h_pt = new TH2D( "pt_tree", "pt", 10, 0, 400, 10, 0, 400 ); t_reco->Project( "pt_tree", "pt:truth.pt","passed && truth.passed" );
We noticed that the results are different whether we use TChains or TTree. The issue appears also when using Draw and Scan.
I have attached a working example (it should work out of the box on lxplus):
- chainExample.C and run_chainExample.C: this macro creates two trees from scratch (reco and truth), containing only three variables each: eventNumber, pt and passed_cut. The tree is saved in a root file and response matrices are built using TChain and TTree. The matrices are saved in png format, and they are a little different. The problems doesn’t appear if the reco and truth trees contain the same number of entries. For the record, the results from the TTree are the correct ones
Is it a known behavior? Unfortunately I need to use TChains because my datasets are made by many files. For now, we have found a workaround: replace t_reco->Project( “pt_tree”, “pt:truth.pt”,“passed && truth.passed” ); with t_reco->Project( “pt_tree”, “pt:truth.pt”,“passed && truth.passed && (eventNumber == truth.eventNumber)” );. It seems to work (honestly I don’t understand how) but it’s an ugly fix.
Thanks a lot,