1 |
bendavid |
1.18 |
// $Id: FillerElectrons.cc,v 1.17 2008/10/22 08:55:40 peveraer Exp $
|
2 |
loizides |
1.1 |
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerElectrons.h"
|
4 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
6 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
7 |
|
|
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
|
8 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
9 |
sixie |
1.11 |
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
|
10 |
|
|
#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
|
11 |
|
|
#include "DataFormats/EgammaReco/interface/ClusterShape.h"
|
12 |
|
|
#include "DataFormats/EgammaReco/interface/BasicClusterShapeAssociation.h"
|
13 |
bendavid |
1.18 |
#include "DataFormats/Common/interface/RefToPtr.h"
|
14 |
sixie |
1.11 |
#include "RecoEgamma/EgammaIsolationAlgos/interface/ElectronTkIsolation.h"
|
15 |
|
|
#include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaEcalIsolation.h"
|
16 |
sixie |
1.14 |
#include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaTowerIsolation.h"
|
17 |
loizides |
1.1 |
#include "MitAna/DataTree/interface/Track.h"
|
18 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
19 |
sixie |
1.12 |
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
|
20 |
|
|
#include "AnalysisDataFormats/Egamma/interface/ElectronID.h"
|
21 |
|
|
#include "AnalysisDataFormats/Egamma/interface/ElectronIDAssociation.h"
|
22 |
loizides |
1.1 |
|
23 |
sixie |
1.13 |
#include "DataFormats/Common/interface/ValueMap.h"
|
24 |
|
|
|
25 |
loizides |
1.1 |
using namespace std;
|
26 |
|
|
using namespace edm;
|
27 |
|
|
using namespace mithep;
|
28 |
|
|
|
29 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
30 |
loizides |
1.10 |
FillerElectrons::FillerElectrons(const edm::ParameterSet &cfg, bool active) :
|
31 |
loizides |
1.8 |
BaseFiller(cfg,"Electrons",active),
|
32 |
loizides |
1.1 |
edmName_(Conf().getUntrackedParameter<string>("edmName","pixelMatchGsfElectrons")),
|
33 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkElectronBrn)),
|
34 |
loizides |
1.10 |
gsfTrackMapName_(Conf().getUntrackedParameter<string>("gsfTrackMapName","")),
|
35 |
|
|
trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
|
36 |
sixie |
1.12 |
barrelEcalRecHitName_(Conf().getUntrackedParameter<string>("barrelEcalRecHitName","")),
|
37 |
|
|
endcapEcalRecHitName_(Conf().getUntrackedParameter<string>("endcapEcalRecHitName","")),
|
38 |
|
|
barrelSuperClusterName_(Conf().getUntrackedParameter<string>("barrelSuperClusterName", "")),
|
39 |
|
|
endcapSuperClusterName_(Conf().getUntrackedParameter<string>("endcapSuperClusterName", "")),
|
40 |
|
|
barrelBasicClusterName_(Conf().getUntrackedParameter<string>("barrelBasicClusterName", "")),
|
41 |
|
|
endcapBasicClusterName_(Conf().getUntrackedParameter<string>("endcapBasicClusterName", "")),
|
42 |
|
|
barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
|
43 |
|
|
endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
|
44 |
loizides |
1.16 |
eIDCutBasedTightName_(Conf().getUntrackedParameter<string>("eIDCutBasedTightName","eidTight")),
|
45 |
sixie |
1.13 |
eIDCutBasedLooseName_(Conf().getUntrackedParameter<string>("eIDCutBasedLooseName","eidLoose")),
|
46 |
sixie |
1.12 |
eIDLikelihoodName_(Conf().getUntrackedParameter<string>("eIDLikelihood","eidLikelihood")),
|
47 |
|
|
eIDNeuralNetName_(Conf().getUntrackedParameter<string>("eIDNeuralNet","eidNeuralNet")),
|
48 |
loizides |
1.16 |
isoTrackColName_(Conf().getUntrackedParameter<string>
|
49 |
|
|
("IsolationTrackCollectionName","generalTracks")),
|
50 |
|
|
isoCaloTowerColName_(Conf().getUntrackedParameter<string>
|
51 |
|
|
("IsolationCaloTowerCollectionName","towerMaker")),
|
52 |
|
|
ecalJurassicIsoName_(Conf().getUntrackedParameter<string>
|
53 |
|
|
("EcalJurassicIsolationName","eleIsoFromDepsEcalFromHits")),
|
54 |
|
|
hcalJurassicIsoName_(Conf().getUntrackedParameter<string>
|
55 |
|
|
("HcalJurassicIsolationName","eleIsoFromDepsHcalFromHits")),
|
56 |
peveraer |
1.17 |
trackerIsoName_(Conf().getUntrackedParameter<string>
|
57 |
|
|
("TrackerIsolationName","eleIsoFromDepsTk")),
|
58 |
loizides |
1.8 |
electrons_(new mithep::ElectronArr(16)),
|
59 |
loizides |
1.10 |
gsfTrackMap_(0),
|
60 |
sixie |
1.11 |
trackerTrackMap_(0),
|
61 |
sixie |
1.12 |
barrelSuperClusterMap_(0),
|
62 |
|
|
endcapSuperClusterMap_(0)
|
63 |
loizides |
1.1 |
{
|
64 |
|
|
// Constructor.
|
65 |
|
|
}
|
66 |
|
|
|
67 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
68 |
loizides |
1.1 |
FillerElectrons::~FillerElectrons()
|
69 |
|
|
{
|
70 |
|
|
// Destructor.
|
71 |
loizides |
1.6 |
|
72 |
|
|
delete electrons_;
|
73 |
loizides |
1.1 |
}
|
74 |
|
|
|
75 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
76 |
loizides |
1.1 |
void FillerElectrons::BookDataBlock(TreeWriter &tws)
|
77 |
|
|
{
|
78 |
loizides |
1.10 |
// Add electron branch to our tree and get our maps.
|
79 |
loizides |
1.1 |
|
80 |
|
|
tws.AddBranch(mitName_.c_str(),&electrons_);
|
81 |
loizides |
1.10 |
|
82 |
|
|
if (!gsfTrackMapName_.empty())
|
83 |
bendavid |
1.18 |
gsfTrackMap_ = OS()->get<TrackMap>(gsfTrackMapName_.c_str());
|
84 |
loizides |
1.10 |
if (!trackerTrackMapName_.empty())
|
85 |
sixie |
1.11 |
trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_.c_str());
|
86 |
sixie |
1.12 |
if (!barrelSuperClusterMapName_.empty())
|
87 |
|
|
barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_.c_str());
|
88 |
|
|
if (!endcapSuperClusterMapName_.empty())
|
89 |
|
|
endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_.c_str());
|
90 |
loizides |
1.1 |
}
|
91 |
|
|
|
92 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
93 |
sixie |
1.11 |
void FillerElectrons::FillDataBlock(const edm::Event &event, const edm::EventSetup &setup)
|
94 |
loizides |
1.1 |
{
|
95 |
|
|
// Fill electrons from edm collection into our collection.
|
96 |
|
|
|
97 |
|
|
electrons_->Reset();
|
98 |
|
|
|
99 |
sixie |
1.11 |
Handle<reco::GsfElectronCollection> hElectronProduct;
|
100 |
loizides |
1.7 |
GetProduct(edmName_, hElectronProduct, event);
|
101 |
loizides |
1.1 |
|
102 |
sixie |
1.13 |
//Handles to get the electron ID information
|
103 |
|
|
Handle<edm::ValueMap<float> > eidLooseMap;
|
104 |
|
|
GetProduct(eIDCutBasedLooseName_, eidLooseMap, event);
|
105 |
|
|
Handle<edm::ValueMap<float> > eidTightMap;
|
106 |
|
|
GetProduct(eIDCutBasedTightName_, eidTightMap, event);
|
107 |
|
|
Handle<edm::ValueMap<float> > eidLikelihoodMap;
|
108 |
|
|
GetProduct(eIDLikelihoodName_, eidLikelihoodMap, event);
|
109 |
|
|
|
110 |
sixie |
1.11 |
const reco::GsfElectronCollection inElectrons = *(hElectronProduct.product());
|
111 |
|
|
//loop over electrons
|
112 |
sixie |
1.13 |
|
113 |
sixie |
1.11 |
for (reco::GsfElectronCollection::const_iterator iM = inElectrons.begin();
|
114 |
loizides |
1.1 |
iM != inElectrons.end(); ++iM) {
|
115 |
sixie |
1.13 |
|
116 |
|
|
//the index and Ref are needed for the eID association Map
|
117 |
|
|
unsigned int iElectron = iM - inElectrons.begin();
|
118 |
|
|
reco::GsfElectronRef eRef(hElectronProduct, iElectron);
|
119 |
|
|
|
120 |
loizides |
1.8 |
mithep::Electron *outElectron = electrons_->AddNew();
|
121 |
sixie |
1.12 |
|
122 |
sixie |
1.11 |
outElectron->SetESuperClusterOverP( iM->eSuperClusterOverP() ) ;
|
123 |
|
|
outElectron->SetESeedClusterOverPout( iM->eSeedClusterOverPout() ) ;
|
124 |
sixie |
1.13 |
outElectron->SetPIn( iM->trackMomentumAtVtx().R() ) ;
|
125 |
|
|
outElectron->SetPOut( iM->trackMomentumOut().R() );
|
126 |
sixie |
1.11 |
outElectron->SetDeltaEtaSuperClusterTrackAtVtx( iM->deltaEtaSuperClusterTrackAtVtx() ) ;
|
127 |
|
|
outElectron->SetDeltaEtaSeedClusterTrackAtCalo( iM->deltaEtaSeedClusterTrackAtCalo() ) ;
|
128 |
|
|
outElectron->SetDeltaPhiSuperClusterTrackAtVtx( iM->deltaPhiSuperClusterTrackAtVtx() ) ;
|
129 |
|
|
outElectron->SetDeltaPhiSeedClusterTrackAtCalo( iM->deltaPhiSeedClusterTrackAtCalo() ) ;
|
130 |
|
|
outElectron->SetHadronicOverEm( iM->hadronicOverEm() ) ;
|
131 |
|
|
outElectron->SetIsEnergyScaleCorrected( iM->isEnergyScaleCorrected() ) ;
|
132 |
|
|
outElectron->SetIsMomentumCorrected( iM->isMomentumCorrected() ) ;
|
133 |
|
|
outElectron->SetNumberOfClusters( iM->numberOfClusters() ) ;
|
134 |
|
|
outElectron->SetClassification( iM->classification() ) ;
|
135 |
|
|
|
136 |
loizides |
1.16 |
//shower shape variables
|
137 |
|
|
EcalClusterLazyTools lazyTools(event, setup, edm::InputTag(barrelEcalRecHitName_),
|
138 |
|
|
edm::InputTag(endcapEcalRecHitName_));
|
139 |
|
|
outElectron->SetE33(lazyTools.e3x3(*(iM->superCluster()->seed())));
|
140 |
|
|
outElectron->SetE55(lazyTools.e5x5(*(iM->superCluster()->seed())));
|
141 |
|
|
std::vector<float> vCov = lazyTools.covariances(*(iM->superCluster()->seed()));
|
142 |
sixie |
1.12 |
outElectron->SetCovEtaEta(vCov[0]);
|
143 |
|
|
outElectron->SetCovEtaPhi(vCov[1]);
|
144 |
|
|
outElectron->SetCovPhiPhi(vCov[2]);
|
145 |
|
|
|
146 |
loizides |
1.16 |
//compute isolations
|
147 |
|
|
//get the barrel BasicClusters
|
148 |
sixie |
1.12 |
edm::Handle<reco::BasicClusterCollection> barrelBasicClusterHandle;
|
149 |
|
|
GetProduct(barrelBasicClusterName_, barrelBasicClusterHandle, event);
|
150 |
sixie |
1.11 |
const reco::BasicClusterCollection* barrelBasicClusters = barrelBasicClusterHandle.product();
|
151 |
|
|
|
152 |
loizides |
1.16 |
//get the endcap BasicClusters
|
153 |
sixie |
1.11 |
edm::Handle<reco::BasicClusterCollection> endcapBasicClusterHandle;
|
154 |
sixie |
1.12 |
GetProduct(endcapBasicClusterName_, endcapBasicClusterHandle, event);
|
155 |
sixie |
1.11 |
const reco::BasicClusterCollection* endcapBasicClusters = endcapBasicClusterHandle.product();
|
156 |
|
|
|
157 |
loizides |
1.16 |
//get the barrel SuperClusters
|
158 |
sixie |
1.12 |
edm::Handle<reco::SuperClusterCollection> barrelSuperClusterHandle;
|
159 |
|
|
GetProduct(barrelSuperClusterName_, barrelSuperClusterHandle, event);
|
160 |
|
|
const reco::SuperClusterCollection* barrelSuperClusters = barrelSuperClusterHandle.product();
|
161 |
|
|
|
162 |
loizides |
1.16 |
//Get the endcap SuperClusters
|
163 |
sixie |
1.12 |
edm::Handle<reco::SuperClusterCollection> endcapSuperClusterHandle;
|
164 |
|
|
GetProduct(endcapSuperClusterName_, endcapSuperClusterHandle, event);
|
165 |
|
|
const reco::SuperClusterCollection* endcapSuperClusters = endcapSuperClusterHandle.product();
|
166 |
|
|
|
167 |
|
|
//find out whether this electron super cluster is in the barrel or endcap
|
168 |
|
|
bool isBarrel=false ;
|
169 |
|
|
if(barrelSuperClusterMap_->HasMit(iM->superCluster()))
|
170 |
|
|
isBarrel = true;
|
171 |
|
|
|
172 |
sixie |
1.11 |
//compute ECAL isolation
|
173 |
|
|
double extRadius = 0.3;
|
174 |
|
|
double etLow = 0.0;
|
175 |
loizides |
1.16 |
EgammaEcalIsolation *myEcalIsolation = 0;
|
176 |
sixie |
1.12 |
if (!isBarrel) {
|
177 |
|
|
myEcalIsolation =
|
178 |
|
|
new EgammaEcalIsolation(extRadius,etLow,endcapBasicClusters,endcapSuperClusters);
|
179 |
loizides |
1.16 |
} else {
|
180 |
|
|
myEcalIsolation =
|
181 |
|
|
new EgammaEcalIsolation(extRadius,etLow,barrelBasicClusters,barrelSuperClusters);
|
182 |
sixie |
1.12 |
}
|
183 |
loizides |
1.16 |
|
184 |
sixie |
1.12 |
double ecalIsoValue = myEcalIsolation->getEcalEtSum(&(*iM));
|
185 |
|
|
|
186 |
loizides |
1.16 |
//compute CaloTower isolation
|
187 |
sixie |
1.14 |
edm::Handle<CaloTowerCollection> caloTowers;
|
188 |
loizides |
1.16 |
GetProduct(isoCaloTowerColName_, caloTowers, event);
|
189 |
sixie |
1.14 |
extRadius = 0.3;
|
190 |
loizides |
1.16 |
etLow = 0.0;
|
191 |
sixie |
1.14 |
double intRadius = 0.02;
|
192 |
|
|
EgammaTowerIsolation *myTowerIsolation =
|
193 |
|
|
new EgammaTowerIsolation (extRadius, intRadius, etLow, caloTowers.product());
|
194 |
|
|
double towerIsoValue = myTowerIsolation->getTowerEtSum(&(*iM));
|
195 |
|
|
outElectron->SetCaloTowerIsolation( towerIsoValue );
|
196 |
peveraer |
1.17 |
|
197 |
loizides |
1.16 |
//fill the isolation values
|
198 |
sixie |
1.11 |
outElectron->SetCaloIsolation( ecalIsoValue ) ;
|
199 |
peveraer |
1.17 |
|
200 |
|
|
//get and fill Track isolation
|
201 |
|
|
Handle<edm::ValueMap<double> > eleIsoFromDepsTkValueMap;
|
202 |
|
|
GetProduct(trackerIsoName_, eleIsoFromDepsTkValueMap, event);
|
203 |
|
|
outElectron->SetTrackIsolation((*eleIsoFromDepsTkValueMap)[eRef]);
|
204 |
sixie |
1.11 |
|
205 |
loizides |
1.16 |
//get and fill Jurassic isolation values
|
206 |
sixie |
1.15 |
Handle<edm::ValueMap<double> > eleIsoFromDepsEcalFromHitsValueMap;
|
207 |
loizides |
1.16 |
GetProduct(ecalJurassicIsoName_, eleIsoFromDepsEcalFromHitsValueMap, event);
|
208 |
sixie |
1.15 |
Handle<edm::ValueMap<double> > eleIsoFromDepsHcalFromHitsValueMap;
|
209 |
loizides |
1.16 |
GetProduct(hcalJurassicIsoName_, eleIsoFromDepsHcalFromHitsValueMap, event);
|
210 |
sixie |
1.15 |
|
211 |
|
|
outElectron->SetEcalJurassicIsolation((*eleIsoFromDepsEcalFromHitsValueMap)[eRef]);
|
212 |
|
|
outElectron->SetHcalJurassicIsolation((*eleIsoFromDepsHcalFromHitsValueMap)[eRef]);
|
213 |
|
|
|
214 |
loizides |
1.16 |
//make proper links to Tracks and Super Clusters
|
215 |
loizides |
1.1 |
if (gsfTrackMap_ && iM->gsfTrack().isNonnull())
|
216 |
bendavid |
1.18 |
outElectron->SetGsfTrk(gsfTrackMap_->GetMit(refToPtr(iM->gsfTrack())));
|
217 |
loizides |
1.1 |
if (trackerTrackMap_ && iM->track().isNonnull())
|
218 |
bendavid |
1.18 |
outElectron->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->track())));
|
219 |
sixie |
1.12 |
if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && iM->superCluster().isNonnull())
|
220 |
|
|
if(isBarrel) {
|
221 |
|
|
outElectron->SetSuperCluster(barrelSuperClusterMap_->GetMit(iM->superCluster()));
|
222 |
|
|
} else {
|
223 |
|
|
outElectron->SetSuperCluster(endcapSuperClusterMap_->GetMit(iM->superCluster()));
|
224 |
|
|
}
|
225 |
sixie |
1.13 |
|
226 |
loizides |
1.16 |
//fill Electron ID information
|
227 |
sixie |
1.13 |
outElectron->SetPassLooseID((*eidLooseMap)[eRef]);
|
228 |
|
|
outElectron->SetPassTightID((*eidTightMap)[eRef]);
|
229 |
|
|
outElectron->SetIDLikelihood((*eidLikelihoodMap)[eRef]);
|
230 |
sixie |
1.12 |
}
|
231 |
loizides |
1.1 |
electrons_->Trim();
|
232 |
|
|
}
|