void PrintTLorentz(TTree* tree) { TLeaf* leaf = tree->GetLeaf("value"); TLorentzVector* lorentz = (*(TLorentzVector**)leaf->GetBranch()->GetAddress()); if (lorentz->Y() == 1) { std::cout << "Alright." << std::endl; } else { std::cout << "Wrong, TLorentzVector is not loaded." << std::endl; } } void Case1() { TFile file("Tree_TLorentz.root"); TTree* tree = (TTree*)file.Get("tree"); tree->GetEntry(0); PrintTLorentz(tree); } void Case2() { TFile file("Tree_TLorentz.root"); TTree* tree = (TTree*)file.Get("tree"); tree->SetBranchStatus("*", kFALSE); tree->SetBranchStatus("*", kTRUE); tree->GetEntry(0); PrintTLorentz(tree); } void Case3() { TFile file("Tree_TLorentz.root"); TTree* tree = (TTree*)file.Get("tree"); tree->SetBranchStatus("*", kFALSE); tree->GetEntry(0); tree->SetBranchStatus("*", kTRUE); tree->GetEntry(0); PrintTLorentz(tree); } void TLorentzTree() { Case1(); Case2(); Case3(); }