Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-31 23:46:30

0001 /**\class PFDisplacedVertexProducer 
0002 \brief Producer for DisplacedVertices 
0003 
0004 This producer makes use of DisplacedVertexFinder. This Finder fit vertex candidates
0005 out of the DisplacedVertexCandidates which contain all tracks linked 
0006 together by the criterion which is by default the minimal approach distance. 
0007 
0008 \author Maxime Gouzevitch
0009 \date   November 2009
0010 */
0011 
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/stream/EDProducer.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/ParameterSet/interface/FileInPath.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/Utilities/interface/Exception.h"
0020 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0021 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
0022 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0023 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0024 #include "MagneticField/Engine/interface/MagneticField.h"
0025 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0026 #include "RecoParticleFlow/PFTracking/interface/PFDisplacedVertexFinder.h"
0027 
0028 class PFDisplacedVertexProducer : public edm::stream::EDProducer<> {
0029 public:
0030   explicit PFDisplacedVertexProducer(const edm::ParameterSet&);
0031 
0032   ~PFDisplacedVertexProducer() override;
0033 
0034   void produce(edm::Event&, const edm::EventSetup&) override;
0035 
0036 private:
0037   /// Collection of DisplacedVertex Candidates used as input for
0038   /// the Displaced VertexFinder.
0039   const edm::EDGetTokenT<reco::PFDisplacedVertexCandidateCollection> inputTagVertexCandidates_;
0040 
0041   /// Input tag for main vertex to cut of dxy of secondary tracks
0042 
0043   const edm::EDGetTokenT<reco::VertexCollection> inputTagMainVertex_;
0044   const edm::EDGetTokenT<reco::BeamSpot> inputTagBeamSpot_;
0045 
0046   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
0047   const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> globTkGeomToken_;
0048   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tkerTopoToken_;
0049   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tkerGeomToken_;
0050 
0051   /// verbose ?
0052   bool verbose_;
0053 
0054   /// Displaced Vertices finder
0055   PFDisplacedVertexFinder pfDisplacedVertexFinder_;
0056 };
0057 
0058 #include "FWCore/Framework/interface/MakerMacros.h"
0059 DEFINE_FWK_MODULE(PFDisplacedVertexProducer);
0060 
0061 using namespace std;
0062 using namespace edm;
0063 
0064 PFDisplacedVertexProducer::PFDisplacedVertexProducer(const edm::ParameterSet& iConfig)
0065     : inputTagVertexCandidates_(consumes<reco::PFDisplacedVertexCandidateCollection>(
0066           iConfig.getParameter<InputTag>("vertexCandidatesLabel"))),
0067       inputTagMainVertex_(consumes<reco::VertexCollection>(iConfig.getParameter<InputTag>("mainVertexLabel"))),
0068       inputTagBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<InputTag>("offlineBeamSpotLabel"))),
0069       magFieldToken_(esConsumes()),
0070       globTkGeomToken_(esConsumes()),
0071       tkerTopoToken_(esConsumes()),
0072       tkerGeomToken_(esConsumes()) {
0073   // --- Setup input collection names --- //
0074 
0075   verbose_ = iConfig.getUntrackedParameter<bool>("verbose");
0076 
0077   bool debug = iConfig.getUntrackedParameter<bool>("debug");
0078 
0079   // ------ Algo Parameters ------ //
0080 
0081   // Maximal transverse distance between two minimal
0082   // approach points to be used together
0083   double transvSize = iConfig.getParameter<double>("transvSize");
0084 
0085   // Maximal longitudinal distance between two minimal
0086   // approach points to be used together
0087   double longSize = iConfig.getParameter<double>("longSize");
0088 
0089   // Minimal radius below which we do not reconstruct interactions
0090   // Typically the position of the first Pixel layer
0091   double primaryVertexCut = iConfig.getParameter<double>("primaryVertexCut");
0092 
0093   // Radius at which no secondary tracks are availables
0094   // in the barrel.For the moment we exclude the TOB barrel
0095   // since 5-th track step starts the latest at first TOB
0096   // layer.
0097   double tobCut = iConfig.getParameter<double>("tobCut");
0098 
0099   // Radius at which no secondary tracks are availables
0100   // in the endcaps.For the moment we exclude the TEC wheel.
0101   double tecCut = iConfig.getParameter<double>("tecCut");
0102 
0103   // The minimal accepted weight for the tracks calculated in the
0104   // adaptive vertex fitter to be associated to the displaced vertex
0105   double minAdaptWeight = iConfig.getParameter<double>("minAdaptWeight");
0106 
0107   bool switchOff2TrackVertex = iConfig.getUntrackedParameter<bool>("switchOff2TrackVertex");
0108 
0109   edm::ParameterSet ps_trk = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
0110   edm::ParameterSet ps_vtx = iConfig.getParameter<edm::ParameterSet>("vertexIdentifierParameters");
0111   edm::ParameterSet ps_avf = iConfig.getParameter<edm::ParameterSet>("avfParameters");
0112 
0113   produces<reco::PFDisplacedVertexCollection>();
0114 
0115   // Vertex Finder parameters  -----------------------------------
0116   pfDisplacedVertexFinder_.setDebug(debug);
0117   pfDisplacedVertexFinder_.setParameters(
0118       transvSize, longSize, primaryVertexCut, tobCut, tecCut, minAdaptWeight, switchOff2TrackVertex);
0119   pfDisplacedVertexFinder_.setAVFParameters(ps_avf);
0120   pfDisplacedVertexFinder_.setTracksSelector(ps_trk);
0121   pfDisplacedVertexFinder_.setVertexIdentifier(ps_vtx);
0122 }
0123 
0124 PFDisplacedVertexProducer::~PFDisplacedVertexProducer() {}
0125 
0126 void PFDisplacedVertexProducer::produce(Event& iEvent, const EventSetup& iSetup) {
0127   LogDebug("PFDisplacedVertexProducer") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run();
0128 
0129   // Prepare useful information for the Finder
0130 
0131   auto const& theMagField = &iSetup.getData(magFieldToken_);
0132   auto const& globTkGeom = &iSetup.getData(globTkGeomToken_);
0133   auto const& tkerTopo = &iSetup.getData(tkerTopoToken_);
0134   auto const& tkerGeom = &iSetup.getData(tkerGeomToken_);
0135 
0136   auto const& vertexCandidates = iEvent.getHandle(inputTagVertexCandidates_);
0137   auto const& mainVertexHandle = iEvent.getHandle(inputTagMainVertex_);
0138   auto const& beamSpotHandle = iEvent.getHandle(inputTagBeamSpot_);
0139 
0140   // Fill useful event information for the Finder
0141   pfDisplacedVertexFinder_.setEdmParameters(theMagField, globTkGeom, tkerTopo, tkerGeom);
0142   pfDisplacedVertexFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
0143   pfDisplacedVertexFinder_.setInput(vertexCandidates);
0144 
0145   // Run the finder
0146   pfDisplacedVertexFinder_.findDisplacedVertices();
0147 
0148   if (verbose_) {
0149     ostringstream str;
0150     str << pfDisplacedVertexFinder_;
0151     edm::LogInfo("PFDisplacedVertexProducer") << str.str();
0152   }
0153 
0154   std::unique_ptr<reco::PFDisplacedVertexCollection> pOutputDisplacedVertexCollection(
0155       pfDisplacedVertexFinder_.transferDisplacedVertices());
0156 
0157   iEvent.put(std::move(pOutputDisplacedVertexCollection));
0158 
0159   LogDebug("PFDisplacedVertexProducer") << "STOP event: " << iEvent.id().event() << " in run " << iEvent.id().run();
0160 }