ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerElectrons.cc
Revision: 1.40
Committed: Mon Nov 2 22:54:56 2009 UTC (15 years, 6 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012
Changes since 1.39: +4 -1 lines
Log Message:
Fill additional charge info in 33x

File Contents

# Content
1 // $Id: FillerElectrons.cc,v 1.39 2009/09/25 08:42:50 loizides Exp $
2
3 #include "MitProd/TreeFiller/interface/FillerElectrons.h"
4 #include "DataFormats/TrackReco/interface/Track.h"
5 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
6 #include "DataFormats/TrackReco/interface/TrackFwd.h"
7 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
8 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
9 #include "DataFormats/EgammaReco/interface/ClusterShape.h"
10 #include "DataFormats/EgammaReco/interface/BasicClusterShapeAssociation.h"
11 #include "DataFormats/Common/interface/RefToPtr.h"
12 #include "DataFormats/Common/interface/ValueMap.h"
13 #include "AnalysisDataFormats/Egamma/interface/ElectronID.h"
14 #include "AnalysisDataFormats/Egamma/interface/ElectronIDAssociation.h"
15 #include "RecoEgamma/EgammaIsolationAlgos/interface/ElectronTkIsolation.h"
16 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaEcalIsolation.h"
17 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaTowerIsolation.h"
18 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
19 #include "MitAna/DataTree/interface/ElectronCol.h"
20 #include "MitAna/DataTree/interface/Names.h"
21 #include "MitAna/DataTree/interface/Track.h"
22 #include "MitEdm/DataFormats/interface/RefToBaseToPtr.h"
23 #include "MitProd/ObjectService/interface/ObjectService.h"
24
25 using namespace std;
26 using namespace edm;
27 using namespace mithep;
28
29 //--------------------------------------------------------------------------------------------------
30 FillerElectrons::FillerElectrons(const edm::ParameterSet &cfg, const char *name, bool active) :
31 BaseFiller(cfg,name,active),
32 edmName_(Conf().getUntrackedParameter<string>("edmName","pixelMatchGsfElectrons")),
33 mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkElectronBrn)),
34 gsfTrackMapName_(Conf().getUntrackedParameter<string>("gsfTrackMapName","")),
35 trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
36 barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
37 endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
38 pfSuperClusterMapName_(Conf().getUntrackedParameter<string>("pfSuperClusterMapName","")),
39 eIDCutBasedTightName_(Conf().getUntrackedParameter<string>("eIDCutBasedTightName","eidTight")),
40 eIDCutBasedLooseName_(Conf().getUntrackedParameter<string>("eIDCutBasedLooseName","eidLoose")),
41 electrons_(new mithep::ElectronArr(16)),
42 gsfTrackMap_(0),
43 trackerTrackMap_(0),
44 barrelSuperClusterMap_(0),
45 endcapSuperClusterMap_(0)
46 {
47 // Constructor.
48 }
49
50 //--------------------------------------------------------------------------------------------------
51 FillerElectrons::~FillerElectrons()
52 {
53 // Destructor.
54
55 delete electrons_;
56 }
57
58 //--------------------------------------------------------------------------------------------------
59 void FillerElectrons::BookDataBlock(TreeWriter &tws, const edm::EventSetup &es)
60 {
61 // Add electron branch to our tree and get our maps.
62
63 tws.AddBranch(mitName_,&electrons_);
64 OS()->add<mithep::ElectronArr>(electrons_,mitName_);
65
66 if (!gsfTrackMapName_.empty()) {
67 gsfTrackMap_ = OS()->get<TrackMap>(gsfTrackMapName_);
68 if (gsfTrackMap_)
69 AddBranchDep(mitName_,gsfTrackMap_->GetBrName());
70 }
71 if (!trackerTrackMapName_.empty()) {
72 trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_);
73 if (trackerTrackMap_)
74 AddBranchDep(mitName_,trackerTrackMap_->GetBrName());
75 }
76 if (!barrelSuperClusterMapName_.empty()) {
77 barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_);
78 if (barrelSuperClusterMap_)
79 AddBranchDep(mitName_,barrelSuperClusterMap_->GetBrName());
80 }
81 if (!endcapSuperClusterMapName_.empty()) {
82 endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_);
83 if (endcapSuperClusterMap_)
84 AddBranchDep(mitName_,endcapSuperClusterMap_->GetBrName());
85 }
86 if (!pfSuperClusterMapName_.empty()) {
87 pfSuperClusterMap_ = OS()->get<SuperClusterMap>(pfSuperClusterMapName_);
88 if (pfSuperClusterMap_)
89 AddBranchDep(mitName_,pfSuperClusterMap_->GetBrName());
90 }
91 }
92
93 //--------------------------------------------------------------------------------------------------
94 void FillerElectrons::FillDataBlock(const edm::Event &event, const edm::EventSetup &setup)
95 {
96 // Fill electrons from edm collection into our collection.
97
98 electrons_->Delete();
99
100 Handle<reco::GsfElectronCollection> hElectronProduct;
101 GetProduct(edmName_, hElectronProduct, event);
102
103 // handles to get the electron ID information
104 Handle<edm::ValueMap<float> > eidLooseMap;
105 GetProduct(eIDCutBasedLooseName_, eidLooseMap, event);
106 Handle<edm::ValueMap<float> > eidTightMap;
107 GetProduct(eIDCutBasedTightName_, eidTightMap, event);
108
109 const reco::GsfElectronCollection inElectrons = *(hElectronProduct.product());
110 // loop over electrons
111 for (reco::GsfElectronCollection::const_iterator iM = inElectrons.begin();
112 iM != inElectrons.end(); ++iM) {
113
114 // the index and Ref are needed for the eID association Map
115 unsigned int iElectron = iM - inElectrons.begin();
116 reco::GsfElectronRef eRef(hElectronProduct, iElectron);
117
118 mithep::Electron *outElectron = electrons_->AddNew();
119
120 outElectron->SetPtEtaPhi(iM->pt(),iM->eta(),iM->phi());
121
122 outElectron->SetCharge(iM->charge());
123 outElectron->SetScPixCharge(iM->scPixCharge());
124
125 outElectron->SetESuperClusterOverP(iM->eSuperClusterOverP());
126 outElectron->SetESeedClusterOverPout(iM->eSeedClusterOverPout());
127 outElectron->SetPIn(iM->trackMomentumAtVtx().R());
128 outElectron->SetPOut(iM->trackMomentumOut().R());
129 outElectron->SetDeltaEtaSuperClusterTrackAtVtx(iM->deltaEtaSuperClusterTrackAtVtx());
130 outElectron->SetDeltaEtaSeedClusterTrackAtCalo(iM->deltaEtaSeedClusterTrackAtCalo());
131 outElectron->SetDeltaPhiSuperClusterTrackAtVtx(iM->deltaPhiSuperClusterTrackAtVtx());
132 outElectron->SetDeltaPhiSeedClusterTrackAtCalo(iM->deltaPhiSeedClusterTrackAtCalo());
133 outElectron->SetIsEnergyScaleCorrected(iM->isEnergyScaleCorrected());
134 outElectron->SetIsMomentumCorrected(iM->isMomentumCorrected());
135 outElectron->SetNumberOfClusters(iM->basicClustersSize());
136 outElectron->SetClassification(iM->classification());
137 outElectron->SetFBrem(iM->fbrem());
138
139 // pflow electron stuff
140 outElectron->SetIsEcalDriven(iM->isEcalDriven());
141 outElectron->SetIsTrackerDriven(iM->isTrackerDriven());
142 outElectron->SetMva(iM->mva());
143
144 // shower shape variables
145 outElectron->SetE15(iM->e1x5());
146 outElectron->SetE25Max(iM->e2x5Max());
147 outElectron->SetE55(iM->e5x5());
148 outElectron->SetCovEtaEta(iM->sigmaEtaEta());
149 outElectron->SetCoviEtaiEta(iM->sigmaIetaIeta());
150 outElectron->SetHadronicOverEm(iM->hcalOverEcal());
151 outElectron->SetHcalDepth1OverEcal(iM->hcalDepth1OverEcal());
152 outElectron->SetHcalDepth2OverEcal(iM->hcalDepth2OverEcal());
153
154 // fill isolation variables for both cone sizes
155 outElectron->SetEcalRecHitIsoDr04(iM->dr04EcalRecHitSumEt());
156 outElectron->SetHcalDepth1TowerSumEtDr04(iM->dr04HcalDepth1TowerSumEt());
157 outElectron->SetHcalDepth2TowerSumEtDr04(iM->dr04HcalDepth2TowerSumEt());
158 outElectron->SetTrackIsolationDr04(iM->dr04TkSumPt());
159 outElectron->SetEcalRecHitIsoDr03(iM->dr03EcalRecHitSumEt());
160 outElectron->SetHcalTowerSumEtDr03(iM->dr03HcalTowerSumEt());
161 outElectron->SetHcalDepth1TowerSumEtDr03(iM->dr03HcalDepth1TowerSumEt());
162 outElectron->SetHcalDepth2TowerSumEtDr03(iM->dr03HcalDepth2TowerSumEt());
163 outElectron->SetTrackIsolationDr03(iM->dr03TkSumPt());
164
165 // fiducial flags
166 outElectron->SetIsEB(iM->isEB());
167 outElectron->SetIsEE(iM->isEE());
168 outElectron->SetIsEBEEGap(iM->isEBEEGap());
169 outElectron->SetIsEBEtaGap(iM->isEBEtaGap());
170 outElectron->SetIsEBPhiGap(iM->isEBPhiGap());
171 outElectron->SetIsEEDeeGap(iM->isEEDeeGap());
172 outElectron->SetIsEERingGap(iM->isEERingGap());
173
174 // gsf-tracker match quality
175 outElectron->SetFracSharedHits(iM->shFracInnerHits());
176
177 // make proper links to Tracks and Super Clusters
178 if (gsfTrackMap_ && iM->gsfTrack().isNonnull())
179 outElectron->SetGsfTrk(gsfTrackMap_->GetMit(refToPtr(iM->gsfTrack())));
180 // make tracker track links, relinking from gsf track associations if configured and
181 // link is otherwise absent
182 if (trackerTrackMap_ && iM->closestCtfTrackRef().isNonnull()) {
183 outElectron->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->closestCtfTrackRef())));
184 }
185 if (barrelSuperClusterMap_ && endcapSuperClusterMap_ &&
186 pfSuperClusterMap_ && iM->superCluster().isNonnull()) {
187 if(barrelSuperClusterMap_->HasMit(iM->superCluster())) {
188 outElectron->SetSuperCluster(barrelSuperClusterMap_->GetMit(iM->superCluster()));
189 }
190 else if (endcapSuperClusterMap_->HasMit(iM->superCluster())) {
191 outElectron->SetSuperCluster(endcapSuperClusterMap_->GetMit(iM->superCluster()));
192 }
193 else if (pfSuperClusterMap_->HasMit(iM->superCluster())) {
194 outElectron->SetSuperCluster(pfSuperClusterMap_->GetMit(iM->superCluster()));
195 }
196 else throw edm::Exception(edm::errors::Configuration, "FillerElectrons:FillDataBlock()\n")
197 << "Error! SuperCluster reference in unmapped collection " << edmName_ << endl;
198 }
199
200 // fill Electron ID information
201 outElectron->SetPassLooseID((*eidLooseMap)[eRef]);
202 outElectron->SetPassTightID((*eidTightMap)[eRef]);
203
204 if (verbose_>1) {
205 double recomass = sqrt(iM->energy()*iM->energy() - iM->p()*iM->p());
206 printf(" mithep::Electron, pt=%5f, eta=%5f, phi=%5f, energy=%5f, p=%5f, mass=%5f\n",
207 outElectron->Pt(), outElectron->Eta(), outElectron->Phi(),
208 outElectron->E(), outElectron->P(), outElectron->Mass());
209 printf("reco::GsfElectron , pt=%5f, eta=%5f, phi=%5f, energy=%5f, p=%5f, mass=%5f\n",
210 iM->pt(), iM->eta(), iM->phi(), iM->energy(), iM->p(), recomass);
211 }
212 }
213 electrons_->Trim();
214 }