Usage
download everything from here: TreeWalk.tar.gz
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
1 #include "treewalk.h"
2
3 #include <string>
4 #include <assert.h>
5
6
7 using std::vector;
8 using std::string;
9
10 int main ( int argc, char *argv[] ) {
11 // argv[0] is app name
12 assert ( argc > 2 );
13
14 string destination_file ( argv[1] );
15
16 TChain* chain = new TChain("OutputTree");
17 for ( int i = 2; i < argc; ++i ) {
18 Int_t res = chain->AddFile(argv[i]);
19 assert(res == 1);
20 }
21
22 TreeWalk treewalk ( destination_file, chain );
23
24 return ( 0 );
25 }
26
27 // kate: indent-mode cstyle; space-indent on; indent-width 4;
28
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
1 #include "treewalk.h"
2
3 #include <TH1.h>
4 #include <TFile.h>
5
6
7 TreeWalk::TreeWalk(string destionation_file, TChain* chain) {
8
9 chain->SetBranchAddress("DiJet_pT_0",&m_DiJet_pT_0);
10 chain->SetBranchAddress("DiJet_pT_1",&m_DiJet_pT_1);
11 chain->SetBranchAddress("DiJet_delta_phi",&m_DiJet_delta_phi);
12 chain->SetBranchAddress("DiJet_delta_R",&m_DiJet_delta_R);
13 chain->SetBranchAddress("DiJet_boosted_angle",&m_DiJet_boosted_angle);
14 chain->SetBranchAddress("DiJet_boosted_delta_R",&m_DiJet_boosted_delta_R);
15 chain->SetBranchAddress("DiJet_balance",&m_DiJet_balance);
16 chain->SetBranchAddress("Jet_centrality",&m_Jet_centrality);
17 chain->SetBranchAddress("Jet_sphericity",&m_Jet_sphericity);
18 chain->SetBranchAddress("Jet_aplanarity",&m_Jet_aplanarity);
19 chain->SetBranchAddress("Jet_acoplanarity",&m_Jet_acoplanarity);
20 chain->SetBranchAddress("Jet_Thrust",&m_Jet_thrust);
21 chain->SetBranchAddress("Jet_thrust_transverse",&m_Jet_thrust_transverse);
22 chain->SetBranchAddress("Jet_sphericity1",&m_Jet_sphericity1);
23 chain->SetBranchAddress("Jet_sphericity2",&m_Jet_sphericity2);
24 chain->SetBranchAddress("Jet_Ht",&m_Jet_Ht);
25 chain->SetBranchAddress("Jet_circularity",&m_Jet_circularity);
26 chain->SetBranchAddress("cut_info",&m_cutinfo);
27
28 TFile* file = new TFile(destionation_file.c_str(),"RECREATE");
29
30 const Short_t BINS = 40;
31
32 TH1D* th1_balance = new TH1D("balance","Balance;Balance;Number of events",BINS,0,1);
33
34 /// number of total entries in chain of root files
35 Long64_t chain_entries = chain->GetEntries();
36 // Loop over all leafs in the chain
37 for (Long64_t chain_entry = 0; chain_entry < chain_entries; ++chain_entry) {
38 chain->GetEvent(chain_entry); // load leafs from tree
39 th1_balance->Fill(m_DiJet_balance,1);
40 }
41
42 file->Write();
43 }
44 // kate: indent-mode cstyle; space-indent on; indent-width 4;
45
treewalk.h
1 #ifndef treewalk_h
2 #define treewalk_h
3
4 #include <string>
5 #include <vector>
6 #include <iostream>
7
8 #include <TChain.h>
9
10 using std::vector;
11 using std::string;
12 using std::cout;
13 using std::endl;
14
15 class TreeWalk {
16 public:
17 TreeWalk ( string destionation_file, TChain* chain);
18
19 private:
20 Double_t m_DiJet_balance;
21 Double_t m_DiJet_boosted_angle;
22 Double_t m_DiJet_boosted_delta_R;
23 Double_t m_DiJet_delta_R;
24 Double_t m_DiJet_delta_phi;
25 Double_t m_DiJet_pT_0; // pT_0 > pT_1
26 Double_t m_DiJet_pT_1; // pT_1 < pT_0
27 Double_t m_Jet_Ht;
28 Double_t m_Jet_thrust;
29 Double_t m_Jet_acoplanarity;
30 Double_t m_Jet_aplanarity;
31 Double_t m_Jet_centrality;
32 Double_t m_Jet_circularity;
33 Double_t m_Jet_sphericity;
34 Double_t m_Jet_sphericity1;
35 Double_t m_Jet_sphericity2;
36 Double_t m_Jet_thrust_transverse;
37 Double_t m_deltaR_1stJet_Lepton;
38 Double_t m_JetSum_eta;
39 Int_t m_cutinfo;
40
41 // cutflow flags
42 enum {
43 cf_MinBiasMBTS11 = (1 << 0),
44 cf_SingleElectronNoMissingETCut = (1 << 1),
45 cf_SingleElectronMissingETCut = (1 << 2),
46 cf_SingleMuonNoMissingETCut = (1 << 3),
47 cf_SingleMuonMissingETCut = (1 << 4)
48 };
49 };
50
51 #endif // treewalk_h
52 // kate: indent-mode cstyle; space-indent on; indent-width 4;
53