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:
26 
29 
30  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
31 
32  private:
33 
34  void beginStream(edm::StreamID) override{;}
35  void produce(edm::Event&, const edm::EventSetup&) override;
36  void endStream() override{;}
37 
38  // ----------member data ---------------------------
41  unsigned int minNHits;
42 };
43 
44 
46  : simHitsToken(consumes<edm::PSimHitContainer>(iConfig.getParameter<edm::InputTag>("simHits")))
47  , simHit2RecHitMapToken(consumes<FastTrackerRecHitRefCollection>(iConfig.getParameter<edm::InputTag>("simHit2RecHitMap")))
48  , minNHits(iConfig.getParameter<unsigned int>("minNHits"))
49 {
50  produces<FastTrackerRecHitCombinationCollection>();
51 }
52 
53 
54 void
56 {
57 
58  // input
60  iEvent.getByToken(simHitsToken,simHits);
61 
63  iEvent.getByToken(simHit2RecHitMapToken,simHit2RecHitMap);
64 
65  // output
66  std::unique_ptr<FastTrackerRecHitCombinationCollection> output(new FastTrackerRecHitCombinationCollection);
67 
68  FastTrackerRecHitCombination currentCombination;
69  for(unsigned int simHitCounter = 0;simHitCounter < simHits->size();simHitCounter++){
70 
71  // get simHit and recHit
72  const PSimHit & simHit = (*simHits)[simHitCounter];
73  const FastTrackerRecHitRef & recHit = (*simHit2RecHitMap)[simHitCounter];
74 
75  // add recHit to latest combination
76  if(!recHit.isNull())
77  currentCombination.push_back(recHit);
78 
79  // if simTrackId is about to change, add combination
80  if(simHits->size()-simHitCounter == 1 || simHit.trackId() != (*simHits)[simHitCounter+1].trackId() ){
81  // combination must have sufficient hits
82  if(currentCombination.size() >= minNHits){
83  currentCombination.shrink_to_fit();
84  output->push_back(currentCombination);
85  }
86  currentCombination.clear();
87  }
88  }
89 
90  // put output in event
91  iEvent.put(std::move(output));
92 }
93 
94 
95 
96 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
98  //The following says we do not know what parameters are allowed so do no validation
99  // Please change this to state exactly what you do use, even if it is no parameters
101  desc.setUnknown();
102  descriptions.addDefault(desc);
103 }
104 
105 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void beginStream(edm::StreamID) override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< FastTrackerRecHitRefCollection > simHit2RecHitMapToken
FastTrackerRecHitCombiner(const edm::ParameterSet &)
bool isNull() const
Checks for null.
Definition: Ref.h:248
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
unsigned int trackId() const
Definition: PSimHit.h:106
std::vector< PSimHit > PSimHitContainer
def move(src, dest)
Definition: eostools.py:511