ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/skim.h
Revision: 1.1
Committed: Wed Apr 15 06:35:28 2009 UTC (16 years ago) by jengbou
Content type: text/plain
Branch: MAIN
Log Message:
To skim file for QCD extrapolation study

File Contents

# User Rev Content
1 jengbou 1.1 //////////////////////////////////////////////////////////
2     // This class has been automatically generated on
3     // Tue Apr 14 23:27:01 2009
4     // from TTree top/top
5     // found on file: nominal/ABCD_TTJets_all.root
6     //////////////////////////////////////////////////////////
7    
8     #ifndef skim_h
9     #define skim_h
10    
11     #include <vector>
12     using namespace std;
13    
14     #include <TROOT.h>
15     #include <TChain.h>
16     #include <TFile.h>
17     #include <TH1.h>
18     const Int_t kMaxtop = 1;
19    
20     class skim {
21     public :
22     TTree *fChain; //!pointer to the analyzed TTree or TChain
23     Int_t fCurrent; //!current Tree number in a TChain
24    
25     // Declaration of leaf types
26     //BooEventNtuple *top.;
27     Int_t top_njets;
28     vector<float> top_muon_d0;
29     vector<float> top_muon_d0Error;
30     vector<float> top_muon_old_reliso;
31     vector<float> top_muon_new_reliso;
32     vector<float> top_muon_ptrel;
33    
34     // List of branches
35     TBranch *b_top_njets;
36     TBranch *b_top_muon_d0;
37     TBranch *b_top_muon_d0Error;
38     TBranch *b_top_muon_old_reliso;
39     TBranch *b_top_muon_new_reliso;
40    
41     skim(TTree *tree=0);
42     virtual ~skim();
43     virtual Int_t Cut(Long64_t entry);
44     virtual Int_t GetEntry(Long64_t entry);
45     virtual Long64_t LoadTree(Long64_t entry);
46     virtual void Init(TTree *tree);
47     virtual void Loop();
48     virtual Bool_t Notify();
49     virtual void Show(Long64_t entry = -1);
50     };
51    
52     #endif
53    
54     #ifdef skim_cxx
55     skim::skim(TTree *tree)
56     {
57     TChain * chain = new TChain("top","");
58     chain->Add("nominal/ABCD_TTJets_all.root/top");
59     chain->Add("nominal/ABCD_MuPt15_all.root/top");
60     chain->Add("nominal/ABCD_WJets_all.root/top");
61     chain->Add("nominal/ABCD_ZJets_all.root/top");
62    
63     tree = chain;
64     Init(tree);
65     }
66    
67     skim::~skim()
68     {
69     if (!fChain) return;
70     delete fChain->GetCurrentFile();
71     }
72    
73     Int_t skim::GetEntry(Long64_t entry)
74     {
75     // Read contents of entry.
76     if (!fChain) return 0;
77     return fChain->GetEntry(entry);
78     }
79     Long64_t skim::LoadTree(Long64_t entry)
80     {
81     // Set the environment to read one entry
82     if (!fChain) return -5;
83     Long64_t centry = fChain->LoadTree(entry);
84     if (centry < 0) return centry;
85     if (!fChain->InheritsFrom(TChain::Class())) return centry;
86     TChain *chain = (TChain*)fChain;
87     if (chain->GetTreeNumber() != fCurrent) {
88     fCurrent = chain->GetTreeNumber();
89     Notify();
90     }
91     return centry;
92     }
93    
94     void skim::Init(TTree *tree)
95     {
96     // The Init() function is called when the selector needs to initialize
97     // a new tree or chain. Typically here the branch addresses and branch
98     // pointers of the tree will be set.
99     // It is normally not necessary to make changes to the generated
100     // code, but the routine can be extended by the user if needed.
101     // Init() will be called many times when running on PROOF
102     // (once per file to be processed).
103    
104     // Set branch addresses and branch pointers
105     if (!tree) return;
106     fChain = tree;
107     fCurrent = -1;
108     fChain->SetMakeClass(1);
109    
110     fChain->SetBranchAddress("top.njets", &top_njets, &b_top_njets);
111     fChain->SetBranchAddress("top.muon_d0", &top_muon_d0, &b_top_muon_d0);
112     fChain->SetBranchAddress("top.muon_d0Error", &top_muon_d0Error, &b_top_muon_d0Error);
113     fChain->SetBranchAddress("top.muon_old_reliso", &top_muon_old_reliso, &b_top_muon_old_reliso);
114     fChain->SetBranchAddress("top.muon_new_reliso", &top_muon_new_reliso, &b_top_muon_new_reliso);
115     Notify();
116     }
117    
118     Bool_t skim::Notify()
119     {
120     // The Notify() function is called when a new file is opened. This
121     // can be either for a new TTree in a TChain or when when a new TTree
122     // is started when using PROOF. It is normally not necessary to make changes
123     // to the generated code, but the routine can be extended by the
124     // user if needed. The return value is currently not used.
125    
126     return kTRUE;
127     }
128    
129     void skim::Show(Long64_t entry)
130     {
131     // Print contents of entry.
132     // If entry is not specified, print current entry
133     if (!fChain) return;
134     fChain->Show(entry);
135     }
136    
137     Int_t skim::Cut(Long64_t entry)
138     {
139     // This function may be called from Loop.
140     // returns 1 if entry is accepted.
141     // returns -1 otherwise.
142     return 1;
143     }
144    
145     #endif // #ifdef skim_cxx