ATLAS Offline Software
Loading...
Searching...
No Matches
TrigPrimaryVertexFitter Class Reference

#include <TrigPrimaryVertexFitter.h>

Inheritance diagram for TrigPrimaryVertexFitter:
Collaboration diagram for TrigPrimaryVertexFitter:

Public Member Functions

 TrigPrimaryVertexFitter (const std::string &, const std::string &, const IInterface *)
virtual ~TrigPrimaryVertexFitter ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual TrigVertexfit (const TrackCollection *, TrackCollection &, double z=0.0) const
virtual TrigVertexfit (const TrackCollection *, std::vector< double > &, double z=0.0) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

int m_numIter
double m_zVariance
double m_maxChi2Increase
double m_chi2cut
double m_chi2cut_loose
bool m_createTrackLists
double m_xyVariance
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 11 of file TrigPrimaryVertexFitter.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TrigPrimaryVertexFitter()

TrigPrimaryVertexFitter::TrigPrimaryVertexFitter ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 31 of file TrigPrimaryVertexFitter.cxx.

33 : AthAlgTool(t,n,p),
34 m_createTrackLists(false),
35 m_xyVariance(10.0)
36{
37 declareInterface< ITrigPrimaryVertexFitter >( this );
38 declareProperty( "numberOfIterations", m_numIter=3);
39 declareProperty( "maxChi2Increase", m_maxChi2Increase=1000.0);
40 declareProperty( "zVariance", m_zVariance=1.0);
41 declareProperty( "Chi2Cut", m_chi2cut=15.0);
42 declareProperty( "Chi2CutLoose", m_chi2cut_loose=100.0);
43 declareProperty( "CreateTrackLists", m_createTrackLists=false);
44 declareProperty( "xyVariance", m_xyVariance=10.0);
45}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ ~TrigPrimaryVertexFitter()

TrigPrimaryVertexFitter::~TrigPrimaryVertexFitter ( )
virtual

Definition at line 63 of file TrigPrimaryVertexFitter.cxx.

64{
65
66}

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode TrigPrimaryVertexFitter::finalize ( )
virtual

Definition at line 57 of file TrigPrimaryVertexFitter.cxx.

58{
59 ATH_CHECK( AthAlgTool::finalize() );
60 return StatusCode::SUCCESS;
61}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ fit() [1/2]

TrigVertex * TrigPrimaryVertexFitter::fit ( const TrackCollection * tc,
std::vector< double > & Chi2V,
double z = 0.0 ) const
virtual

Implements ITrigPrimaryVertexFitter.

Definition at line 168 of file TrigPrimaryVertexFitter.cxx.

169{
170
171 TrigVertex* pVertex=NULL;
172
173 double chi2;
174 int ndof;
175
176 std::vector<TrigPrimaryVertexTrack*> tracks;
177 tracks.clear();
178 Chi2V.clear();
179 int idx=1;
180 for(TrackCollection::const_iterator ptIt=tc->begin();ptIt!=tc->end();++ptIt)
181 {
182 TrigPrimaryVertexTrack* pT= new TrigPrimaryVertexTrack(*ptIt);
183 if(pT!=NULL)
184 {
185 pT->setIndex(idx++);
186 tracks.push_back(pT);
187 Chi2V.push_back(-100.0);
188 }
189 }
190
191 TrigL2Vertex* pV = new TrigL2Vertex();
192
193 // 1. preliminary fit
194
195 pV->getParametersVector()[0]=0.0;
196 pV->getParametersVector()[1]=0.0;
197 pV->getParametersVector()[2]=z0;
198
199 memset(&pV->m_Gk[0][0],0,sizeof(pV->m_Gk));
202 pV->m_Gk[2][2]=m_zVariance*m_zVariance;
203
204 bool fitFailed=false;
205 for(std::vector<TrigPrimaryVertexTrack*>::iterator it=tracks.begin();it!=tracks.end();++it)
206 {
207 double dchi2=(*it)->getChi2Distance(pV);
208 if(std::isnan(dchi2)||(dchi2<0.0)||(dchi2>m_maxChi2Increase))
209 {
210 fitFailed=true;
211 break;
212 }
213 if(dchi2<m_chi2cut_loose) (*it)->updateVertex(pV);
214 }
215 if(fitFailed)
216 {
217 delete pV;
218 for(std::vector<TrigPrimaryVertexTrack*>::iterator it=tracks.begin();
219 it!=tracks.end();++it) delete (*it);
220 return pVertex;
221 }
222
223 // 2. calculation of "smoothed" chi2s
224
225 memset(&pV->m_Gk[0][0],0,sizeof(pV->m_Gk));
226
227 for(std::vector<TrigPrimaryVertexTrack*>::iterator it=tracks.begin();it!=tracks.end();++it)
228 {
229 double dchi2=(*it)->getChi2Distance(pV);
230 ATH_MSG_DEBUG("Track "<<(*it)->getIndex()<<" dchi2="<<dchi2 );
231 }
232
233 // 3. sort tracks in accordance with their chi2s
234
235 std::sort(tracks.begin(),tracks.end(),TrigPrimaryTrackSortPredicate());
236
237 // 4. Final track fit
238
239 pV->getParametersVector()[0]=0.0;
240 pV->getParametersVector()[1]=0.0;
241 pV->getParametersVector()[2]=z0;
242 fitFailed=false;
243 chi2=0.0;ndof=-3;
244 for(int nIter=0;nIter<m_numIter;nIter++)
245 {
246 memset(&pV->m_Gk[0][0],0,sizeof(pV->m_Gk));
247 pV->m_Gk[0][0]=100.0;
248 pV->m_Gk[1][1]=100.0;
249 pV->m_Gk[2][2]=m_zVariance*m_zVariance;
250 chi2=0.0;ndof=-3;
251 fitFailed=false;
252
253 for(std::vector<TrigPrimaryVertexTrack*>::iterator it=tracks.begin();it!=tracks.end();++it)
254 {
255 double dchi2=(*it)->getChi2Distance(pV);
256 Chi2V[(*it)->getIndex()-1]=dchi2;
257 ATH_MSG_VERBOSE("Track "<<(*it)->getIndex()<<" dchi2="<<dchi2 );
258 if(std::isnan(dchi2)||(dchi2<0.0)||(dchi2>m_maxChi2Increase))
259 {
260 fitFailed=true;
261 break;
262 }
263 if(dchi2<m_chi2cut)
264 {
265 chi2+=dchi2;ndof+=2;
266 (*it)->updateVertex(pV);
267 }
268 else
269 {
270 ATH_MSG_DEBUG("Skipping track "<<(*it)->getIndex()<<"due to large dchi2="<<dchi2 );
271 }
272 }
273 if(fitFailed) break;
274 }
275 for(std::vector<TrigPrimaryVertexTrack*>::iterator it=tracks.begin();it!=tracks.end();++it)
276 {
277 delete (*it);
278 }
279
280 if(!fitFailed && (ndof>0))
281 {
282 ATH_MSG_DEBUG("Primary vertex fit OK, chi2 = "<<chi2<<" NDOF = "<<ndof );
283 ATH_MSG_DEBUG("x= "<<pV->getParametersVector()[0]<<
284 " y= "<<pV->getParametersVector()[1]<<" z= "<<pV->getParametersVector()[2] );
285 double cv[6];
286 cv[0]=pV->m_Gk[0][0];cv[1]=pV->m_Gk[0][1];cv[2]=pV->m_Gk[1][1];
287 cv[3]=pV->m_Gk[0][2];cv[4]=pV->m_Gk[1][2];cv[5]=pV->m_Gk[2][2];
288 pVertex = new TrigVertex(pV->getParametersVector()[0],
289 pV->getParametersVector()[1],
290 pV->getParametersVector()[2],cv,chi2,ndof,NULL);
291 }
292 delete pV;
293
294 return pVertex;
295}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
static Double_t tc
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:837
double * getParametersVector()
returns vector of vertex fit parameters: vertex position + refitted track momenta at-perigee (sic !...
double m_Gk[MAX_SIZE_VERT_COVM][MAX_SIZE_VERT_COVM]
double chi2(TH1 *h0, TH1 *h1)
bool fitFailed
float ndof(const U &p)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ fit() [2/2]

TrigVertex * TrigPrimaryVertexFitter::fit ( const TrackCollection * tc,
TrackCollection & output_tc,
double z = 0.0 ) const
virtual

Implements ITrigPrimaryVertexFitter.

Definition at line 68 of file TrigPrimaryVertexFitter.cxx.

69{
70
71 TrigVertex* pVertex=NULL;
72
73 double chi2;
74 int ndof;
75
76 std::vector<TrigPrimaryVertexTrack*> tracks;
77 tracks.clear();
78 int idx=1;
79 for(TrackCollection::const_iterator ptIt=tc->begin();ptIt!=tc->end();++ptIt)
80 {
81 TrigPrimaryVertexTrack* pT= new TrigPrimaryVertexTrack(*ptIt);
82 if(pT!=NULL) {
83 pT->setIndex(idx++);
84 tracks.push_back(pT);
85 }
86 }
87
88 TrigL2Vertex* pV = new TrigL2Vertex();
89
90 pV->getParametersVector()[0]=0.0;
91 pV->getParametersVector()[1]=0.0;
92 pV->getParametersVector()[2]=z0;
93 bool fitFailed=false;
94 chi2=0.0;ndof=-3;
95 for(int nIter=0;nIter<m_numIter;nIter++)
96 {
97 memset(&pV->m_Gk[0][0],0,sizeof(pV->m_Gk));
100 pV->m_Gk[2][2]=m_zVariance*m_zVariance;
101 chi2=0.0;ndof=-3;
102 fitFailed=false;
103
104 for(std::vector<TrigPrimaryVertexTrack*>::iterator it=tracks.begin();it!=tracks.end();++it)
105 {
106 if(!(*it)->isActive())
107 (*it)->activate();
108
109 double dchi2=(*it)->getChi2Distance(pV);
110 ATH_MSG_VERBOSE("Track "<<(*it)->getIndex()<<" dchi2="<<dchi2 );
111 if(std::isnan(dchi2)||(dchi2<0.0)||(dchi2>m_maxChi2Increase))
112 {
113 fitFailed=true;
114 break;
115 }
116 if(dchi2<m_chi2cut)
117 {
118 chi2+=dchi2;ndof+=2;
119 (*it)->updateVertex(pV);
120 }
121 else
122 {
123 (*it)->mask();
124 ATH_MSG_DEBUG("Skipping track "<<(*it)->getIndex()<<"due to large dchi2="<<dchi2 );
125 }
126 }
127 if(fitFailed) break;
128 }
129
130
131 if(!fitFailed && (ndof>0))
132 {
133 ATH_MSG_DEBUG("Primary vertex fit OK, chi2 = "<<chi2<<" NDOF = "<<ndof );
134 ATH_MSG_DEBUG("x= "<<pV->getParametersVector()[0]<<
135 " y= "<<pV->getParametersVector()[1]<<" z= "<<pV->getParametersVector()[2] );
136 double cv[6];
137 cv[0]=pV->m_Gk[0][0];cv[1]=pV->m_Gk[0][1];cv[2]=pV->m_Gk[1][1];
138 cv[3]=pV->m_Gk[0][2];cv[4]=pV->m_Gk[1][2];cv[5]=pV->m_Gk[2][2];
140 output_tc.clear();
141 output_tc.reserve(tracks.size());
142
143 for(std::vector<TrigPrimaryVertexTrack*>::iterator it=tracks.begin();it!=tracks.end();++it) {
144 if ((*it)->isActive())
145 output_tc.push_back(new Trk::Track(*(*it)->getTrkTrack()));
146 }
147 }
148 pVertex = new TrigVertex(pV->getParametersVector()[0],
149 pV->getParametersVector()[1],
150 pV->getParametersVector()[2],cv,chi2,ndof, nullptr);
151 }
152 delete pV;
153 for(std::vector<TrigPrimaryVertexTrack*>::iterator it=tracks.begin();it!=tracks.end();++it)
154 {
155 delete (*it);
156 }
157 return pVertex;
158}
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void clear()
Erase all the elements in the collection.

◆ initialize()

StatusCode TrigPrimaryVertexFitter::initialize ( )
virtual

Definition at line 47 of file TrigPrimaryVertexFitter.cxx.

48{
49 ATH_CHECK( AthAlgTool::initialize() );
50
51 ATH_MSG_INFO( "Number of iterations is set to " << m_numIter );
52 ATH_MSG_INFO( "Accuracy of starting z-position is " << m_zVariance<<" mm" );
53 ATH_MSG_INFO( "Track lists created ? " << std::boolalpha<<m_createTrackLists );
54 return StatusCode::SUCCESS;
55}
#define ATH_MSG_INFO(x,...)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ITrigPrimaryVertexFitter::interfaceID ( )
inlinestaticinherited

Definition at line 20 of file ITrigPrimaryVertexFitter.h.

20 {
22 }
static const InterfaceID IID_ITrigPrimaryVertexFitter("ITrigPrimaryVertexFitter", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_chi2cut

double TrigPrimaryVertexFitter::m_chi2cut
private

Definition at line 23 of file TrigPrimaryVertexFitter.h.

◆ m_chi2cut_loose

double TrigPrimaryVertexFitter::m_chi2cut_loose
private

Definition at line 23 of file TrigPrimaryVertexFitter.h.

◆ m_createTrackLists

bool TrigPrimaryVertexFitter::m_createTrackLists
private

Definition at line 24 of file TrigPrimaryVertexFitter.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_maxChi2Increase

double TrigPrimaryVertexFitter::m_maxChi2Increase
private

Definition at line 23 of file TrigPrimaryVertexFitter.h.

◆ m_numIter

int TrigPrimaryVertexFitter::m_numIter
private

Definition at line 22 of file TrigPrimaryVertexFitter.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_xyVariance

double TrigPrimaryVertexFitter::m_xyVariance
private

Definition at line 25 of file TrigPrimaryVertexFitter.h.

◆ m_zVariance

double TrigPrimaryVertexFitter::m_zVariance
private

Definition at line 23 of file TrigPrimaryVertexFitter.h.


The documentation for this class was generated from the following files: