CMS 3D CMS Logo

AlcaRecoTrackSelector.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <algorithm>
4 
5 // user include files
19 
20 // class declaration
22 public:
24  ~AlcaRecoTrackSelector() override = default;
25  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
26 
27 private:
28  void produce(edm::StreamID streamID, edm::Event& iEvent, edm::EventSetup const& iSetup) const override;
29 
32  const double ptmin_;
33  const double pmin_;
34  const double etamin_;
35  const double etamax_;
36  const int nhits_;
37 };
38 
41  desc.addUntracked<edm::InputTag>("trackInputTag", edm::InputTag("generalTracks"));
42  desc.addUntracked<double>("ptmin", 0.);
43  desc.addUntracked<double>("pmin", 0.);
44  desc.addUntracked<double>("etamin", -4.);
45  desc.addUntracked<double>("etamax", 4.);
46  desc.addUntracked<unsigned int>("nhits", 1);
47  descriptions.addWithDefaultLabel(desc);
48 }
49 
51  : tracksTag_(ps.getUntrackedParameter<edm::InputTag>("trackInputTag", edm::InputTag("generalTracks"))),
52  tracksToken_(consumes<reco::TrackCollection>(tracksTag_)),
53  ptmin_(ps.getUntrackedParameter<double>("ptmin", 0.)),
54  pmin_(ps.getUntrackedParameter<double>("pmin", 0.)),
55  etamin_(ps.getUntrackedParameter<double>("etamin", -4.)),
56  etamax_(ps.getUntrackedParameter<double>("etamax", 4.)),
57  nhits_(ps.getUntrackedParameter<uint32_t>("nhits", 1)) {
58  produces<reco::TrackCollection>("");
59 }
60 
62  std::unique_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection());
63 
64  // Read Track collection
66  iEvent.getByToken(tracksToken_, tracks);
67 
68  if (tracks.isValid()) {
69  for (auto const& trk : *tracks) {
70  if (trk.pt() < ptmin_)
71  continue;
72  if (trk.p() < pmin_)
73  continue;
74  if (trk.eta() < etamin_)
75  continue;
76  if (trk.eta() > etamax_)
77  continue;
78  if (trk.hitPattern().numberOfAllHits(reco::HitPattern::TRACK_HITS) <= nhits_)
79  continue;
80  outputTColl->push_back(trk);
81  }
82  } else {
83  edm::LogError("AlcaRecoTrackSelector") << "Error >> Failed to get AlcaRecoTrackSelector for label: " << tracksTag_;
84  }
85  iEvent.put(std::move(outputTColl));
86 }
87 
88 // Define this as a plug-in
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
Log< level::Error, false > LogError
void produce(edm::StreamID streamID, edm::Event &iEvent, edm::EventSetup const &iSetup) const override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< reco::TrackCollection > tracksToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::InputTag tracksTag_
~AlcaRecoTrackSelector() override=default
AlcaRecoTrackSelector(const edm::ParameterSet &)
fixed size matrix
HLT enums.
def move(src, dest)
Definition: eostools.py:511