ATLAS Offline Software
Loading...
Searching...
No Matches
EMTrackFit.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5 /********************************************************************
6
7NAME: EMTrackFit.cxx
8PACKAGE: offline/Reconstruction/egammaEvent
9
10AUTHORS: Anthony Morley
11CREATED: July 2008
12
13PURPOSE: An awful looking object that contains the Electron Track refit information
14MODIFIED:
15 Jun 10, 2009 (FD/AM) Small changes to include brem fit status,
16 brem radius uncertainty and fit Chi2
17 Jun 28, 1010 (JM) Change float to double in accessor functions
18********************************************************************/
19
20// INCLUDE HEADER FILES:
21
25#include "GaudiKernel/GaudiException.h"
28#include "TrkSurfaces/Surface.h"
29#include "TrkTrack/Track.h"
30#include <cmath>
31
32
33
34// END OF HEADER FILES INCLUDE
35
36// ----------------------------
37// Constructor
38// ----------------------------
39
40// give default values
44
45// interfaces
47const std::string& EMTrackFit::className() const
48{
49 return s_className;
50}
51
52// ==============================================================
54{
55
56 if ( hasIntParameter(key) ) {
57 return (double) intParameter(key);
58 }
59
60 using elParams = std::pair<egammaParameters::ParamDef, double>;
61
63 std::vector<elParams>::const_iterator p = m_parameters.begin();
64
65 for (;p !=m_parameters.end(); ++p) {
66 if ( (*p).first == key ) {
67 result = (*p).second;
68 break;
69 }
70 }
71
72 return result;
73}
74
75// ===================================================================
76void EMTrackFit::set_parameter(egammaParameters::ParamDef key, double value, bool overwrite) {
77
78 if ( hasIntParameter(key) ) {
79 set_parameterInt(key,(int)value,overwrite);
80 }
81
82 using elParams = std::pair<egammaParameters::ParamDef, double>;
83
84 std::vector<elParams>::iterator p = m_parameters.begin();
85
86 for (;p !=m_parameters.end(); ++p) {
87 if ( (*p).first == key ) break;
88 }
89
90 if ( p == m_parameters.end() ) {
91 m_parameters.emplace_back(key,value );
92 }
93 else {
94 if ( overwrite ) {
95 (*p).second = value;
96 }
97 else {
98 throw GaudiException("parameter not saved", "EMTrackFit::set_parameter(...)", StatusCode::FAILURE);
99 }
100 }
101
102}
103
104// ==================================================================
106{
107 using elParams = std::pair<egammaParameters::ParamDef, int>;
108
110 std::vector<elParams>::const_iterator p = m_parametersInt.begin();
111
112 for (;p !=m_parametersInt.end(); ++p) {
113 if ( (*p).first == key ){
114 result = (*p).second;
115 break;
116 }
117 }
118
119 return result;
120}
121
122// ===================================================================
123void EMTrackFit::set_parameterInt(egammaParameters::ParamDef key, int value, bool overwrite) {
124
125 using elParams = std::pair<egammaParameters::ParamDef, int>;
126
127 std::vector<elParams>::iterator p = m_parametersInt.begin();
128
129 for (;p !=m_parametersInt.end(); ++p) {
130 if ( (*p).first == key ) break;
131 }
132
133 if ( p == m_parametersInt.end() ) {
134 m_parametersInt.emplace_back(key,value );
135 }
136 else {
137 if ( overwrite ) {
138 (*p).second = value;
139 }
140 else {
141 throw GaudiException("parameter not saved", "EMTrackFit::set_parameter(...)", StatusCode::FAILURE);
142 }
143 }
144
145}
146
147// ========================================================================
149 if (track){
150 bremTrackAuthor( track->info().trackFitter() );
151 fillPerigeeParamters( track->perigeeParameters() );
152 fillLastMeasurement(track);
153 fillBrems(track);
154 } else {
155 throw GaudiException("Parameters not saved, no track", "EMTrackFit::fillDetails(...)", StatusCode::FAILURE);
156 }
157
158 }
159
160// =======================================================================
162
163 std::vector<const Trk::EstimatedBremOnTrack*> estimatedBremOnTrack;
164 std::vector<const Trk::TrackStateOnSurface* > trkStateOnSurfaceWithBrem;
165
166 Trk::TrackStates::const_iterator trackStateOnSurface = track->trackStateOnSurfaces()->begin();
167 //For look for all of the EstimatedBremsOnTrack and add the pointers to a vector
168 for (;trackStateOnSurface < track->trackStateOnSurfaces()->end(); ++trackStateOnSurface){
169 const Trk::EstimatedBremOnTrack* brem = dynamic_cast<const Trk::EstimatedBremOnTrack*>((*trackStateOnSurface)->materialEffectsOnTrack());
170 if (brem){
171 estimatedBremOnTrack.push_back ( brem );
172 trkStateOnSurfaceWithBrem.push_back( (*trackStateOnSurface) );
173 }
174 }
175
176 if (estimatedBremOnTrack.empty()){
177 hasBrem(0);
178 bremRadius(0);
179 bremDeltaZ(0);
180 return;
181 }
182 // The energy loss weighted average position of the brem.
183 std::vector<const Trk::EstimatedBremOnTrack*>::iterator brems = estimatedBremOnTrack.begin();
184 std::vector<const Trk::TrackStateOnSurface*>::iterator tsos = trkStateOnSurfaceWithBrem.begin();
185
186 double Z(1.);
187 double R(0.);
188 double fractionELost(0.);
189 double sigmaRetainedEnFraction(0);
190 for (; brems!=estimatedBremOnTrack.end(); ++brems, ++tsos) {
191
192 fractionELost += 1-(*brems)->retainedEnFraction();
193
194 Z *= (*brems)->retainedEnFraction();
195
196 R += (1-(*brems)->retainedEnFraction()) * (*tsos)->trackParameters()->position().perp();
197 sigmaRetainedEnFraction += (1-(*brems)->retainedEnFraction()) * (*brems)->sigmaRetainedEnFraction();
198 }
199 if (Z>0 && fractionELost>0.){
200 R/=fractionELost;
201 sigmaRetainedEnFraction/=fractionELost;
202 }
203 hasBrem(estimatedBremOnTrack.size());
204 bremRadius(R);
205 bremDeltaZ(Z);
206 //Clearly this is poorly defined for multiple brems a better way of doing this need to be found
207 bremDeltaZerr(sigmaRetainedEnFraction);
208
209 }
210
211// ======================================================================
213
214 if (track == nullptr ){
215 return;
216 }
217
239
240 const Trk::TrackStates* oldTrackStates = track->trackStateOnSurfaces();
241 if (oldTrackStates == nullptr)
242 {
243 return;
244 }
245
246 for ( Trk::TrackStates::const_reverse_iterator rItTSoS = oldTrackStates->rbegin(); rItTSoS != oldTrackStates->rend(); ++rItTSoS)
247 {
248
249 if ( (*rItTSoS)->type(Trk::TrackStateOnSurface::Measurement) && (*rItTSoS)->trackParameters()!=nullptr && (*rItTSoS)->measurementOnTrack()!=nullptr)
250 {
251 const Trk::TrackParameters* trkPara = (*rItTSoS)->trackParameters();
252 track_LastM_loc1 ( trkPara->parameters()[Trk::loc1]);
253 track_LastM_loc2 ( trkPara->parameters()[Trk::loc2]);
254 track_LastM_phi ( trkPara->parameters()[Trk::phi]);
255 track_LastM_theta ( trkPara->parameters()[Trk::theta]);
256 track_LastM_qOverP ( trkPara->parameters()[Trk::qOverP]);
257 break;
258 }
259 }
260 }
261
262// ========================================================================
264 if (trackParameters){
265 track_perigee_d0(trackParameters->parameters()[Trk::d0]);
266 track_perigee_z0(trackParameters->parameters()[Trk::z0]);
267 track_perigee_phi0(trackParameters->parameters()[Trk::phi]);
268 track_perigee_theta(trackParameters->parameters()[Trk::theta]);
269 track_perigee_qOverP(trackParameters->parameters()[Trk::qOverP]);
270
271 if ( !(fillPerigeeErrors(trackParameters->covariance())) ){
272 // This Failed Jolly good
273 }
274
275 return true;
276 }
277 return false;
278
279 return true;
280}
281
283{
284 if(!errorMatrix)
285 return false;
286
287
288 track_perigee_Covd0d0 ((*errorMatrix)(Trk::d0, Trk::d0)) ;
289 track_perigee_Covd0z0 ((*errorMatrix)(Trk::d0, Trk::z0)) ;
290 track_perigee_Covd0phi ((*errorMatrix)(Trk::d0, Trk::phi)) ;
291 track_perigee_Covd0theta ((*errorMatrix)(Trk::d0, Trk::theta)) ;
293 track_perigee_Covz0z0 ((*errorMatrix)(Trk::z0, Trk::z0)) ;
294 track_perigee_Covz0phi ((*errorMatrix)(Trk::z0, Trk::phi)) ;
295 track_perigee_Covz0theta ((*errorMatrix)(Trk::z0, Trk::theta)) ;
297 track_perigee_Covphiphi ((*errorMatrix)(Trk::phi, Trk::phi)) ;
303 return true;
304}
305
306// =======================================================================
307AmgSymMatrix(5) EMTrackFit::getErrorMatrix() const
308{
309 // Make a 5x5 matrix that is filled with zero's alternatively we could fill it with the identity matrix;
310 // Chosen the identity matrix option
311 AmgSymMatrix(5) hepSymMatrix;
312 hepSymMatrix.setIdentity();
313 // Fill the matrix
314 hepSymMatrix.fillSymmetric(0,0, track_perigee_Covd0d0());
315 hepSymMatrix.fillSymmetric(0,1, track_perigee_Covd0z0());
316 hepSymMatrix.fillSymmetric(0,2, track_perigee_Covd0phi());
317 hepSymMatrix.fillSymmetric(0,3, track_perigee_Covd0theta());
318 hepSymMatrix.fillSymmetric(0,4, track_perigee_Covd0qOverP());
319 hepSymMatrix.fillSymmetric(1,1, track_perigee_Covz0z0());
320 hepSymMatrix.fillSymmetric(1,2, track_perigee_Covz0phi());
321 hepSymMatrix.fillSymmetric(1,3, track_perigee_Covz0theta());
322 hepSymMatrix.fillSymmetric(1,4, track_perigee_Covz0qOverP());
323 hepSymMatrix.fillSymmetric(2,2, track_perigee_Covphiphi());
324 hepSymMatrix.fillSymmetric(2,3, track_perigee_Covphitheta());
325 hepSymMatrix.fillSymmetric(2,4, track_perigee_CovphiqOverP());
326 hepSymMatrix.fillSymmetric(3,3, track_perigee_Covthetatheta());
327 hepSymMatrix.fillSymmetric(3,4, track_perigee_CovthetaqOverP());
328 hepSymMatrix.fillSymmetric(4,4, track_perigee_CovqOverPqOverP());
329
330
331 return hepSymMatrix;
332
333}
334
335// ================================================================
337{
338 // Create a MeasuredPerigee from the individual doubles stored in the class.
339
340 const Trk::PerigeeSurface surface;
341
342 const Trk::Perigee* measuredPerigee =
343 surface
344 .createUniqueParameters<5, Trk::Charged>(track_perigee_d0(),
349 getErrorMatrix())
350 .release();
351
352 return measuredPerigee;
353
354}
355
356// =====================================================================
358 if ( hasIntParameter(key) ) return true;
359 if ( key == egammaParameters::refittedTrack_d0 ) return true;
360 else if ( key == egammaParameters::refittedTrack_phi0 ) return true;
361 else if ( key == egammaParameters::refittedTrack_qOverP ) return true;
362 else if ( key == egammaParameters::refittedTrack_z0 ) return true;
363 else if ( key == egammaParameters::refittedTrack_theta ) return true;
364 else if ( key == egammaParameters::refittedTrack_Covd0d0 ) return true;
365 else if ( key == egammaParameters::refittedTrack_Covd0z0 ) return true;
366 else if ( key == egammaParameters::refittedTrack_Covd0phi ) return true;
367 else if ( key == egammaParameters::refittedTrack_Covd0theta ) return true;
368 else if ( key == egammaParameters::refittedTrack_Covd0qOverP) return true;
369 else if ( key == egammaParameters::refittedTrack_Covz0z0 ) return true;
370 else if ( key == egammaParameters::refittedTrack_Covz0phi ) return true;
371 else if ( key == egammaParameters::refittedTrack_Covz0theta ) return true;
372 else if ( key == egammaParameters::refittedTrack_Covz0qOverP )return true;
373 else if ( key == egammaParameters::refittedTrack_Covphiphi ) return true;
374 else if ( key == egammaParameters::refittedTrack_Covphitheta )return true;
375 else if ( key == egammaParameters::refittedTrack_CovphiqOverP)return true;
376 else if ( key == egammaParameters::refittedTrack_Covthetatheta )return true;
377 else if ( key == egammaParameters::refittedTrack_CovthetaqOverP)return true;
378 else if ( key == egammaParameters::refittedTrack_CovqOverPqOverP)return true;
379 else if ( key == egammaParameters::refittedTrackLastM_loc1 ) return true;
380 else if ( key == egammaParameters::refittedTrackLastM_loc2 ) return true;
381 else if ( key == egammaParameters::refittedTrackLastM_phi ) return true;
382 else if ( key == egammaParameters::refittedTrackLastM_theta ) return true;
383 else if ( key == egammaParameters::refittedTrackLastM_qOverP )return true;
384 else if ( key == egammaParameters::bremDeltaQoverP ) return true;
385 else if ( key == egammaParameters::bremDeltaQoverPErr ) return true;
386 else if ( key == egammaParameters::bremMaterialTraversed ) return true;
387 else if ( key == egammaParameters::bremRadius ) return true;
388 else if ( key == egammaParameters::bremClusterRadius ) return true;
389 else if ( key == egammaParameters::bremFitChi2 ) return true;
390 return false;
391}
392
393// =====================================================================
395 if (key == egammaParameters::hasBrem) return true;
396 if (key == egammaParameters::bremTrackAuthor ) return true;
397 else if (key == egammaParameters::bremFitStatus ) return true;
398 else if (key == egammaParameters::linkIndex ) return true;
399
400 return false;
401}
402
403// =======================================================================
409
425
431
437
453
459
461
468
476
479
482
485
486
An interface for getting the name of a class as a string.
Provide an interface for finding inheritance information at run time.
#define SG_ADD_BASE(D, B)
Add a new base class B to class D.
#define AmgSymMatrix(dim)
#define x
static std::string name()
Return the name of class T as a string.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition DataVector.h:847
Contains the fit result with addtional brem information EMTrackFit is made by EMTrkRefitter.
Definition EMTrackFit.h:35
double track_perigee_phi0() const
azimuth angle of the momentum at the point of closest approach after Track Refit
double track_LastM_theta() const
Last Measurment Surface theta after Track Refit.
const Trk::Perigee * getMeasuredPerigee() const
returns the MeasuredPerigee from the stored egammaParameters
double track_LastM_phi() const
Last Measurment Surface azimuth angle after Track Refit.
double track_perigee_Covphiphi() const
Covariance matrix item (phi,phi)
double bremMaterialTraversed() const
Amount of Material seen by the particle according to the track fitter (in X0)
int linkIndex() const
Index of track this EMTrackFit is associated with.
double track_perigee_Covz0theta() const
Covariance matrix item (z0,theta)
double track_perigee_z0() const
the z value at the point of closest approach after Track Refit
double track_perigee_CovthetaqOverP() const
Covariance matrix item (theta,q/P)
bool fillPerigeeParamters(const Trk::Perigee *trackParameters)
Fill the perigree parameter details.
void set_parameterInt(egammaParameters::ParamDef, int, bool overwrite=false)
std::vector< std::pair< egammaParameters::ParamDef, double > > m_parameters
Definition EMTrackFit.h:243
void fillDetails(Trk::Track *track)
Fill the details of the object from a Trk::Track.
double track_LastM_loc2() const
Last Measurment Surface Local Position 2 after Track Refit.
int bremTrackAuthor() const
Track Author enum as Defined in Track/Track.h.
bool fillPerigeeErrors(const AmgSymMatrix(5) *)
Fill the perigree error details.
double track_perigee_theta() const
theta of the track after EMTrackFit
double track_perigee_Covthetatheta() const
Covariance matrix item (theta,theta)
void set_linkIndex(int)
Index of track this EMTrackFit is associated with.
std::vector< std::pair< egammaParameters::ParamDef, int > > m_parametersInt
Definition EMTrackFit.h:244
double bremDeltaZ() const
Fraction of the measured perigee momentum retained after brem.
double track_perigee_qOverP() const
1/pT estimate according to Track Refit
virtual bool hasParameter(egammaParameters::ParamDef) const
void set_parameter(egammaParameters::ParamDef, double, bool overwrite=false)
general set method for parameters
double bremRadius() const
estimated brem radius from EMTrackFit (mm) [x-y plane] (weighted average if more than one brem)
double track_LastM_loc1() const
Last Measurment Surface Local Position 1 after Track Refit.
virtual double parameter(egammaParameters::ParamDef) const
virtual const std::string & className() const
double track_perigee_d0() const
transverse impact parameter (distance of closest approach) after Track Refit
double track_perigee_Covz0qOverP() const
Covariance matrix item (z0,q/p)
static const std::string s_className
Definition EMTrackFit.h:245
double track_perigee_Covz0phi() const
Covariance matrix item (z0,phi)
double track_perigee_Covd0z0() const
Covariance matrix item ( )
double bremRadiusErr() const
estimated brem radius uncertainty
virtual bool hasIntParameter(egammaParameters::ParamDef) const
checks if the parameter is integer
void fillBrems(Trk::Track *track)
Fill in brem information from a Trk::Track.
double track_perigee_Covd0phi() const
Covariance matrix item ( )
EMTrackFit()
Default constructor.
double track_perigee_Covd0qOverP() const
Covariance matrix item (d0,q/p)
int hasBrem() const
The Number of brems identified by the track fitter.
double track_LastM_qOverP() const
Last Measurment Surface q/pT estimate according to Track Refit.
double track_perigee_CovqOverPqOverP() const
Covariance matrix item (q/P,q/P)
double track_perigee_Covphitheta() const
Covariance matrix item (phi,theta)
virtual int intParameter(egammaParameters::ParamDef) const
double track_perigee_Covz0z0() const
Covariance matrix item (z0,z0)
double bremFitChi2() const
Fit Chi2/nDoF.
double track_perigee_CovphiqOverP() const
Covariance matrix item (phi,q/P)
int bremFitStatus() const
Bremfit Status 1 Reached Iteration Limit, 0 Converged, -1 recheached iteration limit,...
double track_perigee_Covd0d0() const
Covariance matrix item ( )
double track_perigee_Covd0theta() const
Covariance matrix item (d0,theta)
void fillLastMeasurement(Trk::Track *track)
Obtains the last measurment on the Track and fills details into the object.
double bremDeltaZerr() const
Error on the fraction of the energy lost after the brem.
class holding information about momentum reduction and an additional noise term due to significant en...
std::unique_ptr< ParametersT< DIM, T, PerigeeSurface > > createUniqueParameters(double l1, double l2, double phi, double theta, double qop, std::optional< AmgSymMatrix(DIM)> cov=std::nullopt) const
Use the Surface as a ParametersBase constructor, from local parameters.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Base class for detailed egamma information.
Definition egDetail.h:29
egDetail()=default
Default constructor.
static std::string release
Definition computils.h:50
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ loc2
generic first and second local coordinate
Definition ParamDefs.h:35
@ phi
Definition ParamDefs.h:75
@ loc1
Definition ParamDefs.h:34
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
ParametersBase< TrackParametersDim, Charged > TrackParameters
@ refittedTrackLastM_loc2
Last Measurment Surface Local Position 2 after Track Refit.
@ bremFitStatus
Minuit EMBremFit fit status.
@ refittedTrack_Covd0z0
Refitted track perigee covariance matrix item ( )
@ bremDeltaQoverPErr
Error on the fraction of energy lost.
@ refittedTrack_Covz0qOverP
Refitted track perigee covariance matrix item (z0,q/p)
@ refittedTrack_Covz0z0
Refitted track perigee covariance matrix item (z0,z0)
@ bremRadius
estimated brem radius from EMBremFit (mm) [x-y plane]
@ refittedTrack_Covphiphi
Refitted track perigee covariance matrix item (phi,phi)
@ refittedTrack_Covphitheta
Refitted track perigee covariance matrix item (phi,theta)
@ refittedTrack_CovqOverPqOverP
Refitted track perigee covariance matrix item (q/P,q/P)
@ refittedTrack_phi0
azimuth angle of the momentum at the point of closest approach after Track Refit
@ refittedTrack_qOverP
1/pT estimate according to Track Refit
@ refittedTrack_Covd0qOverP
Refitted track perigee covariance matrix item (d0,q/p)
@ refittedTrack_Covthetatheta
Refitted track perigee covariance matrix item (theta,theta)
@ refittedTrackLastM_qOverP
Last Measurment Surface q/pT estimate according to Track Refit.
@ bremDeltaQoverP
Fraction of the measured perigee momentum lost.
@ bremMaterialTraversed
The amount of material traversed as seen by the track (in X0)
@ bremTrackAuthor
The author of the Refitted track.
@ refittedTrackLastM_phi
Last Measurment Surface azimuth angle after Track Refit.
@ refittedTrack_Covz0phi
Refitted track perigee covariance matrix item (z0,phi)
@ refittedTrack_theta
theta of the track after EMTrackFit
@ refittedTrackLastM_theta
Last Measurment Surface theta after Track Refit.
@ linkIndex
link index for multiple track and vertex matches
@ refittedTrack_CovthetaqOverP
Refitted track perigee covariance matrix item (theta,q/P)
@ refittedTrack_d0
transverse impact parameter (distance of closest approach) after Track Refit
@ bremClusterRadius
cluster radius (mm) [x-y plane] from EMBremFit (depth)
@ refittedTrack_Covd0phi
Refitted track perigee covariance matrix item ( )
@ refittedTrack_z0
the z value at the point of closest approach after Track Refit
@ refittedTrack_CovphiqOverP
Refitted track perigee covariance matrix item (phi,q/P)
@ refittedTrack_Covd0d0
Refitted track perigee covariance matrix item ( )
@ hasBrem
The Number of brems identified by the track fitter.
@ bremFitChi2
chi2 of EMBremFit
@ refittedTrack_Covz0theta
Refitted track perigee covariance matrix item (z0,theta)
@ refittedTrackLastM_loc1
Last Measurment Surface Local Position 1 after Track Refit.
@ refittedTrack_Covd0theta
Refitted track perigee covariance matrix item (d0,theta)
const double EgParamUndefined