diff --git a/Trigger/TrigFTK/FTK_RecTools/CMakeLists.txt b/Trigger/TrigFTK/FTK_RecTools/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..05aa3e31775e9d11911cc81ae2fa6557c96ffe97 --- /dev/null +++ b/Trigger/TrigFTK/FTK_RecTools/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################################################ +# Package: FTK_RecTools +################################################################################ + +# Declare the package name: +atlas_subdir( FTK_RecTools ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + GaudiKernel + Tools/PyJobTransforms + Tracking/TrkEvent/TrkTrack + Tracking/TrkEvent/VxVertex + Trigger/TrigFTK/FTK_DataProviderInterfaces + Trigger/TrigFTK/FTK_RecToolInterfaces + Trigger/TrigFTK/TrigFTK_RawData ) + +# External dependencies: +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_library( FTK_RecToolsLib + src/*.cxx + PUBLIC_HEADERS FTK_RecTools + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel TrkTrack VxVertex FTK_DataProviderInterfaces TrigFTK_RawData ) + +atlas_add_component( FTK_RecTools + src/components/*.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel TrkTrack VxVertex FTK_DataProviderInterfaces TrigFTK_RawData FTK_RecToolsLib ) + diff --git a/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_VertexFinderTool.h b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_VertexFinderTool.h new file mode 100644 index 0000000000000000000000000000000000000000..ec9179ec86d87c6bb83d0b1b14f85549bc2f3582 --- /dev/null +++ b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_VertexFinderTool.h @@ -0,0 +1,111 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//implementation +//////////////////////////////////////////////////////////////////////////////// +// FTK_VertexFinderTool tool +// ------------------------------- +// ATLAS Collaboration +// +// Return fitted vertices +// +// 10.08.2015 Package created +// +// Author: Rui Wang, ANL +// e-mail: Rui.Wang@cern.ch +// +//////////////////////////////////////////////////////////////////////////////// + + +#ifndef __TRIG_FTK_VERTEXFINDER_TOOL_H__ +#define __TRIG_FTK_VERTEXFINDER_TOOL_H__ + +#include "GaudiKernel/ToolHandle.h" + +#include "AthenaBaseComps/AthAlgTool.h" + +#include "FTK_RecToolInterfaces/IFTK_VertexFinderTool.h" +#include "FTK_DataProviderInterfaces/IFTK_UncertaintyTool.h" + +#include "TrigFTK_RawData/FTK_RawTrack.h" +#include "TrigFTK_RawData/FTK_RawTrackContainer.h" +#include "TrkTrack/TrackCollection.h" +#include "VxVertex/VxContainer.h" +class VxContainer; +using std::vector; +class FTK_VertexFinderTool : public AthAlgTool, virtual public IFTK_VertexFinderTool +{ + //struct to hold track parameters + struct MyTrack{ + MyTrack(int idx,float pt,float theta,float phi,float d0,float z0,float pterr,float thetaerr,float phierr,float d0err,float z0err){ + m_idx=idx; + m_pt=pt; + m_theta=theta; + m_phi=phi; + m_d0=d0; + m_z0=z0; + + m_pterr=pterr; + // m_qoverperr=qoverperr; + m_thetaerr=thetaerr; + m_phierr=phierr; + m_d0err=d0err; + m_z0err=z0err; + } + int m_idx; + double m_pt; + double m_theta; + double m_phi; + double m_d0; + double m_z0; + + double m_pterr; + //double m_qoverperr=qoverperr; + double m_thetaerr; + double m_phierr; + double m_d0err; + double m_z0err; + + //Track pT sort + bool operator<(const MyTrack &a)const{ + return fabs(m_pt) > fabs(a.m_pt); + } + }; + public: + + FTK_VertexFinderTool( const std::string&, const std::string&, const IInterface* ); + virtual ~FTK_VertexFinderTool(){}; + + virtual StatusCode initialize(); + virtual StatusCode finalize (); + + + // + // Get the element of the covariance matrix for id0th and id1th track parameter + // + VxContainer* findVertex(const FTK_RawTrackContainer* trks); + VxContainer* findVertex(const TrackCollection* trks); + + private: + + bool m_barrelOnly; + bool m_hasIBL; + double m_cluster_size; + double m_chi2cut; + double m_constTrkPt; + double m_constTrkEta; + // + // Helper functions with the uncerianties + // + VxContainer* findVertex(vector<MyTrack> trks); + double ctheta2eta(double cot); + vector<MyTrack> getTracks(const FTK_RawTrackContainer* trks); + vector<MyTrack> getTracks(const TrackCollection* trks); + //tool handel + ToolHandle<IFTK_UncertaintyTool> m_uncertaintyTool; +}; + + +#endif + diff --git a/Trigger/TrigFTK/FTK_RecTools/cmt/requirements b/Trigger/TrigFTK/FTK_RecTools/cmt/requirements new file mode 100644 index 0000000000000000000000000000000000000000..45495e383f4488c87a2186d140722bf40c8aa1bc --- /dev/null +++ b/Trigger/TrigFTK/FTK_RecTools/cmt/requirements @@ -0,0 +1,34 @@ +################################################ +package FTK_RecTools + +author Rui Wang <Rui.Wang@cern.ch> + +public +use AtlasPolicy AtlasPolicy-* +use GaudiInterface GaudiInterface-* External +use AtlasROOT AtlasROOT-* External +use AthenaBaseComps AthenaBaseComps-* Control +use PyJobTransforms PyJobTransforms-* Tools +use FTK_RecToolInterfaces FTK_RecToolInterfaces-* Trigger/TrigFTK +use AtlasReconstructionRunTime AtlasReconstructionRunTime-* +use AtlasPolicy AtlasPolicy-* +use GaudiInterface GaudiInterface-* External +use TrigFTK_RawData TrigFTK_RawData-* Trigger/TrigFTK +use FTK_DataProviderInterfaces FTK_DataProviderInterfaces-* Trigger/TrigFTK +########use FTK_DataProviderSvc FTK_DataProviderSvc-* Trigger/TrigFTK + +#TrkTrack and VxVertec need to be public for Collection typedef +use TrkTrack TrkTrack-* Tracking/TrkEvent +use VxVertex VxVertex-* Tracking/TrkEvent + +private + + +# Add transform +apply_pattern declare_job_transforms tfs='*_tf.py' jo='skeleton.*.py' +#end_private +#####apply_pattern declare_runtime extras="../share/FTK_DataProviderLoad.py" +apply_pattern dual_use_library files=*.cxx +apply_pattern declare_joboptions files="*.py" +apply_pattern declare_xmls extras="-s=../share *.dtd *.xml" +apply_pattern declare_python_modules files="*.py" diff --git a/Trigger/TrigFTK/FTK_RecTools/src/FTK_VertexFinderTool.cxx b/Trigger/TrigFTK/FTK_RecTools/src/FTK_VertexFinderTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3cae2180d977fba64bef8c55154d5c8983d2c808 --- /dev/null +++ b/Trigger/TrigFTK/FTK_RecTools/src/FTK_VertexFinderTool.cxx @@ -0,0 +1,422 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//////////////////////////////////////////////////////////////////////////////// +// FTK_VertexFinder tool +// ------------------------------- +// ATLAS Collaboration +// +// Return the fitted vertex +// +// 10.08.2015 Package created +// +// Author: Rui Wang, ANL +// e-mail: Rui.Wang@cern.ch +// +//////////////////////////////////////////////////////////////////////////////// + +#include <cmath> +#include <iostream> +#include <vector> +#include "TVector3.h" +#include "GaudiKernel/MsgStream.h" + +#include "FTK_RecTools/FTK_VertexFinderTool.h" +#include "FTK_DataProviderInterfaces/IFTK_UncertaintyTool.h" +#include "TrigFTK_RawData/FTK_RawTrack.h" +#include "TrkTrack/TrackCollection.h" +#include "VxVertex/VxContainer.h" +#include "VxVertex/ExtendedVxCandidate.h" +#include "VxVertex/RecVertex.h" +#include "VxVertex/Vertex.h" +#include "VxVertex/VxTrackAtVertex.h" +#include "TrigFTK_RawData/FTK_RawTrackContainer.h" + +//#include "CLHEP/Matrix/SymMatrix.h" +//#include "CLHEP/Matrix/Vector.h" +//#include "TrkTrack/Track.h" +//#include "TrkEventPrimitives/FitQuality.h" +//#include "TrkTrackSummary/TrackSummary.h" +//#include "TrkParameters/TrackParameters.h" +//#include "TrkParticleBase/TrackParticleBase.h" +//#include "TrkEventPrimitives/ParamDefs.h" +#include "VxVertex/VxCandidate.h" +#include <map> +#include <vector> +#include <utility> +//#include "TrkSurfaces/PlaneSurface.h" + +using std::map; using std::string; +using std::cout; using std::endl; +using std::vector; using std::iterator; +using Trk::RecVertex;using Trk::VxTrackAtVertex; + + +FTK_VertexFinderTool::FTK_VertexFinderTool(const std::string& t, + const std::string& n, + const IInterface* p ): + AthAlgTool(t,n,p), + m_barrelOnly(false), + m_hasIBL(false), + m_cluster_size(1.87), + m_chi2cut(5.), + m_constTrkPt(1.), + m_constTrkEta(1.1), + m_uncertaintyTool("FTK_UncertaintyTool",this) +{ + declareInterface< IFTK_VertexFinderTool >( this ); + declareProperty( "HasIBL", m_hasIBL); + declareProperty( "BarrelOnly", m_barrelOnly); + declareProperty( "Cluster_size", m_cluster_size); + declareProperty( "Chi2cut", m_chi2cut); + declareProperty( "ConstTrkPt", m_constTrkPt); + declareProperty( "ConstTrkEta", m_constTrkEta); + declareProperty("UncertaintyTool",m_uncertaintyTool); +} + +StatusCode FTK_VertexFinderTool::initialize() { + + StatusCode sc = AlgTool::initialize(); + MsgStream athenaLog(msgSvc(), name()); + + athenaLog << MSG::DEBUG << "FTK_VertexFinderTool initialized "<< endreq; + return sc; +} + +StatusCode FTK_VertexFinderTool::finalize() { + StatusCode sc = AlgTool::finalize(); + return sc; +} + +VxContainer* FTK_VertexFinderTool::findVertex(const FTK_RawTrackContainer* trks) +{ + vector<MyTrack> mytrk; + mytrk=getTracks(trks); + return findVertex(mytrk); +} + +VxContainer* FTK_VertexFinderTool::findVertex(const TrackCollection* trks) +{ + vector<MyTrack> mytrk; + mytrk=getTracks(trks); + return findVertex(mytrk); +} +// +// Covariance Matrix if there is a BLayer Hit +// +VxContainer* FTK_VertexFinderTool::findVertex(vector<MyTrack> mytrk) +{ + + MsgStream athenaLog(msgSvc(), name()); + double mGkx=0.0001; + double mGky=0.0001; + double mGkz=16.; + athenaLog << MSG::DEBUG << "FTK_VertexFinderTool:: barrel " << m_barrelOnly<< endreq; + VxContainer* myVtx = new VxContainer; + vector<MyTrack>::iterator trkbegin; + vector<MyTrack>::iterator trkend; + vector<MyTrack> trkatvtx; + + athenaLog << MSG::DEBUG << "FTK_VertexFinderTool:: total " << mytrk.size()<< " tracks "<< endreq; + sort(mytrk.begin(),mytrk.end());//sorting mytrk by pt(Track7.h) + + int numdo=0; + do{ + athenaLog << MSG::DEBUG << "findVertex: finding vertex "<< endreq; + ////////////////////// + //clustering + ////////////////////// + numdo++; + vector<MyTrack> vxtrk; + //high pt track selecting + trkbegin=mytrk.begin(); + trkend=mytrk.end(); + float seed_z=(*trkbegin).m_z0; + + //selecting tracks near high pt track + for(vector<MyTrack>::iterator i=trkbegin ; i<trkend;){ + if(fabs((*i).m_z0 - seed_z) < m_cluster_size){ + vxtrk.push_back(*i); + i=mytrk.erase(i); + } + else{ + i++; + } + trkbegin=mytrk.begin(); + trkend=mytrk.end(); + } + + //calculating seed z position(z average weighted by z error) + double oldz=0; + double z_weight=0; + trkbegin=vxtrk.begin(); + trkend=vxtrk.end(); + for(vector<MyTrack>::iterator i=trkbegin ; i<trkend;i++){ + oldz += (*i).m_z0*(*i).m_z0err; + z_weight += (*i).m_z0err; + } + oldz /= z_weight; + + double oldx=0; + double oldy=0; + double m_Gk[3][3]={{mGkx,0.,0.},{0.,mGky,0.},{0.,0.,mGkz}};//error + Amg::MatrixX C22_mat(3,3); + double chi2=0; + + trkbegin=vxtrk.begin(); + trkend=vxtrk.end(); + int trknumber=0; + athenaLog << MSG::DEBUG << "FTK_VertexFinderTool:: fit VTX, using "<<vxtrk.size()<<" trks."<< endreq; + for( vector<MyTrack>::iterator i=trkbegin ; i<trkend ;){ + trknumber++; + + athenaLog << MSG::VERBOSE << "getTracks: "<<trknumber<<", pt "<<(*i).m_pt<<", eta "<<(*i).m_theta<<", phi "<<(*i).m_phi<<", d0 "<<(*i).m_d0<<", z0 "<<(*i).m_z0<<", pt err "<<(*i).m_pterr<<", theta err "<<(*i).m_thetaerr<<", phi err "<< (*i).m_phierr<<", d0 err"<< (*i).m_d0err<<", z0 err "<<(*i).m_z0err<< endreq; + //track parameter reading + double xv,yv,zv,P0,phi0,theta0; + TVector3 trk; + xv=oldx; + yv=oldy; + zv=oldz; + P0=(*i).m_pt; + phi0=(*i).m_phi; + theta0=(*i).m_theta; + + //parameter of angle + + double cosPhi0,sinPhi0,sinPsi,cosPsi; + double psi,ctt,sint; + double alpha=0.02997*20.84/1000.0; + + cosPhi0=cos(phi0);sinPhi0=sin(phi0); + sinPsi=-alpha*(xv*cosPhi0+yv*sinPhi0)/P0; + cosPsi=sqrt(1.0-sinPsi*sinPsi); + psi=asin(sinPsi); + sint=sin(theta0); + ctt=cos(theta0)/sint; + + //difference of values expected and observed + + double m_A[2][3],m_B[2][3],m_u[2],m_h[2],m_resid[2]; + + m_A[0][0]=-sin(phi0+psi)/cosPsi; + m_A[0][1]= cos(phi0+psi)/cosPsi; + m_A[0][2]=0.0; + + m_A[1][0]=-ctt*cosPhi0/cosPsi; + m_A[1][1]=-ctt*sinPhi0/cosPsi; + m_A[1][2]=1.0; + + m_B[0][0]=-xv*m_A[0][1]+yv*m_A[0][0]; + m_B[0][1]=0.0; + m_B[0][2]=(1.0-1.0/cosPsi)/alpha; + + m_B[1][0]=-xv*m_A[1][1]+yv*m_A[1][0]; + m_B[1][1]=-P0*psi/(alpha*sint*sint); + m_B[1][2]=ctt*(psi-sinPsi/cosPsi)/alpha; + + m_u[0]=(*i).m_d0; + m_u[1]=(*i).m_z0; + + m_h[0]=yv*cosPhi0-xv*sinPhi0+P0*(1-cosPsi)/alpha; + m_h[1]=zv+P0*ctt*psi/alpha; + + m_resid[0]=m_u[0]-m_h[0]; + m_resid[1]=m_u[1]-m_h[1]; + + //error of difference + + double m_Vqq[3][3]={{(*i).m_phierr*(*i).m_phierr,0.,0.},{0.,(*i).m_thetaerr*(*i).m_thetaerr,0.},{0.,0.,(*i).m_pterr*(*i).m_pterr}}; + double m_Vuu[2][2]={{(*i).m_d0err*(*i).m_d0err,0.},{0.,(*i).m_z0err*(*i).m_z0err}}; + double AC[2][3],BV[2][3],Sk[2][2]; + + for(int i1=0;i1<2;i1++) for(int j=0;j<2;j++) Sk[i1][j]=m_Vuu[i1][j]; + for(int i1=0;i1<2;i1++) for(int j=0;j<3;j++) + { + AC[i1][j]=0.0; + for(int k=0;k<3;k++) AC[i1][j]+=m_A[i1][k]*m_Gk[j][k]; + } + for(int i1=0;i1<2;i1++) for(int j=0;j<2;j++) + { + for(int k=0;k<3;k++) Sk[i1][j]+=AC[i1][k]*m_A[j][k]; + } + for(int i1=0;i1<2;i1++) + for(int j=0;j<3;j++) + { + BV[i1][j]=0.0; + for(int k=0;k<3;k++) BV[i1][j]+=m_B[i1][k]*m_Vqq[k][j]; + } + for(int i1=0;i1<2;i1++) + for(int j=0;j<2;j++) + { + for(int k=0;k<3;k++) Sk[i1][j]+=BV[i1][k]*m_B[j][k]; + } + + //error determinant + double detr,m_V[2][2]; + + detr=1.0/(Sk[0][0]*Sk[1][1]-Sk[0][1]*Sk[1][0]); + m_V[0][0]=Sk[1][1]*detr; + m_V[1][1]=Sk[0][0]*detr; + m_V[0][1]=m_V[1][0]=-Sk[0][1]*detr; + + //chi2 + chi2=m_V[0][0]*m_resid[0]*m_resid[0]+m_V[1][1]*m_resid[1]*m_resid[1]+2.0*m_V[0][1]*m_resid[1]*m_resid[0]; + if(chi2>m_chi2cut || chi2<0){ + i=vxtrk.erase(i); + } + else{ + trkatvtx.push_back(*i); + i++; + } + trkbegin=vxtrk.begin(); + trkend=vxtrk.end(); + //vertex position & covariance update + double K[2][3],dV[3]; + + for(int i2=0;i2<2;i2++){ + for(int j=0;j<3;j++){ + for(int k=0;k<2;k++)K[i2][j]=AC[k][j]*m_V[k][i2]; + } + } + + for(int i2=0;i2<3;i2++){ + dV[i2]=K[0][i2]*m_resid[0]+K[1][i2]*m_resid[1]; + for(int j2=i2;j2<3;j2++){ + m_Gk[i2][j2]-=K[0][i2]*AC[0][j2]+K[1][i2]*AC[1][j2]; + m_Gk[j2][i2]=m_Gk[i2][j2]; + } + } + oldx+=dV[0]; + oldy+=dV[1]; + oldz+=dV[2]; + C22_mat(0,0)=m_Gk[0][0];C22_mat(0,1)=m_Gk[0][1];C22_mat(0,2)=m_Gk[0][0]; + C22_mat(1,0)=m_Gk[1][0];C22_mat(1,1)=m_Gk[1][1];C22_mat(1,2)=m_Gk[1][2]; + C22_mat(2,0)=m_Gk[2][0];C22_mat(2,1)=m_Gk[2][1];C22_mat(2,2)=m_Gk[2][2]; + }//track loop end + if (vxtrk.size()==0)continue; + athenaLog << MSG::DEBUG << "findVertex: find vertex at "<< oldx<<";"<<oldy<<";"<<oldz<< endreq; + Amg::Vector3D frameOrigin(oldx,oldy,oldz); + Trk::RecVertex * fittedVertex; + int ndf = 2*vxtrk.size()-3; + fittedVertex = new RecVertex( frameOrigin, C22_mat, ndf, chi2 ); + std::vector<VxTrackAtVertex*> * tracksAtVertex; + tracksAtVertex = new std::vector<VxTrackAtVertex*>(); + // Store the tracks at vertex + Amg::Vector3D Vertex(frameOrigin[0],frameOrigin[1],frameOrigin[2]); + const Trk::PerigeeSurface Surface(Vertex); + Trk::Perigee * refittedPerigee(0); + vector<MyTrack>::iterator i; + for (i = trkatvtx.begin(); i != trkatvtx.end() ; ++i) + { + AmgSymMatrix(5) * CovMtxP = new AmgSymMatrix(5); + double eta = ctheta2eta((*i).m_theta); + double etaerr=(*i).m_thetaerr*cosh(eta); + double qoverperr=cosh(eta)? 2./cosh(eta) * sqrt(4*(*i).m_pterr*(*i).m_pterr + 1/4/(*i).m_pt/(*i).m_pt*tanh(eta)*tanh(eta)*etaerr*etaerr) : 10; + (*CovMtxP)(0,0)=(*i).m_d0err*(*i).m_d0err; + (*CovMtxP)(0,0)=(*i).m_z0err*(*i).m_z0err; + (*CovMtxP)(0,0)=(*i).m_phierr*(*i).m_phierr; + (*CovMtxP)(0,0)=(*i).m_thetaerr*(*i).m_thetaerr; + (*CovMtxP)(0,0)=qoverperr*qoverperr; + double qoverp = 2/(*i).m_pt/cosh(eta); + refittedPerigee = new Trk::Perigee ((*i).m_d0,(*i).m_z0,(*i).m_phi,(*i).m_theta,qoverp, Surface, CovMtxP); + VxTrackAtVertex* trkV = new VxTrackAtVertex(0, refittedPerigee); + tracksAtVertex->push_back(trkV); + } + + Trk::VxCandidate * fittedVxCandidate = new Trk::VxCandidate(*fittedVertex, *tracksAtVertex); + athenaLog << MSG::VERBOSE << "debug line _31_ "<<fittedVxCandidate->recVertex().fitQuality().doubleNumberDoF()<<"; number of tracks is"<<fittedVxCandidate->vxTrackAtVertex()->size()<< endreq; + myVtx->push_back(fittedVxCandidate); + trkatvtx.clear(); + delete fittedVertex; + //delete fittedVxCandidate; JTB mustn't delete object in container + delete tracksAtVertex; + }while(mytrk.size()>0);//vertex loop end + athenaLog << MSG::VERBOSE << "debug line _326_ "<< myVtx->size()<< endreq; + return myVtx; + +} + +vector<FTK_VertexFinderTool::MyTrack> FTK_VertexFinderTool::getTracks(const FTK_RawTrackContainer* trks){ + + MsgStream athenaLog(msgSvc(), name()); + vector<MyTrack> mytrk; + athenaLog << MSG::DEBUG << "getTracks: find "<< trks->size()<< " tracks "<< endreq; + for (unsigned int ftk_track_index = 0; ftk_track_index != trks->size(); ++ftk_track_index){ + athenaLog << MSG::DEBUG << "getTracks: get "<< ftk_track_index << " track "<< endreq; + const FTK_RawTrack* ftk_track= trks->at(ftk_track_index); + float trk_theta = std::atan2(1.0,ftk_track->getCotTh()); + double invpt= ftk_track->getInvPt(); + float trk_eta = -std::log(std::tan(trk_theta/2)); + float trk_phi = ftk_track->getPhi(); + float trk_d0 = ftk_track->getD0(); + float trk_z0 = ftk_track->getZ0(); + float trk_pt = fabs(1/invpt/1000); +/* double trk_phierr=sqrt(3.446e-7+29.24*invpt*invpt); + double trk_thetaerr=sqrt(7.093e-6+38.4*invpt*invpt); + double trk_pterr=1; + double trk_d0err=sqrt(1.662e-3+6.947e4*invpt*invpt); + double trk_z0err=sqrt(6.472e-2+1.587e5*invpt*invpt); +*/ + double trk_d0err= sqrt(m_uncertaintyTool->getParamCovMtx(*ftk_track, m_hasIBL, FTKTrackParam::d0, FTKTrackParam::d0)); + double trk_z0err= sqrt(m_uncertaintyTool->getParamCovMtx(*ftk_track, m_hasIBL, FTKTrackParam::z0, FTKTrackParam::z0)); + double trk_phierr= sqrt(m_uncertaintyTool->getParamCovMtx(*ftk_track, m_hasIBL, FTKTrackParam::phi, FTKTrackParam::phi)); + double trk_thetaerr= sqrt(m_uncertaintyTool->getParamCovMtx(*ftk_track, m_hasIBL, FTKTrackParam::theta, FTKTrackParam::theta)); + double trk_pterr= sqrt(m_uncertaintyTool->getParamCovMtx(*ftk_track, m_hasIBL, FTKTrackParam::pt, FTKTrackParam::pt)); + + if(fabs(trk_pt)<m_constTrkPt)continue; + if(m_barrelOnly&&fabs(trk_eta)>m_constTrkEta)continue; + MyTrack Trk(ftk_track_index,trk_pt,trk_theta,trk_phi,trk_d0,trk_z0,trk_pterr,trk_thetaerr,trk_phierr,trk_d0err,trk_z0err); + mytrk.push_back(Trk); + } + athenaLog << MSG::DEBUG << "getTracks: total "<< mytrk.size() << " track "<< endreq; + return mytrk; +} + +vector<FTK_VertexFinderTool::MyTrack> FTK_VertexFinderTool::getTracks(const TrackCollection* trks){ + MsgStream athenaLog(msgSvc(), name()); + vector<MyTrack> mytrk; + athenaLog << MSG::DEBUG << "getTracks: find "<< trks->size()<< " tracks "<< endreq; + TrackCollection::const_iterator track_it = trks->begin(); + TrackCollection::const_iterator last_track = trks->end(); + for (int iTrack = 0 ; track_it!= last_track; track_it++, iTrack++) { +// double invpt= sin(trk_Theta)*ftk_track->getCurv()/2.; + double qOverp= (*track_it)->perigeeParameters()->parameters()[Trk::qOverP]; + float trk_theta = (*track_it)->perigeeParameters()->parameters()[Trk::theta]; + float trk_eta = ctheta2eta(trk_theta); + float trk_phi = (*track_it)->perigeeParameters()->parameters()[Trk::phi0]; + float trk_d0 = (*track_it)->perigeeParameters()->parameters()[Trk::d0]; + float trk_z0 = (*track_it)->perigeeParameters()->parameters()[Trk::z0]; + float trk_pt = fabs(1/qOverp/1000/sin(trk_theta)); + float invpt = 1/2/(trk_pt*1000); + double trk_phierr=sqrt(3.446e-7+29.24*invpt*invpt); + double trk_thetaerr=sqrt(7.093e-6+38.4*invpt*invpt); + double trk_pterr=1; + double trk_d0err=sqrt(1.662e-3+6.947e4*invpt*invpt); + double trk_z0err=sqrt(6.472e-2+1.587e5*invpt*invpt); + +/* double trk_d0err=(*track_it)->measuredPerigee()->localErrorMatrix().error(Trk::d0); + double trk_z0err=(*track_it)->measuredPerigee()->localErrorMatrix().error(Trk::z0); + double trk_phi0err=(*track_it)->measuredPerigee()->localErrorMatrix().error(Trk::phi0); + double trk_thetaerr=(*track_it)->measuredPerigee()->localErrorMatrix().error(Trk::theta); + double trk_qOverperr=(*track_it)->measuredPerigee()->localErrorMatrix().error(Trk::qOverP); + double trk_pterr=fabs(trk_qOverperr/trk_qOverp)+cot(trk_theta)*trk_thetaerr)/(sin(trk_theta)*trk_qOverp*1000) +*/ if(fabs(trk_pt)<m_constTrkPt)continue; + if(m_barrelOnly&&fabs(trk_eta)>m_constTrkEta)continue; + mytrk.push_back(MyTrack(iTrack,trk_pt,trk_theta,trk_phi,trk_d0,trk_z0,trk_pterr,trk_thetaerr,trk_phierr,trk_d0err,trk_z0err)); + } + return mytrk; +} + +double FTK_VertexFinderTool::ctheta2eta(double cot){ + double eta=0.0; + double tempX=0.0; + + if(atan(1.0/cot) >= 0) tempX = atan(1.0/cot); + if(atan(1.0/cot) < 0) tempX = atan(1.0/cot)+M_PI; + + eta = -log(tan(tempX/2.0)); + + return eta; +} + diff --git a/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_entries.cxx b/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5c4c30317cd5afafce2cf4cafc893f2f8a88d0e5 --- /dev/null +++ b/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_entries.cxx @@ -0,0 +1,9 @@ +#include "GaudiKernel/DeclareFactoryEntries.h" + +#include "FTK_RecTools/FTK_VertexFinderTool.h" + +DECLARE_TOOL_FACTORY(FTK_VertexFinderTool) + +DECLARE_FACTORY_ENTRIES(FTK_RecTools) { + DECLARE_TOOL(FTK_VertexFinderTool) +} diff --git a/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_load.cxx b/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_load.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ab6eeecf9b08aea3ae8a5d5d2855791e5a2f298b --- /dev/null +++ b/Trigger/TrigFTK/FTK_RecTools/src/components/FTK_RecTools_load.cxx @@ -0,0 +1,3 @@ +#include "GaudiKernel/LoadFactoryEntries.h" + +LOAD_FACTORY_ENTRIES(FTK_RecTools)