CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/RecoParticleFlow/PFTracking/plugins/PFDisplacedVertexProducer.cc

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   // --- Setup input collection names --- //
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   // ------ Algo Parameters ------ //
00047 
00048   // Maximal transverse distance between two minimal
00049   // approach points to be used together
00050   double transvSize 
00051      = iConfig.getParameter< double >("transvSize");
00052    
00053   // Maximal longitudinal distance between two minimal
00054   // approach points to be used together
00055   double longSize 
00056      = iConfig.getParameter< double >("longSize");
00057 
00058   // Minimal radius below which we do not reconstruct interactions
00059   // Typically the position of the first Pixel layer
00060   double primaryVertexCut
00061     = iConfig.getParameter< double >("primaryVertexCut");
00062 
00063   // Radius at which no secondary tracks are availables
00064   // in the barrel.For the moment we exclude the TOB barrel
00065   // since 5-th track step starts the latest at first TOB
00066   // layer.
00067   double tobCut 
00068      = iConfig.getParameter< double >("tobCut");
00069 
00070   // Radius at which no secondary tracks are availables
00071   // in the endcaps.For the moment we exclude the TEC wheel.
00072   double tecCut 
00073      = iConfig.getParameter< double >("tecCut");
00074 
00075   // The minimal accepted weight for the tracks calculated in the 
00076   // adaptive vertex fitter to be associated to the displaced vertex 
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   // Vertex Finder parameters  -----------------------------------
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::beginJob() { }
00108 
00109 void 
00110 PFDisplacedVertexProducer::beginRun(edm::Run & run, 
00111                           const edm::EventSetup & es) { }
00112 
00113 
00114 void 
00115 PFDisplacedVertexProducer::produce(Event& iEvent, 
00116                          const EventSetup& iSetup) {
00117   
00118   LogDebug("PFDisplacedVertexProducer")<<"START event: "<<iEvent.id().event()
00119                              <<" in run "<<iEvent.id().run()<<endl;
00120   
00121   // Prepare useful information for the Finder
00122 
00123   ESHandle<MagneticField> magField;
00124   iSetup.get<IdealMagneticFieldRecord>().get(magField);
00125   const MagneticField* theMagField = magField.product();
00126 
00127   ESHandle<GlobalTrackingGeometry> globTkGeomHandle;
00128   iSetup.get<GlobalTrackingGeometryRecord>().get(globTkGeomHandle);
00129 
00130   ESHandle<TrackerGeometry> tkerGeomHandle;
00131   iSetup.get<TrackerDigiGeometryRecord>().get(tkerGeomHandle);
00132 
00133   Handle<reco::PFDisplacedVertexCandidateCollection> vertexCandidates;
00134   iEvent.getByLabel(inputTagVertexCandidates_, vertexCandidates);
00135 
00136   Handle< reco::VertexCollection > mainVertexHandle;
00137   iEvent.getByLabel(inputTagMainVertex_, mainVertexHandle);
00138 
00139   Handle< reco::BeamSpot > beamSpotHandle;
00140   iEvent.getByLabel(inputTagBeamSpot_, beamSpotHandle);
00141 
00142   // Fill useful event information for the Finder
00143   pfDisplacedVertexFinder_.setEdmParameters(theMagField, globTkGeomHandle, tkerGeomHandle); 
00144   pfDisplacedVertexFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
00145   pfDisplacedVertexFinder_.setInput(vertexCandidates);
00146 
00147   // Run the finder
00148   pfDisplacedVertexFinder_.findDisplacedVertices();
00149   
00150 
00151   if(verbose_) {
00152     ostringstream  str;
00153     //str<<pfDisplacedVertexFinder_<<endl;
00154     cout << pfDisplacedVertexFinder_<<endl;
00155     LogInfo("PFDisplacedVertexProducer") << str.str()<<endl;
00156   }    
00157 
00158 
00159   auto_ptr< reco::PFDisplacedVertexCollection > 
00160     pOutputDisplacedVertexCollection( 
00161       pfDisplacedVertexFinder_.transferDisplacedVertices() ); 
00162 
00163 
00164   
00165   iEvent.put(pOutputDisplacedVertexCollection);
00166  
00167   LogDebug("PFDisplacedVertexProducer")<<"STOP event: "<<iEvent.id().event()
00168                              <<" in run "<<iEvent.id().run()<<endl;
00169 
00170 }