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 bool switchOff2TrackVertex
00081 = iConfig.getUntrackedParameter< bool >("switchOff2TrackVertex");
00082
00083 edm::ParameterSet ps_trk = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
00084 edm::ParameterSet ps_vtx = iConfig.getParameter<edm::ParameterSet>("vertexIdentifierParameters");
00085 edm::ParameterSet ps_avf = iConfig.getParameter<edm::ParameterSet>("avfParameters");
00086
00087 produces<reco::PFDisplacedVertexCollection>();
00088
00089
00090 pfDisplacedVertexFinder_.setDebug(debug);
00091 pfDisplacedVertexFinder_.setParameters(transvSize, longSize,
00092 primaryVertexCut, tobCut,
00093 tecCut, minAdaptWeight, switchOff2TrackVertex);
00094 pfDisplacedVertexFinder_.setAVFParameters(ps_avf);
00095 pfDisplacedVertexFinder_.setTracksSelector(ps_trk);
00096 pfDisplacedVertexFinder_.setVertexIdentifier(ps_vtx);
00097
00098 }
00099
00100
00101
00102 PFDisplacedVertexProducer::~PFDisplacedVertexProducer() { }
00103
00104
00105
00106 void
00107 PFDisplacedVertexProducer::produce(Event& iEvent,
00108 const EventSetup& iSetup) {
00109
00110 LogDebug("PFDisplacedVertexProducer")<<"START event: "<<iEvent.id().event()
00111 <<" in run "<<iEvent.id().run()<<endl;
00112
00113
00114
00115 ESHandle<MagneticField> magField;
00116 iSetup.get<IdealMagneticFieldRecord>().get(magField);
00117 const MagneticField* theMagField = magField.product();
00118
00119 ESHandle<GlobalTrackingGeometry> globTkGeomHandle;
00120 iSetup.get<GlobalTrackingGeometryRecord>().get(globTkGeomHandle);
00121
00122 ESHandle<TrackerGeometry> tkerGeomHandle;
00123 iSetup.get<TrackerDigiGeometryRecord>().get(tkerGeomHandle);
00124
00125 Handle<reco::PFDisplacedVertexCandidateCollection> vertexCandidates;
00126 iEvent.getByLabel(inputTagVertexCandidates_, vertexCandidates);
00127
00128 Handle< reco::VertexCollection > mainVertexHandle;
00129 iEvent.getByLabel(inputTagMainVertex_, mainVertexHandle);
00130
00131 Handle< reco::BeamSpot > beamSpotHandle;
00132 iEvent.getByLabel(inputTagBeamSpot_, beamSpotHandle);
00133
00134
00135 pfDisplacedVertexFinder_.setEdmParameters(theMagField, globTkGeomHandle, tkerGeomHandle);
00136 pfDisplacedVertexFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
00137 pfDisplacedVertexFinder_.setInput(vertexCandidates);
00138
00139
00140 pfDisplacedVertexFinder_.findDisplacedVertices();
00141
00142
00143 if(verbose_) {
00144 ostringstream str;
00145
00146 cout << pfDisplacedVertexFinder_<<endl;
00147 LogInfo("PFDisplacedVertexProducer") << str.str()<<endl;
00148 }
00149
00150
00151 auto_ptr< reco::PFDisplacedVertexCollection >
00152 pOutputDisplacedVertexCollection(
00153 pfDisplacedVertexFinder_.transferDisplacedVertices() );
00154
00155
00156
00157 iEvent.put(pOutputDisplacedVertexCollection);
00158
00159 LogDebug("PFDisplacedVertexProducer")<<"STOP event: "<<iEvent.id().event()
00160 <<" in run "<<iEvent.id().run()<<endl;
00161
00162 }