CMS 3D CMS Logo

PFDisplacedVertexCandidateProducer.cc
Go to the documentation of this file.
1 
23 
25 public:
27 
29 
30  void produce(edm::Event&, const edm::EventSetup&) override;
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33 private:
36 
40 
42 
44  bool verbose_;
45 
48 };
49 
52 
55  // The track collection use for the fitting. May be any collection.
56  // The only condition is that it shall contain the hit pattern information
57  desc.add<edm::InputTag>("trackCollection", {"generalTracks"});
58  // verbosity
59  desc.addUntracked<bool>("verbose", false);
60  // Debug flag
61  desc.addUntracked<bool>("debug", false);
62  // maximum dca distance for two tracks to be linked
63  desc.add<double>("dcaCut", 0.5);
64  // minimum distance of secondary vertex with respect to the primary
65  desc.add<double>("primaryVertexCut", 1.8);
66  // maximum distance between the DCA Point and the inner hit of the track
67  // not used for the moment
68  desc.add<double>("dcaPInnerHitCut", 1000.0);
69  // Primary vertex information used for dxy calculation
70  desc.add<edm::InputTag>("mainVertexLabel", {"offlinePrimaryVertices", ""});
71  desc.add<edm::InputTag>("offlineBeamSpotLabel", {"offlineBeamSpot", ""});
72  // Tracks preselection to reduce the combinatorics in PFDisplacedVertexCandidates
73  // this cuts are repeated then in a smarter way in the PFDisplacedVertexFinder
74  // be sure you are consistent between them.
75  {
77  // selection parameters for secondary tracks
78  pset.add<double>("nChi2_max", 5.);
79  pset.add<double>("pt_min", 0.2);
80  // if the tracks is not a good candidate to be a secondary (dxy cut) restrict in minimal pt
81  // this cut reduce drastically the combinatorics. It is very useful to reduce the
82  // PFDisplacedVertex timing
83  pset.add<double>("pt_min_prim", 0.8);
84  pset.add<double>("dxy", 0.2);
85  desc.add<edm::ParameterSetDescription>("tracksSelectorParameters", pset);
86  }
87  descriptions.add("particleFlowDisplacedVertexCandidate", desc);
88 }
89 
90 using namespace std;
91 using namespace edm;
92 
94  : magneticFieldToken_(esConsumes()) {
95  // --- Setup input collection names --- //
96  inputTagTracks_ = consumes<reco::TrackCollection>(iConfig.getParameter<InputTag>("trackCollection"));
97 
98  inputTagMainVertex_ = consumes<reco::VertexCollection>(iConfig.getParameter<InputTag>("mainVertexLabel"));
99 
100  inputTagBeamSpot_ = consumes<reco::BeamSpot>(iConfig.getParameter<InputTag>("offlineBeamSpotLabel"));
101 
102  verbose_ = iConfig.getUntrackedParameter<bool>("verbose");
103 
104  bool debug = iConfig.getUntrackedParameter<bool>("debug");
105 
106  // ------ Algo Parameters ------ //
107 
108  // Distance of minimal approach below which
109  // two tracks are considered as linked together
110  double dcaCut = iConfig.getParameter<double>("dcaCut");
111 
112  // Do not reconstruct vertices wich are
113  // too close to the beam pipe
114  double primaryVertexCut = iConfig.getParameter<double>("primaryVertexCut");
115 
116  //maximum distance between the DCA Point and the inner hit of the track
117  double dcaPInnerHitCut = iConfig.getParameter<double>("dcaPInnerHitCut");
118 
119  edm::ParameterSet ps_trk = iConfig.getParameter<edm::ParameterSet>("tracksSelectorParameters");
120 
121  // Collection to be produced
122  produces<reco::PFDisplacedVertexCandidateCollection>();
123 
124  // Vertex Finder parameters -----------------------------------
126  pfDisplacedVertexCandidateFinder_.setParameters(dcaCut, primaryVertexCut, dcaPInnerHitCut, ps_trk);
127 }
128 
130 
132  LogDebug("PFDisplacedVertexCandidateProducer")
133  << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run() << endl;
134 
135  // Prepare and fill useful event information for the Finder
136  auto const& theMagField = &iSetup.getData(magneticFieldToken_);
137 
140 
141  Handle<reco::VertexCollection> mainVertexHandle;
142  iEvent.getByToken(inputTagMainVertex_, mainVertexHandle);
143 
144  Handle<reco::BeamSpot> beamSpotHandle;
145  iEvent.getByToken(inputTagBeamSpot_, beamSpotHandle);
146 
147  pfDisplacedVertexCandidateFinder_.setPrimaryVertex(mainVertexHandle, beamSpotHandle);
149 
150  // Run the finder
152 
153  if (verbose_) {
154  ostringstream str;
157  LogInfo("PFDisplacedVertexCandidateProducer") << str.str() << endl;
158  }
159 
160  std::unique_ptr<reco::PFDisplacedVertexCandidateCollection> pOutputDisplacedVertexCandidateCollection(
162 
163  iEvent.put(std::move(pOutputDisplacedVertexCandidateCollection));
164 
165  LogDebug("PFDisplacedVertexCandidateProducer")
166  << "STOP event: " << iEvent.id().event() << " in run " << iEvent.id().run() << endl;
167 }
void setInput(const edm::Handle< reco::TrackCollection > &trackh, const MagneticField *magField)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::EDGetTokenT< reco::TrackCollection > inputTagTracks_
Reco Tracks used to spot the nuclear interactions.
void setPrimaryVertex(edm::Handle< reco::VertexCollection > mainVertexHandle, edm::Handle< reco::BeamSpot > beamSpotHandle)
PFDisplacedVertexCandidateFinder pfDisplacedVertexCandidateFinder_
Displaced Vertex Candidates finder.
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::BeamSpot > inputTagBeamSpot_
int iEvent
Definition: GenABIO.cc:224
void setDebug(bool debug)
sets debug printout flag
void setParameters(double dcaCut, double primaryVertexCut, double dcaPInnerHitCut, const edm::ParameterSet &ps_trk)
---—— Set different algo parameters —— ///
edm::EDGetTokenT< reco::VertexCollection > inputTagMainVertex_
Input tag for main vertex to cut of dxy of secondary tracks.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::Event &, const edm::EventSetup &) override
trackCollection
Definition: JetHT_cfg.py:51
Log< level::Info, false > LogInfo
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
#define debug
Definition: HDRShower.cc:19
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void findDisplacedVertexCandidates()
-----— Main function which find vertices -----— ///
std::unique_ptr< reco::PFDisplacedVertexCandidateCollection > transferVertexCandidates()
#define str(s)
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)