Skip to content

Commit

Permalink
this commit addressed the GitHub issue cms-sw#30895 :
Browse files Browse the repository at this point in the history
- set vertex position of PFCandidate in PFAlgo, PFEGammaAlgo, and PFMuonAlgo
- remove vertex related member-functions from PFCandidate class (use the member-fuctions defined in the LeafCandidate base-class instead)
- updated ClassDefs in classes_def.xml files accordingly
  • Loading branch information
veelken authored and jpata committed Sep 16, 2020
1 parent c024f9f commit 75fdaa2
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 91 deletions.
38 changes: 0 additions & 38 deletions DataFormats/ParticleFlowCandidate/interface/PFCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ namespace reco {
GAMMA_TO_GAMMACONV
};

enum PFVertexType {
kCandVertex = 0,
kTrkVertex = 1,
kComMuonVertex = 2,
kSAMuonVertex = 3,
kTrkMuonVertex = 4,
kGSFVertex = 5,
kTPFMSMuonVertex = 6,
kPickyMuonVertex = 7,
kDYTMuonVertex = 8
};

/// default constructor
PFCandidate();

Expand Down Expand Up @@ -386,30 +374,6 @@ namespace reco {

friend std::ostream& operator<<(std::ostream& out, const PFCandidate& c);

//Tips on setting the vertex efficiently
//There are two choices: a) use the vertex_ data member, or b) point to the vertex
//of one of the refs stored by this class. The PFVertexType enum gives the current list
//of possible references. For these references, use the setVeretxSource method and NOT
//the setVertex method. If none of the available refs have the vertex that you want for this
//PFCandidate, use the setVertex method. If you find that you are using frequently two store a
// vertex that is the same as one of the refs in this class, you should just extend the enum
// and modify the vertex() method accordingly.
void setVertexSource(PFVertexType vt) {
vertexType_ = vt;
if (vertexType_ != kCandVertex)
LeafCandidate::setVertex(Point(0., 0., 0.));
}

void setVertex(const math::XYZPoint& p) override {
LeafCandidate::setVertex(p);
vertexType_ = kCandVertex;
}

const Point& vertex() const override;
double vx() const override { return vertex().x(); }
double vy() const override { return vertex().y(); }
double vz() const override { return vertex().z(); }

/// do we have a valid time information
bool isTimeValid() const { return timeError_ >= 0.f; }
/// \return the timing
Expand Down Expand Up @@ -483,8 +447,6 @@ namespace reco {
/// uncertainty on 3-momentum
float deltaP_;

PFVertexType vertexType_;

// mva for isolated electrons
float mva_Isolated_;

Expand Down
38 changes: 0 additions & 38 deletions DataFormats/ParticleFlowCandidate/src/PFCandidate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ PFCandidate::PFCandidate()
ps2Energy_(0.),
flags_(0),
deltaP_(0.),
vertexType_(kCandVertex),
mva_Isolated_(bigMva_),
mva_e_pi_(bigMva_),
mva_e_mu_(bigMva_),
Expand Down Expand Up @@ -73,7 +72,6 @@ PFCandidate::PFCandidate(Charge charge, const LorentzVector& p4, ParticleType pa
ps2Energy_(0.),
flags_(0),
deltaP_(0.),
vertexType_(kCandVertex),
mva_Isolated_(bigMva_),
mva_e_pi_(bigMva_),
mva_e_mu_(bigMva_),
Expand Down Expand Up @@ -129,7 +127,6 @@ PFCandidate::PFCandidate(PFCandidate const& iOther)
ps2Energy_(iOther.ps2Energy_),
flags_(iOther.flags_),
deltaP_(iOther.deltaP_),
vertexType_(iOther.vertexType_),
mva_Isolated_(iOther.mva_Isolated_),
mva_e_pi_(iOther.mva_e_pi_),
mva_e_mu_(iOther.mva_e_mu_),
Expand Down Expand Up @@ -173,7 +170,6 @@ PFCandidate& PFCandidate::operator=(PFCandidate const& iOther) {
ps2Energy_ = iOther.ps2Energy_;
flags_ = iOther.flags_;
deltaP_ = iOther.deltaP_;
vertexType_ = iOther.vertexType_;
mva_Isolated_ = iOther.mva_Isolated_;
mva_e_pi_ = iOther.mva_e_pi_;
mva_e_mu_ = iOther.mva_e_mu_;
Expand Down Expand Up @@ -599,40 +595,6 @@ void PFCandidate::setPFEGammaExtraRef(const reco::PFCandidateEGammaExtraRef& iRe
kRefPFEGammaExtraMask, kRefPFEGammaExtraBit, iRef.isNonnull(), iRef.refCore(), iRef.key(), iRef.productGetter());
}

const math::XYZPoint& PFCandidate::vertex() const {
switch (vertexType_) {
case kCandVertex:
return LeafCandidate::vertex();
break;
case kTrkVertex:
return trackRef()->vertex();
break;
case kComMuonVertex:
return muonRef()->combinedMuon()->vertex();
break;
case kSAMuonVertex:
return muonRef()->standAloneMuon()->vertex();
break;
case kTrkMuonVertex:
return muonRef()->track()->vertex();
break;
case kTPFMSMuonVertex:
return muonRef()->tpfmsTrack()->vertex();
break;
case kPickyMuonVertex:
return muonRef()->pickyTrack()->vertex();
break;
case kDYTMuonVertex:
return muonRef()->dytTrack()->vertex();
break;

case kGSFVertex:
return gsfTrackRef()->vertex();
break;
}
return LeafCandidate::vertex();
}

const PFCandidate::ElementsInBlocks& PFCandidate::elementsInBlocks() const {
if (nullptr == elementsInBlocks_.load(std::memory_order_acquire)) {
std::unique_ptr<ElementsInBlocks> temp(new ElementsInBlocks(blocksStorage_.size()));
Expand Down
9 changes: 6 additions & 3 deletions DataFormats/ParticleFlowCandidate/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<lcgdict>

<class name="reco::PFCandidate" ClassVersion="19">
<class name="reco::PFCandidate" ClassVersion="20">
<version ClassVersion="20" checksum="1260609994"/>
<version ClassVersion="19" checksum="2990582232"/>
<version ClassVersion="18" checksum="910857761"/>
<version ClassVersion="17" checksum="3126170233"/>
Expand Down Expand Up @@ -52,7 +53,8 @@
<class name="edm::PtrVector<reco::PFCandidate> "/>
<class name="edm::Wrapper<edm::PtrVector<reco::PFCandidate> >"/>

<class name="reco::IsolatedPFCandidate" ClassVersion="15">
<class name="reco::IsolatedPFCandidate" ClassVersion="16">
<version ClassVersion="16" checksum="1266825707"/>
<version ClassVersion="15" checksum="3042264953"/>
<version ClassVersion="14" checksum="207328514"/>
<version ClassVersion="13" checksum="1855164250"/>
Expand All @@ -67,7 +69,8 @@
<class name="reco::IsolatedPFCandidateRefVector"/>
<class name="reco::IsolatedPFCandidatePtr"/>

<class name="reco::PileUpPFCandidate" ClassVersion="15">
<class name="reco::PileUpPFCandidate" ClassVersion="16">
<version ClassVersion="16" checksum="278254000"/>
<version ClassVersion="15" checksum="953549166"/>
<version ClassVersion="14" checksum="4065938015"/>
<version ClassVersion="13" checksum="1734488695"/>
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/PatCandidates/src/classes_def_objects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@
<version ClassVersion="11" checksum="3492108938"/>
<version ClassVersion="10" checksum="417284221"/>
</class>
<class name="pat::PFParticle" ClassVersion="15">
<class name="pat::PFParticle" ClassVersion="16">
<version ClassVersion="16" checksum="4013624954"/>
<version ClassVersion="15" checksum="1485536104"/>
<version ClassVersion="14" checksum="2795911745"/>
<version ClassVersion="13" checksum="223824921"/>
Expand Down
2 changes: 1 addition & 1 deletion RecoParticleFlow/PFProducer/src/PFAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3160,7 +3160,7 @@ unsigned PFAlgo::reconstructTrack(const reco::PFBlockElement& elt, bool allowLoo
<< ", phi=" << momentum.phi();
pfCandidates_->push_back(PFCandidate(charge, momentum, particleType));
//Set vertex and stuff like this
pfCandidates_->back().setVertexSource(PFCandidate::kTrkVertex);
pfCandidates_->back().setVertex(trackRef->vertex());
pfCandidates_->back().setTrackRef(trackRef);
pfCandidates_->back().setPositionAtECALEntrance(eltTrack->positionAtECALEntrance());
if (muonRef.isNonnull())
Expand Down
2 changes: 2 additions & 0 deletions RecoParticleFlow/PFProducer/src/PFEGammaAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1488,12 +1488,14 @@ PFEGammaAlgo::EgammaObjects PFEGammaAlgo::fillPFCandidates(const std::list<PFEGa
cand.setCharge(RO.primaryKFs[0]->trackRef()->charge());
xtra.setKfTrackRef(RO.primaryKFs[0]->trackRef());
cand.setTrackRef(RO.primaryKFs[0]->trackRef());
cand.setVertex(RO.primaryKFs[0]->trackRef()->vertex());
cand.addElementInBlock(_currentblock, RO.primaryKFs[0]->index());
}
if (!RO.primaryGSFs.empty()) {
cand.setCharge(RO.primaryGSFs[0]->GsftrackRef()->chargeMode());
xtra.setGsfTrackRef(RO.primaryGSFs[0]->GsftrackRef());
cand.setGsfTrackRef(RO.primaryGSFs[0]->GsftrackRef());
cand.setVertex(RO.primaryGSFs[0]->GsftrackRef()->vertex());
cand.addElementInBlock(_currentblock, RO.primaryGSFs[0]->index());
}
if (RO.parentSC) {
Expand Down
11 changes: 1 addition & 10 deletions RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -600,16 +600,7 @@ void PFMuonAlgo::changeTrack(reco::PFCandidate& candidate, const MuonTrackTypePa
candidate.setParticleType(reco::PFCandidate::mu);
// candidate.setTrackRef( bestTrack );
candidate.setMuonTrackType(trackType);
if (trackType == reco::Muon::InnerTrack)
candidate.setVertexSource(PFCandidate::kTrkMuonVertex);
else if (trackType == reco::Muon::CombinedTrack)
candidate.setVertexSource(PFCandidate::kComMuonVertex);
else if (trackType == reco::Muon::TPFMS)
candidate.setVertexSource(PFCandidate::kTPFMSMuonVertex);
else if (trackType == reco::Muon::Picky)
candidate.setVertexSource(PFCandidate::kPickyMuonVertex);
else if (trackType == reco::Muon::DYT)
candidate.setVertexSource(PFCandidate::kDYTMuonVertex);
candidate.setVertex(bestTrack->vertex());
}

reco::Muon::MuonTrackTypePair PFMuonAlgo::getTrackWithSmallestError(
Expand Down

0 comments on commit 75fdaa2

Please sign in to comment.