CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
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
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Implementation of produce method.
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< pat::PackedCandidate > PackedCandidateCollection
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
fill descriptions
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
double pt() const
track transverse momentum
Definition: TrackBase.h:637
def move
Definition: eostools.py:511
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > tokenPFCandidates_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
TrackFromPackedCandidateProducer(const edm::ParameterSet &iConfig)
Constructor.