ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::CascadeTools Class Reference

#include <CascadeTools.h>

Inheritance diagram for DerivationFramework::CascadeTools:
Collaboration diagram for DerivationFramework::CascadeTools:

Public Member Functions

 CascadeTools (const std::string &t, const std::string &n, const IInterface *p)
 Default constructor due to Athena interface.
 ~CascadeTools ()
 Virtual destructor.
Amg::Vector3D momentum (const std::vector< TLorentzVector > &particleMom) const
Amg::Vector3D pca (const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double invariantMass (const std::vector< TLorentzVector > &moms, const std::vector< double > &masses) const
double invariantMass (const std::vector< TLorentzVector > &moms) const
double invariantMassError (const std::vector< TLorentzVector > &moms, const Amg::MatrixX &cov, const std::vector< double > &masses) const
double invariantMassError (const std::vector< TLorentzVector > &moms, const Amg::MatrixX &cov) const
double pT (const std::vector< TLorentzVector > &moms) const
double pTError (const std::vector< TLorentzVector > &moms, const Amg::MatrixX &cov) const
double lxy (const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double lxyError (const std::vector< TLorentzVector > &particleMom, const Amg::MatrixX &cov, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double tau (const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double tauError (const std::vector< TLorentzVector > &particleMom, const Amg::MatrixX &cov, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double tau (const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV, double M) const
double tauError (const std::vector< TLorentzVector > &particleMom, const Amg::MatrixX &cov, const xAOD::Vertex *SV, const xAOD::Vertex *PV, double M) const
double a0z (const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double a0zError (const std::vector< TLorentzVector > &particleMom, const Amg::MatrixX &cov, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double a0xy (const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double a0xyError (const std::vector< TLorentzVector > &particleMom, const Amg::MatrixX &cov, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double a0 (const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double a0Error (const std::vector< TLorentzVector > &particleMom, const Amg::MatrixX &cov, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double cosTheta (const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double cosTheta_xy (const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
double massProbability (double V0Mass, double mass, double massErr) const
double vertexProbability (int ndf, double chi2) const
Amg::MatrixXconvertCovMatrix (const xAOD::Vertex *vxCandidate) const
Amg::MatrixX SetFullMatrix (int NTrk, const std::vector< float > &Matrix) 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

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

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 18 of file CascadeTools.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

◆ CascadeTools()

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

Default constructor due to Athena interface.

Definition at line 14 of file CascadeTools.cxx.

14 :
15 AthAlgTool(t,n,p)
16{
17}
AthAlgTool()
Default constructor:

◆ ~CascadeTools()

DerivationFramework::CascadeTools::~CascadeTools ( )

Virtual destructor.

Definition at line 19 of file CascadeTools.cxx.

19{}

Member Function Documentation

◆ a0()

double DerivationFramework::CascadeTools::a0 ( const std::vector< TLorentzVector > & particleMom,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 448 of file CascadeTools.cxx.

449{
450 if(particleMom.size() == 0) return -999999.;
451 double cosineTheta = cosTheta(particleMom,SV,PV);
452 double sinTheta = ((1.-cosineTheta*cosineTheta)>0.) ? sqrt((1.-cosineTheta*cosineTheta)) : 0.;
453 return (SV->position()-PV->position()).mag() * sinTheta;
454}
double cosTheta(const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
const Amg::Vector3D & position() const
Returns the 3-pos.

◆ a0Error()

double DerivationFramework::CascadeTools::a0Error ( const std::vector< TLorentzVector > & particleMom,
const Amg::MatrixX & cov,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 456 of file CascadeTools.cxx.

457{
458 if(particleMom.size() == 0) return -999999.;
459 auto vert = SV->position() - PV->position();
460 double dx = vert.x();
461 double dy = vert.y();
462 double dz = vert.z();
463 Amg::Vector3D P = momentum(particleMom);;
464 double Px = P.x();
465 double Py = P.y();
466 double Pz = P.z();
467 double P2 = P.mag2();
468 double L = Px*dx+Py*dy+Pz*dz;
469 double dR2 = vert.mag2();
470 double d = sqrt((P2*dR2-L*L)/P2);
471
472 unsigned int NTrk = particleMom.size();
473
474 double da0dx = (P2*dx-L*Px)/(P2*d);
475 double da0dy = (P2*dy-L*Py)/(P2*d);
476 double da0dz = (P2*dz-L*Pz)/(P2*d);
477 double da0dx0 = -da0dx;
478 double da0dy0 = -da0dy;
479 double da0dz0 = -da0dz;
480
481 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
482 D_vec(0) = da0dx;
483 D_vec(1) = da0dy;
484 D_vec(2) = da0dz;
485 for( unsigned int it=0; it<NTrk; it++) {
486 D_vec(3*it+3) = (L*(L*Px-P2*dx))/(P2*P2*d);
487 D_vec(3*it+4) = (L*(L*Py-P2*dy))/(P2*P2*d);
488 D_vec(3*it+5) = (L*(L*Pz-P2*dz))/(P2*P2*d);
489 }
490 D_vec(3*NTrk+3) = da0dx0;
491 D_vec(3*NTrk+4) = da0dy0;
492 D_vec(3*NTrk+5) = da0dz0;
493
494 unsigned int ndim = 3*NTrk+3;
495 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
496 W_mat.block(0,0,ndim,ndim) = cov;
497 W_mat.block(3*NTrk+3,3*NTrk+3,3,3) = PV->covariancePosition();
498 Amg::MatrixX V_err = D_vec.transpose() * W_mat * D_vec;
499
500 double a0Errsq = V_err(0,0);
501 if (a0Errsq <= 0.) ATH_MSG_DEBUG("a0Error: negative sqrt a0Errsq " << a0Errsq);
502 return (a0Errsq>0.) ? sqrt(a0Errsq) : 0.;
503}
#define ATH_MSG_DEBUG(x)
static Double_t P(Double_t *tt, Double_t *par)
Amg::Vector3D momentum(const std::vector< TLorentzVector > &particleMom) const
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D

◆ a0xy()

double DerivationFramework::CascadeTools::a0xy ( const std::vector< TLorentzVector > & particleMom,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 395 of file CascadeTools.cxx.

396{
397 if(particleMom.size() == 0) return -999999.;
398 double cosineTheta_xy = cosTheta_xy(particleMom,SV,PV);
399 double sinTheta_xy = ((1.-cosineTheta_xy*cosineTheta_xy)>0.) ? sqrt((1.-cosineTheta_xy*cosineTheta_xy)) : 0.;
400 return (SV->position()-PV->position()).perp() * sinTheta_xy;
401}
double cosTheta_xy(const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const

◆ a0xyError()

double DerivationFramework::CascadeTools::a0xyError ( const std::vector< TLorentzVector > & particleMom,
const Amg::MatrixX & cov,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 403 of file CascadeTools.cxx.

404{
405 if(particleMom.size() == 0) return -999999.;
406 auto vert = SV->position() - PV->position();
407 double dx = vert.x();
408 double dy = vert.y();
409 Amg::Vector3D P = momentum(particleMom);;
410 double Px = P.x();
411 double Py = P.y();
412 double P2 = P.perp()*P.perp();
413 double L = Px*dx+Py*dy;
414 double dR2 = vert.perp()*vert.perp();
415 double d = sqrt((P2*dR2-L*L)/P2);
416
417 unsigned int NTrk = particleMom.size();
418
419 double da0dx = (P2*dx-L*Px)/(P2*d);
420 double da0dy = (P2*dy-L*Py)/(P2*d);
421 double da0dx0 = -da0dx;
422 double da0dy0 = -da0dy;
423
424 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
425 D_vec(0) = da0dx;
426 D_vec(1) = da0dy;
427 D_vec(2) = 0.;
428 for( unsigned int it=0; it<NTrk; it++) {
429 D_vec(3*it+3) = (L*(L*Px-P2*dx))/(P2*P2*d);
430 D_vec(3*it+4) = (L*(L*Py-P2*dy))/(P2*P2*d);
431 D_vec(3*it+5) = 0.;
432 }
433 D_vec(3*NTrk+3) = da0dx0;
434 D_vec(3*NTrk+4) = da0dy0;
435 D_vec(3*NTrk+5) = 0.;
436
437 unsigned int ndim = 3*NTrk+3;
438 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
439 W_mat.block(0,0,ndim,ndim) = cov;
440 W_mat.block(3*NTrk+3,3*NTrk+3,3,3) = PV->covariancePosition();
441 Amg::MatrixX V_err = D_vec.transpose() * W_mat * D_vec;
442
443 double a0xyErrsq = V_err(0,0);
444 if (a0xyErrsq <= 0.) ATH_MSG_DEBUG("a0xyError: negative sqrt a0xyErrsq " << a0xyErrsq);
445 return (a0xyErrsq>0.) ? sqrt(a0xyErrsq) : 0.;
446}

◆ a0z()

double DerivationFramework::CascadeTools::a0z ( const std::vector< TLorentzVector > & particleMom,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 338 of file CascadeTools.cxx.

339{
340 if(particleMom.size() == 0) return -999999.;
341 Amg::Vector3D pv = PV->position();
342 Amg::Vector3D ca_point = pca(particleMom,SV,PV);
343 Amg::Vector3D a0_vec = pv - ca_point;
344 return a0_vec.z();
345}
Amg::Vector3D pca(const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const

◆ a0zError()

double DerivationFramework::CascadeTools::a0zError ( const std::vector< TLorentzVector > & particleMom,
const Amg::MatrixX & cov,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 347 of file CascadeTools.cxx.

348{
349 if(particleMom.size() == 0) return -999999.;
350 auto vert = SV->position() - PV->position();
351 double dx = vert.x();
352 double dy = vert.y();
353 double dz = vert.z();
354 Amg::Vector3D P = momentum(particleMom);;
355 double Px = P.x();
356 double Py = P.y();
357 double Pz = P.z();
358 double P2 = P.mag2();
359 double L = Px*dx+Py*dy+Pz*dz;
360
361 unsigned int NTrk = particleMom.size();
362
363
364 double da0zdx = (Px*Pz)/P2;
365 double da0zdy = (Py*Pz)/P2;
366 double da0zdz = (Pz*Pz)/P2 - 1.;
367 double da0zdx0 = -da0zdx;
368 double da0zdy0 = -da0zdy;
369 double da0zdz0 = -da0zdz;
370
371 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
372 D_vec(0) = da0zdx;
373 D_vec(1) = da0zdy;
374 D_vec(2) = da0zdz;
375 for( unsigned int it=0; it<NTrk; it++) {
376 D_vec(3*it+3) = (Pz*(P2*dx-2.*L*Px))/(P2*P2);
377 D_vec(3*it+4) = (Pz*(P2*dy-2.*L*Py))/(P2*P2);
378 D_vec(3*it+5) = (Pz*(P2*dz-2.*L*Pz))/(P2*P2)+L/P2;
379 }
380 D_vec(3*NTrk+3) = da0zdx0;
381 D_vec(3*NTrk+4) = da0zdy0;
382 D_vec(3*NTrk+5) = da0zdz0;
383
384 unsigned int ndim = 3*NTrk+3;
385 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
386 W_mat.block(0,0,ndim,ndim) = cov;
387 W_mat.block(3*NTrk+3,3*NTrk+3,3,3) = PV->covariancePosition();
388 Amg::MatrixX V_err = D_vec.transpose() * W_mat * D_vec;
389
390 double a0zErrsq = V_err(0,0);
391 if (a0zErrsq <= 0.) ATH_MSG_DEBUG("a0zError: negative sqrt a0zErrsq " << a0zErrsq);
392 return (a0zErrsq>0.) ? sqrt(a0zErrsq) : 0.;
393}

◆ convertCovMatrix()

Amg::MatrixX * DerivationFramework::CascadeTools::convertCovMatrix ( const xAOD::Vertex * vxCandidate) const

Definition at line 555 of file CascadeTools.cxx.

556{
557 unsigned int NTrk = vxCandidate->nTrackParticles();
558 std::vector<float> matrix = vxCandidate->covariance();
559
560 int ndim = 0;
561
562 if ( matrix.size() == (3*NTrk+3)*(3*NTrk+3+1)/2) {
563 ndim = 3*NTrk+3;
564 } else if (matrix.size() == (5*NTrk+3)*(5*NTrk+3+1)/2) {
565 ndim = 5*NTrk+3;
566 } else {
567 return nullptr;
568 }
569
570 Amg::MatrixX* mtx = new Amg::MatrixX(ndim,ndim);
571
572 long int ij=0;
573 for (int i=1; i<= ndim; i++) {
574 for (int j=1; j<=i; j++){
575 if (i==j) {
576 (*mtx)(i-1,j-1)=matrix[ij];
577 } else {
578 (*mtx).fillSymmetric(i-1,j-1,matrix[ij]);
579 }
580 ij++;
581 }
582 }
583 // NOTE: mtx is a pointer! Take care of deleting it after you do not need it anymore!!!
584
585 return mtx;
586}
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
const std::vector< float > & covariance() const
Returns the covariance matrix as a simple vector of values.

◆ cosTheta()

double DerivationFramework::CascadeTools::cosTheta ( const std::vector< TLorentzVector > & particleMom,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 319 of file CascadeTools.cxx.

320{
321 if(particleMom.size() == 0) return -999999.;
322 Amg::Vector3D P = momentum(particleMom);;
323 Amg::Vector3D vtx = SV->position();
324 vtx -= PV->position();
325 return (P.dot(vtx))/(P.mag()*vtx.mag());
326}

◆ cosTheta_xy()

double DerivationFramework::CascadeTools::cosTheta_xy ( const std::vector< TLorentzVector > & particleMom,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 328 of file CascadeTools.cxx.

329{
330 if(particleMom.size() == 0) return -999999.;
331 Amg::Vector3D P = momentum(particleMom);;
332 Amg::Vector3D vtx = SV->position();
333 vtx -= PV->position();
334 double pT = P.perp();
335 return (P.x()*vtx.x()+P.y()*vtx.y())/(pT*vtx.perp());
336}
double pT(const std::vector< TLorentzVector > &moms) const

◆ 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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ 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

◆ 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.

◆ invariantMass() [1/2]

double DerivationFramework::CascadeTools::invariantMass ( const std::vector< TLorentzVector > & moms) const

Definition at line 24 of file CascadeTools.cxx.

25{
26 if(particleMom.size() == 0) return -999999.;
27 TLorentzVector totalMom;
28 unsigned int NTrk = particleMom.size();
29 for( unsigned int it=0; it<NTrk; it++) totalMom += particleMom[it];
30 return totalMom.M();
31}

◆ invariantMass() [2/2]

double DerivationFramework::CascadeTools::invariantMass ( const std::vector< TLorentzVector > & moms,
const std::vector< double > & masses ) const

Definition at line 33 of file CascadeTools.cxx.

34{
35 if(particleMom2.size() == 0) return -999999.;
36 TLorentzVector totalMom;
37 unsigned int NTrk = particleMom2.size();
38 if (masses.size() != NTrk) {
39 ATH_MSG_DEBUG("The provided number of masses does not match the number of tracks in the vertex");
40 return -999999.;
41 }
42 TLorentzVector temp;
43 for( unsigned int it=0; it<NTrk; it++) {
44 double esq = particleMom2[it].Px()*particleMom2[it].Px() + particleMom2[it].Py()*particleMom2[it].Py() +
45 particleMom2[it].Pz()*particleMom2[it].Pz() + masses[it]*masses[it];
46 double e = (esq>0.) ? sqrt(esq) : 0.;
47
48 temp.SetPxPyPzE(particleMom2[it].Px(),particleMom2[it].Py(),particleMom2[it].Pz(),e);
49 totalMom += temp;
50 }
51 return totalMom.M();
52}

◆ invariantMassError() [1/2]

double DerivationFramework::CascadeTools::invariantMassError ( const std::vector< TLorentzVector > & moms,
const Amg::MatrixX & cov ) const

Definition at line 54 of file CascadeTools.cxx.

55{
56 if(particleMom.size() == 0) return -999999.;
57 unsigned int NTrk = particleMom.size();
58 TLorentzVector totalMom;
59 for( unsigned int it=0; it<NTrk; it++) totalMom += particleMom[it];
60
61 Amg::MatrixX D_vec(3*NTrk+3,1); D_vec.setZero();
62 for( unsigned int it=0; it<NTrk; it++) {
63 D_vec(3*it+3) = 2.*(totalMom.E()*particleMom[it].Px()/particleMom[it].E()-totalMom.Px());
64 D_vec(3*it+4) = 2.*(totalMom.E()*particleMom[it].Py()/particleMom[it].E()-totalMom.Py());
65 D_vec(3*it+5) = 2.*(totalMom.E()*particleMom[it].Pz()/particleMom[it].E()-totalMom.Pz());
66 }
67 Amg::MatrixX merr = D_vec.transpose() * cov * D_vec;
68 double massVarsq = merr(0,0);
69 if (massVarsq <= 0.) ATH_MSG_DEBUG("massError: negative sqrt massVarsq " << massVarsq);
70 double massVar = (massVarsq>0.) ? sqrt(massVarsq) : 0.;
71 double massErr = massVar/(2.*totalMom.M());
72 return massErr;
73}

◆ invariantMassError() [2/2]

double DerivationFramework::CascadeTools::invariantMassError ( const std::vector< TLorentzVector > & moms,
const Amg::MatrixX & cov,
const std::vector< double > & masses ) const

Definition at line 75 of file CascadeTools.cxx.

76{
77 if(particleMom2.size() == 0) return -999999.;
78 unsigned int NTrk = particleMom2.size();
79 if (masses.size() != NTrk) {
80 ATH_MSG_DEBUG("The provided number of masses does not match the number of tracks in the vertex");
81 return -999999.;
82 }
83 std::vector<TLorentzVector> particleMom(NTrk);
84 for( unsigned int it=0; it<NTrk; it++) {
85 double esq = particleMom2[it].Px()*particleMom2[it].Px() + particleMom2[it].Py()*particleMom2[it].Py() +
86 particleMom2[it].Pz()*particleMom2[it].Pz() + masses[it]*masses[it];
87 double e = (esq>0.) ? sqrt(esq) : 0.;
88 particleMom[it].SetPxPyPzE(particleMom2[it].Px(),particleMom2[it].Py(),particleMom2[it].Pz(),e);
89 }
90 TLorentzVector totalMom;
91 for( unsigned int it=0; it<NTrk; it++) totalMom += particleMom[it];
92
93 std::vector<double>dm2dpx(NTrk), dm2dpy(NTrk), dm2dpz(NTrk);
94 for( unsigned int it=0; it<NTrk; it++) {
95 dm2dpx[it] = 2.*(totalMom.E()*particleMom[it].Px()/particleMom[it].E()-totalMom.Px());
96 dm2dpy[it] = 2.*(totalMom.E()*particleMom[it].Py()/particleMom[it].E()-totalMom.Py());
97 dm2dpz[it] = 2.*(totalMom.E()*particleMom[it].Pz()/particleMom[it].E()-totalMom.Pz());
98 }
99 Amg::MatrixX D_vec(3*NTrk+3,1); D_vec.setZero();
100 for( unsigned int it=0; it<NTrk; it++) {
101 D_vec(3*it+3) = dm2dpx[it];
102 D_vec(3*it+4) = dm2dpy[it];
103 D_vec(3*it+5) = dm2dpz[it];
104 }
105 Amg::MatrixX merr = D_vec.transpose() * cov * D_vec;
106 double massVarsq = merr(0,0);
107 if (massVarsq <= 0.) ATH_MSG_DEBUG("massError: negative sqrt massVarsq " << massVarsq);
108 double massVar = (massVarsq>0.) ? sqrt(massVarsq) : 0.;
109 double massErr = massVar/(2.*totalMom.M());
110 return massErr;
111}

◆ lxy()

double DerivationFramework::CascadeTools::lxy ( const std::vector< TLorentzVector > & particleMom,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 141 of file CascadeTools.cxx.

142{
143 if(particleMom.size() == 0) return -999999.;
144 auto vert = SV->position() - PV->position();
145 double dx = vert.x();
146 double dy = vert.y();
147 Amg::Vector3D P = momentum(particleMom);;
148 double dxy = (P.x()*dx + P.y()*dy)/P.perp();
149 return dxy;
150}

◆ lxyError()

double DerivationFramework::CascadeTools::lxyError ( const std::vector< TLorentzVector > & particleMom,
const Amg::MatrixX & cov,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 152 of file CascadeTools.cxx.

153{
154 if(particleMom.size() == 0) return -999999.;
155 auto vert = SV->position() - PV->position();
156 double dx = vert.x();
157 double dy = vert.y();
158 Amg::Vector3D P = momentum(particleMom);;
159 double Px = P.x();
160 double Py = P.y();
161 double PT = P.perp();
162 double LXYoverPT = (Px*dx+Py*dy)/(PT*PT);
163
164 unsigned int NTrk = particleMom.size();
165
166 double dLxydx = Px/PT;
167 double dLxydy = Py/PT;
168 double dLxydx0 = -dLxydx;
169 double dLxydy0 = -dLxydy;
170
171 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
172 D_vec(0) = dLxydx;
173 D_vec(1) = dLxydy;
174 D_vec(2) = 0.;
175 for( unsigned int it=0; it<NTrk; it++) {
176 D_vec(3*it+3) = (dx - LXYoverPT*Px)/PT;
177 D_vec(3*it+4) = (dy - LXYoverPT*Py)/PT;
178 D_vec(3*it+5) = 0.;
179 }
180 D_vec(3*NTrk+3) = dLxydx0;
181 D_vec(3*NTrk+4) = dLxydy0;
182 D_vec(3*NTrk+5) = 0.;
183
184 unsigned int ndim = 3*NTrk+3;
185 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
186 W_mat.block(0,0,ndim,ndim) = cov;
187 W_mat.block(3*NTrk+3,3*NTrk+3,3,3) = PV->covariancePosition();
188 Amg::MatrixX V_err = D_vec.transpose() * W_mat * D_vec;
189
190 double LxyErrsq = V_err(0,0);
191 if (LxyErrsq <= 0.) ATH_MSG_DEBUG("lxyError: negative sqrt LxyErrsq " << LxyErrsq);
192 return (LxyErrsq>0.) ? sqrt(LxyErrsq) : 0.;
193}
H5::PredType PT
Definition H5Traits.cxx:15

◆ massProbability()

double DerivationFramework::CascadeTools::massProbability ( double V0Mass,
double mass,
double massErr ) const

Definition at line 519 of file CascadeTools.cxx.

520{
521 if(massErr > 0.) {
522 double chi2 = (V0Mass - mass)*(V0Mass - mass)/(massErr*massErr);
523 int ndf = 1;
524 Genfun::CumulativeChiSquare myCumulativeChiSquare(ndf);
525 if (chi2 > 0.) {
526 double achi2prob = 1.-myCumulativeChiSquare(chi2);
527 return achi2prob;
528 } else {
529 ATH_MSG_DEBUG("chi2 <= 0");
530 return -1.;
531 }
532 } else {
533 return -1.;
534 }
535}
double chi2(TH1 *h0, TH1 *h1)

◆ momentum()

Amg::Vector3D DerivationFramework::CascadeTools::momentum ( const std::vector< TLorentzVector > & particleMom) const

Definition at line 505 of file CascadeTools.cxx.

506{
507 if(particleMom.size() == 0) {
508 Amg::Vector3D p; p.setZero();
509 return p;
510 }
511 TLorentzVector totalMom;
512 unsigned int NTrk = particleMom.size();
513 for( unsigned int it=0; it<NTrk; it++) totalMom += particleMom[it];
514 TVector3 P3 = totalMom.Vect();
515 Amg::Vector3D mom(P3.Px(),P3.Py(),P3.Pz());
516 return mom;
517}

◆ 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.

◆ pca()

Amg::Vector3D DerivationFramework::CascadeTools::pca ( const std::vector< TLorentzVector > & particleMom,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 305 of file CascadeTools.cxx.

306{
307 if(particleMom.size() == 0) {
308 Amg::Vector3D p; p.setZero();
309 return p;
310 }
311 Amg::Vector3D pv = PV->position();
312 Amg::Vector3D sv = SV->position();
313 Amg::Vector3D P = momentum(particleMom);;
314 double p2 = P.mag2();
315 double pdr = P.dot((sv - pv));
316 return sv - P*pdr/p2;
317}

◆ pT()

double DerivationFramework::CascadeTools::pT ( const std::vector< TLorentzVector > & moms) const

Definition at line 113 of file CascadeTools.cxx.

114{
115 if(particleMom.size() == 0) return -999999.;
116 Amg::Vector3D P = momentum(particleMom);;
117 return P.perp();
118}

◆ pTError()

double DerivationFramework::CascadeTools::pTError ( const std::vector< TLorentzVector > & moms,
const Amg::MatrixX & cov ) const

Definition at line 120 of file CascadeTools.cxx.

121{
122 if(particleMom.size() == 0) return -999999.;
123 Amg::Vector3D P = momentum(particleMom);;
124 double Px = P.x();
125 double Py = P.y();
126 double PT = P.perp();
127
128 unsigned int NTrk = particleMom.size();
129 Amg::MatrixX D_vec(3*NTrk+3,1); D_vec.setZero();
130 for( unsigned int it=0; it<NTrk; it++) {
131 D_vec(3*it+3) = Px/PT;
132 D_vec(3*it+4) = Py/PT;
133 D_vec(3*it+5) = 0.;
134 }
135 Amg::MatrixX PtErrSq = D_vec.transpose() * cov * D_vec;
136 double PtErrsq = PtErrSq(0,0);
137 if (PtErrsq <= 0.) ATH_MSG_DEBUG("ptError: negative sqrt PtErrsq " << PtErrsq);
138 return (PtErrsq>0.) ? sqrt(PtErrsq) : 0.;
139}

◆ 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 }

◆ SetFullMatrix()

Amg::MatrixX DerivationFramework::CascadeTools::SetFullMatrix ( int NTrk,
const std::vector< float > & Matrix ) const

Definition at line 588 of file CascadeTools.cxx.

589{
590
591 Amg::MatrixX mtx(3+3*NTrk,3+3*NTrk); // Create identity matrix of needed size
592
593 int ij=0;
594
595 for(int i=0; i<(3+3*NTrk); i++){
596 for(int j=0; j<=i; j++){
597 mtx(i,j)=Matrix[ij];
598 if(i!=j) mtx(j,i)=Matrix[ij];
599 ij++;
600 }
601 }
602
603 return mtx;
604}

◆ 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 >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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.

◆ tau() [1/2]

double DerivationFramework::CascadeTools::tau ( const std::vector< TLorentzVector > & particleMom,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 195 of file CascadeTools.cxx.

196{
197 if(particleMom.size() == 0) return -999999.;
198 double M = invariantMass(particleMom);
199 double LXY = lxy(particleMom,SV,PV);
200 double PT = pT(particleMom);
201 return s_CONST*M*LXY/PT;
202}
double invariantMass(const std::vector< TLorentzVector > &moms, const std::vector< double > &masses) const
double lxy(const std::vector< TLorentzVector > &particleMom, const xAOD::Vertex *SV, const xAOD::Vertex *PV) const
constexpr double s_CONST

◆ tau() [2/2]

double DerivationFramework::CascadeTools::tau ( const std::vector< TLorentzVector > & particleMom,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV,
double M ) const

Definition at line 251 of file CascadeTools.cxx.

252{
253 if(particleMom.size() == 0) return -999999.;
254 double LXY = lxy(particleMom,SV,PV);
255 double PT = pT(particleMom);
256 return s_CONST*M*LXY/PT;
257}

◆ tauError() [1/2]

double DerivationFramework::CascadeTools::tauError ( const std::vector< TLorentzVector > & particleMom,
const Amg::MatrixX & cov,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV ) const

Definition at line 204 of file CascadeTools.cxx.

205{
206 if(particleMom.size() == 0) return -999999.;
207 double M = invariantMass(particleMom);
208 auto vert = SV->position() - PV->position();
209 double dx = vert.x();
210 double dy = vert.y();
211 Amg::Vector3D P = momentum(particleMom);;
212 double Px = P.x();
213 double Py = P.y();
214 double PT = P.perp();
215 double LXY = Px*dx+Py*dy;
216
217 unsigned int NTrk = particleMom.size();
218 TLorentzVector totalMom;
219 for( unsigned int it=0; it<NTrk; it++) totalMom += particleMom[it];
220
221 double dTaudx = (M*Px)/(PT*PT);
222 double dTaudy = (M*Py)/(PT*PT);
223 double dTaudx0 = -dTaudx;
224 double dTaudy0 = -dTaudy;
225
226 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
227 D_vec(0) = dTaudx;
228 D_vec(1) = dTaudy;
229 D_vec(2) = 0.;
230 for( unsigned int it=0; it<NTrk; it++) {
231 D_vec(3*it+3) = (((totalMom.E()*particleMom[it].Px()*LXY)/(M*particleMom[it].E()))-Px*LXY/M+M*dx)/(PT*PT) - 2.*M*LXY*Px/(PT*PT*PT*PT);
232 D_vec(3*it+4) = (((totalMom.E()*particleMom[it].Py()*LXY)/(M*particleMom[it].E()))-Py*LXY/M+M*dy)/(PT*PT) - 2.*M*LXY*Py/(PT*PT*PT*PT);
233 D_vec(3*it+5) = 0.;
234 }
235 D_vec(3*NTrk+3) = dTaudx0;
236 D_vec(3*NTrk+4) = dTaudy0;
237 D_vec(3*NTrk+5) = 0.;
238
239 unsigned int ndim = 3*NTrk+3;
240 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
241 W_mat.block(0,0,ndim,ndim) = cov;
242 W_mat.block(3*NTrk+3,3*NTrk+3,3,3) = PV->covariancePosition();
243 Amg::MatrixX V_err = D_vec.transpose() * W_mat * D_vec;
244
245 double tauErrsq = V_err(0,0);
246 if (tauErrsq <= 0.) ATH_MSG_DEBUG("tauError: negative sqrt tauErrsq " << tauErrsq);
247 double tauErr = (tauErrsq>0.) ? sqrt(tauErrsq) : 0.;
248 return s_CONST*tauErr;
249}

◆ tauError() [2/2]

double DerivationFramework::CascadeTools::tauError ( const std::vector< TLorentzVector > & particleMom,
const Amg::MatrixX & cov,
const xAOD::Vertex * SV,
const xAOD::Vertex * PV,
double M ) const

Definition at line 259 of file CascadeTools.cxx.

260{
261 if(particleMom.size() == 0) return -999999.;
262 auto vert = SV->position() - PV->position();
263 double dx = vert.x();
264 double dy = vert.y();
265 Amg::Vector3D P = momentum(particleMom);;
266 double Px = P.x();
267 double Py = P.y();
268 double PT = P.perp();
269 double LXY = Px*dx+Py*dy;
270
271 unsigned int NTrk = particleMom.size();
272 TLorentzVector totalMom;
273 for( unsigned int it=0; it<NTrk; it++) totalMom += particleMom[it];
274
275 double dTaudx = (M*Px)/(PT*PT);
276 double dTaudy = (M*Py)/(PT*PT);
277 double dTaudx0 = -dTaudx;
278 double dTaudy0 = -dTaudy;
279
280 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
281 D_vec(0) = dTaudx;
282 D_vec(1) = dTaudy;
283 D_vec(2) = 0.;
284 for( unsigned int it=0; it<NTrk; it++) {
285 D_vec(3*it+3) = (M*dx)/(PT*PT) - 2.*M*LXY*Px/(PT*PT*PT*PT);
286 D_vec(3*it+4) = (M*dy)/(PT*PT) - 2.*M*LXY*Py/(PT*PT*PT*PT);
287 D_vec(3*it+5) = 0.;
288 }
289 D_vec(3*NTrk+3) = dTaudx0;
290 D_vec(3*NTrk+4) = dTaudy0;
291 D_vec(3*NTrk+5) = 0.;
292
293 unsigned int ndim = 3*NTrk+3;
294 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
295 W_mat.block(0,0,ndim,ndim) = cov;
296 W_mat.block(3*NTrk+3,3*NTrk+3,3,3) = PV->covariancePosition();
297 Amg::MatrixX V_err = D_vec.transpose() * W_mat * D_vec;
298
299 double tauErrsq = V_err(0,0);
300 if (tauErrsq <= 0.) ATH_MSG_DEBUG("tauError: negative sqrt tauErrsq " << tauErrsq);
301 double tauErr = (tauErrsq>0.) ? sqrt(tauErrsq) : 0.;
302 return s_CONST*tauErr;
303}

◆ 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

◆ vertexProbability()

double DerivationFramework::CascadeTools::vertexProbability ( int ndf,
double chi2 ) const

Definition at line 537 of file CascadeTools.cxx.

538{
539 if (ndf > 0.) {
540 Genfun::CumulativeChiSquare myCumulativeChiSquare(ndf);
541 if (chi2 > 0.) {
542 double chi2prob = 1.-myCumulativeChiSquare(chi2);
543 return chi2prob;
544 } else {
545 ATH_MSG_DEBUG("chi2 <= 0");
546 return -1.;
547 }
548 } else {
549 ATH_MSG_DEBUG("ndf <= 0");
550 return -1.;
551 }
552}

Member Data Documentation

◆ 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_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.


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