CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoParticleFlow/PFTracking/plugins/PFDisplacedVertexCandidateProducer.cc

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   // --- Setup input collection names --- //
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   // ------ Algo Parameters ------ //
00041 
00042   // Distance of minimal approach below which 
00043   // two tracks are considered as linked together
00044   double dcaCut 
00045     = iConfig.getParameter< double >("dcaCut");   
00046 
00047   // Do not reconstruct vertices wich are 
00048   // too close to the beam pipe
00049   double primaryVertexCut
00050     = iConfig.getParameter< double >("primaryVertexCut");   
00051 
00052   //maximum distance between the DCA Point and the inner hit of the track
00053   double dcaPInnerHitCut
00054     = iConfig.getParameter< double >("dcaPInnerHitCut");  
00055 
00056   edm::ParameterSet ps_trk 
00057     = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
00058 
00059   // Collection to be produced
00060   produces<reco::PFDisplacedVertexCandidateCollection>();
00061 
00062   // Vertex Finder parameters  -----------------------------------
00063   pfDisplacedVertexCandidateFinder_.setDebug(debug);
00064   pfDisplacedVertexCandidateFinder_.setParameters(dcaCut, primaryVertexCut, dcaPInnerHitCut, ps_trk);
00065      
00066 }
00067 
00068 
00069 PFDisplacedVertexCandidateProducer::~PFDisplacedVertexCandidateProducer() { }
00070 
00071 
00072 void 
00073 PFDisplacedVertexCandidateProducer::produce(Event& iEvent, 
00074                          const EventSetup& iSetup) {
00075   
00076   LogDebug("PFDisplacedVertexCandidateProducer")<<"START event: "<<iEvent.id().event()
00077                              <<" in run "<<iEvent.id().run()<<endl;
00078   
00079   // Prepare and fill useful event information for the Finder
00080   edm::ESHandle<MagneticField> magField;
00081   iSetup.get<IdealMagneticFieldRecord>().get(magField);
00082   const MagneticField* theMagField = magField.product();
00083 
00084   Handle <reco::TrackCollection> trackCollection;
00085   iEvent.getByLabel(inputTagTracks_, trackCollection);
00086     
00087   Handle< reco::VertexCollection > mainVertexHandle;
00088   iEvent.getByLabel(inputTagMainVertex_, mainVertexHandle);
00089 
00090   Handle< reco::BeamSpot > beamSpotHandle;
00091   iEvent.getByLabel(inputTagBeamSpot_, beamSpotHandle);
00092 
00093   pfDisplacedVertexCandidateFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
00094   pfDisplacedVertexCandidateFinder_.setInput( trackCollection, theMagField );
00095 
00096 
00097   // Run the finder
00098   pfDisplacedVertexCandidateFinder_.findDisplacedVertexCandidates();
00099   
00100 
00101   if(verbose_) {
00102     ostringstream  str;
00103     str<<pfDisplacedVertexCandidateFinder_<<endl;
00104     cout << pfDisplacedVertexCandidateFinder_<<endl;
00105     LogInfo("PFDisplacedVertexCandidateProducer") << str.str()<<endl;
00106   }    
00107 
00108 
00109   auto_ptr< reco::PFDisplacedVertexCandidateCollection > 
00110     pOutputDisplacedVertexCandidateCollection(
00111       pfDisplacedVertexCandidateFinder_.transferVertexCandidates() ); 
00112   
00113   
00114   iEvent.put(pOutputDisplacedVertexCandidateCollection);
00115  
00116   LogDebug("PFDisplacedVertexCandidateProducer")<<"STOP event: "<<iEvent.id().event()
00117                              <<" in run "<<iEvent.id().run()<<endl;
00118 
00119 }