Go to the documentation of this file.00001 #include "RecoParticleFlow/PFTracking/plugins/PFDisplacedVertexCandidateProducer.h"
00002
00003 #include "FWCore/Framework/interface/ESHandle.h"
00004
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "FWCore/Utilities/interface/Exception.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008
00009 #include "FWCore/ParameterSet/interface/FileInPath.h"
00010
00011 #include "MagneticField/Engine/interface/MagneticField.h"
00012 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00013
00014 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexCandidateFwd.h"
00015 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00016
00017 #include <set>
00018
00019 using namespace std;
00020 using namespace edm;
00021
00022 PFDisplacedVertexCandidateProducer::PFDisplacedVertexCandidateProducer(const edm::ParameterSet& iConfig) {
00023
00024
00025 inputTagTracks_
00026 = iConfig.getParameter<InputTag>("trackCollection");
00027
00028 inputTagMainVertex_
00029 = iConfig.getParameter<InputTag>("mainVertexLabel");
00030
00031 inputTagBeamSpot_
00032 = iConfig.getParameter<InputTag>("offlineBeamSpotLabel");
00033
00034 verbose_ =
00035 iConfig.getUntrackedParameter<bool>("verbose");
00036
00037 bool debug =
00038 iConfig.getUntrackedParameter<bool>("debug");
00039
00040
00041
00042
00043
00044 double dcaCut
00045 = iConfig.getParameter< double >("dcaCut");
00046
00047
00048
00049 double primaryVertexCut
00050 = iConfig.getParameter< double >("primaryVertexCut");
00051
00052
00053 double dcaPInnerHitCut
00054 = iConfig.getParameter< double >("dcaPInnerHitCut");
00055
00056 edm::ParameterSet ps_trk
00057 = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
00058
00059
00060 produces<reco::PFDisplacedVertexCandidateCollection>();
00061
00062
00063 pfDisplacedVertexCandidateFinder_.setDebug(debug);
00064 pfDisplacedVertexCandidateFinder_.setParameters(dcaCut, primaryVertexCut, dcaPInnerHitCut, ps_trk);
00065
00066 }
00067
00068
00069 PFDisplacedVertexCandidateProducer::~PFDisplacedVertexCandidateProducer() { }
00070
00071
00072
00073 void
00074 PFDisplacedVertexCandidateProducer::beginJob() { }
00075
00076 void
00077 PFDisplacedVertexCandidateProducer::beginRun(edm::Run & run,
00078 const edm::EventSetup & es) { }
00079
00080
00081 void
00082 PFDisplacedVertexCandidateProducer::produce(Event& iEvent,
00083 const EventSetup& iSetup) {
00084
00085 LogDebug("PFDisplacedVertexCandidateProducer")<<"START event: "<<iEvent.id().event()
00086 <<" in run "<<iEvent.id().run()<<endl;
00087
00088
00089 edm::ESHandle<MagneticField> magField;
00090 iSetup.get<IdealMagneticFieldRecord>().get(magField);
00091 const MagneticField* theMagField = magField.product();
00092
00093 Handle <reco::TrackCollection> trackCollection;
00094 iEvent.getByLabel(inputTagTracks_, trackCollection);
00095
00096 Handle< reco::VertexCollection > mainVertexHandle;
00097 iEvent.getByLabel(inputTagMainVertex_, mainVertexHandle);
00098
00099 Handle< reco::BeamSpot > beamSpotHandle;
00100 iEvent.getByLabel(inputTagBeamSpot_, beamSpotHandle);
00101
00102 pfDisplacedVertexCandidateFinder_.setInput( trackCollection, theMagField );
00103 pfDisplacedVertexCandidateFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
00104
00105
00106
00107 pfDisplacedVertexCandidateFinder_.findDisplacedVertexCandidates();
00108
00109
00110 if(verbose_) {
00111 ostringstream str;
00112 str<<pfDisplacedVertexCandidateFinder_<<endl;
00113 cout << pfDisplacedVertexCandidateFinder_<<endl;
00114 LogInfo("PFDisplacedVertexCandidateProducer") << str.str()<<endl;
00115 }
00116
00117
00118 auto_ptr< reco::PFDisplacedVertexCandidateCollection >
00119 pOutputDisplacedVertexCandidateCollection(
00120 pfDisplacedVertexCandidateFinder_.transferVertexCandidates() );
00121
00122
00123 iEvent.put(pOutputDisplacedVertexCandidateCollection);
00124
00125 LogDebug("PFDisplacedVertexCandidateProducer")<<"STOP event: "<<iEvent.id().event()
00126 <<" in run "<<iEvent.id().run()<<endl;
00127
00128 }