ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerElectrons.cc
Revision: 1.58
Committed: Fri May 20 16:52:37 2011 UTC (13 years, 11 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_021
Changes since 1.57: +93 -71 lines
Log Message:
Add muon kink and electron,muon unbiased ip variables

File Contents

# User Rev Content
1 bendavid 1.58 // $Id: FillerElectrons.cc,v 1.57 2011/05/20 16:19:31 ksung 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 ksung 1.57 #include "MitEdm/Tools/interface/VertexReProducer.h"
40 sixie 1.13
41 loizides 1.1 using namespace std;
42     using namespace edm;
43     using namespace mithep;
44    
45 loizides 1.5 //--------------------------------------------------------------------------------------------------
46 loizides 1.28 FillerElectrons::FillerElectrons(const edm::ParameterSet &cfg, const char *name, bool active) :
47     BaseFiller(cfg,name,active),
48 loizides 1.1 edmName_(Conf().getUntrackedParameter<string>("edmName","pixelMatchGsfElectrons")),
49 bendavid 1.49 expectedHitsName_(Conf().getUntrackedParameter<string>("expectedHitsName","")),
50 loizides 1.1 mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkElectronBrn)),
51 loizides 1.10 gsfTrackMapName_(Conf().getUntrackedParameter<string>("gsfTrackMapName","")),
52     trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
53 sixie 1.12 barrelSuperClusterMapName_(Conf().getUntrackedParameter<string>("barrelSuperClusterMapName","")),
54     endcapSuperClusterMapName_(Conf().getUntrackedParameter<string>("endcapSuperClusterMapName","")),
55 bendavid 1.36 pfSuperClusterMapName_(Conf().getUntrackedParameter<string>("pfSuperClusterMapName","")),
56 loizides 1.16 eIDCutBasedTightName_(Conf().getUntrackedParameter<string>("eIDCutBasedTightName","eidTight")),
57 bendavid 1.43 eIDCutBasedLooseName_(Conf().getUntrackedParameter<string>("eIDCutBasedLooseName","eidLoose")),
58 bendavid 1.49 eIDLikelihoodName_(Conf().getUntrackedParameter<string>("eIDLikelihoodName","")),
59 bendavid 1.43 pvEdmName_(Conf().getUntrackedParameter<string>("pvEdmName","offlinePrimaryVertices")),
60 bendavid 1.52 pvBSEdmName_(Conf().getUntrackedParameter<string>("pvBSEdmName","offlinePrimaryVerticesWithBS")),
61 bendavid 1.54 recomputeConversionInfo_(Conf().getUntrackedParameter<bool>("recomputeConversionInfo",false)),
62 loizides 1.8 electrons_(new mithep::ElectronArr(16)),
63 loizides 1.10 gsfTrackMap_(0),
64 sixie 1.11 trackerTrackMap_(0),
65 sixie 1.12 barrelSuperClusterMap_(0),
66     endcapSuperClusterMap_(0)
67 loizides 1.1 {
68     // Constructor.
69     }
70    
71 loizides 1.5 //--------------------------------------------------------------------------------------------------
72 loizides 1.1 FillerElectrons::~FillerElectrons()
73     {
74     // Destructor.
75 loizides 1.6
76     delete electrons_;
77 loizides 1.1 }
78    
79 loizides 1.5 //--------------------------------------------------------------------------------------------------
80 bendavid 1.42 void FillerElectrons::BookDataBlock(TreeWriter &tws)
81 loizides 1.1 {
82 loizides 1.10 // Add electron branch to our tree and get our maps.
83 loizides 1.1
84 loizides 1.29 tws.AddBranch(mitName_,&electrons_);
85     OS()->add<mithep::ElectronArr>(electrons_,mitName_);
86 loizides 1.10
87 loizides 1.29 if (!gsfTrackMapName_.empty()) {
88     gsfTrackMap_ = OS()->get<TrackMap>(gsfTrackMapName_);
89     if (gsfTrackMap_)
90     AddBranchDep(mitName_,gsfTrackMap_->GetBrName());
91     }
92     if (!trackerTrackMapName_.empty()) {
93     trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_);
94     if (trackerTrackMap_)
95     AddBranchDep(mitName_,trackerTrackMap_->GetBrName());
96     }
97     if (!barrelSuperClusterMapName_.empty()) {
98     barrelSuperClusterMap_ = OS()->get<SuperClusterMap>(barrelSuperClusterMapName_);
99     if (barrelSuperClusterMap_)
100     AddBranchDep(mitName_,barrelSuperClusterMap_->GetBrName());
101     }
102     if (!endcapSuperClusterMapName_.empty()) {
103     endcapSuperClusterMap_ = OS()->get<SuperClusterMap>(endcapSuperClusterMapName_);
104     if (endcapSuperClusterMap_)
105     AddBranchDep(mitName_,endcapSuperClusterMap_->GetBrName());
106     }
107 bendavid 1.36 if (!pfSuperClusterMapName_.empty()) {
108     pfSuperClusterMap_ = OS()->get<SuperClusterMap>(pfSuperClusterMapName_);
109     if (pfSuperClusterMap_)
110     AddBranchDep(mitName_,pfSuperClusterMap_->GetBrName());
111     }
112 loizides 1.1 }
113    
114 loizides 1.5 //--------------------------------------------------------------------------------------------------
115 loizides 1.29 void FillerElectrons::FillDataBlock(const edm::Event &event, const edm::EventSetup &setup)
116 loizides 1.1 {
117     // Fill electrons from edm collection into our collection.
118    
119 bendavid 1.26 electrons_->Delete();
120 loizides 1.1
121 sixie 1.11 Handle<reco::GsfElectronCollection> hElectronProduct;
122 loizides 1.7 GetProduct(edmName_, hElectronProduct, event);
123 loizides 1.1
124 loizides 1.29 // handles to get the electron ID information
125 peveraer 1.47 Handle<edm::ValueMap<float> > eidLooseMap;
126     GetProduct(eIDCutBasedLooseName_, eidLooseMap, event);
127     Handle<edm::ValueMap<float> > eidTightMap;
128 peveraer 1.48 GetProduct(eIDCutBasedTightName_, eidTightMap, event);
129 bendavid 1.49 edm::Handle<edm::ValueMap<float> > eidLikelihoodMap;
130     if (!eIDLikelihoodName_.empty()) {
131     GetProduct(eIDLikelihoodName_, eidLikelihoodMap, event);
132     }
133    
134 bendavid 1.43 edm::Handle<reco::VertexCollection> hVertex;
135     event.getByLabel(pvEdmName_, hVertex);
136     const reco::VertexCollection *pvCol = hVertex.product();
137 bendavid 1.54
138 bendavid 1.43 edm::Handle<reco::VertexCollection> hVertexBS;
139     event.getByLabel(pvBSEdmName_, hVertexBS);
140     const reco::VertexCollection *pvBSCol = hVertexBS.product();
141    
142     edm::Handle<reco::TrackCollection> hGeneralTracks;
143     event.getByLabel("generalTracks", hGeneralTracks);
144     //const reco::VertexCollection *trackCol = hGeneralTracks.product();
145 bendavid 1.45
146 bendavid 1.54 edm::Handle<reco::GsfTrackCollection> hGsfTracks;
147     event.getByLabel("electronGsfTracks", hGsfTracks);
148    
149 bendavid 1.45 edm::Handle<std::vector<mitedm::DecayPart> > hConversions;
150     event.getByLabel("mvfConversionRemoval", hConversions);
151    
152     mitedm::ConversionMatcher convMatcher;
153 bendavid 1.50
154 bendavid 1.43 edm::ESHandle<TransientTrackBuilder> hTransientTrackBuilder;
155     setup.get<TransientTrackRecord>().get("TransientTrackBuilder",hTransientTrackBuilder);
156     const TransientTrackBuilder *transientTrackBuilder = hTransientTrackBuilder.product();
157 bendavid 1.19
158 bendavid 1.44 GsfVertexTrackCompatibilityEstimator gsfEstimator;
159    
160 bendavid 1.51 LinearizedTrackStateFactory lTrackFactory;
161     VertexTrackFactory<5> vTrackFactory;
162     KalmanVertexUpdator<5> updator;
163    
164 bendavid 1.43 //Get Magnetic Field from event setup, taking value at (0,0,0)
165 bendavid 1.54 edm::ESHandle<MagneticField> magneticField;
166     setup.get<IdealMagneticFieldRecord>().get(magneticField);
167     const double bfield = magneticField->inTesla(GlobalPoint(0.,0.,0.)).z();
168 bendavid 1.43
169 sixie 1.11 const reco::GsfElectronCollection inElectrons = *(hElectronProduct.product());
170 loizides 1.29 // loop over electrons
171 sixie 1.11 for (reco::GsfElectronCollection::const_iterator iM = inElectrons.begin();
172 loizides 1.1 iM != inElectrons.end(); ++iM) {
173 sixie 1.13
174 loizides 1.29 // the index and Ref are needed for the eID association Map
175 sixie 1.13 unsigned int iElectron = iM - inElectrons.begin();
176     reco::GsfElectronRef eRef(hElectronProduct, iElectron);
177    
178 loizides 1.8 mithep::Electron *outElectron = electrons_->AddNew();
179 bendavid 1.31
180     outElectron->SetPtEtaPhi(iM->pt(),iM->eta(),iM->phi());
181 sixie 1.12
182 bendavid 1.40 outElectron->SetCharge(iM->charge());
183     outElectron->SetScPixCharge(iM->scPixCharge());
184    
185 loizides 1.30 outElectron->SetESuperClusterOverP(iM->eSuperClusterOverP());
186     outElectron->SetESeedClusterOverPout(iM->eSeedClusterOverPout());
187     outElectron->SetPIn(iM->trackMomentumAtVtx().R());
188 loizides 1.29 outElectron->SetPOut(iM->trackMomentumOut().R());
189 loizides 1.30 outElectron->SetDeltaEtaSuperClusterTrackAtVtx(iM->deltaEtaSuperClusterTrackAtVtx());
190     outElectron->SetDeltaEtaSeedClusterTrackAtCalo(iM->deltaEtaSeedClusterTrackAtCalo());
191     outElectron->SetDeltaPhiSuperClusterTrackAtVtx(iM->deltaPhiSuperClusterTrackAtVtx());
192     outElectron->SetDeltaPhiSeedClusterTrackAtCalo(iM->deltaPhiSeedClusterTrackAtCalo());
193     outElectron->SetIsEnergyScaleCorrected(iM->isEnergyScaleCorrected());
194 bendavid 1.55 //outElectron->SetIsMomentumCorrected(iM->isMomentumCorrected());
195 bendavid 1.36 outElectron->SetNumberOfClusters(iM->basicClustersSize());
196 loizides 1.30 outElectron->SetClassification(iM->classification());
197 bendavid 1.37 outElectron->SetFBrem(iM->fbrem());
198    
199 loizides 1.38 // pflow electron stuff
200 bendavid 1.41 outElectron->SetIsEcalDriven(iM->ecalDrivenSeed());
201     outElectron->SetIsTrackerDriven(iM->trackerDrivenSeed());
202 bendavid 1.37 outElectron->SetMva(iM->mva());
203    
204 loizides 1.29 // shower shape variables
205 bendavid 1.37 outElectron->SetE15(iM->e1x5());
206     outElectron->SetE25Max(iM->e2x5Max());
207     outElectron->SetE55(iM->e5x5());
208     outElectron->SetCovEtaEta(iM->sigmaEtaEta());
209     outElectron->SetCoviEtaiEta(iM->sigmaIetaIeta());
210     outElectron->SetHadronicOverEm(iM->hcalOverEcal());
211     outElectron->SetHcalDepth1OverEcal(iM->hcalDepth1OverEcal());
212     outElectron->SetHcalDepth2OverEcal(iM->hcalDepth2OverEcal());
213 sixie 1.12
214 loizides 1.38 // fill isolation variables for both cone sizes
215 bendavid 1.37 outElectron->SetEcalRecHitIsoDr04(iM->dr04EcalRecHitSumEt());
216     outElectron->SetHcalDepth1TowerSumEtDr04(iM->dr04HcalDepth1TowerSumEt());
217     outElectron->SetHcalDepth2TowerSumEtDr04(iM->dr04HcalDepth2TowerSumEt());
218     outElectron->SetTrackIsolationDr04(iM->dr04TkSumPt());
219     outElectron->SetEcalRecHitIsoDr03(iM->dr03EcalRecHitSumEt());
220     outElectron->SetHcalTowerSumEtDr03(iM->dr03HcalTowerSumEt());
221     outElectron->SetHcalDepth1TowerSumEtDr03(iM->dr03HcalDepth1TowerSumEt());
222     outElectron->SetHcalDepth2TowerSumEtDr03(iM->dr03HcalDepth2TowerSumEt());
223     outElectron->SetTrackIsolationDr03(iM->dr03TkSumPt());
224    
225 bendavid 1.56 //pflow isolation
226     outElectron->SetPFChargedHadronIso(iM->pfIsolationVariables().chargedHadronIso);
227     outElectron->SetPFChargedHadronIso(iM->pfIsolationVariables().neutralHadronIso);
228     outElectron->SetPFChargedHadronIso(iM->pfIsolationVariables().photonIso);
229    
230 loizides 1.38 // fiducial flags
231 bendavid 1.37 outElectron->SetIsEB(iM->isEB());
232     outElectron->SetIsEE(iM->isEE());
233     outElectron->SetIsEBEEGap(iM->isEBEEGap());
234     outElectron->SetIsEBEtaGap(iM->isEBEtaGap());
235     outElectron->SetIsEBPhiGap(iM->isEBPhiGap());
236     outElectron->SetIsEEDeeGap(iM->isEEDeeGap());
237     outElectron->SetIsEERingGap(iM->isEERingGap());
238 sixie 1.12
239 loizides 1.38 // gsf-tracker match quality
240 bendavid 1.37 outElectron->SetFracSharedHits(iM->shFracInnerHits());
241 sixie 1.15
242 loizides 1.29 // make proper links to Tracks and Super Clusters
243 bendavid 1.49 if (gsfTrackMap_ && iM->gsfTrack().isNonnull()) {
244 bendavid 1.18 outElectron->SetGsfTrk(gsfTrackMap_->GetMit(refToPtr(iM->gsfTrack())));
245 bendavid 1.49 }
246     // make links to ambigous gsf tracks
247     if (gsfTrackMap_) {
248     for (reco::GsfTrackRefVector::const_iterator agsfi = iM->ambiguousGsfTracksBegin(); agsfi != iM->ambiguousGsfTracksEnd(); ++agsfi) {
249     outElectron->AddAmbiguousGsfTrack(gsfTrackMap_->GetMit(refToPtr(*agsfi)));
250     }
251     }
252    
253     // make tracker track links,
254 bendavid 1.37 if (trackerTrackMap_ && iM->closestCtfTrackRef().isNonnull()) {
255 bendavid 1.36 outElectron->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->closestCtfTrackRef())));
256 bendavid 1.19 }
257 loizides 1.38 if (barrelSuperClusterMap_ && endcapSuperClusterMap_ &&
258     pfSuperClusterMap_ && iM->superCluster().isNonnull()) {
259 bendavid 1.37 if(barrelSuperClusterMap_->HasMit(iM->superCluster())) {
260 sixie 1.12 outElectron->SetSuperCluster(barrelSuperClusterMap_->GetMit(iM->superCluster()));
261 bendavid 1.36 }
262     else if (endcapSuperClusterMap_->HasMit(iM->superCluster())) {
263 sixie 1.12 outElectron->SetSuperCluster(endcapSuperClusterMap_->GetMit(iM->superCluster()));
264     }
265 bendavid 1.36 else if (pfSuperClusterMap_->HasMit(iM->superCluster())) {
266     outElectron->SetSuperCluster(pfSuperClusterMap_->GetMit(iM->superCluster()));
267     }
268     else throw edm::Exception(edm::errors::Configuration, "FillerElectrons:FillDataBlock()\n")
269     << "Error! SuperCluster reference in unmapped collection " << edmName_ << endl;
270     }
271 sixie 1.13
272 bendavid 1.43 //compute impact parameter with respect to PV
273     if (iM->gsfTrack().isNonnull()) {
274     const reco::TransientTrack &tt = transientTrackBuilder->build(iM->gsfTrack());
275 bendavid 1.51
276     reco::TransientTrack ttckf;
277    
278 bendavid 1.58 reco::Vertex thevtx = pvCol->at(0);
279     reco::Vertex thevtxbs = pvBSCol->at(0);
280 bendavid 1.52
281 bendavid 1.58 reco::Vertex thevtxub = pvCol->at(0);
282     reco::Vertex thevtxubbs = pvBSCol->at(0);
283 bendavid 1.52
284 bendavid 1.51
285     //check if closest ctf track is included in PV and if so, remove it before computing impact parameters and uncertainties
286     if (iM->closestCtfTrackRef().isNonnull()) {
287     ttckf = transientTrackBuilder->build(iM->closestCtfTrackRef());
288 ksung 1.57
289     //check if closest ctf track is included in PV and if so, remove it from the collection of
290     //tracks associated with the PV and perform a refit before computing impact parameters and uncertainties
291     reco::TrackCollection newTkCollection;
292     bool foundMatch = false;
293     for(reco::Vertex::trackRef_iterator itk = thevtx.tracks_begin(); itk!=thevtx.tracks_end(); itk++) {
294     if(iM->closestCtfTrack().ctfTrack.isNonnull()) {
295     bool refMatching = (itk->get() == &*(iM->closestCtfTrack().ctfTrack));
296     float shFraction = iM->closestCtfTrack().shFracInnerHits;
297     if(refMatching && shFraction > 0.5) {
298     foundMatch = true;
299     continue;
300     }
301     }
302     newTkCollection.push_back(*itk->get());
303     }
304 bendavid 1.51
305 ksung 1.57 if(foundMatch) {
306     edm::Handle<reco::BeamSpot> bs;
307     event.getByLabel(edm::InputTag("offlineBeamSpot"),bs);
308    
309     VertexReProducer revertex(hVertex,event);
310     edm::Handle<reco::BeamSpot> pvbeamspot;
311     event.getByLabel(revertex.inputBeamSpot(),pvbeamspot);
312     vector<TransientVertex> pvs = revertex.makeVertices(newTkCollection,*pvbeamspot,setup);
313 bendavid 1.58 if(pvs.size()>0) {
314     thevtxub = pvs.front(); // take the first in the list
315     }
316    
317 ksung 1.57 VertexReProducer revertexbs(hVertexBS,event);
318     edm::Handle<reco::BeamSpot> pvbsbeamspot;
319     event.getByLabel(revertexbs.inputBeamSpot(),pvbsbeamspot);
320     vector<TransientVertex> pvbss = revertexbs.makeVertices(newTkCollection,*pvbsbeamspot,setup);
321 bendavid 1.58 if(pvbss.size()>0) {
322     thevtxubbs = pvbss.front(); // take the first in the list
323     }
324 ksung 1.57 }
325 bendavid 1.51 }
326 ksung 1.57
327    
328 bendavid 1.51 //preserve sign of transverse impact parameter (cross-product definition from track, not lifetime-signing)
329     const double gsfsign = ( (-iM->gsfTrack()->dxy(thevtx.position())) >=0 ) ? 1. : -1.;
330     const double gsfsignbs = ( (-iM->gsfTrack()->dxy(thevtxbs.position())) >=0 ) ? 1. : -1.;
331    
332     const std::pair<bool,Measurement1D> &d0pv = IPTools::absoluteTransverseImpactParameter(tt,thevtx);
333 bendavid 1.43 if (d0pv.first) {
334 bendavid 1.51 outElectron->SetD0PV(gsfsign*d0pv.second.value());
335 bendavid 1.43 outElectron->SetD0PVErr(d0pv.second.error());
336     }
337 bendavid 1.44 else {
338 bendavid 1.51 outElectron->SetD0PV(-999.0);
339 bendavid 1.44 }
340    
341 bendavid 1.43
342 bendavid 1.51 const std::pair<bool,Measurement1D> &ip3dpv = IPTools::absoluteImpactParameter3D(tt,thevtx);
343 bendavid 1.43 if (ip3dpv.first) {
344 bendavid 1.51 outElectron->SetIp3dPV(gsfsign*ip3dpv.second.value());
345 bendavid 1.43 outElectron->SetIp3dPVErr(ip3dpv.second.error());
346     }
347 bendavid 1.44 else {
348 bendavid 1.51 outElectron->SetIp3dPV(-999.0);
349 bendavid 1.44 }
350 bendavid 1.43
351 bendavid 1.51 const std::pair<bool,Measurement1D> &d0pvbs = IPTools::absoluteTransverseImpactParameter(tt,thevtxbs);
352 bendavid 1.43 if (d0pvbs.first) {
353 bendavid 1.51 outElectron->SetD0PVBS(gsfsignbs*d0pvbs.second.value());
354 bendavid 1.43 outElectron->SetD0PVBSErr(d0pvbs.second.error());
355     }
356 bendavid 1.44 else {
357 bendavid 1.51 outElectron->SetD0PVBS(-999.0);
358 bendavid 1.44 }
359 bendavid 1.43
360 bendavid 1.51 const std::pair<bool,Measurement1D> &ip3dpvbs = IPTools::absoluteImpactParameter3D(tt,thevtxbs);
361 bendavid 1.43 if (ip3dpvbs.first) {
362 bendavid 1.51 outElectron->SetIp3dPVBS(gsfsignbs*ip3dpvbs.second.value());
363 bendavid 1.43 outElectron->SetIp3dPVBSErr(ip3dpvbs.second.error());
364     }
365 bendavid 1.44 else {
366 bendavid 1.51 outElectron->SetIp3dPVBS(-999.0);
367 bendavid 1.44 }
368    
369 bendavid 1.58 const std::pair<bool,Measurement1D> &d0pvub = IPTools::absoluteTransverseImpactParameter(tt,thevtxub);
370     if (d0pvub.first) {
371     outElectron->SetD0PVUB(gsfsign*d0pvub.second.value());
372     outElectron->SetD0PVUBErr(d0pvub.second.error());
373     }
374     else {
375     outElectron->SetD0PVUB(-999.0);
376     }
377    
378    
379     const std::pair<bool,Measurement1D> &ip3dpvub = IPTools::absoluteImpactParameter3D(tt,thevtxub);
380     if (ip3dpvub.first) {
381     outElectron->SetIp3dPVUB(gsfsign*ip3dpvub.second.value());
382     outElectron->SetIp3dPVUBErr(ip3dpvub.second.error());
383     }
384     else {
385     outElectron->SetIp3dPVUB(-999.0);
386     }
387    
388     const std::pair<bool,Measurement1D> &d0pvubbs = IPTools::absoluteTransverseImpactParameter(tt,thevtxubbs);
389     if (d0pvubbs.first) {
390     outElectron->SetD0PVUBBS(gsfsignbs*d0pvubbs.second.value());
391     outElectron->SetD0PVUBBSErr(d0pvubbs.second.error());
392     }
393     else {
394     outElectron->SetD0PVUBBS(-999.0);
395     }
396    
397     const std::pair<bool,Measurement1D> &ip3dpvubbs = IPTools::absoluteImpactParameter3D(tt,thevtxubbs);
398     if (ip3dpvubbs.first) {
399     outElectron->SetIp3dPVUBBS(gsfsignbs*ip3dpvubbs.second.value());
400     outElectron->SetIp3dPVUBBSErr(ip3dpvubbs.second.error());
401     }
402     else {
403     outElectron->SetIp3dPVUBBS(-999.0);
404     }
405    
406 bendavid 1.51 if (iM->closestCtfTrackRef().isNonnull()) {
407    
408     const double ckfsign = ( (-iM->closestCtfTrackRef()->dxy(thevtx.position())) >=0 ) ? 1. : -1.;
409     const double ckfsignbs = ( (-iM->closestCtfTrackRef()->dxy(thevtxbs.position())) >=0 ) ? 1. : -1.;
410    
411     const std::pair<bool,Measurement1D> &d0pvckf = IPTools::absoluteTransverseImpactParameter(ttckf,thevtx);
412     if (d0pvckf.first) {
413     outElectron->SetD0PVCkf(ckfsign*d0pvckf.second.value());
414     outElectron->SetD0PVCkfErr(d0pvckf.second.error());
415     }
416     else {
417     outElectron->SetD0PVCkf(-999.0);
418     }
419    
420    
421     const std::pair<bool,Measurement1D> &ip3dpvckf = IPTools::absoluteImpactParameter3D(ttckf,thevtx);
422     if (ip3dpvckf.first) {
423     outElectron->SetIp3dPVCkf(ckfsign*ip3dpvckf.second.value());
424     outElectron->SetIp3dPVCkfErr(ip3dpvckf.second.error());
425     }
426     else {
427     outElectron->SetIp3dPVCkf(-999.0);
428     }
429    
430     const std::pair<bool,Measurement1D> &d0pvbsckf = IPTools::absoluteTransverseImpactParameter(ttckf,thevtxbs);
431     if (d0pvbsckf.first) {
432     outElectron->SetD0PVBSCkf(ckfsignbs*d0pvbsckf.second.value());
433     outElectron->SetD0PVBSCkfErr(d0pvbsckf.second.error());
434     }
435     else {
436     outElectron->SetD0PVBSCkf(-999.0);
437     }
438    
439     const std::pair<bool,Measurement1D> &ip3dpvbsckf = IPTools::absoluteImpactParameter3D(ttckf,thevtxbs);
440     if (ip3dpvbsckf.first) {
441     outElectron->SetIp3dPVBSCkf(ckfsignbs*ip3dpvbsckf.second.value());
442     outElectron->SetIp3dPVBSCkfErr(ip3dpvbsckf.second.error());
443     }
444     else {
445     outElectron->SetIp3dPVBSCkf(-999.0);
446     }
447 bendavid 1.58 //////////////
448    
449     const std::pair<bool,Measurement1D> &d0pvubckf = IPTools::absoluteTransverseImpactParameter(ttckf,thevtxub);
450     if (d0pvubckf.first) {
451     outElectron->SetD0PVUBCkf(ckfsign*d0pvubckf.second.value());
452     outElectron->SetD0PVUBCkfErr(d0pvubckf.second.error());
453     }
454     else {
455     outElectron->SetD0PVUBCkf(-999.0);
456     }
457    
458    
459     const std::pair<bool,Measurement1D> &ip3dpvubckf = IPTools::absoluteImpactParameter3D(ttckf,thevtxub);
460     if (ip3dpvubckf.first) {
461     outElectron->SetIp3dPVUBCkf(ckfsign*ip3dpvubckf.second.value());
462     outElectron->SetIp3dPVUBCkfErr(ip3dpvubckf.second.error());
463     }
464     else {
465     outElectron->SetIp3dPVUBCkf(-999.0);
466     }
467    
468     const std::pair<bool,Measurement1D> &d0pvubbsckf = IPTools::absoluteTransverseImpactParameter(ttckf,thevtxubbs);
469     if (d0pvubbsckf.first) {
470     outElectron->SetD0PVUBBSCkf(ckfsignbs*d0pvubbsckf.second.value());
471     outElectron->SetD0PVUBBSCkfErr(d0pvubbsckf.second.error());
472     }
473     else {
474     outElectron->SetD0PVUBBSCkf(-999.0);
475     }
476    
477     const std::pair<bool,Measurement1D> &ip3dpvubbsckf = IPTools::absoluteImpactParameter3D(ttckf,thevtxubbs);
478     if (ip3dpvubbsckf.first) {
479     outElectron->SetIp3dPVUBBSCkf(ckfsignbs*ip3dpvubbsckf.second.value());
480     outElectron->SetIp3dPVUBBSCkfErr(ip3dpvubbsckf.second.error());
481     }
482     else {
483     outElectron->SetIp3dPVUBBSCkf(-999.0);
484     }
485    
486 bendavid 1.51 }
487     else {
488     outElectron->SetD0PVCkf(-999.0);
489     outElectron->SetIp3dPVCkf(-999.0);
490     outElectron->SetD0PVBSCkf(-999.0);
491     outElectron->SetIp3dPVBSCkf(-999.0);
492 bendavid 1.58
493     outElectron->SetD0PVUBCkf(-999.0);
494     outElectron->SetIp3dPVUBCkf(-999.0);
495     outElectron->SetD0PVUBBSCkf(-999.0);
496     outElectron->SetIp3dPVUBBSCkf(-999.0);
497 bendavid 1.51 }
498    
499    
500 bendavid 1.43 if (verbose_>1) {
501     printf("gsf track pt = %5f\n",iM->gsfTrack()->pt());
502     printf("gsf track mode pt = %5f\n",iM->gsfTrack()->ptMode());
503     printf("ttrack pt = %5f\n",tt.initialFreeState().momentum().perp());
504     //printf("ttrackgsf pt = %5f\n",ttgsf.innermostMeasurementState().globalMomentum().perp());
505 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));
506     //printf("gsf reduced chisquared = %5f, probability = %5f\n", pvGsfCompat.second/2, TMath::Prob(pvGsfCompat.second,2));
507 bendavid 1.43 }
508    
509     }
510    
511 bendavid 1.53
512 bendavid 1.43 //fill conversion partner track info
513 bendavid 1.54 if (recomputeConversionInfo_) {
514     ConversionFinder convFinder; outElectron->SetConvPartnerDCotTheta(iM->convDcot());
515     ConversionInfo convInfo = convFinder.getConversionInfo(*iM, hGeneralTracks, hGsfTracks, bfield);
516    
517     outElectron->SetConvFlag(convInfo.flag());
518     outElectron->SetConvPartnerDCotTheta(convInfo.dcot());
519     outElectron->SetConvPartnerDist(convInfo.dist());
520     outElectron->SetConvPartnerRadius(convInfo.radiusOfConversion());
521     reco::TrackRef ckfconvTrackRef = convInfo.conversionPartnerCtfTk();
522     reco::GsfTrackRef gsfconvTrackRef = convInfo.conversionPartnerGsfTk();
523    
524    
525     if ( gsfconvTrackRef.isNonnull() && gsfTrackMap_ ) {
526     outElectron->SetConvPartnerTrk(gsfTrackMap_->GetMit(edm::refToPtr(gsfconvTrackRef)));
527     }
528     else if (ckfconvTrackRef.isNonnull() && trackerTrackMap_) {
529     outElectron->SetConvPartnerTrk(trackerTrackMap_->GetMit(edm::refToPtr(ckfconvTrackRef)));
530 bendavid 1.50 }
531 bendavid 1.54 }
532     else {
533     outElectron->SetConvFlag(iM->convFlags());
534     outElectron->SetConvPartnerDCotTheta(iM->convDcot());
535     outElectron->SetConvPartnerDist(iM->convDist());
536     outElectron->SetConvPartnerRadius(iM->convRadius());
537     reco::TrackBaseRef convTrackRef = iM->convPartner();
538     if (convTrackRef.isNonnull()) {
539     if ( dynamic_cast<const reco::GsfTrack*>(convTrackRef.get()) && gsfTrackMap_ ) {
540     outElectron->SetConvPartnerTrk(gsfTrackMap_->GetMit(mitedm::refToBaseToPtr(convTrackRef)));
541     }
542     else if (trackerTrackMap_) {
543     outElectron->SetConvPartnerTrk(trackerTrackMap_->GetMit(mitedm::refToBaseToPtr(convTrackRef)));
544     }
545 bendavid 1.50 }
546 bendavid 1.45 }
547 bendavid 1.43
548 bendavid 1.50
549    
550 loizides 1.29 // fill Electron ID information
551 peveraer 1.47 outElectron->SetPassLooseID((*eidLooseMap)[eRef]);
552     outElectron->SetPassTightID((*eidTightMap)[eRef]);
553 bendavid 1.49 if (!eIDLikelihoodName_.empty()) {
554     outElectron->SetIDLikelihood((*eidLikelihoodMap)[eRef]);
555     }
556    
557     // fill corrected expected inner hits
558 bendavid 1.50 if(iM->gsfTrack().isNonnull()) {
559     outElectron->SetCorrectedNExpectedHitsInner(iM->gsfTrack()->trackerExpectedHitsInner().numberOfHits());
560 bendavid 1.49 }
561 bendavid 1.31
562 bendavid 1.45 //fill additional conversion flag
563     outElectron->SetMatchesVertexConversion(convMatcher.matchesGoodConversion(*iM,hConversions));
564    
565 bendavid 1.31 if (verbose_>1) {
566     double recomass = sqrt(iM->energy()*iM->energy() - iM->p()*iM->p());
567 loizides 1.32 printf(" mithep::Electron, pt=%5f, eta=%5f, phi=%5f, energy=%5f, p=%5f, mass=%5f\n",
568     outElectron->Pt(), outElectron->Eta(), outElectron->Phi(),
569     outElectron->E(), outElectron->P(), outElectron->Mass());
570     printf("reco::GsfElectron , pt=%5f, eta=%5f, phi=%5f, energy=%5f, p=%5f, mass=%5f\n",
571     iM->pt(), iM->eta(), iM->phi(), iM->energy(), iM->p(), recomass);
572 bendavid 1.31 }
573 sixie 1.12 }
574 loizides 1.1 electrons_->Trim();
575     }