1 |
// $Id: FillerElectrons.cc,v 1.37 2009/07/07 08:32:26 bendavid 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)
|
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->SetESuperClusterOverP(iM->eSuperClusterOverP());
|
123 |
outElectron->SetESeedClusterOverPout(iM->eSeedClusterOverPout());
|
124 |
outElectron->SetPIn(iM->trackMomentumAtVtx().R());
|
125 |
outElectron->SetPOut(iM->trackMomentumOut().R());
|
126 |
outElectron->SetDeltaEtaSuperClusterTrackAtVtx(iM->deltaEtaSuperClusterTrackAtVtx());
|
127 |
outElectron->SetDeltaEtaSeedClusterTrackAtCalo(iM->deltaEtaSeedClusterTrackAtCalo());
|
128 |
outElectron->SetDeltaPhiSuperClusterTrackAtVtx(iM->deltaPhiSuperClusterTrackAtVtx());
|
129 |
outElectron->SetDeltaPhiSeedClusterTrackAtCalo(iM->deltaPhiSeedClusterTrackAtCalo());
|
130 |
outElectron->SetIsEnergyScaleCorrected(iM->isEnergyScaleCorrected());
|
131 |
outElectron->SetIsMomentumCorrected(iM->isMomentumCorrected());
|
132 |
outElectron->SetNumberOfClusters(iM->basicClustersSize());
|
133 |
outElectron->SetClassification(iM->classification());
|
134 |
outElectron->SetFBrem(iM->fbrem());
|
135 |
|
136 |
// pflow electron stuff
|
137 |
outElectron->SetIsEcalDriven(iM->isEcalDriven());
|
138 |
outElectron->SetIsTrackerDriven(iM->isTrackerDriven());
|
139 |
outElectron->SetMva(iM->mva());
|
140 |
|
141 |
// shower shape variables
|
142 |
outElectron->SetE15(iM->e1x5());
|
143 |
outElectron->SetE25Max(iM->e2x5Max());
|
144 |
outElectron->SetE55(iM->e5x5());
|
145 |
outElectron->SetCovEtaEta(iM->sigmaEtaEta());
|
146 |
outElectron->SetCoviEtaiEta(iM->sigmaIetaIeta());
|
147 |
outElectron->SetHadronicOverEm(iM->hcalOverEcal());
|
148 |
outElectron->SetHcalDepth1OverEcal(iM->hcalDepth1OverEcal());
|
149 |
outElectron->SetHcalDepth2OverEcal(iM->hcalDepth2OverEcal());
|
150 |
|
151 |
// fill isolation variables for both cone sizes
|
152 |
outElectron->SetEcalRecHitIsoDr04(iM->dr04EcalRecHitSumEt());
|
153 |
outElectron->SetHcalDepth1TowerSumEtDr04(iM->dr04HcalDepth1TowerSumEt());
|
154 |
outElectron->SetHcalDepth2TowerSumEtDr04(iM->dr04HcalDepth2TowerSumEt());
|
155 |
outElectron->SetTrackIsolationDr04(iM->dr04TkSumPt());
|
156 |
outElectron->SetEcalRecHitIsoDr03(iM->dr03EcalRecHitSumEt());
|
157 |
outElectron->SetHcalTowerSumEtDr03(iM->dr03HcalTowerSumEt());
|
158 |
outElectron->SetHcalDepth1TowerSumEtDr03(iM->dr03HcalDepth1TowerSumEt());
|
159 |
outElectron->SetHcalDepth2TowerSumEtDr03(iM->dr03HcalDepth2TowerSumEt());
|
160 |
outElectron->SetTrackIsolationDr03(iM->dr03TkSumPt());
|
161 |
|
162 |
// fiducial flags
|
163 |
outElectron->SetIsEB(iM->isEB());
|
164 |
outElectron->SetIsEE(iM->isEE());
|
165 |
outElectron->SetIsEBEEGap(iM->isEBEEGap());
|
166 |
outElectron->SetIsEBEtaGap(iM->isEBEtaGap());
|
167 |
outElectron->SetIsEBPhiGap(iM->isEBPhiGap());
|
168 |
outElectron->SetIsEEDeeGap(iM->isEEDeeGap());
|
169 |
outElectron->SetIsEERingGap(iM->isEERingGap());
|
170 |
|
171 |
// gsf-tracker match quality
|
172 |
outElectron->SetFracSharedHits(iM->shFracInnerHits());
|
173 |
|
174 |
// make proper links to Tracks and Super Clusters
|
175 |
if (gsfTrackMap_ && iM->gsfTrack().isNonnull())
|
176 |
outElectron->SetGsfTrk(gsfTrackMap_->GetMit(refToPtr(iM->gsfTrack())));
|
177 |
// make tracker track links, relinking from gsf track associations if configured and
|
178 |
// link is otherwise absent
|
179 |
if (trackerTrackMap_ && iM->closestCtfTrackRef().isNonnull()) {
|
180 |
outElectron->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->closestCtfTrackRef())));
|
181 |
}
|
182 |
if (barrelSuperClusterMap_ && endcapSuperClusterMap_ &&
|
183 |
pfSuperClusterMap_ && iM->superCluster().isNonnull()) {
|
184 |
if(barrelSuperClusterMap_->HasMit(iM->superCluster())) {
|
185 |
outElectron->SetSuperCluster(barrelSuperClusterMap_->GetMit(iM->superCluster()));
|
186 |
}
|
187 |
else if (endcapSuperClusterMap_->HasMit(iM->superCluster())) {
|
188 |
outElectron->SetSuperCluster(endcapSuperClusterMap_->GetMit(iM->superCluster()));
|
189 |
}
|
190 |
else if (pfSuperClusterMap_->HasMit(iM->superCluster())) {
|
191 |
outElectron->SetSuperCluster(pfSuperClusterMap_->GetMit(iM->superCluster()));
|
192 |
}
|
193 |
else throw edm::Exception(edm::errors::Configuration, "FillerElectrons:FillDataBlock()\n")
|
194 |
<< "Error! SuperCluster reference in unmapped collection " << edmName_ << endl;
|
195 |
}
|
196 |
|
197 |
// fill Electron ID information
|
198 |
outElectron->SetPassLooseID((*eidLooseMap)[eRef]);
|
199 |
outElectron->SetPassTightID((*eidTightMap)[eRef]);
|
200 |
|
201 |
if (verbose_>1) {
|
202 |
double recomass = sqrt(iM->energy()*iM->energy() - iM->p()*iM->p());
|
203 |
printf(" mithep::Electron, pt=%5f, eta=%5f, phi=%5f, energy=%5f, p=%5f, mass=%5f\n",
|
204 |
outElectron->Pt(), outElectron->Eta(), outElectron->Phi(),
|
205 |
outElectron->E(), outElectron->P(), outElectron->Mass());
|
206 |
printf("reco::GsfElectron , pt=%5f, eta=%5f, phi=%5f, energy=%5f, p=%5f, mass=%5f\n",
|
207 |
iM->pt(), iM->eta(), iM->phi(), iM->energy(), iM->p(), recomass);
|
208 |
}
|
209 |
}
|
210 |
electrons_->Trim();
|
211 |
}
|