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("ticlCandidateFromTrackstersProducer"));
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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
ParticleType
particle types
Definition: PFCandidate.h:43
~PFTICLProducer() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
EDProductGetter const & productGetter() const
Definition: Event.cc:102
PFTICLProducer(const edm::ParameterSet &)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< edm::View< TICLCandidate > > ticl_candidates_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
def move(src, dest)
Definition: eostools.py:511