Go to the documentation of this file.00001
00002 #include "SimTracker/Records/interface/TrackAssociatorRecord.h"
00003 #include "SimTracker/Records/interface/VertexAssociatorRecord.h"
00004 #include "SimTracker/TrackHistory/interface/VertexHistory.h"
00005
00006 VertexHistory::VertexHistory (
00007 const edm::ParameterSet & config
00008 ) : HistoryBase()
00009 {
00010
00011 trackProducer_ = config.getUntrackedParameter<edm::InputTag> ( "trackProducer" );
00012
00013
00014 vertexProducer_ = config.getUntrackedParameter<edm::InputTag> ( "vertexProducer" );
00015
00016
00017 trackingTruth_ = config.getUntrackedParameter<edm::InputTag> ( "trackingTruth" );
00018
00019
00020 trackAssociator_ = config.getUntrackedParameter<std::string> ( "trackAssociator" );
00021
00022
00023 vertexAssociator_ = config.getUntrackedParameter<std::string> ( "vertexAssociator" );
00024
00025
00026 bestMatchByMaxValue_ = config.getUntrackedParameter<bool> ( "bestMatchByMaxValue" );
00027
00028
00029 enableRecoToSim_ = config.getUntrackedParameter<bool> ( "enableRecoToSim" );
00030
00031
00032 enableSimToReco_ = config.getUntrackedParameter<bool> ( "enableSimToReco" );
00033
00034 quality_ = 0.;
00035 }
00036
00037
00038 void VertexHistory::newEvent (
00039 const edm::Event & event, const edm::EventSetup & setup
00040 )
00041 {
00042 if ( enableRecoToSim_ || enableSimToReco_ )
00043 {
00044
00045
00046 edm::Handle<edm::View<reco::Track> > trackCollection;
00047 event.getByLabel(trackProducer_, trackCollection);
00048
00049
00050 edm::Handle<TrackingParticleCollection> TPCollection;
00051 event.getByLabel(trackingTruth_, TPCollection);
00052
00053
00054 edm::ESHandle<TrackAssociatorBase> trackAssociator;
00055 setup.get<TrackAssociatorRecord>().get(trackAssociator_, trackAssociator);
00056
00057
00058 edm::Handle<edm::View<reco::Vertex> > vertexCollection;
00059 event.getByLabel(vertexProducer_, vertexCollection);
00060
00061
00062 edm::Handle<TrackingVertexCollection> TVCollection;
00063 event.getByLabel(trackingTruth_, TVCollection);
00064
00065
00066 edm::ESHandle<VertexAssociatorBase> vertexAssociator;
00067 setup.get<VertexAssociatorRecord>().get(vertexAssociator_, vertexAssociator);
00068
00069 if ( enableRecoToSim_ )
00070 {
00071
00072 reco::RecoToSimCollection
00073 trackRecoToSim = trackAssociator->associateRecoToSim(trackCollection, TPCollection, &event);
00074
00075
00076 recoToSim_ = vertexAssociator->associateRecoToSim(vertexCollection, TVCollection, event, trackRecoToSim);
00077 }
00078
00079 if ( enableSimToReco_ )
00080 {
00081
00082 reco::SimToRecoCollection
00083 trackSimToReco = trackAssociator->associateSimToReco (trackCollection, TPCollection, &event);
00084
00085
00086 simToReco_ = vertexAssociator->associateSimToReco(vertexCollection, TVCollection, event, trackSimToReco);
00087 }
00088
00089 }
00090 }
00091
00092
00093 bool VertexHistory::evaluate (reco::VertexBaseRef tv)
00094 {
00095
00096 if ( !enableRecoToSim_ ) return false;
00097
00098 std::pair<TrackingVertexRef, double> result = match(tv, recoToSim_, bestMatchByMaxValue_);
00099
00100 TrackingVertexRef tvr( result.first );
00101 quality_ = result.second;
00102
00103 if ( !tvr.isNull() )
00104 {
00105 HistoryBase::evaluate(tvr);
00106
00107 recovertex_ = tv;
00108
00109 return true;
00110 }
00111
00112 return false;
00113 }
00114