Go to the documentation of this file.00001 #include <memory>
00002 #include <set>
00003
00004
00005 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00006 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00007 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00008 #include "TrackingTools/IPTools/interface/IPTools.h"
00009
00010
00011 #include "FWCore/Framework/interface/EDProducer.h"
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "FWCore/Framework/interface/MakerMacros.h"
00014 #include "FWCore/Utilities/interface/InputTag.h"
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016
00017 #include "DataFormats/Common/interface/Handle.h"
00018 #include "DataFormats/TrackReco/interface/Track.h"
00019 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00020 #include "DataFormats/VertexReco/interface/Vertex.h"
00021 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00022 #include "RecoVertex/VertexTools/interface/VertexDistance3D.h"
00023
00024
00025 #include "DataFormats/TrackReco/interface/Track.h"
00026 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00027 #include "DataFormats/VertexReco/interface/Vertex.h"
00028 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00029 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00030
00031 #include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h"
00032 #include "RecoVertex/KalmanVertexFit/interface/KalmanVertexUpdator.h"
00033 #include "RecoVertex/KalmanVertexFit/interface/KalmanVertexTrackCompatibilityEstimator.h"
00034 #include "RecoVertex/KalmanVertexFit/interface/KalmanVertexSmoother.h"
00035 #include "DataFormats/Math/interface/deltaR.h"
00036
00037
00038 #include "RecoVertex/ConfigurableVertexReco/interface/ConfigurableVertexReconstructor.h"
00039 #include "RecoVertex/AdaptiveVertexFinder/interface/TrackVertexArbitratration.h"
00040
00041
00042
00043
00044
00045 class TrackVertexArbitrator : public edm::EDProducer {
00046 public:
00047 TrackVertexArbitrator(const edm::ParameterSet ¶ms);
00048
00049
00050 virtual void produce(edm::Event &event, const edm::EventSetup &es);
00051
00052 private:
00053 bool trackFilter(const reco::TrackRef &track) const;
00054
00055 edm::InputTag primaryVertexCollection;
00056 edm::InputTag secondaryVertexCollection;
00057 edm::InputTag trackCollection;
00058 edm::InputTag beamSpotCollection;
00059 TrackVertexArbitration * theArbitrator;
00060 };
00061
00062 TrackVertexArbitrator::TrackVertexArbitrator(const edm::ParameterSet ¶ms) :
00063 primaryVertexCollection (params.getParameter<edm::InputTag>("primaryVertices")),
00064 secondaryVertexCollection (params.getParameter<edm::InputTag>("secondaryVertices")),
00065 trackCollection (params.getParameter<edm::InputTag>("tracks")),
00066 beamSpotCollection (params.getParameter<edm::InputTag>("beamSpot"))
00067 {
00068 produces<reco::VertexCollection>();
00069 theArbitrator = new TrackVertexArbitration(params);
00070 }
00071
00072
00073 void TrackVertexArbitrator::produce(edm::Event &event, const edm::EventSetup &es)
00074 {
00075 using namespace reco;
00076
00077 edm::Handle<VertexCollection> secondaryVertices;
00078 event.getByLabel(secondaryVertexCollection, secondaryVertices);
00079 VertexCollection theSecVertexColl = *(secondaryVertices.product());
00080
00081 edm::Handle<VertexCollection> primaryVertices;
00082 event.getByLabel(primaryVertexCollection, primaryVertices);
00083
00084 std::auto_ptr<VertexCollection> recoVertices(new VertexCollection);
00085 if(primaryVertices->size()!=0){
00086 const reco::Vertex &pv = (*primaryVertices)[0];
00087
00088 edm::Handle<TrackCollection> tracks;
00089 event.getByLabel(trackCollection, tracks);
00090
00091 edm::ESHandle<TransientTrackBuilder> trackBuilder;
00092 es.get<TransientTrackRecord>().get("TransientTrackBuilder",
00093 trackBuilder);
00094
00095 edm::Handle<BeamSpot> beamSpot;
00096 event.getByLabel(beamSpotCollection, beamSpot);
00097
00098
00099 edm::RefVector< TrackCollection > selectedTracks;
00100 for(TrackCollection::const_iterator track = tracks->begin();
00101 track != tracks->end(); ++track) {
00102 TrackRef ref(tracks, track - tracks->begin());
00103 selectedTracks.push_back(ref);
00104
00105 }
00106
00107
00108 const edm::RefVector< TrackCollection > tracksForArbitration= selectedTracks;
00109 reco::VertexCollection theRecoVertices = theArbitrator->trackVertexArbitrator(beamSpot, pv, trackBuilder, tracksForArbitration,
00110 theSecVertexColl);
00111
00112 for(unsigned int ivtx=0; ivtx < theRecoVertices.size(); ivtx++){
00113 recoVertices->push_back(theRecoVertices[ivtx]);
00114 }
00115
00116 }
00117 event.put(recoVertices);
00118
00119
00120
00121 }
00122
00123 DEFINE_FWK_MODULE(TrackVertexArbitrator);