1 |
bendavid |
1.53 |
// $Id: FillerElectrons.cc,v 1.52 2011/03/13 22:16:08 bendavid Exp $
|
2 |
loizides |
1.1 |
|
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 |
sixie |
1.11 |
#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 |
bendavid |
1.18 |
#include "DataFormats/Common/interface/RefToPtr.h"
|
12 |
loizides |
1.35 |
#include "DataFormats/Common/interface/ValueMap.h"
|
13 |
|
|
#include "AnalysisDataFormats/Egamma/interface/ElectronID.h"
|
14 |
|
|
#include "AnalysisDataFormats/Egamma/interface/ElectronIDAssociation.h"
|
15 |
sixie |
1.11 |
#include "RecoEgamma/EgammaIsolationAlgos/interface/ElectronTkIsolation.h"
|
16 |
|
|
#include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaEcalIsolation.h"
|
17 |
sixie |
1.14 |
#include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaTowerIsolation.h"
|
18 |
loizides |
1.35 |
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
|
19 |
bendavid |
1.43 |
#include "DataFormats/VertexReco/interface/VertexFwd.h"
|
20 |
|
|
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
|
21 |
|
|
#include "TrackingTools/TransientTrack/plugins/TransientTrackBuilderESProducer.h"
|
22 |
bendavid |
1.44 |
#include "RecoVertex/GaussianSumVertexFit/interface/GsfVertexTrackCompatibilityEstimator.h"
|
23 |
bendavid |
1.43 |
#include "TrackingTools/IPTools/interface/IPTools.h"
|
24 |
|
|
#include "RecoEgamma/EgammaTools/interface/ConversionFinder.h"
|
25 |
|
|
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
|
26 |
|
|
#include "MagneticField/Engine/interface/MagneticField.h"
|
27 |
loizides |
1.35 |
#include "MitAna/DataTree/interface/ElectronCol.h"
|
28 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
29 |
|
|
#include "MitAna/DataTree/interface/Track.h"
|
30 |
loizides |
1.33 |
#include "MitEdm/DataFormats/interface/RefToBaseToPtr.h"
|
31 |
loizides |
1.35 |
#include "MitProd/ObjectService/interface/ObjectService.h"
|
32 |
bendavid |
1.45 |
#include "MitEdm/DataFormats/interface/DecayPart.h"
|
33 |
|
|
#include "MitEdm/ConversionRejection/interface/ConversionMatcher.h"
|
34 |
bendavid |
1.51 |
#include "RecoVertex/VertexTools/interface/LinearizedTrackStateFactory.h"
|
35 |
|
|
#include "RecoVertex/VertexTools/interface/VertexTrackFactory.h"
|
36 |
|
|
#include "RecoVertex/VertexPrimitives/interface/VertexTrack.h"
|
37 |
|
|
#include "RecoVertex/VertexPrimitives/interface/CachingVertex.h"
|
38 |
|
|
#include "RecoVertex/KalmanVertexFit/interface/KalmanVertexUpdator.h"
|
39 |
sixie |
1.13 |
|
40 |
loizides |
1.1 |
using namespace std;
|
41 |
|
|
using namespace edm;
|
42 |
|
|
using namespace mithep;
|
43 |
|
|
|
44 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
45 |
loizides |
1.28 |
FillerElectrons::FillerElectrons(const edm::ParameterSet &cfg, const char *name, bool active) :
|
46 |
|
|
BaseFiller(cfg,name,active),
|
47 |
loizides |
1.1 |
edmName_(Conf().getUntrackedParameter<string>("edmName","pixelMatchGsfElectrons")),
|
48 |
bendavid |
1.49 |
expectedHitsName_(Conf().getUntrackedParameter<string>("expectedHitsName","")),
|
49 |
loizides |
1.1 |
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkElectronBrn)),
|
50 |
loizides |
1.10 |
gsfTrackMapName_(Conf().getUntrackedParameter<string>("gsfTrackMapName","")),
|
51 |
|
|
trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
|
52 |
sixie |
1.12 |
barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
|
53 |
|
|
endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
|
54 |
bendavid |
1.36 |
pfSuperClusterMapName_(Conf().getUntrackedParameter<string>("pfSuperClusterMapName","")),
|
55 |
loizides |
1.16 |
eIDCutBasedTightName_(Conf().getUntrackedParameter<string>("eIDCutBasedTightName","eidTight")),
|
56 |
bendavid |
1.43 |
eIDCutBasedLooseName_(Conf().getUntrackedParameter<string>("eIDCutBasedLooseName","eidLoose")),
|
57 |
bendavid |
1.49 |
eIDLikelihoodName_(Conf().getUntrackedParameter<string>("eIDLikelihoodName","")),
|
58 |
bendavid |
1.43 |
pvEdmName_(Conf().getUntrackedParameter<string>("pvEdmName","offlinePrimaryVertices")),
|
59 |
bendavid |
1.52 |
pvBSEdmName_(Conf().getUntrackedParameter<string>("pvBSEdmName","offlinePrimaryVerticesWithBS")),
|
60 |
loizides |
1.8 |
electrons_(new mithep::ElectronArr(16)),
|
61 |
loizides |
1.10 |
gsfTrackMap_(0),
|
62 |
sixie |
1.11 |
trackerTrackMap_(0),
|
63 |
sixie |
1.12 |
barrelSuperClusterMap_(0),
|
64 |
|
|
endcapSuperClusterMap_(0)
|
65 |
loizides |
1.1 |
{
|
66 |
|
|
// Constructor.
|
67 |
|
|
}
|
68 |
|
|
|
69 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
70 |
loizides |
1.1 |
FillerElectrons::~FillerElectrons()
|
71 |
|
|
{
|
72 |
|
|
// Destructor.
|
73 |
loizides |
1.6 |
|
74 |
|
|
delete electrons_;
|
75 |
loizides |
1.1 |
}
|
76 |
|
|
|
77 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
78 |
bendavid |
1.42 |
void FillerElectrons::BookDataBlock(TreeWriter &tws)
|
79 |
loizides |
1.1 |
{
|
80 |
loizides |
1.10 |
// Add electron branch to our tree and get our maps.
|
81 |
loizides |
1.1 |
|
82 |
loizides |
1.29 |
tws.AddBranch(mitName_,&electrons_);
|
83 |
|
|
OS()->add<mithep::ElectronArr>(electrons_,mitName_);
|
84 |
loizides |
1.10 |
|
85 |
loizides |
1.29 |
if (!gsfTrackMapName_.empty()) {
|
86 |
|
|
gsfTrackMap_ = OS()->get<TrackMap>(gsfTrackMapName_);
|
87 |
|
|
if (gsfTrackMap_)
|
88 |
|
|
AddBranchDep(mitName_,gsfTrackMap_->GetBrName());
|
89 |
|
|
}
|
90 |
|
|
if (!trackerTrackMapName_.empty()) {
|
91 |
|
|
trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_);
|
92 |
|
|
if (trackerTrackMap_)
|
93 |
|
|
AddBranchDep(mitName_,trackerTrackMap_->GetBrName());
|
94 |
|
|
}
|
95 |
|
|
if (!barrelSuperClusterMapName_.empty()) {
|
96 |
|
|
barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_);
|
97 |
|
|
if (barrelSuperClusterMap_)
|
98 |
|
|
AddBranchDep(mitName_,barrelSuperClusterMap_->GetBrName());
|
99 |
|
|
}
|
100 |
|
|
if (!endcapSuperClusterMapName_.empty()) {
|
101 |
|
|
endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_);
|
102 |
|
|
if (endcapSuperClusterMap_)
|
103 |
|
|
AddBranchDep(mitName_,endcapSuperClusterMap_->GetBrName());
|
104 |
|
|
}
|
105 |
bendavid |
1.36 |
if (!pfSuperClusterMapName_.empty()) {
|
106 |
|
|
pfSuperClusterMap_ = OS()->get<SuperClusterMap>(pfSuperClusterMapName_);
|
107 |
|
|
if (pfSuperClusterMap_)
|
108 |
|
|
AddBranchDep(mitName_,pfSuperClusterMap_->GetBrName());
|
109 |
|
|
}
|
110 |
loizides |
1.1 |
}
|
111 |
|
|
|
112 |
loizides |
1.5 |
//--------------------------------------------------------------------------------------------------
|
113 |
loizides |
1.29 |
void FillerElectrons::FillDataBlock(const edm::Event &event, const edm::EventSetup &setup)
|
114 |
loizides |
1.1 |
{
|
115 |
|
|
// Fill electrons from edm collection into our collection.
|
116 |
|
|
|
117 |
bendavid |
1.26 |
electrons_->Delete();
|
118 |
loizides |
1.1 |
|
119 |
sixie |
1.11 |
Handle<reco::GsfElectronCollection> hElectronProduct;
|
120 |
loizides |
1.7 |
GetProduct(edmName_, hElectronProduct, event);
|
121 |
loizides |
1.1 |
|
122 |
loizides |
1.29 |
// handles to get the electron ID information
|
123 |
peveraer |
1.47 |
Handle<edm::ValueMap<float> > eidLooseMap;
|
124 |
|
|
GetProduct(eIDCutBasedLooseName_, eidLooseMap, event);
|
125 |
|
|
Handle<edm::ValueMap<float> > eidTightMap;
|
126 |
peveraer |
1.48 |
GetProduct(eIDCutBasedTightName_, eidTightMap, event);
|
127 |
bendavid |
1.49 |
edm::Handle<edm::ValueMap<float> > eidLikelihoodMap;
|
128 |
|
|
if (!eIDLikelihoodName_.empty()) {
|
129 |
|
|
GetProduct(eIDLikelihoodName_, eidLikelihoodMap, event);
|
130 |
|
|
}
|
131 |
|
|
|
132 |
bendavid |
1.43 |
edm::Handle<reco::VertexCollection> hVertex;
|
133 |
|
|
event.getByLabel(pvEdmName_, hVertex);
|
134 |
|
|
const reco::VertexCollection *pvCol = hVertex.product();
|
135 |
|
|
|
136 |
|
|
edm::Handle<reco::VertexCollection> hVertexBS;
|
137 |
|
|
event.getByLabel(pvBSEdmName_, hVertexBS);
|
138 |
|
|
const reco::VertexCollection *pvBSCol = hVertexBS.product();
|
139 |
|
|
|
140 |
|
|
edm::Handle<reco::TrackCollection> hGeneralTracks;
|
141 |
|
|
event.getByLabel("generalTracks", hGeneralTracks);
|
142 |
|
|
//const reco::VertexCollection *trackCol = hGeneralTracks.product();
|
143 |
bendavid |
1.45 |
|
144 |
|
|
edm::Handle<std::vector<mitedm::DecayPart> > hConversions;
|
145 |
|
|
event.getByLabel("mvfConversionRemoval", hConversions);
|
146 |
|
|
|
147 |
|
|
mitedm::ConversionMatcher convMatcher;
|
148 |
bendavid |
1.50 |
|
149 |
bendavid |
1.43 |
edm::ESHandle<TransientTrackBuilder> hTransientTrackBuilder;
|
150 |
|
|
setup.get<TransientTrackRecord>().get("TransientTrackBuilder",hTransientTrackBuilder);
|
151 |
|
|
const TransientTrackBuilder *transientTrackBuilder = hTransientTrackBuilder.product();
|
152 |
bendavid |
1.19 |
|
153 |
bendavid |
1.44 |
GsfVertexTrackCompatibilityEstimator gsfEstimator;
|
154 |
|
|
|
155 |
bendavid |
1.51 |
LinearizedTrackStateFactory lTrackFactory;
|
156 |
|
|
VertexTrackFactory<5> vTrackFactory;
|
157 |
|
|
KalmanVertexUpdator<5> updator;
|
158 |
|
|
|
159 |
bendavid |
1.43 |
//Get Magnetic Field from event setup, taking value at (0,0,0)
|
160 |
bendavid |
1.50 |
// edm::ESHandle<MagneticField> magneticField;
|
161 |
|
|
// setup.get<IdealMagneticFieldRecord>().get(magneticField);
|
162 |
|
|
// const double bfield = magneticField->inTesla(GlobalPoint(0.,0.,0.)).z();
|
163 |
bendavid |
1.43 |
|
164 |
sixie |
1.11 |
const reco::GsfElectronCollection inElectrons = *(hElectronProduct.product());
|
165 |
loizides |
1.29 |
// loop over electrons
|
166 |
sixie |
1.11 |
for (reco::GsfElectronCollection::const_iterator iM = inElectrons.begin();
|
167 |
loizides |
1.1 |
iM != inElectrons.end(); ++iM) {
|
168 |
sixie |
1.13 |
|
169 |
loizides |
1.29 |
// the index and Ref are needed for the eID association Map
|
170 |
sixie |
1.13 |
unsigned int iElectron = iM - inElectrons.begin();
|
171 |
|
|
reco::GsfElectronRef eRef(hElectronProduct, iElectron);
|
172 |
|
|
|
173 |
loizides |
1.8 |
mithep::Electron *outElectron = electrons_->AddNew();
|
174 |
bendavid |
1.31 |
|
175 |
|
|
outElectron->SetPtEtaPhi(iM->pt(),iM->eta(),iM->phi());
|
176 |
sixie |
1.12 |
|
177 |
bendavid |
1.40 |
outElectron->SetCharge(iM->charge());
|
178 |
|
|
outElectron->SetScPixCharge(iM->scPixCharge());
|
179 |
|
|
|
180 |
loizides |
1.30 |
outElectron->SetESuperClusterOverP(iM->eSuperClusterOverP());
|
181 |
|
|
outElectron->SetESeedClusterOverPout(iM->eSeedClusterOverPout());
|
182 |
|
|
outElectron->SetPIn(iM->trackMomentumAtVtx().R());
|
183 |
loizides |
1.29 |
outElectron->SetPOut(iM->trackMomentumOut().R());
|
184 |
loizides |
1.30 |
outElectron->SetDeltaEtaSuperClusterTrackAtVtx(iM->deltaEtaSuperClusterTrackAtVtx());
|
185 |
|
|
outElectron->SetDeltaEtaSeedClusterTrackAtCalo(iM->deltaEtaSeedClusterTrackAtCalo());
|
186 |
|
|
outElectron->SetDeltaPhiSuperClusterTrackAtVtx(iM->deltaPhiSuperClusterTrackAtVtx());
|
187 |
|
|
outElectron->SetDeltaPhiSeedClusterTrackAtCalo(iM->deltaPhiSeedClusterTrackAtCalo());
|
188 |
|
|
outElectron->SetIsEnergyScaleCorrected(iM->isEnergyScaleCorrected());
|
189 |
|
|
outElectron->SetIsMomentumCorrected(iM->isMomentumCorrected());
|
190 |
bendavid |
1.36 |
outElectron->SetNumberOfClusters(iM->basicClustersSize());
|
191 |
loizides |
1.30 |
outElectron->SetClassification(iM->classification());
|
192 |
bendavid |
1.37 |
outElectron->SetFBrem(iM->fbrem());
|
193 |
|
|
|
194 |
loizides |
1.38 |
// pflow electron stuff
|
195 |
bendavid |
1.41 |
outElectron->SetIsEcalDriven(iM->ecalDrivenSeed());
|
196 |
|
|
outElectron->SetIsTrackerDriven(iM->trackerDrivenSeed());
|
197 |
bendavid |
1.37 |
outElectron->SetMva(iM->mva());
|
198 |
|
|
|
199 |
loizides |
1.29 |
// shower shape variables
|
200 |
bendavid |
1.37 |
outElectron->SetE15(iM->e1x5());
|
201 |
|
|
outElectron->SetE25Max(iM->e2x5Max());
|
202 |
|
|
outElectron->SetE55(iM->e5x5());
|
203 |
|
|
outElectron->SetCovEtaEta(iM->sigmaEtaEta());
|
204 |
|
|
outElectron->SetCoviEtaiEta(iM->sigmaIetaIeta());
|
205 |
|
|
outElectron->SetHadronicOverEm(iM->hcalOverEcal());
|
206 |
|
|
outElectron->SetHcalDepth1OverEcal(iM->hcalDepth1OverEcal());
|
207 |
|
|
outElectron->SetHcalDepth2OverEcal(iM->hcalDepth2OverEcal());
|
208 |
sixie |
1.12 |
|
209 |
loizides |
1.38 |
// fill isolation variables for both cone sizes
|
210 |
bendavid |
1.37 |
outElectron->SetEcalRecHitIsoDr04(iM->dr04EcalRecHitSumEt());
|
211 |
|
|
outElectron->SetHcalDepth1TowerSumEtDr04(iM->dr04HcalDepth1TowerSumEt());
|
212 |
|
|
outElectron->SetHcalDepth2TowerSumEtDr04(iM->dr04HcalDepth2TowerSumEt());
|
213 |
|
|
outElectron->SetTrackIsolationDr04(iM->dr04TkSumPt());
|
214 |
|
|
outElectron->SetEcalRecHitIsoDr03(iM->dr03EcalRecHitSumEt());
|
215 |
|
|
outElectron->SetHcalTowerSumEtDr03(iM->dr03HcalTowerSumEt());
|
216 |
|
|
outElectron->SetHcalDepth1TowerSumEtDr03(iM->dr03HcalDepth1TowerSumEt());
|
217 |
|
|
outElectron->SetHcalDepth2TowerSumEtDr03(iM->dr03HcalDepth2TowerSumEt());
|
218 |
|
|
outElectron->SetTrackIsolationDr03(iM->dr03TkSumPt());
|
219 |
|
|
|
220 |
loizides |
1.38 |
// fiducial flags
|
221 |
bendavid |
1.37 |
outElectron->SetIsEB(iM->isEB());
|
222 |
|
|
outElectron->SetIsEE(iM->isEE());
|
223 |
|
|
outElectron->SetIsEBEEGap(iM->isEBEEGap());
|
224 |
|
|
outElectron->SetIsEBEtaGap(iM->isEBEtaGap());
|
225 |
|
|
outElectron->SetIsEBPhiGap(iM->isEBPhiGap());
|
226 |
|
|
outElectron->SetIsEEDeeGap(iM->isEEDeeGap());
|
227 |
|
|
outElectron->SetIsEERingGap(iM->isEERingGap());
|
228 |
sixie |
1.12 |
|
229 |
loizides |
1.38 |
// gsf-tracker match quality
|
230 |
bendavid |
1.37 |
outElectron->SetFracSharedHits(iM->shFracInnerHits());
|
231 |
sixie |
1.15 |
|
232 |
loizides |
1.29 |
// make proper links to Tracks and Super Clusters
|
233 |
bendavid |
1.49 |
if (gsfTrackMap_ && iM->gsfTrack().isNonnull()) {
|
234 |
bendavid |
1.18 |
outElectron->SetGsfTrk(gsfTrackMap_->GetMit(refToPtr(iM->gsfTrack())));
|
235 |
bendavid |
1.49 |
}
|
236 |
|
|
// make links to ambigous gsf tracks
|
237 |
|
|
if (gsfTrackMap_) {
|
238 |
|
|
for (reco::GsfTrackRefVector::const_iterator agsfi = iM->ambiguousGsfTracksBegin(); agsfi != iM->ambiguousGsfTracksEnd(); ++agsfi) {
|
239 |
|
|
outElectron->AddAmbiguousGsfTrack(gsfTrackMap_->GetMit(refToPtr(*agsfi)));
|
240 |
|
|
}
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
// make tracker track links,
|
244 |
bendavid |
1.37 |
if (trackerTrackMap_ && iM->closestCtfTrackRef().isNonnull()) {
|
245 |
bendavid |
1.36 |
outElectron->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->closestCtfTrackRef())));
|
246 |
bendavid |
1.19 |
}
|
247 |
loizides |
1.38 |
if (barrelSuperClusterMap_ && endcapSuperClusterMap_ &&
|
248 |
|
|
pfSuperClusterMap_ && iM->superCluster().isNonnull()) {
|
249 |
bendavid |
1.37 |
if(barrelSuperClusterMap_->HasMit(iM->superCluster())) {
|
250 |
sixie |
1.12 |
outElectron->SetSuperCluster(barrelSuperClusterMap_->GetMit(iM->superCluster()));
|
251 |
bendavid |
1.36 |
}
|
252 |
|
|
else if (endcapSuperClusterMap_->HasMit(iM->superCluster())) {
|
253 |
sixie |
1.12 |
outElectron->SetSuperCluster(endcapSuperClusterMap_->GetMit(iM->superCluster()));
|
254 |
|
|
}
|
255 |
bendavid |
1.36 |
else if (pfSuperClusterMap_->HasMit(iM->superCluster())) {
|
256 |
|
|
outElectron->SetSuperCluster(pfSuperClusterMap_->GetMit(iM->superCluster()));
|
257 |
|
|
}
|
258 |
|
|
else throw edm::Exception(edm::errors::Configuration, "FillerElectrons:FillDataBlock()\n")
|
259 |
|
|
<< "Error! SuperCluster reference in unmapped collection " << edmName_ << endl;
|
260 |
|
|
}
|
261 |
sixie |
1.13 |
|
262 |
bendavid |
1.43 |
//compute impact parameter with respect to PV
|
263 |
|
|
if (iM->gsfTrack().isNonnull()) {
|
264 |
|
|
const reco::TransientTrack &tt = transientTrackBuilder->build(iM->gsfTrack());
|
265 |
bendavid |
1.51 |
|
266 |
|
|
reco::TransientTrack ttckf;
|
267 |
|
|
|
268 |
bendavid |
1.52 |
reco::Vertex thevtx;// = pvCol->at(0);
|
269 |
|
|
reco::Vertex thevtxbs;// = pvBSCol->at(0);
|
270 |
|
|
|
271 |
|
|
double mindzvtx = 9999.;
|
272 |
|
|
for (uint ivtx = 0; ivtx<pvCol->size(); ++ivtx) {
|
273 |
|
|
reco::Vertex avtx = pvCol->at(ivtx);
|
274 |
|
|
double dzvtx = std::abs(iM->gsfTrack()->dz(avtx.position()));
|
275 |
|
|
if (dzvtx<mindzvtx) {
|
276 |
|
|
mindzvtx = dzvtx;
|
277 |
|
|
thevtx = avtx;
|
278 |
|
|
}
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
double mindzvtxbs = 9999.;
|
282 |
bendavid |
1.53 |
for (uint ivtxbs = 0; ivtxbs<pvBSCol->size(); ++ivtxbs) {
|
283 |
bendavid |
1.52 |
reco::Vertex avtxbs = pvBSCol->at(ivtxbs);
|
284 |
|
|
double dzvtxbs = std::abs(iM->gsfTrack()->dz(avtxbs.position()));
|
285 |
|
|
if (dzvtxbs<mindzvtxbs) {
|
286 |
|
|
mindzvtxbs = dzvtxbs;
|
287 |
|
|
thevtxbs = avtxbs;
|
288 |
|
|
}
|
289 |
|
|
}
|
290 |
|
|
|
291 |
bendavid |
1.51 |
|
292 |
|
|
//check if closest ctf track is included in PV and if so, remove it before computing impact parameters and uncertainties
|
293 |
|
|
if (iM->closestCtfTrackRef().isNonnull()) {
|
294 |
|
|
ttckf = transientTrackBuilder->build(iM->closestCtfTrackRef());
|
295 |
|
|
|
296 |
bendavid |
1.52 |
if (0) { //don't refit vertex for now
|
297 |
|
|
|
298 |
|
|
if (find(thevtx.tracks_begin(), thevtx.tracks_end(), ttckf.trackBaseRef()) != thevtx.tracks_end()) {
|
299 |
|
|
GlobalPoint linP(Basic3DVector<float> (thevtx.position()));
|
300 |
|
|
KalmanVertexUpdator<5>::RefCountedLinearizedTrackState linTrack = lTrackFactory.linearizedTrackState(linP, ttckf);
|
301 |
|
|
GlobalError err(thevtx.covariance());
|
302 |
|
|
VertexState vState(linP, err);
|
303 |
|
|
KalmanVertexUpdator<5>::RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
|
304 |
|
|
|
305 |
|
|
std::vector<KalmanVertexUpdator<5>::RefCountedVertexTrack> initialTracks(1, vertexTrack);
|
306 |
|
|
CachingVertex<5> cachingVertex(linP, err, initialTracks, thevtx.chi2());
|
307 |
|
|
const CachingVertex<5> &newCachingVertex = updator.remove(cachingVertex,vertexTrack);
|
308 |
|
|
|
309 |
|
|
if (newCachingVertex.isValid()) {
|
310 |
|
|
const TransientVertex &tvtx = newCachingVertex;
|
311 |
|
|
thevtx = tvtx;
|
312 |
|
|
}
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
if (find(thevtxbs.tracks_begin(), thevtxbs.tracks_end(), ttckf.trackBaseRef()) != thevtxbs.tracks_end()) {
|
316 |
|
|
GlobalPoint linP(Basic3DVector<float> (thevtxbs.position()));
|
317 |
|
|
KalmanVertexUpdator<5>::RefCountedLinearizedTrackState linTrack = lTrackFactory.linearizedTrackState(linP, ttckf);
|
318 |
|
|
GlobalError err(thevtxbs.covariance());
|
319 |
|
|
VertexState vState(linP, err);
|
320 |
|
|
KalmanVertexUpdator<5>::RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
|
321 |
|
|
|
322 |
|
|
std::vector<KalmanVertexUpdator<5>::RefCountedVertexTrack> initialTracks(1, vertexTrack);
|
323 |
|
|
CachingVertex<5> cachingVertex(linP, err, initialTracks, thevtxbs.chi2());
|
324 |
|
|
const CachingVertex<5> &newCachingVertex = updator.remove(cachingVertex,vertexTrack);
|
325 |
|
|
|
326 |
|
|
if (newCachingVertex.isValid()) {
|
327 |
|
|
const TransientVertex &tvtx = newCachingVertex;
|
328 |
|
|
thevtxbs = tvtx;
|
329 |
|
|
}
|
330 |
|
|
}
|
331 |
bendavid |
1.51 |
}
|
332 |
|
|
|
333 |
|
|
}
|
334 |
bendavid |
1.43 |
|
335 |
bendavid |
1.51 |
//preserve sign of transverse impact parameter (cross-product definition from track, not lifetime-signing)
|
336 |
|
|
const double gsfsign = ( (-iM->gsfTrack()->dxy(thevtx.position())) >=0 ) ? 1. : -1.;
|
337 |
|
|
const double gsfsignbs = ( (-iM->gsfTrack()->dxy(thevtxbs.position())) >=0 ) ? 1. : -1.;
|
338 |
|
|
|
339 |
|
|
const std::pair<bool,Measurement1D> &d0pv = IPTools::absoluteTransverseImpactParameter(tt,thevtx);
|
340 |
bendavid |
1.43 |
if (d0pv.first) {
|
341 |
bendavid |
1.51 |
outElectron->SetD0PV(gsfsign*d0pv.second.value());
|
342 |
bendavid |
1.43 |
outElectron->SetD0PVErr(d0pv.second.error());
|
343 |
|
|
}
|
344 |
bendavid |
1.44 |
else {
|
345 |
bendavid |
1.51 |
outElectron->SetD0PV(-999.0);
|
346 |
bendavid |
1.44 |
}
|
347 |
|
|
|
348 |
bendavid |
1.43 |
|
349 |
bendavid |
1.51 |
const std::pair<bool,Measurement1D> &ip3dpv = IPTools::absoluteImpactParameter3D(tt,thevtx);
|
350 |
bendavid |
1.43 |
if (ip3dpv.first) {
|
351 |
bendavid |
1.51 |
outElectron->SetIp3dPV(gsfsign*ip3dpv.second.value());
|
352 |
bendavid |
1.43 |
outElectron->SetIp3dPVErr(ip3dpv.second.error());
|
353 |
|
|
}
|
354 |
bendavid |
1.44 |
else {
|
355 |
bendavid |
1.51 |
outElectron->SetIp3dPV(-999.0);
|
356 |
bendavid |
1.44 |
}
|
357 |
bendavid |
1.43 |
|
358 |
bendavid |
1.51 |
const std::pair<bool,Measurement1D> &d0pvbs = IPTools::absoluteTransverseImpactParameter(tt,thevtxbs);
|
359 |
bendavid |
1.43 |
if (d0pvbs.first) {
|
360 |
bendavid |
1.51 |
outElectron->SetD0PVBS(gsfsignbs*d0pvbs.second.value());
|
361 |
bendavid |
1.43 |
outElectron->SetD0PVBSErr(d0pvbs.second.error());
|
362 |
|
|
}
|
363 |
bendavid |
1.44 |
else {
|
364 |
bendavid |
1.51 |
outElectron->SetD0PVBS(-999.0);
|
365 |
bendavid |
1.44 |
}
|
366 |
bendavid |
1.43 |
|
367 |
bendavid |
1.51 |
const std::pair<bool,Measurement1D> &ip3dpvbs = IPTools::absoluteImpactParameter3D(tt,thevtxbs);
|
368 |
bendavid |
1.43 |
if (ip3dpvbs.first) {
|
369 |
bendavid |
1.51 |
outElectron->SetIp3dPVBS(gsfsignbs*ip3dpvbs.second.value());
|
370 |
bendavid |
1.43 |
outElectron->SetIp3dPVBSErr(ip3dpvbs.second.error());
|
371 |
|
|
}
|
372 |
bendavid |
1.44 |
else {
|
373 |
bendavid |
1.51 |
outElectron->SetIp3dPVBS(-999.0);
|
374 |
bendavid |
1.44 |
}
|
375 |
|
|
|
376 |
bendavid |
1.51 |
if (iM->closestCtfTrackRef().isNonnull()) {
|
377 |
|
|
|
378 |
|
|
const double ckfsign = ( (-iM->closestCtfTrackRef()->dxy(thevtx.position())) >=0 ) ? 1. : -1.;
|
379 |
|
|
const double ckfsignbs = ( (-iM->closestCtfTrackRef()->dxy(thevtxbs.position())) >=0 ) ? 1. : -1.;
|
380 |
|
|
|
381 |
|
|
const std::pair<bool,Measurement1D> &d0pvckf = IPTools::absoluteTransverseImpactParameter(ttckf,thevtx);
|
382 |
|
|
if (d0pvckf.first) {
|
383 |
|
|
outElectron->SetD0PVCkf(ckfsign*d0pvckf.second.value());
|
384 |
|
|
outElectron->SetD0PVCkfErr(d0pvckf.second.error());
|
385 |
|
|
}
|
386 |
|
|
else {
|
387 |
|
|
outElectron->SetD0PVCkf(-999.0);
|
388 |
|
|
}
|
389 |
|
|
|
390 |
|
|
|
391 |
|
|
const std::pair<bool,Measurement1D> &ip3dpvckf = IPTools::absoluteImpactParameter3D(ttckf,thevtx);
|
392 |
|
|
if (ip3dpvckf.first) {
|
393 |
|
|
outElectron->SetIp3dPVCkf(ckfsign*ip3dpvckf.second.value());
|
394 |
|
|
outElectron->SetIp3dPVCkfErr(ip3dpvckf.second.error());
|
395 |
|
|
}
|
396 |
|
|
else {
|
397 |
|
|
outElectron->SetIp3dPVCkf(-999.0);
|
398 |
|
|
}
|
399 |
|
|
|
400 |
|
|
const std::pair<bool,Measurement1D> &d0pvbsckf = IPTools::absoluteTransverseImpactParameter(ttckf,thevtxbs);
|
401 |
|
|
if (d0pvbsckf.first) {
|
402 |
|
|
outElectron->SetD0PVBSCkf(ckfsignbs*d0pvbsckf.second.value());
|
403 |
|
|
outElectron->SetD0PVBSCkfErr(d0pvbsckf.second.error());
|
404 |
|
|
}
|
405 |
|
|
else {
|
406 |
|
|
outElectron->SetD0PVBSCkf(-999.0);
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
const std::pair<bool,Measurement1D> &ip3dpvbsckf = IPTools::absoluteImpactParameter3D(ttckf,thevtxbs);
|
410 |
|
|
if (ip3dpvbsckf.first) {
|
411 |
|
|
outElectron->SetIp3dPVBSCkf(ckfsignbs*ip3dpvbsckf.second.value());
|
412 |
|
|
outElectron->SetIp3dPVBSCkfErr(ip3dpvbsckf.second.error());
|
413 |
|
|
}
|
414 |
|
|
else {
|
415 |
|
|
outElectron->SetIp3dPVBSCkf(-999.0);
|
416 |
|
|
}
|
417 |
|
|
}
|
418 |
|
|
else {
|
419 |
|
|
outElectron->SetD0PVCkf(-999.0);
|
420 |
|
|
outElectron->SetIp3dPVCkf(-999.0);
|
421 |
|
|
outElectron->SetD0PVBSCkf(-999.0);
|
422 |
|
|
outElectron->SetIp3dPVBSCkf(-999.0);
|
423 |
|
|
}
|
424 |
|
|
|
425 |
|
|
|
426 |
bendavid |
1.43 |
if (verbose_>1) {
|
427 |
|
|
printf("gsf track pt = %5f\n",iM->gsfTrack()->pt());
|
428 |
|
|
printf("gsf track mode pt = %5f\n",iM->gsfTrack()->ptMode());
|
429 |
|
|
printf("ttrack pt = %5f\n",tt.initialFreeState().momentum().perp());
|
430 |
|
|
//printf("ttrackgsf pt = %5f\n",ttgsf.innermostMeasurementState().globalMomentum().perp());
|
431 |
bendavid |
1.44 |
printf("ip3dpv reduced chisquared = %5f, probability = %5f\n", ip3dpv.second.value()/ip3dpv.second.error(), TMath::Prob(ip3dpv.second.value()/ip3dpv.second.error(),1));
|
432 |
|
|
//printf("gsf reduced chisquared = %5f, probability = %5f\n", pvGsfCompat.second/2, TMath::Prob(pvGsfCompat.second,2));
|
433 |
bendavid |
1.43 |
}
|
434 |
|
|
|
435 |
|
|
}
|
436 |
|
|
|
437 |
bendavid |
1.53 |
|
438 |
bendavid |
1.43 |
//fill conversion partner track info
|
439 |
bendavid |
1.50 |
outElectron->SetConvPartnerDCotTheta(iM->convDcot());
|
440 |
|
|
outElectron->SetConvPartnerDist(iM->convDist());
|
441 |
|
|
outElectron->SetConvPartnerRadius(iM->convRadius());
|
442 |
|
|
reco::TrackBaseRef convTrackRef = iM->convPartner();
|
443 |
|
|
if (convTrackRef.isNonnull()) {
|
444 |
|
|
if ( dynamic_cast<const reco::GsfTrack*>(convTrackRef.get()) && gsfTrackMap_ ) {
|
445 |
|
|
outElectron->SetConvPartnerTrk(gsfTrackMap_->GetMit(mitedm::refToBaseToPtr(convTrackRef)));
|
446 |
|
|
}
|
447 |
|
|
else if (trackerTrackMap_) {
|
448 |
|
|
outElectron->SetConvPartnerTrk(trackerTrackMap_->GetMit(mitedm::refToBaseToPtr(convTrackRef)));
|
449 |
|
|
}
|
450 |
bendavid |
1.45 |
}
|
451 |
bendavid |
1.43 |
|
452 |
bendavid |
1.50 |
|
453 |
|
|
|
454 |
loizides |
1.29 |
// fill Electron ID information
|
455 |
peveraer |
1.47 |
outElectron->SetPassLooseID((*eidLooseMap)[eRef]);
|
456 |
|
|
outElectron->SetPassTightID((*eidTightMap)[eRef]);
|
457 |
bendavid |
1.49 |
if (!eIDLikelihoodName_.empty()) {
|
458 |
|
|
outElectron->SetIDLikelihood((*eidLikelihoodMap)[eRef]);
|
459 |
|
|
}
|
460 |
|
|
|
461 |
|
|
// fill corrected expected inner hits
|
462 |
bendavid |
1.50 |
if(iM->gsfTrack().isNonnull()) {
|
463 |
|
|
outElectron->SetCorrectedNExpectedHitsInner(iM->gsfTrack()->trackerExpectedHitsInner().numberOfHits());
|
464 |
bendavid |
1.49 |
}
|
465 |
bendavid |
1.31 |
|
466 |
bendavid |
1.45 |
//fill additional conversion flag
|
467 |
|
|
outElectron->SetMatchesVertexConversion(convMatcher.matchesGoodConversion(*iM,hConversions));
|
468 |
|
|
|
469 |
bendavid |
1.31 |
if (verbose_>1) {
|
470 |
|
|
double recomass = sqrt(iM->energy()*iM->energy() - iM->p()*iM->p());
|
471 |
loizides |
1.32 |
printf(" mithep::Electron, pt=%5f, eta=%5f, phi=%5f, energy=%5f, p=%5f, mass=%5f\n",
|
472 |
|
|
outElectron->Pt(), outElectron->Eta(), outElectron->Phi(),
|
473 |
|
|
outElectron->E(), outElectron->P(), outElectron->Mass());
|
474 |
|
|
printf("reco::GsfElectron , pt=%5f, eta=%5f, phi=%5f, energy=%5f, p=%5f, mass=%5f\n",
|
475 |
|
|
iM->pt(), iM->eta(), iM->phi(), iM->energy(), iM->p(), recomass);
|
476 |
bendavid |
1.31 |
}
|
477 |
sixie |
1.12 |
}
|
478 |
loizides |
1.1 |
electrons_->Trim();
|
479 |
|
|
}
|