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-2024 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 FittingInput &input,
109 const xAOD::TrackParticle *tracklep,
110 std::vector<std::unique_ptr<xAOD::Vertex>> &initVtxs,
111 const std::vector<const xAOD::TrackParticle *> &selectedTracks
112 ) override;
113
114 private:
115
117 const FittingInput &input,
118 std::vector<std::unique_ptr<xAOD::Vertex>> &initVtxs,
120 const VtxType vtxType
121 );
122
123 /*
124 Given a seed vertex, this function generates a new merged vertex.
125
126 A new vertex is created and assigned to the newMergedVtx reference.
127 */
129 xAOD::Vertex* seedVtx,
130 std::unique_ptr<xAOD::Vertex> &newMergedVtx,
131 const FittingInput &input,
132 std::vector<TwoTrackVtx>::iterator &currVit,
133 std::vector<TwoTrackVtx> &vtxs2Track,
134 const VtxType vtxType
135 );
136
137 /*
138 Iteratively fit a new vertex from a seed vertex and group
139 of two-track vertices.
140
141 A new vertex will be created. Because of the complicated ownership
142 semantics of the recursive calls, we release the unique_ptr that is
143 generated when this vertex is created. The caller must capture the
144 bare pointer!
145 */
147 const FittingInput &input,
148 xAOD::Vertex* seedVtx,
149 const VtxType vtxType,
150 std::vector<TwoTrackVtx> &others
151 );
152 /*
153 Second signature for the iterative vertex fit.
154 This one assumes the seed is owned by the caller.
155 Used to prevent memory leaks within the recursion step
156 */
158 const FittingInput &input,
159 std::unique_ptr<xAOD::Vertex> & seedVtx,
160 const VtxType vtxType,
161 std::vector<TwoTrackVtx> &others
162 );
163
164 std::unique_ptr<xAOD::Vertex> fitSeedPlusOtherVertex(
165 const FittingInput &input,
166 const xAOD::Vertex *seedVtx,
167 const xAOD::Vertex *otherVtx,
168 const VtxType vtxType
169 );
170
171 bool passVertexSelection(const xAOD::Vertex *vtx) const;
172
173 /*
174 Remove 2-tracks that are succesfully merged into one vertex.
175
176 This is done by iterating over the list of 2-track vertices and removing
177 those for which both tracks overlap with the mergedVtx.
178 */
180 const xAOD::Vertex *mergedVtx,
181 std::vector<TwoTrackVtx> &vtxs
182 ) const;
183
184 void plotVertexDistances(const std::vector<TwoTrackVtx> &others);
185
186 std::vector<const xAOD::TrackParticle *> getTracksWithoutVertex(
187 const std::vector<xAOD::Vertex*> &passVtxs,
188 const std::vector<const xAOD::TrackParticle *> &selectedTracks
189 );
190
191 /*
192 Fit new 2-track vertices from a list of tracks.
193
194 Since this fits new vertices, it returns a list of unique_ptr
195 so that the caller will handle memory.
196 */
197 std::vector<std::unique_ptr<xAOD::Vertex>> fit2TrackVertexes(
198 const FittingInput &input,
199 std::vector<const xAOD::TrackParticle *> &selectedTracks,
200 const VtxType vtxType
201 );
202
203 StatusCode makeHist(TH1 *&h, const std::string &key, int nbin, double xmin, double xmax);
204
205 //
206 // Properties:
207 //
208 ToolHandle<Prompt::IVertexFittingTool> m_vertexFitterTool {
209 this, "VertexFittingTool",
210 "Prompt::VertexFittingTool/VertexFittingTool"
211 };
213 this, "THistSvc", "THistSvc/THistSvc"
214 };
215
216 Gaudi::Property<double> m_minFitProb {this, "minFitProb", 0.01,
217 "minimum fit probability requirement for a vertex"
218 };
219 Gaudi::Property<double> m_minCandOverSeedFitProbRatio {
220 this, "minCandOverSeedFitProbRatio", 0.2,
221 "minimum requirement of the fit probability of new merged vertex / fit probability of seed vertex"
222 };
223 Gaudi::Property<unsigned> m_maxExtraTracks {
224 this, "maxExtraTracks", 10,
225 "maximum number of tracks without good lepton+track vertex that we will used for further fitting of vertexes without lepton"
226 };
227
228 Gaudi::Property<std::string> m_outputStream {
229 this, "outputStream", ""
230 };
231
232 //
233 // Development histograms
234 //
239
242
247
253
258
262
267 };
268}
269
270#endif
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Header file for AthHistogramAlgorithm.
virtual MergeResultNotOwner mergeInitVertices(const FittingInput &input, const xAOD::TrackParticle *tracklep, std::vector< std::unique_ptr< xAOD::Vertex > > &initVtxs, const std::vector< const xAOD::TrackParticle * > &selectedTracks) override
std::vector< const xAOD::TrackParticle * > getTracksWithoutVertex(const std::vector< xAOD::Vertex * > &passVtxs, const std::vector< const xAOD::TrackParticle * > &selectedTracks)
std::vector< std::unique_ptr< xAOD::Vertex > > fit2TrackVertexes(const FittingInput &input, std::vector< const xAOD::TrackParticle * > &selectedTracks, const VtxType vtxType)
ToolHandle< Prompt::IVertexFittingTool > m_vertexFitterTool
void plotVertexDistances(const std::vector< TwoTrackVtx > &others)
std::unique_ptr< xAOD::Vertex > fitSeedPlusOtherVertex(const FittingInput &input, const xAOD::Vertex *seedVtx, const xAOD::Vertex *otherVtx, const VtxType vtxType)
bool mergeIteratively2TrackVtxs(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(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)
xAOD::Vertex * fitSeedVertexCluster(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