CMS 3D CMS Logo

PFTICLProducer.cc
Go to the documentation of this file.
1 // This producer converts a list of TICLCandidates to a list of PFCandidates.
2 
5 
8 
10 
13 
15 
17 public:
19  ~PFTICLProducer() override {}
20 
21  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
22 
23  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
24 
25 private:
26  // inputs
28 };
29 
31 
33  : ticl_candidates_(consumes<edm::View<TICLCandidate>>(conf.getParameter<edm::InputTag>("ticlCandidateSrc"))) {
34  produces<reco::PFCandidateCollection>();
35 }
36 
39  desc.add<edm::InputTag>("ticlCandidateSrc", edm::InputTag("ticlCandidateFromTracksters"));
40  descriptions.add("pfTICLProducer", desc);
41 }
42 
44  //get TICLCandidates
46  evt.getByToken(ticl_candidates_, ticl_cand_h);
47  const auto ticl_candidates = *ticl_cand_h;
48 
49  auto candidates = std::make_unique<reco::PFCandidateCollection>();
50 
51  for (const auto& ticl_cand : ticl_candidates) {
52  const auto abs_pdg_id = std::abs(ticl_cand.pdgId());
53  const auto charge = ticl_cand.charge();
54  const auto& four_mom = ticl_cand.p4();
55 
57  switch (abs_pdg_id) {
58  case 11:
59  part_type = reco::PFCandidate::e;
60  break;
61  case 13:
62  part_type = reco::PFCandidate::mu;
63  break;
64  case 22:
65  part_type = reco::PFCandidate::gamma;
66  break;
67  case 130:
68  part_type = reco::PFCandidate::h0;
69  break;
70  case 211:
71  part_type = reco::PFCandidate::h;
72  break;
73  // default also handles neutral pions (111) for the time being (not yet foreseen in PFCandidate)
74  default:
75  part_type = reco::PFCandidate::X;
76  }
77 
78  candidates->emplace_back(charge, four_mom, part_type);
79 
80  auto& candidate = candidates->back();
81  if (candidate.charge()) { // otherwise PFCandidate throws
82  // Construct edm::Ref from edm::Ptr. As of now, assumes type to be reco::Track. To be extended (either via
83  // dynamic type checking or configuration) if additional track types are needed.
84  reco::TrackRef ref(ticl_cand.trackPtr().id(), int(ticl_cand.trackPtr().key()), &evt.productGetter());
85  candidate.setTrackRef(ref);
86  }
87  candidate.setTime(ticl_cand.time(), ticl_cand.timeError());
88  }
89 
90  evt.put(std::move(candidates));
91 }
edm::StreamID
Definition: StreamID.h:30
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
reco::PFCandidate::e
Definition: PFCandidate.h:46
sistrip::View
View
Definition: ConstantsForView.h:26
PFCandidate.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Event::productGetter
EDProductGetter const & productGetter() const
Definition: Event.cc:101
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PFTICLProducer::PFTICLProducer
PFTICLProducer(const edm::ParameterSet &)
Definition: PFTICLProducer.cc:32
reco::PFCandidate::h
Definition: PFCandidate.h:45
edm::Handle
Definition: AssociativeIterator.h:50
reco::PFCandidate::X
Definition: PFCandidate.h:44
edm::Ref< TrackCollection >
MakerMacros.h
PFTICLProducer::ticl_candidates_
const edm::EDGetTokenT< edm::View< TICLCandidate > > ticl_candidates_
Definition: PFTICLProducer.cc:27
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::PFCandidate::mu
Definition: PFCandidate.h:47
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
TICLCandidate.h
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
createfilelist.int
int
Definition: createfilelist.py:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
reco::PFCandidate::gamma
Definition: PFCandidate.h:48
edm::EventSetup
Definition: EventSetup.h:57
TICLCandidate
Definition: TICLCandidate.h:13
PFTICLProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: PFTICLProducer.cc:43
PFTICLProducer
Definition: PFTICLProducer.cc:16
PFTICLProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFTICLProducer.cc:37
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
HLT_2018_cff.candidates
candidates
Definition: HLT_2018_cff.py:53513
reco::PFCandidate::h0
Definition: PFCandidate.h:49
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
View.h
EDProducer.h
reco::PFCandidate::ParticleType
ParticleType
particle types
Definition: PFCandidate.h:43
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
PFTICLProducer::~PFTICLProducer
~PFTICLProducer() override
Definition: PFTICLProducer.cc:19
PFCandidateFwd.h