CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackInfoProducer.cc
Go to the documentation of this file.
2 // system include files
3 #include <memory>
4 // user include files
14  conf_(iConfig),
15  theAlgo_(iConfig)
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::auto_ptr<reco::TrackInfoCollection> outputColl (new reco::TrackInfoCollection);
31  std::auto_ptr<reco::TrackInfoTrackAssociationCollection> TIassociationColl (new reco::TrackInfoTrackAssociationCollection);
32 
33  edm::InputTag TkTag = conf_.getParameter<edm::InputTag>("cosmicTracks");
34 
38 
40  setup.get<TrackerDigiGeometryRecord>().get( tkgeom );
41  const TrackerGeometry * tracker=&(* tkgeom);
42 
43  theEvent.getByLabel(TkTag,TrajectoryCollection);
44  theEvent.getByLabel(TkTag,trackCollection);
45  theEvent.getByLabel(TkTag,assoMap);
46 
47  //
48  //run the algorithm
49  //
51 
52  std::vector<Trajectory>::const_iterator traj_iterator;
53  edm::LogInfo("TrackInfoProducer") << "Loop on trajectories";
54  std::map<reco::TrackRef,unsigned int> trackid;
55  int i=0;
56 
57  for(TrajTrackAssociationCollection::const_iterator it = assoMap->begin();it != assoMap->end(); ++it){
58  const edm::Ref<std::vector<Trajectory> > traj = it->key;
59  const reco::TrackRef track = it->val;
60  trackid.insert(make_pair(track,i));
61  i++;
62  theAlgo_.run(traj,track,output,tracker);
63  outputColl->push_back(*(new reco::TrackInfo(output)));
64 
65  }
66 
67 
68  //put everything in the event
70 
71 // if(forwardPredictedStateTag_!="") rTrackInfof = theEvent.put(outputFwdColl,forwardPredictedStateTag_ );
72 // if(backwardPredictedStateTag_!="") rTrackInfob = theEvent.put(outputBwdColl,backwardPredictedStateTag_);
73 // if(updatedStateTag_!="") rTrackInfou = theEvent.put(outputUpdatedColl,updatedStateTag_ );
74 // if(combinedStateTag_!="") rTrackInfoc = theEvent.put(outputCombinedColl,combinedStateTag_ );
75  rTrackInfo=theEvent.put(outputColl);
76 
77  for(std::map<reco::TrackRef,unsigned int>::iterator ref_iter=trackid.begin();ref_iter!=trackid.end();ref_iter++){
78 
79  TIassociationColl->insert( ref_iter->first,edm::Ref<reco::TrackInfoCollection>(rTrackInfo,ref_iter->second ));
80  }
81 
82  theEvent.put(TIassociationColl);
83 }
84 
85 
86 
87 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
TrackInfoProducer(const edm::ParameterSet &iConfig)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual void produce(edm::Event &, const edm::EventSetup &)
std::vector< TrackInfo > TrackInfoCollection
collection of TrackInfos
Definition: TrackInfoFwd.h:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
TrackInfoProducerAlgorithm theAlgo_
edm::ParameterSet conf_
const T & get() const
Definition: EventSetup.h:55
key_type key() const
Accessor for product key.
Definition: Ref.h:266
std::vector< Trajectory > TrajectoryCollection
void run(const edm::Ref< std::vector< Trajectory > > traj_iterator, reco::TrackRef track, reco::TrackInfo &output, const TrackerGeometry *tracker)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")