test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
16 
18  public:
19 
22 
23  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
24 
25  private:
26 
27  virtual void beginStream(edm::StreamID) override{;}
28  virtual void produce(edm::Event&, const edm::EventSetup&) override;
29  virtual void endStream() override{;}
30 
31  // ----------member data ---------------------------
34  unsigned int minNHits;
35 };
36 
37 
39  : simHitsToken(consumes<edm::PSimHitContainer>(iConfig.getParameter<edm::InputTag>("simHits")))
40  , simHit2RecHitMapToken(consumes<FastTrackerRecHitRefCollection>(iConfig.getParameter<edm::InputTag>("simHit2RecHitMap")))
41  , minNHits(iConfig.getParameter<unsigned int>("minNHits"))
42 {
43  produces<FastTrackerRecHitCombinationCollection>();
44 }
45 
46 
47 void
49 {
50 
51  // input
53  iEvent.getByToken(simHitsToken,simHits);
54 
56  iEvent.getByToken(simHit2RecHitMapToken,simHit2RecHitMap);
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 
64  // get simHit and recHit
65  const PSimHit & simHit = (*simHits)[simHitCounter];
66  const FastTrackerRecHitRef & recHit = (*simHit2RecHitMap)[simHitCounter];
67 
68  // add recHit to latest combination
69  if(!recHit.isNull())
70  currentCombination.push_back(recHit);
71 
72  // if simTrackId is about to change, add combination
73  if(simHits->size()-simHitCounter == 1 || simHit.trackId() != (*simHits)[simHitCounter+1].trackId() ){
74  // combination must have sufficient hits
75  if(currentCombination.size() >= minNHits){
76  currentCombination.shrink_to_fit();
77  output->push_back(currentCombination);
78  }
79  currentCombination.clear();
80  }
81  }
82 
83  // put output in event
84  iEvent.put(std::move(output));
85 }
86 
87 
88 
89 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
91  //The following says we do not know what parameters are allowed so do no validation
92  // Please change this to state exactly what you do use, even if it is no parameters
94  desc.setUnknown();
95  descriptions.addDefault(desc);
96 }
97 
98 //define this as a plug-in
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void endStream() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< FastTrackerRecHitRefCollection > simHit2RecHitMapToken
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
def move
Definition: eostools.py:510
FastTrackerRecHitCombiner(const edm::ParameterSet &)
bool isNull() const
Checks for null.
Definition: Ref.h:249
std::vector< FastTrackerRecHitRef > FastTrackerRecHitCombination
tuple simHits
Definition: trackerHits.py:16
virtual void produce(edm::Event &, const edm::EventSetup &) override
virtual void beginStream(edm::StreamID) override
std::vector< FastTrackerRecHitRef > FastTrackerRecHitRefCollection
std::vector< FastTrackerRecHitCombination > FastTrackerRecHitCombinationCollection
edm::EDGetTokenT< edm::PSimHitContainer > simHitsToken
unsigned int trackId() const
Definition: PSimHit.h:102
std::vector< PSimHit > PSimHitContainer