diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.cxx index 7c4a223c02b4aa8ecc879a03bdebd59150a466d5..5a63749a53243fc196ac93ccab92c040359e7d4b 100644 --- a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.cxx +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.cxx @@ -1,9 +1,51 @@ /* - Copyright (C) 2021 CERN for the benefit of the FASER collaboration -*/ + Copyright (C) 2021 CERN for the benefit of the FASER collaboration + */ #include "FaserSCT_SpacePointContainerCnv.h" +/* +StatusCode FaserSCT_SpacePointContainerCnv::initialize() { + ATH_MSG_INFO("FaserSCT_SpacePointContainerCnv::initialize()"); + + StatusCode sc = FaserSCT_SpacePointContainerCnvBase::initialize(); + if (sc.isFailure()) { + ATH_MSG_FATAL("Cannot initialize cnv base !"); + return StatusCode::FAILURE; + } + + // get StoreGate service. This is needed only for clients + // that register collections directly to the SG instead of adding + // them to the container. + sc = service("StoreGateSvc", m_storeGate); + if (sc.isFailure()) { + ATH_MSG_FATAL("StoreGate service not found !"); + return StatusCode::FAILURE; + } + + // get DetectorStore service + StoreGateSvc* detStore(nullptr); + if (service("DetectorStore", detStore).isFailure()) { + ATH_MSG_FATAL("DetectorStore service not found !"); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG("Found DetectorStore."); + } + + // Get the SCT helper from the detector store + const FaserSCT_ID* idhelper(nullptr); + if (detStore->retrieve(idhelper, "FaserSCT_ID").isFailure()) { + ATH_MSG_FATAL("Could not get FaserSCT_ID helper !"); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG("Found the FaserSCT_ID helper."); + } + ATH_MSG_DEBUG("Converter initialized"); + + return StatusCode::SUCCESS; +} +*/ + FaserSCT_SpacePointContainer_PERS* FaserSCT_SpacePointContainerCnv::createPersistent (FaserSCT_SpacePointContainer* transObj) { ATH_MSG_INFO("FaserSCT_SpacePointContainerCnv::createPersistent()"); diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.h index 704a24e1fece5b07dda40941cde41623ba4d87a4..0004da8e97d4c208533f063e53bcf79cb0178231 100644 --- a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.h +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.h @@ -2,8 +2,8 @@ Copyright 2021 CERN for the benefit of the FASER collaboration */ -#ifndef SPACEPOINTCONTAINERCNV_H -#define SPACEPOINTCONTAINERCNV_H +#ifndef FASERSCT_SPACEPOINTCONTAINERCNV_H +#define FASERSCT_SPACEPOINTCONTAINERCNV_H #include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" @@ -11,6 +11,11 @@ #include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" #include "TrackerEventTPCnv/FaserSCT_SpacePointContainer_p0.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "StoreGate/StoreGateSvc.h" +#include "StoreGate/ReadCondHandle.h" + typedef FaserSCT_SpacePointContainer_p0 FaserSCT_SpacePointContainer_PERS; typedef FaserSCT_SpacePointContainerCnv_p0 FaserSCT_SpacePointContainerCnv_PERS; @@ -24,6 +29,8 @@ class FaserSCT_SpacePointContainerCnv : public FaserSCT_SpacePointContainerCnvBa FaserSCT_SpacePointContainerCnv (ISvcLocator* svcloc) : FaserSCT_SpacePointContainerCnvBase(svcloc, "FaserSCT_SpacePointContainerCnv") {} protected: + // Must initialize ID helpers +// virtual StatusCode initialize(); virtual FaserSCT_SpacePointContainer_PERS* createPersistent (FaserSCT_SpacePointContainer* transObj); virtual FaserSCT_SpacePointContainer* createTransient (); }; diff --git a/Tracker/TrackerEventCnv/TrackerEventCnvTools/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerEventCnvTools/CMakeLists.txt index 6053d2790392ae986af95db90127dedf1fc5c0b1..31dad792833d8b5aef2f1dc06a36cc676dbaa724 100644 --- a/Tracker/TrackerEventCnv/TrackerEventCnvTools/CMakeLists.txt +++ b/Tracker/TrackerEventCnv/TrackerEventCnvTools/CMakeLists.txt @@ -5,6 +5,6 @@ atlas_subdir( TrackerEventCnvTools ) # Component(s) in the package: atlas_add_component( TrackerEventCnvTools - src/*.cxx + src/*.cxx TrackerEventCnvTools/*h src/components/*.cxx - LINK_LIBRARIES AthenaBaseComps FaserDetDescr IdDictDetDescr Identifier TrackerIdentifier TrackerReadoutGeometry TrackerPrepRawData TrackerRIO_OnTrack StoreGateLib TrkPrepRawData TrkRIO_OnTrack TrkEventCnvToolsLib ) + LINK_LIBRARIES AthenaBaseComps FaserDetDescr IdDictDetDescr Identifier TrackerIdentifier TrackerReadoutGeometry TrackerPrepRawData TrackerSpacePoint TrackerRIO_OnTrack StoreGateLib TrkPrepRawData TrkRIO_OnTrack TrkEventCnvToolsLib ) diff --git a/Tracker/TrackerEventCnv/TrackerEventCnvTools/TrackerEventCnvTools/TrackerSpacePointCnvTool.h b/Tracker/TrackerEventCnv/TrackerEventCnvTools/TrackerEventCnvTools/TrackerSpacePointCnvTool.h new file mode 100644 index 0000000000000000000000000000000000000000..115139c39fc4987243566831004795de5f8cd820 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventCnvTools/TrackerEventCnvTools/TrackerSpacePointCnvTool.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + */ + +#ifndef TRACKERSPACEPOINTCNVTOOL_H +#define TRACKERSPACEPOINTCNVTOOL_H + +#include "AthenaBaseComps/AthAlgTool.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/ReadHandleKey.h" + +#include <utility> + +class Identifier; +class IdentifierHash; + + +namespace Tracker { + /**Helper tool uses to convert Tracker objects in generic tracking custom convertor TrkEventAthenaPool. + + See "mainpage" for discussion of jobOpts. + */ + class TrackerSpacePointCnvTool : public AthAlgTool + { + public: + + TrackerSpacePointCnvTool(const std::string&,const std::string&,const IInterface*); + + ~TrackerSpacePointCnvTool() = default; + + virtual StatusCode initialize() override; + + + std::pair<const Tracker::FaserSCT_Cluster*, const Tracker::FaserSCT_Cluster*> + sctClusterLinks( const Identifier& id1, const IdentifierHash& idHash1, const Identifier& id2, const IdentifierHash& idHash2 ) const ; + void recreateSpacePoint( Tracker::FaserSCT_SpacePoint *sp, const Identifier& id1, const Identifier& id2, const IdentifierHash& idhash1, const IdentifierHash& idhash2 ) const ; + + + private: + + + SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_sctClusContName{this, "SCT_ClusterContainer", "SCT_Clusters", "SCT Cluster container name"}; //!< location of container of sct clusters + + }; + +} +#endif // MOORETOTRACKTOOL_H diff --git a/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/TrackerSpacePointCnvTool.cxx b/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/TrackerSpacePointCnvTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8649c37127b23639a993806971cf35e5124d2ea3 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/TrackerSpacePointCnvTool.cxx @@ -0,0 +1,86 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + */ + +#include "TrackerEventCnvTools/TrackerSpacePointCnvTool.h" + +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerRIO_OnTrack/FaserSCT_ClusterOnTrack.h" + +#include <vector> +#include <cassert> +#include <iostream> + +Tracker::TrackerSpacePointCnvTool::TrackerSpacePointCnvTool(const std::string& t, + const std::string& n, + const IInterface* p ) + : + AthAlgTool(t,n,p) +{ +} + +StatusCode Tracker::TrackerSpacePointCnvTool::initialize() { + + StatusCode sc = AthAlgTool::initialize(); + if (sc.isFailure()) return sc; + + ATH_CHECK( m_sctClusContName.initialize() ); + + return sc; + +} + +void Tracker::TrackerSpacePointCnvTool::recreateSpacePoint( Tracker::FaserSCT_SpacePoint *sp, const Identifier& id1, const Identifier& id2, const IdentifierHash& idhash1, const IdentifierHash& idhash2 ) const { + auto clusters= sctClusterLinks( id1,idhash1, id2,idhash2); + sp->setClusList(clusters); + return; +} + +std::pair<const Tracker::FaserSCT_Cluster*, const Tracker::FaserSCT_Cluster*> +Tracker::TrackerSpacePointCnvTool::sctClusterLinks( const Identifier& id1, const IdentifierHash & idHash1, const Identifier& id2, const IdentifierHash& idHash2 ) const { + const Tracker::FaserSCT_Cluster* clus1=nullptr; + const Tracker::FaserSCT_Cluster* clus2=nullptr; + // need to retrieve pointers to collections + // retrieve Pixel cluster container + + // obviously this can be optimised! EJWM + SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> h_sctClusCont(m_sctClusContName); + if (!h_sctClusCont.isValid()) { + ATH_MSG_ERROR("FaserSCT Cluster container not found at "<<m_sctClusContName); + return std::make_pair(clus1,clus2); + } else { + ATH_MSG_DEBUG("FaserSCT Cluster Container found" ); + } + const Tracker::FaserSCT_ClusterCollection *ptr1 = h_sctClusCont->indexFindPtr(idHash1); + const Tracker::FaserSCT_ClusterCollection *ptr2 = h_sctClusCont->indexFindPtr(idHash2); + // if we find PRD, then recreate link + if (ptr1!=nullptr) { + //loop though collection to find matching PRD. + Tracker::FaserSCT_ClusterCollection::const_iterator collIt = ptr1->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator collItEnd = ptr1->end(); + // there MUST be a faster way to do this!! + for ( ; collIt!=collItEnd; collIt++) { + if ( (*collIt)->identify()==id1 ) + clus1= &(**collIt); + } + } + // if we find PRD, then recreate link + if (ptr2!=nullptr) { + //loop though collection to find matching PRD. + Tracker::FaserSCT_ClusterCollection::const_iterator collIt = ptr2->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator collItEnd = ptr2->end(); + // there MUST be a faster way to do this!! + for ( ; collIt!=collItEnd; collIt++) { + if ( (*collIt)->identify()==id2 ) + clus2= &(**collIt); + } + } + if(clus1==nullptr||clus2==nullptr) + ATH_MSG_DEBUG("No matching PRD found" ); + return std::make_pair(clus1,clus2); +} + + diff --git a/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/components/TrackerEventCnvTool_entries.cxx b/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/components/TrackerEventCnvTool_entries.cxx index 3d7144a021d532b496ba19bcba2422c01936ba11..73857c22607ce210ee2480e456e57e70a7796d5b 100644 --- a/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/components/TrackerEventCnvTool_entries.cxx +++ b/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/components/TrackerEventCnvTool_entries.cxx @@ -1,6 +1,8 @@ #include "TrackerEventCnvTools/TrackerEventCnvTool.h" +#include "TrackerEventCnvTools/TrackerSpacePointCnvTool.h" using namespace Tracker; DECLARE_COMPONENT( TrackerEventCnvTool ) +DECLARE_COMPONENT( TrackerSpacePointCnvTool) diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt index 259453c94f261532d0e1054ace7259760fada14f..d097ad117081d6de28d584b3d8ea20fb9ba2cf40 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt @@ -21,7 +21,7 @@ atlas_add_tpcnv_library( TrackerEventTPCnv TrkPrepRawData TrkSpacePoint TrackerSpacePoint - PRIVATE_LINK_LIBRARIES AthenaBaseComps AthenaKernel + PRIVATE_LINK_LIBRARIES AthenaBaseComps AthenaKernel EventPrimitives TrackerReadoutGeometry TrkSurfaces TrkEventPrimitives TrkMeasurementBase TrkRIO_OnTrack EventContainers ) diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h index a9822809eb2078a3dc57e0cb9d362b960c7ffca6..5b0b2afcb3ba4185dc003659c1d45e6d2d613eec 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h @@ -11,12 +11,16 @@ #include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" #include "DataModelAthenaPool/ElementLinkCnv_p1.h" #include "AthLinks/ElementLink.h" +//#include "TrackerEventCnvTools/TrackerSpacePointCnvTool.h" #include "TrackerPrepRawData/FaserSCT_Cluster.h" #include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/StoreGateSvc.h" class FaserSCT_SpacePointCnv_p0 : public T_AthenaPoolTPCnvBase<Tracker::FaserSCT_SpacePoint, FaserSCT_SpacePoint_p0> { public: - FaserSCT_SpacePointCnv_p0() {}; + FaserSCT_SpacePointCnv_p0():m_sctClusContName{"SCT_ClusterContainer"} {}; virtual void persToTrans(const FaserSCT_SpacePoint_p0* persObj, Tracker::FaserSCT_SpacePoint* transObj, @@ -25,8 +29,13 @@ class FaserSCT_SpacePointCnv_p0 : public T_AthenaPoolTPCnvBase<Tracker::FaserSCT virtual void transToPers(const Tracker::FaserSCT_SpacePoint* transObj, FaserSCT_SpacePoint_p0* persObj, MsgStream& log); + virtual StatusCode initialize( MsgStream& log ); ElementLinkCnv_p1<ElementLink<Tracker::FaserSCT_ClusterContainer>> m_elCnv; + private: + SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_sctClusContName; +// ToolHandle<Tracker::TrackerSpacePointCnvTool> m_cnvtool{this, "SpacePointCnvTool","SpacePointCnvTool"}; + }; #endif // SPACEPOINTCNV_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h index 5c1b5738d2777f4c38309409b4335444ec76c535..abae9236583c5113dcba648e0dd91991b9a4924e 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h @@ -22,7 +22,8 @@ class FaserSCT_SpacePointContainerCnv_p0 : public T_AthenaPoolTPCnvBase<FaserSCT FaserSCT_SpacePointContainer_p0* persObj, MsgStream& log); FaserSCT_SpacePointContainer* createTransient(FaserSCT_SpacePointContainer_p0* persObj, MsgStream& log){ - FaserSCT_SpacePointContainer* trans=new FaserSCT_SpacePointContainer(1000); persToTrans(persObj,trans,log);return trans;}; + FaserSCT_SpacePointContainer* trans=new FaserSCT_SpacePointContainer(1000); persToTrans(persObj,trans,log);return trans;}; + private: }; #endif // SPACEPOINTCONTAINERCNV_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h index 3c9d0660d971a0c29aa52fa27655f1dabdb1026c..ec13a7ff457af4241222fd2672cebd5c1e11f6e4 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h @@ -15,6 +15,14 @@ class FaserSCT_SpacePoint_p0 { private: unsigned int m_idHash0; unsigned int m_idHash1; + unsigned long long m_id1; + unsigned long long m_id0; + + float m_localpos_x; + float m_localpos_y; + float m_localcov00; + float m_localcov01; + float m_localcov11; float m_pos_x; float m_pos_y; @@ -34,6 +42,13 @@ inline FaserSCT_SpacePoint_p0::FaserSCT_SpacePoint_p0() : m_idHash0(0), m_idHash1(0), + m_id0(0), + m_id1(0), + m_localpos_x(0), + m_localpos_y(0), + m_localcov00(0), + m_localcov01(0), + m_localcov11(0), m_pos_x(0), m_pos_y(0), m_pos_z(0), diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointCnv_p0.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointCnv_p0.cxx index 3e0799934503f18c521aa3bb612e2bb5dd3af670..0e32664f9d408d3e6b011636ef6b652552eddac7 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointCnv_p0.cxx +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointCnv_p0.cxx @@ -1,22 +1,105 @@ /* - Copyright (C) 2021 CERN for the benefit of the FASER collaboration -*/ + Copyright (C) 2021 CERN for the benefit of the FASER collaboration + */ #include "TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h" +// Athena #include "AthLinks/ElementLink.h" + #include "Identifier/Identifier.h" #include "TrackerPrepRawData/FaserSCT_Cluster.h" #include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +StatusCode FaserSCT_SpacePointCnv_p0::initialize(MsgStream& log ) { + + ISvcLocator* svcLocator = Gaudi::svcLocator(); + + // Get the messaging service, print where you are + log << MSG::INFO << "FaserSCT_SpacePointCnv::initialize()" << endmsg; + m_sctClusContName.initialize(); + + return StatusCode::SUCCESS; +} + void FaserSCT_SpacePointCnv_p0::persToTrans(const FaserSCT_SpacePoint_p0* persObj, Tracker::FaserSCT_SpacePoint* transObj, MsgStream& log) { + this->initialize(log); + ElementLink<Tracker::FaserSCT_ClusterContainer> link1; ElementLink<Tracker::FaserSCT_ClusterContainer> link2; m_elCnv.persToTrans(&persObj->m_link1,&link1,log); m_elCnv.persToTrans(&persObj->m_link2,&link2,log); Amg::Vector3D pos(persObj->m_pos_x,persObj->m_pos_y,persObj->m_pos_z); - *transObj=Tracker::FaserSCT_SpacePoint(std::make_pair(persObj->m_idHash0,persObj->m_idHash1),&pos,link1,link2); + Amg::Vector2D localpos(persObj->m_localpos_x,persObj->m_localpos_y); + Amg::MatrixX localcov(2,2); + localcov<< + persObj->m_localcov00, persObj->m_localcov01, + persObj->m_localcov01, persObj->m_localcov11; + Amg::MatrixX cov(3,3); + cov<< + persObj->m_cov00, persObj->m_cov01, persObj->m_cov02, + persObj->m_cov01, persObj->m_cov11, persObj->m_cov12, + persObj->m_cov02, persObj->m_cov12, persObj->m_cov22; + const Tracker::FaserSCT_Cluster* clus1=nullptr; + const Tracker::FaserSCT_Cluster* clus2=nullptr; + + SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> h_sctClusCont(m_sctClusContName); + if (!h_sctClusCont.isValid()) { + log<<MSG::ERROR<<"SCT Cluster container not found at "<<m_sctClusContName<<endmsg; + return ; + } else { + log<<MSG::DEBUG<<"SCT Cluster Container found" <<endmsg; + } + const Tracker::FaserSCT_ClusterCollection *ptr = h_sctClusCont->indexFindPtr(persObj->m_idHash0); + // if we find PRD, then recreate link + if (ptr!=nullptr) { + //loop though collection to find matching PRD. + Tracker::FaserSCT_ClusterCollection::const_iterator collIt= ptr->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator collItEnd = ptr->end(); + // there MUST be a faster way to do this!! + for ( ; collIt!=collItEnd; ++collIt) { + if ( (*collIt)->identify().get_compact()==persObj->m_id0 ) clus1= &(**collIt); + } + } + + const Tracker::FaserSCT_ClusterCollection *ptr1 = h_sctClusCont->indexFindPtr(persObj->m_idHash1); + // if we find PRD, then recreate link + if (ptr1!=nullptr) { + //loop though collection to find matching PRD. + Tracker::FaserSCT_ClusterCollection::const_iterator collIt= ptr1->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator collItEnd = ptr1->end(); + // there MUST be a faster way to do this!! + for ( ; collIt!=collItEnd; ++collIt) { + if ( (*collIt)->identify().get_compact()==persObj->m_id1 ) clus2= &(**collIt); + } + } + /* + m_cnvtool->recreateSpacePoint(transObj,persObj->m_id0,persObj->m_idHash0,persObj->m_id1,persObj->m_idHash1); + */ + // if(clus2==nullptr)std::cout<<"didnot found the second cluster"<<std::endl; + if(clus1==nullptr||clus2==nullptr){ + log<<MSG::DEBUG<<"could not found the clusters"<<endmsg; + return; + } + // const TrackerDD::SiDetectorElement * de1 = elements->getDetectorElement( persObj->m_idHash0); + // const TrackerDD::SiDetectorElement * de2 = elements->getDetectorElement( persObj->m_idHash1); + // Tracker::FaserSCT_Cluster* clus1=const_cast<Tracker::FaserSCT_Cluster*>(link1.cachedElement()); + // Tracker::FaserSCT_Cluster* clus2=const_cast<Tracker::FaserSCT_Cluster*>(link2.cachedElement()); + // clus1->setDetectorElement(de1); + // clus2->setDetectorElement(de2); + // *transObj=Tracker::FaserSCT_SpacePoint(std::make_pair(persObj->m_idHash0,persObj->m_idHash1),&pos,&cov,&localpos,&localcov,link1,link2); + const std::pair<const Tracker::FaserSCT_Cluster*, const Tracker::FaserSCT_Cluster*> cluslist(clus1,clus2); + // transObj=new Tracker::FaserSCT_SpacePoint(std::make_pair(IdentifierHash(persObj->m_idHash0),IdentifierHash(persObj->m_idHash1)),&pos,&cluslist); + // //*transObj=Tracker::FaserSCT_SpacePoint(std::make_pair(IdentifierHash(persObj->m_idHash0),IdentifierHash(persObj->m_idHash1)),&pos,&cluslist); + // transObj->m_elelink1=link1; + // transObj->m_elelink1=link2; + transObj->setElemIdList(std::make_pair(IdentifierHash(persObj->m_idHash0),IdentifierHash(persObj->m_idHash1))); + transObj->setClusList(cluslist); + transObj->setGlobalParameters(pos); + transObj->setGlobalCovariance(cov); + transObj->setLocalCovariance(localcov); + transObj->setLocalParameters(localpos); } @@ -40,15 +123,16 @@ FaserSCT_SpacePointCnv_p0::transToPers(const Tracker::FaserSCT_SpacePoint* trans persObj->m_cov12 = cov(1,2); persObj->m_cov22 = cov(2,2); -// static const SG::InitializedReadHandleKey<Tracker::FaserSCT_ClusterContainer> sctClusContName ("FaserSCT_Clusters"); -// ElementLink<Tracker::FaserSCT_ClusterContainer>::index_type hashAndIndex1{0}; -// ElementLink<Tracker::FaserSCT_ClusterContainer>::index_type hashAndIndex2{0}; -// bool isFound1{m_eventCnvTool->getHashAndIndex1<Tracker::FaserSCT_ClusterContainer, Tracker::FaserSCT_SpacePoint>(transObj, sctClusContName, hashAndIndex1)}; -// bool isFound2{m_eventCnvTool->getHashAndIndex2<Tracker::FaserSCT_ClusterContainer, Tracker::FaserSCT_SpacePoint>(transObj, sctClusContName, hashAndIndex2)}; -// persObj->m_link1.m_contName=(isFound1 ? sctClusContName.key() : ""); -// persObj->m_link2.m_contName=(isFound2 ? sctClusContName.key() : ""); -// persObj->m_link1.m_elementIndex= hashAndIndex1; -// persObj->m_link2.m_elementIndex= hashAndIndex2; + persObj->m_id0= transObj->clusterList().first->identify().get_compact(); + persObj->m_id1= transObj->clusterList().second->identify().get_compact(); + auto localparam=transObj->localParameters(); + persObj->m_localpos_x = localparam.x(); + persObj->m_localpos_y = localparam.y(); + auto localcov = transObj->localCovariance(); + persObj->m_localcov00 = cov(0,0); + persObj->m_localcov01 = cov(0,1); + persObj->m_localcov11 = cov(1,2); + persObj->m_link1.m_contName = transObj->getElementLink1()->dataID(); persObj->m_link1.m_elementIndex = transObj->getElementLink1()->index(); persObj->m_link2.m_contName = transObj->getElementLink2()->dataID(); diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointContainerCnv_p0.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointContainerCnv_p0.cxx index ec43ce0abe97570ae6cee30846b5bf050a79e30c..908aae35fcdff270796dfe70f059d744132f2e7e 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointContainerCnv_p0.cxx +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointContainerCnv_p0.cxx @@ -8,12 +8,15 @@ #include "TrackerEventTPCnv/FaserSCT_SpacePointCollection_p0.h" #include "TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h" #include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/StatusCode.h" void FaserSCT_SpacePointContainerCnv_p0::persToTrans(const FaserSCT_SpacePointContainer_p0* persObj, FaserSCT_SpacePointContainer* transObj, MsgStream& log) { FaserSCT_SpacePointCollection* coll = 0; FaserSCT_SpacePointCnv_p0 chanCnv; unsigned int collBegin(0); + for (unsigned int icoll = 0; icoll < persObj->m_spacepoint_collections.size(); ++icoll) { const FaserSCT_SpacePointCollection_p0& pcoll = persObj->m_spacepoint_collections[icoll]; IdentifierHash collIDHash(IdentifierHash(pcoll.m_idHash)); @@ -23,9 +26,10 @@ void FaserSCT_SpacePointContainerCnv_p0::persToTrans(const FaserSCT_SpacePointCo coll->resize(nchans); for (unsigned int ichan = 0; ichan < nchans; ++ ichan) { const FaserSCT_SpacePoint_p0* pchan=&(persObj->m_spacepoints[ichan+collBegin]); - Tracker::FaserSCT_SpacePoint* transSP=nullptr; - chanCnv.persToTrans(pchan, transSP, log); - if(transSP==nullptr)std::cout<<"did not found space"<<std::endl; + Tracker::FaserSCT_SpacePoint* transSP=new Tracker::FaserSCT_SpacePoint(); + chanCnv.persToTrans(pchan, transSP, log ); + if(transSP==nullptr) + log << MSG::INFO<<"did not found space"<<endmsg; (*coll)[ichan]=transSP; } collBegin +=nchans; @@ -38,7 +42,7 @@ void FaserSCT_SpacePointContainerCnv_p0::persToTrans(const FaserSCT_SpacePointCo } void FaserSCT_SpacePointContainerCnv_p0::transToPers(const FaserSCT_SpacePointContainer* transObj, FaserSCT_SpacePointContainer_p0* persObj, MsgStream& log) { - log << MSG::INFO << "FaserSCT_SpacePointContainerCnv_p0::transToPers()" << endmsg; + log << MSG::DEBUG<< "FaserSCT_SpacePointContainerCnv_p0::transToPers()" << endmsg; FaserSCT_SpacePointCnv_p0 spCnv; typedef FaserSCT_SpacePointContainer TRANS; diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx index 2c6386a389183a90c2b93f4cbfa9621a3feba21e..68e9695ef1b05723ac2539b947ed9af644a621a0 100755 --- a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx @@ -148,7 +148,26 @@ StatusCode StatisticsAlg::execute (const EventContext& ctx) const msg(MSG:: FATAL) << "Could not find the data object "<< sct_clcontainer.name() << " !" << endmsg; return StatusCode::RECOVERABLE; } + std::cout<<"read sct"<<std::endl; + Tracker::FaserSCT_ClusterContainer::const_iterator clusit = sct_clcontainer->begin(); + Tracker::FaserSCT_ClusterContainer::const_iterator clusend = sct_clcontainer->end(); + for (; clusit != clusend; ++clusit){ + const Tracker::FaserSCT_ClusterCollection *colNext=&(**clusit); + Identifier elementID = colNext->identify(); + std::cout<<"SCT hash "<<colNext->identify()<<" "<<colNext->identifyHash()<<" "<<colNext->size()<<std::endl; + FaserSCT_ClusterCollection::const_iterator clusters {colNext->begin()}; + FaserSCT_ClusterCollection::const_iterator clustersEnd {colNext->end()}; + for (; clusters != clustersEnd; ++clusters) + { + + const TrackerDD::SiDetectorElement* elem = (*clusters)->detectorElement(); + if (elem == nullptr)std::cout<<"not found detectorelement "<<std::endl; + else std::cout<<"element id "<<elem->identify(); + } + } + + std::cout<<"finish read sct"<<std::endl; // retrieve SCT cluster container SG::ReadHandle<FaserSCT_SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h index d3ad87a299c9c21f68fee6b2dd1ff7b8e9d8118c..f21facf6ae0533bcd14a0bd29ebbc92157328d39 100755 --- a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h @@ -1,6 +1,6 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ /////////////////////////////////////////////////////////////////// // SCT_SpacePoint.h @@ -41,201 +41,216 @@ namespace Tracker * @class SCT_SpacePoint * An SCT_SpacePoint is created from two SCT_Cluster's from two different wafers. */ - + class FaserSCT_SpacePoint - { - friend class FaserSCT_SpacePointContainerCnv; - friend class FaserSCT_SpacePointContainerCnv_p0; - friend class FaserSCT_SpacePointCnv_p0; - - /////////////////////////////`////////////////////////////////////// - // Public methods: - /////////////////////////////////////////////////////////////////// + { + friend class FaserSCT_SpacePointContainerCnv; + friend class FaserSCT_SpacePointContainerCnv_p0; + friend class FaserSCT_SpacePointCnv_p0; + + /////////////////////////////`////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// public: - - /** Default constructor */ - FaserSCT_SpacePoint() ; - - /** - * @name Parametrised constructors - * In order to ensure initialisation, the global Position has to be - * on the surface associated to the FIRST member of the PRD-pair clusList. - */ - //@{ - FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, - const Amg::Vector3D* position, - const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; - - FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, - const Amg::Vector3D* position, - const Amg::MatrixX* loccov,//assumes ownership of loccov - const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; - - FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, - const Amg::Vector3D& position, - const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; - - FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, - const Amg::Vector3D& position, - const Amg::MatrixX& loccov,//assumes ownership of loccov - const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; - FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, - const Amg::Vector3D* position, - const ElementLink<Tracker::FaserSCT_ClusterContainer>& link1, const ElementLink<Tracker::FaserSCT_ClusterContainer>& link2) ; - //@} - - /** Copy Constructor */ -// FaserSCT_SpacePoint(const FaserSCT_SpacePoint &) ; - - /** Destructor */ - ~FaserSCT_SpacePoint() = default; - - /** Overloading Assignment Operator */ -// FaserSCT_SpacePoint &operator=(const FaserSCT_SpacePoint &); - - /** Clones */ - FaserSCT_SpacePoint* clone() const ; - /** return the pair of Ids of the element by reference*/ - const std::pair<IdentifierHash, IdentifierHash>& elementIdList() const; - - /** return the pair of cluster pointers by reference */ - const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>& clusterList() const; - - /** return the error matrix by reference - The Matrix is calculated from the local Covariance Matrix when demanded and the cached */ - const Amg::MatrixX& globCovariance() const; - - /** calculate eta (not cached), needs z0 info */ - double eta(double z0=0) const; - - /**returns the r value of the SpacePoint's position (in cylindrical coordinates). - This is calculated once in the ctor and then cached*/ - double r() const ; - - /**returns the phi value of the SpacePoint's position (in cylindrical coordinates). - 0070 This is calculated once in the ctor and then cached*/ - double phi() const ; - - - /**Interface method for output, to be overloaded by child classes* */ - MsgStream& dump( MsgStream& out ) const ; - - /**Interface method for output, to be overloaded by child classes* */ - std::ostream& dump( std::ostream& out ) const ; - - /**Interface method to get the LocalParameters*/ - const Trk::LocalParameters& localParameters() const; - - /**Interface method to get the localError*/ - const Amg::MatrixX& localCovariance() const; - - /**Interface method to get the associated Surface*/ - const Trk::Surface& associatedSurface() const ; - - /**Interface method to get the global Position*/ - const Amg::Vector3D& globalPosition() const ; - - // Here to help implement the relevant semantics for - // the derived classes - FaserSCT_SpacePoint(const FaserSCT_SpacePoint&) = default; - FaserSCT_SpacePoint(FaserSCT_SpacePoint&&) noexcept = default; - FaserSCT_SpacePoint& operator=(const FaserSCT_SpacePoint&); - FaserSCT_SpacePoint& operator=(FaserSCT_SpacePoint&&) noexcept = default; - - //Element link to FaserSCT_Cluster - ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink1(){return (&m_elelink1);} - ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink2(){return (&m_elelink2);} - const ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink1()const {return (&m_elelink1);} - const ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink2()const {return (&m_elelink2);} - const Tracker::FaserSCT_Cluster* cluster1() const{if(m_elelink1.isValid())return m_elelink1.cachedElement();else return 0;} - const Tracker::FaserSCT_Cluster* cluster2() const{if(m_elelink2.isValid())return m_elelink2.cachedElement();else return 0;} - - protected: - - Trk::LocalParameters m_localParams; - Amg::MatrixX m_localCovariance; - std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*> m_clusList; - std::pair<IdentifierHash, IdentifierHash> m_elemIdList; - Amg::Vector3D m_position; - Amg::MatrixX m_globalCovariance; - - private: + /** Default constructor */ + FaserSCT_SpacePoint() ; + + /** + * @name Parametrised constructors + * In order to ensure initialisation, the global Position has to be + * on the surface associated to the FIRST member of the PRD-pair clusList. + */ + //@{ + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; + + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const Amg::MatrixX* loccov,//assumes ownership of loccov + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; + + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + Amg::MatrixX* globallcov, + const Amg::Vector2D* localpos, + Amg::MatrixX* localcov, + const ElementLink<Tracker::FaserSCT_ClusterContainer>& link1, const ElementLink<Tracker::FaserSCT_ClusterContainer>& link2) ; + + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const Amg::MatrixX& loccov,//assumes ownership of loccov + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const ElementLink<Tracker::FaserSCT_ClusterContainer>& link1, const ElementLink<Tracker::FaserSCT_ClusterContainer>& link2) ; + //@} + + /** Copy Constructor */ + // FaserSCT_SpacePoint(const FaserSCT_SpacePoint &) ; + + /** Destructor */ + ~FaserSCT_SpacePoint() = default; + + /** Overloading Assignment Operator */ + // FaserSCT_SpacePoint &operator=(const FaserSCT_SpacePoint &); + + /** Clones */ + FaserSCT_SpacePoint* clone() const ; + /** return the pair of Ids of the element by reference*/ + const std::pair<IdentifierHash, IdentifierHash>& elementIdList() const; + + /** return the pair of cluster pointers by reference */ + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>& clusterList() const; + + /** return the error matrix by reference + The Matrix is calculated from the local Covariance Matrix when demanded and the cached */ + const Amg::MatrixX& globCovariance() const; + + /** calculate eta (not cached), needs z0 info */ + double eta(double z0=0) const; + + /**returns the r value of the SpacePoint's position (in cylindrical coordinates). + This is calculated once in the ctor and then cached*/ + double r() const ; + + /**returns the phi value of the SpacePoint's position (in cylindrical coordinates). + 0070 This is calculated once in the ctor and then cached*/ + double phi() const ; + + + /**Interface method for output, to be overloaded by child classes* */ + MsgStream& dump( MsgStream& out ) const ; + + /**Interface method for output, to be overloaded by child classes* */ + std::ostream& dump( std::ostream& out ) const ; + + /**Interface method to get the LocalParameters*/ + const Trk::LocalParameters& localParameters() const; + + /**Interface method to get the localError*/ + const Amg::MatrixX& localCovariance() const; - ElementLink<Tracker::FaserSCT_ClusterContainer> m_elelink1, m_elelink2; - void setupGlobalFromLocalCovariance(); - /** method to set up the local Covariance Matrix. */ - void setupLocalCovarianceSCT() ; + /**Interface method to get the associated Surface*/ + const Trk::Surface& associatedSurface() const ; - /** common method used in constructors. */ - void setup(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, - const Amg::Vector3D& position, - const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList); + /**Interface method to get the global Position*/ + const Amg::Vector3D& globalPosition() const ; + + // Here to help implement the relevant semantics for + // the derived classes + FaserSCT_SpacePoint(const FaserSCT_SpacePoint&) = default; + FaserSCT_SpacePoint(FaserSCT_SpacePoint&&) noexcept = default; + FaserSCT_SpacePoint& operator=(const FaserSCT_SpacePoint&); + FaserSCT_SpacePoint& operator=(FaserSCT_SpacePoint&&) noexcept = default; + + //Element link to FaserSCT_Cluster + ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink1(){return (&m_elelink1);} + ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink2(){return (&m_elelink2);} + const ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink1()const {return (&m_elelink1);} + const ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink2()const {return (&m_elelink2);} + const Tracker::FaserSCT_Cluster* cluster1() const{if(m_elelink1.isValid())return m_elelink1.cachedElement();else return 0;} + const Tracker::FaserSCT_Cluster* cluster2() const{if(m_elelink2.isValid())return m_elelink2.cachedElement();else return 0;} + + void setLocalParameters(Amg::Vector2D& loc){m_localParams = Trk::LocalParameters(loc);}; + void setGlobalParameters(Amg::Vector3D& glo){m_position=glo;}; + void setGlobalCovariance(Amg::MatrixX& glo){m_globalCovariance=glo;}; + void setLocalCovariance(Amg::MatrixX& loc){m_localCovariance=loc;}; + void setClusList(std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*> list){m_clusList=list; m_elelink1.setElement(list.first); + m_elelink2.setElement(list.second); }; - + void setElemIdList(std::pair<IdentifierHash, IdentifierHash> list){m_elemIdList=list;}; + + protected: + + Trk::LocalParameters m_localParams; + Amg::MatrixX m_localCovariance; + std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*> m_clusList; + std::pair<IdentifierHash, IdentifierHash> m_elemIdList; + Amg::Vector3D m_position; + Amg::MatrixX m_globalCovariance; + + private: + + + ElementLink<Tracker::FaserSCT_ClusterContainer> m_elelink1, m_elelink2; + void setupGlobalFromLocalCovariance(); + /** method to set up the local Covariance Matrix. */ + void setupLocalCovarianceSCT() ; + + /** common method used in constructors. */ + void setup(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList); + }; + /////////////////////////////////////////////////////////////////// // Inline methods: /////////////////////////////////////////////////////////////////// inline FaserSCT_SpacePoint* FaserSCT_SpacePoint::clone() const - { return new FaserSCT_SpacePoint(*this) ; } + { return new FaserSCT_SpacePoint(*this) ; } inline const Trk::LocalParameters& FaserSCT_SpacePoint::localParameters() const { return m_localParams; - } - - inline const Amg::MatrixX& + } + + inline const Amg::MatrixX& FaserSCT_SpacePoint::localCovariance() const { return m_localCovariance; - } - - /**Overload of << operator for MsgStream for debug output*/ - inline MsgStream& - operator<<(MsgStream& sl, const FaserSCT_SpacePoint& mbase) - { - return mbase.dump(sl); - } - - /**Overload of << operator for std::ostream for debug output*/ - inline std::ostream& - operator<<(std::ostream& sl, const FaserSCT_SpacePoint& mbase) - { - return mbase.dump(sl); - } - inline const std::pair<IdentifierHash, IdentifierHash>& FaserSCT_SpacePoint::elementIdList() const - { return m_elemIdList; } - - - inline const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>& FaserSCT_SpacePoint::clusterList() const - { - return m_clusList; - } - - inline double FaserSCT_SpacePoint::eta(double z0) const - { - // double zr = (m_z-z0)/m_r; - double zr = (m_position.z() - z0)/m_position.perp(); - return std::log(zr+std::sqrt(1.+zr*zr)); - } - - inline double FaserSCT_SpacePoint::r() const - { return m_position.perp(); } - - inline double FaserSCT_SpacePoint::phi() const - { return m_position.phi(); } - - // The methods required by MeasurementBase - inline const Amg::Vector3D& FaserSCT_SpacePoint::globalPosition() const - { - return m_position; - } - inline const Amg::MatrixX& FaserSCT_SpacePoint::globCovariance() const { - return m_globalCovariance; - } - + } + + /**Overload of << operator for MsgStream for debug output*/ + inline MsgStream& + operator<<(MsgStream& sl, const FaserSCT_SpacePoint& mbase) + { + return mbase.dump(sl); + } + + /**Overload of << operator for std::ostream for debug output*/ + inline std::ostream& + operator<<(std::ostream& sl, const FaserSCT_SpacePoint& mbase) + { + return mbase.dump(sl); + } + inline const std::pair<IdentifierHash, IdentifierHash>& FaserSCT_SpacePoint::elementIdList() const + { return m_elemIdList; } + + + inline const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>& FaserSCT_SpacePoint::clusterList() const + { + return m_clusList; + } + + inline double FaserSCT_SpacePoint::eta(double z0) const + { + // double zr = (m_z-z0)/m_r; + double zr = (m_position.z() - z0)/m_position.perp(); + return std::log(zr+std::sqrt(1.+zr*zr)); + } + + inline double FaserSCT_SpacePoint::r() const + { return m_position.perp(); } + + inline double FaserSCT_SpacePoint::phi() const + { return m_position.phi(); } + + // The methods required by MeasurementBase + inline const Amg::Vector3D& FaserSCT_SpacePoint::globalPosition() const + { + return m_position; + } + inline const Amg::MatrixX& FaserSCT_SpacePoint::globCovariance() const { + return m_globalCovariance; + } + } #endif // TRACKERSPACEPOINT_SCTSPACEPOINT_H diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx index 068c0ab890bd6526ea5fba3bd6d927133c535b67..33b0610b8409d32163c8af6a0091133e6c742610 100755 --- a/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx @@ -20,6 +20,26 @@ namespace Tracker //------------------------------------------------------------- + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + Amg::MatrixX* globalcov, + const Amg::Vector2D* localpos, + Amg::MatrixX* localcov, + const ElementLink<Tracker::FaserSCT_ClusterContainer>& link1, const ElementLink<Tracker::FaserSCT_ClusterContainer>& link2): m_elelink1(link1),m_elelink2(link2) + { + const FaserSCT_Cluster* clus1=link1.cachedElement(); + const FaserSCT_Cluster* clus2=link2.cachedElement(); + std::cout<<*clus1<<std::endl;; + std::cout<<clus1->identify()<<" "<<std::endl; + m_clusList.first = clus1; + m_clusList.second = clus2; + m_position = *position ; + m_globalCovariance = *globalcov; + m_localParams = Trk::LocalParameters(*localpos) ; + m_localCovariance = *localcov; + } + //------------------------------------------------------------- + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, const Amg::Vector3D* position, const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) @@ -29,7 +49,7 @@ namespace Tracker setupGlobalFromLocalCovariance(); m_elelink1.setElement(clusList->first); m_elelink2.setElement(clusList->second); - delete position; +// delete position; } //------------------------------------------------------------- diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h index fdf91ae18e75e6ff1a30604a225b963c8315b923..678fef289c9f5b01a1e4a566a24ebee0353ba386 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h @@ -17,20 +17,20 @@ namespace Acts { class SPSeedBasedInitialParameterTool : public AthAlgTool { - public: - SPSeedBasedInitialParameterTool (const std::string& type, - const std::string& name, const IInterface* parent); - ~SPSeedBasedInitialParameterTool() = default; + public: + SPSeedBasedInitialParameterTool (const std::string& type, + const std::string& name, const IInterface* parent); + ~SPSeedBasedInitialParameterTool() = default; - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; + virtual StatusCode initialize() override; + virtual StatusCode finalize() override; - std::vector<Acts::CurvilinearTrackParameters> getInitialParameters() const; - //Acts::CurvilinearTrackParameters getInitialParameters(std::vector<Identifier> ids) const; + std::vector<Acts::CurvilinearTrackParameters> getInitialParameters() const; + //Acts::CurvilinearTrackParameters getInitialParameters(std::vector<Identifier> ids) const; - private: - const FaserSCT_ID* m_idHelper{nullptr}; - SG::ReadHandleKey<Tracker::TrackerSeedCollection> m_trackerSeedContainerKey{this, "FaserTrackerSeedName", "FaserTrackerSeedCollection", "FaserTrackerSeedCollection"}; + private: + const FaserSCT_ID* m_idHelper{nullptr}; + SG::ReadHandleKey<Tracker::TrackerSeedCollection> m_trackerSeedContainerKey{this, "FaserTrackerSeedName", "FaserTrackerSeedCollection", "FaserTrackerSeedCollection"}; }; #endif // TRUTHBASEDINITIALPARAMETERTOOL_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSimpleInitialParameterTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSimpleInitialParameterTool.h index 437d5622a882be5ff4b624f475d573f5bae98f14..9db75f35f692669dfd3739872697d9309a967228 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSimpleInitialParameterTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSimpleInitialParameterTool.h @@ -18,20 +18,20 @@ namespace Acts { class SPSimpleInitialParameterTool : public AthAlgTool { - public: - SPSimpleInitialParameterTool (const std::string& type, - const std::string& name, const IInterface* parent); - ~SPSimpleInitialParameterTool() = default; + public: + SPSimpleInitialParameterTool (const std::string& type, + const std::string& name, const IInterface* parent); + ~SPSimpleInitialParameterTool() = default; - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; + virtual StatusCode initialize() override; + virtual StatusCode finalize() override; - Acts::CurvilinearTrackParameters getInitialParameters(Acts::Vector3 pos1, Acts::Vector3 pos2, Acts::Vector3 pos3) const; - Acts::CurvilinearTrackParameters getInitialParameters_2stations(Acts::Vector3 pos1, Acts::Vector3 pos2, Acts::Vector3 pos3) const; - std::vector<Acts::CurvilinearTrackParameters> getInitialParameters_1station(std::vector<Acts::Vector3> pos1, std::vector<Acts::Vector3> pos2, std::vector<Acts::Vector3> pos3) const; - //Acts::CurvilinearTrackParameters getInitialParameters(std::vector<Identifier> ids) const; + Acts::CurvilinearTrackParameters getInitialParameters(Acts::Vector3 pos1, Acts::Vector3 pos2, Acts::Vector3 pos3) const; + Acts::CurvilinearTrackParameters getInitialParameters_2stations(Acts::Vector3 pos1, Acts::Vector3 pos2, Acts::Vector3 pos3) const; + std::vector<Acts::CurvilinearTrackParameters> getInitialParameters_1station(std::vector<Acts::Vector3> pos1, std::vector<Acts::Vector3> pos2, std::vector<Acts::Vector3> pos3) const; + //Acts::CurvilinearTrackParameters getInitialParameters(std::vector<Identifier> ids) const; - private: + private: }; #endif // TRUTHBASEDINITIALPARAMETERTOOL_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx index b0eedcc3f5467409cd087c97cf9761e3bd7bf2e5..08e9f2b2283089fbcda678d65234c3cce03c3c7e 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx @@ -188,19 +188,20 @@ return StatusCode::RECOVERABLE; // } // } // } + /* if(pos1.size()>0&&pos2.size()>0&&pos3.size()>0) { auto initialParameter=m_initialParameterTool->getInitialParameters(pos1a,pos2a,pos3a); if(initialParameter.momentum().z()>0){ m_nseeds++; initialParameters.push_back(initialParameter); - /* + */ // for one stations if(pos1.size()>2) { std::vector<Acts::Vector3> pos10; std::vector<Acts::Vector3> pos11; std::vector<Acts::Vector3> pos12; pos10.clear();pos11.clear();pos12.clear(); - for(int ipos=0;ipos<pos1.size();ipos++){ + for(std::size_t ipos=0;ipos<pos1.size();ipos++){ if(layer1[ipos]==0)pos10.push_back(pos1[ipos]); if(layer1[ipos]==1)pos11.push_back(pos1[ipos]); if(layer1[ipos]==2)pos12.push_back(pos1[ipos]); @@ -208,7 +209,6 @@ return StatusCode::RECOVERABLE; if(pos10.size()>0&&pos11.size()>0&&pos12.size()>0){ auto initialParameter=m_initialParameterTool->getInitialParameters_1station(pos10,pos11,pos12); initialParameters.insert(initialParameters.end(),initialParameter.begin(),initialParameter.end()); - */ /* //for two stations if(pos1.size()>1&&pos2.size()>0) { @@ -407,7 +407,7 @@ CombinatorialKalmanFilterAlg::makeTrack(Acts::GeometryContext& tgContext, Fitter if (fitOutput.fittedParameters.size()>0) { DataVector<const Trk::TrackStateOnSurface>* finalTrajectory=new DataVector<const Trk::TrackStateOnSurface>{}; std::vector<std::unique_ptr<const Acts::BoundTrackParameters>> actsSmoothedParam; - std::cout<<"makeTrack : trackTip "<<fitOutput.lastMeasurementIndices.size()<<std::endl; + ATH_MSG_DEBUG("makeTrack : trackTip "<<fitOutput.lastMeasurementIndices.size()); // Loop over all the output state to create track state fitOutput.fittedStates.visitBackwards(fitOutput.lastMeasurementIndices.front(), [&](const auto &state) { auto flag = state.typeFlags(); @@ -440,21 +440,15 @@ CombinatorialKalmanFilterAlg::makeTrack(Acts::GeometryContext& tgContext, Fitter const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(), state.smoothed(), state.smoothedCovariance()); - std::cout<<actsParam<<std::endl; actsSmoothedParam.push_back(std::make_unique<const Acts::BoundTrackParameters>(Acts::BoundTrackParameters(actsParam))); - const auto& psurface=actsParam.referenceSurface(); -// std::cout<<"position "<<psurface.center(tgContext)<<std::endl; -// std::cout<<"position "<<psurface.associatedDetectorElement()->thickness()<<std::endl; -// std::cout<<"geometry "<<psurface.geometryId().volume()<<" "<<psurface.geometryId().layer()<<" "<<psurface.geometryId().sensitive()<<std::endl; - Acts::Vector2 local(actsParam.parameters()[Acts::eBoundLoc0], actsParam.parameters()[Acts::eBoundLoc1]); -const Acts::Vector3 dir = Acts::makeDirectionUnitFromPhiTheta(actsParam.parameters()[Acts::eBoundPhi], actsParam.parameters()[Acts::eBoundTheta]); - Acts::Vector3 global = - actsParam.position(tgContext); - //psurface.localToGlobal(tgContext, local, dir); - -// std::cout<<global<<std::endl; - auto pos=actsParam.position(tgContext); + // const auto& psurface=actsParam.referenceSurface(); + // std::cout<<"position "<<psurface.center(tgContext)<<std::endl; + // std::cout<<"position "<<psurface.associatedDetectorElement()->thickness()<<std::endl; + // std::cout<<"geometry "<<psurface.geometryId().volume()<<" "<<psurface.geometryId().layer()<<" "<<psurface.geometryId().sensitive()<<std::endl; + Acts::Vector2 local(actsParam.parameters()[Acts::eBoundLoc0], actsParam.parameters()[Acts::eBoundLoc1]); +// const Acts::Vector3 dir = Acts::makeDirectionUnitFromPhiTheta(actsParam.parameters()[Acts::eBoundPhi], actsParam.parameters()[Acts::eBoundTheta]); +// auto pos=actsParam.position(tgContext); parm = ConvertActsTrackParameterToATLAS(actsParam, tgContext); typePattern.set(Trk::TrackStateOnSurface::Measurement); @@ -466,7 +460,7 @@ const Acts::Vector3 dir = Acts::makeDirectionUnitFromPhiTheta(actsParam.paramete //const Tracker::FaserSCT_Cluster* fitCluster=&sp; const Tracker::FaserSCT_Cluster* fitCluster=sp.clusterList().first; if(fitCluster !=nullptr){ - measState = new Tracker::FaserSCT_ClusterOnTrack{ fitCluster, Trk::LocalParameters { Trk::DefinedParameter { fitCluster->localPosition()[0], Trk::loc1 }, Trk::DefinedParameter { fitCluster->localPosition()[1], Trk::loc2 } }, fitCluster->localCovariance(), m_idHelper->wafer_hash(fitCluster->detectorElement()->identify())}; + measState = new Tracker::FaserSCT_ClusterOnTrack{ fitCluster, Trk::LocalParameters { Trk::DefinedParameter { fitCluster->localPosition()[0], Trk::loc1 }, Trk::DefinedParameter { fitCluster->localPosition()[1], Trk::loc2 } }, fitCluster->localCovariance(), m_idHelper->wafer_hash(fitCluster->detectorElement()->identify())}; } } double nDoF = state.calibratedSize(); @@ -477,7 +471,7 @@ const Acts::Vector3 dir = Acts::makeDirectionUnitFromPhiTheta(actsParam.paramete finalTrajectory->insert(finalTrajectory->begin(), perState); } -// } + // } } return; }); @@ -515,7 +509,6 @@ CombinatorialKalmanFilterAlg ::ConvertActsTrackParameterToATLAS(const Acts::Boun } cov = std::optional<AmgSymMatrix(5)>(newcov); } - std::cout<<actsParameter<<std::endl; const Amg::Vector3D& pos=actsParameter.position(gctx); double tphi=actsParameter.get<Acts::eBoundPhi>(); double ttheta=actsParameter.get<Acts::eBoundTheta>(); diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/FaserActsKalmanFilterAlg.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/FaserActsKalmanFilterAlg.cxx index 392d0bfd8d4572273ae0b38812ca507cb363da16..c9427a0f8f9940f6d181e4f4775bcb9a8e2ae527 100755 --- a/Tracking/Acts/FaserActsKalmanFilter/src/FaserActsKalmanFilterAlg.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/FaserActsKalmanFilterAlg.cxx @@ -453,8 +453,8 @@ StatusCode FaserActsKalmanFilterAlg::execute() std::shared_ptr<const Acts::Surface> initSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(center, normal); // extrapolate the particle from production point to the first layer const Acts::Vector4 truthPosTime (pPos.x(), pPos.y(), pPos.z(), time); - const Acts::Vector3 truthMomentum_dir = pMom.normalized(); - double truthMomentum_abs = pMom.norm(); +// const Acts::Vector3 truthMomentum_dir = pMom.normalized(); +// double truthMomentum_abs = pMom.norm(); BoundVector params = BoundVector::Zero(); params[Acts::eBoundLoc0] = pPos.x(); diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/SPSeedBasedInitialParameterTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/SPSeedBasedInitialParameterTool.cxx index 7b04f41984428028b0b80aeea5186db746d0479e..f29ce6e80e65a9ca759f931174318fd1c1a68b68 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/SPSeedBasedInitialParameterTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/SPSeedBasedInitialParameterTool.cxx @@ -38,7 +38,7 @@ std::vector<Acts::CurvilinearTrackParameters> SPSeedBasedInitialParameterTool::g msg(MSG::FATAL) << "Could not find the data object "<< trackerSeedCollection.name() << " !" << endmsg; return initialParameters; } -// msg(MSG::INFO) << "found "<< trackerSeedCollection.size()<< " seeds" << endmsg; + // msg(MSG::INFO) << "found "<< trackerSeedCollection.size()<< " seeds" << endmsg; double charge = 1; double B = 0.55; @@ -57,7 +57,6 @@ std::vector<Acts::CurvilinearTrackParameters> SPSeedBasedInitialParameterTool::g Acts::Vector3 pos2_1(0., 0., 0.); Acts::Vector3 pos2_2(0., 0., 0.); for(auto isp : sps){ - std::cout<<"SP in seed "<<*isp<<std::endl; //get the cluster ID const Identifier id = isp->clusterList().first->identify(); Amg::Vector3D gloPos=isp->globalPosition(); @@ -115,7 +114,7 @@ std::vector<Acts::CurvilinearTrackParameters> SPSeedBasedInitialParameterTool::g const Acts::Vector4 postime(pos.x(), pos.y(), pos.z(),time); Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); -// Acts::CurvilinearTrackParameters InitTrackParam(std::make_optional(std::move(cov)), pos, mom, charge, time); // calculated initial parameters + // Acts::CurvilinearTrackParameters InitTrackParam(std::make_optional(std::move(cov)), pos, mom, charge, time); // calculated initial parameters initialParameters.push_back(InitTrackParam); } diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/SPSimpleInitialParameterTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/SPSimpleInitialParameterTool.cxx index bba52ec8d6f2030d5da18d811aa6d6dd53bb2890..f3d227dcb6e81085b28a12d6e68a5161d171dba3 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/SPSimpleInitialParameterTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/SPSimpleInitialParameterTool.cxx @@ -38,35 +38,35 @@ Acts::CurvilinearTrackParameters SPSimpleInitialParameterTool::getInitialParamet double tmpa=sqrt(amc.y()*amc.y()+amc.z()*amc.z())/2.; double tmpb=sqrt((pos2.y()-apc.y())*(pos2.y()-apc.y())+(pos2.z()-apc.z())*(pos2.z()-apc.z())); double R=(tmpa*tmpa+tmpb*tmpb)/2./tmpb; - double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) - - Acts::Vector3 d1=amc.normalized()+amb.normalized()-bmc.normalized(); - Acts::Vector3 d2=(pos3+pos2)/2.-pos1; - double p_z=p_yz*d1.z()/sqrt(d1.z()*d1.z()+d1.y()*d1.y()); - double p_y=p_z*d1.y()/d1.z(); - double p_x=p_z*d2.x()/d2.z(); - - const Acts::Vector3 mom(p_x, p_y, p_z); - double p = mom.norm(); - msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<endmsg; - // build the track covariance matrix using the smearing sigmas - double sigmaU = 10000_um; - double sigmaV = 10000_um; - double sigmaPhi = 20_degree; - double sigmaTheta = 10_degree; - double sigmaQOverP = 10.00*p / (p*p); - //double sigmaQOverP = 0.02*p / (p*p); - double sigmaT0 = 1_ns; - Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); - cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; - cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; - cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; - cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; - cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; - cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; - double time =0; - const Acts::Vector4 postime(pos1.x(), pos1.y(), pos1.z(),time); - Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); + double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) + + Acts::Vector3 d1=amc.normalized()+amb.normalized()-bmc.normalized(); + Acts::Vector3 d2=(pos3+pos2)/2.-pos1; + double p_z=p_yz*d1.z()/sqrt(d1.z()*d1.z()+d1.y()*d1.y()); + double p_y=p_z*d1.y()/d1.z(); + double p_x=p_z*d2.x()/d2.z(); + + const Acts::Vector3 mom(p_x, p_y, p_z); + double p = mom.norm(); + msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<endmsg; + // build the track covariance matrix using the smearing sigmas + double sigmaU = 10000_um; + double sigmaV = 10000_um; + double sigmaPhi = 20_degree; + double sigmaTheta = 10_degree; + double sigmaQOverP = 10.00*p / (p*p); + //double sigmaQOverP = 0.02*p / (p*p); + double sigmaT0 = 1_ns; + Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; + cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; + cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; + cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; + cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; + cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; + double time =0; + const Acts::Vector4 postime(pos1.x(), pos1.y(), pos1.z(),time); + Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); return InitTrackParam; } @@ -84,83 +84,86 @@ Acts::CurvilinearTrackParameters SPSimpleInitialParameterTool::getInitialParamet dir2=(pos2-pos1)/2.; double R=sqrt(dir2.y()*dir2.y()+dir2.z()*dir2.z())/st; - double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) - double p_z=p_yz*dir1.z()/sqrt(dir1.y()*dir1.y()+dir1.z()*dir1.z()); - double p_y=p_z*dir1.y()/dir1.z(); - double p_x=p_z*dir1.x()/dir1.z(); - - - const Acts::Vector3 mom(p_x, p_y, p_z); - double p = mom.norm(); - msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<st<<" "<<charge<<endmsg; - // build the track covariance matrix using the smearing sigmas - double sigmaU = 1000_um; - double sigmaV = 1000_um; - double sigmaPhi = 10_degree; - double sigmaTheta = 2_degree; - double sigmaQOverP = 0.20*p / (p*p); - //double sigmaQOverP = 0.02*p / (p*p); - double sigmaT0 = 1_ns; - Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); - cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; - cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; - cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; - cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; - cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; - cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; - double time =0; - const Acts::Vector4 postime(pos1.x(), pos1.y(), pos1.z(),time); - Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); + double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) + double p_z=p_yz*dir1.z()/sqrt(dir1.y()*dir1.y()+dir1.z()*dir1.z()); + double p_y=p_z*dir1.y()/dir1.z(); + double p_x=p_z*dir1.x()/dir1.z(); + + + const Acts::Vector3 mom(p_x, p_y, p_z); + double p = mom.norm(); + msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<st<<" "<<charge<<endmsg; + // build the track covariance matrix using the smearing sigmas + double sigmaU = 1000_um; + double sigmaV = 1000_um; + double sigmaPhi = 10_degree; + double sigmaTheta = 2_degree; + double sigmaQOverP = 0.20*p / (p*p); + //double sigmaQOverP = 0.02*p / (p*p); + double sigmaT0 = 1_ns; + Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; + cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; + cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; + cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; + cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; + cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; + double time =0; + const Acts::Vector4 postime(pos1.x(), pos1.y(), pos1.z(),time); + Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); return InitTrackParam; } - std::vector<Acts::CurvilinearTrackParameters> SPSimpleInitialParameterTool::getInitialParameters_1station(std::vector<Acts::Vector3> pos1, std::vector<Acts::Vector3> pos2, std::vector<Acts::Vector3> pos3) const { -std::vector<Acts::CurvilinearTrackParameters> InitTrackParams; -InitTrackParams.clear(); - -for(int i1=0;i1<pos1.size();i1++){ -for(int i2=0;i2<pos2.size();i2++){ -for(int i3=0;i3<pos3.size();i3++){ -Acts::Vector3 pstart=pos1[i1]; -Acts::Vector3 pend=(pos2[i2]+pos3[i3])/2.; -Acts::Vector3 dir=pend-pstart; - - double charge = 1; -// double B = 0.55; - - double p_yz = 100.; - //double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) - double p_z=p_yz*dir.y()/sqrt(dir.y()*dir.y()+dir.z()*dir.z()); - double p_y=p_z*dir.y()/dir.z(); - double p_x=p_z*dir.x()/dir.z(); - - - const Acts::Vector3 mom(p_x, p_y, p_z); - double p = mom.norm(); - msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<endmsg; - // build the track covariance matrix using the smearing sigmas - double sigmaU = 1000_um; - double sigmaV = 1000_um; - double sigmaPhi = 10_degree; - double sigmaTheta = 2_degree; - double sigmaQOverP = 0.20*p / (p*p); - //double sigmaQOverP = 0.02*p / (p*p); - double sigmaT0 = 1_ns; - Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); - cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; - cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; - cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; - cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; - cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; - cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; - double time =0; - const Acts::Vector4 postime(pstart.x(), pstart.y(), pstart.z(),time); - Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); - InitTrackParams.push_back(InitTrackParam); - } - } +std::vector<Acts::CurvilinearTrackParameters> SPSimpleInitialParameterTool::getInitialParameters_1station(std::vector<Acts::Vector3> pos1, std::vector<Acts::Vector3> pos2, std::vector<Acts::Vector3> pos3) const { + std::vector<Acts::CurvilinearTrackParameters> InitTrackParams; + InitTrackParams.clear(); + + for(std::size_t i1=0;i1<pos1.size();i1++){ + for(std::size_t i2=0;i2<pos2.size();i2++){ + for(std::size_t i3=0;i3<pos3.size();i3++){ + if(fabs(pos3[i3].y()-pos2[i2].y())>1.5*fabs(pos2[i2].y()-pos1[i1].y()))continue; + if(fabs(pos3[i3].x()-pos2[i2].x())>1.5*fabs(pos2[i2].x()-pos1[i1].x()))continue; + Acts::Vector3 pstart=pos1[i1]; + Acts::Vector3 pend=(pos2[i2]+pos3[i3])/2.; + Acts::Vector3 dir=pend-pstart; + + double charge = 1; + // double B = 0.55; + + double p_yz = 100.; + //double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) + double p_z=p_yz*dir.y()/sqrt(dir.y()*dir.y()+dir.z()*dir.z()); + if(p_z<0)continue; + double p_y=p_z*dir.y()/dir.z(); + double p_x=p_z*dir.x()/dir.z(); + + + const Acts::Vector3 mom(p_x, p_y, p_z); + double p = mom.norm(); + msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<endmsg; + // build the track covariance matrix using the smearing sigmas + double sigmaU = 2000_um; + double sigmaV = 2000_um; + double sigmaPhi = 30_degree; + double sigmaTheta = 10_degree; + double sigmaQOverP = 1.20*p / (p*p); + //double sigmaQOverP = 0.02*p / (p*p); + double sigmaT0 = 1_ns; + Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; + cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; + cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; + cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; + cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; + cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; + double time =0; + const Acts::Vector4 postime(pstart.x(), pstart.y(), pstart.z(),time); + Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); + InitTrackParams.push_back(InitTrackParam); + } } + } return InitTrackParams; } diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/TrajectoryWriterTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/TrajectoryWriterTool.cxx index 02a34d415bd33e8e7384b06a9ee4817c3f48c19b..f742348b0197db4f89a164acee6067aecf9dfe07 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/TrajectoryWriterTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/TrajectoryWriterTool.cxx @@ -244,7 +244,7 @@ void TrajectoryWriterTool::writeout(TrajectoriesContainer trajectories, Acts::MultiTrajectoryHelpers::trajectoryState(mj, trackTip); m_nMeasurements = trajState.nMeasurements; - if(m_nMeasurements<2)continue; +// if(m_nMeasurements<2)continue; m_nStates = trajState.nStates; m_nOutliers = trajState.nOutliers; m_nHoles = trajState.nHoles;