-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
TrackInfoProducer.cc
85 lines (63 loc) · 3.36 KB
/
TrackInfoProducer.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "AnalysisAlgos/TrackInfoProducer/interface/TrackInfoProducer.h"
// system include files
#include <memory>
// user include files
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "AnalysisDataFormats/TrackInfo/interface/TrackInfo.h"
#include "AnalysisDataFormats/TrackInfo/interface/TrackInfoTrackAssociation.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
TrackInfoProducer::TrackInfoProducer(const edm::ParameterSet& iConfig):
theAlgo_(iConfig),
TrajectoryToken_(consumes<std::vector<Trajectory> >(iConfig.getParameter<edm::InputTag>("cosmicTracks"))),
trackCollectionToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("cosmicTracks"))),
assoMapToken_(consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("cosmicTracks")))
{
produces<reco::TrackInfoCollection>();
produces<reco::TrackInfoTrackAssociationCollection>();
}
void TrackInfoProducer::produce(edm::Event& theEvent, const edm::EventSetup& setup)
{
//
// create empty output collections
//
std::unique_ptr<reco::TrackInfoCollection> outputColl (new reco::TrackInfoCollection);
edm::Handle<std::vector<Trajectory> > TrajectoryCollection;
edm::Handle<reco::TrackCollection > trackCollection;
edm::Handle<TrajTrackAssociationCollection> assoMap;
edm::ESHandle<TrackerGeometry> tkgeom;
setup.get<TrackerDigiGeometryRecord>().get( tkgeom );
const TrackerGeometry * tracker=&(* tkgeom);
theEvent.getByToken(TrajectoryToken_,TrajectoryCollection);
theEvent.getByToken(trackCollectionToken_,trackCollection);
theEvent.getByToken(assoMapToken_,assoMap);
//
//run the algorithm
//
reco::TrackInfo output;
std::vector<Trajectory>::const_iterator traj_iterator;
edm::LogInfo("TrackInfoProducer") << "Loop on trajectories";
std::map<reco::TrackRef,unsigned int> trackid;
int i=0;
for(TrajTrackAssociationCollection::const_iterator it = assoMap->begin();it != assoMap->end(); ++it){
const edm::Ref<std::vector<Trajectory> > traj = it->key;
const reco::TrackRef track = it->val;
trackid.insert(make_pair(track,i));
i++;
theAlgo_.run(traj,track,output,tracker);
outputColl->push_back(*(new reco::TrackInfo(output)));
}
//put everything in the event
edm::OrphanHandle<reco::TrackInfoCollection> rTrackInfo;
// if(forwardPredictedStateTag_!="") rTrackInfof = theEvent.put(std::move(outputFwdColl),forwardPredictedStateTag_ );
// if(backwardPredictedStateTag_!="") rTrackInfob = theEvent.put(std::move(outputBwdColl),backwardPredictedStateTag_);
// if(updatedStateTag_!="") rTrackInfou = theEvent.put(std::move(outputUpdatedColl),updatedStateTag_ );
// if(combinedStateTag_!="") rTrackInfoc = theEvent.put(std::move(outputCombinedColl),combinedStateTag_ );
rTrackInfo=theEvent.put(std::move(outputColl));
std::unique_ptr<reco::TrackInfoTrackAssociationCollection> TIassociationColl (new reco::TrackInfoTrackAssociationCollection(assoMap->refProd().val, rTrackInfo));
for(std::map<reco::TrackRef,unsigned int>::iterator ref_iter=trackid.begin();ref_iter!=trackid.end();++ref_iter){
TIassociationColl->insert( ref_iter->first,edm::Ref<reco::TrackInfoCollection>(rTrackInfo,ref_iter->second ));
}
theEvent.put(std::move(TIassociationColl));
}