Skip to content

Commit 7dd6557

Browse files
committed
Merge pull request cms-sw#2261 from bendavid/singleLegConversionUpdate
Reco update -- Single leg conversion update
2 parents daa7948 + 6747b69 commit 7dd6557

File tree

14 files changed

+154
-139
lines changed

14 files changed

+154
-139
lines changed

DataFormats/EgammaCandidates/interface/GsfElectronCore.h

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "DataFormats/TrackReco/interface/TrackFwd.h"
88
#include "DataFormats/EgammaReco/interface/SuperCluster.h"
99
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
10+
#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
1011

1112
#include <vector>
1213

@@ -45,12 +46,22 @@ namespace reco
4546
bool ecalDrivenSeed() const { return isEcalDrivenSeed_ ; }
4647
bool trackerDrivenSeed() const { return isTrackerDrivenSeed_ ; }
4748

49+
/// get vector of references to Conversion's
50+
reco::ConversionRefVector conversions() const {return conversions_;}
51+
/// get vector of references to one leg Conversion's
52+
reco::ConversionRefVector conversionsOneLeg() const {return conversionsOneLeg_;}
53+
4854
// setters
4955
void setGsfTrack( const GsfTrackRef & gsfTrack ) { gsfTrack_ = gsfTrack ; }
5056
void setSuperCluster( const SuperClusterRef & scl ) { superCluster_ = scl ; }
5157
void setCtfTrack( const TrackRef & closestCtfTrack, float ctfGsfOverlap )
5258
{ closestCtfTrack_ = closestCtfTrack ; ctfGsfOverlap_ = ctfGsfOverlap ; }
5359

60+
/// add single ConversionRef to the vector of Refs
61+
void addConversion( const reco::ConversionRef & r ) { conversions_.push_back(r); }
62+
/// add single ConversionRef to the vector of Refs
63+
void addOneLegConversion( const reco::ConversionRef & r ) { conversionsOneLeg_.push_back(r); }
64+
5465
// pflow eventual additionnal info
5566
const SuperClusterRef & parentSuperCluster() const { return parentSuperCluster_ ; }
5667
void setParentSuperCluster( const SuperClusterRef & scl ) { parentSuperCluster_ = scl ; }
@@ -61,6 +72,10 @@ namespace reco
6172
SuperClusterRef superCluster_ ;
6273
SuperClusterRef parentSuperCluster_ ;
6374
TrackRef closestCtfTrack_ ; // best matching ctf track
75+
// vector of references to Conversions
76+
reco::ConversionRefVector conversions_;
77+
//vector of references for 1-leg
78+
reco::ConversionRefVector conversionsOneLeg_;
6479
float ctfGsfOverlap_ ; // fraction of common hits between the ctf and gsf tracks
6580
bool isEcalDrivenSeed_ ;
6681
bool isTrackerDrivenSeed_ ;

DataFormats/EgammaCandidates/src/classes_def.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@
111111

112112

113113

114-
<class name="reco::GsfElectronCore" ClassVersion="11">
114+
<class name="reco::GsfElectronCore" ClassVersion="12">
115115
<version ClassVersion="10" checksum="2226610106"/>
116116
<version ClassVersion="11" checksum="2637403054"/>
117+
<version ClassVersion="12" checksum="2885797746"/>
117118
</class>
118119
<ioread sourceClass="reco::GsfElectronCore" version="[1-10]" targetClass="reco::GsfElectronCore" source="reco::SuperClusterRef pflowSuperCluster_;" target="parentSuperCluster_">
119120
<![CDATA[parentSuperCluster_ = onfile.pflowSuperCluster_;]]>

DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,23 @@ namespace reco {
114114
void setSuperClusterPFECALRef(reco::SuperClusterRef sc) { scPFECALRef_ = sc; }
115115

116116
/// add Single Leg Conversion TrackRef
117-
void addSingleLegConvTrackRef(const reco::TrackRef& trackref);
117+
void addSingleLegConvTrackRefMva(const std::pair<reco::TrackRef, float> &trackrefmva);
118118

119119
/// return vector of Single Leg Conversion TrackRef from
120-
const std::vector<reco::TrackRef>& singleLegConvTrackRef() const {return assoSingleLegRefTrack_;}
121-
122-
/// add Single Leg Conversion mva
123-
void addSingleLegConvMva(const float& mvasingleleg);
124-
125-
/// return Single Leg Conversion mva
126-
const std::vector<float>& singleLegConvMva() const {return assoSingleLegMva_;}
120+
const std::vector<std::pair<reco::TrackRef, float > > &singleLegConvTrackRefMva() const {return assoSingleLeg_;}
127121

128122
/// add Conversions from PF
129123
void addConversionRef(const reco::ConversionRef& convref);
130124

131125
/// return Conversions from PF
132126
reco::ConversionRefVector conversionRef() const {return assoConversionsRef_;}
133127

128+
/// add Conversions from PF
129+
void addSingleLegConversionRef(const reco::ConversionRef& convref);
130+
131+
/// return Conversions from PF
132+
reco::ConversionRefVector singleLegConversionRef() const {return singleLegConversions_;}
133+
134134
/// set LateBrem
135135
void setLateBrem(float val);
136136
/// set EarlyBrem
@@ -204,18 +204,18 @@ namespace reco {
204204
/// Ref to PF-ECAL only supercluster
205205
reco::SuperClusterRef scPFECALRef_;
206206

207-
/// vector of TrackRef from Single Leg conversions
208-
std::vector<reco::TrackRef> assoSingleLegRefTrack_;
207+
/// vector of TrackRef from Single Leg conversions and associated mva value
208+
std::vector<std::pair<reco::TrackRef, float> > assoSingleLeg_;
209209

210210
// information for track matching
211211
ElementsInBlocks assoNonConvExtraTracks_;
212212

213-
/// vector of Mvas from Single Leg conversions
214-
std::vector<float> assoSingleLegMva_;
215-
216213
/// vector of ConversionRef from PF
217214
reco::ConversionRefVector assoConversionsRef_;
218215

216+
//associated single leg conversions
217+
reco::ConversionRefVector singleLegConversions_;
218+
219219
/// energy of individual clusters (corrected).
220220
/// The first cluster is the seed
221221
std::vector<float> clusterEnergies_;

DataFormats/ParticleFlowCandidate/src/PFCandidateEGammaExtra.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,18 @@ float PFCandidateEGammaExtra::mvaVariable(MvaVariable var) const {
153153
return (mvaStatus(var) ? mvaVariables_[var] : -9999. );
154154
}
155155

156-
void PFCandidateEGammaExtra::addSingleLegConvTrackRef(const reco::TrackRef& trackref){
157-
assoSingleLegRefTrack_.push_back(trackref);
158-
}
159-
160-
void PFCandidateEGammaExtra::addSingleLegConvMva(const float& mvasingleleg){
161-
assoSingleLegMva_.push_back(mvasingleleg);
156+
void PFCandidateEGammaExtra::addSingleLegConvTrackRefMva(const std::pair<reco::TrackRef, float> &trackrefmva){
157+
assoSingleLeg_.push_back(trackrefmva);
162158
}
163159

164160
void PFCandidateEGammaExtra::addConversionRef(const reco::ConversionRef& convref){
165161
assoConversionsRef_.push_back(convref);
166162
}
167163

164+
void PFCandidateEGammaExtra::addSingleLegConversionRef(const reco::ConversionRef& convref){
165+
singleLegConversions_.push_back(convref);
166+
}
167+
168168
static const char * const listVar[] = {
169169
"LogPt",
170170
"Eta",

RecoEgamma/Configuration/python/RecoEgamma_EventContent_cff.py

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
'keep floatedmValueMap_eidLoose_*_*',
101101
'keep floatedmValueMap_eidTight_*_*',
102102
'keep recoPhotonCores_gedPhotonCore_*_*',
103-
'keep recoConversions_gedPhotonCore_*_*',
104103
'keep recoPhotons_gedPhotons_*_*',
105104
'keep *_particleBasedIsolation_*_*',
106105
'drop *_gedPhotons_valMapPFEgammaCandToPhoton_*',

RecoEgamma/EgammaElectronProducers/plugins/GEDGsfElectronCoreProducer.cc

+8
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ void GEDGsfElectronCoreProducer::produceElectronCore( const reco::PFCandidate &
7070
SuperClusterRef scRef = extraRef->superClusterRef();
7171
SuperClusterRef scBoxRef = extraRef->superClusterPFECALRef();
7272

73+
for(const auto &convref : extraRef->conversionRef()) {
74+
eleCore->addConversion(convref);
75+
}
76+
77+
for(const auto &convref : extraRef->singleLegConversionRef()) {
78+
eleCore->addOneLegConversion(convref);
79+
}
80+
7381
if (!scRef.isNull() || !scBoxRef.isNull())
7482
{
7583
eleCore->setSuperCluster(scRef) ;

RecoEgamma/EgammaPhotonProducers/interface/GEDPhotonCoreProducer.h

-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ class GEDPhotonCoreProducer : public edm::EDProducer {
3131

3232
private:
3333

34-
void createSingleLegConversions( reco::CaloClusterPtr, const std::vector<reco::TrackRef>&, const std::vector<float>&, reco::ConversionCollection &oneLegConversions );
35-
3634
std::string GEDPhotonCoreCollection_;
37-
std::string PFConversionCollection_;
3835
edm::EDGetTokenT<reco::PFCandidateCollection> pfEgammaCandidates_;
3936
edm::EDGetTokenT<reco::ElectronSeedCollection> pixelSeedProducer_;
4037

RecoEgamma/EgammaPhotonProducers/src/GEDPhotonCoreProducer.cc

+5-87
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ GEDPhotonCoreProducer::GEDPhotonCoreProducer(const edm::ParameterSet& config) :
5050

5151
// Register the product
5252
produces<reco::PhotonCoreCollection>(GEDPhotonCoreCollection_);
53-
produces<reco::ConversionCollection>(PFConversionCollection_);
5453

5554
}
5655

@@ -68,9 +67,6 @@ void GEDPhotonCoreProducer::produce(edm::Event &theEvent, const edm::EventSetup&
6867
reco::PhotonCoreCollection outputPhotonCoreCollection;
6968
std::auto_ptr< reco::PhotonCoreCollection > outputPhotonCoreCollection_p(new reco::PhotonCoreCollection);
7069

71-
reco::ConversionCollection outputOneLegConversionCollection;
72-
std::auto_ptr<reco::ConversionCollection> SingleLeg_p(new reco::ConversionCollection(outputOneLegConversionCollection));
73-
7470
// Get the PF refined cluster collection
7571
Handle<reco::PFCandidateCollection> pfCandidateHandle;
7672
theEvent.getByToken(pfEgammaCandidates_,pfCandidateHandle);
@@ -104,6 +100,7 @@ void GEDPhotonCoreProducer::produce(edm::Event &theEvent, const edm::EventSetup&
104100
reco::SuperClusterRef refinedSC= pfPhoRef->superClusterRef();
105101
reco::SuperClusterRef boxSC= pfPhoRef->superClusterPFECALRef();
106102
const reco::ConversionRefVector & doubleLegConv = pfPhoRef->conversionRef();
103+
const reco::ConversionRefVector & singleLegConv = pfPhoRef->singleLegConversionRef();
107104
reco::CaloClusterPtr refinedSCPtr= edm::refToPtr(refinedSC);
108105

109106
// std::cout << "newCandidate doubleLegConv="<<doubleLegConv.size()<< std::endl;
@@ -121,6 +118,10 @@ void GEDPhotonCoreProducer::produce(edm::Event &theEvent, const edm::EventSetup&
121118
for(unsigned int lConv=0; lConv < doubleLegConv.size(); lConv++) {
122119
newCandidate.addConversion(doubleLegConv[lConv]);
123120
}
121+
122+
for(unsigned int lConv=0; lConv < singleLegConv.size(); lConv++) {
123+
newCandidate.addOneLegConversion(singleLegConv[lConv]);
124+
}
124125

125126
// std::cout << "newCandidate pf refined SC energy="<< newCandidate.superCluster()->energy()<<std::endl;
126127
//std::cout << "newCandidate pf SC energy="<< newCandidate.parentSuperCluster()->energy()<<std::endl;
@@ -135,39 +136,9 @@ void GEDPhotonCoreProducer::produce(edm::Event &theEvent, const edm::EventSetup&
135136
}
136137
}
137138

138-
139-
140-
//
141-
createSingleLegConversions(refinedSCPtr, pfPhoRef->singleLegConvTrackRef(), pfPhoRef->singleLegConvMva(), outputOneLegConversionCollection);
142139
outputPhotonCoreCollection.push_back(newCandidate);
143140
}
144141

145-
SingleLeg_p->assign(outputOneLegConversionCollection.begin(),outputOneLegConversionCollection.end());
146-
const edm::OrphanHandle<reco::ConversionCollection> singleLegConvOrhpHandle = theEvent.put(SingleLeg_p,PFConversionCollection_);
147-
148-
//std::cout << " GEDPhotonCoreProducer::produce orphanHandle to single legs " << singleLegConvOrhpHandle->size() << std::endl;
149-
//std::cout << " GEDPhotonCoreProducer::produce photon size " << outputPhotonCoreCollection.size() << std::endl;
150-
151-
152-
153-
int ipho=0;
154-
for (reco::PhotonCoreCollection::iterator gamIter=outputPhotonCoreCollection.begin(); gamIter != outputPhotonCoreCollection.end(); ++gamIter){
155-
156-
for( unsigned int icp = 0; icp < singleLegConvOrhpHandle->size(); icp++) {
157-
const reco::ConversionRef cpRef(reco::ConversionRef(singleLegConvOrhpHandle,icp));
158-
if ( !cpRef->caloCluster().size()) continue;
159-
if (!( gamIter->superCluster().id() == cpRef->caloCluster()[0].id() && gamIter->superCluster().key() == cpRef->caloCluster()[0].key() )) continue;
160-
gamIter->addOneLegConversion(cpRef);
161-
}
162-
// debug
163-
// std::cout << "PhotonCoreCollection i="<<ipho<<" pf refined SC energy="<<gamIter->superCluster()->energy()<<std::endl;
164-
//std::cout << "PhotonCoreCollection i="<<ipho<<" pf SC energy="<<gamIter->parentSuperCluster()->energy()<<std::endl;
165-
//std::cout << "PhotonCoreCollection i="<<ipho<<" nconv2leg="<<gamIter->conversions().size()<<" nconv1leg="<<gamIter->conversionsOneLeg().size()<<std::endl;
166-
ipho++;
167-
}
168-
169-
170-
171142
// put the product in the event
172143
// edm::LogInfo("GEDPhotonCoreProducer") << " Put in the event " << iSC << " Photon Candidates \n";
173144
outputPhotonCoreCollection_p->assign(outputPhotonCoreCollection.begin(),outputPhotonCoreCollection.end());
@@ -177,56 +148,3 @@ void GEDPhotonCoreProducer::produce(edm::Event &theEvent, const edm::EventSetup&
177148

178149

179150
}
180-
181-
182-
void GEDPhotonCoreProducer::createSingleLegConversions(reco::CaloClusterPtr sc, const std::vector<reco::TrackRef>& conv, const std::vector<float>& mva, reco::ConversionCollection &oneLegConversions) {
183-
// this method translates the single track into the Conversion Data Format
184-
185-
math::Error<3>::type error;
186-
for (unsigned int itk=0; itk<conv.size(); itk++){
187-
const reco::Vertex convVtx(conv[itk]->innerPosition(), error);
188-
std::vector<reco::TrackRef> OneLegConvVector;
189-
OneLegConvVector.push_back(conv[itk]);
190-
std::vector< float > OneLegMvaVector;
191-
OneLegMvaVector.push_back(mva[itk]);
192-
std::vector<reco::CaloClusterPtr> dummymatchingBC;
193-
reco::CaloClusterPtrVector scPtrVec;
194-
scPtrVec.push_back(sc);
195-
196-
197-
std::vector<math::XYZPointF>trackPositionAtEcalVec;
198-
std::vector<math::XYZPointF>innPointVec;
199-
std::vector<math::XYZVectorF>trackPinVec;
200-
std::vector<math::XYZVectorF>trackPoutVec;
201-
math::XYZPointF trackPositionAtEcal(conv[itk]->outerPosition().X(), conv[itk]->outerPosition().Y(), conv[itk]->outerPosition().Z());
202-
trackPositionAtEcalVec.push_back(trackPositionAtEcal);
203-
204-
math::XYZPointF innPoint(conv[itk]->innerPosition().X(), conv[itk]->innerPosition().Y(), conv[itk]->innerPosition().Z());
205-
innPointVec.push_back(innPoint);
206-
207-
math::XYZVectorF trackPin(conv[itk]->innerMomentum().X(), conv[itk]->innerMomentum().Y(), conv[itk]->innerMomentum().Z());
208-
trackPinVec.push_back(trackPin);
209-
210-
math::XYZVectorF trackPout(conv[itk]->outerMomentum().X(), conv[itk]->outerMomentum().Y(), conv[itk]->outerMomentum().Z());
211-
trackPoutVec.push_back( trackPout );
212-
213-
float DCA = conv[itk]->d0() ;
214-
reco::Conversion singleLegConvCandidate(scPtrVec,
215-
OneLegConvVector,
216-
trackPositionAtEcalVec,
217-
convVtx,
218-
dummymatchingBC,
219-
DCA,
220-
innPointVec,
221-
trackPinVec,
222-
trackPoutVec,
223-
mva[itk],
224-
reco::Conversion::pflow);
225-
singleLegConvCandidate.setOneLegMVA(OneLegMvaVector);
226-
oneLegConversions.push_back(singleLegConvCandidate);
227-
228-
}
229-
230-
231-
232-
}

RecoParticleFlow/Configuration/python/RecoParticleFlow_EventContent_cff.py

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
'keep recoPFCandidates_particleFlowEGamma_*_*',
3434
'keep recoCaloClusters_particleFlowEGamma_*_*',
3535
'keep recoSuperClusters_particleFlowEGamma_*_*',
36+
'keep recoConversions_particleFlowEGamma_*_*',
3637
'keep recoPFCandidates_particleFlow_*_*',
3738
'keep recoPFCandidates_particleFlowTmp_*_*',
3839
'drop recoPFCandidates_particleFlowTmp__*',
@@ -75,6 +76,7 @@
7576
'keep recoPFCandidates_particleFlowEGamma_*_*',
7677
'keep recoCaloClusters_particleFlowEGamma_*_*',
7778
'keep recoSuperClusters_particleFlowEGamma_*_*',
79+
'keep recoConversions_particleFlowEGamma_*_*',
7880
'keep recoPFCandidates_particleFlow_*_*',
7981
'keep recoPFCandidates_particleFlowTmp_electrons_*',
8082
'keep recoPFCandidates_particleFlowTmp_*_*',
@@ -110,6 +112,7 @@
110112
#'keep recoPFCandidates_*_*_*',
111113
'keep recoCaloClusters_particleFlowEGamma_*_*',
112114
'keep recoSuperClusters_particleFlowEGamma_*_*',
115+
'keep recoConversions_particleFlowEGamma_*_*',
113116
'keep recoPFCandidates_particleFlow_*_*',
114117
'keep recoPFCandidates_particleFlowTmp_*_*',
115118
'drop recoPFCandidates_particleFlowTmp__*',

RecoParticleFlow/PFProducer/interface/PFEGammaAlgo.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ class PFEGammaAlgo {
6969
std::vector<PFKFFlaggedElement> > GSFToTrackMap;
7070
typedef std::unordered_map<const PFClusterElement*,
7171
std::vector<PFClusterFlaggedElement> > ClusterMap;
72-
72+
typedef std::unordered_map<const PFKFElement*,
73+
float > KFValMap;
74+
7375
struct ProtoEGObject {
7476
ProtoEGObject() : parentSC(NULL) {}
7577
reco::PFBlockRef parentBlock;
@@ -88,6 +90,7 @@ class PFEGammaAlgo {
8890
// for manual brem recovery
8991
std::vector<PFGSFFlaggedElement> secondaryGSFs;
9092
std::vector<PFKFFlaggedElement> secondaryKFs;
93+
KFValMap singleLegConversionMvaMap;
9194
// for track-HCAL cluster linking
9295
std::vector<PFClusterFlaggedElement> hcalClusters;
9396
ElementMap localMap;
@@ -380,7 +383,7 @@ class PFEGammaAlgo {
380383
// std::vector<reco::SuperCluser> sCluster_;
381384
reco::PFCandidateEGammaExtraCollection egExtra_;
382385

383-
bool EvaluateSingleLegMVA(const reco::PFBlockRef& blockref,
386+
float EvaluateSingleLegMVA(const reco::PFBlockRef& blockref,
384387
const reco::Vertex& primaryvtx,
385388
unsigned int track_index);
386389
};

0 commit comments

Comments
 (0)