Commit b552e50e authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

'CMakeLists.txt' (InDetVKalPriVxFinderTool-00-01-03)

parent fd177771
################################################################################
# Package: InDetVKalPriVxFinderTool
################################################################################
# Declare the package name:
atlas_subdir( InDetVKalPriVxFinderTool )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps
Event/xAOD/xAODTracking
GaudiKernel
InnerDetector/InDetRecTools/InDetRecToolInterfaces
Tracking/TrkEvent/TrkParameters
Tracking/TrkEvent/TrkParticleBase
Tracking/TrkEvent/TrkTrack
Tracking/TrkVertexFitter/TrkVKalVrtFitter
PRIVATE
InnerDetector/InDetConditions/InDetBeamSpotService
Tracking/TrkEvent/TrkEventPrimitives
Tracking/TrkEvent/TrkTrackLink
Tracking/TrkEvent/TrkTrackSummary
Tracking/TrkEvent/VxVertex
Tracking/TrkTools/TrkToolInterfaces )
# External dependencies:
find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
# Component(s) in the package:
atlas_add_component( InDetVKalPriVxFinderTool
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps xAODTracking GaudiKernel InDetRecToolInterfaces TrkParameters TrkParticleBase TrkTrack TrkVKalVrtFitterLib TrkEventPrimitives TrkTrackSummary VxVertex TrkToolInterfaces )
# Install files from the package:
atlas_install_headers( InDetVKalPriVxFinderTool )
atlas_install_python_modules( python/*.py )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/*******************************************************
InDetVKalPriVxFinderTool.h - description
A tool to find primary vertex with or without pileup, with or without beam constraint.
It works with TrackCollection of TrackParticleBaseCollection.
Beam position if needed is provided via BeamCond service or
jobOptions.
Tool used VKalVrt vertex fitter (TrkVKalVrtFitter tool).
By default primary vertex finder user robust functional Rob=5 (see VKalVrt
descrption for details) which provides optimal pulls.
Author: Vadim Kostyukhin
e-mail: vadim.kostyukhin@cern.ch
********************************************************/
#ifndef _VKalVrt_InDetVKalPriVxFinderTool_H
#define _VKalVrt_InDetVKalPriVxFinderTool_H
// Normal STL and physical vectors
#include <vector>
// Gaudi includes
#include "TrkTrack/TrackCollection.h"
#include "TrkParameters/TrackParameters.h"
#include "TrkParticleBase/TrackParticleBaseCollection.h"
// Gaudi includes
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
//
#include "TrkVKalVrtFitter/TrkVKalVrtFitter.h"
#include "InDetRecToolInterfaces/IVertexFinder.h"
#include "xAODTracking/Vertex.h"
#include "xAODTracking/TrackParticle.h"
//
class IBeamCondSvc;
namespace Trk {
class ITrackSummaryTool;
class ITrackSelectorTool;
}
namespace InDet {
class InDetVKalPriVxFinderTool : public AthAlgTool, virtual public IVertexFinder
{
public:
InDetVKalPriVxFinderTool(const std::string& t, const std::string& n, const IInterface* p);
virtual ~InDetVKalPriVxFinderTool();
StatusCode initialize();
StatusCode finalize();
//
// Tool interface
//
VxContainer* findVertex(const TrackCollection* trackTES);
VxContainer* findVertex(const Trk::TrackParticleBaseCollection* trackTES);
std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> findVertex(const xAOD::TrackParticleContainer* trackTES);
//
//Old VxContainer* findVertex(const Rec::TrackParticleContainer* partTES);
private:
/* JobOption tunable parameters */
// Beam position
double m_BeamPositionX;
double m_BeamPositionY;
long int m_BeamConstraint;
long int m_TypeRobust;
double m_RobustScale;
// Track selection
long int m_CutSctHits;
long int m_CutPixelHits;
long int m_CutSiHits;
long int m_CutBLayHits;
long int m_CutSharedHits;
double m_CutPt;
double m_CutZVrt;
double m_CutA0;
double m_CutChi2;
double m_A0TrkErrorCut;
double m_ZTrkErrorCut;
// Cuts for track - initial vertex association
double m_RImpSelCut;
double m_ZImpSelCut;
double m_RDistSelCut;
double m_ZDistSelCut;
double m_SignifSelCut;
// Stop point for the common fit
double m_SecTrkChi2Cut;
double m_WeightCut;
// Maximal number of vertices
long int m_NPVertexMax;
ToolHandle< Trk::ITrkVKalVrtFitter > m_fitSvc;
ToolHandle< Trk::ITrackSummaryTool > m_sumSvc; //!< Pointer to the track summary tool
ServiceHandle< IBeamCondSvc > m_iBeamCondSvc; //!< pointer to the beam condition service
//Trk::ITrkVKalVrtFitter* m_fitSvc;
//IBeamCondSvc* m_iBeamCondSvc;
ToolHandle<Trk::ITrackSelectorTool> m_trkSelector;
Amg::Vector3D m_BeamCnst;
std::vector<double> m_BeamCnstWid;
//
int m_SummaryToolExist;
int m_BeamCondSvcExist;
int m_trkSelectorExist;
//
// To simplify life....
StatusCode m_sc;
TLorentzVector m_Momentum;
long int m_Charge;
//----------------------------------------------------------------------------------------------
// Private functions
//
void CleanTrkSet(std::vector<const Trk::TrackParticleBase*>& ,std::vector<const Trk::Track*>&,
Amg::Vector3D &FitVertex, std::vector<double> &Chi2PerTrk,
std::vector<const Trk::TrackParticleBase*>& ,std::vector<const Trk::Track*>&);
int FindMax( std::vector<double>& );
int FindMin( std::vector<double>& );
int FindMaxSecond( std::vector<double>& );
const Trk::Perigee* GetPerigee( const Trk::TrackParticleBase* List);
const Trk::Perigee* GetPerigee( const Trk::Track* List);
void RemoveEntryInList(std::vector<const Trk::Track*>& ListTracks, int );
void RemoveEntryInList(std::vector<const Trk::TrackParticleBase*>& ListTracks, int );
void RemoveEntryInList(std::vector<double>& List, int Outlier);
double GetLimitAngle(double);
void UniqList(std::vector<const Trk::Track*> & List);
void UniqList(std::vector<const Trk::TrackParticleBase*> & List);
void RemoveUsedEntry(std::vector<const Trk::Track*>& ,std::vector<const Trk::Track*>& , std::vector<double> &);
void RemoveUsedEntry(std::vector<const Trk::TrackParticleBase*>& ,
std::vector<const Trk::TrackParticleBase*>&, std::vector<double> & );
void inpSelector(std::vector<const Trk::TrackParticleBase*> & ListParticles,
std::vector<const Trk::Track*> & ListTracks,
Amg::Vector3D & IniVertex,
std::vector<const Trk::TrackParticleBase*> & SelectedParticles,
std::vector<const Trk::Track*> & SelectedTracks);
double FitCommonVrt(std::vector<const Trk::TrackParticleBase*>& ListP,
std::vector<const Trk::Track*>& ListT,
double ZEstimation,
Amg::Vector3D & FitVertex,
std::vector<double> & ErrorMatrix,
std::vector<double> & TrkWeights);
double FindZPosTrk(std::vector<const Trk::Track*>& ListTracks,double & ControlVariable);
double FindZPosTrk(std::vector<const Trk::TrackParticleBase*>& ListTracks,double & ControlVariable);
double FindZPos( std::vector<double> &ZTrk,
std::vector<double> &PtTrk,
std::vector<double> &PxTrk,
std::vector<double> &PyTrk,
std::vector<double> &PhiTrk,
double & ControlVar);
void SetTrkParamVectors(std::vector<const Trk::TrackParticleBase*>& ListTracks,
std::vector<double> &ZTrk,
std::vector<double> &PtTrk,
std::vector<double> &PxTrk,
std::vector<double> &PyTrk,
std::vector<double> &PhiTrk);
void SetTrkParamVectors(std::vector<const Trk::Track*>& ListTracks,
std::vector<double> &ZTrk,
std::vector<double> &PtTrk,
std::vector<double> &PxTrk,
std::vector<double> &PyTrk,
std::vector<double> &PhiTrk);
int PVrtListFind(std::vector<const Trk::TrackParticleBase*> & ListParticles,
std::vector<const Trk::Track*> & ListTracks,
std::vector< Amg::Vector3D > & PVrtList,
std::vector< AmgSymMatrix(3) > & ErrorMatrixPerVrt,
std::vector<double> & Chi2PerVrt,
std::vector<double> & ControlVariablePerVrt,
std::vector< std::vector<const Trk::TrackParticleBase*> > & PrtPerVrt,
std::vector< std::vector<const Trk::Track*> > & TrkPerVrt,
std::vector< std::vector<double> > & TrkWgtPerVrt);
VxContainer* SaveResults( int NVrt,
std::vector< Amg::Vector3D > & PVrtList,
std::vector< AmgSymMatrix(3) > & ErrorMatrixPerVrt,
std::vector<double> & Chi2PerVrt,
std::vector<int> & NTrkPerVrt,
std::vector< std::vector<const Trk::TrackParticleBase*> > & PrtPerVrt,
std::vector< std::vector<const Trk::Track*> > & TrkPerVrt,
std::vector< std::vector<double> > & TrkWgtPerVrt,
const TrackCollection* trackTES = 0,
const Trk::TrackParticleBaseCollection* partTES = 0);
StatusCode CutTrk(double PInvVert, double ThetaVert, double A0Vert, double Chi2,
long int PixelHits,long int SctHits,long int SharedHits, long int BLayHits);
// const vector<const Trk::TrackParticleBase*> Base(const vector<const Rec::TrackParticle*> & listPart);
// const Trk::TrackParticleBase* Base(const Rec::TrackParticle* listPart);
double** getWorkArr2(long int dim1,long int dim2);
void removeWorkArr2(double **Arr,long int dim1,long int dim2);
double*** getWorkArr3(long int dim1,long int dim2,long int dim3);
void removeWorkArr3(double ***Arr,long int dim1,long int dim2,long int dim3);
AmgSymMatrix(5) FillCovMatrix(int iTrk, std::vector<double> & Matrix);
Amg::Vector3D findIniXY(const Trk::TrackParticleBaseCollection* newPrtCol);
Amg::Vector3D findIniXY(const TrackCollection* newPrtCol);
//---------------------------------------------------------------------------
// Arrays for propagation of fit results to steering procedure
//
double ***trkFittedParam3;
std::vector<double **> savedTrkFittedPerigees;
std::vector< std::vector< AmgSymMatrix(5) > > m_fittedTrkCov;
};
} // end of namespace bracket
#endif
package InDetVKalPriVxFinderTool
author Vadim Kostyukhin <Vadim.Kostyukhin@cern.ch>
private
use AtlasROOT AtlasROOT-* External
#
use TrkTrackSummary TrkTrackSummary-* Tracking/TrkEvent
use TrkEventPrimitives TrkEventPrimitives-* Tracking/TrkEvent
use TrkToolInterfaces TrkToolInterfaces-* Tracking/TrkTools
use TrkTrackLink TrkTrackLink-* Tracking/TrkEvent
use InDetBeamSpotService InDetBeamSpotService-* InnerDetector/InDetConditions
use VxVertex VxVertex-* Tracking/TrkEvent
public
use AtlasPolicy AtlasPolicy-*
use GaudiInterface GaudiInterface-* External
use AthenaBaseComps AthenaBaseComps-* Control
#
use TrkTrack TrkTrack-* Tracking/TrkEvent
use TrkParticleBase TrkParticleBase-* Tracking/TrkEvent
use InDetRecToolInterfaces InDetRecToolInterfaces-* InnerDetector/InDetRecTools
use TrkParameters TrkParameters-* Tracking/TrkEvent
use TrkVKalVrtFitter TrkVKalVrtFitter-* Tracking/TrkVertexFitter
use xAODTracking xAODTracking-* Event/xAOD
library InDetVKalPriVxFinderTool *.cxx components/*.cxx
apply_pattern component_library
##apply_pattern dual_use_library files="*.cxx *.F"
##apply_pattern declare_joboptions files="*.txt *.py"
apply_pattern declare_python_modules files="*.py"
private
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
from AthenaCommon.Logging import logging
#
from InDetVKalPriVxFinderToolConf import InDet__InDetVKalPriVxFinderTool
class InDetVKalPriVxFinder ( InDet__InDetVKalPriVxFinderTool ) :
def __init__(self, name="InDetVKalPriVxFinder"):
from AthenaCommon.AppMgr import ToolSvc
mlog = logging.getLogger( 'InDetVKalPriVxFinder::__init__ ' )
mlog.info("entering")
from TrkVKalVrtFitter.TrkVKalVrtFitterConf import Trk__TrkVKalVrtFitter
TrkVKalVrtPFitter = Trk__TrkVKalVrtFitter()
ToolSvc += TrkVKalVrtPFitter
from TrkTrackSummaryTool.AtlasTrackSummaryTool import AtlasTrackSummaryTool
AtlasTrackSummaryTool = AtlasTrackSummaryTool()
mlog.info("AtlasTrackSummaryTool for InDetVKalPriVxFinder created")
ToolSvc += AtlasTrackSummaryTool
InDet__InDetVKalPriVxFinderTool.__init__( self,name="InDetVKalPriVxFinderTool",
TrackSummaryTool=AtlasTrackSummaryTool,
FitterTool=TrkVKalVrtPFitter )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// Header include
#include "InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool.h"
//-------------------------------------------------
namespace InDet {
StatusCode InDetVKalPriVxFinderTool::CutTrk(double PInvVert, double ThetaVert, double A0Vert, double Chi2,
long int PixelHits,long int SctHits,long int SharedHits, long int BLayHits)
{
double Pt = sin(ThetaVert)/fabs(PInvVert);
//- Track quality
if(Pt < m_CutPt) return StatusCode::FAILURE;
if(Chi2 > m_CutChi2) return StatusCode::FAILURE;
if(fabs(A0Vert) > m_CutA0) return StatusCode::FAILURE;
if(PixelHits < m_CutPixelHits) return StatusCode::FAILURE;
if(SctHits < m_CutSctHits) return StatusCode::FAILURE;
if((PixelHits+SctHits) < m_CutSiHits) return StatusCode::FAILURE;
if(BLayHits < m_CutBLayHits) return StatusCode::FAILURE;
if(SharedHits > m_CutSharedHits) return StatusCode::FAILURE;
return StatusCode::SUCCESS;
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// Header include
#include "InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool.h"
//-------------------------------------------------
// Other stuff
#include<iostream>
//
//--------------------------------------------------------
// Routine for global secondary vertex fitting
//
namespace InDet {
int InDetVKalPriVxFinderTool::PVrtListFind(std::vector<const Trk::TrackParticleBase*> & ListParticles,
std::vector<const Trk::Track*> & ListTracks,
std::vector< Amg::Vector3D > & PVrtList,
std::vector< AmgSymMatrix(3) > & ErrorMatrixPerVrt,
std::vector<double> & Chi2PerVrt,
std::vector<double> & ControlVariablePerVrt,
std::vector< std::vector<const Trk::TrackParticleBase*> > & PrtPerVrt,
std::vector< std::vector<const Trk::Track*> > & TrkPerVrt,
std::vector< std::vector<double> > & TrkWgtPerVrt )
{
if(msgLvl(MSG::DEBUG))msg(MSG::DEBUG) << "Primary Vertex Finder called " <<endreq;
// Select track type for vertex finding.
int Selector=2; // Initial choice
int NTracksVrt = 0;
if( ListParticles.size() == 0 && ListTracks.size() == 0 ){return 0; }
if( ListParticles.size() != 0 && ListTracks.size() == 0 ){ Selector =1; NTracksVrt=ListParticles.size(); }
if( ListParticles.size() == 0 && ListTracks.size() != 0 ){ Selector =2; NTracksVrt=ListTracks.size();}
if( NTracksVrt == 0) return 0;
if( NTracksVrt == 1 && !m_BeamConstraint) return 0;
if(Selector==1 && msgLvl(MSG::DEBUG))msg(MSG::DEBUG) << " Trk::TrackParticlesBase are used for vertex search!!!="<<NTracksVrt<<endreq;
if(Selector==2 && msgLvl(MSG::DEBUG))msg(MSG::DEBUG) << " Trk::Tracks are used for vertex search!!!="<<NTracksVrt<<endreq;
//
int NFoundVertices = 0;
std::vector<const Trk::TrackParticleBase*> SelectedParticles;
std::vector<const Trk::Track*> SelectedTracks;
PVrtList.clear();ErrorMatrixPerVrt.clear();Chi2PerVrt.clear();ControlVariablePerVrt.clear();
TrkPerVrt.clear(); PrtPerVrt.clear(); TrkWgtPerVrt.clear();
//
// Fit preparation
//
double ZStartFit=0., ControlVariable, Chi2 ;
std::vector<double> VertexErrorMatrix;
std::vector<double> TrkWeights;
AmgSymMatrix(3) CovMtx;
Amg::Vector3D FitVertex(0.,0.,0.);
//
// Start of fit
//
while ( 1 ) {
if(Selector==1) ZStartFit = FindZPosTrk( ListParticles, ControlVariable);
if(Selector==2) ZStartFit = FindZPosTrk( ListTracks, ControlVariable);
if(msgLvl(MSG::DEBUG))msg(MSG::DEBUG)<< " Z pos estimation= " <<ZStartFit<<" for vertex="<<NFoundVertices<< endreq;
if(ZStartFit < -10000.) return NFoundVertices; // No more candidates
if(NFoundVertices > m_NPVertexMax) return NFoundVertices; // Too many candidates
Amg::Vector3D IniVertex(m_BeamCnst[0], m_BeamCnst[1], ZStartFit);
//
// track selection for given vertex candidates
//
inpSelector(ListParticles,ListTracks,IniVertex,SelectedParticles,SelectedTracks);
//
if(Selector==1){
if( SelectedParticles.size() == 0) break; // 0 tracks selected for fit. Break.
if( SelectedParticles.size() < 2 && NFoundVertices>0 ) break; // One vertex is found already. Break.
if( SelectedParticles.size() == 1 && (!m_BeamConstraint)) break; // 1 track selected for fit. Break.
//VK now after fit RemoveUsedEntry(ListParticles,SelectedParticles);
}
if(Selector==2){
if( SelectedTracks.size() == 0) break; // 0 tracks selected for fit. Break.
if( SelectedTracks.size() < 2 && NFoundVertices>0 ) break; // One vertex is found already. Break.
if( SelectedTracks.size() == 1 && (!m_BeamConstraint) ) break; // 1 track selected for fit. Break.
//VK now after fit RemoveUsedEntry(ListTracks,SelectedTracks);
}
// Now common vertex fit. Also saves results for current vertex, so each vertex may be fitted only ONCE!!!
Chi2 = FitCommonVrt(SelectedParticles,SelectedTracks,ZStartFit,FitVertex,VertexErrorMatrix,TrkWeights);
// if( Chi2 < 0.) break; //Bad fit. Break vertex search !!VK 6.02.2008 Wrong!!!
if( Chi2 > 0. ){
int NTrkInVrt=0;
if(Selector==1)NTrkInVrt=SelectedParticles.size();
if(Selector==2)NTrkInVrt=SelectedTracks.size();
if(fabs(FitVertex.z()-IniVertex.z())>m_ZDistSelCut/2. && NTrkInVrt>4){
ZStartFit=FitVertex.z();
IniVertex<<FitVertex.x(),FitVertex.y(),FitVertex.z();
int lastVrt=savedTrkFittedPerigees.size()-1;
removeWorkArr2(savedTrkFittedPerigees[lastVrt],NTrkInVrt,3); // Remove previous fit results
savedTrkFittedPerigees.pop_back(); m_fittedTrkCov.pop_back(); // Remove previous fit results!!!See above
inpSelector(ListParticles,ListTracks,IniVertex,SelectedParticles,SelectedTracks);
Chi2 = FitCommonVrt(SelectedParticles,SelectedTracks,ZStartFit,FitVertex,VertexErrorMatrix,TrkWeights);
if(Chi2 > 0){
if(Selector==1)NTrkInVrt=SelectedParticles.size();
if(Selector==2)NTrkInVrt=SelectedTracks.size();
}else{ NTrkInVrt=0; }
}
if( NTrkInVrt && (NTrkInVrt>1 || NFoundVertices==0) ){
NFoundVertices++;
Chi2PerVrt.push_back(Chi2);
ControlVariablePerVrt.push_back(ControlVariable);
PVrtList.push_back(FitVertex);
if(Selector==1)PrtPerVrt.push_back(SelectedParticles);
if(Selector==2)TrkPerVrt.push_back(SelectedTracks);
TrkWgtPerVrt.push_back(TrkWeights);
//
CovMtx(0,0)= VertexErrorMatrix[0];
CovMtx(1,0)= CovMtx(0,1) = VertexErrorMatrix[1];
CovMtx(1,1)= VertexErrorMatrix[2];
CovMtx(2,0)= CovMtx(0,2) = VertexErrorMatrix[3];
CovMtx(2,1)= CovMtx(1,2) = VertexErrorMatrix[4];
CovMtx(2,2)= VertexErrorMatrix[5];
ErrorMatrixPerVrt.push_back( CovMtx );
}
}
//
// VK now only tracks attached to vertex are excluded (with weight > m_WeightCut)
if(Selector==1){ RemoveUsedEntry(ListParticles,SelectedParticles,TrkWeights);}
if(Selector==2){ RemoveUsedEntry(ListTracks,SelectedTracks,TrkWeights);}
if(Selector==1 && ListParticles.size() < 2) break; // Less than 2 tracks left
if(Selector==2 && ListTracks.size() < 2) break; // Less than 2 tracks left
} // Next beam vertex
return NFoundVertices;
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// Header include
#include "InDetVKalPriVxFinderTool/InDetVKalPriVxFinderTool.h"
#include "TrkToolInterfaces/ITrackSummaryTool.h"
#include "TrkTrackSummary/TrackSummary.h"
//-------------------------------------------------
// Other stuff
#include <map>
//#include <iostream>
/* Technicalities */
namespace InDet {
void InDetVKalPriVxFinderTool::inpSelector(std::vector<const Trk::TrackParticleBase*> & ListParticles,
std::vector<const Trk::Track*> & ListTracks,
Amg::Vector3D & IniVertex,
std::vector<const Trk::TrackParticleBase*> & SelectedParticles,
std::vector<const Trk::Track*> & SelectedTracks)
{
int Selector=2; // Initial choice
int NTrkInList = 0;
SelectedParticles.clear(); SelectedTracks.clear();
if( ListParticles.size() == 0 && ListTracks.size() == 0 )return;
if( ListParticles.size() != 0 && ListTracks.size() == 0 ){ Selector =1; NTrkInList=ListParticles.size(); }
if( ListParticles.size() == 0 && ListTracks.size() != 0 ){ Selector =2; NTrkInList=ListTracks.size();}
//
// track selection for given vertex candidates