ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/skim_data.h
Revision: 1.1
Committed: Tue Jun 22 22:37:55 2010 UTC (14 years, 10 months ago) by jengbou
Content type: text/plain
Branch: MAIN
Log Message:
Add file

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_data_h
9     #define skim_data_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_data {
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     // if use BooEventNtuple
28     /* vector<float> top_muon_pt; */
29     /* vector<float> top_muon_d0; */
30     /* vector<float> top_muon_d0Error; */
31     /* vector<float> top_muon_old_reliso; */
32     /* vector<float> top_muon_new_reliso; */
33     /* vector<float> top_muon_ptrel; */
34    
35     Int_t top_njets;
36     Int_t top_trk_muon;
37     float top_met;
38     float top_muon_pt;
39     float top_muon_d0;
40     float top_muon_d0Error;
41     float top_muon_old_reliso;
42     float top_muon_new_reliso;
43     float top_muon_ptrel;
44    
45     // List of branches
46     TBranch *b_top_njets;
47     TBranch *b_top_met;
48     TBranch *b_top_muon_pt;
49     TBranch *b_top_muon_d0;
50     TBranch *b_top_muon_d0Error;
51     TBranch *b_top_muon_old_reliso;
52     TBranch *b_top_trk_muon;
53    
54     skim_data(TTree *tree=0);
55     virtual ~skim_data();
56     virtual Int_t Cut(Long64_t entry);
57     virtual Int_t GetEntry(Long64_t entry);
58     virtual Long64_t LoadTree(Long64_t entry);
59     virtual void Init(TTree *tree);
60     virtual void Loop();
61     virtual Bool_t Notify();
62     virtual void Show(Long64_t entry = -1);
63     double round(double, int);
64     };
65    
66     #endif
67    
68     #ifdef skim_data_cxx
69     skim_data::skim_data(TTree *tree)
70     {
71     TChain * chain = new TChain("top");
72    
73     chain->Add("20100621/ABCD_data_May27thReReco.root");
74     //chain->Add("20100616/ABCD_QCD.root");
75     //chain->Add("20100616/ABCD_ppMuX_loose.root");
76     //chain->Add("20100616/ABCD_W_loose.root");
77    
78     tree = chain;
79     Init(tree);
80     }
81    
82     skim_data::~skim_data()
83     {
84     if (!fChain) return;
85     delete fChain->GetCurrentFile();
86     }
87    
88     Int_t skim_data::GetEntry(Long64_t entry)
89     {
90     // Read contents of entry.
91     if (!fChain) return 0;
92     return fChain->GetEntry(entry);
93     }
94     Long64_t skim_data::LoadTree(Long64_t entry)
95     {
96     // Set the environment to read one entry
97     if (!fChain) return -5;
98     Long64_t centry = fChain->LoadTree(entry);
99     if (centry < 0) return centry;
100     if (!fChain->InheritsFrom(TChain::Class())) return centry;
101     TChain *chain = (TChain*)fChain;
102     if (chain->GetTreeNumber() != fCurrent) {
103     fCurrent = chain->GetTreeNumber();
104     Notify();
105     }
106     return centry;
107     }
108    
109     void skim_data::Init(TTree *tree)
110     {
111     // The Init() function is called when the selector needs to initialize
112     // a new tree or chain. Typically here the branch addresses and branch
113     // pointers of the tree will be set.
114     // It is normally not necessary to make changes to the generated
115     // code, but the routine can be extended by the user if needed.
116     // Init() will be called many times when running on PROOF
117     // (once per file to be processed).
118    
119     // Set branch addresses and branch pointers
120     if (!tree) return;
121     fChain = tree;
122     fCurrent = -1;
123     fChain->SetMakeClass(1);
124    
125     fChain->SetBranchAddress("njets", &top_njets, &b_top_njets);
126     fChain->SetBranchAddress("TrackerMu", &top_trk_muon, &b_top_trk_muon);
127     fChain->SetBranchAddress("met", &top_met, &b_top_met);
128     fChain->SetBranchAddress("muon_pt", &top_muon_pt, &b_top_muon_pt);
129     fChain->SetBranchAddress("muon_d0", &top_muon_d0, &b_top_muon_d0);
130     fChain->SetBranchAddress("muon_d0Error", &top_muon_d0Error, &b_top_muon_d0Error);
131     fChain->SetBranchAddress("muon_old_reliso", &top_muon_old_reliso, &b_top_muon_old_reliso);
132     Notify();
133     }
134    
135     Bool_t skim_data::Notify()
136     {
137     // The Notify() function is called when a new file is opened. This
138     // can be either for a new TTree in a TChain or when when a new TTree
139     // is started when using PROOF. It is normally not necessary to make changes
140     // to the generated code, but the routine can be extended by the
141     // user if needed. The return value is currently not used.
142    
143     return kTRUE;
144     }
145    
146     void skim_data::Show(Long64_t entry)
147     {
148     // Print contents of entry.
149     // If entry is not specified, print current entry
150     if (!fChain) return;
151     fChain->Show(entry);
152     }
153    
154     Int_t skim_data::Cut(Long64_t entry)
155     {
156     // This function may be called from Loop.
157     // returns 1 if entry is accepted.
158     // returns -1 otherwise.
159     return 1;
160     }
161    
162     #endif // #ifdef skim_data_cxx