ATLAS Offline Software
Loading...
Searching...
No Matches
VertexIterativeFitMergingTool.h
Go to the documentation of this file.
1// This is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef PROMPT_VERTEXITERATIVEFITMERGINGTOOL_H
8#define PROMPT_VERTEXITERATIVEFITMERGINGTOOL_H
9
10/**********************************************************************************
11 * @Package: LeptonTaggers
12 * @Class : VertexIterativeFitMergingTool
13 * @Author : Fudong He
14 * @Author : Rustem Ospanov
15 *
16 * @Brief :
17 *
18 * Merge the input vertices and output merged vertices.
19 *
20 **********************************************************************************/
21
22// Local
24#include "IVertexMergingTool.h"
25#include "IVertexFittingTool.h"
26
27// Athena
31#include "GaudiKernel/ITHistSvc.h"
32#include "GaudiKernel/ToolHandle.h"
33#include "GaudiKernel/ServiceHandle.h"
34
35// xAOD
36#include "xAODTracking/Vertex.h"
38
39// ROOT
40#include "TH1.h"
41
42
43namespace Prompt
44{
45 /*
46 A 2-track vertex.
47 */
59
60 //=============================================================================
62 {
63 bool operator()(const TwoTrackVtx &lhs, const TwoTrackVtx &rhs) { return lhs.sumTrackPt > rhs.sumTrackPt; }
64 };
65
66 //=============================================================================
68 {
69 bool operator()(const xAOD::TrackParticle *lhs, const xAOD::TrackParticle *rhs) { return lhs->pt() > rhs->pt(); }
70 };
71
72
73 //=============================================================================
75 {
76 explicit SortTwoTrackVtxByDistToSeed(const xAOD::Vertex *seed_):seed(seed_) {}
77
78 bool operator()(const TwoTrackVtx &lhs, const TwoTrackVtx &rhs)
79 {
81 }
82
84 };
85
86 //======================================================================================================
87 // Vertex Merging Tool
88 //
90 {
91 public:
92
93 VertexIterativeFitMergingTool(const std::string &name,
94 const std::string &type,
95 const IInterface *parent);
96
97 virtual StatusCode initialize() override;
98
99 /*
100 Perform a deep merge of the initial vertices.
101
102 In the r21 version, the input initVtxs was defined as
103 a const std::vector<xAOD::Vertex*> object. The const-ness
104 had to be removed to work with unique_ptr objects. However,
105 we should avoid modifying the underlying objects in initVtxs.
106 */
108 const EventContext& ctx,
109 const FittingInput &input,
110 const xAOD::TrackParticle *tracklep,
111 std::vector<std::unique_ptr<xAOD::Vertex>> &initVtxs,
112 const std::vector<const xAOD::TrackParticle *> &selectedTracks
113 ) override;
114
115 private:
116
118 const EventContext& ctx,
119 const FittingInput &input,
120 std::vector<std::unique_ptr<xAOD::Vertex>> &initVtxs,
121 MergeResultNotOwner &result,
122 const VtxType vtxType
123 );
124
125 /*
126 Given a seed vertex, this function generates a new merged vertex.
127
128 A new vertex is created and assigned to the newMergedVtx reference.
129 */
131 const EventContext& ctx,
132 xAOD::Vertex* seedVtx,
133 std::unique_ptr<xAOD::Vertex> &newMergedVtx,
134 const FittingInput &input,
135 std::vector<TwoTrackVtx>::iterator &currVit,
136 std::vector<TwoTrackVtx> &vtxs2Track,
137 const VtxType vtxType
138 );
139
140 /*
141 Iteratively fit a new vertex from a seed vertex and group
142 of two-track vertices.
143
144 A new vertex will be created. Because of the complicated ownership
145 semantics of the recursive calls, we release the unique_ptr that is
146 generated when this vertex is created. The caller must capture the
147 bare pointer!
148 */
150 const EventContext& ctx,
151 const FittingInput &input,
152 xAOD::Vertex* seedVtx,
153 const VtxType vtxType,
154 std::vector<TwoTrackVtx> &others
155 );
156 /*
157 Second signature for the iterative vertex fit.
158 This one assumes the seed is owned by the caller.
159 Used to prevent memory leaks within the recursion step
160 */
162 const EventContext& ctx,
163 const FittingInput &input,
164 std::unique_ptr<xAOD::Vertex> & seedVtx,
165 const VtxType vtxType,
166 std::vector<TwoTrackVtx> &others
167 );
168
169 std::unique_ptr<xAOD::Vertex> fitSeedPlusOtherVertex(
170 const EventContext& ctx,
171 const FittingInput &input,
172 const xAOD::Vertex *seedVtx,
173 const xAOD::Vertex *otherVtx,
174 const VtxType vtxType
175 );
176
177 bool passVertexSelection(const xAOD::Vertex *vtx) const;
178
179 /*
180 Remove 2-tracks that are succesfully merged into one vertex.
181
182 This is done by iterating over the list of 2-track vertices and removing
183 those for which both tracks overlap with the mergedVtx.
184 */
186 const xAOD::Vertex *mergedVtx,
187 std::vector<TwoTrackVtx> &vtxs
188 ) const;
189
190 void plotVertexDistances(const std::vector<TwoTrackVtx> &others);
191
192 std::vector<const xAOD::TrackParticle *> getTracksWithoutVertex(
193 const std::vector<xAOD::Vertex*> &passVtxs,
194 const std::vector<const xAOD::TrackParticle *> &selectedTracks
195 );
196
197 /*
198 Fit new 2-track vertices from a list of tracks.
199
200 Since this fits new vertices, it returns a list of unique_ptr
201 so that the caller will handle memory.
202 */
203 std::vector<std::unique_ptr<xAOD::Vertex>> fit2TrackVertexes(
204 const EventContext& ctx,
205 const FittingInput &input,
206 std::vector<const xAOD::TrackParticle *> &selectedTracks,
207 const VtxType vtxType
208 );
209
210 StatusCode makeHist(TH1 *&h, const std::string &key, int nbin, double xmin, double xmax);
211
212 //
213 // Properties:
214 //
215 ToolHandle<Prompt::IVertexFittingTool> m_vertexFitterTool {
216 this, "VertexFittingTool",
217 "Prompt::VertexFittingTool/VertexFittingTool"
218 };
220 this, "THistSvc", "THistSvc/THistSvc"
221 };
222
223 Gaudi::Property<double> m_minFitProb {this, "minFitProb", 0.01,
224 "minimum fit probability requirement for a vertex"
225 };
226 Gaudi::Property<double> m_minCandOverSeedFitProbRatio {
227 this, "minCandOverSeedFitProbRatio", 0.2,
228 "minimum requirement of the fit probability of new merged vertex / fit probability of seed vertex"
229 };
230 Gaudi::Property<unsigned> m_maxExtraTracks {
231 this, "maxExtraTracks", 10,
232 "maximum number of tracks without good lepton+track vertex that we will used for further fitting of vertexes without lepton"
233 };
234
235 Gaudi::Property<std::string> m_outputStream {
236 this, "outputStream", ""
237 };
238
239 //
240 // Development histograms
241 //
246
249
254
260
265
269
274 };
275}
276
277#endif
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Header file for AthHistogramAlgorithm.
std::vector< const xAOD::TrackParticle * > getTracksWithoutVertex(const std::vector< xAOD::Vertex * > &passVtxs, const std::vector< const xAOD::TrackParticle * > &selectedTracks)
ToolHandle< Prompt::IVertexFittingTool > m_vertexFitterTool
void plotVertexDistances(const std::vector< TwoTrackVtx > &others)
std::vector< std::unique_ptr< xAOD::Vertex > > fit2TrackVertexes(const EventContext &ctx, const FittingInput &input, std::vector< const xAOD::TrackParticle * > &selectedTracks, const VtxType vtxType)
bool mergeIteratively2TrackVtxs(const EventContext &ctx, const FittingInput &input, std::vector< std::unique_ptr< xAOD::Vertex > > &initVtxs, MergeResultNotOwner &result, const VtxType vtxType)
VertexIterativeFitMergingTool(const std::string &name, const std::string &type, const IInterface *parent)
void getNewMergedVertex(const EventContext &ctx, xAOD::Vertex *seedVtx, std::unique_ptr< xAOD::Vertex > &newMergedVtx, const FittingInput &input, std::vector< TwoTrackVtx >::iterator &currVit, std::vector< TwoTrackVtx > &vtxs2Track, const VtxType vtxType)
StatusCode makeHist(TH1 *&h, const std::string &key, int nbin, double xmin, double xmax)
std::unique_ptr< xAOD::Vertex > fitSeedPlusOtherVertex(const EventContext &ctx, const FittingInput &input, const xAOD::Vertex *seedVtx, const xAOD::Vertex *otherVtx, const VtxType vtxType)
virtual MergeResultNotOwner mergeInitVertices(const EventContext &ctx, const FittingInput &input, const xAOD::TrackParticle *tracklep, std::vector< std::unique_ptr< xAOD::Vertex > > &initVtxs, const std::vector< const xAOD::TrackParticle * > &selectedTracks) override
xAOD::Vertex * fitSeedVertexCluster(const EventContext &ctx, const FittingInput &input, xAOD::Vertex *seedVtx, const VtxType vtxType, std::vector< TwoTrackVtx > &others)
unsigned removeMerged2TrackVertexes(const xAOD::Vertex *mergedVtx, std::vector< TwoTrackVtx > &vtxs) const
bool passVertexSelection(const xAOD::Vertex *vtx) const
virtual double pt() const override final
The transverse momentum ( ) of the particle.
double xmax
Definition listroot.cxx:61
double xmin
Definition listroot.cxx:60
double getDistance(const xAOD::Vertex *vtx1, const xAOD::Vertex *vtx2)
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
bool operator()(const xAOD::TrackParticle *lhs, const xAOD::TrackParticle *rhs)
bool operator()(const TwoTrackVtx &lhs, const TwoTrackVtx &rhs)
bool operator()(const TwoTrackVtx &lhs, const TwoTrackVtx &rhs)
const xAOD::TrackParticle * trackId0
const xAOD::TrackParticle * trackId1