ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CITCommon/CommonData/interface/ZmumuGammaEventTree.h
Revision: 1.3
Committed: Thu Oct 4 11:02:27 2012 UTC (12 years, 6 months ago) by sixie
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +76 -2 lines
Error occurred while calculating annotation data.
Log Message:
update

File Contents

# Content
1 #ifndef ZmumuGammaEventTree_H
2 #define ZmumuGammaEventTree_H
3
4 #include "TFile.h"
5 #include "TTree.h"
6 #include "TError.h"
7 #include <cmath>
8 #include "assert.h"
9
10 namespace citana
11 {
12 class ZmumuGammaEventTree {
13
14 public:
15
16 enum ZmumuGammaEventTreeType { kCITZmumuGammaEvent = 0
17 };
18
19
20 /// setup variables
21 UInt_t fTreeType;
22
23 //Tree variables
24 Float_t fWeight;
25 UInt_t fRunNumber;
26 UInt_t fLumiSectionNumber;
27 UInt_t fEventNumber;
28 UInt_t fNPU;
29 Float_t fRho;
30 UInt_t fNVertices;
31 Float_t fMass;
32 Float_t fDileptonMass;
33 Float_t fPhotonPt;
34 Float_t fPhotonEta;
35 Float_t fPhotonPhi;
36 Float_t fPhotonR9;
37 Float_t fPhotonIsEB;
38 Float_t fPhotonHoE;
39 Float_t fSCEt;
40 Float_t fSCE;
41 Float_t fSCRawE;
42 Float_t fSCEta;
43 Float_t fSCEtaWidth;
44 Float_t fSCPhiWidth;
45 Float_t fPhoToTrackDeltaR;
46 Float_t fPhoPassElectronVeto;
47 Float_t fPhoHasMatchedConversion;
48 Float_t fPhoHasPixelMatch;
49 Float_t fPhoSigmaIEtaIEta;
50 Float_t fPhoTrackIso;
51 Float_t fPhoEcalIso;
52 Float_t fPhoHcalIso;
53 Float_t fPhoPdgId;
54 Float_t fPhoCrackCorr;
55 Float_t fMu1Pt;
56 Float_t fMu1Eta;
57 Float_t fMu1Phi;
58 Float_t fMu1Charge;
59 Float_t fMu1TrackChi2;
60 Float_t fMu1TrackNormalizedChi2;
61 Float_t fMu1DeltaR;
62 Float_t fMu1CalEnergyEm;
63 Float_t fMu1CalEnergyEmMax;
64 Float_t fMu1CalEnergyEmHad;
65 Float_t fMu2Pt;
66 Float_t fMu2Eta;
67 Float_t fMu2Phi;
68 Float_t fMu2Charge;
69 Float_t fMu2TrackChi2;
70 Float_t fMu2TrackNormalizedChi2;
71 Float_t fMu2DeltaR;
72 Float_t fMu2CalEnergyEm;
73 Float_t fMu2CalEnergyEmMax;
74 Float_t fMu2CalEnergyEmHad;
75 Float_t fMinDeltaEta;
76 Float_t fMinDeltaR;
77 Float_t fMinDeltaPhi;
78 Float_t fkRatio;
79 Float_t fPreshowerE;
80
81 Float_t fGenMu1Pt;
82 Float_t fGenMu1Eta;
83 Float_t fGenMu1Phi;
84 Float_t fGenMu2Pt;
85 Float_t fGenMu2Eta;
86 Float_t fGenMu2Phi;
87 Float_t fGenPhoE;
88 Float_t fGenPhoEt;
89 Float_t fGenPhoEta;
90 Float_t fGenPhoPhi;
91 Float_t fGenPhoMotherPdgId;
92 Bool_t fIsFSR;
93 Bool_t fIsISR;
94
95 Int_t fPhoIEtaX;
96 Int_t fPhoIPhiY;
97 Int_t fMuNearIEtaX;
98 Int_t fMuNearIPhiY;
99 Bool_t fMuNearIsEB;
100 Int_t fMuNearIndex;
101
102
103
104
105 public:
106 /// this is the main element
107 TTree *tree_;
108 TFile *f_;
109
110 /// hold the names of variables to facilitate things (filled during Init)
111 std::vector<std::string> variables_;
112
113 /// default constructor
114 ZmumuGammaEventTree() {
115 fTreeType = kCITZmumuGammaEvent;
116 };
117 /// default destructor
118 ~ZmumuGammaEventTree(){
119 if (f_) f_->Close();
120 };
121
122 /// initialize varibles and fill list of available variables
123 void InitVariables() {
124
125 fWeight = 0.0;
126 fRunNumber = 0.0;
127 fLumiSectionNumber = 0.0;
128 fEventNumber = 0.0;
129 fNPU = 0.0;
130 fRho = 0.0;
131 fNVertices = 0.0;
132 fMass = 0.0;
133 fDileptonMass = 0.0;
134 fPhotonPt = 0.0;
135 fPhotonEta = 0.0;
136 fPhotonPhi = 0.0;
137 fPhotonR9 = 0.0;
138 fPhotonIsEB = 0.0;
139 fPhotonHoE = 0.0;
140 fSCEt = 0.0;
141 fSCE = 0.0;
142 fSCRawE = 0.0;
143 fSCEta = 0.0;
144 fSCEtaWidth = 0.0;
145 fSCPhiWidth = 0.0;
146 fPhoToTrackDeltaR = 0.0;
147 fPhoPassElectronVeto = 0.0;
148 fPhoHasMatchedConversion = 0.0;
149 fPhoHasPixelMatch = 0.0;
150 fPhoSigmaIEtaIEta = 0.0;
151 fPhoTrackIso = 0.0;
152 fPhoEcalIso = 0.0;
153 fPhoHcalIso = 0.0;
154 fPhoPdgId = 0.0;
155 fPhoCrackCorr = 0.0;
156 fMu1Pt = 0.0;
157 fMu1Eta = 0.0;
158 fMu1Phi = 0.0;
159 fMu1Charge = 0;
160 fMu1TrackChi2 = 0.0;
161 fMu1TrackNormalizedChi2 = 0.0;
162 fMu1DeltaR = 0.0;
163 fMu1CalEnergyEm = 0.0;
164 fMu1CalEnergyEmMax = 0.0;
165 fMu1CalEnergyEmHad = 0.0;
166 fMu2Pt = 0.0;
167 fMu2Eta = 0.0;
168 fMu2Phi = 0.0;
169 fMu2Charge = 0;
170 fMu2TrackChi2 = 0.0;
171 fMu2TrackNormalizedChi2 = 0.0;
172 fMu2DeltaR = 0.0;
173 fMu2CalEnergyEm = 0.0;
174 fMu2CalEnergyEmMax = 0.0;
175 fMu2CalEnergyEmHad = 0.0;
176 fMinDeltaEta = 0.0;
177 fMinDeltaR = 0.0;
178 fMinDeltaPhi = 0.0;
179 fkRatio = 0.0;
180 fPreshowerE = 0.0;
181 fGenMu1Pt = 0.0;
182 fGenMu1Eta = 0.0;
183 fGenMu1Phi = 0.0;
184 fGenMu2Pt = 0.0;
185 fGenMu2Eta = 0.0;
186 fGenMu2Phi = 0.0;
187 fGenPhoE = 0.0;
188 fGenPhoEt = 0.0;
189 fGenPhoEta = 0.0;
190 fGenPhoPhi = 0.0;
191 fGenPhoMotherPdgId = 0.0;
192 fIsFSR = false;
193 fIsISR = false;
194 fPhoIEtaX = 0.0;
195 fPhoIPhiY = 0.0;
196 fMuNearIEtaX = 0.0;
197 fMuNearIPhiY = 0.0;
198 fMuNearIsEB = false;
199 fMuNearIndex = 0.0;
200
201 }
202
203 /// load a ZmumuGammaEventTree
204 void LoadTree(const char* file, UInt_t Type = kCITZmumuGammaEvent){
205 fTreeType = Type;
206 f_ = TFile::Open(file);
207 assert(f_);
208 if (Type == kCITZmumuGammaEvent) {
209 tree_ = dynamic_cast<TTree*>(f_->Get("ZmumuGammaEvent"));
210 } else {
211 cout << "Warning: Type " << Type << " is not supported \n";
212 }
213 InitTree(Type);
214 assert(tree_);
215 }
216
217 /// create a ZmumuGammaEventTree
218 void CreateTree(){
219 tree_ = new TTree("ZmumuGammaEvent","ZmumuGammaEvent");
220 f_ = 0;
221
222 //book the branches
223 tree_->Branch("Weight",&fWeight,"Weight/F");
224 tree_->Branch("RunNumber",&fRunNumber,"RunNumber/i");
225 tree_->Branch("LumiSectionNumber",&fLumiSectionNumber,"LumiSectionNumber/i");
226 tree_->Branch("EventNumber",&fEventNumber,"EventNumber/i");
227 tree_->Branch("NPU",&fNPU,"NPU/i");
228 tree_->Branch("Rho",&fRho,"Rho/F");
229 tree_->Branch("NVertices",&fNVertices,"NVertices/i");
230 tree_->Branch("Mass",&fMass,"Mass/F");
231 tree_->Branch("DileptonMass",&fDileptonMass,"DileptonMass/F");
232 tree_->Branch("PhotonPt",&fPhotonPt,"PhotonPt/F");
233 tree_->Branch("PhotonEta",&fPhotonEta,"PhotonEta/F");
234 tree_->Branch("PhotonPhi",&fPhotonPhi,"PhotonPhi/F");
235 tree_->Branch("PhotonR9",&fPhotonR9,"PhotonR9/F");
236 tree_->Branch("PhotonIsEB",&fPhotonIsEB,"PhotonIsEB/F");
237 tree_->Branch("PhotonHoE",&fPhotonHoE,"PhotonHoE/F");
238 tree_->Branch("SCEt",&fSCEt,"SCEt/F");
239 tree_->Branch("SCE",&fSCE,"SCE/F");
240 tree_->Branch("SCRawE",&fSCRawE,"SCRawE/F");
241 tree_->Branch("SCEta",&fSCEta,"SCEta/F");
242 tree_->Branch("SCEtaWidth",&fSCEtaWidth,"SCEtaWidth/F");
243 tree_->Branch("SCPhiWidth",&fSCPhiWidth,"SCPhiWidth/F");
244 tree_->Branch("PhoToTrackDeltaR",&fPhoToTrackDeltaR,"PhoToTrackDeltaR/F");
245 tree_->Branch("PhoPassElectronVeto",&fPhoPassElectronVeto,"PhoPassElectronVeto/F");
246 tree_->Branch("PhoHasMatchedConversion",&fPhoHasMatchedConversion,"PhoHasMatchedConversion/F");
247 tree_->Branch("PhoHasPixelMatch",&fPhoHasPixelMatch,"PhoHasPixelMatch/F");
248 tree_->Branch("PhoSigmaIEtaIEta",&fPhoSigmaIEtaIEta,"PhoSigmaIEtaIEta/F");
249 tree_->Branch("PhoTrackIso",&fPhoTrackIso,"PhoTrackIso/F");
250 tree_->Branch("PhoEcalIso",&fPhoEcalIso,"PhoEcalIso/F");
251 tree_->Branch("PhoHcalIso",&fPhoHcalIso,"PhoHcalIso/F");
252 tree_->Branch("PhoPdgId",&fPhoPdgId,"PhoPdgId/F");
253 tree_->Branch("PhoCrackCorr",&fPhoCrackCorr,"PhoCrackCorr/F");
254 tree_->Branch("Mu1Pt",&fMu1Pt,"Mu1Pt/F");
255 tree_->Branch("Mu1Eta",&fMu1Eta,"Mu1Eta/F");
256 tree_->Branch("Mu1Phi",&fMu1Phi,"Mu1Phi/F");
257 tree_->Branch("Mu1Charge",&fMu1Charge,"Mu1Charge/F");
258 tree_->Branch("Mu1TrackChi2",&fMu1TrackChi2,"Mu1TrackChi2/F");
259 tree_->Branch("Mu1TrackNormalizedChi2",&fMu1TrackNormalizedChi2,"Mu1TrackNormalizedChi2/F");
260 tree_->Branch("Mu1DeltaR",&fMu1DeltaR,"Mu1DeltaR/F");
261 tree_->Branch("Mu1CalEnergyEm",&fMu1CalEnergyEm,"Mu1CalEnergyEm/F");
262 tree_->Branch("Mu1CalEnergyEmMax",&fMu1CalEnergyEmMax,"Mu1CalEnergyEmMax/F");
263 tree_->Branch("Mu1CalEnergyEmHad",&fMu1CalEnergyEmHad,"Mu1CalEnergyEmHad/F");
264 tree_->Branch("Mu2Pt",&fMu2Pt,"Mu2Pt/F");
265 tree_->Branch("Mu2Eta",&fMu2Eta,"Mu2Eta/F");
266 tree_->Branch("Mu2Phi",&fMu2Phi,"Mu2Phi/F");
267 tree_->Branch("Mu2Charge",&fMu2Charge,"Mu2Charge/F");
268 tree_->Branch("Mu2TrackChi2",&fMu2TrackChi2,"Mu2TrackChi2/F");
269 tree_->Branch("Mu2TrackNormalizedChi2",&fMu2TrackNormalizedChi2,"Mu2TrackNormalizedChi2/F");
270 tree_->Branch("Mu2DeltaR",&fMu2DeltaR,"Mu2DeltaR/F");
271 tree_->Branch("Mu2CalEnergyEm",&fMu2CalEnergyEm,"Mu2CalEnergyEm/F");
272 tree_->Branch("Mu2CalEnergyEmMax",&fMu2CalEnergyEmMax,"Mu2CalEnergyEmMax/F");
273 tree_->Branch("Mu2CalEnergyEmHad",&fMu2CalEnergyEmHad,"Mu2CalEnergyEmHad/F");
274 tree_->Branch("MinDeltaEta",&fMinDeltaEta,"MinDeltaEta/F");
275 tree_->Branch("MinDeltaR",&fMinDeltaR,"MinDeltaR/F");
276 tree_->Branch("MinDeltaPhi",&fMinDeltaPhi,"MinDeltaPhi/F");
277 tree_->Branch("kRatio",&fkRatio,"kRatio/F");
278 tree_->Branch("PreshowerE",&fPreshowerE,"PreshowerE/F");
279 tree_->Branch("GenMu1Pt",&fGenMu1Pt,"GenMu1Pt/F");
280 tree_->Branch("GenMu1Eta",&fGenMu1Eta,"GenMu1Eta/F");
281 tree_->Branch("GenMu1Phi",&fGenMu1Phi,"GenMu1Phi/F");
282 tree_->Branch("GenMu2Pt",&fGenMu2Pt,"GenMu2Pt/F");
283 tree_->Branch("GenMu2Eta",&fGenMu2Eta,"GenMu2Eta/F");
284 tree_->Branch("GenMu2Phi",&fGenMu2Phi,"GenMu2Phi/F");
285 tree_->Branch("GenPhoE",&fGenPhoE,"GenPhoE/F");
286 tree_->Branch("GenPhoEt",&fGenPhoEt,"GenPhoEt/F");
287 tree_->Branch("GenPhoEta",&fGenPhoEta,"GenPhoEta/F");
288 tree_->Branch("GenPhoPhi",&fGenPhoPhi,"GenPhoPhi/F");
289 tree_->Branch("GenPhoMotherPdgId",&fGenPhoMotherPdgId,"GenPhoMotherPdgId/F");
290 tree_->Branch("IsFSR",&fIsFSR,"IsFSR/O");
291 tree_->Branch("IsISR",&fIsISR,"IsISR/O");
292 tree_->Branch("PhoIEtaX",&fPhoIEtaX,"PhoIEtaX/I");
293 tree_->Branch("PhoIPhiY",&fPhoIPhiY,"PhoIPhiY/I");
294 tree_->Branch("MuNearIEtaX",&fMuNearIEtaX,"MuNearIEtaX/I");
295 tree_->Branch("MuNearIPhiY",&fMuNearIPhiY,"MuNearIPhiY/I");
296 tree_->Branch("MuNearIsEB",&fMuNearIsEB,"MuNearIsEB/O");
297 tree_->Branch("MuNearIndex",&fMuNearIndex,"MuNearIndex/I");
298 }
299
300 // initialze a ZmumuGammaEventTree
301 void InitTree(UInt_t Type = kCITZmumuGammaEvent){
302 assert(tree_);
303 // don't forget to set pointers to zero before you set address
304 // or you will fully appreciate that "ROOT sucks" :)
305 InitVariables();
306 //Set branch address
307 Int_t currentState = gErrorIgnoreLevel;
308
309 if (Type == kCITZmumuGammaEvent) {
310 cout << "CITZmumuGammaEvent\n";
311 tree_->SetBranchAddress("Weight",&fWeight);
312 tree_->SetBranchAddress("RunNumber",&fRunNumber);
313 tree_->SetBranchAddress("LumiSectionNumber",&fLumiSectionNumber);
314 tree_->SetBranchAddress("EventNumber",&fEventNumber);
315 tree_->SetBranchAddress("NPU",&fNPU);
316 tree_->SetBranchAddress("Rho",&fRho);
317 tree_->SetBranchAddress("NVertices",&fNVertices);
318 tree_->SetBranchAddress("Mass",&fMass);
319 tree_->SetBranchAddress("DileptonMass",&fDileptonMass);
320 tree_->SetBranchAddress("PhotonPt",&fPhotonPt);
321 tree_->SetBranchAddress("PhotonEta",&fPhotonEta);
322 tree_->SetBranchAddress("PhotonPhi",&fPhotonPhi);
323 tree_->SetBranchAddress("PhotonR9",&fPhotonR9);
324 tree_->SetBranchAddress("PhotonIsEB",&fPhotonIsEB);
325 tree_->SetBranchAddress("PhotonHoE",&fPhotonHoE);
326 tree_->SetBranchAddress("SCEt",&fSCEt);
327 tree_->SetBranchAddress("SCE",&fSCE);
328 tree_->SetBranchAddress("SCRawE",&fSCRawE);
329 tree_->SetBranchAddress("SCEta",&fSCEta);
330 tree_->SetBranchAddress("SCEtaWidth",&fSCEtaWidth);
331 tree_->SetBranchAddress("SCPhiWidth",&fSCPhiWidth);
332 tree_->SetBranchAddress("PhoToTrackDeltaR",&fPhoToTrackDeltaR);
333 tree_->SetBranchAddress("PhoPassElectronVeto",&fPhoPassElectronVeto);
334 tree_->SetBranchAddress("PhoHasMatchedConversion",&fPhoHasMatchedConversion);
335 tree_->SetBranchAddress("PhoHasPixelMatch",&fPhoHasPixelMatch);
336 tree_->SetBranchAddress("PhoSigmaIEtaIEta",&fPhoSigmaIEtaIEta);
337 tree_->SetBranchAddress("PhoTrackIso",&fPhoTrackIso);
338 tree_->SetBranchAddress("PhoEcalIso",&fPhoEcalIso);
339 tree_->SetBranchAddress("PhoHcalIso",&fPhoHcalIso);
340 tree_->SetBranchAddress("PhoPdgId",&fPhoPdgId);
341 tree_->SetBranchAddress("PhoCrackCorr",&fPhoCrackCorr);
342 tree_->SetBranchAddress("Mu1Pt",&fMu1Pt);
343 tree_->SetBranchAddress("Mu1Eta",&fMu1Eta);
344 tree_->SetBranchAddress("Mu1Phi",&fMu1Phi);
345 tree_->SetBranchAddress("Mu1Charge",&fMu1Charge);
346 tree_->SetBranchAddress("Mu1TrackChi2",&fMu1TrackChi2);
347 tree_->SetBranchAddress("Mu1TrackNormalizedChi2",&fMu1TrackNormalizedChi2);
348 tree_->SetBranchAddress("Mu1DeltaR",&fMu1DeltaR);
349 tree_->SetBranchAddress("Mu1CalEnergyEm",&fMu1CalEnergyEm);
350 tree_->SetBranchAddress("Mu1CalEnergyEmMax",&fMu1CalEnergyEmMax);
351 tree_->SetBranchAddress("Mu1CalEnergyEmHad",&fMu1CalEnergyEmHad);
352 tree_->SetBranchAddress("Mu2Pt",&fMu2Pt);
353 tree_->SetBranchAddress("Mu2Eta",&fMu2Eta);
354 tree_->SetBranchAddress("Mu2Phi",&fMu2Phi);
355 tree_->SetBranchAddress("Mu2Charge",&fMu2Charge);
356 tree_->SetBranchAddress("Mu2TrackChi2",&fMu2TrackChi2);
357 tree_->SetBranchAddress("Mu2TrackNormalizedChi2",&fMu2TrackNormalizedChi2);
358 tree_->SetBranchAddress("Mu2DeltaR",&fMu2DeltaR);
359 tree_->SetBranchAddress("Mu2CalEnergyEm",&fMu2CalEnergyEm);
360 tree_->SetBranchAddress("Mu2CalEnergyEmMax",&fMu2CalEnergyEmMax);
361 tree_->SetBranchAddress("Mu2CalEnergyEmHad",&fMu2CalEnergyEmHad);
362 tree_->SetBranchAddress("MinDeltaEta",&fMinDeltaEta);
363 tree_->SetBranchAddress("MinDeltaR",&fMinDeltaR);
364 tree_->SetBranchAddress("MinDeltaPhi",&fMinDeltaPhi);
365 tree_->SetBranchAddress("kRatio",&fkRatio);
366 tree_->SetBranchAddress("PreshowerE",&fPreshowerE);
367 tree_->SetBranchAddress("GenMu1Pt",&fGenMu1Pt);
368 tree_->SetBranchAddress("GenMu1Eta",&fGenMu1Eta);
369 tree_->SetBranchAddress("GenMu1Phi",&fGenMu1Phi);
370 tree_->SetBranchAddress("GenMu2Pt",&fGenMu2Pt);
371 tree_->SetBranchAddress("GenMu2Eta",&fGenMu2Eta);
372 tree_->SetBranchAddress("GenMu2Phi",&fGenMu2Phi);
373 tree_->SetBranchAddress("GenPhoE",&fGenPhoE);
374 tree_->SetBranchAddress("GenPhoEt",&fGenPhoEt);
375 tree_->SetBranchAddress("GenPhoEta",&fGenPhoEta);
376 tree_->SetBranchAddress("GenPhoPhi",&fGenPhoPhi);
377 tree_->SetBranchAddress("GenPhoMotherPdgId",&fGenPhoMotherPdgId);
378 tree_->SetBranchAddress("IsFSR",&fIsFSR);
379 tree_->SetBranchAddress("IsISR",&fIsISR);
380 tree_->SetBranchAddress("PhoIEtaX",&fPhoIEtaX);
381 tree_->SetBranchAddress("PhoIPhiY",&fPhoIPhiY);
382 tree_->SetBranchAddress("MuNearIEtaX",&fMuNearIEtaX);
383 tree_->SetBranchAddress("MuNearIPhiY",&fMuNearIPhiY);
384 tree_->SetBranchAddress("MuNearIsEB",&fMuNearIsEB);
385 tree_->SetBranchAddress("MuNearIndex",&fMuNearIndex);
386 } else {
387 cout << "Warning: Type " << Type << " is not supported \n";
388 }
389
390 gErrorIgnoreLevel = currentState;
391 }
392
393 };
394 }
395
396
397 #endif