#include <RecoTracker/DebugTools/plugins/TrackAlgoCompareUtil.h>
Public Member Functions | |
TrackAlgoCompareUtil (const edm::ParameterSet &) | |
~TrackAlgoCompareUtil () | |
Private Member Functions | |
virtual void | beginJob (const edm::EventSetup &) |
virtual void | endJob () |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
void | SetTrackingParticleD0Dz (TrackingParticleRef tp, const reco::BeamSpot &bs, const MagneticField *bf, RecoTracktoTP &RTTP) |
void | SetTrackingParticleD0Dz (TrackingParticleRef tp, const reco::BeamSpot &bs, const MagneticField *bf, TPtoRecoTrack &TPRT) |
Private Attributes | |
edm::InputTag | associatormap_algoA |
edm::InputTag | associatormap_algoB |
std::string | assocLabel |
edm::InputTag | beamSpotLabel |
edm::InputTag | trackingParticleLabel_effic |
edm::InputTag | trackingParticleLabel_fakes |
edm::InputTag | trackingVertexLabel |
edm::InputTag | trackLabel_algoA |
edm::InputTag | trackLabel_algoB |
bool | UseAssociators |
edm::InputTag | vertexLabel_algoA |
edm::InputTag | vertexLabel_algoB |
Definition at line 57 of file TrackAlgoCompareUtil.h.
TrackAlgoCompareUtil::TrackAlgoCompareUtil | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 8 of file TrackAlgoCompareUtil.cc.
References associatormap_algoA, associatormap_algoB, assocLabel, beamSpotLabel, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), trackingParticleLabel_effic, trackingParticleLabel_fakes, trackLabel_algoA, trackLabel_algoB, UseAssociators, vertexLabel_algoA, and vertexLabel_algoB.
00009 { 00010 //now do what ever other initialization is needed 00011 trackLabel_algoA = iConfig.getParameter<edm::InputTag>("trackLabel_algoA"); 00012 trackLabel_algoB = iConfig.getParameter<edm::InputTag>("trackLabel_algoB"); 00013 trackingParticleLabel_fakes = iConfig.getParameter<edm::InputTag>("trackingParticleLabel_fakes"); 00014 trackingParticleLabel_effic = iConfig.getParameter<edm::InputTag>("trackingParticleLabel_effic"); 00015 vertexLabel_algoA = iConfig.getParameter<edm::InputTag>("vertexLabel_algoA"); 00016 vertexLabel_algoB = iConfig.getParameter<edm::InputTag>("vertexLabel_algoB"); 00017 beamSpotLabel = iConfig.getParameter<edm::InputTag>("beamSpotLabel"); 00018 assocLabel = iConfig.getUntrackedParameter<std::string>("assocLabel", "TrackAssociator"); 00019 associatormap_algoA = iConfig.getParameter< edm::InputTag >("associatormap_algoA"); 00020 associatormap_algoB = iConfig.getParameter< edm::InputTag >("associatormap_algoB"); 00021 UseAssociators = iConfig.getParameter< bool >("UseAssociators"); 00022 00023 produces<RecoTracktoTPCollection>("AlgoA"); 00024 produces<RecoTracktoTPCollection>("AlgoB"); 00025 produces<TPtoRecoTrackCollection>("TP"); 00026 }
TrackAlgoCompareUtil::~TrackAlgoCompareUtil | ( | ) |
void TrackAlgoCompareUtil::beginJob | ( | const edm::EventSetup & | ) | [private, virtual] |
void TrackAlgoCompareUtil::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 42 of file TrackAlgoCompareUtil.cc.
References associatormap_algoA, associatormap_algoB, assocLabel, beamSpotLabel, edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), edm::EventSetup::get(), edm::Event::getByLabel(), i, reco::BeamSpot::position(), edm::ESHandle< T >::product(), edm::Handle< T >::product(), edm::Event::put(), RecoTracktoTP::SetBeamSpot(), TPtoRecoTrack::SetBeamSpot(), RecoTracktoTP::SetRecoTrack(), TPtoRecoTrack::SetRecoTrack_AlgoA(), TPtoRecoTrack::SetRecoTrack_AlgoB(), RecoTracktoTP::SetRecoVertex(), TPtoRecoTrack::SetRecoVertex_AlgoA(), TPtoRecoTrack::SetRecoVertex_AlgoB(), RecoTracktoTP::SetTrackingParticle(), TPtoRecoTrack::SetTrackingParticle(), SetTrackingParticleD0Dz(), trackingParticleLabel_effic, trackingParticleLabel_fakes, trackLabel_algoA, trackLabel_algoB, UseAssociators, vertexLabel_algoA, and vertexLabel_algoB.
00043 { 00044 // create output collection instance 00045 std::auto_ptr<RecoTracktoTPCollection> outputAlgoA(new RecoTracktoTPCollection()); 00046 std::auto_ptr<RecoTracktoTPCollection> outputAlgoB(new RecoTracktoTPCollection()); 00047 std::auto_ptr<TPtoRecoTrackCollection> outputTP(new TPtoRecoTrackCollection()); 00048 00049 // Get Inputs 00050 edm::Handle<reco::BeamSpot> recoBeamSpotHandle; 00051 iEvent.getByLabel(beamSpotLabel, recoBeamSpotHandle); 00052 reco::BeamSpot beamSpot = *recoBeamSpotHandle; 00053 00054 edm::Handle<View<reco::Track> > trackCollAlgoA; 00055 iEvent.getByLabel(trackLabel_algoA, trackCollAlgoA); 00056 00057 edm::Handle< View<reco::Track> > trackCollAlgoB; 00058 iEvent.getByLabel(trackLabel_algoB, trackCollAlgoB); 00059 00060 edm::Handle<TrackingParticleCollection> trackingParticleCollFakes; 00061 iEvent.getByLabel(trackingParticleLabel_fakes, trackingParticleCollFakes); 00062 00063 edm::Handle<TrackingParticleCollection> trackingParticleCollEffic; 00064 iEvent.getByLabel(trackingParticleLabel_effic, trackingParticleCollEffic); 00065 00066 edm::Handle<reco::VertexCollection> vertexCollAlgoA; 00067 iEvent.getByLabel(vertexLabel_algoA, vertexCollAlgoA); 00068 00069 edm::Handle<reco::VertexCollection> vertexCollAlgoB; 00070 iEvent.getByLabel(vertexLabel_algoB, vertexCollAlgoB); 00071 00072 // call the associator functions: 00073 reco::RecoToSimCollection recSimColl_AlgoA; 00074 reco::RecoToSimCollection recSimColl_AlgoB; 00075 00076 reco::SimToRecoCollection simRecColl_AlgoA; 00077 reco::SimToRecoCollection simRecColl_AlgoB; 00078 00079 if(UseAssociators) 00080 { 00081 edm::ESHandle<TrackAssociatorBase> theAssociator; 00082 iSetup.get<TrackAssociatorRecord>().get(assocLabel, theAssociator); 00083 00084 recSimColl_AlgoA = theAssociator->associateRecoToSim(trackCollAlgoA, trackingParticleCollFakes, &iEvent); 00085 recSimColl_AlgoB = theAssociator->associateRecoToSim(trackCollAlgoB, trackingParticleCollFakes, &iEvent); 00086 00087 simRecColl_AlgoA = theAssociator->associateSimToReco(trackCollAlgoA, trackingParticleCollEffic, &iEvent); 00088 simRecColl_AlgoB = theAssociator->associateSimToReco(trackCollAlgoB, trackingParticleCollEffic, &iEvent); 00089 } 00090 else 00091 { 00092 Handle<reco::RecoToSimCollection > recotosimCollectionH_AlgoA; 00093 iEvent.getByLabel(associatormap_algoA,recotosimCollectionH_AlgoA); 00094 recSimColl_AlgoA = *(recotosimCollectionH_AlgoA.product()); 00095 00096 Handle<reco::RecoToSimCollection > recotosimCollectionH_AlgoB; 00097 iEvent.getByLabel(associatormap_algoB,recotosimCollectionH_AlgoB); 00098 recSimColl_AlgoB = *(recotosimCollectionH_AlgoB.product()); 00099 00100 Handle<reco::SimToRecoCollection > simtorecoCollectionH_AlgoA; 00101 iEvent.getByLabel(associatormap_algoA, simtorecoCollectionH_AlgoA); 00102 simRecColl_AlgoA = *(simtorecoCollectionH_AlgoA.product()); 00103 00104 Handle<reco::SimToRecoCollection > simtorecoCollectionH_AlgoB; 00105 iEvent.getByLabel(associatormap_algoB, simtorecoCollectionH_AlgoB); 00106 simRecColl_AlgoB = *(simtorecoCollectionH_AlgoB.product()); 00107 } 00108 00109 // define the vector of references to trackingParticleColl associated with a given reco::Track 00110 std::vector<std::pair<TrackingParticleRef, double> > associatedTrackingParticles; 00111 00112 // define the vector of references to trackColl associated with a given TrackingParticle 00113 std::vector<std::pair<reco::TrackBaseRef, double> > associatedRecoTracks; 00114 00115 // Get the magnetic field data from the event (used to calculate the point of closest TrackingParticle) 00116 edm::ESHandle<MagneticField> theMagneticField; 00117 iSetup.get<IdealMagneticFieldRecord>().get(theMagneticField); 00118 const MagneticField *magneticField = theMagneticField.product(); 00119 00120 // fill collection algoA 00121 for(View<reco::Track>::size_type i = 0; i < trackCollAlgoA->size(); ++i) 00122 { 00123 // get recoTrack algo A 00124 reco::TrackBaseRef recoTrack(trackCollAlgoA, i); 00125 RecoTracktoTP recoTracktoTP; 00126 recoTracktoTP.SetRecoTrack(recoTrack); 00127 recoTracktoTP.SetBeamSpot(beamSpot.position()); 00128 00129 // get the associated trackingParticle 00130 if(recSimColl_AlgoA.find(recoTrack) != recSimColl_AlgoA.end()) 00131 { 00132 associatedTrackingParticles = recSimColl_AlgoA[recoTrack]; 00133 recoTracktoTP.SetTrackingParticle( associatedTrackingParticles.begin()->first ); 00134 SetTrackingParticleD0Dz(associatedTrackingParticles.begin()->first, beamSpot, magneticField, recoTracktoTP); 00135 } 00136 else 00137 { 00138 recoTracktoTP.SetTrackingParticle(TrackingParticleRef()); 00139 } 00140 00141 // get the reco primary vertex info 00142 if(vertexCollAlgoA->size()) 00143 { 00144 recoTracktoTP.SetRecoVertex( reco::VertexRef(vertexCollAlgoA, 0) ); 00145 } 00146 else 00147 { 00148 recoTracktoTP.SetRecoVertex( reco::VertexRef() ); 00149 } 00150 00151 outputAlgoA->push_back(recoTracktoTP); 00152 } 00153 00154 00155 // fill collection algoB 00156 for(reco::TrackCollection::size_type i = 0; i < trackCollAlgoB->size(); ++i) 00157 { 00158 // get recoTrack algo B 00159 reco::TrackBaseRef recoTrack(trackCollAlgoB, i); 00160 RecoTracktoTP recoTracktoTP; 00161 recoTracktoTP.SetRecoTrack(recoTrack); 00162 recoTracktoTP.SetBeamSpot(beamSpot.position()); 00163 00164 // get the associated trackingParticle 00165 if(recSimColl_AlgoB.find(recoTrack) != recSimColl_AlgoB.end()) 00166 { 00167 associatedTrackingParticles = recSimColl_AlgoB[recoTrack]; 00168 recoTracktoTP.SetTrackingParticle( associatedTrackingParticles.begin()->first ); 00169 SetTrackingParticleD0Dz(associatedTrackingParticles.begin()->first, beamSpot, magneticField, recoTracktoTP); 00170 } 00171 else 00172 { 00173 recoTracktoTP.SetTrackingParticle(TrackingParticleRef()); 00174 } 00175 00176 // get the reco primary vertex info 00177 if(vertexCollAlgoB->size()) 00178 { 00179 recoTracktoTP.SetRecoVertex( reco::VertexRef(vertexCollAlgoB, 0) ); 00180 } 00181 else 00182 { 00183 recoTracktoTP.SetRecoVertex( reco::VertexRef() ); 00184 } 00185 00186 outputAlgoB->push_back(recoTracktoTP); 00187 } 00188 00189 00190 for(TrackingParticleCollection::size_type i = 0; i < trackingParticleCollEffic->size(); ++i) 00191 { 00192 // initialize the trackingParticle (sim) info 00193 TrackingParticleRef tparticle(trackingParticleCollEffic, i); 00194 TPtoRecoTrack tptoRecoTrack; 00195 tptoRecoTrack.SetBeamSpot(beamSpot.position()); 00196 tptoRecoTrack.SetTrackingParticle(tparticle); 00197 SetTrackingParticleD0Dz(tparticle, beamSpot, magneticField, tptoRecoTrack); 00198 00199 // get the assocated recoTrack algoA 00200 if(simRecColl_AlgoA.find(tparticle) != simRecColl_AlgoA.end()) 00201 { 00202 associatedRecoTracks = simRecColl_AlgoA[tparticle]; 00203 tptoRecoTrack.SetRecoTrack_AlgoA(associatedRecoTracks.begin()->first ); 00204 } 00205 else 00206 { 00207 tptoRecoTrack.SetRecoTrack_AlgoA(reco::TrackBaseRef()); 00208 } 00209 00210 // get the recoVertex algo A 00211 if(vertexCollAlgoA->size()) 00212 { 00213 tptoRecoTrack.SetRecoVertex_AlgoA( reco::VertexRef(vertexCollAlgoA, 0) ); 00214 } 00215 else 00216 { 00217 tptoRecoTrack.SetRecoVertex_AlgoA( reco::VertexRef() ); 00218 } 00219 00220 // get the assocated recoTrack algoB 00221 if(simRecColl_AlgoB.find(tparticle) != simRecColl_AlgoB.end()) 00222 { 00223 associatedRecoTracks = simRecColl_AlgoB[tparticle]; 00224 tptoRecoTrack.SetRecoTrack_AlgoB(associatedRecoTracks.begin()->first ); 00225 } 00226 else 00227 { 00228 tptoRecoTrack.SetRecoTrack_AlgoB(reco::TrackBaseRef()); 00229 } 00230 // get the recoVertex algo B 00231 if(vertexCollAlgoB->size()) 00232 { 00233 tptoRecoTrack.SetRecoVertex_AlgoB( reco::VertexRef(vertexCollAlgoB, 0) ); 00234 } 00235 else 00236 { 00237 tptoRecoTrack.SetRecoVertex_AlgoB( reco::VertexRef() ); 00238 } 00239 00240 outputTP->push_back(tptoRecoTrack); 00241 } 00242 00243 00244 // put the collection in the event record 00245 iEvent.put(outputAlgoA, "AlgoA"); 00246 iEvent.put(outputAlgoB, "AlgoB"); 00247 iEvent.put(outputTP, "TP"); 00248 }
void TrackAlgoCompareUtil::SetTrackingParticleD0Dz | ( | TrackingParticleRef | tp, | |
const reco::BeamSpot & | bs, | |||
const MagneticField * | bf, | |||
RecoTracktoTP & | RTTP | |||
) | [private] |
Definition at line 285 of file TrackAlgoCompareUtil.cc.
References TrajectoryStateClosestToBeamLine::isValid(), FreeTrajectoryState::momentum(), p, FreeTrajectoryState::position(), RecoTracktoTP::SetTrackingParticleMomentumPCA(), RecoTracktoTP::SetTrackingParticlePCA(), TrajectoryStateClosestToBeamLine::trackStateAtPCA(), and v1.
00286 { 00287 GlobalPoint trackingParticleVertex( tp->vertex().x(), tp->vertex().y(), tp->vertex().z() ); 00288 GlobalVector trackingParticleP3(tp->g4Track_begin()->momentum().x(), 00289 tp->g4Track_begin()->momentum().y(), 00290 tp->g4Track_begin()->momentum().z() ); 00291 TrackCharge trackingParticleCharge(tp->charge()); 00292 00293 FreeTrajectoryState ftsAtProduction( trackingParticleVertex, trackingParticleP3, trackingParticleCharge, bf ); 00294 TrajectoryStateClosestToBeamLineBuilder tscblBuilder; 00295 TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction, bs); //as in TrackProducerAlgorithm 00296 00297 if(tsAtClosestApproach.isValid()) 00298 { 00299 GlobalPoint v1 = tsAtClosestApproach.trackStateAtPCA().position(); 00300 GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum(); 00301 00302 RTTP.SetTrackingParticleMomentumPCA(p); 00303 RTTP.SetTrackingParticlePCA(v1); 00304 } 00305 else 00306 { 00307 RTTP.SetTrackingParticleMomentumPCA(GlobalVector(-9999.0, -9999.0, -9999.0)); 00308 RTTP.SetTrackingParticlePCA(GlobalPoint(-9999.0, -9999.0, -9999.0)); 00309 } 00310 }
void TrackAlgoCompareUtil::SetTrackingParticleD0Dz | ( | TrackingParticleRef | tp, | |
const reco::BeamSpot & | bs, | |||
const MagneticField * | bf, | |||
TPtoRecoTrack & | TPRT | |||
) | [private] |
Definition at line 257 of file TrackAlgoCompareUtil.cc.
References TrajectoryStateClosestToBeamLine::isValid(), FreeTrajectoryState::momentum(), p, FreeTrajectoryState::position(), TPtoRecoTrack::SetTrackingParticleMomentumPCA(), TPtoRecoTrack::SetTrackingParticlePCA(), TrajectoryStateClosestToBeamLine::trackStateAtPCA(), and v1.
Referenced by produce().
00258 { 00259 GlobalPoint trackingParticleVertex( tp->vertex().x(), tp->vertex().y(), tp->vertex().z() ); 00260 GlobalVector trackingParticleP3(tp->g4Track_begin()->momentum().x(), 00261 tp->g4Track_begin()->momentum().y(), 00262 tp->g4Track_begin()->momentum().z() ); 00263 TrackCharge trackingParticleCharge(tp->charge()); 00264 00265 FreeTrajectoryState ftsAtProduction( trackingParticleVertex, trackingParticleP3, trackingParticleCharge, bf ); 00266 TrajectoryStateClosestToBeamLineBuilder tscblBuilder; 00267 TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction, bs); //as in TrackProducerAlgorithm 00268 00269 if(tsAtClosestApproach.isValid()) 00270 { 00271 GlobalPoint v1 = tsAtClosestApproach.trackStateAtPCA().position(); 00272 GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum(); 00273 00274 TPRT.SetTrackingParticleMomentumPCA(p); 00275 TPRT.SetTrackingParticlePCA(v1); 00276 } 00277 else 00278 { 00279 TPRT.SetTrackingParticleMomentumPCA(GlobalVector(-9999.0, -9999.0, -9999.0)); 00280 TPRT.SetTrackingParticlePCA(GlobalPoint(-9999.0, -9999.0, -9999.0)); 00281 } 00282 }
Definition at line 82 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
Definition at line 83 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
std::string TrackAlgoCompareUtil::assocLabel [private] |
Definition at line 85 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
Definition at line 81 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
Definition at line 77 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
Definition at line 76 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
Definition at line 80 of file TrackAlgoCompareUtil.h.
Definition at line 74 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
Definition at line 75 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
bool TrackAlgoCompareUtil::UseAssociators [private] |
Definition at line 84 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
Definition at line 78 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().
Definition at line 79 of file TrackAlgoCompareUtil.h.
Referenced by produce(), and TrackAlgoCompareUtil().