ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/skim.h
Revision: 1.3
Committed: Fri Oct 30 17:55:47 2009 UTC (15 years, 6 months ago) by jengbou
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +9 -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 jengbou 1.3 /* 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    
69     chain->Add("nominal_2_2_6/ABCD_TTJets_all.root/top");
70     chain->Add("nominal_2_2_6/ABCD_MuPt15_all.root/top");
71     chain->Add("nominal_2_2_6/ABCD_WJets_all.root/top");
72     chain->Add("nominal_2_2_6/ABCD_ZJets_all.root/top");
73 jengbou 1.1
74     tree = chain;
75     Init(tree);
76     }
77    
78     skim::~skim()
79     {
80     if (!fChain) return;
81     delete fChain->GetCurrentFile();
82     }
83    
84     Int_t skim::GetEntry(Long64_t entry)
85     {
86     // Read contents of entry.
87     if (!fChain) return 0;
88     return fChain->GetEntry(entry);
89     }
90     Long64_t skim::LoadTree(Long64_t entry)
91     {
92     // Set the environment to read one entry
93     if (!fChain) return -5;
94     Long64_t centry = fChain->LoadTree(entry);
95     if (centry < 0) return centry;
96     if (!fChain->InheritsFrom(TChain::Class())) return centry;
97     TChain *chain = (TChain*)fChain;
98     if (chain->GetTreeNumber() != fCurrent) {
99     fCurrent = chain->GetTreeNumber();
100     Notify();
101     }
102     return centry;
103     }
104    
105     void skim::Init(TTree *tree)
106     {
107     // The Init() function is called when the selector needs to initialize
108     // a new tree or chain. Typically here the branch addresses and branch
109     // pointers of the tree will be set.
110     // It is normally not necessary to make changes to the generated
111     // code, but the routine can be extended by the user if needed.
112     // Init() will be called many times when running on PROOF
113     // (once per file to be processed).
114    
115     // Set branch addresses and branch pointers
116     if (!tree) return;
117     fChain = tree;
118     fCurrent = -1;
119     fChain->SetMakeClass(1);
120    
121     fChain->SetBranchAddress("top.njets", &top_njets, &b_top_njets);
122     fChain->SetBranchAddress("top.muon_d0", &top_muon_d0, &b_top_muon_d0);
123     fChain->SetBranchAddress("top.muon_d0Error", &top_muon_d0Error, &b_top_muon_d0Error);
124     fChain->SetBranchAddress("top.muon_old_reliso", &top_muon_old_reliso, &b_top_muon_old_reliso);
125     fChain->SetBranchAddress("top.muon_new_reliso", &top_muon_new_reliso, &b_top_muon_new_reliso);
126     Notify();
127     }
128    
129     Bool_t skim::Notify()
130     {
131     // The Notify() function is called when a new file is opened. This
132     // can be either for a new TTree in a TChain or when when a new TTree
133     // is started when using PROOF. It is normally not necessary to make changes
134     // to the generated code, but the routine can be extended by the
135     // user if needed. The return value is currently not used.
136    
137     return kTRUE;
138     }
139    
140     void skim::Show(Long64_t entry)
141     {
142     // Print contents of entry.
143     // If entry is not specified, print current entry
144     if (!fChain) return;
145     fChain->Show(entry);
146     }
147    
148     Int_t skim::Cut(Long64_t entry)
149     {
150     // This function may be called from Loop.
151     // returns 1 if entry is accepted.
152     // returns -1 otherwise.
153     return 1;
154     }
155    
156     #endif // #ifdef skim_cxx