CMS 3D CMS Logo

TrackInfoProducer.cc
Go to the documentation of this file.
1 //
2 // Package: RecoTracker/TrackInfoProducer
3 // Class: TrackInfoProducer
4 //
5 //
6 // Description: Produce TrackInfo from Trajectory
7 //
8 //
9 // Original Author: Chiara Genta
10 // Created:
11 //
12 
13 // system include files
14 #include <memory>
15 
16 // user include files
31 
33 public:
34  explicit TrackInfoProducer(const edm::ParameterSet& iConfig);
35 
36  ~TrackInfoProducer() override{};
37 
38  void produce(edm::Event&, const edm::EventSetup&) override;
39 
40 private:
47 };
48 
50  : tkGeomToken_(esConsumes()),
51  theAlgo_(iConfig),
52  TrajectoryToken_(consumes<std::vector<Trajectory> >(iConfig.getParameter<edm::InputTag>("cosmicTracks"))),
53  trackCollectionToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("cosmicTracks"))),
54  assoMapToken_(consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("cosmicTracks"))) {
55  produces<reco::TrackInfoCollection>();
56  produces<reco::TrackInfoTrackAssociationCollection>();
57 }
58 
60  //
61  // create empty output collections
62  //
63  std::unique_ptr<reco::TrackInfoCollection> outputColl(new reco::TrackInfoCollection);
64 
65  const TrackerGeometry* tracker = &setup.getData(tkGeomToken_);
66 
70 
73  theEvent.getByToken(assoMapToken_, assoMap);
74 
75  //
76  //run the algorithm
77  //
79 
80  edm::LogInfo("TrackInfoProducer") << "Loop on trajectories";
81  std::map<reco::TrackRef, unsigned int> trackid;
82  int i = 0;
83 
84  for (TrajTrackAssociationCollection::const_iterator it = assoMap->begin(); it != assoMap->end(); ++it) {
85  const edm::Ref<std::vector<Trajectory> > traj = it->key;
86  const reco::TrackRef track = it->val;
87  trackid.insert(make_pair(track, i));
88  i++;
89  theAlgo_.run(traj, track, output, tracker);
90  outputColl->push_back(output);
91  }
92 
93  //put everything in the event
95 
96  // if(forwardPredictedStateTag_!="") rTrackInfof = theEvent.put(std::move(outputFwdColl),forwardPredictedStateTag_ );
97  // if(backwardPredictedStateTag_!="") rTrackInfob = theEvent.put(std::move(outputBwdColl),backwardPredictedStateTag_);
98  // if(updatedStateTag_!="") rTrackInfou = theEvent.put(std::move(outputUpdatedColl),updatedStateTag_ );
99  // if(combinedStateTag_!="") rTrackInfoc = theEvent.put(std::move(outputCombinedColl),combinedStateTag_ );
100  rTrackInfo = theEvent.put(std::move(outputColl));
101  std::unique_ptr<reco::TrackInfoTrackAssociationCollection> TIassociationColl(
102  new reco::TrackInfoTrackAssociationCollection(assoMap->refProd().val, rTrackInfo));
103 
104  for (std::map<reco::TrackRef, unsigned int>::iterator ref_iter = trackid.begin(); ref_iter != trackid.end();
105  ++ref_iter) {
106  TIassociationColl->insert(ref_iter->first, edm::Ref<reco::TrackInfoCollection>(rTrackInfo, ref_iter->second));
107  }
108 
109  theEvent.put(std::move(TIassociationColl));
110 }
111 
~TrackInfoProducer() override
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::EDGetTokenT< TrajTrackAssociationCollection > assoMapToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
TrackInfoProducer(const edm::ParameterSet &iConfig)
void produce(edm::Event &, const edm::EventSetup &) override
std::string updatedStateTag_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:536
const ref_type & refProd() const
return ref-prod structure
edm::EDGetTokenT< std::vector< Trajectory > > TrajectoryToken_
key_type key() const
Accessor for product key.
Definition: Ref.h:250
const_iterator end() const
last iterator over the map (read only)
std::string forwardPredictedStateTag_
std::string combinedStateTag_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< TrackInfo > TrackInfoCollection
collection of TrackInfos
Definition: TrackInfoFwd.h:9
trackCollection
Definition: JetHT_cfg.py:51
std::string backwardPredictedStateTag_
Log< level::Info, false > LogInfo
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
TrackInfoProducerAlgorithm theAlgo_
const_iterator begin() const
first iterator over the map (read only)
fixed size matrix
HLT enums.
void run(const edm::Ref< std::vector< Trajectory > > traj_iterator, reco::TrackRef track, reco::TrackInfo &output, const TrackerGeometry *tracker)
std::vector< Trajectory > TrajectoryCollection
edm::EDGetTokenT< reco::TrackCollection > trackCollectionToken_
def move(src, dest)
Definition: eostools.py:511