-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28116 from steggema/TICLtoPF
TICL: Create PF candidates as output of TICL
- Loading branch information
Showing
25 changed files
with
691 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#ifndef DataFormats_HGCalReco_TICLCandidate_h | ||
#define DataFormats_HGCalReco_TICLCandidate_h | ||
|
||
#include "DataFormats/Candidate/interface/LeafCandidate.h" | ||
#include "DataFormats/Common/interface/Ref.h" | ||
#include "DataFormats/HGCalReco/interface/Trackster.h" | ||
#include "DataFormats/Math/interface/Point3D.h" | ||
#include "DataFormats/TrackReco/interface/Track.h" | ||
#include "DataFormats/TrackReco/interface/TrackFwd.h" | ||
|
||
// A TICLCandidate is a lightweight physics object made from one or multiple Tracksters. | ||
|
||
class TICLCandidate : public reco::LeafCandidate { | ||
public: | ||
typedef ticl::Trackster::ParticleType ParticleType; | ||
|
||
TICLCandidate(Charge q, const LorentzVector& p4) | ||
: LeafCandidate(q, p4), time_(0.f), timeError_(-1.f), rawEnergy_(0.f) {} | ||
|
||
TICLCandidate() : LeafCandidate(), time_(0.f), timeError_(-1.f), rawEnergy_(0.f) {} | ||
|
||
TICLCandidate(const edm::Ptr<ticl::Trackster>& trackster) | ||
: LeafCandidate(), time_(0.f), timeError_(-1.f), rawEnergy_(0.f), tracksters_({trackster}) {} | ||
|
||
inline float time() const { return time_; } | ||
inline float timeError() const { return timeError_; } | ||
|
||
void setTime(float time) { time_ = time; }; | ||
void setTimeError(float timeError) { timeError_ = timeError; } | ||
|
||
inline const edm::Ptr<reco::Track> trackPtr() const { return trackPtr_; } | ||
void setTrackPtr(const edm::Ptr<reco::Track>& trackPtr) { trackPtr_ = trackPtr; } | ||
|
||
inline float rawEnergy() const { return rawEnergy_; } | ||
void setRawEnergy(float rawEnergy) { rawEnergy_ = rawEnergy; } | ||
|
||
inline const std::vector<edm::Ptr<ticl::Trackster> > tracksters() const { return tracksters_; }; | ||
|
||
void setTracksters(const std::vector<edm::Ptr<ticl::Trackster> >& tracksters) { tracksters_ = tracksters; } | ||
void addTrackster(const edm::Ptr<ticl::Trackster>& trackster) { tracksters_.push_back(trackster); } | ||
// convenience method to return the ID probability for a certain particle type | ||
inline float id_probability(ParticleType type) const { | ||
// probabilities are stored in the same order as defined in the ParticleType enum | ||
return idProbabilities_[(int)type]; | ||
} | ||
|
||
void setIdProbabilities(const std::array<float, 8>& idProbs) { idProbabilities_ = idProbs; } | ||
|
||
private: | ||
float time_; | ||
float timeError_; | ||
edm::Ptr<reco::Track> trackPtr_; | ||
|
||
float rawEnergy_; | ||
|
||
// vector of Ptr so Tracksters can come from different collections | ||
// and there can be derived classes | ||
std::vector<edm::Ptr<ticl::Trackster> > tracksters_; | ||
|
||
// Since it contains multiple tracksters, duplicate the probability interface | ||
std::array<float, 8> idProbabilities_; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<use name="DataFormats/Candidate"/> | ||
<use name="DataFormats/HGCalReco"/> | ||
<use name="DataFormats/VertexReco"/> | ||
<use name="FWCore/PluginManager"/> | ||
<export> | ||
<lib name="1"/> | ||
</export> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef RecoHGCal_TICL_TracksterMomentumPluginBase_H__ | ||
#define RecoHGCal_TICL_TracksterMomentumPluginBase_H__ | ||
|
||
#include "DataFormats/Candidate/interface/Candidate.h" | ||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
#include "DataFormats/CaloRecHit/interface/CaloCluster.h" | ||
#include "DataFormats/HGCalReco/interface/Trackster.h" | ||
#include "DataFormats/HGCalReco/interface/TICLCandidate.h" | ||
#include "FWCore/Framework/interface/ConsumesCollector.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/PluginManager/interface/PluginFactory.h" | ||
|
||
namespace ticl { | ||
class TracksterMomentumPluginBase { | ||
public: | ||
TracksterMomentumPluginBase(const edm::ParameterSet&, edm::ConsumesCollector&& iC) {} | ||
typedef reco::Candidate::LorentzVector LorentzVector; | ||
virtual ~TracksterMomentumPluginBase() {} | ||
virtual void setP4(const std::vector<const Trackster*>& tracksters, | ||
std::vector<TICLCandidate>& ticl_cands, | ||
edm::Event& event) const = 0; | ||
}; | ||
} // namespace ticl | ||
|
||
typedef edmplugin::PluginFactory<ticl::TracksterMomentumPluginBase*(const edm::ParameterSet&, | ||
edm::ConsumesCollector&& iC)> | ||
TracksterMomentumPluginFactory; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Base class for plugins that set the track reference(s) in the Trackster -> TICLCandidate conversion. | ||
|
||
#ifndef RecoHGCal_TICL_TracksterTrackPluginBase_H__ | ||
#define RecoHGCal_TICL_TracksterTrackPluginBase_H__ | ||
|
||
#include "DataFormats/Candidate/interface/Candidate.h" | ||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
#include "DataFormats/CaloRecHit/interface/CaloCluster.h" | ||
#include "DataFormats/HGCalReco/interface/Trackster.h" | ||
#include "DataFormats/HGCalReco/interface/TICLCandidate.h" | ||
#include "FWCore/Framework/interface/ConsumesCollector.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/PluginManager/interface/PluginFactory.h" | ||
|
||
namespace ticl { | ||
class TracksterTrackPluginBase { | ||
public: | ||
TracksterTrackPluginBase(const edm::ParameterSet&, edm::ConsumesCollector&& iC) {} | ||
typedef reco::Candidate::LorentzVector LorentzVector; | ||
virtual ~TracksterTrackPluginBase() {} | ||
virtual void setTrack(const std::vector<const Trackster*>& tracksters, | ||
std::vector<TICLCandidate>& ticl_cands, | ||
edm::Event& event) const = 0; | ||
}; | ||
} // namespace ticl | ||
|
||
typedef edmplugin::PluginFactory<ticl::TracksterTrackPluginBase*(const edm::ParameterSet&, edm::ConsumesCollector&& iC)> | ||
TracksterTrackPluginFactory; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// This producer converts a list of TICLCandidates to a list of PFCandidates. | ||
|
||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/global/EDProducer.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "DataFormats/Common/interface/View.h" | ||
|
||
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" | ||
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" | ||
|
||
#include "DataFormats/HGCalReco/interface/TICLCandidate.h" | ||
|
||
class PFTICLProducer : public edm::global::EDProducer<> { | ||
public: | ||
PFTICLProducer(const edm::ParameterSet&); | ||
~PFTICLProducer() override {} | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; | ||
|
||
private: | ||
// inputs | ||
const edm::EDGetTokenT<edm::View<TICLCandidate>> ticl_candidates_; | ||
}; | ||
|
||
DEFINE_FWK_MODULE(PFTICLProducer); | ||
|
||
PFTICLProducer::PFTICLProducer(const edm::ParameterSet& conf) | ||
: ticl_candidates_(consumes<edm::View<TICLCandidate>>(conf.getParameter<edm::InputTag>("ticlCandidateSrc"))) { | ||
produces<reco::PFCandidateCollection>(); | ||
} | ||
|
||
void PFTICLProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
desc.add<edm::InputTag>("ticlCandidateSrc", edm::InputTag("ticlCandidateFromTrackstersProducer")); | ||
descriptions.add("pfTICLProducer", desc); | ||
} | ||
|
||
void PFTICLProducer::produce(edm::StreamID, edm::Event& evt, const edm::EventSetup& es) const { | ||
//get TICLCandidates | ||
edm::Handle<edm::View<TICLCandidate>> ticl_cand_h; | ||
evt.getByToken(ticl_candidates_, ticl_cand_h); | ||
const auto ticl_candidates = *ticl_cand_h; | ||
|
||
auto candidates = std::make_unique<reco::PFCandidateCollection>(); | ||
|
||
for (const auto& ticl_cand : ticl_candidates) { | ||
const auto abs_pdg_id = std::abs(ticl_cand.pdgId()); | ||
const auto charge = ticl_cand.charge(); | ||
const auto& four_mom = ticl_cand.p4(); | ||
|
||
reco::PFCandidate::ParticleType part_type; | ||
switch (abs_pdg_id) { | ||
case 11: | ||
part_type = reco::PFCandidate::e; | ||
break; | ||
case 13: | ||
part_type = reco::PFCandidate::mu; | ||
break; | ||
case 22: | ||
part_type = reco::PFCandidate::gamma; | ||
break; | ||
case 130: | ||
part_type = reco::PFCandidate::h0; | ||
break; | ||
case 211: | ||
part_type = reco::PFCandidate::h; | ||
break; | ||
// default also handles neutral pions (111) for the time being (not yet foreseen in PFCandidate) | ||
default: | ||
part_type = reco::PFCandidate::X; | ||
} | ||
|
||
candidates->emplace_back(charge, four_mom, part_type); | ||
|
||
auto& candidate = candidates->back(); | ||
if (candidate.charge()) { // otherwise PFCandidate throws | ||
// Construct edm::Ref from edm::Ptr. As of now, assumes type to be reco::Track. To be extended (either via | ||
// dynamic type checking or configuration) if additional track types are needed. | ||
reco::TrackRef ref(ticl_cand.trackPtr().id(), int(ticl_cand.trackPtr().key()), &evt.productGetter()); | ||
candidate.setTrackRef(ref); | ||
} | ||
candidate.setTime(ticl_cand.time(), ticl_cand.timeError()); | ||
} | ||
|
||
evt.put(std::move(candidates)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.