CMS 3D CMS Logo

TrackFromPackedCandidateProducer.cc
Go to the documentation of this file.
1 
5 //
6 // Original Author: Olga Kodolova,40 R-A12,+41227671273,
7 // Created: Fri Feb 19 10:14:02 CET 2010
8 //
9 //
10 
11 // system include files
12 #include <memory>
13 // user include files
25 
27 public:
29  explicit TrackFromPackedCandidateProducer(const edm::ParameterSet& iConfig);
30 
32  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
33 
35  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
36 
37 private:
39 };
40 
42  : tokenPFCandidates_(
43  consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("PFCandidates"))) {
44  produces<reco::TrackCollection>();
45 }
46 
49  desc.add<edm::InputTag>("PFCandidates");
50  iDescriptions.addWithDefaultLabel(desc);
51 }
52 
54  edm::Event& theEvent,
55  const edm::EventSetup& setup) const {
56  //
57  // create empty output collections
58  //
59  auto outputTColl = std::make_unique<reco::TrackCollection>();
60  auto const pfCandidates = theEvent.get(tokenPFCandidates_);
61  outputTColl->reserve(pfCandidates.size());
62 
63  for (auto const& pf : pfCandidates) {
64  if (pf.hasTrackDetails()) {
65  const reco::Track& mytrack = pf.pseudoTrack();
66  using namespace edm;
67  if (isNotFinite(mytrack.pt()) || isNotFinite(mytrack.eta()) || isNotFinite(mytrack.phi()))
68  continue;
69  outputTColl->push_back(mytrack);
70  }
71  }
72  //put everything in the event
73  theEvent.put(std::move(outputTColl));
74 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:347
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Implementation of produce method.
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
std::vector< pat::PackedCandidate > PackedCandidateCollection
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
fill descriptions
Definition: HeavyIon.h:7
double pt() const
track transverse momentum
Definition: TrackBase.h:637
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > tokenPFCandidates_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
HLT enums.
TrackFromPackedCandidateProducer(const edm::ParameterSet &iConfig)
Constructor.
def move(src, dest)
Definition: eostools.py:511