ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CITCommon/CommonData/interface/ZmumuGammaEventTree.h
Revision: 1.1
Committed: Thu Sep 13 18:17:55 2012 UTC (12 years, 7 months ago) by sixie
Content type: text/plain
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 sixie 1.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 fMu1TrackChi2;
59     Float_t fMu1TrackNormalizedChi2;
60     Float_t fMu1DeltaR;
61     Float_t fMu1CalEnergyEm;
62     Float_t fMu1CalEnergyEmMax;
63     Float_t fMu1CalEnergyEmHad;
64     Float_t fMu2Pt;
65     Float_t fMu2Eta;
66     Float_t fMu2Phi;
67     Float_t fMu2TrackChi2;
68     Float_t fMu2TrackNormalizedChi2;
69     Float_t fMu2DeltaR;
70     Float_t fMu2CalEnergyEm;
71     Float_t fMu2CalEnergyEmMax;
72     Float_t fMu2CalEnergyEmHad;
73     Float_t fMinDeltaEta;
74     Float_t fMinDeltaR;
75     Float_t fMinDeltaPhi;
76     Float_t fkRatio;
77     Float_t fPreshowerE;
78    
79     Float_t fGenMu1Pt;
80     Float_t fGenMu1Eta;
81     Float_t fGenMu1Phi;
82     Float_t fGenMu2Pt;
83     Float_t fGenMu2Eta;
84     Float_t fGenMu2Phi;
85     Float_t fGenPhoE;
86     Float_t fGenPhoEt;
87     Float_t fGenPhoEta;
88     Float_t fGenPhoPhi;
89     Float_t fGenPhoMotherPdgId;
90     Bool_t fIsFSR;
91     Bool_t fIsISR;
92    
93     Int_t fPhoIEtaX;
94     Int_t fPhoIPhiY;
95     Int_t fMuNearIEtaX;
96     Int_t fMuNearIPhiY;
97     Bool_t fMuNearIsEB;
98     Int_t fMuNearIndex;
99    
100    
101    
102    
103     public:
104     /// this is the main element
105     TTree *tree_;
106     TFile *f_;
107    
108     /// hold the names of variables to facilitate things (filled during Init)
109     std::vector<std::string> variables_;
110    
111     /// default constructor
112     ZmumuGammaEventTree() {
113     fTreeType = kCITZmumuGammaEvent;
114     };
115     /// default destructor
116     ~ZmumuGammaEventTree(){
117     if (f_) f_->Close();
118     };
119    
120     /// initialize varibles and fill list of available variables
121     void InitVariables() {
122     fTreeType = 0.0;
123     fWeight = 0.0;
124     fRunNumber = 0.0;
125     fLumiSectionNumber = 0.0;
126     fEventNumber = 0.0;
127     fNPU = 0.0;
128     fRho = 0.0;
129     fNVertices = 0.0;
130     fMass = 0.0;
131     fDileptonMass = 0.0;
132     fPhotonPt = 0.0;
133     fPhotonEta = 0.0;
134     fPhotonPhi = 0.0;
135     fPhotonR9 = 0.0;
136     fPhotonIsEB = 0.0;
137     fPhotonHoE = 0.0;
138     fSCEt = 0.0;
139     fSCE = 0.0;
140     fSCRawE = 0.0;
141     fSCEta = 0.0;
142     fSCEtaWidth = 0.0;
143     fSCPhiWidth = 0.0;
144     fPhoToTrackDeltaR = 0.0;
145     fPhoPassElectronVeto = 0.0;
146     fPhoHasMatchedConversion = 0.0;
147     fPhoHasPixelMatch = 0.0;
148     fPhoSigmaIEtaIEta = 0.0;
149     fPhoTrackIso = 0.0;
150     fPhoEcalIso = 0.0;
151     fPhoHcalIso = 0.0;
152     fPhoPdgId = 0.0;
153     fPhoCrackCorr = 0.0;
154     fMu1Pt = 0.0;
155     fMu1Eta = 0.0;
156     fMu1Phi = 0.0;
157     fMu1TrackChi2 = 0.0;
158     fMu1TrackNormalizedChi2 = 0.0;
159     fMu1DeltaR = 0.0;
160     fMu1CalEnergyEm = 0.0;
161     fMu1CalEnergyEmMax = 0.0;
162     fMu1CalEnergyEmHad = 0.0;
163     fMu2Pt = 0.0;
164     fMu2Eta = 0.0;
165     fMu2Phi = 0.0;
166     fMu2TrackChi2 = 0.0;
167     fMu2TrackNormalizedChi2 = 0.0;
168     fMu2DeltaR = 0.0;
169     fMu2CalEnergyEm = 0.0;
170     fMu2CalEnergyEmMax = 0.0;
171     fMu2CalEnergyEmHad = 0.0;
172     fMinDeltaEta = 0.0;
173     fMinDeltaR = 0.0;
174     fMinDeltaPhi = 0.0;
175     fkRatio = 0.0;
176     fPreshowerE = 0.0;
177     fGenMu1Pt = 0.0;
178     fGenMu1Eta = 0.0;
179     fGenMu1Phi = 0.0;
180     fGenMu2Pt = 0.0;
181     fGenMu2Eta = 0.0;
182     fGenMu2Phi = 0.0;
183     fGenPhoE = 0.0;
184     fGenPhoEt = 0.0;
185     fGenPhoEta = 0.0;
186     fGenPhoPhi = 0.0;
187     fGenPhoMotherPdgId = 0.0;
188     fIsFSR = false;
189     fIsISR = false;
190     fPhoIEtaX = 0.0;
191     fPhoIPhiY = 0.0;
192     fMuNearIEtaX = 0.0;
193     fMuNearIPhiY = 0.0;
194     fMuNearIsEB = false;
195     fMuNearIndex = 0.0;
196    
197     }
198    
199     /// load a ZmumuGammaEventTree
200     void LoadTree(const char* file, UInt_t Type = kCITZmumuGammaEvent){
201     fTreeType = Type;
202     f_ = TFile::Open(file);
203     assert(f_);
204     if (Type == kCITZmumuGammaEvent) {
205     tree_ = dynamic_cast<TTree*>(f_->Get("ZmumuGammaEvent"));
206     } else {
207     cout << "Warning: Type " << Type << " is not supported \n";
208     }
209     InitTree(Type);
210     assert(tree_);
211     }
212    
213     /// create a ZmumuGammaEventTree
214     void CreateTree(){
215     tree_ = new TTree("ZmumuGammaEvent","ZmumuGammaEvent");
216     f_ = 0;
217    
218     //book the branches
219     tree_->Branch("Weight",&fWeight,"Weight/F");
220     tree_->Branch("RunNumber",&fRunNumber,"RunNumber/i");
221     tree_->Branch("LumiSectionNumber",&fLumiSectionNumber,"LumiSectionNumber/i");
222     tree_->Branch("EventNumber",&fEventNumber,"EventNumber/i");
223     tree_->Branch("NPU",&fNPU,"NPU/i");
224     tree_->Branch("Rho",&fRho,"Rho/F");
225     tree_->Branch("NVertices",&fNVertices,"NVertices/i");
226     tree_->Branch("Mass",&fMass,"Mass/F");
227     tree_->Branch("DileptonMass",&fDileptonMass,"DileptonMass/F");
228     tree_->Branch("PhotonPt",&fPhotonPt,"PhotonPt/F");
229     tree_->Branch("PhotonEta",&fPhotonEta,"PhotonEta/F");
230     tree_->Branch("PhotonPhi",&fPhotonPhi,"PhotonPhi/F");
231     tree_->Branch("PhotonR9",&fPhotonR9,"PhotonR9/F");
232     tree_->Branch("PhotonIsEB",&fPhotonIsEB,"PhotonIsEB/F");
233     tree_->Branch("PhotonHoE",&fPhotonHoE,"PhotonHoE/F");
234     tree_->Branch("SCEt",&fSCEt,"SCEt/F");
235     tree_->Branch("SCE",&fSCE,"SCE/F");
236     tree_->Branch("SCRawE",&fSCRawE,"SCRawE/F");
237     tree_->Branch("SCEta",&fSCEta,"SCEta/F");
238     tree_->Branch("SCEtaWidth",&fSCEtaWidth,"SCEtaWidth/F");
239     tree_->Branch("SCPhiWidth",&fSCPhiWidth,"SCPhiWidth/F");
240     tree_->Branch("PhoToTrackDeltaR",&fPhoToTrackDeltaR,"PhoToTrackDeltaR/F");
241     tree_->Branch("PhoPassElectronVeto",&fPhoPassElectronVeto,"PhoPassElectronVeto/F");
242     tree_->Branch("PhoHasMatchedConversion",&fPhoHasMatchedConversion,"PhoHasMatchedConversion/F");
243     tree_->Branch("PhoHasPixelMatch",&fPhoHasPixelMatch,"PhoHasPixelMatch/F");
244     tree_->Branch("PhoSigmaIEtaIEta",&fPhoSigmaIEtaIEta,"PhoSigmaIEtaIEta/F");
245     tree_->Branch("PhoTrackIso",&fPhoTrackIso,"PhoTrackIso/F");
246     tree_->Branch("PhoEcalIso",&fPhoEcalIso,"PhoEcalIso/F");
247     tree_->Branch("PhoHcalIso",&fPhoHcalIso,"PhoHcalIso/F");
248     tree_->Branch("PhoPdgId",&fPhoPdgId,"PhoPdgId/F");
249     tree_->Branch("PhoCrackCorr",&fPhoCrackCorr,"PhoCrackCorr/F");
250     tree_->Branch("Mu1Pt",&fMu1Pt,"Mu1Pt/F");
251     tree_->Branch("Mu1Eta",&fMu1Eta,"Mu1Eta/F");
252     tree_->Branch("Mu1Phi",&fMu1Phi,"Mu1Phi/F");
253     tree_->Branch("Mu1TrackChi2",&fMu1TrackChi2,"Mu1TrackChi2/F");
254     tree_->Branch("Mu1TrackNormalizedChi2",&fMu1TrackNormalizedChi2,"Mu1TrackNormalizedChi2/F");
255     tree_->Branch("Mu1DeltaR",&fMu1DeltaR,"Mu1DeltaR/F");
256     tree_->Branch("Mu1CalEnergyEm",&fMu1CalEnergyEm,"Mu1CalEnergyEm/F");
257     tree_->Branch("Mu1CalEnergyEmMax",&fMu1CalEnergyEmMax,"Mu1CalEnergyEmMax/F");
258     tree_->Branch("Mu1CalEnergyEmHad",&fMu1CalEnergyEmHad,"Mu1CalEnergyEmHad/F");
259     tree_->Branch("Mu2Pt",&fMu2Pt,"Mu2Pt/F");
260     tree_->Branch("Mu2Eta",&fMu2Eta,"Mu2Eta/F");
261     tree_->Branch("Mu2Phi",&fMu2Phi,"Mu2Phi/F");
262     tree_->Branch("Mu2TrackChi2",&fMu2TrackChi2,"Mu2TrackChi2/F");
263     tree_->Branch("Mu2TrackNormalizedChi2",&fMu2TrackNormalizedChi2,"Mu2TrackNormalizedChi2/F");
264     tree_->Branch("Mu2DeltaR",&fMu2DeltaR,"Mu2DeltaR/F");
265     tree_->Branch("Mu2CalEnergyEm",&fMu2CalEnergyEm,"Mu2CalEnergyEm/F");
266     tree_->Branch("Mu2CalEnergyEmMax",&fMu2CalEnergyEmMax,"Mu2CalEnergyEmMax/F");
267     tree_->Branch("Mu2CalEnergyEmHad",&fMu2CalEnergyEmHad,"Mu2CalEnergyEmHad/F");
268     tree_->Branch("MinDeltaEta",&fMinDeltaEta,"MinDeltaEta/F");
269     tree_->Branch("MinDeltaR",&fMinDeltaR,"MinDeltaR/F");
270     tree_->Branch("MinDeltaPhi",&fMinDeltaPhi,"MinDeltaPhi/F");
271     tree_->Branch("kRatio",&fkRatio,"kRatio/F");
272     tree_->Branch("PreshowerE",&fPreshowerE,"PreshowerE/F");
273     tree_->Branch("GenMu1Pt",&fGenMu1Pt,"GenMu1Pt/F");
274     tree_->Branch("GenMu1Eta",&fGenMu1Eta,"GenMu1Eta/F");
275     tree_->Branch("GenMu1Phi",&fGenMu1Phi,"GenMu1Phi/F");
276     tree_->Branch("GenMu2Pt",&fGenMu2Pt,"GenMu2Pt/F");
277     tree_->Branch("GenMu2Eta",&fGenMu2Eta,"GenMu2Eta/F");
278     tree_->Branch("GenMu2Phi",&fGenMu2Phi,"GenMu2Phi/F");
279     tree_->Branch("GenPhoE",&fGenPhoE,"GenPhoE/F");
280     tree_->Branch("GenPhoEt",&fGenPhoEt,"GenPhoEt/F");
281     tree_->Branch("GenPhoEta",&fGenPhoEta,"GenPhoEta/F");
282     tree_->Branch("GenPhoPhi",&fGenPhoPhi,"GenPhoPhi/F");
283     tree_->Branch("GenPhoMotherPdgId",&fGenPhoMotherPdgId,"GenPhoMotherPdgId/F");
284     tree_->Branch("IsFSR",&fIsFSR,"IsFSR/O");
285     tree_->Branch("IsISR",&fIsISR,"IsISR/O");
286     tree_->Branch("PhoIEtaX",&fPhoIEtaX,"PhoIEtaX/I");
287     tree_->Branch("PhoIPhiY",&fPhoIPhiY,"PhoIPhiY/I");
288     tree_->Branch("MuNearIEtaX",&fMuNearIEtaX,"MuNearIEtaX/I");
289     tree_->Branch("MuNearIPhiY",&fMuNearIPhiY,"MuNearIPhiY/I");
290     tree_->Branch("MuNearIsEB",&fMuNearIsEB,"MuNearIsEB/O");
291     tree_->Branch("MuNearIndex",&fMuNearIndex,"MuNearIndex/I");
292     }
293    
294     // initialze a ZmumuGammaEventTree
295     void InitTree(UInt_t Type = kCITZmumuGammaEvent){
296     assert(tree_);
297     // don't forget to set pointers to zero before you set address
298     // or you will fully appreciate that "ROOT sucks" :)
299     InitVariables();
300     //Set branch address
301     Int_t currentState = gErrorIgnoreLevel;
302    
303     if (Type == kCITZmumuGammaEvent) {
304     cout << "CITZmumuGammaEvent\n";
305     // tree_->SetBranchAddress("weight",&fWeight);
306     } else {
307     cout << "Warning: Type " << Type << " is not supported \n";
308     }
309    
310     gErrorIgnoreLevel = currentState;
311     }
312    
313     };
314     }
315    
316    
317     #endif