ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Vuko/WZAnalysis/src/MuonProperties.cc
Revision: 1.3
Committed: Mon Nov 26 15:15:55 2007 UTC (17 years, 5 months ago) by senka
Content type: text/plain
Branch: MAIN
Changes since 1.2: +155 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 vuko 1.1 #include "Vuko/WZAnalysis/interface/MuonProperties.h"
2    
3     // user include files
4     #include "FWCore/Framework/interface/Event.h"
5     #include "FWCore/Framework/interface/ESHandle.h"
6    
7     #include "DataFormats/Candidate/interface/CandidateFwd.h"
8    
9     //--- muon AOD:
10     #include "DataFormats/JetReco/interface/CaloJetCollection.h"
11     #include "DataFormats/EgammaCandidates/interface/Electron.h"
12     #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
13     #include "DataFormats/EgammaReco/interface/BasicCluster.h"
14     #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
15     #include "DataFormats/EgammaCandidates/interface/PixelMatchGsfElectron.h"
16    
17     #include "DataFormats/EgammaReco/interface/BasicClusterShapeAssociation.h"
18     #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
19     #include "DataFormats/EcalDetId/interface/EBDetId.h"
20     #include "DataFormats/EcalDetId/interface/EEDetId.h"
21     #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
22     #include "Geometry/Records/interface/IdealGeometryRecord.h"
23    
24     #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
25    
26 senka 1.3 // muon data formats
27     #include "DataFormats/MuonReco/interface/MuIsoDeposit.h"
28     #include "DataFormats/MuonReco/interface/MuonFwd.h"
29     #include "DataFormats/MuonReco/interface/Muon.h"
30    
31 vuko 1.1
32     #include "TTree.h"
33     #include "TVector3.h"
34     #include <iostream>
35     #include <sstream>
36    
37     using namespace wzana;
38     using namespace edm;
39     using namespace std;
40    
41    
42     MuonProperties::MuonProperties() { }
43    
44    
45     void MuonProperties::ResetValues() {
46    
47     Charge = -10;
48     Pt = -10;
49     Energy = -10;
50     Eta = -10;
51     Phi = -10;
52    
53     GenCharge = -10;
54     GenPt = -10;
55     GenEnergy = -10;
56     GenEta = -10;
57     GenPhi = -10;
58     MatchDRGen = -10;
59    
60     MatchedGen = false;
61     MatchedGenFromB = false;
62     MatchedGenFromWZ = false;
63    
64 senka 1.3 //Data
65     //muon isolation info:
66     Et_ecal_tree=-2.;
67     Et_ecal_dr2_tree=-2.;
68     Et_ecal_dr3_tree=-2.;
69     Et_ecal_dr4_tree=-2.;
70     Et_ecal_dr7_tree=-2.;
71    
72     Et_hcal_tree=-2.;
73     Et_hcal_dr2_tree=-2.;
74     Et_hcal_dr3_tree=-2.;
75     Et_hcal_dr4_tree=-2.;
76     Et_hcal_dr7_tree=-2.;
77    
78     Et_ho_tree=-2.;
79     Et_ho_dr2_tree=-2.;
80     Et_ho_dr3_tree=-2.;
81     Et_ho_dr4_tree=-2.;
82     Et_ho_dr7_tree=-2.;
83    
84     Pt_tr_tree=-2.;
85     Pt_tr_dr2_tree=-2.;
86     Pt_tr_dr3_tree=-2.;
87     Pt_tr_dr4_tree=-2.;
88     Pt_tr_dr7_tree=-2.;
89    
90     N_tr_dr2_tree=-2;
91     N_tr_dr3_tree=-2;
92     N_tr_dr4_tree=-2;
93     N_tr_dr7_tree=-2;
94    
95     d0_tree=-200.;
96     d0_error_tree=-200.;
97     dz_tree=-200.;
98     dz_error_tree=-200.;
99    
100 vuko 1.1 }
101    
102    
103     void MuonProperties::CreateFlavourSpecificBranches(TTree * tree,std::string prefix, std::string suffix)
104     {
105    
106     // Create your branches
107    
108     // Examples:
109     /*
110     createFloatBranch(tree,"dca", prefix,suffix, &EoP);
111     createIntBranch(tree,"nhits", prefix,suffix, &nhits);
112     createBoolBranch(tree,"matched", prefix,suffix, &matched);
113     */
114 senka 1.3 createFloatBranch(tree,"Et_ecal_tree", prefix,suffix, &Et_ecal_tree);
115     createFloatBranch(tree,"Et_ecal_dr2_tree", prefix,suffix, &Et_ecal_dr2_tree);
116     createFloatBranch(tree,"Et_ecal_dr3_tree", prefix,suffix, &Et_ecal_dr3_tree);
117     createFloatBranch(tree,"Et_ecal_dr4_tree", prefix,suffix, &Et_ecal_dr4_tree);
118     createFloatBranch(tree,"Et_ecal_dr7_tree", prefix,suffix, &Et_ecal_dr7_tree);
119    
120     createFloatBranch(tree,"Et_hcal_tree", prefix,suffix, &Et_hcal_tree);
121     createFloatBranch(tree,"Et_hcal_dr2_tree", prefix,suffix, &Et_hcal_dr2_tree);
122     createFloatBranch(tree,"Et_hcal_dr3_tree", prefix,suffix, &Et_hcal_dr3_tree);
123     createFloatBranch(tree,"Et_hcal_dr4_tree", prefix,suffix, &Et_hcal_dr4_tree);
124     createFloatBranch(tree,"Et_hcal_dr7_tree", prefix,suffix, &Et_hcal_dr7_tree);
125    
126     createFloatBranch(tree,"Et_ho_tree", prefix,suffix, &Et_ho_tree);
127     createFloatBranch(tree,"Et_ho_dr2_tree", prefix,suffix, &Et_ho_dr2_tree);
128     createFloatBranch(tree,"Et_ho_dr3_tree", prefix,suffix, &Et_ho_dr3_tree);
129     createFloatBranch(tree,"Et_ho_dr4_tree", prefix,suffix, &Et_ho_dr4_tree);
130     createFloatBranch(tree,"Et_ho_dr7_tree", prefix,suffix, &Et_ho_dr7_tree);
131    
132     createFloatBranch(tree,"Pt_tr_tree", prefix,suffix, &Pt_tr_tree);
133     createFloatBranch(tree,"Pt_tr_dr2_tree", prefix,suffix, &Pt_tr_dr2_tree);
134     createFloatBranch(tree,"Pt_tr_dr3_tree", prefix,suffix, &Pt_tr_dr3_tree);
135     createFloatBranch(tree,"Pt_tr_dr4_tree", prefix,suffix, &Pt_tr_dr4_tree);
136     createFloatBranch(tree,"Pt_tr_dr7_tree", prefix,suffix, &Pt_tr_dr7_tree);
137    
138     createIntBranch(tree,"N_tr_dr2_tree", prefix,suffix, &N_tr_dr2_tree);
139     createIntBranch(tree,"N_tr_dr3_tree", prefix,suffix, &N_tr_dr3_tree);
140     createIntBranch(tree,"N_tr_dr4_tree", prefix,suffix, &N_tr_dr4_tree);
141     createIntBranch(tree,"N_tr_dr7_tree", prefix,suffix, &N_tr_dr7_tree);
142    
143     createFloatBranch(tree,"d0_tree", prefix,suffix, &d0_tree);
144     createFloatBranch(tree,"d0_error_tree", prefix,suffix, &d0_error_tree);
145     createFloatBranch(tree,"dz_tree", prefix,suffix, &dz_tree);
146     createFloatBranch(tree,"dz_error_tree", prefix,suffix, &dz_error_tree);
147    
148 vuko 1.1 }
149    
150     void MuonProperties::FillProperties(const reco::Candidate * lepton,
151 vuko 1.2 const edm::Event& iEvent,
152     const edm::EventSetup& iSetup)
153 vuko 1.1
154     {
155    
156     using namespace reco;
157    
158 senka 1.3 // ovdje ide racunanje deklariranih varijabli
159     // const PixelMatchGsfElectron * electron = dynamic_cast<const reco::PixelMatchGsfElectron *>(lepton);
160 vuko 1.1
161 senka 1.3 const reco::Muon * muon = dynamic_cast<const reco::Muon *>(lepton);
162 vuko 1.1
163 senka 1.3 if (muon == 0) {
164 vuko 1.1
165 senka 1.3 cout << "ElectronProperties::FillProperties: ,THIS IS NOT AN ELECTRON!!! \n";
166     return;
167     }
168    
169     Charge = muon->charge();
170     Pt = muon->pt();
171     Energy = muon->energy();
172     Eta = muon->eta();
173     Phi = muon->phi();
174    
175    
176     ///////////////////////////////////////////////////////////
177     //
178     // ISOLATION VARIABLES
179     //
180     //
181    
182     edm::Handle<reco::MuIsoDepositAssociationMap> ecalIso;
183     // iEvent.getByLabel(theECALIsoDepositLabel, ecalIso);
184     iEvent.getByLabel("muGlobalIsoDepositCalByAssociatorTowers","ecal", ecalIso);
185     // muGlobalIsoDepositCalByAssociatorTowers:ecal
186    
187     edm::Handle<reco::MuIsoDepositAssociationMap> hcalIso;
188     // iEvent.getByLabel(theHCALIsoDepositLabel, hcalIso);
189     iEvent.getByLabel("muGlobalIsoDepositCalByAssociatorTowers","hcal", hcalIso);
190     // muGlobalIsoDepositCalByAssociatorTowers:hcal
191    
192     edm::Handle<reco::MuIsoDepositAssociationMap> hocalIso;
193     // iEvent.getByLabel(theHOCALIsoDepositLabel, hocalIso);
194     iEvent.getByLabel("muGlobalIsoDepositCalByAssociatorTowers","ho", hocalIso);
195     // muGlobalIsoDepositCalByAssociatorTowers:ho
196    
197     edm::Handle<reco::MuIsoDepositAssociationMap> trackerIso;
198     // iEvent.getByLabel(theTrackerIsoDepositLabel, trackerIso);
199     iEvent.getByLabel("muGlobalIsoDepositCtfTk", trackerIso);
200     // muGlobalIsoDepositCtfTk
201    
202     const reco::MuIsoDeposit& depEcal = (*ecalIso)[muon->combinedMuon()];
203     const reco::MuIsoDeposit& depHcal = (*hcalIso)[muon->combinedMuon()];
204     const reco::MuIsoDeposit& depHOcal = (*hocalIso)[muon->combinedMuon()];
205     const reco::MuIsoDeposit& depTracker = (*trackerIso)[muon->combinedMuon()];
206    
207     Et_ecal_tree=depEcal.muonEnergy();
208     Et_ecal_dr2_tree=depEcal.depositWithin(0.2);
209     Et_ecal_dr3_tree=depEcal.depositWithin(0.3);
210     Et_ecal_dr4_tree=depEcal.depositWithin(0.4);
211     Et_ecal_dr7_tree=depEcal.depositWithin(0.7);
212    
213     Et_hcal_tree=depHcal.muonEnergy();
214     Et_hcal_dr2_tree=depHcal.depositWithin(0.2);
215     Et_hcal_dr3_tree=depHcal.depositWithin(0.3);
216     Et_hcal_dr4_tree=depHcal.depositWithin(0.4);
217     Et_hcal_dr7_tree=depHcal.depositWithin(0.7);
218    
219     Et_ho_tree=depHOcal.muonEnergy();
220     Et_ho_dr2_tree=depHOcal.depositWithin(0.2);
221     Et_ho_dr3_tree=depHOcal.depositWithin(0.3);
222     Et_ho_dr4_tree=depHOcal.depositWithin(0.4);
223     Et_ho_dr7_tree=depHOcal.depositWithin(0.7);
224    
225     Pt_tr_tree=depTracker.muonEnergy();
226     Pt_tr_dr2_tree=depTracker.depositAndCountWithin(0.2).first;
227     Pt_tr_dr3_tree=depTracker.depositAndCountWithin(0.3).first;
228     Pt_tr_dr4_tree=depTracker.depositAndCountWithin(0.4).first;
229     Pt_tr_dr7_tree=depTracker.depositAndCountWithin(0.7).first;
230    
231     N_tr_dr2_tree=depTracker.depositAndCountWithin(0.2).second;
232     N_tr_dr3_tree=depTracker.depositAndCountWithin(0.3).second;
233     N_tr_dr4_tree=depTracker.depositAndCountWithin(0.4).second;
234     N_tr_dr7_tree=depTracker.depositAndCountWithin(0.7).second;
235    
236     d0_tree=muon->combinedMuon()->d0();
237     d0_error_tree=muon->combinedMuon()->d0Error();
238     dz_tree=muon->combinedMuon()->dz();
239     dz_error_tree=muon->combinedMuon()->dzError();
240    
241 vuko 1.1
242     }