#acl RobertRiemann:read,write,admin All:read = Usage = *download everything from here: [[attachment:TreeWalk.tar.gz||&do=get]] *adjust the "!OutputTree" name and the leaf names to fit your root file *run "make" to create the executable (you will need to intall and setup root first) *run "./main /output/file.root /input/1.root /input/2.root ..." = main.cpp = {{{ #!cplusplus #include "treewalk.h" #include #include using std::vector; using std::string; int main ( int argc, char *argv[] ) { // argv[0] is app name assert ( argc > 2 ); string destination_file ( argv[1] ); TChain* chain = new TChain("OutputTree"); for ( int i = 2; i < argc; ++i ) { Int_t res = chain->AddFile(argv[i]); assert(res == 1); } TreeWalk treewalk ( destination_file, chain ); return ( 0 ); } // kate: indent-mode cstyle; space-indent on; indent-width 4; }}} = Makefile = {{{ CXXFLAGS=`root-config --cflags` -ggdb -g LDLIBS=`root-config --libs` main: main.o treewalk.o run: ./main clean: rm -f main main.o treewalk.o .PHONY: run clean }}} = treewalk.cpp = {{{ #!cplusplus #include "treewalk.h" #include #include TreeWalk::TreeWalk(string destionation_file, TChain* chain) { chain->SetBranchAddress("DiJet_pT_0",&m_DiJet_pT_0); chain->SetBranchAddress("DiJet_pT_1",&m_DiJet_pT_1); chain->SetBranchAddress("DiJet_delta_phi",&m_DiJet_delta_phi); chain->SetBranchAddress("DiJet_delta_R",&m_DiJet_delta_R); chain->SetBranchAddress("DiJet_boosted_angle",&m_DiJet_boosted_angle); chain->SetBranchAddress("DiJet_boosted_delta_R",&m_DiJet_boosted_delta_R); chain->SetBranchAddress("DiJet_balance",&m_DiJet_balance); chain->SetBranchAddress("Jet_centrality",&m_Jet_centrality); chain->SetBranchAddress("Jet_sphericity",&m_Jet_sphericity); chain->SetBranchAddress("Jet_aplanarity",&m_Jet_aplanarity); chain->SetBranchAddress("Jet_acoplanarity",&m_Jet_acoplanarity); chain->SetBranchAddress("Jet_Thrust",&m_Jet_thrust); chain->SetBranchAddress("Jet_thrust_transverse",&m_Jet_thrust_transverse); chain->SetBranchAddress("Jet_sphericity1",&m_Jet_sphericity1); chain->SetBranchAddress("Jet_sphericity2",&m_Jet_sphericity2); chain->SetBranchAddress("Jet_Ht",&m_Jet_Ht); chain->SetBranchAddress("Jet_circularity",&m_Jet_circularity); chain->SetBranchAddress("cut_info",&m_cutinfo); TFile* file = new TFile(destionation_file.c_str(),"RECREATE"); const Short_t BINS = 40; TH1D* th1_balance = new TH1D("balance","Balance;Balance;Number of events",BINS,0,1); /// number of total entries in chain of root files Long64_t chain_entries = chain->GetEntries(); // Loop over all leafs in the chain for (Long64_t chain_entry = 0; chain_entry < chain_entries; ++chain_entry) { chain->GetEvent(chain_entry); // load leafs from tree th1_balance->Fill(m_DiJet_balance,1); } file->Write(); } // kate: indent-mode cstyle; space-indent on; indent-width 4; }}} = treewalk.h = {{{ #!cplusplus #ifndef treewalk_h #define treewalk_h #include #include #include #include using std::vector; using std::string; using std::cout; using std::endl; class TreeWalk { public: TreeWalk ( string destionation_file, TChain* chain); private: Double_t m_DiJet_balance; Double_t m_DiJet_boosted_angle; Double_t m_DiJet_boosted_delta_R; Double_t m_DiJet_delta_R; Double_t m_DiJet_delta_phi; Double_t m_DiJet_pT_0; // pT_0 > pT_1 Double_t m_DiJet_pT_1; // pT_1 < pT_0 Double_t m_Jet_Ht; Double_t m_Jet_thrust; Double_t m_Jet_acoplanarity; Double_t m_Jet_aplanarity; Double_t m_Jet_centrality; Double_t m_Jet_circularity; Double_t m_Jet_sphericity; Double_t m_Jet_sphericity1; Double_t m_Jet_sphericity2; Double_t m_Jet_thrust_transverse; Double_t m_deltaR_1stJet_Lepton; Double_t m_JetSum_eta; Int_t m_cutinfo; // cutflow flags enum { cf_MinBiasMBTS11 = (1 << 0), cf_SingleElectronNoMissingETCut = (1 << 1), cf_SingleElectronMissingETCut = (1 << 2), cf_SingleMuonNoMissingETCut = (1 << 3), cf_SingleMuonMissingETCut = (1 << 4) }; }; #endif // treewalk_h // kate: indent-mode cstyle; space-indent on; indent-width 4; }}}