CMS 3D CMS Logo

FastTrackerRecHitCombiner.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // frame work stuff
11 
12 // specific for this producer
17 
23 
25 public:
27  ~FastTrackerRecHitCombiner() override { ; }
28 
29  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
30 
31 private:
32  void beginStream(edm::StreamID) override { ; }
33  void produce(edm::Event&, const edm::EventSetup&) override;
34  void endStream() override { ; }
35 
36  // ----------member data ---------------------------
39  unsigned int minNHits;
40 };
41 
43  : simHitsToken(consumes<edm::PSimHitContainer>(iConfig.getParameter<edm::InputTag>("simHits"))),
44  simHit2RecHitMapToken(
45  consumes<FastTrackerRecHitRefCollection>(iConfig.getParameter<edm::InputTag>("simHit2RecHitMap"))),
46  minNHits(iConfig.getParameter<unsigned int>("minNHits")) {
47  produces<FastTrackerRecHitCombinationCollection>();
48 }
49 
51  // input
53  iEvent.getByToken(simHitsToken, simHits);
54 
57 
58  // output
59  std::unique_ptr<FastTrackerRecHitCombinationCollection> output(new FastTrackerRecHitCombinationCollection);
60 
61  FastTrackerRecHitCombination currentCombination;
62  for (unsigned int simHitCounter = 0; simHitCounter < simHits->size(); simHitCounter++) {
63  // get simHit and recHit
64  const PSimHit& simHit = (*simHits)[simHitCounter];
65  const FastTrackerRecHitRef& recHit = (*simHit2RecHitMap)[simHitCounter];
66 
67  // add recHit to latest combination
68  if (!recHit.isNull())
69  currentCombination.push_back(recHit);
70 
71  // if simTrackId is about to change, add combination
72  if (simHits->size() - simHitCounter == 1 || simHit.trackId() != (*simHits)[simHitCounter + 1].trackId()) {
73  // combination must have sufficient hits
74  if (currentCombination.size() >= minNHits) {
75  currentCombination.shrink_to_fit();
76  output->push_back(currentCombination);
77  }
78  currentCombination.clear();
79  }
80  }
81 
82  // put output in event
83  iEvent.put(std::move(output));
84 }
85 
86 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
88  //The following says we do not know what parameters are allowed so do no validation
89  // Please change this to state exactly what you do use, even if it is no parameters
91  desc.setUnknown();
92  descriptions.addDefault(desc);
93 }
94 
95 //define this as a plug-in
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginStream(edm::StreamID) override
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< FastTrackerRecHitRefCollection > simHit2RecHitMapToken
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
FastTrackerRecHitCombiner(const edm::ParameterSet &)
std::vector< FastTrackerRecHitRef > FastTrackerRecHitCombination
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< FastTrackerRecHitRef > FastTrackerRecHitRefCollection
HLT enums.
std::vector< FastTrackerRecHitCombination > FastTrackerRecHitCombinationCollection
edm::EDGetTokenT< edm::PSimHitContainer > simHitsToken
std::vector< PSimHit > PSimHitContainer
Definition: output.py:1
def move(src, dest)
Definition: eostools.py:511