1 |
sixie |
1.12 |
// $Id: FillerElectrons.cc,v 1.11 2008/08/08 11:21:08 sixie 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 |
|
|
#include "RecoEgamma/EgammaIsolationAlgos/interface/ElectronTkIsolation.h"
|
14 |
|
|
#include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaEcalIsolation.h"
|
15 |
loizides |
1.1 |
#include "MitAna/DataTree/interface/Track.h"
|
16 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
17 |
sixie |
1.12 |
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
|
18 |
|
|
#include "AnalysisDataFormats/Egamma/interface/ElectronID.h"
|
19 |
|
|
#include "AnalysisDataFormats/Egamma/interface/ElectronIDAssociation.h"
|
20 |
loizides |
1.1 |
|
21 |
|
|
using namespace std;
|
22 |
|
|
using namespace edm;
|
23 |
|
|
using namespace mithep;
|
24 |
|
|
|
25 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
26 |
loizides |
1.10 |
FillerElectrons::FillerElectrons(const edm::ParameterSet &cfg, bool active) :
|
27 |
loizides |
1.8 |
BaseFiller(cfg,"Electrons",active),
|
28 |
loizides |
1.1 |
edmName_(Conf().getUntrackedParameter<string>("edmName","pixelMatchGsfElectrons")),
|
29 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkElectronBrn)),
|
30 |
loizides |
1.10 |
gsfTrackMapName_(Conf().getUntrackedParameter<string>("gsfTrackMapName","")),
|
31 |
|
|
trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
|
32 |
sixie |
1.12 |
barrelEcalRecHitName_(Conf().getUntrackedParameter<string>("barrelEcalRecHitName","")),
|
33 |
|
|
endcapEcalRecHitName_(Conf().getUntrackedParameter<string>("endcapEcalRecHitName","")),
|
34 |
|
|
barrelSuperClusterName_(Conf().getUntrackedParameter<string>("barrelSuperClusterName", "")),
|
35 |
|
|
endcapSuperClusterName_(Conf().getUntrackedParameter<string>("endcapSuperClusterName", "")),
|
36 |
|
|
barrelBasicClusterName_(Conf().getUntrackedParameter<string>("barrelBasicClusterName", "")),
|
37 |
|
|
endcapBasicClusterName_(Conf().getUntrackedParameter<string>("endcapBasicClusterName", "")),
|
38 |
|
|
barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
|
39 |
|
|
endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
|
40 |
|
|
eIDCutBasedName_(Conf().getUntrackedParameter<string>("eIDCutBasedName","eidCutBased")),
|
41 |
|
|
eIDCutBasedClassesName_(Conf().getUntrackedParameter<string>("eIDCutBasedClassesName",
|
42 |
|
|
"eidCutBasedClasses'")),
|
43 |
|
|
eIDLikelihoodName_(Conf().getUntrackedParameter<string>("eIDLikelihood","eidLikelihood")),
|
44 |
|
|
eIDNeuralNetName_(Conf().getUntrackedParameter<string>("eIDNeuralNet","eidNeuralNet")),
|
45 |
|
|
|
46 |
loizides |
1.8 |
electrons_(new mithep::ElectronArr(16)),
|
47 |
loizides |
1.10 |
gsfTrackMap_(0),
|
48 |
sixie |
1.11 |
trackerTrackMap_(0),
|
49 |
sixie |
1.12 |
barrelSuperClusterMap_(0),
|
50 |
|
|
endcapSuperClusterMap_(0)
|
51 |
loizides |
1.1 |
{
|
52 |
|
|
// Constructor.
|
53 |
|
|
}
|
54 |
|
|
|
55 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
56 |
loizides |
1.1 |
FillerElectrons::~FillerElectrons()
|
57 |
|
|
{
|
58 |
|
|
// Destructor.
|
59 |
loizides |
1.6 |
|
60 |
|
|
delete electrons_;
|
61 |
loizides |
1.1 |
}
|
62 |
|
|
|
63 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
64 |
loizides |
1.1 |
void FillerElectrons::BookDataBlock(TreeWriter &tws)
|
65 |
|
|
{
|
66 |
loizides |
1.10 |
// Add electron branch to our tree and get our maps.
|
67 |
loizides |
1.1 |
|
68 |
|
|
tws.AddBranch(mitName_.c_str(),&electrons_);
|
69 |
loizides |
1.10 |
|
70 |
|
|
if (!gsfTrackMapName_.empty())
|
71 |
|
|
gsfTrackMap_ = OS()->get<GsfTrackMap>(gsfTrackMapName_.c_str());
|
72 |
|
|
if (!trackerTrackMapName_.empty())
|
73 |
sixie |
1.11 |
trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_.c_str());
|
74 |
sixie |
1.12 |
if (!barrelSuperClusterMapName_.empty())
|
75 |
|
|
barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_.c_str());
|
76 |
|
|
if (!endcapSuperClusterMapName_.empty())
|
77 |
|
|
endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_.c_str());
|
78 |
loizides |
1.1 |
}
|
79 |
|
|
|
80 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
81 |
sixie |
1.11 |
void FillerElectrons::FillDataBlock(const edm::Event &event, const edm::EventSetup &setup)
|
82 |
loizides |
1.1 |
{
|
83 |
|
|
// Fill electrons from edm collection into our collection.
|
84 |
|
|
|
85 |
|
|
electrons_->Reset();
|
86 |
|
|
|
87 |
sixie |
1.11 |
Handle<reco::GsfElectronCollection> hElectronProduct;
|
88 |
loizides |
1.7 |
GetProduct(edmName_, hElectronProduct, event);
|
89 |
loizides |
1.1 |
|
90 |
sixie |
1.12 |
//Get Official Electron ID Results
|
91 |
|
|
//cout << "try electron ID \n";
|
92 |
|
|
Handle<reco::GsfElectronRefVector> hCutBasedElectronIDProduct;
|
93 |
|
|
GetProduct(eIDCutBasedName_ , hCutBasedElectronIDProduct, event);
|
94 |
|
|
Handle<reco::GsfElectronRefVector> hCutBasedClassesElectronIDProduct;
|
95 |
|
|
GetProduct(eIDCutBasedClassesName_ , hCutBasedClassesElectronIDProduct, event);
|
96 |
|
|
Handle<reco::GsfElectronRefVector> hLikelihoodElectronIDProduct;
|
97 |
|
|
GetProduct(eIDLikelihoodName_ , hLikelihoodElectronIDProduct, event);
|
98 |
|
|
Handle<reco::GsfElectronRefVector> hNeuralNetElectronIDProduct;
|
99 |
|
|
GetProduct(eIDNeuralNetName_ , hNeuralNetElectronIDProduct, event);
|
100 |
|
|
|
101 |
sixie |
1.11 |
const reco::GsfElectronCollection inElectrons = *(hElectronProduct.product());
|
102 |
|
|
//loop over electrons
|
103 |
sixie |
1.12 |
unsigned int i = 0;
|
104 |
sixie |
1.11 |
for (reco::GsfElectronCollection::const_iterator iM = inElectrons.begin();
|
105 |
loizides |
1.1 |
iM != inElectrons.end(); ++iM) {
|
106 |
loizides |
1.8 |
mithep::Electron *outElectron = electrons_->AddNew();
|
107 |
sixie |
1.12 |
|
108 |
sixie |
1.11 |
outElectron->SetESuperClusterOverP( iM->eSuperClusterOverP() ) ;
|
109 |
|
|
outElectron->SetESeedClusterOverPout( iM->eSeedClusterOverPout() ) ;
|
110 |
|
|
outElectron->SetDeltaEtaSuperClusterTrackAtVtx( iM->deltaEtaSuperClusterTrackAtVtx() ) ;
|
111 |
|
|
outElectron->SetDeltaEtaSeedClusterTrackAtCalo( iM->deltaEtaSeedClusterTrackAtCalo() ) ;
|
112 |
|
|
outElectron->SetDeltaPhiSuperClusterTrackAtVtx( iM->deltaPhiSuperClusterTrackAtVtx() ) ;
|
113 |
|
|
outElectron->SetDeltaPhiSeedClusterTrackAtCalo( iM->deltaPhiSeedClusterTrackAtCalo() ) ;
|
114 |
|
|
outElectron->SetHadronicOverEm( iM->hadronicOverEm() ) ;
|
115 |
|
|
outElectron->SetIsEnergyScaleCorrected( iM->isEnergyScaleCorrected() ) ;
|
116 |
|
|
outElectron->SetIsMomentumCorrected( iM->isMomentumCorrected() ) ;
|
117 |
|
|
outElectron->SetNumberOfClusters( iM->numberOfClusters() ) ;
|
118 |
|
|
outElectron->SetClassification( iM->classification() ) ;
|
119 |
|
|
|
120 |
|
|
//initialize
|
121 |
|
|
outElectron->SetE33( -999.0 ) ;
|
122 |
|
|
outElectron->SetE55( -999.0 ) ;
|
123 |
|
|
outElectron->SetCovEtaEta( -999.0 ) ;
|
124 |
|
|
outElectron->SetCovEtaPhi( -999.0 ) ;
|
125 |
sixie |
1.12 |
outElectron->SetCovPhiPhi( -999.0 ) ;
|
126 |
|
|
|
127 |
|
|
EcalClusterLazyTools lazyTools( event, setup, edm::InputTag(barrelEcalRecHitName_),
|
128 |
|
|
edm::InputTag(endcapEcalRecHitName_) );
|
129 |
|
|
|
130 |
|
|
//Shower shape variables
|
131 |
|
|
outElectron->SetE33 (lazyTools.e3x3( *(iM->superCluster()->seed()) ));
|
132 |
|
|
outElectron->SetE55 (lazyTools.e5x5( *(iM->superCluster()->seed()) ));
|
133 |
|
|
std::vector<float> vCov = lazyTools.covariances( *(iM->superCluster()->seed()) );
|
134 |
|
|
outElectron->SetCovEtaEta(vCov[0]);
|
135 |
|
|
outElectron->SetCovEtaPhi(vCov[1]);
|
136 |
|
|
outElectron->SetCovPhiPhi(vCov[2]);
|
137 |
|
|
|
138 |
sixie |
1.11 |
//Compute Isolations
|
139 |
|
|
//Get the barrel basicClusters
|
140 |
sixie |
1.12 |
edm::Handle<reco::BasicClusterCollection> barrelBasicClusterHandle;
|
141 |
|
|
GetProduct(barrelBasicClusterName_, barrelBasicClusterHandle, event);
|
142 |
sixie |
1.11 |
const reco::BasicClusterCollection* barrelBasicClusters = barrelBasicClusterHandle.product();
|
143 |
|
|
|
144 |
|
|
//Get the endcap basicClusters
|
145 |
|
|
edm::Handle<reco::BasicClusterCollection> endcapBasicClusterHandle;
|
146 |
sixie |
1.12 |
GetProduct(endcapBasicClusterName_, endcapBasicClusterHandle, event);
|
147 |
sixie |
1.11 |
const reco::BasicClusterCollection* endcapBasicClusters = endcapBasicClusterHandle.product();
|
148 |
|
|
|
149 |
sixie |
1.12 |
//Get the barrel superClusters
|
150 |
|
|
edm::Handle<reco::SuperClusterCollection> barrelSuperClusterHandle;
|
151 |
|
|
GetProduct(barrelSuperClusterName_, barrelSuperClusterHandle, event);
|
152 |
|
|
const reco::SuperClusterCollection* barrelSuperClusters = barrelSuperClusterHandle.product();
|
153 |
|
|
|
154 |
|
|
//Get the endcap superClusters
|
155 |
|
|
edm::Handle<reco::SuperClusterCollection> endcapSuperClusterHandle;
|
156 |
|
|
GetProduct(endcapSuperClusterName_, endcapSuperClusterHandle, event);
|
157 |
|
|
const reco::SuperClusterCollection* endcapSuperClusters = endcapSuperClusterHandle.product();
|
158 |
|
|
|
159 |
|
|
//find out whether this electron super cluster is in the barrel or endcap
|
160 |
|
|
bool isBarrel=false ;
|
161 |
|
|
if(barrelSuperClusterMap_->HasMit(iM->superCluster()))
|
162 |
|
|
//if (iM->superCluster()->eta() < 1.49) //If above method doesn't work, just use eta
|
163 |
|
|
isBarrel = true;
|
164 |
|
|
|
165 |
sixie |
1.11 |
//compute ECAL isolation
|
166 |
|
|
double extRadius = 0.3;
|
167 |
|
|
double etLow = 0.0;
|
168 |
sixie |
1.12 |
EgammaEcalIsolation *myEcalIsolation =
|
169 |
|
|
new EgammaEcalIsolation(extRadius,etLow,barrelBasicClusters,barrelSuperClusters);
|
170 |
sixie |
1.11 |
|
171 |
sixie |
1.12 |
if (!isBarrel) {
|
172 |
|
|
delete myEcalIsolation;
|
173 |
|
|
myEcalIsolation =
|
174 |
|
|
new EgammaEcalIsolation(extRadius,etLow,endcapBasicClusters,endcapSuperClusters);
|
175 |
|
|
}
|
176 |
|
|
double ecalIsoValue = myEcalIsolation->getEcalEtSum(&(*iM));
|
177 |
|
|
|
178 |
sixie |
1.11 |
//Compute Track Isolation
|
179 |
|
|
edm::Handle<reco::TrackCollection> tracks;
|
180 |
|
|
event.getByLabel("generalTracks",tracks);
|
181 |
|
|
const reco::TrackCollection* trackCollection = tracks.product();
|
182 |
|
|
extRadius = 0.2;
|
183 |
|
|
double intRadius = 0.02;
|
184 |
|
|
double maxVtxDist = 0.1;
|
185 |
|
|
double ptMin = 1.5;
|
186 |
|
|
ElectronTkIsolation myTkIsolation (extRadius,intRadius,ptMin,maxVtxDist,trackCollection) ;
|
187 |
|
|
double trackIsoValue = myTkIsolation.getPtTracks(&(*iM));
|
188 |
|
|
|
189 |
|
|
//Fill the isolation values
|
190 |
|
|
outElectron->SetCaloIsolation( ecalIsoValue ) ;
|
191 |
|
|
outElectron->SetTrackIsolation( trackIsoValue ) ;
|
192 |
|
|
|
193 |
|
|
//Make proper links to Tracks and Super Clusters
|
194 |
loizides |
1.1 |
if (gsfTrackMap_ && iM->gsfTrack().isNonnull())
|
195 |
loizides |
1.9 |
outElectron->SetGsfTrk(gsfTrackMap_->GetMit(iM->gsfTrack()));
|
196 |
loizides |
1.1 |
if (trackerTrackMap_ && iM->track().isNonnull())
|
197 |
loizides |
1.9 |
outElectron->SetTrackerTrk(trackerTrackMap_->GetMit(iM->track()));
|
198 |
sixie |
1.12 |
if (barrelSuperClusterMap_ && endcapSuperClusterMap_ && iM->superCluster().isNonnull())
|
199 |
|
|
if(isBarrel) {
|
200 |
|
|
outElectron->SetSuperCluster(barrelSuperClusterMap_->GetMit(iM->superCluster()));
|
201 |
|
|
} else {
|
202 |
|
|
outElectron->SetSuperCluster(endcapSuperClusterMap_->GetMit(iM->superCluster()));
|
203 |
|
|
}
|
204 |
|
|
|
205 |
|
|
}
|
206 |
loizides |
1.1 |
electrons_->Trim();
|
207 |
|
|
}
|