CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimTrackIdProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FastSimulation/SimTrackIdProducer
4 // Class: SimTrackIdProducer
5 //
11 //
12 // Original Author: Vilius Kripas
13 // Created: Fri, 24 Oct 2014 09:47:25 GMT
14 //
15 //
16 #include <memory>
27 #include <vector>
28 #include <stdio.h>
29 
31 {
32  //Main products
33  produces<std::vector<int> >();
34 
35  // Input Tag
36  edm::InputTag trackCollectionTag = conf.getParameter<edm::InputTag>("trackCollection");
37 
38  // consumes
39  trackToken = consumes<reco::TrackCollection>(trackCollectionTag);
40 }
41 
42 void
44 {
45  // The produced object
46  std::auto_ptr<std::vector<int> > SimTrackIds(new std::vector<int>());
47 
48  // The input track collection handle
50  e.getByToken(trackToken,trackCollection);
51 
52  reco::TrackCollection::const_iterator aTrack = trackCollection->begin();
53  reco::TrackCollection::const_iterator lastTrack = trackCollection->end();
54  bool index = 0;
55 
56  for ( ; aTrack!=lastTrack; ++aTrack,++index ) {
57  int SimTrackId = -1;
58  for( trackingRecHit_iterator hit = aTrack->recHitsBegin(); hit != aTrack->recHitsEnd(); ++ hit ) {
59  // const SiTrackerGSMatchedRecHit2D * rechit = (const SiTrackerGSMatchedRecHit2D*) (hit->get());
60  const SiTrackerGSMatchedRecHit2D * rechit = (const SiTrackerGSMatchedRecHit2D*) (*hit);
61  SimTrackId = rechit->simtrackId();
62  break;
63  }
64  SimTrackIds->push_back(SimTrackId);
65 
66  }
67  e.put(SimTrackIds);
68 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > trackToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
std::vector< int > SimTrackIds
virtual void produce(edm::Event &e, const edm::EventSetup &es) override
SimTrackIdProducer(const edm::ParameterSet &conf)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
tuple conf
Definition: dbtoconf.py:185
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection