ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/skim.h
Revision: 1.2
Committed: Mon Apr 20 23:41:31 2009 UTC (16 years ago) by jengbou
Content type: text/plain
Branch: MAIN
Changes since 1.1: +10 -4 lines
Log Message:
update

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 jengbou 1.2 // FastSim
59     /* chain->Add("nominal_2_2_6/ABCD_TTbar_madgraph_all.root/top"); */
60     /* chain->Add("nominal_2_2_6/ABCD_Mu15Pt20_all.root/top"); */
61     /* chain->Add("nominal_2_2_6/ABCD_WJets_madgraph_v2_all.root/top"); */
62     /* chain->Add("nominal_2_2_6/ABCD_ZJets_madgraph_v2_all.root/top"); */
63    
64     chain->Add("nominal_2_2_5/ABCD_TTJets_all.root/top");
65     chain->Add("nominal_2_2_5/ABCD_MuPt15_all.root/top");
66     chain->Add("nominal_2_2_5/ABCD_WJets_all.root/top");
67     chain->Add("nominal_2_2_5/ABCD_ZJets_all.root/top");
68 jengbou 1.1
69     tree = chain;
70     Init(tree);
71     }
72    
73     skim::~skim()
74     {
75     if (!fChain) return;
76     delete fChain->GetCurrentFile();
77     }
78    
79     Int_t skim::GetEntry(Long64_t entry)
80     {
81     // Read contents of entry.
82     if (!fChain) return 0;
83     return fChain->GetEntry(entry);
84     }
85     Long64_t skim::LoadTree(Long64_t entry)
86     {
87     // Set the environment to read one entry
88     if (!fChain) return -5;
89     Long64_t centry = fChain->LoadTree(entry);
90     if (centry < 0) return centry;
91     if (!fChain->InheritsFrom(TChain::Class())) return centry;
92     TChain *chain = (TChain*)fChain;
93     if (chain->GetTreeNumber() != fCurrent) {
94     fCurrent = chain->GetTreeNumber();
95     Notify();
96     }
97     return centry;
98     }
99    
100     void skim::Init(TTree *tree)
101     {
102     // The Init() function is called when the selector needs to initialize
103     // a new tree or chain. Typically here the branch addresses and branch
104     // pointers of the tree will be set.
105     // It is normally not necessary to make changes to the generated
106     // code, but the routine can be extended by the user if needed.
107     // Init() will be called many times when running on PROOF
108     // (once per file to be processed).
109    
110     // Set branch addresses and branch pointers
111     if (!tree) return;
112     fChain = tree;
113     fCurrent = -1;
114     fChain->SetMakeClass(1);
115    
116     fChain->SetBranchAddress("top.njets", &top_njets, &b_top_njets);
117     fChain->SetBranchAddress("top.muon_d0", &top_muon_d0, &b_top_muon_d0);
118     fChain->SetBranchAddress("top.muon_d0Error", &top_muon_d0Error, &b_top_muon_d0Error);
119     fChain->SetBranchAddress("top.muon_old_reliso", &top_muon_old_reliso, &b_top_muon_old_reliso);
120     fChain->SetBranchAddress("top.muon_new_reliso", &top_muon_new_reliso, &b_top_muon_new_reliso);
121     Notify();
122     }
123    
124     Bool_t skim::Notify()
125     {
126     // The Notify() function is called when a new file is opened. This
127     // can be either for a new TTree in a TChain or when when a new TTree
128     // is started when using PROOF. It is normally not necessary to make changes
129     // to the generated code, but the routine can be extended by the
130     // user if needed. The return value is currently not used.
131    
132     return kTRUE;
133     }
134    
135     void skim::Show(Long64_t entry)
136     {
137     // Print contents of entry.
138     // If entry is not specified, print current entry
139     if (!fChain) return;
140     fChain->Show(entry);
141     }
142    
143     Int_t skim::Cut(Long64_t entry)
144     {
145     // This function may be called from Loop.
146     // returns 1 if entry is accepted.
147     // returns -1 otherwise.
148     return 1;
149     }
150    
151     #endif // #ifdef skim_cxx