CMS 3D CMS Logo

TrackInfoProducer.cc
Go to the documentation of this file.
2 // system include files
3 #include <memory>
4 // user include files
12  theAlgo_(iConfig),
13  TrajectoryToken_(consumes<std::vector<Trajectory> >(iConfig.getParameter<edm::InputTag>("cosmicTracks"))),
14  trackCollectionToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("cosmicTracks"))),
15  assoMapToken_(consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("cosmicTracks")))
16 {
17  produces<reco::TrackInfoCollection>();
18  produces<reco::TrackInfoTrackAssociationCollection>();
19 
20 
21 }
22 
23 
25 {
26  //
27  // create empty output collections
28  //
29 
30  std::unique_ptr<reco::TrackInfoCollection> outputColl (new reco::TrackInfoCollection);
31 
35 
37  setup.get<TrackerDigiGeometryRecord>().get( tkgeom );
38  const TrackerGeometry * tracker=&(* tkgeom);
39 
40  theEvent.getByToken(TrajectoryToken_,TrajectoryCollection);
41  theEvent.getByToken(trackCollectionToken_,trackCollection);
42  theEvent.getByToken(assoMapToken_,assoMap);
43 
44  //
45  //run the algorithm
46  //
48 
49  std::vector<Trajectory>::const_iterator traj_iterator;
50  edm::LogInfo("TrackInfoProducer") << "Loop on trajectories";
51  std::map<reco::TrackRef,unsigned int> trackid;
52  int i=0;
53 
54  for(TrajTrackAssociationCollection::const_iterator it = assoMap->begin();it != assoMap->end(); ++it){
55  const edm::Ref<std::vector<Trajectory> > traj = it->key;
56  const reco::TrackRef track = it->val;
57  trackid.insert(make_pair(track,i));
58  i++;
59  theAlgo_.run(traj,track,output,tracker);
60  outputColl->push_back(*(new reco::TrackInfo(output)));
61 
62  }
63 
64 
65  //put everything in the event
67 
68 // if(forwardPredictedStateTag_!="") rTrackInfof = theEvent.put(std::move(outputFwdColl),forwardPredictedStateTag_ );
69 // if(backwardPredictedStateTag_!="") rTrackInfob = theEvent.put(std::move(outputBwdColl),backwardPredictedStateTag_);
70 // if(updatedStateTag_!="") rTrackInfou = theEvent.put(std::move(outputUpdatedColl),updatedStateTag_ );
71 // if(combinedStateTag_!="") rTrackInfoc = theEvent.put(std::move(outputCombinedColl),combinedStateTag_ );
72  rTrackInfo=theEvent.put(std::move(outputColl));
73  std::unique_ptr<reco::TrackInfoTrackAssociationCollection> TIassociationColl (new reco::TrackInfoTrackAssociationCollection(assoMap->refProd().val, rTrackInfo));
74 
75  for(std::map<reco::TrackRef,unsigned int>::iterator ref_iter=trackid.begin();ref_iter!=trackid.end();++ref_iter){
76 
77  TIassociationColl->insert( ref_iter->first,edm::Ref<reco::TrackInfoCollection>(rTrackInfo,ref_iter->second ));
78  }
79 
80  theEvent.put(std::move(TIassociationColl));
81 }
82 
83 
84 
85 
edm::EDGetTokenT< TrajTrackAssociationCollection > assoMapToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
TrackInfoProducer(const edm::ParameterSet &iConfig)
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
key_type key() const
Accessor for product key.
Definition: Ref.h:265
edm::EDGetTokenT< std::vector< Trajectory > > TrajectoryToken_
const ref_type & refProd() const
return ref-prod structure
virtual void produce(edm::Event &, const edm::EventSetup &)
std::vector< TrackInfo > TrackInfoCollection
collection of TrackInfos
Definition: TrackInfoFwd.h:9
TrackInfoProducerAlgorithm theAlgo_
const T & get() const
Definition: EventSetup.h:55
std::vector< Trajectory > TrajectoryCollection
fixed size matrix
HLT enums.
void run(const edm::Ref< std::vector< Trajectory > > traj_iterator, reco::TrackRef track, reco::TrackInfo &output, const TrackerGeometry *tracker)
const_iterator begin() const
first iterator over the map (read only)
edm::EDGetTokenT< reco::TrackCollection > trackCollectionToken_
def move(src, dest)
Definition: eostools.py:510