Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-22 02:24:09

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   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0036 
0037 private:
0038   /// Collection of DisplacedVertex Candidates used as input for
0039   /// the Displaced VertexFinder.
0040   const edm::EDGetTokenT<reco::PFDisplacedVertexCandidateCollection> inputTagVertexCandidates_;
0041 
0042   /// Input tag for main vertex to cut of dxy of secondary tracks
0043 
0044   const edm::EDGetTokenT<reco::VertexCollection> inputTagMainVertex_;
0045   const edm::EDGetTokenT<reco::BeamSpot> inputTagBeamSpot_;
0046 
0047   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
0048   const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> globTkGeomToken_;
0049   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tkerTopoToken_;
0050   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tkerGeomToken_;
0051 
0052   /// verbose ?
0053   bool verbose_;
0054 
0055   /// Displaced Vertices finder
0056   PFDisplacedVertexFinder pfDisplacedVertexFinder_;
0057 };
0058 
0059 #include "FWCore/Framework/interface/MakerMacros.h"
0060 DEFINE_FWK_MODULE(PFDisplacedVertexProducer);
0061 
0062 void PFDisplacedVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0063   edm::ParameterSetDescription desc;
0064   desc.add<edm::InputTag>("vertexCandidatesLabel", {"particleFlowDisplacedVertexCandidate"});
0065   // verbosity
0066   desc.addUntracked<bool>("verbose", false);
0067   // Debug flag
0068   desc.addUntracked<bool>("debug", false);
0069   // maximum transverse distance between two points to be used in Seed
0070   desc.add<double>("transvSize", 1.0);
0071   // maximum longitudinal distance between two points to be used in Seed
0072   desc.add<double>("longSize", 5);
0073   // minimal radius below which we do not reconstruct interactions
0074   // typically the position of the first Pixel layer or beam pipe
0075   desc.add<double>("primaryVertexCut", 1.8);
0076   // radius below which we don't want to reconstruct displaced
0077   // vertices
0078   desc.add<double>("tobCut", 100);
0079   // z below which we don't want to reconstruct displaced
0080   // vertices
0081   desc.add<double>("tecCut", 220);
0082   // the minimal accepted weight for the tracks calculated in the
0083   // adaptive vertex fitter to be associated to the displaced vertex
0084   // this correspond to the sigmacut of 6
0085   desc.add<double>("minAdaptWeight", 0.5);
0086   // this flag is designed to reduce the timing of the algorithm in the high pile-up conditions. 2 tracks
0087   // vertices are the most sensitives to the pile-ups.
0088   desc.addUntracked<bool>("switchOff2TrackVertex", true);
0089   // ------------ Paramemeters for the track selection ------------
0090   // Primary vertex information used for dxy calculation
0091   desc.add<edm::InputTag>("mainVertexLabel", {"offlinePrimaryVertices", ""});
0092   desc.add<edm::InputTag>("offlineBeamSpotLabel", {"offlineBeamSpot", ""});
0093   // Parameters used to apply cuts
0094   {
0095     edm::ParameterSetDescription pset;
0096     pset.add<bool>("bSelectTracks", true);
0097     // If a track is high purity it is always kept
0098     pset.add<std::string>("quality", "HighPurity");
0099     // Following cuts are applyed to non high purity tracks
0100     // nChi2_max and pt_min cuts are applyed to the primary and secondary tracks
0101     pset.add<double>("nChi2_max", 5.);
0102     pset.add<double>("pt_min", 0.2);
0103     // nChi2_min applyed only to primary tracks which may be short
0104     // remove fake pixel triplets
0105     pset.add<double>("nChi2_min", 0.5);
0106     // Cuts applyed to the secondary tracks long and displaced
0107     pset.add<double>("dxy_min", 0.2);
0108     pset.add<int>("nHits_min", 6);
0109     pset.add<int>("nOuterHits_max", 9);
0110     desc.add<edm::ParameterSetDescription>("tracksSelectorParameters", pset);
0111   }
0112   // ------------ Paramemeters for the vertex identification ------------
0113   {
0114     edm::ParameterSetDescription pset;
0115     pset.add<bool>("bIdentifyVertices", true);
0116     // Minimal sum pt of secondary tracks for displaced vertices.
0117     // Below this value we find either loopers splitted in two parts eiter
0118     // fake vertices in forward direction
0119     pset.add<double>("pt_min", 0.5);
0120     // Minimal pT and log10(P_primary/P_secondary) for primary track in kinks (Primary+Secondary)
0121     // which are not identifier as K-+ decays
0122     pset.add<double>("pt_kink_min", 3.0);
0123     pset.add<double>("logPrimSec_min", 0.0);
0124     // maximum absoluta value of eta for loopers
0125     pset.add<double>("looper_eta_max", 0.1);
0126     // Masses cuts for selections
0127     //                                       CVmin  K0min  K0max  K-min  K-max  Ldmin  Ldmax  Nuclmin_ee
0128     pset.add<std::vector<double>>("masses", {0.050, 0.485, 0.515, 0.480, 0.520, 1.107, 1.125, 0.200});
0129     // Angle between the primaryVertex-secondaryVertex direction and secondary tracks direction
0130     // this angle means that the final system shall propagate in the same direction than initial system
0131     //                                       all_max, CV and V0 max
0132     pset.add<std::vector<double>>("angles", {15, 15});
0133     desc.add<edm::ParameterSetDescription>("vertexIdentifierParameters", pset);
0134   }
0135   // Adaptive Vertex Fitter parameters identical to the default ones except sigmacut.
0136   // The default value is sigmacut = 3 too tight for displaced vertices
0137   // see CMS NOTE-2008/033 for more details
0138   {
0139     edm::ParameterSetDescription pset;
0140     pset.add<double>("sigmacut", 6.);
0141     pset.add<double>("Tini", 256.);
0142     pset.add<double>("ratio", 0.25);
0143     desc.add<edm::ParameterSetDescription>("avfParameters", pset);
0144   }
0145   descriptions.add("particleFlowDisplacedVertex", desc);
0146 }
0147 
0148 using namespace std;
0149 using namespace edm;
0150 
0151 PFDisplacedVertexProducer::PFDisplacedVertexProducer(const edm::ParameterSet& iConfig)
0152     : inputTagVertexCandidates_(consumes<reco::PFDisplacedVertexCandidateCollection>(
0153           iConfig.getParameter<InputTag>("vertexCandidatesLabel"))),
0154       inputTagMainVertex_(consumes<reco::VertexCollection>(iConfig.getParameter<InputTag>("mainVertexLabel"))),
0155       inputTagBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<InputTag>("offlineBeamSpotLabel"))),
0156       magFieldToken_(esConsumes()),
0157       globTkGeomToken_(esConsumes()),
0158       tkerTopoToken_(esConsumes()),
0159       tkerGeomToken_(esConsumes()) {
0160   // --- Setup input collection names --- //
0161 
0162   verbose_ = iConfig.getUntrackedParameter<bool>("verbose");
0163 
0164   bool debug = iConfig.getUntrackedParameter<bool>("debug");
0165 
0166   // ------ Algo Parameters ------ //
0167 
0168   // Maximal transverse distance between two minimal
0169   // approach points to be used together
0170   double transvSize = iConfig.getParameter<double>("transvSize");
0171 
0172   // Maximal longitudinal distance between two minimal
0173   // approach points to be used together
0174   double longSize = iConfig.getParameter<double>("longSize");
0175 
0176   // Minimal radius below which we do not reconstruct interactions
0177   // Typically the position of the first Pixel layer
0178   double primaryVertexCut = iConfig.getParameter<double>("primaryVertexCut");
0179 
0180   // Radius at which no secondary tracks are availables
0181   // in the barrel.For the moment we exclude the TOB barrel
0182   // since 5-th track step starts the latest at first TOB
0183   // layer.
0184   double tobCut = iConfig.getParameter<double>("tobCut");
0185 
0186   // Radius at which no secondary tracks are availables
0187   // in the endcaps.For the moment we exclude the TEC wheel.
0188   double tecCut = iConfig.getParameter<double>("tecCut");
0189 
0190   // The minimal accepted weight for the tracks calculated in the
0191   // adaptive vertex fitter to be associated to the displaced vertex
0192   double minAdaptWeight = iConfig.getParameter<double>("minAdaptWeight");
0193 
0194   bool switchOff2TrackVertex = iConfig.getUntrackedParameter<bool>("switchOff2TrackVertex");
0195 
0196   edm::ParameterSet ps_trk = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
0197   edm::ParameterSet ps_vtx = iConfig.getParameter<edm::ParameterSet>("vertexIdentifierParameters");
0198   edm::ParameterSet ps_avf = iConfig.getParameter<edm::ParameterSet>("avfParameters");
0199 
0200   produces<reco::PFDisplacedVertexCollection>();
0201 
0202   // Vertex Finder parameters  -----------------------------------
0203   pfDisplacedVertexFinder_.setDebug(debug);
0204   pfDisplacedVertexFinder_.setParameters(
0205       transvSize, longSize, primaryVertexCut, tobCut, tecCut, minAdaptWeight, switchOff2TrackVertex);
0206   pfDisplacedVertexFinder_.setAVFParameters(ps_avf);
0207   pfDisplacedVertexFinder_.setTracksSelector(ps_trk);
0208   pfDisplacedVertexFinder_.setVertexIdentifier(ps_vtx);
0209 }
0210 
0211 PFDisplacedVertexProducer::~PFDisplacedVertexProducer() {}
0212 
0213 void PFDisplacedVertexProducer::produce(Event& iEvent, const EventSetup& iSetup) {
0214   LogDebug("PFDisplacedVertexProducer") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run();
0215 
0216   // Prepare useful information for the Finder
0217 
0218   auto const& theMagField = &iSetup.getData(magFieldToken_);
0219   auto const& globTkGeom = &iSetup.getData(globTkGeomToken_);
0220   auto const& tkerTopo = &iSetup.getData(tkerTopoToken_);
0221   auto const& tkerGeom = &iSetup.getData(tkerGeomToken_);
0222 
0223   auto const& vertexCandidates = iEvent.getHandle(inputTagVertexCandidates_);
0224   auto const& mainVertexHandle = iEvent.getHandle(inputTagMainVertex_);
0225   auto const& beamSpotHandle = iEvent.getHandle(inputTagBeamSpot_);
0226 
0227   // Fill useful event information for the Finder
0228   pfDisplacedVertexFinder_.setEdmParameters(theMagField, globTkGeom, tkerTopo, tkerGeom);
0229   pfDisplacedVertexFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
0230   pfDisplacedVertexFinder_.setInput(vertexCandidates);
0231 
0232   // Run the finder
0233   pfDisplacedVertexFinder_.findDisplacedVertices();
0234 
0235   if (verbose_) {
0236     ostringstream str;
0237     str << pfDisplacedVertexFinder_;
0238     edm::LogInfo("PFDisplacedVertexProducer") << str.str();
0239   }
0240 
0241   std::unique_ptr<reco::PFDisplacedVertexCollection> pOutputDisplacedVertexCollection(
0242       pfDisplacedVertexFinder_.transferDisplacedVertices());
0243 
0244   iEvent.put(std::move(pOutputDisplacedVertexCollection));
0245 
0246   LogDebug("PFDisplacedVertexProducer") << "STOP event: " << iEvent.id().event() << " in run " << iEvent.id().run();
0247 }