ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/skim_data.h
Revision: 1.2
Committed: Wed Jul 21 00:55:58 2010 UTC (14 years, 9 months ago) by jengbou
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +28 -8 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 jengbou 1.2 // from TTree top
5     // found on file:
6 jengbou 1.1 //////////////////////////////////////////////////////////
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 jengbou 1.2 Int_t top_muon_trackerhits;
38     Int_t top_muon_muonhits;
39     float top_muon_chi2;
40     float top_muon_jet_dr;
41 jengbou 1.1 float top_met;
42     float top_muon_pt;
43 jengbou 1.2 float top_muon_eta;
44 jengbou 1.1 float top_muon_d0;
45     float top_muon_d0Error;
46     float top_muon_old_reliso;
47     float top_muon_new_reliso;
48     float top_muon_ptrel;
49    
50     // List of branches
51     TBranch *b_top_njets;
52     TBranch *b_top_met;
53     TBranch *b_top_muon_pt;
54 jengbou 1.2 TBranch *b_top_muon_eta;
55 jengbou 1.1 TBranch *b_top_muon_d0;
56     TBranch *b_top_muon_d0Error;
57     TBranch *b_top_muon_old_reliso;
58     TBranch *b_top_trk_muon;
59 jengbou 1.2 TBranch *b_top_muon_trackerhits;
60     TBranch *b_top_muon_muonhits;
61     TBranch *b_top_muon_chi2;
62     TBranch *b_top_muon_jet_dr;
63 jengbou 1.1
64     skim_data(TTree *tree=0);
65     virtual ~skim_data();
66     virtual Int_t Cut(Long64_t entry);
67     virtual Int_t GetEntry(Long64_t entry);
68     virtual Long64_t LoadTree(Long64_t entry);
69     virtual void Init(TTree *tree);
70     virtual void Loop();
71     virtual Bool_t Notify();
72     virtual void Show(Long64_t entry = -1);
73     double round(double, int);
74     };
75    
76     #endif
77    
78     #ifdef skim_data_cxx
79     skim_data::skim_data(TTree *tree)
80     {
81     TChain * chain = new TChain("top");
82 jengbou 1.2
83     chain->Add("20100720/ABCD_data_July20.root");
84     //chain->Add("20100623/ABCD_ppMuX_new.root");
85     //chain->Add("20100623/ABCD_W_new.root");
86     //chain->Add("20100711/ABCD_ZJets.root");
87     //chain->Add("20100715/ABCD_InclusiveMu15_tmp.root");//InclusiveMu15 new
88     //chain->Add("20100615/ABCD_QCD.root");//InclusiveMu15 old format
89     //chain->Add("20100707/ABCD_data_36nb.root");
90     //chain->Add("20100707/ABCD_data_July7.root");
91     //chain->Add("20100711/ABCD_data_July11.root");
92    
93 jengbou 1.1 tree = chain;
94     Init(tree);
95     }
96    
97     skim_data::~skim_data()
98     {
99     if (!fChain) return;
100     delete fChain->GetCurrentFile();
101     }
102    
103     Int_t skim_data::GetEntry(Long64_t entry)
104     {
105     // Read contents of entry.
106     if (!fChain) return 0;
107     return fChain->GetEntry(entry);
108     }
109     Long64_t skim_data::LoadTree(Long64_t entry)
110     {
111     // Set the environment to read one entry
112     if (!fChain) return -5;
113     Long64_t centry = fChain->LoadTree(entry);
114     if (centry < 0) return centry;
115     if (!fChain->InheritsFrom(TChain::Class())) return centry;
116     TChain *chain = (TChain*)fChain;
117     if (chain->GetTreeNumber() != fCurrent) {
118     fCurrent = chain->GetTreeNumber();
119     Notify();
120     }
121     return centry;
122     }
123    
124     void skim_data::Init(TTree *tree)
125     {
126     // The Init() function is called when the selector needs to initialize
127     // a new tree or chain. Typically here the branch addresses and branch
128     // pointers of the tree will be set.
129     // It is normally not necessary to make changes to the generated
130     // code, but the routine can be extended by the user if needed.
131     // Init() will be called many times when running on PROOF
132     // (once per file to be processed).
133    
134     // Set branch addresses and branch pointers
135     if (!tree) return;
136     fChain = tree;
137     fCurrent = -1;
138     fChain->SetMakeClass(1);
139    
140     fChain->SetBranchAddress("njets", &top_njets, &b_top_njets);
141     fChain->SetBranchAddress("TrackerMu", &top_trk_muon, &b_top_trk_muon);
142     fChain->SetBranchAddress("met", &top_met, &b_top_met);
143     fChain->SetBranchAddress("muon_pt", &top_muon_pt, &b_top_muon_pt);
144 jengbou 1.2 fChain->SetBranchAddress("muon_eta", &top_muon_eta, &b_top_muon_eta);
145 jengbou 1.1 fChain->SetBranchAddress("muon_d0", &top_muon_d0, &b_top_muon_d0);
146     fChain->SetBranchAddress("muon_d0Error", &top_muon_d0Error, &b_top_muon_d0Error);
147     fChain->SetBranchAddress("muon_old_reliso", &top_muon_old_reliso, &b_top_muon_old_reliso);
148 jengbou 1.2 fChain->SetBranchAddress("muon_trackerhits", &top_muon_trackerhits, &b_top_muon_trackerhits);
149     fChain->SetBranchAddress("muon_muonhits", &top_muon_muonhits, &b_top_muon_muonhits);
150     fChain->SetBranchAddress("muon_chi2", &top_muon_chi2, &b_top_muon_chi2);
151     fChain->SetBranchAddress("muon_jet_dr", &top_muon_jet_dr, &b_top_muon_jet_dr);
152 jengbou 1.1 Notify();
153     }
154    
155     Bool_t skim_data::Notify()
156     {
157     // The Notify() function is called when a new file is opened. This
158     // can be either for a new TTree in a TChain or when when a new TTree
159     // is started when using PROOF. It is normally not necessary to make changes
160     // to the generated code, but the routine can be extended by the
161     // user if needed. The return value is currently not used.
162    
163     return kTRUE;
164     }
165    
166     void skim_data::Show(Long64_t entry)
167     {
168     // Print contents of entry.
169     // If entry is not specified, print current entry
170     if (!fChain) return;
171     fChain->Show(entry);
172     }
173    
174     Int_t skim_data::Cut(Long64_t entry)
175     {
176     // This function may be called from Loop.
177     // returns 1 if entry is accepted.
178     // returns -1 otherwise.
179     return 1;
180     }
181    
182     #endif // #ifdef skim_data_cxx