diff --git a/InnerDetector/InDetRecTools/SiSpacePointTool/CMakeLists.txt b/InnerDetector/InDetRecTools/SiSpacePointTool/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7e8492d2f9c96c10f5dfd88abb2bab6e90867c2b --- /dev/null +++ b/InnerDetector/InDetRecTools/SiSpacePointTool/CMakeLists.txt @@ -0,0 +1,35 @@ +################################################################################ +# Package: SiSpacePointTool +################################################################################ + +# Declare the package name: +atlas_subdir( SiSpacePointTool ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + DetectorDescription/GeoPrimitives + InnerDetector/InDetRecEvent/InDetPrepRawData + PRIVATE + GaudiKernel + InnerDetector/InDetDetDescr/InDetIdentifier + InnerDetector/InDetDetDescr/InDetReadoutGeometry + InnerDetector/InDetRecEvent/SiSpacePoint + Tracking/TrkEvent/TrkSpacePoint ) + +# External dependencies: +find_package( Eigen ) + +# Component(s) in the package: +atlas_add_library( SiSpacePointToolLib + src/*.cxx + PUBLIC_HEADERS SiSpacePointTool + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps GeoPrimitives InDetPrepRawData + PRIVATE_LINK_LIBRARIES GaudiKernel InDetIdentifier InDetReadoutGeometry SiSpacePoint TrkSpacePoint ) + +atlas_add_component( SiSpacePointTool + src/components/*.cxx + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps GeoPrimitives InDetPrepRawData GaudiKernel InDetIdentifier InDetReadoutGeometry SiSpacePoint TrkSpacePoint SiSpacePointToolLib ) + diff --git a/InnerDetector/InDetRecTools/SiSpacePointTool/SiSpacePointTool/SiSpacePointMakerTool.h b/InnerDetector/InDetRecTools/SiSpacePointTool/SiSpacePointTool/SiSpacePointMakerTool.h index e3c440919c7f0c434781185b30709f5ad292743f..44c0e3dd346d3eb7e27fb847bed86e9f4056e86e 100755 --- a/InnerDetector/InDetRecTools/SiSpacePointTool/SiSpacePointTool/SiSpacePointMakerTool.h +++ b/InnerDetector/InDetRecTools/SiSpacePointTool/SiSpacePointTool/SiSpacePointMakerTool.h @@ -8,66 +8,78 @@ #include "AthenaBaseComps/AthAlgTool.h" #include <string> - -// Cluster and space point collections #include "InDetPrepRawData/PixelClusterCollection.h" #include "InDetPrepRawData/SCT_ClusterCollection.h" -#include "TrkSpacePoint/SpacePointCollection.h" -#include "TrkSpacePoint/SpacePointOverlapCollection.h" + #include "GeoPrimitives/GeoPrimitives.h" - -namespace Trk -{ + +class SCT_ID; +class SpacePointCollection; +class SpacePointOverlapCollection; +namespace Trk{ class SpacePoint; } -namespace InDetDD -{ +namespace InDetDD{ class SCT_DetectorManager; class SiDetectorElement; } - namespace InDet{ class SiCluster; + //class SCT_ClusterCollection; can't fwd declare due to typedef + //class PixelClusterCollection; +} -class SiSpacePointMakerTool : public AthAlgTool { - - public: - - - // Constructor - SiSpacePointMakerTool( const std::string& type, - const std::string& name, - const IInterface* parent ); +namespace InDet{ + class SiSpacePointMakerTool : public AthAlgTool { + public: + // Constructor + SiSpacePointMakerTool( const std::string& type, const std::string& name, const IInterface* parent ); - virtual ~SiSpacePointMakerTool(); + virtual ~SiSpacePointMakerTool(); - static const InterfaceID& interfaceID(); + static const InterfaceID& interfaceID(); - virtual StatusCode initialize(); + virtual StatusCode initialize(); - virtual StatusCode finalize(); + virtual StatusCode finalize(); - // Convert clusters to space points - Trk::SpacePoint* makeSCT_SpacePoint(const InDet::SiCluster& cluster1, const InDet::SiCluster& cluster2, const Amg::Vector3D& m_vertex, - const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2); + // Convert clusters to space points + Trk::SpacePoint* makeSCT_SpacePoint(const InDet::SiCluster& cluster1, const InDet::SiCluster& cluster2, + const Amg::Vector3D& vertexVec, + const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2); - void fillSCT_SpacePointCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool m_allClusters, const Amg::Vector3D& m_vertex, const InDetDD::SCT_DetectorManager *m_manager, SpacePointCollection* spacepointCollection); + void fillSCT_SpacePointCollection(const InDet::SCT_ClusterCollection* clusters1, + const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool allClusters, + const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, + SpacePointCollection* spacepointCollection); - void fillPixelSpacePointCollection(const InDet::PixelClusterCollection* clusters, SpacePointCollection* spacepointCollection); + void fillPixelSpacePointCollection(const InDet::PixelClusterCollection* clusters, + SpacePointCollection* spacepointCollection); - void fillSCT_SpacePointEtaOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool m_allClusters, const Amg::Vector3D& m_vertex, const InDetDD::SCT_DetectorManager *m_manager, SpacePointOverlapCollection* m_spacepointoverlapCollection); + void fillSCT_SpacePointEtaOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, + const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool allClusters, + const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, + SpacePointOverlapCollection* spacepointOverlapCollection); - void fillSCT_SpacePointPhiOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min1, double max1, double min2, double max2, bool m_allClusters, const Amg::Vector3D& m_vertex, const InDetDD::SCT_DetectorManager *m_manager, SpacePointOverlapCollection* m_spacepointoverlapCollection); + void fillSCT_SpacePointPhiOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, + const InDet::SCT_ClusterCollection* clusters2, double min1, double max1, double min2, + double max2, bool allClusters, const Amg::Vector3D& vertexVec , + const InDetDD::SCT_DetectorManager *SCT_Manager, + SpacePointOverlapCollection* spacepointOverlapCollection); - private: - double m_stripLengthTolerance; + private: + double m_stripLengthTolerance; + double m_SCTgapParameter; + double m_stripLengthGapTolerance; - // option to use closest approach of SCT strips as position for SpacePoint - bool m_usePerpProj; + // option to use closest approach of SCT strips as position for SpacePoint + bool m_usePerpProj; - std::vector<Trk::SpacePoint*> m_tmpSpacePoints; + std::vector<Trk::SpacePoint*> m_tmpSpacePoints; + const SCT_ID* m_idHelper; + double offset(const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2); -}; + }; } #endif //SiSpacePointMakerTool_H diff --git a/InnerDetector/InDetRecTools/SiSpacePointTool/cmt/requirements b/InnerDetector/InDetRecTools/SiSpacePointTool/cmt/requirements index ea65a52d4c86fcb55e4b87658f7b48755feab745..d97030d7ee02c09809f51058e0b8051c8d0c6f64 100755 --- a/InnerDetector/InDetRecTools/SiSpacePointTool/cmt/requirements +++ b/InnerDetector/InDetRecTools/SiSpacePointTool/cmt/requirements @@ -9,10 +9,10 @@ public use AtlasPolicy AtlasPolicy-* use AthenaBaseComps AthenaBaseComps-* Control use InDetPrepRawData InDetPrepRawData-* InnerDetector/InDetRecEvent -use TrkSpacePoint TrkSpacePoint-* Tracking/TrkEvent use GeoPrimitives GeoPrimitives-* DetectorDescription private +use TrkSpacePoint TrkSpacePoint-* Tracking/TrkEvent use GaudiInterface GaudiInterface-* External use SiSpacePoint SiSpacePoint-* InnerDetector/InDetRecEvent diff --git a/InnerDetector/InDetRecTools/SiSpacePointTool/src/SiSpacePointMakerTool.cxx b/InnerDetector/InDetRecTools/SiSpacePointTool/src/SiSpacePointMakerTool.cxx index fce836145013cc72f3753917929402d2d72f32af..190598c104e90cf262ac5c3e96ac155c8f0e2307 100755 --- a/InnerDetector/InDetRecTools/SiSpacePointTool/src/SiSpacePointMakerTool.cxx +++ b/InnerDetector/InDetRecTools/SiSpacePointTool/src/SiSpacePointMakerTool.cxx @@ -2,17 +2,12 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifdef HAVE_NEW_IOSTREAMS -#include <iostream> - -#include <fstream> -#else -#include <iostream.h> -#include <fstream.h> -#endif -#include <stdio.h> #include "SiSpacePointTool/SiSpacePointMakerTool.h" +// Cluster and space point collections + +#include "TrkSpacePoint/SpacePointCollection.h" +#include "TrkSpacePoint/SpacePointOverlapCollection.h" // For processing clusters #include "InDetReadoutGeometry/SCT_DetectorManager.h" @@ -38,11 +33,11 @@ SiSpacePointMakerTool::SiSpacePointMakerTool(const std::string &type, const std::string &name, const IInterface *parent) : AthAlgTool(type,name,parent){ - declareInterface< SiSpacePointMakerTool>( this ); declareProperty("StripLengthTolerance",m_stripLengthTolerance = 0.01 ); declareProperty("UsePerpendicularProjection",m_usePerpProj = false ); - + declareProperty("SCTGapParameter", m_SCTgapParameter = 0. ); // Recommend m_SCTgapParameter = .001 - .0015 for ITK geometry + m_idHelper=nullptr; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -51,19 +46,20 @@ SiSpacePointMakerTool::~SiSpacePointMakerTool() {} //-------------------------------------------------------------------------- StatusCode SiSpacePointMakerTool::initialize() { - StatusCode sc; - sc = AlgTool::initialize(); - return sc; + // Get the SCT Helper + ATH_CHECK(detStore()->retrieve(m_idHelper, "SCT_ID")); + m_SCTgapParameter = fabs(m_SCTgapParameter); if(m_SCTgapParameter > .002) m_SCTgapParameter = .002; + return StatusCode::SUCCESS; } //-------------------------------------------------------------------------- StatusCode SiSpacePointMakerTool::finalize() { - StatusCode sc = AlgTool::finalize(); - return sc; + return StatusCode::SUCCESS; } //-------------------------------------------------------------------------- -Trk::SpacePoint* SiSpacePointMakerTool::makeSCT_SpacePoint(const InDet::SiCluster& cluster1, const InDet::SiCluster& cluster2, const Amg::Vector3D& m_vertex, - const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2){ +Trk::SpacePoint* SiSpacePointMakerTool::makeSCT_SpacePoint(const InDet::SiCluster& cluster1, + const InDet::SiCluster& cluster2, const Amg::Vector3D& vertexVec, + const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2){ // -ME fixme- const InDetDD::SCT_DetectorManager *m_manager, const SCT_ID* m_idHelper) { // Find intersection of a line through a cluster on one sct detector and @@ -97,10 +93,10 @@ Trk::SpacePoint* SiSpacePointMakerTool::makeSCT_SpacePoint(const InDet::SiCluste Amg::Vector3D q(a-b); // vector joining ends of line Amg::Vector3D r(c-d); // vector joining ends of line - const Amg::Vector3D *point(0); + Amg::Vector3D point; + bool ok(true); - if ( m_usePerpProj) - { + if ( m_usePerpProj){ /* a simple hack for the case the origin of the particle is completely unknown: The closest approach of element1 to element2 is used (perpendicular projection) to determine the position of the SpacePoint on element 1. @@ -113,59 +109,80 @@ Trk::SpacePoint* SiSpacePointMakerTool::makeSCT_SpacePoint(const InDet::SiCluste double eaTeb = q.dot(r); double denom = 1 - eaTeb*eaTeb; if (fabs(denom)>10e-7){ - double lambda0 = (mab.dot(q) - mab.dot(r)*eaTeb)/denom; - point = new Amg::Vector3D( a+lambda0*q ); - if(msgLvl(MSG::VERBOSE)) msg() << "Endpoints 1 : ( " << a.x() << " , " << a.y() << " , " << a.z() << " ) to (" << - b.x() << " , " << b.y() << " , " << b.z() << " ) " << endreq; - if(msgLvl(MSG::VERBOSE)) msg() << "Endpoints 2 : ( " << c.x() << " , " << c.y() << " , " << c.z() << " ) to (" << - d.x() << " , " << d.y() << " , " << d.z() << " ) " <<endreq; - if(msgLvl(MSG::VERBOSE)) msg() << "Intersection: ( " << point->x() << " , " << point->y() << " , " << point->z() << " ) " << endreq; + double lambda0 = (mab.dot(q) - mab.dot(r)*eaTeb)/denom; + point = a+lambda0*q; + ATH_MSG_VERBOSE( "Endpoints 1 : ( " << a.x() << " , " << a.y() << " , " << a.z() << " ) to (" << b.x() << " , " << b.y() << " , " << b.z() << " ) " ); + ATH_MSG_VERBOSE( "Endpoints 2 : ( " << c.x() << " , " << c.y() << " , " << c.z() << " ) to (" << d.x() << " , " << d.y() << " , " << d.z() << " ) " ); + ATH_MSG_VERBOSE( "Intersection: ( " << point.x() << " , " << point.y() << " , " << point.z() << " ) " ); }else{ - ATH_MSG_WARNING("Intersection failed"); - ok = false; + ATH_MSG_WARNING("Intersection failed"); + ok = false; } - } - else - { - // -ME fixme- const Amg::Vector3D* point; - Amg::Vector3D s(a+b-2*m_vertex); // twice the vector from vertex to midpoint - Amg::Vector3D t(c+d-2*m_vertex); // twice the vector from vertex to midpoint + } else { + + Amg::Vector3D s(a+b-2*vertexVec); // twice the vector from vertex to midpoint + Amg::Vector3D t(c+d-2*vertexVec); // twice the vector from vertex to midpoint Amg::Vector3D qs(q.cross(s)); Amg::Vector3D rt(r.cross(t)); - double m(-s.dot(rt)/q.dot(rt)); // ratio for first line + double m(-s.dot(rt)/q.dot(rt)); // ratio for first line + double n(0.); // ratio for second line // We increase the length of the strip by 1%. This a fudge which allows // us to recover space-points from tracks pointing back to an interaction // point up to around z = +- 20 cm - double limit = 1. + m_stripLengthTolerance; - if (m>limit || m<-1.*limit) ok=false; - else - { - double n(-t.dot(qs)/r.dot(qs)); // ratio for second line - if (n>limit || n<-1.*limit) ok=false; + double limit = 1. + m_stripLengthTolerance; + + if (fabs( m ) > limit) ok = false; + else if (fabs((n=-(t.dot(qs)/r.dot(qs)))) > limit) ok = false; + + if(!ok && m_stripLengthGapTolerance !=0.) { + + double qm = q.mag() ; + double limitn = limit+(m_stripLengthGapTolerance/qm); + + if(fabs(m) <= limitn) { + + if(n==0.) n = -(t.dot(qs)/r.dot(qs)); + + if(fabs(n) <= limitn) { + + double mn = q.dot(r)/(qm*qm); + + if (m > 1. || n > 1.) { + double dm = (m-1.) ; + double dn = (n-1.)*mn; + double sm = dm; if(dm < dn) sm = dn; m-=sm; n-=(sm*mn); + } + else if(m < -1. || n < -1.) { + double dm =-(m+1.) ; + double dn =-(n+1.)*mn; + double sm = dm; if(dm < dn) sm = dn; m+=sm; n+=(sm*mn); + } + if(fabs(m) < limit && fabs(n) < limit) ok = true; + } } + } + if(ok) point = 0.5*(a + b + m*q); + } + if (ok){ - if (cluster1.detectorElement() == 0 || cluster2.detectorElement() == 0 ) ok=false; - - if (ok) point = new Amg::Vector3D( 0.5*(a + b + m*q) ); - } - - if (ok) - { - if(msgLvl(MSG::VERBOSE)) msg() << "SpacePoint generated at: ( " << point->x() << " , " << point->y() << " , " << point->z() << " ) " << endreq; + ATH_MSG_VERBOSE( "SpacePoint generated at: ( " << point.x() << " , " << point.y() << " , " << point.z() << " ) " ); const std::pair<IdentifierHash,IdentifierHash> elementIdList( element1->identifyHash() , element2->identifyHash() ); const std::pair<const Trk::PrepRawData*,const Trk::PrepRawData*>* clusList = new std::pair<const Trk::PrepRawData*,const Trk::PrepRawData*>(&cluster1,&cluster2); - // -ME fixe- added line - Trk::SpacePoint* sp= new InDet::SCT_SpacePoint(elementIdList,point,clusList); - return sp; - } + + return new InDet::SCT_SpacePoint(elementIdList,new Amg::Vector3D(point),clusList); + } return 0; -} + } //-------------------------------------------------------------------------- -void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool m_allClusters, const Amg::Vector3D& m_vertex, const InDetDD::SCT_DetectorManager *m_manager, SpacePointCollection* spacepointCollection){ +void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_ClusterCollection* clusters1, + const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool m_allClusters, + const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, SpacePointCollection* spacepointCollection){ + + m_stripLengthGapTolerance = 0.; // Try all combinations of clusters for space points InDet::SCT_ClusterCollection::const_iterator @@ -173,17 +190,11 @@ void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_Cluste InDet::SCT_ClusterCollection::const_iterator clusters1Finish = clusters1->end(); - // Get the SCT Helper - const SCT_ID* m_idHelper; - if (detStore()->retrieve(m_idHelper, "SCT_ID").isFailure()) { - msg(MSG::FATAL) << "Could not get SCT ID helper" << endreq; - return; - } // -ME fixme- get first element const InDetDD::SiDetectorElement *element1 =0; - if ((*clusters1Next) &&(clusters1Next!=clusters1Finish)) element1 = m_manager->getDetectorElement(m_idHelper->wafer_id((*clusters1Next)->identify())); + if ((*clusters1Next) &&(clusters1Next!=clusters1Finish)) element1 = SCT_Manager->getDetectorElement(m_idHelper->wafer_id((*clusters1Next)->identify())); if (!element1) { msg(MSG::ERROR) << "Bad cluster identifier " << m_idHelper->show_to_string((*clusters1Next)->identify()) <<endreq; @@ -199,19 +210,19 @@ void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_Cluste Amg::Vector2D locpos = (*clusters1Next)->localPosition(); Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); double xPhi1 = InDetDD::SiLocalPosition(localPos.y(),localPos.x(),0).xPhi(); - InDet::SCT_ClusterCollection::const_iterator - clusters2Next=(*clusters2).begin(); - InDet::SCT_ClusterCollection::const_iterator - clusters2Finish=(*clusters2).end(); + InDet::SCT_ClusterCollection::const_iterator clusters2Next=(*clusters2).begin(); + InDet::SCT_ClusterCollection::const_iterator clusters2Finish=(*clusters2).end(); // -ME fixme- get first element const InDetDD::SiDetectorElement *element2 =0; - if (*clusters2Next && (clusters2Next != clusters2Finish)) element2= m_manager->getDetectorElement(m_idHelper->wafer_id((*clusters2Next)->identify())); + if (*clusters2Next && (clusters2Next != clusters2Finish)) element2= SCT_Manager->getDetectorElement(m_idHelper->wafer_id((*clusters2Next)->identify())); if (!element2) { msg(MSG::ERROR) << "Bad cluster identifier " << m_idHelper->show_to_string((*clusters2Next)->identify()) <<endreq; break; } + + if(m_SCTgapParameter!=0.) {double dm = offset(element1,element2); min-=dm; max+=dm; } for (; clusters2Next != clusters2Finish; ++clusters2Next){ Amg::Vector2D locpos = (*clusters2Next)->localPosition(); @@ -220,7 +231,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_Cluste if ((min <= diff && diff <= max)||m_allClusters){ Trk::SpacePoint* sp = - makeSCT_SpacePoint(**clusters1Next, **clusters2Next, m_vertex, element1, element2); + makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2); if (sp) { m_tmpSpacePoints.push_back(sp); } @@ -237,9 +248,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointCollection(const InDet::SCT_Cluste //-------------------------------------------------------------------------- void SiSpacePointMakerTool::fillPixelSpacePointCollection(const InDet::PixelClusterCollection* clusters, SpacePointCollection* spacepointCollection){ - IdentifierHash idHash = clusters->identifyHash(); - InDet::PixelClusterCollection::const_iterator clusStart = clusters->begin(); InDet::PixelClusterCollection::const_iterator clusFinish = clusters->end(); if ((*clusStart)->detectorElement()!=0) { @@ -252,32 +261,28 @@ void SiSpacePointMakerTool::fillPixelSpacePointCollection(const InDet::PixelClus spacepointCollection->push_back(sp); } } - } //-------------------------------------------------------------------------- -void SiSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool m_allClusters, const Amg::Vector3D& m_vertex, const InDetDD::SCT_DetectorManager *m_manager, SpacePointOverlapCollection* m_spacepointoverlapCollection){ +void SiSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, + const InDet::SCT_ClusterCollection* clusters2, double min, double max, bool m_allClusters, + const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, + SpacePointOverlapCollection* m_spacepointoverlapCollection){ + + m_stripLengthGapTolerance = 0.; // Require that (xPhi2 - xPhi1) lie in the range specified. // Used eta modules - // Try all combinations of clusters for space points InDet::SCT_ClusterCollection::const_iterator clusters1Next = clusters1->begin(); InDet::SCT_ClusterCollection::const_iterator clusters1Finish = clusters1->end(); - // Get the SCT Helper - const SCT_ID* m_idHelper; - if (detStore()->retrieve(m_idHelper, "SCT_ID").isFailure()) { - msg(MSG::FATAL) << "Could not get SCT ID helper" << endreq; - return; - } - const InDetDD::SiDetectorElement *element1 =0; - if ((*clusters1Next) &&(clusters1Next!=clusters1Finish)) element1 = m_manager->getDetectorElement(m_idHelper->wafer_id((*clusters1Next)->identify())); + if ((*clusters1Next) &&(clusters1Next!=clusters1Finish)) element1 = SCT_Manager->getDetectorElement(m_idHelper->wafer_id((*clusters1Next)->identify())); if (!element1) { msg(MSG::ERROR) << "Bad cluster identifier " << m_idHelper->show_to_string((*clusters1Next)->identify()) <<endreq; return; @@ -294,12 +299,13 @@ void SiSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const InDet:: clusters2Finish=(*clusters2).end(); const InDetDD::SiDetectorElement *element2 =0; - if (*clusters2Next && (clusters2Next != clusters2Finish)) element2= m_manager->getDetectorElement(m_idHelper->wafer_id((*clusters2Next)->identify())); + if (*clusters2Next && (clusters2Next != clusters2Finish)) element2= SCT_Manager->getDetectorElement(m_idHelper->wafer_id((*clusters2Next)->identify())); if (!element2) { msg(MSG::ERROR) << "Bad cluster identifier " << m_idHelper->show_to_string((*clusters2Next)->identify()) <<endreq; break; } - + if(m_SCTgapParameter!=0.) {double dm = offset(element1,element2); min-=dm; max+=dm; } + for (; clusters2Next != clusters2Finish; ++clusters2Next){ Amg::Vector2D locpos = (*clusters2Next)->localPosition(); Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); @@ -307,7 +313,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const InDet:: if ((min <= diff && diff <= max)||m_allClusters){ Trk::SpacePoint* sp = - makeSCT_SpacePoint(**clusters1Next, **clusters2Next, m_vertex, element1, element2); + makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2); if (sp) { m_spacepointoverlapCollection->push_back(sp); } @@ -319,7 +325,12 @@ void SiSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const InDet:: //-------------------------------------------------------------------------- -void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, const InDet::SCT_ClusterCollection* clusters2, double min1, double max1, double min2, double max2, bool m_allClusters, const Amg::Vector3D& m_vertex, const InDetDD::SCT_DetectorManager *m_manager, SpacePointOverlapCollection* m_spacepointoverlapCollection){ +void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet::SCT_ClusterCollection* clusters1, + const InDet::SCT_ClusterCollection* clusters2, double min1, double max1, double min2, double max2, + bool m_allClusters, const Amg::Vector3D& vertexVec, const InDetDD::SCT_DetectorManager *SCT_Manager, + SpacePointOverlapCollection* m_spacepointoverlapCollection){ + + m_stripLengthGapTolerance = 0.; if(m_SCTgapParameter!=0.) {min1-=20.; max1+=20.;} // Clus1 must lie // within min1 and max1 and clus between min2 and max2. Used for phi @@ -330,16 +341,9 @@ void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet:: clusters1Next = clusters1->begin(); InDet::SCT_ClusterCollection::const_iterator clusters1Finish = clusters1->end(); - - // Get the SCT Helper - const SCT_ID* m_idHelper; - if (detStore()->retrieve(m_idHelper, "SCT_ID").isFailure()) { - msg(MSG::FATAL) << "Could not get SCT ID helper" << endreq; - return; - } - + const InDetDD::SiDetectorElement *element1 =0; - if ( (*clusters1Next) && (clusters1Next!=clusters1Finish)) element1= m_manager->getDetectorElement(m_idHelper->wafer_id((*clusters1Next)->identify())); + if ( (*clusters1Next) && (clusters1Next!=clusters1Finish)) element1= SCT_Manager->getDetectorElement(m_idHelper->wafer_id((*clusters1Next)->identify())); if (!element1) { msg(MSG::ERROR) << "Bad cluster identifier " << m_idHelper->show_to_string((*clusters1Next)->identify()) <<endreq; return; @@ -356,11 +360,14 @@ void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet:: clusters2Finish=(*clusters2).end(); const InDetDD::SiDetectorElement *element2 =0; - if (*clusters2Next&&(clusters2Next != clusters2Finish)) element2 = m_manager->getDetectorElement(m_idHelper->wafer_id((*clusters2Next)->identify())); + if (*clusters2Next&&(clusters2Next != clusters2Finish)) element2 = SCT_Manager->getDetectorElement(m_idHelper->wafer_id((*clusters2Next)->identify())); if (!element2) { msg(MSG::ERROR) << "Bad cluster identifier " << m_idHelper->show_to_string((*clusters2Next)->identify()) <<endreq; break; - } + } + + if(m_SCTgapParameter!=0.) {double dm = offset(element1,element2); min2-=dm; max2+=dm; } + for (; clusters2Next != clusters2Finish; ++clusters2Next) { Amg::Vector2D locpos = (*clusters2Next)->localPosition(); @@ -368,7 +375,7 @@ void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet:: double xPhi2 = InDetDD::SiLocalPosition(localPos.y(),localPos.x(),0).xPhi(); if ((min2<= xPhi2 && xPhi2 <= max2)||m_allClusters){ Trk::SpacePoint* sp - (makeSCT_SpacePoint(**clusters1Next, **clusters2Next, m_vertex, element1, element2)); + (makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2)); if (sp) { m_spacepointoverlapCollection->push_back(sp); } @@ -380,4 +387,27 @@ void SiSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const InDet:: } + /////////////////////////////////////////////////////////////////// + // Possible offset estimation in Z or R direction due to gap size + /////////////////////////////////////////////////////////////////// + + double SiSpacePointMakerTool::offset + (const InDetDD::SiDetectorElement *element1, const InDetDD::SiDetectorElement *element2) + { + const Amg::Transform3D& T1 = element1->transform(); + const Amg::Transform3D& T2 = element2->transform(); + + double x12 = T1(0,0)*T2(0,0)+T1(1,0)*T2(1,0)+T1(2,0)*T2(2,0) ; + double r = sqrt(T1(0,3)*T1(0,3)+T1(1,3)*T1(1,3)) ; + double s = (T1(0,3)-T2(0,3))*T1(0,2)+(T1(1,3)-T2(1,3))*T1(1,2)+(T1(2,3)-T2(2,3))*T1(2,2); + + double dm = (m_SCTgapParameter*r)*fabs(s*x12); + double d = dm/sqrt((1.-x12)*(1.+x12)); + + if(fabs(T1(2,2)) > .7) d*=(r/fabs(T1(2,3))); // endcap d = d*R/Z + + m_stripLengthGapTolerance = d; + return dm; + } + }