Go to the documentation of this file.00001 #include "RecoParticleFlow/PFTracking/plugins/PFDisplacedVertexProducer.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 "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
00015 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00016 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00017 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
00018
00019 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexFwd.h"
00020 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexCandidateFwd.h"
00021
00022 #include <set>
00023
00024 using namespace std;
00025 using namespace edm;
00026
00027 PFDisplacedVertexProducer::PFDisplacedVertexProducer(const edm::ParameterSet& iConfig) {
00028
00029
00030
00031 inputTagVertexCandidates_
00032 = iConfig.getParameter<InputTag>("vertexCandidatesLabel");
00033
00034 inputTagMainVertex_
00035 = iConfig.getParameter<InputTag>("mainVertexLabel");
00036
00037 inputTagBeamSpot_
00038 = iConfig.getParameter<InputTag>("offlineBeamSpotLabel");
00039
00040 verbose_ =
00041 iConfig.getUntrackedParameter<bool>("verbose");
00042
00043 bool debug =
00044 iConfig.getUntrackedParameter<bool>("debug");
00045
00046
00047
00048
00049
00050 double transvSize
00051 = iConfig.getParameter< double >("transvSize");
00052
00053
00054
00055 double longSize
00056 = iConfig.getParameter< double >("longSize");
00057
00058
00059
00060 double primaryVertexCut
00061 = iConfig.getParameter< double >("primaryVertexCut");
00062
00063
00064
00065
00066
00067 double tobCut
00068 = iConfig.getParameter< double >("tobCut");
00069
00070
00071
00072 double tecCut
00073 = iConfig.getParameter< double >("tecCut");
00074
00075
00076
00077 double minAdaptWeight
00078 = iConfig.getParameter< double >("minAdaptWeight");
00079
00080 edm::ParameterSet ps_trk = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
00081 edm::ParameterSet ps_vtx = iConfig.getParameter<edm::ParameterSet>("vertexIdentifierParameters");
00082 edm::ParameterSet ps_avf = iConfig.getParameter<edm::ParameterSet>("avfParameters");
00083
00084 produces<reco::PFDisplacedVertexCollection>();
00085
00086
00087 pfDisplacedVertexFinder_.setDebug(debug);
00088 pfDisplacedVertexFinder_.setParameters(transvSize, longSize,
00089 primaryVertexCut, tobCut,
00090 tecCut, minAdaptWeight);
00091 pfDisplacedVertexFinder_.setAVFParameters(ps_avf);
00092 pfDisplacedVertexFinder_.setTracksSelector(ps_trk);
00093 pfDisplacedVertexFinder_.setVertexIdentifier(ps_vtx);
00094
00095 }
00096
00097
00098
00099 PFDisplacedVertexProducer::~PFDisplacedVertexProducer() { }
00100
00101
00102
00103 void
00104 PFDisplacedVertexProducer::beginJob() { }
00105
00106 void
00107 PFDisplacedVertexProducer::beginRun(edm::Run & run,
00108 const edm::EventSetup & es) { }
00109
00110
00111 void
00112 PFDisplacedVertexProducer::produce(Event& iEvent,
00113 const EventSetup& iSetup) {
00114
00115 LogDebug("PFDisplacedVertexProducer")<<"START event: "<<iEvent.id().event()
00116 <<" in run "<<iEvent.id().run()<<endl;
00117
00118
00119
00120 ESHandle<MagneticField> magField;
00121 iSetup.get<IdealMagneticFieldRecord>().get(magField);
00122 const MagneticField* theMagField = magField.product();
00123
00124 ESHandle<GlobalTrackingGeometry> globTkGeomHandle;
00125 iSetup.get<GlobalTrackingGeometryRecord>().get(globTkGeomHandle);
00126
00127 ESHandle<TrackerGeometry> tkerGeomHandle;
00128 iSetup.get<TrackerDigiGeometryRecord>().get(tkerGeomHandle);
00129
00130 Handle<reco::PFDisplacedVertexCandidateCollection> vertexCandidates;
00131 iEvent.getByLabel(inputTagVertexCandidates_, vertexCandidates);
00132
00133 Handle< reco::VertexCollection > mainVertexHandle;
00134 iEvent.getByLabel(inputTagMainVertex_, mainVertexHandle);
00135
00136 Handle< reco::BeamSpot > beamSpotHandle;
00137 iEvent.getByLabel(inputTagBeamSpot_, beamSpotHandle);
00138
00139
00140 pfDisplacedVertexFinder_.setEdmParameters(theMagField, globTkGeomHandle, tkerGeomHandle);
00141 pfDisplacedVertexFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
00142 pfDisplacedVertexFinder_.setInput(vertexCandidates);
00143
00144
00145 pfDisplacedVertexFinder_.findDisplacedVertices();
00146
00147
00148 if(verbose_) {
00149 ostringstream str;
00150
00151 cout << pfDisplacedVertexFinder_<<endl;
00152 LogInfo("PFDisplacedVertexProducer") << str.str()<<endl;
00153 }
00154
00155
00156 auto_ptr< reco::PFDisplacedVertexCollection >
00157 pOutputDisplacedVertexCollection(
00158 pfDisplacedVertexFinder_.transferDisplacedVertices() );
00159
00160
00161
00162 iEvent.put(pOutputDisplacedVertexCollection);
00163
00164 LogDebug("PFDisplacedVertexProducer")<<"STOP event: "<<iEvent.id().event()
00165 <<" in run "<<iEvent.id().run()<<endl;
00166
00167 }