diff --git a/Tracker/TrackerDigitization/FaserSCT_Digitization/CMakeLists.txt b/Tracker/TrackerDigitization/FaserSCT_Digitization/CMakeLists.txt index 684a7222869a9020ae5b51ffcb3da9716fa4da18..a9bb50b87bec636f9888fb00faf8d416efcf66ea 100644 --- a/Tracker/TrackerDigitization/FaserSCT_Digitization/CMakeLists.txt +++ b/Tracker/TrackerDigitization/FaserSCT_Digitization/CMakeLists.txt @@ -38,7 +38,7 @@ find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) # Component(s) in the package: atlas_add_component( FaserSCT_Digitization - src/*.cxx + src/*.cxx src/*.h src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps AthenaKernel PileUpToolsLib Identifier xAODEventInfo GaudiKernel FaserSiDigitization TrackerRawData TrackerSimEvent HitManagement GeneratorObjects FaserSiPropertiesToolLib TrackerIdentifier TrackerReadoutGeometry TrackerSimData ) diff --git a/Tracker/TrackerDigitization/FaserSCT_Digitization/test/FaserSCT_DigitizationDbg.py b/Tracker/TrackerDigitization/FaserSCT_Digitization/test/FaserSCT_DigitizationDbg.py index 666ff440b1a45052fefc69c5417c9186610d9713..00b2e80da08fafa45891ff11d18d056ebf9e1710 100644 --- a/Tracker/TrackerDigitization/FaserSCT_Digitization/test/FaserSCT_DigitizationDbg.py +++ b/Tracker/TrackerDigitization/FaserSCT_Digitization/test/FaserSCT_DigitizationDbg.py @@ -49,12 +49,7 @@ acc.merge(FaserSCT_DigitizationCfg(ConfigFlags)) # Output Stream customization oStream = acc.getEventAlgo("OutputStreamRDO") -oStream.ItemList += ["EventInfo#*", - "McEventCollection#TruthEvent", - "McEventCollection#GEN_EVENT", - "ScintHitCollection#*", - "FaserSiHitCollection#SCT_Hits" - ] +oStream.TakeItemsFromInput = True # Timing #acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/CMakeLists.txt index e319b1fca11b9a0b3f57168dab9a5b77db98e94d..edcf1d74630492101f386e2645ae43baa3552cf8 100644 --- a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/CMakeLists.txt +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/CMakeLists.txt @@ -6,48 +6,20 @@ # Declare the package name: atlas_subdir( TrackerEventAthenaPool ) -# Declare the package's dependencies: -atlas_depends_on_subdirs( - PUBLIC - DetectorDescription/Identifier - Generators/GeneratorObjectsTPCnv - PRIVATE - AtlasTest/TestTools - Control/AthContainers - Control/AthenaBaseComps - Control/AthenaKernel - Control/SGTools - Control/StoreGate - Database/AthenaPOOL/AthenaPoolCnvSvc - Database/AthenaPOOL/AthenaPoolUtilities - Database/AtlasSealCLHEP - GaudiKernel -# Tracker/TrackerConditions/FaserSCT_ConditionsData - Tracker/TrackerDetDescr/TrackerIdentifier - Tracker/TrackerDetDescr/TrackerReadoutGeometry -# Tracker/TrackerEventCnv/TrackerEventTPCnv - Tracker/TrackerRawEvent/TrackerRawData - Tracker/TrackerRawEvent/TrackerSimData -# Tracker/TrackerRecEvent/TrackerPrepRawData -# Tracking/TrkEvent/TrkTrack - ) - # Component(s) in the package: atlas_add_poolcnv_library( TrackerEventAthenaPoolPoolCnv TrackerEventAthenaPool/*.h src/*.h src/*.cxx FILES TrackerRawData/FaserSCT_RDO_Container.h -# TrackerPrepRawData/FaserSCT_ClusterContainer.h -# src/InDetTrack.h + TrackerPrepRawData/FaserSCT_ClusterContainer.h TrackerSimData/TrackerSimDataCollection.h # FaserSCT_ConditionsData/FaserSCT_FlaggedCondData.h LINK_LIBRARIES Identifier GeneratorObjectsTPCnv AthAllocators AthContainers AthenaBaseComps AthenaKernel SGTools StoreGateLib AthenaPoolCnvSvcLib AthenaPoolUtilities AtlasSealCLHEP GaudiKernel TrackerIdentifier - TrackerReadoutGeometry -# TrackerEventTPCnv + TrackerReadoutGeometry TrackerEventTPCnv TrackerRawData TrackerSimData -# TrackerPrepRawData -# FaserSCT_ConditionsData TrkTrack + TrackerPrepRawData TrkTrack +# FaserSCT_ConditionsData ) atlas_add_dictionary( TrackerEventAthenaPoolCnvDict diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/TrackerEventAthenaPoolCnvDict.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/TrackerEventAthenaPoolCnvDict.h index 03cab952376cf4f4752b9d509d534767c4e63118..6796f7108a1ce19ddf4955d4aa3d6b4c3ec3c8f9 100644 --- a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/TrackerEventAthenaPoolCnvDict.h +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/TrackerEventAthenaPoolCnvDict.h @@ -22,7 +22,7 @@ // #include "TrackerEventAthenaPool/FaserSCT_RawDataContainer_p2.h" // #include "TrackerEventAthenaPool/FaserSCT_RawDataContainer_p3.h" #include "TrackerEventAthenaPool/FaserSCT_RawDataContainer_p4.h" -// #include "TrackerEventAthenaPool/SCT_FlaggedCondData_p1.h" +// #include "TrackerEventAthenaPool/FaserSCT_FlaggedCondData_p1.h" namespace TrackerEventAthenaPoolCnvDict { diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/selection.xml b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/selection.xml index 6fccd719e53bd74da4a9e37beee36999ef409182..5f0f878bdc821da27e1af0814241ea5021e7013a 100644 --- a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/selection.xml +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/selection.xml @@ -5,18 +5,13 @@ <class name="std::vector<std::pair<unsigned int, TrackerSimData_p2> >" /> <class pattern="std::*pair*<unsigned long long, TrackerSimData_p2>" /> <class name="std::vector<std::pair<unsigned long long, TrackerSimData_p2> >" /> - <!-- <class name="InDetSimDataCollection_p3" id="1430AA7B-EE92-5A41-92F3-5DD5367D6BAA" /> --> <class name="TrackerSimDataCollection_p3" id="E25FFB08-56F4-4594-B005-45200A725CD4" /> - <!-- <class name="TrackerRawData_p1" /> --> <class name="TrackerRawData_p2" /> <class name="FaserSCT3_RawData_p4" /> <class name="TrackerRawDataCollection_p1" /> - <!-- <class name="std::vector<TrackerRawData_p1>" /> --> <class name="std::vector<TrackerRawData_p2>" /> <class name="std::vector<FaserSCT3_RawData_p4>" /> - <!-- <class name="InDetRawDataContainer_p2" id="7138342E-0A80-4A32-A387-2842A01C2539" /> --> <class name="TrackerRawDataContainer_p2" id="41607916-86F6-45A3-B857-4DAFA0EF4518" /> - <!-- <class name="SCT_RawDataContainer_p4" id="6C7540BE-E85C-4777-BC1C-A9FF11460F54" /> --> <class name="FaserSCT_RawDataContainer_p4" id="45BE54C2-46EF-4B43-AF87-7F10B52F9487" /> <class name="std::vector<TrackerRawDataCollection_p1>" /> </lcgdict> diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterCnv_p3.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterCnv_p3.h new file mode 100644 index 0000000000000000000000000000000000000000..3fcd8893212d535dbd9cb29ba681872051ca2925 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterCnv_p3.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FaserSCT_CLUSTER_CNV_P3_H +#define FaserSCT_CLUSTER_CNV_P3_H + +//----------------------------------------------------------------------------- +// +// file: SCT_ClusterCnv_p3.h +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "FaserSCT_Cluster_p3.h" + +#include "FaserSiWidthCnv_p2.h" +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPositionCnv_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/ErrorMatrixCnv_p1.h" + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "TrackerIdentifier/FaserSCT_ID.h" + +class MsgStream; +//class SCT_ID; + +class FaserSCT_ClusterCnv_p3 + : public T_AthenaPoolTPPolyCnvBase< Tracker::TrackerCluster, Tracker::FaserSCT_Cluster, Tracker::FaserSCT_Cluster_p3> +{ +public: + FaserSCT_ClusterCnv_p3() {}; + FaserSCT_ClusterCnv_p3( const FaserSCT_ID * ); + + FaserSCT_Cluster + createFaserSCT_Cluster (const Tracker::FaserSCT_Cluster_p3* persObj, + Identifier clusId, + const TrackerDD::SiDetectorElement* detEl, + MsgStream& log); + + void persToTrans( const Tracker::FaserSCT_Cluster_p3 *, Tracker::FaserSCT_Cluster *, MsgStream & ); + void transToPers( const Tracker::FaserSCT_Cluster *, Tracker::FaserSCT_Cluster_p3 *, MsgStream & ); + +protected: + const FaserSCT_ID *m_sctId2; + Tracker::FaserSiWidthCnv_p2 m_swCnv; + LocalPositionCnv_p1 m_localPosCnv; + ErrorMatrixCnv_p1 m_errorMxCnv; +}; + +#endif // FaserSCT_CLUSTER_CNV_P3_H diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainerCnv_p0.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainerCnv_p0.h new file mode 100644 index 0000000000000000000000000000000000000000..33de41ebcdad49349b1442e4ad4162cfe6890128 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainerCnv_p0.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FaserSCT_CLUSTERCONTAINERCNV_P0_H +#define FaserSCT_CLUSTERCONTAINERCNV_P0_H + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "AthContainers/DataVector.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "StoreGate/ReadCondHandleKey.h" + +typedef DataVector<TrackerRawDataCollection<FaserSCT_Cluster> > FaserSCT_ClusterContainer_p0; + +class FaserSCT_ID; +class MsgStream; + +class FaserSCT_ClusterContainerCnv_p0 : public T_AthenaPoolTPCnvBase<FaserSCT_ClusterContainer, FaserSCT_ClusterContainer_p0> { + public: + FaserSCT_ClusterContainerCnv_p0(); + + // ID helper can't be used in the constructor, need initialize() + StatusCode initialize( MsgStream& log ); + + virtual void persToTrans(const FaserSCT_ClusterContainer_p0*, FaserSCT_ClusterContainer*, MsgStream&) override { + // everything is done in createTransient() + } + + virtual void transToPers(const FaserSCT_ClusterContainer*, FaserSCT_ClusterContainer_p0*, MsgStream&) override { + // throw std::runtime_error("Writing SCT PRDs in the old format is not supported"); + } + + virtual FaserSCT_ClusterContainer* createTransient(const FaserSCT_ClusterContainer_p0* /*persObj*/, MsgStream& /*log*/) override { + std::abort(); + } + + FaserSCT_ClusterContainer* createTransient(FaserSCT_ClusterContainer_p0* persObj, MsgStream& log); + + private: + const FaserSCT_ID* m_sctId; + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey; +}; + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainerCnv_p3.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainerCnv_p3.h new file mode 100644 index 0000000000000000000000000000000000000000..f3f8b02fa4c846b94c31837b2264371a72c65bb1 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainerCnv_p3.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FaserSCT_CLUSTERCONTAINERCNV_P3_H +#define FaserSCT_CLUSTERCONTAINERCNV_P3_H + + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerEventAthenaPool/FaserSCT_ClusterContainer_p3.h" + +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "StoreGate/ReadCondHandleKey.h" + +class FaserSCT_ID; +class StoreGateSvc; + +class FaserSCT_ClusterContainerCnv_p3 : public T_AthenaPoolTPCnvBase<FaserSCT_ClusterContainer, FaserSCT_ClusterContainer_p3> +{ + public: + FaserSCT_ClusterContainerCnv_p3() : m_sctId{nullptr}, m_storeGate{nullptr}, m_SCTDetEleCollKey{"SCT_DetectorElementCollection"}, m_useDetectorElement{true}, m_isInitialized{false} {}; + + virtual void transToPers(const FaserSCT_ClusterContainer* transCont, + FaserSCT_ClusterContainer_p3* persCont, + MsgStream &log) ; + virtual void persToTrans(const FaserSCT_ClusterContainer_p3* persCont, + FaserSCT_ClusterContainer* transCont, + MsgStream &log) ; + + virtual FaserSCT_ClusterContainer* createTransient(const FaserSCT_ClusterContainer_p3* persObj, MsgStream& log); + + // Methods for test/FaserSCT_ClusterContainerCnv_p3_test.cxx + void setIdHelper(const FaserSCT_ID* sct_id); + void setUseDetectorElement(const bool useDetectorElement); + StatusCode initialize(MsgStream &log); + + private: + const FaserSCT_ID *m_sctId; + StoreGateSvc *m_storeGate; + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey; + bool m_useDetectorElement; + bool m_isInitialized; + +}; + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainer_p3.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainer_p3.h new file mode 100644 index 0000000000000000000000000000000000000000..650ddb8afdc7ed2ccf59bd36e68e36fbd1912e77 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainer_p3.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FaserSCT_CLUSTERCONTAINER_P3_H +#define FaserSCT_CLUSTERCONTAINER_P3_H + +/* + +Author: Davide Costanzo + +*/ + +#include <vector> +#include <string> +#include "TrackerEventAthenaPool/FaserSCT_Cluster_p3.h" +#include "TrackerEventAthenaPool/TrackerPRD_Collection_p2.h" +#include "TrackerEventAthenaPool/TrackerRawDataCollection_p1.h" +#include "Identifier/Identifier.h" + + +class FaserSCT_ClusterContainer_p3 +{ + public: +/// Default constructor + FaserSCT_ClusterContainer_p3 (); + //private: +// std::vector<TrackerRawDataCollection_p1> m_collections; + std::vector<TrackerPRD_Collection_p2> m_collections; + std::vector<FaserSCT_Cluster_p3> m_rawdata; +// The delta identifiers of the PRD: + //std::vector<unsigned short> m_prdDeltaId; + std::vector<Identifier::diff_type> m_prdDeltaId; +}; + + +// inlines + +inline +FaserSCT_ClusterContainer_p3::FaserSCT_ClusterContainer_p3 () {} + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainer_tlp1.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainer_tlp1.h new file mode 100644 index 0000000000000000000000000000000000000000..22696af83f7b840ef94bb302111f9c4f561849e8 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_ClusterContainer_tlp1.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FaserSCT_CLUSTERCONTAINER_TLP1_H +#define FaserSCT_CLUSTERCONTAINER_TLP1_H + + + + +//----------------------------------------------------------------------------- +// InDetPrepRawData +//----------------------------------------------------------------------------- +#include "TrackerEventAthenaPool/TrackerPRD_Container_p1.h" +#include "TrackerEventAthenaPool/FaserSCT_Cluster_p3.h" +//#include "TrackerEventAthenaPool/TrackerCluster_p1.h" +#include "TrackerEventAthenaPool/FaserSiWidth_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/HepSymMatrix_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPosition_p1.h" + + +// Token +#include "AthenaPoolUtilities/TPCnvTokenList_p1.h" + + class FaserSCT_ClusterContainer_tlp1 + { + public: + FaserSCT_ClusterContainer_tlp1() {} + TPCnvTokenList_p1 m_tokenList; + +// This is the basic info + std::vector< TrackerPRD_Container_p1> m_sctDCCont; + std::vector< FaserSCT_Cluster_p3 > m_sctClusters; +// This are the base classes +// std::vector< TrackerCluster_p1 > m_siClusters; + std::vector< FaserSiWidth_p1 > m_siWidths; +// This is info held by the base class + std::vector< Trk::LocalPosition_p1> m_locPos; + std::vector< Trk::HepSymMatrix_p1> m_errorMat; + + }; + + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_Cluster_p3.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_Cluster_p3.h new file mode 100644 index 0000000000000000000000000000000000000000..9df4f53aec90375bcbb8f53a92e8fc30e04eac44 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSCT_Cluster_p3.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + */ + +#ifndef FaserSCT_CLUSTER_P3_TRK_H +#define FaserSCT_CLUSTER_P3_TRK_H + +//----------------------------------------------------------------------------- +// +// file: FaserSCT_Cluster_p3.h +// +//----------------------------------------------------------------------------- +#include "FaserSiWidth_p2.h" + +class FaserSCT_Cluster_p3 +{ + public: + + // type used for channel id differences + typedef short rdo_diff_type; + + FaserSCT_Cluster_p3(): m_localPos{0.}, m_mat00{0.}, m_mat01{0.}, m_mat11{0.}, m_hitsInThirdTimeBin{0} {} + + // replace this: + std::vector<rdo_diff_type > m_rdoList; + float m_localPos; + float m_mat00; + float m_mat01; + float m_mat11; + uint16_t m_hitsInThirdTimeBin; + + //SiWidth_p2 + FaserSiWidth_p2 m_width; + +}; + +#endif // SCT_CLUSTER_P3_TRK_H diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidthCnv_p1.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidthCnv_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..0d59dd5f7b6cc40680957c56c1708567715076c7 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidthCnv_p1.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSI_WIDTH_CNV_P1_H +#define FASERSI_WIDTH_CNV_P1_H + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidthCnv_p1.h +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "TrackerEventAthenaPool/FaserSiWidth_p1.h" + +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPositionCnv_p1.h" + +class MsgStream; + +class FaserSiWidthCnv_p1 + : public T_AthenaPoolTPCnvBase<FaserSiWidth, FaserSiWidth_p1> +{ +public: + FaserSiWidthCnv_p1() : m_localPosCnv(0) {} + + void persToTrans( const FaserSiWidth_p1 *, FaserSiWidth *, MsgStream & ); + void transToPers( const FaserSiWidth *, FaserSiWidth_p1 *, MsgStream & ); + +private: + LocalPositionCnv_p1 *m_localPosCnv; + +}; + +#endif // FaserSI_WIDTH_CNV_P1_H diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidthCnv_p2.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidthCnv_p2.h new file mode 100644 index 0000000000000000000000000000000000000000..ac0aa8ead373223d7375d7e0ebd40a6eb7852d9a --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidthCnv_p2.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERRSI_WIDTH_CNV_P2_H +#define FASERRSI_WIDTH_CNV_P2_H + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidthCnv_p2.h +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "TrackerEventAthenaPool/FaserSiWidth_p2.h" + +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPositionCnv_p1.h" + +class MsgStream; + + + class FaserSiWidthCnv_p2 + : public T_AthenaPoolTPCnvBase<FaserSiWidth, FaserSiWidth_p2> + { + public: + FaserSiWidthCnv_p2() {} + + void persToTrans( const FaserSiWidth_p2 *, FaserSiWidth *, MsgStream & ); + void transToPers( const FaserSiWidth *, FaserSiWidth_p2 *, MsgStream & ); + + private: + LocalPositionCnv_p1 m_localPosCnv; + + }; +#endif // SI_WIDTH_CNV_P1_H diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidth_p1.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidth_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..083bce3660e4a17d8b5bff7939c970fd4762535a --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidth_p1.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSI_WIDTH_P1_TRK_H +#define FASERSI_WIDTH_P1_TRK_H + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidth_p1.h +// +//----------------------------------------------------------------------------- +#include "AthenaPoolUtilities/TPObjRef.h" + + + class FaserSiWidth_p1 + { + public: + FaserSiWidth_p1() {} + + float x{}; + float y{}; + // Trk::LocalPosition_p1 * + TPObjRef m_phirzWidth; + }; +#endif // SI_WIDTH_TRK_H diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidth_p2.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidth_p2.h new file mode 100644 index 0000000000000000000000000000000000000000..4ebf2ae216d67b7f9c58c614c9d80d5afe714af2 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/FaserSiWidth_p2.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FaserSI_WIDTH_P2_TRK_H +#define FaserSI_WIDTH_P2_TRK_H + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidth_p2.h +// +//----------------------------------------------------------------------------- +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPosition_p1.h" + + + +class FaserSiWidthCnv_p2; + +class FaserSiWidth_p2 + { + public: + FaserSiWidth_p2() {}; + friend class FaserSiWidthCnv_p2; + private: + unsigned int m_size{}; + Trk::LocalPosition_p1 m_phirzWidth; + }; + +#endif // SI_WIDTH_TRK_H diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/TrackerPRD_Collection_p2.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/TrackerPRD_Collection_p2.h new file mode 100644 index 0000000000000000000000000000000000000000..d0768f5c50788382940ac1b86010f2d7ad72b239 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/TrackerPRD_Collection_p2.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERPRD_COLLECTION_P2_H +#define TRACKERPRD_COLLECTION_P2_H + +#include <vector> +class TrackerPRD_Collection_p2 +{ + + +public: + + TrackerPRD_Collection_p2() + : + // m_idDelta(0), + m_hashId(0), + m_size(0) + { } ; + + // container cnvs do conversions + friend class FaserSCT_ClusterContainerCnv_p3; + + //private: + + // Identifier distance of this collection from the previous one + // unsigned short m_idDelta; + + // Hash Identifier of this collection + // (write this one as well, so we don't rely on the IdHelper for it) + unsigned short m_hashId; + + // Collection size into master collection + // Note I use a short. If a collection has more than 2^16 elements (unlikely) it + // has to be split into two separate collections + unsigned short m_size; + +}; + +#endif + + diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/TrackerPRD_Container_p1.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/TrackerPRD_Container_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..e0b0109b02191fbeb5ac0a7c57e280ee1e8264f9 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/TrackerEventAthenaPool/temp/TrackerPRD_Container_p1.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERPRD_CONTAINER_P1_H +#define TRACKERPRD_CONTAINER_P1_H 1 + +#include <vector> +#include <string> +#include "TrackerEventAthenaPool/TrackerPRD_Collection_p2.h" +#include "AthenaPoolUtilities/TPObjRef.h" + +class TrackerPRD_Container_p1 +{ + public: +/// Default constructor + TrackerPRD_Container_p1 (); + //private: + std::vector<TrackerPRD_Collection_p2> m_collections; + std::vector<TPObjRef> m_PRD; +}; + + +// inlines + +inline TrackerPRD_Container_p1::TrackerPRD_Container_p1() {} + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e921e499028929d04b04876df57058550359d51b --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv.cxx @@ -0,0 +1,110 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "FaserSCT_ClusterContainerCnv.h" + +#include "MsgUtil.h" + +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "StoreGate/StoreGateSvc.h" + +#include <iostream> +#include <memory> + +FaserSCT_ClusterContainerCnv::FaserSCT_ClusterContainerCnv (ISvcLocator* svcloc) + : FaserSCT_ClusterContainerCnvBase(svcloc, "FaserSCT_ClusterContainerCnv"), + m_converter_p0(), + m_storeGate(nullptr) + {} + + +StatusCode FaserSCT_ClusterContainerCnv::initialize() { + ATH_MSG_INFO("FaserSCT_ClusterContainerCnv::initialize()"); + + StatusCode sc = FaserSCT_ClusterContainerCnvBase::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."); + } + + if (m_converter_p0.initialize(msg()).isFailure()) + { + ATH_MSG_FATAL("Could not initialize converter!"); + return StatusCode::FAILURE; + } + + ATH_MSG_DEBUG("Converter initialized"); + + return StatusCode::SUCCESS; +} + + +Tracker::FaserSCT_ClusterContainer* FaserSCT_ClusterContainerCnv::createTransient() { + // MsgStream log(msgSvc(), "SCT_ClusterContainerCnv" ); +// static const pool::Guid p0_guid("586ED4E3-FA8F-4A9D-A919-9D42221975B8"); // before t/p split (was: A180F372-0D52-49C3-8AA0-0939CB0B8179) + static const pool::Guid p1_guid("5EF374F6-EA93-4739-9ECE-FBBA9C928818"); // with SCT_Cluster_tlp1 (was: 657F6546-F5CD-4166-9567-16AD9C96D286) +// static const pool::Guid p2_guid("ECE7D831-0F31-4E6F-A6BE-2ADDE90083BA"); // with SCT_Cluster_p2 + static const pool::Guid p3_guid("42921F1E-8D65-4DBF-B309-6510794E05E0"); // with SCT_Cluster_p3 (was: 623F5836-369F-4A94-9DD4-DAD728E93C13) + + //ATH_MSG_DEBUG("createTransient(): main converter"); + Tracker::FaserSCT_ClusterContainer* p_collection(nullptr); + if ( compareClassGuid(p3_guid) ) { + //ATH_MSG_DEBUG("createTransient(): T/P version 3 detected"); + std::unique_ptr< FaserSCT_ClusterContainer_PERS > p_coll( poolReadObject< FaserSCT_ClusterContainer_PERS >() ); + p_collection = m_TPConverter_p3.createTransient( p_coll.get(), msg() ); + + } else if ( compareClassGuid(p1_guid) ) { + //ATH_MSG_DEBUG("createTransient(): T/P version 1 detected"); + std::unique_ptr< Tracker::FaserSCT_ClusterContainer_tlp1 > p_coll( poolReadObject< Tracker::FaserSCT_ClusterContainer_tlp1 >() ); + p_collection = m_TPConverter.createTransient( p_coll.get(), msg() ); + +// } else if ( compareClassGuid(p2_guid) ) { +// //ATH_MSG_DEBUG("createTransient(): T/P version 2 detected"); +// std::unique_ptr< InDet::SCT_ClusterContainer_p2 > p_coll( poolReadObject< InDet::SCT_ClusterContainer_p2 >() ); +// p_collection = m_TPConverter_p2.createTransient( p_coll.get(), msg() ); + +// } else if ( compareClassGuid(p0_guid) ) { +// //ATH_MSG_DEBUG("createTransient(): Old input file"); +// std::unique_ptr< FaserSCT_ClusterContainer_p0 > col_vect( poolReadObject< FaserSCT_ClusterContainer_p0 >() ); +// p_collection = m_converter_p0.createTransient( col_vect.get(), msg() ); + + } else { + throw std::runtime_error("Unsupported persistent version of FaserSCT_ClusterContainer"); + + } + return p_collection; +} + + +FaserSCT_ClusterContainer_PERS* FaserSCT_ClusterContainerCnv::createPersistent (Tracker::FaserSCT_ClusterContainer* transCont) { + FaserSCT_ClusterContainer_PERS* sctdc_p= m_TPConverter_p3.createPersistent( transCont, msg() ); + return sctdc_p; +} diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..d5b65d5fbab07242dbe549bfc0705b80b9c49440 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTERCONTAINERCNV_H +#define FASERSCT_CLUSTERCONTAINERCNV_H + +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + + +class StoreGateSvc; +class SCT_ID; + +#include "FaserSCT_ClusterContainerCnv_p0.h" +#include "TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_tlp1.h" +#include "TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_p3.h" +// #include "TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_p2.h" + + +// the latest persistent representation type of DataCollection: +typedef Tracker::FaserSCT_ClusterContainer_p3 FaserSCT_ClusterContainer_PERS; +typedef T_AthenaPoolCustomCnv<Tracker::FaserSCT_ClusterContainer, FaserSCT_ClusterContainer_PERS > FaserSCT_ClusterContainerCnvBase; + +/** +** Create derived converter to customize the saving of identifiable +** container +**/ +class FaserSCT_ClusterContainerCnv : public FaserSCT_ClusterContainerCnvBase +{ + friend class CnvFactory<FaserSCT_ClusterContainerCnv >; + + // Converters need to be initialized (use ID helpers) + // Thus they can't be local + FaserSCT_ClusterContainerCnv_p0 m_converter_p0; + FaserSCT_ClusterContainerCnv_tlp1 m_TPConverter; + FaserSCT_ClusterContainerCnv_p3 m_TPConverter_p3; +// SCT_ClusterContainerCnv_p2 m_TPConverter_p2; + + // Should not be needed at some point. + StoreGateSvc* m_storeGate; + +protected: +public: + FaserSCT_ClusterContainerCnv (ISvcLocator* svcloc); +protected: + virtual FaserSCT_ClusterContainer_PERS* createPersistent (Tracker::FaserSCT_ClusterContainer* transCont); + virtual Tracker::FaserSCT_ClusterContainer* createTransient (); + + // Must initialize ID helpers + virtual StatusCode initialize(); + virtual AthenaPoolTopLevelTPCnvBase* getTopLevelTPCnv() { return &m_TPConverter; } +}; + + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv_p0.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv_p0.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d7eaf9b4cdb97fdeefb277571ef2be452b918d20 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv_p0.cxx @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "FaserSCT_ClusterContainerCnv_p0.h" + +#include "MsgUtil.h" + +// Athena +#include "AthenaKernel/errorcheck.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "StoreGate/ReadCondHandle.h" +#include "StoreGate/StoreGateSvc.h" + +// Gaudi +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/Service.h" +#include "GaudiKernel/StatusCode.h" + +#include <iostream> +#include <sstream> +#include <string> + +//================================================================ + + +FaserSCT_ClusterContainerCnv_p0::FaserSCT_ClusterContainerCnv_p0(): + m_sctId{nullptr}, + m_SCTDetEleCollKey{"SCT_DetectorElementCollection"} +{ +} + +StatusCode FaserSCT_ClusterContainerCnv_p0::initialize(MsgStream& log ) { + + ISvcLocator* svcLocator = Gaudi::svcLocator(); + + // Get the messaging service, print where you are + log << MSG::INFO << "FaserSCT_ClusterContainerCnv::initialize()" << endmsg; + + StoreGateSvc* detStore = nullptr; + CHECK( svcLocator->service("DetectorStore", detStore) ); + CHECK( detStore->retrieve(m_sctId, "FaserSCT_ID") ); + CHECK( m_SCTDetEleCollKey.initialize() ); + MSG_DEBUG(log,"Converter initialized."); + + return StatusCode::SUCCESS; +} + +Tracker::FaserSCT_ClusterContainer* FaserSCT_ClusterContainerCnv_p0::createTransient(FaserSCT_ClusterContainer_p0* persObj, MsgStream& log) { + + std::unique_ptr<Tracker::FaserSCT_ClusterContainer> trans(std::make_unique<Tracker::FaserSCT_ClusterContainer>(m_sctId->wafer_hash_max()) ); + // MSG_DEBUG(log,"Read PRD vector, size " << persObj->size()); + + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEleHandle(m_SCTDetEleCollKey); + const TrackerDD::SiDetectorElementCollection* elements(*sctDetEleHandle); + if (not sctDetEleHandle.isValid() or elements==nullptr) { + log << MSG::FATAL << m_SCTDetEleCollKey.fullKey() << " is not available." << endmsg; + return trans.release(); + } + + for (Tracker::FaserSCT_ClusterCollection* dcColl : *persObj) { + // Add detElem to each drift circle + IdentifierHash collHash = dcColl->identifyHash(); + const TrackerDD::SiDetectorElement * de = elements->getDetectorElement(collHash); + // MSG_DEBUG(log,"Set SCT_Cluster detector element to "<< de); + + Tracker::FaserSCT_ClusterCollection::iterator itColl = dcColl->begin(); + Tracker::FaserSCT_ClusterCollection::iterator lastColl = dcColl->end(); + for (; itColl != lastColl; ++itColl) { + (*itColl)->m_detEl = de; + } + + StatusCode sc= trans->addCollection(dcColl, collHash); + if (sc.isSuccess()){ + // MSG_VERBOSE("SCT_ClusterContainer successfully added to Container !"); + } else { + log << MSG::ERROR << "Failed to add FaserSCT_ClusterContainer to container" << endmsg; + return nullptr; + } + } + return trans.release(); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv_p0.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv_p0.h new file mode 100644 index 0000000000000000000000000000000000000000..737585f41e1485901f6c9b5dd7e91746f2b01ce6 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_ClusterContainerCnv_p0.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTERCONTAINERCNV_P0_H +#define FASERSCT_CLUSTERCONTAINERCNV_P0_H + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "AthContainers/DataVector.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "StoreGate/ReadCondHandleKey.h" + +typedef DataVector<Trk::PrepRawDataCollection<Tracker::FaserSCT_Cluster> > FaserSCT_ClusterContainer_p0; + +class FaserSCT_ID; +class MsgStream; + +class FaserSCT_ClusterContainerCnv_p0 : public T_AthenaPoolTPCnvBase<Tracker::FaserSCT_ClusterContainer, FaserSCT_ClusterContainer_p0> { + public: + FaserSCT_ClusterContainerCnv_p0(); + + // ID helper can't be used in the constructor, need initialize() + StatusCode initialize( MsgStream& log ); + + virtual void persToTrans(const FaserSCT_ClusterContainer_p0*, Tracker::FaserSCT_ClusterContainer*, MsgStream&) override { + // everything is done in createTransient() + } + + virtual void transToPers(const Tracker::FaserSCT_ClusterContainer*, FaserSCT_ClusterContainer_p0*, MsgStream&) override { + throw std::runtime_error("Writing SCT PRDs in the old format is not supported"); + } + + virtual Tracker::FaserSCT_ClusterContainer* createTransient(const FaserSCT_ClusterContainer_p0* /*persObj*/, MsgStream& /*log*/) override { + std::abort(); + } + + Tracker::FaserSCT_ClusterContainer* createTransient(FaserSCT_ClusterContainer_p0* persObj, MsgStream& log); + + private: + const FaserSCT_ID* m_sctId; + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey; +}; + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterCnv_p3.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterCnv_p3.cxx new file mode 100644 index 0000000000000000000000000000000000000000..42ef7bbff3a1f4384c2636f3f9ae617499dc18d0 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterCnv_p3.cxx @@ -0,0 +1,117 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +//----------------------------------------------------------------------------- +// +// file: FaserSCT_ClusterCnv_p3.cxx +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSCT_Cluster.h" + +#include "EventPrimitives/EventPrimitives.h" + +#include "TrackerEventAthenaPool/FaserSCT_ClusterCnv_p3.h" + +#include <memory> + +FaserSCT_ClusterCnv_p3::FaserSCT_ClusterCnv_p3(const FaserSCT_ID * sctid ) + : + m_sctId2(sctid) +{} + + +FaserSCT_Cluster +FaserSCT_ClusterCnv_p3::createFaserSCT_Cluster (const FaserSCT_Cluster_p3* persObj, + Identifier clusId, + const TrackerDD::SiDetectorElement* detEl, + MsgStream& log) +{ + // Local Position + Amg::Vector2D localPos; + localPos[Trk::locX] = persObj->m_localPos; + localPos[Trk::locY] = 0; + + // List of Id of the cluster + std::vector<Identifier> rdoList; + rdoList.resize( persObj->m_rdoList.size() ); + //Identifier::value_type id32 = transObj->identify().get_compact(); + //Identifier id32 = transObj->identify(); + std::vector<Identifier>::iterator tit = rdoList.begin(); + for (std::vector<FaserSCT_Cluster_p3::rdo_diff_type>::const_iterator it=persObj->m_rdoList.begin(); it != persObj->m_rdoList.end(); it++) { + + *tit = Identifier(m_sctId2->strip_id_offset(clusId,*it) ); + tit++; + } + + FaserSiWidth sw; + m_swCnv.persToTrans(&persObj->m_width, &sw, log); + + // Error matrix + auto cmat = std::make_unique<Amg::MatrixX>(2,2); + (*cmat)(0,0) = static_cast<double>(persObj->m_mat00); + (*cmat)(1,0) = static_cast<double>(persObj->m_mat01); + (*cmat)(0,1) = static_cast<double>(persObj->m_mat01); + (*cmat)(1,1) = static_cast<double>(persObj->m_mat11); + + FaserSCT_Cluster clus (clusId, + localPos, + std::move(rdoList), + sw, + detEl, + std::move(cmat)); + clus.setHitsInThirdTimeBin( persObj->m_hitsInThirdTimeBin ) ; + return clus; +} + + +void FaserSCT_ClusterCnv_p3:: +persToTrans( const FaserSCT_Cluster_p3 *persObj, FaserSCT_Cluster *transObj, MsgStream &log) +{ + Identifier clusId = transObj->identify(); + *transObj = createFaserSCT_Cluster (persObj, clusId, nullptr, log); +} + + +void FaserSCT_ClusterCnv_p3::transToPers( const FaserSCT_Cluster *transObj, FaserSCT_Cluster_p3 *persObj, MsgStream &log ) +{ +// if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "In FaserSCT_Cluster::transToPers" << endmsg; + const FaserSiWidth *sw = &transObj->width(); + m_swCnv.transToPers(sw, &persObj->m_width, log); + + // base class: + // + + // Local Position + persObj->m_localPos = transObj->localPosition()[Trk::locX]; + + // cluster weight + persObj->m_hitsInThirdTimeBin = transObj->hitsInThirdTimeBin(); + + + // Error Matrix + persObj->m_mat00 = (transObj->localCovariance())(0,0); + persObj->m_mat01 = (transObj->localCovariance())(0,1); + persObj->m_mat11 = (transObj->localCovariance())(1,1); + + // List of Id of the cluster + persObj->m_rdoList.resize( transObj->rdoList().size() ); + //Identifier::value_type id32 = transObj->identify().get_compact(); + Identifier id32 = transObj->identify(); + + + // convert the list of ID saved for the cluster + persObj->m_rdoList.resize(transObj->rdoList().size() ); + std::vector<FaserSCT_Cluster_p3::rdo_diff_type>::iterator pit = persObj->m_rdoList.begin(); + + + for (std::vector<Identifier>::const_iterator it=transObj->rdoList().begin(); it != transObj->rdoList().end(); it++) { + + *pit = static_cast<FaserSCT_Cluster_p3::rdo_diff_type>( m_sctId2->calc_offset(id32, *it) ); + pit++; + } + +} + + diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6873b68b8a2d18247c7e050f7b41d877ac3c045d --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv.cxx @@ -0,0 +1,92 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "FaserSCT_ClusterContainerCnv.h" + +#include "MsgUtil.h" + +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "StoreGate/StoreGateSvc.h" + +#include <iostream> +#include <memory> + + FaserSCT_ClusterContainerCnv::FaserSCT_ClusterContainerCnv (ISvcLocator* svcloc) + : SCT_ClusterContainerCnvBase(svcloc, "FaserSCT_ClusterContainerCnv"), + m_converter_p3(), + m_storeGate(nullptr) + {} + + +StatusCode FaserSCT_ClusterContainerCnv::initialize() { + ATH_MSG_INFO("FaserSCT_ClusterContainerCnv::initialize()"); + + StatusCode sc = SCT_ClusterContainerCnvBase::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."); + } + + if (m_converter_p3.initialize(msg()).isFailure()) + { + ATH_MSG_FATAL("Could not initialize converter!"); + return StatusCode::FAILURE; + } + + ATH_MSG_DEBUG("Converter initialized"); + + return StatusCode::SUCCESS; +} + + +FaserSCT_ClusterContainer* FaserSCT_ClusterContainerCnv::createTransient() { + // MsgStream log(msgSvc(), "FaserSCT_ClusterContainerCnv" ); + static const pool::Guid p3_guid("84C2A724-5B0C-417A-BFE2-0A59CE66f17D"); // before t/p split + + //ATH_MSG_DEBUG("createTransient(): main converter"); + FaserSCT_ClusterContainer* p_collection(nullptr); + if ( compareClassGuid(p3_guid) ) { + //ATH_MSG_DEBUG("createTransient(): T/P version 3 detected"); + std::unique_ptr< SCT_ClusterContainer_PERS > p_coll( poolReadObject< SCT_ClusterContainer_PERS >() ); + p_collection = m_converter_p3.createTransient( p_coll.get(), msg() ); + + } else { + throw std::runtime_error("Unsupported persistent version of SCT_ClusterContainer"); + + } + return p_collection; +} + + +SCT_ClusterContainer_PERS* FaserSCT_ClusterContainerCnv::createPersistent (FaserSCT_ClusterContainer* transCont) { + SCT_ClusterContainer_PERS* sctdc_p;//= m_converter_p3.createPersistent( transCont, msg() ); + return sctdc_p; +} diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..32ebd0ee1336ba511ab4b60faea5eac3588fb60a --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTERCONTAINERCNV_H +#define FASERSCT_CLUSTERCONTAINERCNV_H + +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + + + +class StoreGateSvc; +class FaserSCT_ID; + +#include "TrackerEventAthenaPool/FaserSCT_ClusterContainerCnv_p0.h" +#include "TrackerEventAthenaPool/FaserSCT_ClusterContainerCnv_p3.h" +#include "FaserSCT_ClusterContainerCnv_tlp1.h" + + +// the latest persistent representation type of DataCollection: +typedef FaserSCT_ClusterContainer_p3 SCT_ClusterContainer_PERS; +typedef T_AthenaPoolCustomCnv<FaserSCT_ClusterContainer, SCT_ClusterContainer_PERS > SCT_ClusterContainerCnvBase; + +/** +** Create derived converter to customize the saving of identifiable +** container +**/ +class FaserSCT_ClusterContainerCnv : public SCT_ClusterContainerCnvBase +{ + friend class CnvFactory<FaserSCT_ClusterContainerCnv >; + + // Converters need to be initialized (use ID helpers) + // Thus they can't be local + FaserSCT_ClusterContainerCnv_p3 m_converter_p3; +// FaserSCT_ClusterContainerCnv_tlp1 m_TPConverter_p3; + + // Should not be needed at some point. + StoreGateSvc* m_storeGate; + +protected: +public: + FaserSCT_ClusterContainerCnv (ISvcLocator* svcloc); +protected: + virtual SCT_ClusterContainer_PERS* createPersistent (FaserSCT_ClusterContainer* transCont); + virtual FaserSCT_ClusterContainer* createTransient (); + + // Must initialize ID helpers + virtual StatusCode initialize(); + // virtual AthenaPoolTopLevelTPCnvBase* getTopLevelTPCnv() { return &m_TPConverter_p3; } +}; + + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_p0.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_p0.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2d0ea324246a8cfc9ab62e3df84fdda6f8b387fc --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_p0.cxx @@ -0,0 +1,106 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrackerEventAthenaPool/FaserSCT_ClusterContainerCnv_p0.h" + +#include "MsgUtil.h" + +// Athena +#include "AthenaKernel/errorcheck.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "StoreGate/ReadCondHandle.h" +#include "StoreGate/StoreGateSvc.h" + +// Gaudi +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/Service.h" +#include "GaudiKernel/StatusCode.h" + +#include <iostream> +#include <sstream> +#include <string> + +//================================================================ + + +FaserSCT_ClusterContainerCnv_p0::FaserSCT_ClusterContainerCnv_p0(): + m_sctId{nullptr}, + m_SCTDetEleCollKey{"SCT_DetectorElementCollection"} +{ +} + +StatusCode FaserSCT_ClusterContainerCnv_p0::initialize(MsgStream& log ) { + + ISvcLocator* svcLocator = Gaudi::svcLocator(); + + // Get the messaging service, print where you are + log << MSG::INFO << "FaserSCT_ClusterContainerCnv::initialize()" << endmsg; + + StoreGateSvc* detStore = nullptr; + CHECK( svcLocator->service("DetectorStore", detStore) ); + CHECK( detStore->retrieve(m_sctId, "FaserSCT_ID") ); + CHECK( m_SCTDetEleCollKey.initialize() ); + MSG_DEBUG(log,"Converter initialized."); + + return StatusCode::SUCCESS; +} + +FaserSCT_ClusterContainer* FaserSCT_ClusterContainerCnv_p0::createTransient(FaserSCT_ClusterContainer_p0* persObj, MsgStream& log) { + + std::unique_ptr<FaserSCT_ClusterContainer> trans(std::make_unique<FaserSCT_ClusterContainer>(m_sctId->wafer_hash_max()) ); + // MSG_DEBUG(log,"Read PRD vector, size " << persObj->size()); + + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEleHandle(m_SCTDetEleCollKey); + const TrackerDD::SiDetectorElementCollection* elements(*sctDetEleHandle); + if (not sctDetEleHandle.isValid() or elements==nullptr) { + log << MSG::FATAL << m_SCTDetEleCollKey.fullKey() << " is not available." << endmsg; + return trans.release(); + } + FaserSCT_ClusterContainer_p0::const_iterator it = persObj->begin(); + FaserSCT_ClusterContainer_p0::const_iterator last = persObj->end(); + + for (; it != last; ++it) { + + // Old persistent format used collection templated on the specific raw data type + const TrackerRawDataCollection<FaserSCT_Cluster>* rdoCollOld = *it; + + if (rdoCollOld==nullptr) { + throw std::runtime_error("Got NULL collection reading old format FaserSCT_ClusterContainer"); + } + + // Ugly cast... The new format does not need it in its converters. + const TrackerRawDataCollection<FaserSCT_Cluster>* rdoColl = reinterpret_cast<const TrackerRawDataCollection<FaserSCT_Cluster> *>(rdoCollOld); + + // Add to the container + if (trans->addCollection( rdoColl, rdoColl->identifyHash() ).isFailure()) { + log << MSG::FATAL << "[p0] SCT RDOs could not be added to the container!" << endmsg; + throw std::runtime_error("FaserSCT_RDO_ContainerCnv_p0::createTransient(): SCT RDOs could not be added to the container!"); + } + } + + +// for (FaserSCT_ClusterCollection* dcColl : *persObj) { +// // Add detElem to each drift circle +// IdentifierHash collHash = dcColl->identifyHash(); +// const TrackerDD::SiDetectorElement * de = elements->getDetectorElement(collHash); +// // MSG_DEBUG(log,"Set SCT_Cluster detector element to "<< de); +// +// FaserSCT_ClusterCollection::iterator itColl = dcColl->begin(); +// FaserSCT_ClusterCollection::iterator lastColl = dcColl->end(); +// for (; itColl != lastColl; ++itColl) { +// (*itColl)->m_detEl = de; +// } +// +// StatusCode sc= trans->addCollection(dcColl, collHash); +// if (sc.isSuccess()){ +// // MSG_VERBOSE("SCT_ClusterContainer successfully added to Container !"); +// } else { +// log << MSG::ERROR << "Failed to add SCT_ClusterContainer to container" << endmsg; +// return nullptr; +// } +// } + return trans.release(); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_p3.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_p3.cxx new file mode 100644 index 0000000000000000000000000000000000000000..25d60a6ca9d03226846184efe938c5bb54d8050b --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_p3.cxx @@ -0,0 +1,251 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ + +#include "TrackerEventAthenaPool/FaserSCT_ClusterContainerCnv_p3.h" + +// Athena +#include "AthenaKernel/errorcheck.h" +#include "Identifier/Identifier.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerEventAthenaPool/TrackerPRD_Collection_p2.h" +#include "TrackerEventAthenaPool/FaserSCT_Cluster_p3.h" +#include "TrackerEventAthenaPool/FaserSCT_ClusterCnv_p3.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "StoreGate/ReadCondHandle.h" +#include "StoreGate/StoreGateSvc.h" + +// Gaudi +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/Service.h" +#include "GaudiKernel/StatusCode.h" + +void FaserSCT_ClusterContainerCnv_p3::transToPers(const FaserSCT_ClusterContainer* transCont, FaserSCT_ClusterContainer_p3* persCont, MsgStream &log) { + + // The transient model has a container holding collections and the + // collections hold channels. + // + // The persistent model flattens this so that the persistent + // container has two vectors: + // 1) all collections, and + // 2) all PRD + // + // The persistent collections, then only maintain indexes into the + // container's vector of all channels. + // + // So here we loop over all collection and add their channels + // to the container's vector, saving the indexes in the + // collection. + + typedef FaserSCT_ClusterContainer TRANS; + + // this is the id of the latest collection read in + // This starts from the base of the TRT identifiers + unsigned int idLast(0); + + // + + TRANS::const_iterator it_Coll = transCont->begin(); + TRANS::const_iterator it_CollEnd = transCont->end(); + unsigned int collIndex; + unsigned int chanBegin = 0; + unsigned int chanEnd = 0; + + //to retrieve the FaserSCT_ID helper + if(!m_isInitialized) { + if (this->initialize(log) != StatusCode::SUCCESS) { + log << MSG::FATAL << "Could not initialize FaserSCT_ClusterContainerCnv_p2 " << endmsg; + } + } + + FaserSCT_ClusterCnv_p3 chanCnv(m_sctId); + + persCont->m_collections.resize(transCont->numberOfCollections()); + + // to avoid the inside-loop resize + int totSize = 0; + for ( ; it_Coll != it_CollEnd; it_Coll++) { + //for ( it_Coll=transCont->begin(); it_Coll != it_CollEnd; it_Coll++) { + const FaserSCT_ClusterCollection& collection = (**it_Coll); + totSize+=collection.size(); + } + persCont->m_rawdata.resize(totSize); + persCont->m_prdDeltaId.resize(totSize); + + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Preparing " << persCont->m_collections.size() << "Collections" << endmsg; + //for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, it_Coll++) { + for (collIndex = 0, it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++collIndex, it_Coll++) { + // Add in new collection + const FaserSCT_ClusterCollection& collection = (**it_Coll); + chanBegin = chanEnd; + chanEnd += collection.size(); + // Add in channels + TrackerPRD_Collection_p2& pcollection = persCont->m_collections[collIndex]; + unsigned int deltaId = (collection.identifyHash()-idLast); + + pcollection.m_hashId = deltaId; + idLast=collection.identifyHash(); + pcollection.m_size = collection.size(); + + + for (unsigned int i = 0; i < collection.size(); ++i) { + FaserSCT_Cluster_p3* pchan = &(persCont->m_rawdata[i + chanBegin]); + const FaserSCT_Cluster* chan = dynamic_cast<const FaserSCT_Cluster*>(collection[i]); + chanCnv.transToPers(chan, pchan, log); + + persCont->m_prdDeltaId[i+chanBegin]=m_sctId->calc_offset(collection.identify(), chan->identify() ); + } + } + +} + +void FaserSCT_ClusterContainerCnv_p3::persToTrans(const FaserSCT_ClusterContainer_p3* persCont, FaserSCT_ClusterContainer* transCont, MsgStream &log) +{ + if(!m_isInitialized) { + if (this->initialize(log) != StatusCode::SUCCESS) { + log << MSG::FATAL << "Could not initialize FaserSCT_ClusterContainerCnv_p3 from persToTrans" << endmsg; + } + } + + // The transient model has a container holding collections and the + // collections hold channels. + // + // The persistent model flattens this so that the persistent + // container has two vectors: + // 1) all collections, and + // 2) all channels + // + // The persistent collections, then only maintain indexes into the + // container's vector of all channels. + // + // So here we loop over all collection and extract their channels + // from the vector. + + const TrackerDD::SiDetectorElementCollection* elements(nullptr); + if (m_useDetectorElement) { + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEleHandle(m_SCTDetEleCollKey); + elements = *sctDetEleHandle; + if (not sctDetEleHandle.isValid() or elements==nullptr) { + log << MSG::FATAL << m_SCTDetEleCollKey.fullKey() << " is not available." << endmsg; + return; + } + } + + FaserSCT_ClusterCollection* coll = 0; + + //SCT_ClusterCnv_p2 chanCnv; + FaserSCT_ClusterCnv_p3 chanCnv(m_sctId); + unsigned int collBegin(0); + // this is the id of the latest collection read in + // This starts from the base of the TRT identifiers + unsigned int idLast(0); + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Reading " << persCont->m_collections.size() << "Collections" << endmsg; + for (unsigned int icoll = 0; icoll < persCont->m_collections.size(); ++icoll) { + + // Create trans collection - in NOT owner of SCT_DriftCircle (SG::VIEW_ELEMENTS) + // IDet collection don't have the Ownership policy c'tor + const TrackerPRD_Collection_p2& pcoll = persCont->m_collections[icoll]; + idLast += pcoll.m_hashId; + // Identifier collID= Identifier(idLast); + IdentifierHash collIDHash=IdentifierHash((unsigned int) idLast); + Identifier collID = m_sctId->wafer_id(collIDHash); + coll = new FaserSCT_ClusterCollection(collIDHash); + coll->setIdentifier(Identifier(collID)); + unsigned int nchans = pcoll.m_size; + coll->resize(nchans); + const TrackerDD::SiDetectorElement * de = (elements==nullptr ? nullptr : elements->getDetectorElement(collIDHash)); + // Fill with channels: + // This is used to read the vector of errMat + // values and lenght of the value are specified in separate vectors + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Reading collection with " << nchans << "Channels " << endmsg; + for (unsigned int ichan = 0; ichan < nchans; ++ ichan) { + const FaserSCT_Cluster_p3* pchan = &(persCont->m_rawdata[ichan + collBegin]); + //chan->m_clusId=Identifier(collID.get_compact()+persCont->m_prdDeltaId[ichan + collBegin]); + Identifier clusId=m_sctId->strip_id_offset(coll->identify() , persCont->m_prdDeltaId[ichan + collBegin]); + FaserSCT_Cluster* chan = new FaserSCT_Cluster + (chanCnv.createFaserSCT_Cluster (pchan, clusId, de, log)); + + // chan->m_rdoList.resize(1); + // chan->m_rdoList[0]=chan->m_clusId; + //DC Bugfix: Set the idhash for this channel + chan->setHashAndIndex(collIDHash,ichan); + (*coll)[ichan] = chan; + } + collBegin += pcoll.m_size; + + // register the PRD collection in IDC with hash - faster addCollection + StatusCode sc = transCont->addCollection(coll, collIDHash); + if (sc.isFailure()) { + throw std::runtime_error("Failed to add collection to ID Container"); + } + + } + + +} + + + +//================================================================ +FaserSCT_ClusterContainer* FaserSCT_ClusterContainerCnv_p3::createTransient(const FaserSCT_ClusterContainer_p3* persObj, MsgStream& log) { + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "FaserSCT_ClusterContainerCnv_p2::createTransient called " << endmsg; + if(!m_isInitialized) { + if (this->initialize(log) != StatusCode::SUCCESS) { + log << MSG::FATAL << "Could not initialize FaserSCT_ClusterContainerCnv_p3 " << endmsg; + } + } + std::unique_ptr<FaserSCT_ClusterContainer> trans(std::make_unique<FaserSCT_ClusterContainer>(m_sctId->wafer_hash_max())); + persToTrans(persObj, trans.get(), log); + return(trans.release()); +} + + +StatusCode FaserSCT_ClusterContainerCnv_p3::initialize(MsgStream &log) { + // Do not initialize again: + m_isInitialized=true; + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "FaserSCT_ClusterContainerCnv_p2::initialize called " << endmsg; + // Get Storegate, ID helpers, and so on + ISvcLocator* svcLocator = Gaudi::svcLocator(); + // get StoreGate service + StatusCode sc = svcLocator->service("StoreGateSvc", m_storeGate); + if (sc.isFailure()) { + log << MSG::FATAL << "StoreGate service not found !" << endmsg; + return StatusCode::FAILURE; + } + + // get DetectorStore service + StoreGateSvc *detStore; + sc = svcLocator->service("DetectorStore", detStore); + if (sc.isFailure()) { + log << MSG::FATAL << "DetectorStore service not found !" << endmsg; + return StatusCode::FAILURE; + } + // else { + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Found DetectorStore." << endmsg; + // } + + // Get the sct helper from the detector store + sc = detStore->retrieve(m_sctId, "FaserSCT_ID"); + if (sc.isFailure()) { + log << MSG::FATAL << "Could not get FaserSCT_ID helper !" << endmsg; + return StatusCode::FAILURE; + } + // else { + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Found the FaserSCT_ID helper." << endmsg; + // } + + CHECK(m_SCTDetEleCollKey.initialize(m_useDetectorElement)); + + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Converter initialized." << endmsg; + return StatusCode::SUCCESS; +} + +// Methods for test/FaserSCT_ClusterContainerCnv_p3_test.cxx +void FaserSCT_ClusterContainerCnv_p3::setIdHelper(const FaserSCT_ID* sct_id) { + m_sctId = sct_id; +} + +void FaserSCT_ClusterContainerCnv_p3::setUseDetectorElement(const bool useDetectorElement) { + m_useDetectorElement = useDetectorElement; +} diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_tlp1.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_tlp1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d849b7dd57550726dfb3a06c86e02b7dd79fb6df --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_tlp1.cxx @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "FaserSCT_ClusterContainerCnv_tlp1.h" + + +FaserSCT_ClusterContainerCnv_tlp1::FaserSCT_ClusterContainerCnv_tlp1() +{ + // Add all converters defined in this top level converter: + // never change the order of adding converters! + addMainTPConverter(); + addTPConverter( &m_sctClusterCnv ); +// addTPConverter( &m_siClusterCnv ); + addTPConverter( &m_siWidthCnv ); + addTPConverter( &m_locPosCnv); + addTPConverter( &m_errorMatCnv); + + +} + +//void FaserSCT_ClusterContainerCnv_tlp1::setPStorage( FaserSCT_ClusterContainer_tlp1 *storage ) +//{ +// setMainCnvPStorage( &storage->m_sctDCCont ); +// +// m_sctClusterCnv.setPStorage( &storage->m_sctClusters ); +//// m_siClusterCnv.setPStorage( &storage->m_siClusters ); +// m_siWidthCnv.setPStorage( &storage->m_siWidths ); +// m_locPosCnv.setPStorage( &storage->m_locPos ); +// m_errorMatCnv.setPStorage( &storage->m_errorMat ); +//} + +// Method for test/SCT_ClusterCnv_p1_test.cxx +void FaserSCT_ClusterContainerCnv_tlp1::setUseDetectorElement(const bool useDetectorElement) { + m_mainConverter.setUseDetectorElement(useDetectorElement); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_tlp1.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_tlp1.h new file mode 100644 index 0000000000000000000000000000000000000000..1fb59a4d62d391be79fd0e44501a0a19c5c84183 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSCT_ClusterContainerCnv_tlp1.h @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FaserSCT_CLUSTERCONTAINERCNV_TLP1_H +#define FaserSCT_CLUSTERCONTAINERCNV_TLP1_H + + +#include "AthenaPoolCnvSvc/AthenaPoolTopLevelTPConverter.h" + +#include "TrackerEventAthenaPool/FaserSCT_ClusterContainer_tlp1.h" + +#include "TrackerEventAthenaPool/FaserSCT_ClusterContainerCnv_p3.h" +#include "TrackerEventAthenaPool/FaserSCT_ClusterCnv_p3.h" +#include "TrackerEventAthenaPool/FaserSiWidthCnv_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/ErrorMatrixCnv_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPositionCnv_p1.h" + + +#include <iostream> + +class FaserSCT_ClusterContainerCnv_tlp1 + : public AthenaPoolTopLevelTPConverter<FaserSCT_ClusterContainerCnv_p3, FaserSCT_ClusterContainer_tlp1 > +{ +public: + + FaserSCT_ClusterContainerCnv_tlp1(); + virtual ~FaserSCT_ClusterContainerCnv_tlp1() = default; + +// virtual void setPStorage( FaserSCT_ClusterContainer_tlp1 *storage ); +// return list of tokens to extending persistent objects +// it is stored in m_tokenList member of the Track persistent rep + virtual TPCnvTokenList_p1* getTokenListVar() { return &(getTLPersObject()->m_tokenList); } + + void setUseDetectorElement(const bool useDetectorElement); + +protected: + + //SiClusterCnv_p1 m_siClusterCnv; + FaserSCT_ClusterCnv_p3 m_sctClusterCnv; + FaserSiWidthCnv_p1 m_siWidthCnv; +// PrepRawDataCnv_p1 m_prepDataCnv; + LocalPositionCnv_p1 m_locPosCnv; + ErrorMatrixCnv_p1 m_errorMatCnv; + + +}; + + +#endif + + diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSiWidthCnv_p1.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSiWidthCnv_p1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e77d0ce2fbfd7bfa80220206e7e4239f154253a1 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSiWidthCnv_p1.cxx @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidthCnv_p1.cxx +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "TrackerEventAthenaPool/FaserSiWidthCnv_p1.h" + +void FaserSiWidthCnv_p1::persToTrans( const FaserSiWidth_p1 *persObj, + FaserSiWidth *transObj, MsgStream &log ) +{ +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "in SiWidthCnv_p1::persToTrans" << endmsg; + transObj->setColumn (persObj->x); + transObj->setRow (persObj->y); + Amg::Vector2D phirzwidth; + fillTransFromPStore( &m_localPosCnv, persObj->m_phirzWidth, &phirzwidth, log ); + transObj->setPhirzWidth (phirzwidth); +} + + +void FaserSiWidthCnv_p1::transToPers( const FaserSiWidth *transObj, + FaserSiWidth_p1 *persObj, MsgStream &log ) +{ +// if (log.level() <= MSG::DEBUG) log<< MSG::DEBUG << "in SiWidthCnv_p1::transToPERS" << endmsg; + persObj->x = (float) transObj->colRow()[0]; + persObj->y = (float) transObj->colRow()[1]; + //persObj->x = (float) transObj->colRow()[Trk::locX]; + //persObj->y = (float) transObj->colRow()[Trk::locY]; + persObj->m_phirzWidth = toPersistent( &m_localPosCnv, &transObj->widthPhiRZ(), log ); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSiWidthCnv_p2.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSiWidthCnv_p2.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d3f5ed8957f6e76fdc8cb77d8c0fb99f18b6599c --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/tmp/FaserSiWidthCnv_p2.cxx @@ -0,0 +1,34 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidthCnv_p2.cxx +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSiWidth.h" + +#include "TrackerEventAthenaPool/FaserSiWidthCnv_p2.h" + +void FaserSiWidthCnv_p2::persToTrans( const FaserSiWidth_p2 *persObj, + FaserSiWidth *transObj, MsgStream &log ) +{ +// if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "in SiWidthCnv_p2::persToTrans" << endmsg; + transObj->setColumn (persObj->m_size >> 8); + transObj->setRow (persObj->m_size & 0xFF ); + Amg::Vector2D phirzwidth; + m_localPosCnv.persToTrans(&persObj->m_phirzWidth, &phirzwidth, log); + transObj->setPhirzWidth (phirzwidth); +} + + +void FaserSiWidthCnv_p2::transToPers( const FaserSiWidth *transObj, + FaserSiWidth_p2 *persObj, MsgStream &log ) +{ +// if (log.level() <= MSG::VERBOSE) log<< MSG::VERBOSE << "in SiWidthCnv_p2::transToPERS" << endmsg; + persObj->m_size = ( (unsigned int) transObj->colRow()[0] << 8) | ( (unsigned int) transObj->colRow()[1] ); + //persObj->m_size = ( (unsigned int) transObj->colRow()[Trk::locX] << 8) | ( (unsigned int) transObj->colRow()[Trk::locY] ); + m_localPosCnv.transToPers(&transObj->widthPhiRZ(), &persObj->m_phirzWidth, log); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txtIgnore b/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt similarity index 93% rename from Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txtIgnore rename to Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt index b01b52100c8333b2dc0e64e9db935199db91c57a..c63114d74df4313edca03a867782f705adc7f63e 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txtIgnore +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt @@ -19,7 +19,7 @@ atlas_depends_on_subdirs( GaudiKernel Tracker/TrackerDetDescr/TrackerIdentifier #InnerDetector/InDetRecEvent/InDetCompetingRIOsOnTrack - #Tracker/TrackerRecEvent/TrackerPrepRawData + Tracker/TrackerRecEvent/TrackerPrepRawData #Tracker/TrackerRecEvent/TrackerRIO_OnTrack Tracking/TrkEventCnv/TrkEventCnvTools Tracking/TrkEventCnv/TrkEventTPCnv @@ -40,7 +40,7 @@ atlas_depends_on_subdirs( atlas_add_tpcnv_library( TrackerEventTPCnv TrackerEventTPCnv/*.h src/*.cxx # TrackerEventTPCnv/TrackerRIO_OnTrack/*.h src/TrackerRIO_OnTrack/*.cxx -# TrackerEventTPCnv/TrackerPrepRawData/*.h src/TrackerPrepRawData/*.cxx + TrackerEventTPCnv/TrackerPrepRawData/*.h src/TrackerPrepRawData/*.cxx # TrackerEventTPCnv/InDetCompetingRIOsOnTrack/*.h # src/InDetCompetingRIOsOnTrack/*.cxx PUBLIC_HEADERS TrackerEventTPCnv @@ -48,7 +48,8 @@ atlas_add_tpcnv_library( TrackerEventTPCnv AthenaPoolCnvSvcLib AthenaPoolUtilities Identifier GaudiKernel TrackerIdentifier # InDetCompetingRIOsOnTrack -# TrackerPrepRawData TrackerRIO_OnTrack + TrackerPrepRawData +# TrackerRIO_OnTrack TrkEventTPCnv PRIVATE_LINK_LIBRARIES AthenaBaseComps AthenaKernel EventPrimitives TrackerReadoutGeometry TrkSurfaces TrkEventPrimitives @@ -76,4 +77,4 @@ set( _jobOPath "${_jobOPath}:$ENV{JOBOPTSEARCHPATH}" ) # SGTools TrackerReadoutGeometry TestTools TrackerIdentifier # ENVIRONMENT "JOBOPTSEARCHPATH=${_jobOPath}" ) -endforeach() +#endforeach() diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_p3.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_p3.h new file mode 100644 index 0000000000000000000000000000000000000000..558595f0d993c502859cec9382f3f7a713e45305 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_p3.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTERCONTAINERCNV_P3_H +#define FASERSCT_CLUSTERCONTAINERCNV_P3_H + +// SCT_DriftCircleContainerCnv_p3, T/P separation of SCT PRD +// author D.Costanzo <davide.costanzo@cern.ch> + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerEventTPCnv/FaserSCT_ClusterContainer_p3.h" + +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "StoreGate/ReadCondHandleKey.h" + +class FaserSCT_ID; +class StoreGateSvc; + +class FaserSCT_ClusterContainerCnv_p3 : public T_AthenaPoolTPCnvBase<Tracker::FaserSCT_ClusterContainer, Tracker::FaserSCT_ClusterContainer_p3> +{ + public: + FaserSCT_ClusterContainerCnv_p3() : m_sctId{nullptr}, m_storeGate{nullptr}, m_SCTDetEleCollKey{"SCT_DetectorElementCollection"}, m_useDetectorElement{true}, m_isInitialized{false} {}; + + virtual void transToPers(const Tracker::FaserSCT_ClusterContainer* transCont, + Tracker::FaserSCT_ClusterContainer_p3* persCont, + MsgStream &log) ; + virtual void persToTrans(const Tracker::FaserSCT_ClusterContainer_p3* persCont, + Tracker::FaserSCT_ClusterContainer* transCont, + MsgStream &log) ; + + virtual Tracker::FaserSCT_ClusterContainer* createTransient(const Tracker::FaserSCT_ClusterContainer_p3* persObj, MsgStream& log); + + // Methods for test/SCT_ClusterContainerCnv_p3_test.cxx + void setIdHelper(const FaserSCT_ID* sct_id); + void setUseDetectorElement(const bool useDetectorElement); + + private: + const FaserSCT_ID *m_sctId; + StoreGateSvc *m_storeGate; + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey; + bool m_useDetectorElement; + bool m_isInitialized; + StatusCode initialize(MsgStream &log); + +}; + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_tlp1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_tlp1.h new file mode 100644 index 0000000000000000000000000000000000000000..de6a85707a1db6433966ecf8899f2ad65077952b --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_tlp1.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTERCONTAINERCNV_TLP1_H +#define FASERSCT_CLUSTERCONTAINERCNV_TLP1_H + + +#include "AthenaPoolCnvSvc/AthenaPoolTopLevelTPConverter.h" + +#include "FaserSCT_ClusterContainer_tlp1.h" + +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterContainerCnv_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerClusterCnv_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidthCnv_p1.h" +#include "TrkEventTPCnv/TrkPrepRawData/PrepRawDataCnv_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/ErrorMatrixCnv_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPositionCnv_p1.h" + + +#include <iostream> + +class FaserSCT_ClusterContainerCnv_tlp1 + : public AthenaPoolTopLevelTPConverter<Tracker::FaserSCT_ClusterContainerCnv_p1, Tracker::FaserSCT_ClusterContainer_tlp1 > +{ +public: + + FaserSCT_ClusterContainerCnv_tlp1(); + virtual ~FaserSCT_ClusterContainerCnv_tlp1() = default; + + virtual void setPStorage( Tracker::FaserSCT_ClusterContainer_tlp1 *storage ); +// return list of tokens to extending persistent objects +// it is stored in m_tokenList member of the Track persistent rep + virtual TPCnvTokenList_p1* getTokenListVar() { return &(getTLPersObject()->m_tokenList); } + + void setUseDetectorElement(const bool useDetectorElement); + +protected: + + TrackerClusterCnv_p1 m_siClusterCnv; + FaserSCT_ClusterCnv_p1 m_sctClusterCnv; + FaserSiWidthCnv_p1 m_siWidthCnv; + PrepRawDataCnv_p1 m_prepDataCnv; + LocalPositionCnv_p1 m_locPosCnv; + ErrorMatrixCnv_p1 m_errorMatCnv; + + +}; + + +#endif + + diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainer_p3.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainer_p3.h new file mode 100644 index 0000000000000000000000000000000000000000..8e942c8355a98c72708d592419e8d61011231579 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainer_p3.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTERCONTAINER_P3_H +#define FASERSCT_CLUSTERCONTAINER_P3_H + +/* + +Author: Davide Costanzo + +*/ + +#include <vector> +#include <string> +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p3.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p2.h" +#include "Identifier/Identifier.h" + + +namespace Tracker{ +class FaserSCT_ClusterContainer_p3 +{ + public: +/// Default constructor + FaserSCT_ClusterContainer_p3 (); + //private: + std::vector<Tracker::TrackerPRD_Collection_p2> m_collections; + std::vector<Tracker::FaserSCT_Cluster_p3> m_rawdata; +// The delta identifiers of the PRD: + //std::vector<unsigned short> m_prdDeltaId; + std::vector<Identifier::diff_type> m_prdDeltaId; +}; + + +// inlines + +inline +FaserSCT_ClusterContainer_p3::FaserSCT_ClusterContainer_p3 () {} +} + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainer_tlp1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainer_tlp1.h new file mode 100644 index 0000000000000000000000000000000000000000..6958946e378b2cfe423388d9062ca96703206f5c --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_ClusterContainer_tlp1.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTERCONTAINER_TLP1_H +#define FASERSCT_CLUSTERCONTAINER_TLP1_H + + + + +//----------------------------------------------------------------------------- +// InDetPrepRawData +//----------------------------------------------------------------------------- +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Container_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerCluster_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidth_p1.h" +#include "TrkEventTPCnv/TrkPrepRawData/PrepRawData_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/HepSymMatrix_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPosition_p1.h" + + +// Token +#include "AthenaPoolUtilities/TPCnvTokenList_p1.h" + +namespace Tracker +{ + class FaserSCT_ClusterContainer_tlp1 + { + public: + FaserSCT_ClusterContainer_tlp1() {} + TPCnvTokenList_p1 m_tokenList; + +// This is the basic info + std::vector< Tracker::TrackerPRD_Container_p1> m_sctDCCont; + std::vector< Tracker::FaserSCT_Cluster_p1 > m_sctClusters; +// This are the base classes + std::vector< Tracker::TrackerCluster_p1 > m_siClusters; + std::vector< Tracker::FaserSiWidth_p1 > m_siWidths; + std::vector< Trk::PrepRawData_p1> m_prepData; +// This is info held by the base class + std::vector< Trk::LocalPosition_p1> m_locPos; + std::vector< Trk::HepSymMatrix_p1> m_errorMat; + + }; +} + + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerEventTPCnvDict.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerEventTPCnvDict.h index 95960147ef2739fcf1805a8c9cc5fd85541ce771..a99bf84eb4e46238572c4fd4f29e4b60890f826a 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerEventTPCnvDict.h +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerEventTPCnvDict.h @@ -11,52 +11,52 @@ // //----------------------------------------------------------------------------- -#include "InDetEventTPCnv/InDetTrack_tlp1.h" -#include "InDetEventTPCnv/InDetTrack_tlp2.h" -#include "InDetEventTPCnv/PixelClusterContainer_tlp1.h" -#include "InDetEventTPCnv/InDetPrepRawData/SiCluster_p1.h" -#include "InDetEventTPCnv/InDetPrepRawData/InDetPRD_Collection_p1.h" -#include "InDetEventTPCnv/InDetPrepRawData/InDetPRD_Container_p1.h" -#include "InDetEventTPCnv/InDetPrepRawData/PixelCluster_p1.h" -#include "InDetEventTPCnv/InDetPrepRawData/PixelCluster_p2.h" -#include "InDetEventTPCnv/InDetPrepRawData/PixelCluster_p3.h" -#include "InDetEventTPCnv/InDetPrepRawData/SCT_Cluster_p1.h" -#include "InDetEventTPCnv/InDetPrepRawData/TRT_DriftCircle_p1.h" -#include "InDetEventTPCnv/InDetPrepRawData/TRT_DriftCircle_p2.h" -#include "InDetEventTPCnv/TRT_DriftCircleContainer_p2.h" -#include "InDetEventTPCnv/PixelClusterContainer_p2.h" -#include "InDetEventTPCnv/PixelClusterContainer_p3.h" -#include "InDetEventTPCnv/SCT_ClusterContainer_p2.h" -#include "InDetEventTPCnv/SCT_ClusterContainer_p3.h" -#include "InDetEventTPCnv/PixelClusterContainer_tlp1.h" -#include "InDetEventTPCnv/SCT_ClusterContainer_tlp1.h" -#include "InDetEventTPCnv/TRT_DriftCircleContainer_tlp1.h" -#include "InDetEventTPCnv/InDetPrepRawData/PixelGangedClusterAmbiguities_p1.h" -#include "InDetEventTPCnv/TRT_DriftCircleContainer_tlp1.h" -#include "InDetEventTPCnv/InDetCompetingRIOsOnTrack/CompetingPixelClustersOnTrack_p1.h" -#include "InDetEventTPCnv/InDetCompetingRIOsOnTrack/CompetingSCT_ClustersOnTrack_p1.h" -#include "InDetEventTPCnv/InDetCompetingRIOsOnTrack/CompetingTRT_DriftCirclesOnTrack_p1.h" -#include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaCandidate_p1.h" -#include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaContainer_p1.h" -#include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaCandidate_tlp1.h" -#include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaContainer_tlp1.h" +// #include "InDetEventTPCnv/InDetTrack_tlp1.h" +// #include "InDetEventTPCnv/InDetTrack_tlp2.h" +// #include "InDetEventTPCnv/PixelClusterContainer_tlp1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerCluster_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Container_p1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/PixelCluster_p1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/PixelCluster_p2.h" +// #include "InDetEventTPCnv/InDetPrepRawData/PixelCluster_p3.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/TRT_DriftCircle_p1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/TRT_DriftCircle_p2.h" +// #include "InDetEventTPCnv/TRT_DriftCircleContainer_p2.h" +// #include "InDetEventTPCnv/PixelClusterContainer_p2.h" +// #include "InDetEventTPCnv/PixelClusterContainer_p3.h" +// #include "InDetEventTPCnv/SCT_ClusterContainer_p2.h" +#include "TrackerEventTPCnv/FaserSCT_ClusterContainer_p3.h" +// #include "InDetEventTPCnv/PixelClusterContainer_tlp1.h" +#include "TrackerEventTPCnv/FaserSCT_ClusterContainer_tlp1.h" +// #include "InDetEventTPCnv/TRT_DriftCircleContainer_tlp1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/PixelGangedClusterAmbiguities_p1.h" +// #include "InDetEventTPCnv/TRT_DriftCircleContainer_tlp1.h" +// #include "InDetEventTPCnv/InDetCompetingRIOsOnTrack/CompetingPixelClustersOnTrack_p1.h" +// #include "InDetEventTPCnv/InDetCompetingRIOsOnTrack/CompetingSCT_ClustersOnTrack_p1.h" +// #include "InDetEventTPCnv/InDetCompetingRIOsOnTrack/CompetingTRT_DriftCirclesOnTrack_p1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaCandidate_p1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaContainer_p1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaCandidate_tlp1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaContainer_tlp1.h" -namespace InDetEventTPCnvDict { +namespace TrackerEventTPCnvDict { struct tmp { - std::vector< InDet::PixelCluster_p1> m_v1; - std::vector< InDet::SCT_Cluster_p1> m_v2; - std::vector< InDet::SCT_Cluster_p3> m_v2a; - std::vector< InDet::SiCluster_p1> m_v3; - std::vector< InDet::TRT_DriftCircle_p1 > m_v6; - std::vector< InDet::TRT_DriftCircle_p2 > m_v6a; - std::vector< InDet::InDetPRD_Collection_p1 > m_v7; - std::vector< InDet::InDetPRD_Container_p1 > m_v8; - std::vector< InDet::CompetingPixelClustersOnTrack_p1> m_v9; - std::vector< InDet::CompetingSCT_ClustersOnTrack_p1> m_v10; - std::vector< InDet::CompetingTRT_DriftCirclesOnTrack_p1> m_v11; - std::vector< InDetLowBetaCandidate_p1> m_v12; + // std::vector< InDet::PixelCluster_p1> m_v1; + std::vector< Tracker::FaserSCT_Cluster_p1> m_v2; + std::vector< Tracker::FaserSCT_Cluster_p3> m_v2a; + std::vector< Tracker::TrackerCluster_p1> m_v3; + // std::vector< InDet::TRT_DriftCircle_p1 > m_v6; + // std::vector< InDet::TRT_DriftCircle_p2 > m_v6a; + std::vector< Tracker::TrackerPRD_Collection_p1 > m_v7; + std::vector< Tracker::TrackerPRD_Container_p1 > m_v8; + // std::vector< InDet::CompetingPixelClustersOnTrack_p1> m_v9; + // std::vector< InDet::CompetingSCT_ClustersOnTrack_p1> m_v10; + // std::vector< InDet::CompetingTRT_DriftCirclesOnTrack_p1> m_v11; + // std::vector< InDetLowBetaCandidate_p1> m_v12; }; -} //> namespace InDetEventTPCnvDict +} //> namespace TrackerEventTPCnvDict -#endif // INDETEVENTTPCNV_INDETEVENTTPCNVDICT_H +#endif // TRACKEREVENTTPCNV_TRACKEREVENTTPCNVDICT_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..325617c727656de42019d9d224aedf4b6d3ae22c --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p1.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTER_CNV_P1_H +#define FASERSCT_CLUSTER_CNV_P1_H + +//----------------------------------------------------------------------------- +// +// file: FaserSCT_ClusterCnv_p1.h +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "FaserSCT_Cluster_p1.h" + +#include "TrackerClusterCnv_p1.h" + + +class MsgStream; + +class FaserSCT_ClusterCnv_p1 + : public T_AthenaPoolTPPolyCnvBase< Trk::PrepRawData, Tracker::FaserSCT_Cluster, Tracker::FaserSCT_Cluster_p1> +{ +public: + FaserSCT_ClusterCnv_p1() : m_siClusterCnv(0) {} + + void persToTrans( const Tracker::FaserSCT_Cluster_p1 *persObj, Tracker::FaserSCT_Cluster *transObj, MsgStream &log ); + void transToPers( const Tracker::FaserSCT_Cluster *transObj, Tracker::FaserSCT_Cluster_p1 *persObj,MsgStream &log ); + +private: + TrackerClusterCnv_p1 *m_siClusterCnv; +}; + + +#endif // FASERSCT_CLUSTER_CNV_P1_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p3.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p3.h new file mode 100644 index 0000000000000000000000000000000000000000..d156b8880cfcd82f938fb9cf929351e019c93d3a --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p3.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTER_CNV_P3_H +#define FASERSCT_CLUSTER_CNV_P3_H + +//----------------------------------------------------------------------------- +// +// file: FaserSCT_ClusterCnv_p3.h +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "FaserSCT_Cluster_p3.h" + +#include "FaserSiWidthCnv_p2.h" +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPositionCnv_p1.h" +#include "TrkEventTPCnv/TrkEventPrimitives/ErrorMatrixCnv_p1.h" + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "TrackerIdentifier/FaserSCT_ID.h" + +class MsgStream; + +class FaserSCT_ClusterCnv_p3 + : public T_AthenaPoolTPPolyCnvBase< Trk::PrepRawData, Tracker::FaserSCT_Cluster, Tracker::FaserSCT_Cluster_p3> +{ +public: + FaserSCT_ClusterCnv_p3() {}; + FaserSCT_ClusterCnv_p3( const FaserSCT_ID * ); + + Tracker::FaserSCT_Cluster + createSCT_Cluster (const Tracker::FaserSCT_Cluster_p3* persObj, + Identifier clusId, + const TrackerDD::SiDetectorElement* detEl, + MsgStream& log); + + void persToTrans( const Tracker::FaserSCT_Cluster_p3 *, Tracker::FaserSCT_Cluster *, MsgStream & ); + void transToPers( const Tracker::FaserSCT_Cluster *, Tracker::FaserSCT_Cluster_p3 *, MsgStream & ); + +protected: + const FaserSCT_ID* m_sctId2; + Tracker::FaserSiWidthCnv_p2 m_swCnv; + LocalPositionCnv_p1 m_localPosCnv; + ErrorMatrixCnv_p1 m_errorMxCnv; +}; + +#endif // FASERSCT_CLUSTER_CNV_P3_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterContainerCnv_p1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterContainerCnv_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..2be71fa27136beac37636acea903aa9488f7e048 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterContainerCnv_p1.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTERCONTAINERCNV_P1_H +#define FASERSCT_CLUSTERCONTAINERCNV_P1_H + +//----------------------------------------------------------------------------- +// +// file: FaserSCT_ClusterContainerCnv_p1.h +// +//----------------------------------------------------------------------------- + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Container_p1.h" + +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "StoreGate/ReadCondHandleKey.h" + +class MsgStream; +class FaserSCT_ID; +class StoreGateSvc; + +namespace Tracker{ +class FaserSCT_ClusterContainerCnv_p1 : public T_AthenaPoolTPCnvBase< Tracker::FaserSCT_ClusterContainer, Tracker::TrackerPRD_Container_p1 > + +{ + public: + typedef Tracker::TrackerPRD_Container_p1 PERS; + typedef Tracker::FaserSCT_ClusterContainer TRANS; + FaserSCT_ClusterContainerCnv_p1(): m_sctId{nullptr}, m_storeGate{nullptr}, m_SCTDetEleCollKey{"SCT_DetectorElementCollection"}, m_useDetectorElement{true}, m_isInitialized(false) {} + virtual void transToPers(const TRANS* transCont, PERS* persCont, MsgStream &log); + virtual void persToTrans(const PERS* persCont, TRANS* transCont, MsgStream &log); + virtual Tracker::FaserSCT_ClusterContainer* createTransient(const Tracker::TrackerPRD_Container_p1* persObj, MsgStream& log); + // Method for test/SCT_ClusterContainerCnv_p1_test.cxx + void setUseDetectorElement(const bool useDetectorElement); + private: + const FaserSCT_ID *m_sctId; + StoreGateSvc *m_storeGate; + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey; + // Declaration of ReadCondHandleKey in SCT_ClusterContainerCnv_p1 triggers memory leak in SCT_ClusterCnv_p1_test. + bool m_useDetectorElement; + bool m_isInitialized; + StatusCode initialize(MsgStream &log); +}; + +} +#endif + diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..1367f95ac719763d1ac6707f593f4f39e5f22815 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p1.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTER_P1_TRK_H +#define FASERSCT_CLUSTER_P1_TRK_H + +//----------------------------------------------------------------------------- +// +// file: SCT_Cluster_p1.h +// +//----------------------------------------------------------------------------- +#include "AthenaPoolUtilities/TPObjRef.h" + +namespace Tracker +{ + class FaserSCT_Cluster_p1 + { + public: + FaserSCT_Cluster_p1() {} + // base + TPObjRef m_siCluster; + }; +} + +#endif // FASERSCT_CLUSTER_P1_TRK_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p3.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p3.h new file mode 100644 index 0000000000000000000000000000000000000000..19bc6df5fd5b1be929bca4bd62a2c32df53f3651 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p3.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSCT_CLUSTER_P3_TRK_H +#define FASERSCT_CLUSTER_P3_TRK_H + +//----------------------------------------------------------------------------- +// +// file: SCT_Cluster_p3.h +// +//----------------------------------------------------------------------------- +#include "FaserSiWidth_p2.h" + +namespace Tracker +{ + class FaserSCT_Cluster_p3 + { + public: + + // type used for channel id differences + typedef short rdo_diff_type; + + FaserSCT_Cluster_p3(): m_localPos{0.}, m_mat00{0.}, m_mat01{0.}, m_mat11{0.}, m_hitsInThirdTimeBin{0} {} + + // replace this: + std::vector<rdo_diff_type > m_rdoList; + float m_localPos; + float m_mat00; + float m_mat01; + float m_mat11; + uint16_t m_hitsInThirdTimeBin; + + //SiWidth_p2 + Tracker::FaserSiWidth_p2 m_width; + + }; +} + +#endif // FASERSCT_CLUSTER_P3_TRK_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidthCnv_p1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidthCnv_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..a6059890658e0079da4841cda94c281221802d8f --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidthCnv_p1.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSI_WIDTH_CNV_P1_H +#define FASERSI_WIDTH_CNV_P1_H + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidthCnv_p1.h +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidth_p1.h" + +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPositionCnv_p1.h" + +class MsgStream; + +class FaserSiWidthCnv_p1 + : public T_AthenaPoolTPCnvBase<Tracker::FaserSiWidth, Tracker::FaserSiWidth_p1> +{ +public: + FaserSiWidthCnv_p1() : m_localPosCnv(0) {} + + void persToTrans( const Tracker::FaserSiWidth_p1 *, Tracker::FaserSiWidth *, MsgStream & ); + void transToPers( const Tracker::FaserSiWidth *, Tracker::FaserSiWidth_p1 *, MsgStream & ); + +private: + LocalPositionCnv_p1 *m_localPosCnv; + +}; + +#endif // FASERSI_WIDTH_CNV_P1_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidthCnv_p2.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidthCnv_p2.h new file mode 100644 index 0000000000000000000000000000000000000000..28f922bfa10e099abe2e0cfb9a860b0486178cea --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidthCnv_p2.h @@ -0,0 +1,38 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSI_WIDTH_CNV_P2_H +#define FASERSI_WIDTH_CNV_P2_H + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidthCnv_p2.h +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidth_p2.h" + +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPositionCnv_p1.h" + +class MsgStream; + +namespace Tracker +{ + + class FaserSiWidthCnv_p2 + : public T_AthenaPoolTPCnvBase<Tracker::FaserSiWidth, Tracker::FaserSiWidth_p2> + { + public: + FaserSiWidthCnv_p2() {} + + void persToTrans( const Tracker::FaserSiWidth_p2 *, Tracker::FaserSiWidth *, MsgStream & ); + void transToPers( const Tracker::FaserSiWidth *, Tracker::FaserSiWidth_p2 *, MsgStream & ); + + private: + LocalPositionCnv_p1 m_localPosCnv; + + }; +} +#endif // FASERSI_WIDTH_CNV_P1_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidth_p1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidth_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..1931ea8479011bf35c5edd9b9e9ab5c3378b273f --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidth_p1.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSI_WIDTH_P1_TRK_H +#define FASERSI_WIDTH_P1_TRK_H + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidth_p1.h +// +//----------------------------------------------------------------------------- +#include "AthenaPoolUtilities/TPObjRef.h" + + +namespace Tracker +{ + class FaserSiWidth_p1 + { + public: + FaserSiWidth_p1() {} + + float x{}; + float y{}; + // Trk::LocalPosition_p1 * + TPObjRef m_phirzWidth; + }; +} + +#endif // FASERSI_WIDTH_TRK_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidth_p2.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidth_p2.h new file mode 100644 index 0000000000000000000000000000000000000000..d1d594cc97256a9ab5902a99164c2ae45d306ac9 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidth_p2.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSI_WIDTH_P2_TRK_H +#define FASERSI_WIDTH_P2_TRK_H + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidth_p2.h +// +//----------------------------------------------------------------------------- +#include "TrkEventTPCnv/TrkEventPrimitives/LocalPosition_p1.h" + + +namespace Tracker +{ + +class FaserSiWidthCnv_p2; + +class FaserSiWidth_p2 + { + public: + FaserSiWidth_p2() {}; + friend class FaserSiWidthCnv_p2; + private: + unsigned int m_size{}; + Trk::LocalPosition_p1 m_phirzWidth; + }; + +} +#endif // FASERSI_WIDTH_TRK_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerClusterCnv_p1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerClusterCnv_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..af1f9ced4246436320b80a517ebb66269e6ff7c3 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerClusterCnv_p1.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERCLUSTER_CNV_P1_H +#define TRACKERCLUSTER_CNV_P1_H + +//----------------------------------------------------------------------------- +// +// file: TrackerClusterCnv_p1.h +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/TrackerCluster.h" +#include "TrackerCluster_p1.h" + +#include "FaserSiWidthCnv_p1.h" +#include "TrkEventTPCnv/TrkPrepRawData/PrepRawDataCnv_p1.h" + + +class MsgStream; + +class TrackerClusterCnv_p1 + : public T_AthenaPoolTPPolyCnvBase< Trk::PrepRawData, Tracker::TrackerCluster, Tracker::TrackerCluster_p1> +{ +public: + TrackerClusterCnv_p1(): m_rawDataCnv(0), m_swCnv(0) {} + + void persToTrans( const Tracker::TrackerCluster_p1 *, Tracker::TrackerCluster *, MsgStream & ); + void transToPers( const Tracker::TrackerCluster *, Tracker::TrackerCluster_p1 *, MsgStream & ); + +protected: +// ITPConverterFor<Trk::PrepRawData> *m_rawDataCnv; +// ITPConverterFor<Tracker::FaserSiWidth> *m_swCnv; + PrepRawDataCnv_p1 *m_rawDataCnv; + FaserSiWidthCnv_p1 *m_swCnv; + + +}; + +#endif // TRACKERCLUSTER_CNV_P1_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerCluster_p1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerCluster_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..058ec75df42c95b069ca8b6c2229b52203f99372 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerCluster_p1.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERCLUSTER_P1_TRK_H +#define TRACKERCLUSTER_P1_TRK_H + +//----------------------------------------------------------------------------- +// +// file: TrackerCluster_p1.h +// +//----------------------------------------------------------------------------- +#include "AthenaPoolUtilities/TPObjRef.h" + + +namespace Tracker +{ + class TrackerCluster_p1 + { + public: + TrackerCluster_p1() {} + + // base PrepRawData_p1 + TPObjRef m_rawData; + + //FaserSiWidth_p1* + TPObjRef m_width; + + }; +} + +#endif // TRACKERCLUSTER_P1_TRK_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..fef52bc88ad8a220c21fa89e41484f99983b89d4 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p1.h @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERPRD_COLLECTION_P1_H +#define TRACKERPRD_COLLECTION_P1_H + + +namespace Tracker{ +class TrackerPRD_Collection_p1 +{ + + +public: + + TrackerPRD_Collection_p1() + : + m_id(0), + m_hashId(0), + m_begin(0), + m_end(0) + { } ; + + // container cnvs do conversions + // friend class PixelClusterContainerCnv_p1; + friend class FaserSCT_ClusterContainerCnv_p1; + // friend class TRT_DriftCircleContainerCnv_p1; + + //private: + + // Identifier of this collection + unsigned int m_id; + + //Identifier::value_type m_id; + + // Hash Identifier of this collection + // (write this one as well, so we don't rely on the IdHelper for it) + unsigned int m_hashId; + + // Begin index into master collection + unsigned int m_begin; + + // End index into master collection + unsigned int m_end; + +}; + +} + +#endif + + diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p2.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p2.h new file mode 100644 index 0000000000000000000000000000000000000000..4119fe1621e5de15c4e3bb056bfc8db49383d920 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p2.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERPRD_COLLECTION_P2_H +#define TRACKERPRD_COLLECTION_P2_H + +#include <vector> +namespace Tracker{ +class TrackerPRD_Collection_p2 +{ + + +public: + + TrackerPRD_Collection_p2() + : + // m_idDelta(0), + m_hashId(0), + m_size(0) + { } ; + + // container cnvs do conversions + // friend class PixelClusterContainerCnv_p2; + friend class FaserSCT_ClusterContainerCnv_p2; + // friend class TRT_DriftCircleContainerCnv_p1; + + //private: + + // Identifier distance of this collection from the previous one + // unsigned short m_idDelta; + + // Hash Identifier of this collection + // (write this one as well, so we don't rely on the IdHelper for it) + unsigned short m_hashId; + + // Collection size into master collection + // Note I use a short. If a collection has more than 2^16 elements (unlikely) it + // has to be split into two separate collections + unsigned short m_size; + +}; + +} + +#endif + + diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Container_p1.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Container_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..55e8a39116830bf15cc07a733f864db7dbc494e0 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Container_p1.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERPRD_CONTAINER_P1_H +#define TRACKERPRD_CONTAINER_P1_H 1 + +#include <vector> +#include <string> +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p1.h" + +namespace Tracker { +class TrackerPRD_Container_p1 +{ + public: +/// Default constructor + TrackerPRD_Container_p1 (); + //private: + std::vector<Tracker::TrackerPRD_Collection_p1> m_collections; + std::vector<TPObjRef> m_PRD; +}; + +} + + +// inlines + +inline Tracker::TrackerPRD_Container_p1::TrackerPRD_Container_p1() {} + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/selection.xml b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..9f9267182b5dd4e39314166555deb98db5b7eae0 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/selection.xml @@ -0,0 +1,75 @@ +<lcgdict> + + <!-- <class name="InDet::Track_tlp1" id="8380F7AC-4A8F-4382-95A5-1234E43D3B08" /> + <class name="InDet::Track_tlp2" id="4E3778E2-1497-4F10-8746-AA02319FAC83" /> + --> + <!-- InDetRIO_OnTrack --> + <!-- <class name="InDet::SiClusterOnTrack_p1" /> + <class name="std::vector<InDet::SiClusterOnTrack_p1>" /> --> + <!-- <class name="InDet::SiClusterOnTrack_p2" /> --> + <!-- <class name="std::vector<InDet::SiClusterOnTrack_p2>" /> --> + <!-- <class name="InDet::PixelClusterOnTrack_p1" /> + <class name="std::vector<InDet::PixelClusterOnTrack_p1>" /> + <class name="InDet::PixelClusterOnTrack_p2" /> + <class name="std::vector<InDet::PixelClusterOnTrack_p2>" /> + <class name="InDet::SCT_ClusterOnTrack_p1" /> + <class name="std::vector<InDet::SCT_ClusterOnTrack_p1>" /> + <class name="InDet::SCT_ClusterOnTrack_p2" /> + <class name="std::vector<InDet::SCT_ClusterOnTrack_p2>" /> + <class name="InDet::TRT_DriftCircleOnTrack_p1" /> + <class name="std::vector<InDet::TRT_DriftCircleOnTrack_p1>" /> + <class name="InDet::TRT_DriftCircleOnTrack_p2" /> + <class name="std::vector<InDet::TRT_DriftCircleOnTrack_p2>" /> --> + + <!--InDetCompetingRIOsOnTrack --> + <!-- <class name="InDet::CompetingPixelClustersOnTrack_p1" /> + <class name="std::vector<InDet::CompetingPixelClustersOnTrack_p1>" /> + <class name="InDet::CompetingSCT_ClustersOnTrack_p1" /> + <class name="std::vector<InDet::CompetingSCT_ClustersOnTrack_p1>" /> + <class name="InDet::CompetingTRT_DriftCirclesOnTrack_p1" /> + <class name="std::vector<InDet::CompetingTRT_DriftCirclesOnTrack_p1>" /> --> + + + <!-- InDetPrepRawData --> + <class name="Tracker::TrackerCluster_p1" /> + <class name="std::vector<Tracker::TrackerCluster_p1>" /> + <!-- <class name="Tracker::FaserSCT_Cluster_p2" /> + <class name="std::vector<Tracker::FaserSCT_Cluster_p2>" /> --> + <class name="Tracker::FaserSCT_Cluster_p3" /> + <class name="std::vector<Tracker::FaserSCT_Cluster_p3>" /> + <!-- <class name="InDet::SiWidth_p1" /> --> + <class name="Tracker::FaserSiWidth_p2" /> + <!-- <class name="std::vector<InDet::SiWidth_p1>" /> --> + <!-- <class name="InDet::InDetPRD_Collection_p1" /> --> + <class name="Tracker::TrackerPRD_Collection_p2" /> + <class name="Tracker::TrackerPRD_Container_p1" /> + <class name="std::vector<Tracker::TrackerPRD_Collection_p1>" /> + <class name="std::vector<Tracker::TrackerPRD_Collection_p2>" /> + <class name="std::vector<Tracker::TrackerPRD_Container_p1>" /> + <!-- <class name="InDet::PixelCluster_p1" /> + <class name="InDet::PixelCluster_p2" /> + <class name="InDet::PixelCluster_p3" /> + <class name="std::vector<InDet::PixelCluster_p1>" /> + <class name="std::vector<InDet::PixelCluster_p2>" /> + <class name="std::vector<InDet::PixelCluster_p3>" /> + <class name="InDet::PixelClusterContainer_tlp1" id="9DB54746-8C4E-4A56-8B4C-0E5D42905218" /> + <class name="InDet::PixelClusterContainer_p2" id="DE48E26B-9E03-4EAD-86B9-351AD88D060E" /> + <class name="InDet::PixelClusterContainer_p3" id="7BF0F163-B227-434C-86A6-16130E005E6C" /> --> + <class name="Tracker::FaserSCT_Cluster_p1" /> + <class name="std::vector<Tracker::FaserSCT_Cluster_p1>" /> + <class name="Tracker::FaserSCT_ClusterContainer_tlp1" id="5EF374F6-EA93-4739-9ECE-FBBA9C928818" /> + <!-- <class name="InDet::SCT_ClusterContainer_p2" id="ECE7D831-0F31-4E6F-A6BE-2ADDE90083BA" /> --> + <class name="Tracker::FaserSCT_ClusterContainer_p3" id="42921F1E-8D65-4DBF-B309-6510794E05E0" /> + <!-- <class name="InDet::TRT_DriftCircle_p1" /> + <class name="std::vector<InDet::TRT_DriftCircle_p1>" /> + <class name="InDet::TRT_DriftCircle_p2" /> + <class name="std::vector<InDet::TRT_DriftCircle_p2>" /> + <class name="InDet::TRT_DriftCircleContainer_p2" id="36195EDE-941C-424B-81A1-E04C867C35D8" /> + <class name="InDet::TRT_DriftCircleContainer_tlp1" id="42B48D79-AF4E-4D45-AAA9-A2BA5A033534" /> --> + + <!-- <class name="InDet::PixelGangedClusterAmbiguities_p1" id="FE36CE7E-EADF-481F-A55A-26DA0030DFAA"/> --> +<!-- <class name="uint32_t" /> --> +<!-- <class name="std::vector<uint32_t>" /> --> +<!-- <class name="std::pair<unsigned int,std::vector<unsigned int> >" /> --> + <class name="std::vector< std::pair<unsigned int, std::vector<unsigned int> > >" /> + diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_ClusterContainerCnv_p3.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_ClusterContainerCnv_p3.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7ff5889daf7c6a0d12a65bf698e1957b85b93465 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_ClusterContainerCnv_p3.cxx @@ -0,0 +1,251 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_p3.h" + +// Athena +#include "AthenaKernel/errorcheck.h" +#include "Identifier/Identifier.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p2.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p3.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p3.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "StoreGate/ReadCondHandle.h" +#include "StoreGate/StoreGateSvc.h" + +// Gaudi +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/Service.h" +#include "GaudiKernel/StatusCode.h" + +void FaserSCT_ClusterContainerCnv_p3::transToPers(const Tracker::FaserSCT_ClusterContainer* transCont, Tracker::FaserSCT_ClusterContainer_p3* persCont, MsgStream &log) { + + // The transient model has a container holding collections and the + // collections hold channels. + // + // The persistent model flattens this so that the persistent + // container has two vectors: + // 1) all collections, and + // 2) all PRD + // + // The persistent collections, then only maintain indexes into the + // container's vector of all channels. + // + // So here we loop over all collection and add their channels + // to the container's vector, saving the indexes in the + // collection. + + typedef Tracker::FaserSCT_ClusterContainer TRANS; + + // this is the id of the latest collection read in + // This starts from the base of the TRT identifiers + unsigned int idLast(0); + + // + + TRANS::const_iterator it_Coll = transCont->begin(); + TRANS::const_iterator it_CollEnd = transCont->end(); + unsigned int collIndex; + unsigned int chanBegin = 0; + unsigned int chanEnd = 0; + + //to retrieve the SCT_ID helper + if(!m_isInitialized) { + if (this->initialize(log) != StatusCode::SUCCESS) { + log << MSG::FATAL << "Could not initialize SCT_ClusterContainerCnv_p2 " << endmsg; + } + } + + FaserSCT_ClusterCnv_p3 chanCnv(m_sctId); + + persCont->m_collections.resize(transCont->numberOfCollections()); + + // to avoid the inside-loop resize + int totSize = 0; + //for ( ; it_Coll != it_CollEnd; it_Coll++) { + for ( it_Coll=transCont->begin(); it_Coll != it_CollEnd; it_Coll++) { + const Tracker::FaserSCT_ClusterCollection& collection = (**it_Coll); + totSize+=collection.size(); + } + persCont->m_rawdata.resize(totSize); + persCont->m_prdDeltaId.resize(totSize); + + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Preparing " << persCont->m_collections.size() << "Collections" << endmsg; + //for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, it_Coll++) { + for (collIndex = 0, it_Coll=transCont->begin(); it_Coll != it_CollEnd; ++collIndex, it_Coll++) { + // Add in new collection + const Tracker::FaserSCT_ClusterCollection& collection = (**it_Coll); + chanBegin = chanEnd; + chanEnd += collection.size(); + Tracker::TrackerPRD_Collection_p2& pcollection = persCont->m_collections[collIndex]; + unsigned int deltaId = (collection.identifyHash()-idLast); + + pcollection.m_hashId = deltaId; + idLast=collection.identifyHash(); + pcollection.m_size = collection.size(); + // Add in channels + + for (unsigned int i = 0; i < collection.size(); ++i) { + Tracker::FaserSCT_Cluster_p3* pchan = &(persCont->m_rawdata[i + chanBegin]); + const Tracker::FaserSCT_Cluster* chan = dynamic_cast<const Tracker::FaserSCT_Cluster*>(collection[i]); + chanCnv.transToPers(chan, pchan, log); + + persCont->m_prdDeltaId[i+chanBegin]=m_sctId->calc_offset(collection.identify(), chan->identify() ); + } + } + +} + +void FaserSCT_ClusterContainerCnv_p3::persToTrans(const Tracker::FaserSCT_ClusterContainer_p3* persCont, Tracker::FaserSCT_ClusterContainer* transCont, MsgStream &log) +{ + if(!m_isInitialized) { + if (this->initialize(log) != StatusCode::SUCCESS) { + log << MSG::FATAL << "Could not initialize FaserSCT_ClusterContainerCnv_p3 from persToTrans" << endmsg; + } + } + + // The transient model has a container holding collections and the + // collections hold channels. + // + // The persistent model flattens this so that the persistent + // container has two vectors: + // 1) all collections, and + // 2) all channels + // + // The persistent collections, then only maintain indexes into the + // container's vector of all channels. + // + // So here we loop over all collection and extract their channels + // from the vector. + + const TrackerDD::SiDetectorElementCollection* elements(nullptr); + if (m_useDetectorElement) { + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEleHandle(m_SCTDetEleCollKey); + elements = *sctDetEleHandle; + if (not sctDetEleHandle.isValid() or elements==nullptr) { + log << MSG::FATAL << m_SCTDetEleCollKey.fullKey() << " is not available." << endmsg; + return; + } + } + + Tracker::FaserSCT_ClusterCollection* coll = 0; + + //SCT_ClusterCnv_p2 chanCnv; + FaserSCT_ClusterCnv_p3 chanCnv(m_sctId); + unsigned int collBegin(0); + // this is the id of the latest collection read in + // This starts from the base of the TRT identifiers + unsigned int idLast(0); + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Reading " << persCont->m_collections.size() << "Collections" << endmsg; + for (unsigned int icoll = 0; icoll < persCont->m_collections.size(); ++icoll) { + + // Create trans collection - in NOT owner of SCT_DriftCircle (SG::VIEW_ELEMENTS) + // IDet collection don't have the Ownership policy c'tor + const Tracker::TrackerPRD_Collection_p2& pcoll = persCont->m_collections[icoll]; + idLast += pcoll.m_hashId; + // Identifier collID= Identifier(idLast); + IdentifierHash collIDHash=IdentifierHash((unsigned int) idLast); + Identifier collID = m_sctId->wafer_id(collIDHash); + coll = new Tracker::FaserSCT_ClusterCollection(collIDHash); + coll->setIdentifier(Identifier(collID)); + unsigned int nchans = pcoll.m_size; + coll->resize(nchans); + const TrackerDD::SiDetectorElement * de = (elements==nullptr ? nullptr : elements->getDetectorElement(collIDHash)); + // Fill with channels: + // This is used to read the vector of errMat + // values and lenght of the value are specified in separate vectors + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Reading collection with " << nchans << "Channels " << endmsg; + for (unsigned int ichan = 0; ichan < nchans; ++ ichan) { + const Tracker::FaserSCT_Cluster_p3* pchan = &(persCont->m_rawdata[ichan + collBegin]); + //chan->m_clusId=Identifier(collID.get_compact()+persCont->m_prdDeltaId[ichan + collBegin]); + Identifier clusId=m_sctId->strip_id_offset(coll->identify() , persCont->m_prdDeltaId[ichan + collBegin]); + Tracker::FaserSCT_Cluster* chan = new Tracker::FaserSCT_Cluster + (chanCnv.createSCT_Cluster (pchan, clusId, de, log)); + + // chan->m_rdoList.resize(1); + // chan->m_rdoList[0]=chan->m_clusId; + //DC Bugfix: Set the idhash for this channel + chan->setHashAndIndex(collIDHash,ichan); + (*coll)[ichan] = chan; + } + collBegin += pcoll.m_size; + + // register the PRD collection in IDC with hash - faster addCollection + StatusCode sc = transCont->addCollection(coll, collIDHash); + if (sc.isFailure()) { + throw std::runtime_error("Failed to add collection to ID Container"); + } + + } + + +} + + + +//================================================================ +Tracker::FaserSCT_ClusterContainer* FaserSCT_ClusterContainerCnv_p3::createTransient(const Tracker::FaserSCT_ClusterContainer_p3* persObj, MsgStream& log) { + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "FaserSCT_ClusterContainerCnv_p2::createTransient called " << endmsg; + if(!m_isInitialized) { + if (this->initialize(log) != StatusCode::SUCCESS) { + log << MSG::FATAL << "Could not initialize SCT_ClusterContainerCnv_p3 " << endmsg; + } + } + std::unique_ptr<Tracker::FaserSCT_ClusterContainer> trans(std::make_unique<Tracker::FaserSCT_ClusterContainer>(m_sctId->wafer_hash_max())); + persToTrans(persObj, trans.get(), log); + return(trans.release()); +} + + +StatusCode FaserSCT_ClusterContainerCnv_p3::initialize(MsgStream &log) { + // Do not initialize again: + m_isInitialized=true; + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "SCT_ClusterContainerCnv_p2::initialize called " << endmsg; + // Get Storegate, ID helpers, and so on + ISvcLocator* svcLocator = Gaudi::svcLocator(); + // get StoreGate service + StatusCode sc = svcLocator->service("StoreGateSvc", m_storeGate); + if (sc.isFailure()) { + log << MSG::FATAL << "StoreGate service not found !" << endmsg; + return StatusCode::FAILURE; + } + + // get DetectorStore service + StoreGateSvc *detStore; + sc = svcLocator->service("DetectorStore", detStore); + if (sc.isFailure()) { + log << MSG::FATAL << "DetectorStore service not found !" << endmsg; + return StatusCode::FAILURE; + } + // else { + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Found DetectorStore." << endmsg; + // } + + // Get the sct helper from the detector store + sc = detStore->retrieve(m_sctId, "FaserSCT_ID"); + if (sc.isFailure()) { + log << MSG::FATAL << "Could not get FaserSCT_ID helper !" << endmsg; + return StatusCode::FAILURE; + } + // else { + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Found the SCT_ID helper." << endmsg; + // } + + CHECK(m_SCTDetEleCollKey.initialize(m_useDetectorElement)); + + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Converter initialized." << endmsg; + return StatusCode::SUCCESS; +} + +// Methods for test/SCT_ClusterContainerCnv_p3_test.cxx +void FaserSCT_ClusterContainerCnv_p3::setIdHelper(const FaserSCT_ID* sct_id) { + m_sctId = sct_id; +} + +void FaserSCT_ClusterContainerCnv_p3::setUseDetectorElement(const bool useDetectorElement) { + m_useDetectorElement = useDetectorElement; +} diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_ClusterContainerCnv_tlp1.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_ClusterContainerCnv_tlp1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8a2bc7e7a9b6b96a28fb65213ad06819e95ccfd3 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_ClusterContainerCnv_tlp1.cxx @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrackerEventTPCnv/FaserSCT_ClusterContainerCnv_tlp1.h" + + +FaserSCT_ClusterContainerCnv_tlp1::FaserSCT_ClusterContainerCnv_tlp1() +{ + // Add all converters defined in this top level converter: + // never change the order of adding converters! + addMainTPConverter(); + addTPConverter( &m_sctClusterCnv ); + addTPConverter( &m_siClusterCnv ); + addTPConverter( &m_siWidthCnv ); + addTPConverter( &m_prepDataCnv); + addTPConverter( &m_locPosCnv); + addTPConverter( &m_errorMatCnv); + + +} + + + +void FaserSCT_ClusterContainerCnv_tlp1::setPStorage( Tracker::FaserSCT_ClusterContainer_tlp1 *storage ) +{ + setMainCnvPStorage( &storage->m_sctDCCont ); + + m_sctClusterCnv.setPStorage( &storage->m_sctClusters ); + m_siClusterCnv.setPStorage( &storage->m_siClusters ); + m_siWidthCnv.setPStorage( &storage->m_siWidths ); + m_prepDataCnv.setPStorage( &storage->m_prepData ); + m_locPosCnv.setPStorage( &storage->m_locPos ); + m_errorMatCnv.setPStorage( &storage->m_errorMat ); +} + +// Method for test/SCT_ClusterCnv_p1_test.cxx +void FaserSCT_ClusterContainerCnv_tlp1::setUseDetectorElement(const bool useDetectorElement) { + m_mainConverter.setUseDetectorElement(useDetectorElement); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerEventTPCnv.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerEventTPCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3110a08b0f8aac79fbf7a4772aba5c67fb94157f --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerEventTPCnv.cxx @@ -0,0 +1,38 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// generate the T/P converter entries +#include "AthenaKernel/TPCnvFactory.h" + +// #include "InDetEventTPCnv/InDetTrack_tlp1.h" +// #include "InDetEventTPCnv/InDetTrack_tlp2.h" +// #include "InDetEventTPCnv/PixelClusterContainer_tlp1.h" +// #include "InDetEventTPCnv/PixelClusterContainerCnv_tlp1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerCluster_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Collection_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Container_p1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/PixelCluster_p1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/PixelCluster_p2.h" +// #include "InDetEventTPCnv/InDetPrepRawData/PixelCluster_p3.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_Cluster_p1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/TRT_DriftCircle_p1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/TRT_DriftCircle_p2.h" +// #include "InDetEventTPCnv/TRT_DriftCircleContainer_p2.h" +// #include "InDetEventTPCnv/PixelClusterContainer_p2.h" +// #include "InDetEventTPCnv/PixelClusterContainer_p3.h" +// #include "TrackerEventTPCnv/SCT_ClusterContainer_p2.h" +// #include "InDetEventTPCnv/PixelClusterContainer_tlp1.h" +#include "TrackerEventTPCnv/FaserSCT_ClusterContainer_tlp1.h" +// #include "InDetEventTPCnv/TRT_DriftCircleContainer_tlp1.h" +// #include "InDetEventTPCnv/InDetPrepRawData/PixelGangedClusterAmbiguities_p1.h" +// #include "InDetEventTPCnv/TRT_DriftCircleContainer_tlp1.h" +// #include "InDetEventTPCnv/InDetCompetingRIOsOnTrack/CompetingPixelClustersOnTrack_p1.h" +// #include "InDetEventTPCnv/InDetCompetingRIOsOnTrack/CompetingSCT_ClustersOnTrack_p1.h" +// #include "InDetEventTPCnv/InDetCompetingRIOsOnTrack/CompetingTRT_DriftCirclesOnTrack_p1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaCandidate_p1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaContainer_p1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaCandidate_tlp1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaContainer_tlp1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaContainerCnv_tlp1.h" +// #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaCandidateCnv_tlp1.h" diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSCT_ClusterCnv_p1.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSCT_ClusterCnv_p1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5be7105af49894d747ac9d0e377195a72622e406 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSCT_ClusterCnv_p1.cxx @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//----------------------------------------------------------------------------- +// +// file: FaserSCT_ClusterCnv_p1.cxx +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p1.h" + +void FaserSCT_ClusterCnv_p1:: +persToTrans( const Tracker::FaserSCT_Cluster_p1 *persObj, Tracker::FaserSCT_Cluster *transObj,MsgStream &log ) +{ +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "SCT_ClusterCnv_p1::persToTrans" << endmsg; + fillTransFromPStore( &m_siClusterCnv, persObj->m_siCluster, transObj, log ); +} + +void FaserSCT_ClusterCnv_p1:: +transToPers( const Tracker::FaserSCT_Cluster *transObj, Tracker::FaserSCT_Cluster_p1 *persObj, MsgStream &log ) +{ +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "SCT_ClusterCnv_p1::transToPers" << endmsg; + persObj->m_siCluster = baseToPersistent( &m_siClusterCnv, transObj, log ); +} + + diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSCT_ClusterCnv_p3.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSCT_ClusterCnv_p3.cxx new file mode 100644 index 0000000000000000000000000000000000000000..038542e50285a76e1a41fb77156b465bd96b4bb9 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSCT_ClusterCnv_p3.cxx @@ -0,0 +1,117 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +//----------------------------------------------------------------------------- +// +// file: FaserSCT_ClusterCnv_p3.cxx +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSCT_Cluster.h" + +#include "EventPrimitives/EventPrimitives.h" + +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p3.h" + +#include <memory> + +FaserSCT_ClusterCnv_p3::FaserSCT_ClusterCnv_p3(const FaserSCT_ID * sctid ) + : + m_sctId2(sctid) +{} + + +Tracker::FaserSCT_Cluster +FaserSCT_ClusterCnv_p3::createSCT_Cluster (const Tracker::FaserSCT_Cluster_p3* persObj, + Identifier clusId, + const TrackerDD::SiDetectorElement* detEl, + MsgStream& log) +{ + // Local Position + Amg::Vector2D localPos; + localPos[Trk::locX] = persObj->m_localPos; + localPos[Trk::locY] = 0; + + // List of Id of the cluster + std::vector<Identifier> rdoList; + rdoList.resize( persObj->m_rdoList.size() ); + //Identifier::value_type id32 = transObj->identify().get_compact(); + //Identifier id32 = transObj->identify(); + std::vector<Identifier>::iterator tit = rdoList.begin(); + for (std::vector<Tracker::FaserSCT_Cluster_p3::rdo_diff_type>::const_iterator it=persObj->m_rdoList.begin(); it != persObj->m_rdoList.end(); it++) { + + *tit = Identifier(m_sctId2->strip_id_offset(clusId,*it) ); + tit++; + } + + Tracker::FaserSiWidth sw; + m_swCnv.persToTrans(&persObj->m_width, &sw, log); + + // Error matrix + auto cmat = std::make_unique<Amg::MatrixX>(2,2); + (*cmat)(0,0) = static_cast<double>(persObj->m_mat00); + (*cmat)(1,0) = static_cast<double>(persObj->m_mat01); + (*cmat)(0,1) = static_cast<double>(persObj->m_mat01); + (*cmat)(1,1) = static_cast<double>(persObj->m_mat11); + + Tracker::FaserSCT_Cluster clus (clusId, + localPos, + std::move(rdoList), + sw, + detEl, + std::move(cmat)); + clus.setHitsInThirdTimeBin( persObj->m_hitsInThirdTimeBin ) ; + return clus; +} + + +void FaserSCT_ClusterCnv_p3:: +persToTrans( const Tracker::FaserSCT_Cluster_p3 *persObj, Tracker::FaserSCT_Cluster *transObj, MsgStream &log) +{ + Identifier clusId = transObj->identify(); + *transObj = createSCT_Cluster (persObj, clusId, nullptr, log); +} + + +void FaserSCT_ClusterCnv_p3::transToPers( const Tracker::FaserSCT_Cluster *transObj, Tracker::FaserSCT_Cluster_p3 *persObj, MsgStream &log ) +{ +// if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "In SCT_Cluster::transToPers" << endmsg; + const Tracker::FaserSiWidth *sw = &transObj->width(); + m_swCnv.transToPers(sw, &persObj->m_width, log); + + // base class: + // + + // Local Position + persObj->m_localPos = transObj->localPosition()[Trk::locX]; + + // cluster weight + persObj->m_hitsInThirdTimeBin = transObj->hitsInThirdTimeBin(); + + + // Error Matrix + persObj->m_mat00 = (transObj->localCovariance())(0,0); + persObj->m_mat01 = (transObj->localCovariance())(0,1); + persObj->m_mat11 = (transObj->localCovariance())(1,1); + + // List of Id of the cluster + persObj->m_rdoList.resize( transObj->rdoList().size() ); + //Identifier::value_type id32 = transObj->identify().get_compact(); + Identifier id32 = transObj->identify(); + + + // convert the list of ID saved for the cluster + persObj->m_rdoList.resize(transObj->rdoList().size() ); + std::vector<Tracker::FaserSCT_Cluster_p3::rdo_diff_type>::iterator pit = persObj->m_rdoList.begin(); + + + for (std::vector<Identifier>::const_iterator it=transObj->rdoList().begin(); it != transObj->rdoList().end(); it++) { + + *pit = static_cast<Tracker::FaserSCT_Cluster_p3::rdo_diff_type>( m_sctId2->calc_offset(id32, *it) ); + pit++; + } + +} + + diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSCT_ClusterContainerCnv_p1.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSCT_ClusterContainerCnv_p1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..dbfc558821e150a52c638982b2c24ab051534e29 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSCT_ClusterContainerCnv_p1.cxx @@ -0,0 +1,203 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterContainerCnv_p1.h" + +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerCluster_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerPRD_Container_p1.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSCT_ClusterCnv_p1.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" + +// Athena +#include "AthenaKernel/errorcheck.h" +#include "StoreGate/ReadCondHandle.h" +#include "StoreGate/StoreGateSvc.h" + +// Gaudi +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/Service.h" +#include "GaudiKernel/StatusCode.h" + +void Tracker::FaserSCT_ClusterContainerCnv_p1::transToPers(const Tracker::FaserSCT_ClusterContainer* transCont, Tracker::TrackerPRD_Container_p1* persCont, MsgStream &log) +{ + + // The transient model has a container holding collections and the + // collections hold channels. + // + // The persistent model flattens this so that the persistent + // container has two vectors: + // 1) all collections, and + // 2) all RDO + // + // The persistent collections, then only maintain indexes into the + // container's vector of all channels. + // + // So here we loop over all collection and add their channels + // to the container's vector, saving the indexes in the + // collection. + + typedef Tracker::FaserSCT_ClusterContainer TRANS; + typedef ITPConverterFor<Trk::PrepRawData> CONV; + + FaserSCT_ClusterCnv_p1 chanCnv; + TRANS::const_iterator it_Coll = transCont->begin(); + TRANS::const_iterator it_CollEnd = transCont->end(); + unsigned int collIndex; + unsigned int chanBegin = 0; + unsigned int chanEnd = 0; + persCont->m_collections.resize(transCont->numberOfCollections()); +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Preparing " << persCont->m_collections.size() << "Collections" << endmsg; + + for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, it_Coll++) { + // Add in new collection +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " New collection" << endmsg; + const Tracker::FaserSCT_ClusterCollection& collection = (**it_Coll); + chanBegin = chanEnd; + chanEnd += collection.size(); + Tracker::TrackerPRD_Collection_p1& pcollection = persCont->m_collections[collIndex]; + pcollection.m_id = collection.identify().get_compact(); + pcollection.m_hashId = (unsigned int) collection.identifyHash(); + pcollection.m_begin = chanBegin; + pcollection.m_end = chanEnd; + // Add in channels + persCont->m_PRD.resize(chanEnd); + for (unsigned int i = 0; i < collection.size(); ++i) { + const Tracker::FaserSCT_Cluster* chan = collection[i]; + persCont->m_PRD[i + chanBegin] = toPersistent((CONV**)0, chan, log ); + } + } +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Writing SCT_ClusterContainer ***" << endmsg; +} + +void Tracker::FaserSCT_ClusterContainerCnv_p1::persToTrans(const Tracker::TrackerPRD_Container_p1* persCont, Tracker::FaserSCT_ClusterContainer* transCont, MsgStream &log) +{ + + // The transient model has a container holding collections and the + // collections hold channels. + // + // The persistent model flattens this so that the persistent + // container has two vectors: + // 1) all collections, and + // 2) all channels + // + // The persistent collections, then only maintain indexes into the + // container's vector of all channels. + // + // So here we loop over all collection and extract their channels + // from the vector. + + const TrackerDD::SiDetectorElementCollection* elements(nullptr); + if (m_useDetectorElement) { + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEleHandle(m_SCTDetEleCollKey); + elements = *sctDetEleHandle; + if (not sctDetEleHandle.isValid() or elements==nullptr) { + log << MSG::FATAL << m_SCTDetEleCollKey.fullKey() << " is not available." << endmsg; + return; + } + } + + Tracker::FaserSCT_ClusterCollection* coll = 0; + + FaserSCT_ClusterCnv_p1 chanCnv; + typedef ITPConverterFor<Trk::PrepRawData> CONV; + +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " Reading " << persCont->m_collections.size() << "Collections" << endmsg; + for (unsigned int icoll = 0; icoll < persCont->m_collections.size(); ++icoll) { + + // Create trans collection - is NOT owner of SCT_Cluster (SG::VIEW_ELEMENTS) + // IDet collection don't have the Ownership policy c'tor + const Tracker::TrackerPRD_Collection_p1& pcoll = persCont->m_collections[icoll]; + //Identifier collID(Identifier(pcoll.m_id)); + IdentifierHash collIDHash(IdentifierHash(pcoll.m_hashId)); + coll = new Tracker::FaserSCT_ClusterCollection(collIDHash); + coll->setIdentifier(Identifier(pcoll.m_id)); + unsigned int nchans = pcoll.m_end - pcoll.m_begin; + coll->resize(nchans); + const TrackerDD::SiDetectorElement * de = (m_useDetectorElement ? elements->getDetectorElement(collIDHash) : nullptr); + // Fill with channels + for (unsigned int ichan = 0; ichan < nchans; ++ ichan) { + const TPObjRef pchan = persCont->m_PRD[ichan + pcoll.m_begin]; + Tracker::FaserSCT_Cluster* chan = dynamic_cast<Tracker::FaserSCT_Cluster*>(createTransFromPStore((CONV**)0, pchan, log ) ); + if (chan) { + chan->m_detEl = de; + (*coll)[ichan] = chan; + } + } + + // register the rdo collection in IDC with hash - faster addCollection + StatusCode sc = transCont->addCollection(coll, collIDHash); + if (sc.isFailure()) { + throw std::runtime_error("Failed to add collection to ID Container"); + } +// if (log.level() <= MSG::DEBUG) { +// log << MSG::DEBUG << "AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " << (int) collIDHash << " / " << +// collID.get_compact() << ", added to Identifiable container." << endmsg; +// } + } + +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Reading SCT_ClusterContainer" << endmsg; +} + + + +//================================================================ +Tracker::FaserSCT_ClusterContainer* Tracker::FaserSCT_ClusterContainerCnv_p1::createTransient(const Tracker::TrackerPRD_Container_p1* persObj, MsgStream& log) +{ + if(!m_isInitialized) { + if (this->initialize(log) != StatusCode::SUCCESS) { + log << MSG::FATAL << "Could not initialize SCT_ClusterContainerCnv_p1 " << endmsg; + } + } + std::unique_ptr<Tracker::FaserSCT_ClusterContainer> trans(std::make_unique<Tracker::FaserSCT_ClusterContainer>(m_sctId->wafer_hash_max())); + persToTrans(persObj, trans.get(), log); + return(trans.release()); +} + +StatusCode Tracker::FaserSCT_ClusterContainerCnv_p1::initialize(MsgStream &log) { + // Do not initialize again: + m_isInitialized=true; + + // Get Storegate, ID helpers, and so on + ISvcLocator* svcLocator = Gaudi::svcLocator(); + // get StoreGate service + StatusCode sc = svcLocator->service("StoreGateSvc", m_storeGate); + if (sc.isFailure()) { + log << MSG::FATAL << "StoreGate service not found !" << endmsg; + return StatusCode::FAILURE; + } + + // get DetectorStore service + StoreGateSvc *detStore; + sc = svcLocator->service("DetectorStore", detStore); + if (sc.isFailure()) { + log << MSG::FATAL << "DetectorStore service not found !" << endmsg; + return StatusCode::FAILURE; + } + // else { + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Found DetectorStore." << endmsg; + // } + + // Get the SCT helper from the detector store + sc = detStore->retrieve(m_sctId, "FaserSCT_ID"); + if (sc.isFailure()) { + log << MSG::FATAL << "Could not get SCT_ID helper !" << endmsg; + return StatusCode::FAILURE; + } + // else { + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Found the SCT_ID helper." << endmsg; + // } + + CHECK(m_SCTDetEleCollKey.initialize(m_useDetectorElement)); + + // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Converter initialized." << endmsg; + return StatusCode::SUCCESS; +} + +// Method for test/SCT_ClusterContainerCnv_p1_test.cxx +void Tracker::FaserSCT_ClusterContainerCnv_p1::setUseDetectorElement(const bool useDetectorElement) { + m_useDetectorElement = useDetectorElement; +} diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSiWidthCnv_p1.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSiWidthCnv_p1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..66a5f573e828d41977702ca2abef99071c96b869 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSiWidthCnv_p1.cxx @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidthCnv_p1.cxx +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidthCnv_p1.h" + +void FaserSiWidthCnv_p1::persToTrans( const Tracker::FaserSiWidth_p1 *persObj, + Tracker::FaserSiWidth *transObj, MsgStream &log ) +{ +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "in SiWidthCnv_p1::persToTrans" << endmsg; + transObj->setColumn (persObj->x); + transObj->setRow (persObj->y); + Amg::Vector2D phirzwidth; + fillTransFromPStore( &m_localPosCnv, persObj->m_phirzWidth, &phirzwidth, log ); + transObj->setPhirzWidth (phirzwidth); +} + + +void FaserSiWidthCnv_p1::transToPers( const Tracker::FaserSiWidth *transObj, + Tracker::FaserSiWidth_p1 *persObj, MsgStream &log ) +{ +// if (log.level() <= MSG::DEBUG) log<< MSG::DEBUG << "in SiWidthCnv_p1::transToPERS" << endmsg; + persObj->x = (float) transObj->colRow()[Trk::locX]; + persObj->y = (float) transObj->colRow()[Trk::locY]; + persObj->m_phirzWidth = toPersistent( &m_localPosCnv, &transObj->widthPhiRZ(), log ); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSiWidthCnv_p2.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSiWidthCnv_p2.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ac73b78c2a5aca2b08948a87f29a97ff3ebafc13 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/FaserSiWidthCnv_p2.cxx @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//----------------------------------------------------------------------------- +// +// file: FaserSiWidthCnv_p2.cxx +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/FaserSiWidth.h" + +#include "TrackerEventTPCnv/TrackerPrepRawData/FaserSiWidthCnv_p2.h" + +void Tracker::FaserSiWidthCnv_p2::persToTrans( const Tracker::FaserSiWidth_p2 *persObj, + Tracker::FaserSiWidth *transObj, MsgStream &log ) +{ +// if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "in SiWidthCnv_p2::persToTrans" << endmsg; + transObj->setColumn (persObj->m_size >> 8); + transObj->setRow (persObj->m_size & 0xFF ); + Amg::Vector2D phirzwidth; + m_localPosCnv.persToTrans(&persObj->m_phirzWidth, &phirzwidth, log); + transObj->setPhirzWidth (phirzwidth); +} + + +void Tracker::FaserSiWidthCnv_p2::transToPers( const Tracker::FaserSiWidth *transObj, + Tracker::FaserSiWidth_p2 *persObj, MsgStream &log ) +{ +// if (log.level() <= MSG::VERBOSE) log<< MSG::VERBOSE << "in SiWidthCnv_p2::transToPERS" << endmsg; + persObj->m_size = ( (unsigned int) transObj->colRow()[Trk::locX] << 8) | ( (unsigned int) transObj->colRow()[Trk::locY] ); + m_localPosCnv.transToPers(&transObj->widthPhiRZ(), &persObj->m_phirzWidth, log); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/TrackerClusterCnv_p1.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/TrackerClusterCnv_p1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0224beaa99068610630eb3ebc61d61327d9a9e02 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/TrackerPrepRawData/TrackerClusterCnv_p1.cxx @@ -0,0 +1,31 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//----------------------------------------------------------------------------- +// +// file: TrackerClusterCnv_p1.cxx +// +//----------------------------------------------------------------------------- + +#include "TrackerPrepRawData/TrackerCluster.h" +#include "TrackerEventTPCnv/TrackerPrepRawData/TrackerClusterCnv_p1.h" + + +void TrackerClusterCnv_p1:: +persToTrans( const Tracker::TrackerCluster_p1 *persObj, Tracker::TrackerCluster *transObj, MsgStream &log) +{ +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "In SiCluster::persToTrans" << endmsg; + fillTransFromPStore( &m_rawDataCnv, persObj->m_rawData, transObj, log ); + fillTransFromPStore( &m_swCnv, persObj->m_width, &transObj->m_width, log ); +} + + +void TrackerClusterCnv_p1::transToPers( const Tracker::TrackerCluster *transObj, Tracker::TrackerCluster_p1 *persObj, MsgStream &log ) +{ +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "In SiCluster::transToPers" << endmsg; + persObj->m_rawData = baseToPersistent( &m_rawDataCnv, transObj, log ); + persObj->m_width = toPersistent( &m_swCnv, &transObj->width(), log ); +} + + diff --git a/Tracker/TrackerRawEvent/TrackerRawData/CMakeLists.txt b/Tracker/TrackerRawEvent/TrackerRawData/CMakeLists.txt index d4892a5b8264a3d493a6c73aaf7626683f4cc169..9037208e1b21193f930259a61d7bb14d1657d2b2 100644 --- a/Tracker/TrackerRawEvent/TrackerRawData/CMakeLists.txt +++ b/Tracker/TrackerRawEvent/TrackerRawData/CMakeLists.txt @@ -12,6 +12,7 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaKernel DetectorDescription/Identifier Event/EventContainers + Tracker/TrackerDetDescr/TrackerReadoutGeometry PRIVATE GaudiKernel ) @@ -23,7 +24,7 @@ atlas_add_library( TrackerRawData src/*.cxx PUBLIC_HEADERS TrackerRawData PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES AthenaKernel AthContainers AthLinks Identifier EventContainers + LINK_LIBRARIES AthenaKernel AthContainers AthLinks Identifier EventContainers TrackerReadoutGeometry GeoPrimitives PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel ) atlas_add_dictionary( TrackerRawDataDict diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/CMakeLists.txt b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..05ab132032688a08d1c4429954256863fb2bb93a --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/CMakeLists.txt @@ -0,0 +1,38 @@ +################################################################################ +# Package: TrackerPrepRawDataFormation +################################################################################ + +# Declare the package name: +atlas_subdir( TrackerPrepRawDataFormation ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + Control/StoreGate + DetectorDescription/Identifier + GaudiKernel + Tracker/TrackerRawEvent/TrackerRawData + Tracker/TrackerRecEvent/TrackerPrepRawData + Tracker/TrackerRecTools/FaserSiClusterizationTool + PRIVATE + Control/AthViews + DetectorDescription/FaserDetDescr + Tracker/TrackerDetDescr/TrackerIdentifier + Tracker/TrackerDetDescr/TrackerReadoutGeometry + Tracker/TrackerConditions/FaserSCT_ConditionsData + InnerDetector/InDetConditions/SCT_ConditionsData + InnerDetector/InDetConditions/InDetConditionsSummaryService + ) + +# Component(s) in the package: +atlas_add_component( TrackerPrepRawDataFormation + src/*.cxx src/*.h + src/components/*.cxx + LINK_LIBRARIES AthenaBaseComps StoreGateLib SGtests Identifier GaudiKernel TrackerRawData TrackerPrepRawData FaserSiClusterizationToolLib FaserDetDescr TrackerIdentifier TrackerReadoutGeometry AthViews) + +# Install files from the package: +#atlas_install_headers( TrackerPrepRawDataFormation ) + +atlas_install_python_modules( python/*.py ) + +atlas_install_scripts( test/*.py ) diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/TrackerPrepRawDataFormation/ATLAS_CHECK_THREAD_SAFETY b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/TrackerPrepRawDataFormation/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..3fe0ee023dab1c156254a68e56da758cfa0e74f2 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/TrackerPrepRawDataFormation/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..fa451680033df679d9d53ea9610344d6c88d84d4 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py @@ -0,0 +1,68 @@ +"""Define methods to construct configured SCT Digitization tools and algorithms + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConf import Tracker__FaserSCT_Clusterization +#from FaserSCT_ClusteringTool.FaserSCT_ClusteringToolConf import FaserSCT_ClusteringTool +PileUpXingFolder=CompFactory.PileUpXingFolder + +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +#SCT_RadDamageSummaryTool=CompFactory.SCT_RadDamageSummaryTool +from FaserGeoModel.SCTGMConfig import SctGeometryCfg + +#from FaserSCT_ConditionsTools.FaserSCT_DCSConditionsConfig import FaserSCT_DCSConditionsCfg +#from FaserSCT_ConditionsTools.FaserSCT_DCSConditionsConfig import FaserSCT_DCSConditionsToolCfg +from FaserSiLorentzAngleTool.FaserSCT_LorentzAngleConfig import FaserSCT_LorentzAngleCfg + + +def FaserSCT_ClusterizationCommonCfg(flags, name="FaserSCT_ClusterizationToolCommon", **kwargs): + """Return ComponentAccumulator with common FaserSCT Clusterization tool config""" + acc = SctGeometryCfg(flags) + + kwargs.setdefault("InputObjectName", "SCT_RDOs") + #kwargs.setdefault("BarrelOnly", False) + from FaserSiClusterizationTool.FaserSiClusterizationToolConf import Tracker__TrackerClusterMakerTool, Tracker__FaserSCT_ClusteringTool + trackerClusterMakerTool = Tracker__TrackerClusterMakerTool(name = "TrackerClusterMakerTool") + faserSCT_LorentzAngleTool=acc.popToolsAndMerge(FaserSCT_LorentzAngleCfg(flags)) + clusteringTool = Tracker__FaserSCT_ClusteringTool(name, globalPosAlg = trackerClusterMakerTool, FaserSiLorentzAngleTool=faserSCT_LorentzAngleTool) + clusteringTool.timeBins = "01X" + # attach ToolHandles + acc.setPrivateTools(clusteringTool) + return acc + + +def FaserSCT_ClusterizationToolCfg(flags, name="FaserSCT_ClusterizationTool", **kwargs): + """Return ComponentAccumulator with configured FaserSCT Clusterization tool""" + #kwargs.setdefault("HardScatterSplittingMode", 0) + return FaserSCT_ClusterizationCommonCfg(flags, name, **kwargs) + + +def FaserSCT_ClusterizationBasicCfg(flags, **kwargs): + """Return ComponentAccumulator for FaserSCT Clusterization""" + acc = ComponentAccumulator() + clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags)) + kwargs.setdefault("SCT_ClusteringTool", clusterTool) + kwargs.setdefault("DataObjectName", "SCT_RDOs") + kwargs.setdefault("ClustersName", "SCT_ClusterContainer") + kwargs.setdefault("SCT_FlaggedCondData", "SCT_Flags"); + acc.addEventAlgo(Tracker__FaserSCT_Clusterization(**kwargs)) + return acc + +def FaserSCT_OutputCfg(flags): + """Return ComponentAccumulator with Output for SCT. Not standalone.""" + acc = ComponentAccumulator() + ItemList = ["Tracker::FaserSCT_ClusterContainer#*"] + acc.merge(OutputStreamCfg(flags, "RDO", ItemList)) + ostream = acc.getEventAlgo("OutputStreamRDO") + ostream.TakeItemsFromInput=True + return acc + + +# with output defaults +def FaserSCT_ClusterizationCfg(flags, **kwargs): + """Return ComponentAccumulator for SCT Clusterization and Output""" + acc = FaserSCT_ClusterizationBasicCfg(flags, **kwargs) + acc.merge(FaserSCT_OutputCfg(flags)) + return acc diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfigDb.py b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfigDb.py new file mode 100644 index 0000000000000000000000000000000000000000..98d757e8dc460d1adb9eea16a098cf3e81562dcd --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfigDb.py @@ -0,0 +1,4 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# from AthenaCommon.CfgGetter import addTool,addService,addAlgorithm +# addTool("FaserSiClusterizationTool.FaserSiClusterizationToolConf.FaserSCT_ClusteringTool", "FaserSCT_ClusteringTool") diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserCacheCreator.cxx b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserCacheCreator.cxx new file mode 100644 index 0000000000000000000000000000000000000000..09455d629e1f4650b250f6ec158acfc3eed09531 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserCacheCreator.cxx @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + + +#include "FaserCacheCreator.h" + +#include "TrackerIdentifier/FaserSCT_ID.h" + +#include "Identifier/IdentifierHash.h" +#include "AthViews/View.h" + +namespace Tracker +{ + + FaserCacheCreator::FaserCacheCreator(const std::string &name, ISvcLocator *pSvcLocator) : + AthReentrantAlgorithm(name,pSvcLocator), + m_sct_idHelper(nullptr), + m_disableWarningCheck(false) + { + } + + + StatusCode FaserCacheCreator::initialize(){ + ATH_CHECK( m_SCTclusterContainerCacheKey.initialize(!m_SCTclusterContainerCacheKey.key().empty()) ); + //ATH_CHECK( m_SCTSpacePointCacheKey.initialize(!m_SCTSpacePointCacheKey.key().empty()) ); + ATH_CHECK( m_SCTRDOCacheKey.initialize(!m_SCTRDOCacheKey.key().empty()) ); + ATH_CHECK(detStore()->retrieve(m_sct_idHelper, "FaserSCT_ID")); + return StatusCode::SUCCESS; + } + + FaserCacheCreator::~FaserCacheCreator() {} + + bool FaserCacheCreator::isInsideView(const EventContext& context) const + { + const IProxyDict* proxy = Atlas::getExtendedEventContext(context).proxy(); + const SG::View* view = dynamic_cast<const SG::View*>(proxy); + return view != nullptr; + } + + StatusCode FaserCacheCreator::execute (const EventContext& ctx) const + { + + if (!m_disableWarningCheck and !m_disableWarning.value()){ + if (isInsideView(ctx)){ + ATH_MSG_ERROR("FaserCacheCreator is running inside a view, this is probably a misconfiguration"); + return StatusCode::FAILURE; + } + m_disableWarningCheck = true; //only check once + } + + ATH_CHECK(createContainer(m_SCTclusterContainerCacheKey, m_sct_idHelper->wafer_hash_max(), ctx)); + + //ATH_CHECK(createContainer(m_SCTSpacePointCacheKey, m_sct_idHelper->wafer_hash_max(), ctx)); + + ATH_CHECK(createContainer(m_SCTRDOCacheKey, m_sct_idHelper->wafer_hash_max(), ctx)); + + + return StatusCode::SUCCESS; + } + +} \ No newline at end of file diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserCacheCreator.h b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserCacheCreator.h new file mode 100644 index 0000000000000000000000000000000000000000..b6534e8f941218645b558650bd1e8a5270063058 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserCacheCreator.h @@ -0,0 +1,82 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + + +/** + * @file FaserCacheCreator.h + */ + +#ifndef TRACKERPREPRAWDATAFORMATION_FASERCACHECREATOR +#define TRACKERPREPRAWDATAFORMATION_FASERCACHECREATOR + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerRawData/FaserSCT_RDO_Container.h" +// #include "FaserTrkSpacePoint/FaserSpacePointContainer.h" +#include "TrkSpacePoint/SpacePointContainer.h" + +#include "AthenaPoolUtilities/CondAttrListCollection.h" + +#include <atomic> + +class FaserSCT_ID; + +namespace Tracker +{ + class FaserCacheCreator : public AthReentrantAlgorithm + { + public: + + FaserCacheCreator(const std::string &name,ISvcLocator *pSvcLocator); + virtual ~FaserCacheCreator() ; + virtual StatusCode initialize () override; + virtual StatusCode execute (const EventContext& ctx) const override; + //No need for finalize + protected: + const FaserSCT_ID* m_sct_idHelper; + SG::WriteHandleKey<Tracker::FaserSCT_ClusterContainerCache> m_SCTclusterContainerCacheKey + {this, "SCT_ClusterKey", ""}; + SG::WriteHandleKey<SpacePointCache> m_SCTSpacePointCacheKey + {this, "SpacePointCacheSCT", ""}; + SG::WriteHandleKey<FaserSCT_RDO_Cache> m_SCTRDOCacheKey + {this, "SCTRDOCacheKey", ""}; + + BooleanProperty m_disableWarning{this, "DisableViewWarning", false}; + mutable std::atomic_bool m_disableWarningCheck; + //Temporary workarounds for problem in scheduler - remove later + bool isInsideView(const EventContext&) const; + template<typename T> + StatusCode createContainer(const SG::WriteHandleKey<T>& , long unsigned int , const EventContext& ) const; + + // template<typename T, typename X> + // StatusCode createValueContainer(const SG::WriteHandleKey<T>& containerKey, long unsigned int size, const EventContext& ctx, const X& defaultValue) const; + }; + + template<typename T> + StatusCode FaserCacheCreator::createContainer(const SG::WriteHandleKey<T>& containerKey, long unsigned int size, const EventContext& ctx) const{ + if(containerKey.key().empty()){ + ATH_MSG_DEBUG( "Creation of container "<< containerKey.key() << " is disabled (no name specified)"); + return StatusCode::SUCCESS; + } + SG::WriteHandle<T> ContainerCacheKey(containerKey, ctx); + ATH_CHECK( ContainerCacheKey.recordNonConst ( std::make_unique<T>(IdentifierHash(size), nullptr) )); + ATH_MSG_DEBUG( "Container "<< containerKey.key() << " created to hold " << size ); + return StatusCode::SUCCESS; + } + + // template<typename T, typename X> + // StatusCode FaserCacheCreator::createValueContainer(const SG::WriteHandleKey<T>& containerKey, long unsigned int size, const EventContext& ctx, const X& defaultValue) const{ + // static_assert(std::is_base_of<IdentifiableValueCache<X>, T>::value, "Expects a IdentifiableValueCache Class" ); + // if(containerKey.key().empty()){ + // ATH_MSG_DEBUG( "Creation of container "<< containerKey.key() << " is disabled (no name specified)"); + // return StatusCode::SUCCESS; + // } + // SG::WriteHandle<T> ContainerCacheKey(containerKey, ctx); + // ATH_CHECK( ContainerCacheKey.recordNonConst ( std::make_unique<T>(size, defaultValue) )); + // ATH_MSG_DEBUG( "ValueContainer "<< containerKey.key() << " created to hold " << size ); + // return StatusCode::SUCCESS; + // } + +} +#endif //TRACKERPREPRAWDATAFORMATION_FASERCACHECREATOR diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7061951d8b7272faf977740438fb14eb349f9300 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx @@ -0,0 +1,187 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/** @file SCT_Clusterization.cxx + * Implementation file for the SCT_Clusterization class. + * @author Paul Bell, Tommaso Lari, Shaun Roe, Carl Gwilliam + * @date 08 July 2008 + */ + +#include "FaserSCT_Clusterization.h" + +#include "FaserDetDescr/FaserDetectorID.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +// #include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +// #include "TrackerRawData/TrackerClusterContainer.h" +#include "TrackerRawData/FaserSCT_RDO_Container.h" +#include "TrackerRawData/FaserSCT_RDORawData.h" +#include "FaserSiClusterizationTool/IFaserSCT_ClusteringTool.h" +#include "StoreGate/WriteHandle.h" + +namespace Tracker +{ + +static const std::string moduleFailureReason{"FaserSCT_Clusterization: Exceeds max fired strips"}; + +// Constructor with parameters: +FaserSCT_Clusterization::FaserSCT_Clusterization(const std::string& name, ISvcLocator* pSvcLocator) : + AthReentrantAlgorithm(name, pSvcLocator), + m_idHelper{nullptr} +{ + // // // Get parameter values from jobOptions file + declareProperty("ClusterContainerCacheKey", m_clusterContainerCacheKey=""); +} + +// Initialize method: +StatusCode FaserSCT_Clusterization::initialize() { + ATH_MSG_INFO("FaserSCT_Clusterization::initialize()!"); + + // Get the conditions summary service (continue anyway, just check the pointer + // later and declare everything to be 'good' if it is NULL) + if (m_checkBadModules.value()) { + ATH_MSG_INFO("Clusterization has been asked to look at bad module info"); + // ATH_CHECK(m_pSummaryTool.retrieve()); + } else { + // m_pSummaryTool.disable(); + } + + // m_clusterContainerLinkKey = m_clusterContainerKey.key(); + + ATH_CHECK(m_rdoContainerKey.initialize()); + ATH_CHECK(m_clusterContainerKey.initialize()); + ATH_CHECK(m_clusterContainerLinkKey.initialize()); + ATH_CHECK(m_clusterContainerCacheKey.initialize(not m_clusterContainerCacheKey.key().empty())); + ATH_CHECK(m_flaggedCondDataKey.initialize()); + + // Get the clustering tool + ATH_CHECK(m_clusteringTool.retrieve()); + + // Get the SCT ID helper + ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID")); + + return StatusCode::SUCCESS; +} + +// Execute method: +StatusCode FaserSCT_Clusterization::execute(const EventContext& ctx) const { + ++m_numberOfEvents; + // Register the IdentifiableContainer into StoreGate + SG::WriteHandle<Tracker::FaserSCT_ClusterContainer> clusterContainer{m_clusterContainerKey, ctx}; + if (m_clusterContainerCacheKey.key().empty()) { + ATH_CHECK(clusterContainer.record(std::make_unique<Tracker::FaserSCT_ClusterContainer>(m_idHelper->wafer_hash_max()))); + } else { + SG::UpdateHandle<Tracker::FaserSCT_ClusterContainerCache> clusterContainercache{m_clusterContainerCacheKey, ctx}; + ATH_CHECK(clusterContainer.record(std::make_unique<Tracker::FaserSCT_ClusterContainer>(clusterContainercache.ptr()))); + } + ATH_MSG_DEBUG("Container '" << clusterContainer.name() << "' initialised"); + + ATH_CHECK(clusterContainer.symLink(m_clusterContainerLinkKey)); + ATH_CHECK(clusterContainer.isValid()); + ATH_MSG_DEBUG("FaserSCT clusters '" << clusterContainer.name() << "' symlinked in StoreGate"); + + SG::WriteHandle<SCT_FlaggedCondData> flaggedCondData{m_flaggedCondDataKey, ctx}; + ATH_CHECK(flaggedCondData.record(std::make_unique<SCT_FlaggedCondData>())); + + // First, we have to retrieve and access the container, not because we want to + // use it, but in order to generate the proxies for the collections, if they + // are being provided by a container converter. + SG::ReadHandle<FaserSCT_RDO_Container> rdoContainer{m_rdoContainerKey, ctx}; + ATH_CHECK(rdoContainer.isValid()); + + // Anything to dereference the DataHandle will trigger the converter + FaserSCT_RDO_Container::const_iterator rdoCollections{rdoContainer->begin()}; + FaserSCT_RDO_Container::const_iterator rdoCollectionsEnd{rdoContainer->end()}; + bool dontDoClusterization{false}; + //new code to remove large numbers of hits (what is large?) + if (m_maxTotalOccupancyPercent.value()!=100) { + constexpr unsigned int totalNumberOfChannels{110592}; + const unsigned int maxAllowableStrips{(totalNumberOfChannels*m_maxTotalOccupancyPercent.value())/100};//integer arithmetic, should be ok + unsigned int totalFiredStrips{0}; + for (; rdoCollections != rdoCollectionsEnd; ++rdoCollections) { + for (const FaserSCT_RDORawData* rdo: **rdoCollections) { + totalFiredStrips += rdo->getGroupSize(); + } + } //iterator is now at the end + //reset the iterator + rdoCollections = rdoContainer->begin(); + if (totalFiredStrips > maxAllowableStrips) { + ATH_MSG_WARNING("This event has too many hits in the FaserSCT: " << totalFiredStrips << " > " << maxAllowableStrips); + dontDoClusterization = true; + } + } + if (not dontDoClusterization) { + for (; rdoCollections != rdoCollectionsEnd; ++rdoCollections) { + ++m_numberOfRDOCollection; + const TrackerRawDataCollection<FaserSCT_RDORawData>* rd{*rdoCollections}; + ATH_MSG_DEBUG("RDO collection size=" << rd->size() << ", Hash=" << rd->identifyHash()); + Tracker::FaserSCT_ClusterContainer::IDC_WriteHandle lock{clusterContainer->getWriteHandle(rdoCollections.hashId())}; + if (lock.alreadyPresent()) { + ATH_MSG_DEBUG("Item already in cache , Hash=" << rd->identifyHash()); + continue; + } + bool goodModule{m_checkBadModules.value() && false? m_pSummaryTool->isGood(rd->identifyHash()) : true}; + // Check the RDO is not empty and that the wafer is good according to the conditions + if ((not rd->empty()) && goodModule ) { + // If more than a certain number of RDOs set module to bad + if (m_maxFiredStrips.value()) { + unsigned int nFiredStrips{0}; + for (const FaserSCT_RDORawData* rdo: *rd) { + ++m_numberOfRDO; + nFiredStrips += rdo->getGroupSize(); + } + if (nFiredStrips > m_maxFiredStrips.value()) { + flaggedCondData->insert(std::make_pair(rd->identifyHash(), moduleFailureReason)); + continue; + } + } + // Use one of the specific clustering AlgTools to make clusters + //FaserSCT_ClusterCollection* clusterCollection{m_clusteringTool->clusterize(*rd, *m_idHelper)}; + std::unique_ptr<FaserSCT_ClusterCollection> clusterCollection{m_clusteringTool->clusterize(*rd, *m_idHelper)}; + if (clusterCollection) { + if (not clusterCollection->empty()) { + ++m_numberOfClusterCollection; + const IdentifierHash hash{clusterCollection->identifyHash()}; + ATH_MSG_DEBUG("Clusters with key '" << hash << "' added to Container\n"); + ATH_MSG_DEBUG("Clusters size " <<clusterCollection->size()<< "' added to Container\n"); + Tracker::FaserSCT_ClusterCollection::const_iterator clustersNext = clusterCollection->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator clustersFinish = clusterCollection->end(); + for (; clustersNext!=clustersFinish; clustersNext++){ + ++m_numberOfCluster; + ATH_MSG_DEBUG("Clusters information"); + ATH_MSG_DEBUG("Clusters " <<(*clustersNext)<< "' added to Container\n"); + // (*clustersNext)->dump(msg(MSG::INFO)) ; + } + + //Using get because I'm unsure of move semantec status + ATH_CHECK(lock.addOrDelete(std::move(clusterCollection))); + + } else { + ATH_MSG_DEBUG("Don't write empty collections\n"); + } + } else { + ATH_MSG_DEBUG("Clustering algorithm found no clusters\n"); + } + //} + } + } + } + // Set container to const + ATH_CHECK(clusterContainer.setConst()); + ATH_MSG_DEBUG("clusterContainer->numberOfCollections() " << clusterContainer->numberOfCollections()); + return StatusCode::SUCCESS; +} + +// Finalize method: +StatusCode FaserSCT_Clusterization::finalize() +{ + ATH_MSG_INFO("FaserSCT_Clusterization::finalize()"); + ATH_MSG_INFO( m_numberOfEvents << " events processed" ); + ATH_MSG_INFO( m_numberOfRDOCollection << " RDO collections processed" ); + ATH_MSG_INFO( m_numberOfRDO<< " RawData" ); + ATH_MSG_INFO( m_numberOfClusterCollection<< " cluster collections generated" ); + ATH_MSG_INFO( m_numberOfCluster<< " cluster generated" ); + + return StatusCode::SUCCESS; +} +} \ No newline at end of file diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.h b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.h new file mode 100644 index 0000000000000000000000000000000000000000..790e4aee22c55a3c6f1ec25a0475faa9178b5494 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.h @@ -0,0 +1,93 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/** @file SCT_Clusterization + * Header file for the SCT_Clusterization class (an Algorithm). + * @author Paul Bell, Tommaso Lari, Shaun Roe, Carl Gwilliam + * @date 08 July 2008 + */ + +#ifndef FASERSCTCLUSTERIZATION_FASERSCT_CLUSTERIZATION_H +#define FASERSCTCLUSTERIZATION_FASERSCT_CLUSTERIZATION_H + +// Base class +#include "AthenaBaseComps/AthReentrantAlgorithm.h" + +////Next contains a typedef so cannot be fwd declared +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerPrepRawData/TrackerClusterContainer.h" +#include "TrackerRawData/FaserSCT_RDO_Container.h" +#include "SCT_ConditionsData/SCT_FlaggedCondData.h" + +#include "InDetConditionsSummaryService/IInDetConditionsTool.h" +#include "FaserSiClusterizationTool/IFaserSCT_ClusteringTool.h" + +//Gaudi +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +//STL +#include <map> +#include <string> + +class FaserSCT_ID; +class ISvcLocator; +class StatusCode; + +namespace Tracker +{ + +/** + * @class SCT_Clusterization + * @brief Form clusters from SCT Raw Data Objects + * The class loops over an RDO grouping strips and creating collections of clusters, subsequently recorded in StoreGate + * Uses SCT_ConditionsTools to determine which strips to include. + */ +class FaserSCT_Clusterization : public AthReentrantAlgorithm { + public: + /// Constructor with parameters: + FaserSCT_Clusterization(const std::string& name, ISvcLocator* pSvcLocator); + + /** @name Usual algorithm methods */ + //@{ + ///Retrieve the tools used and initialize variables + virtual StatusCode initialize() override; + ///Form clusters and record them in StoreGate (detector store) + virtual StatusCode execute(const EventContext& ctx) const override; + ///Clean up and release the collection containers + virtual StatusCode finalize() override; + //Make this algorithm clonable. + virtual bool isClonable() const override { return true; }; + //@} + + private: + /** @name Disallow default instantiation, copy, assignment */ + //@{ + FaserSCT_Clusterization() = delete; + FaserSCT_Clusterization(const FaserSCT_Clusterization&) = delete; + FaserSCT_Clusterization &operator=(const FaserSCT_Clusterization&) = delete; + //@} + + ToolHandle<IFaserSCT_ClusteringTool> m_clusteringTool{this, "SCT_ClusteringTool", "FaserSCT_ClusteringTool"}; + ToolHandle<IInDetConditionsTool> m_pSummaryTool{this, "conditionsTool", "SCT_ConditionsSummaryTool/InDetSCT_ConditionsSummaryTool", "Tool to retrieve SCT conditions summary"}; + const FaserSCT_ID* m_idHelper; + + SG::ReadHandleKey<FaserSCT_RDO_Container> m_rdoContainerKey{this, "DataObjectName", "FaserSCT_RDOs", "FaserSCT RDOs"}; + SG::WriteHandleKey<FaserSCT_ClusterContainer> m_clusterContainerKey{this, "ClustersName", "SCT_ClusterContainer", "FaserSCT cluster container"}; + SG::WriteHandleKey<TrackerClusterContainer> m_clusterContainerLinkKey{this, "ClustersLinkName_", "SCT_ClusterContainer", "Tracker cluster container link name (don't set this)"}; + SG::WriteHandleKey<SCT_FlaggedCondData> m_flaggedCondDataKey{this, "SCT_FlaggedCondData", "SCT_FlaggedCondData", "SCT flagged conditions data"}; + SG::UpdateHandleKey<FaserSCT_ClusterContainerCache> m_clusterContainerCacheKey; + + UnsignedIntegerProperty m_maxFiredStrips{this, "maxFiredStrips", 384, "Threshold of number of fired strips per wafer"}; // 0 disables the per-wafer cut + UnsignedIntegerProperty m_maxTotalOccupancyPercent{this, "maxTotalOccupancyInPercent", 100, "Threshold of percentage of fired strips for the whole SCT"}; // 100 disables the whole SCT cut + BooleanProperty m_checkBadModules{this, "checkBadModules", false}; + + mutable std::atomic<int> m_numberOfEvents{0}; + mutable std::atomic<int> m_numberOfRDOCollection{0}; + mutable std::atomic<int> m_numberOfRDO{0}; + mutable std::atomic<int> m_numberOfClusterCollection{0}; + mutable std::atomic<int> m_numberOfCluster{0}; +}; +} +#endif // INDETRIOMAKER_SCT_CLUSTERIZATION_H diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/components/TrackerPrepRawDataFormation_entries.cxx b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/components/TrackerPrepRawDataFormation_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f8debcc6a2949af892f9cbb75a3660450e759d4a --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/components/TrackerPrepRawDataFormation_entries.cxx @@ -0,0 +1,5 @@ +#include "../FaserSCT_Clusterization.h" +#include "../FaserCacheCreator.h" + +DECLARE_COMPONENT( Tracker::FaserSCT_Clusterization ) +DECLARE_COMPONENT( Tracker::FaserCacheCreator ) diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbg.py b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbg.py new file mode 100644 index 0000000000000000000000000000000000000000..53d79d195e168ddc2860b0279805d0d7f3ead22e --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/test/FaserSCT_ClusterizationDbg.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +"""Test various ComponentAccumulator Digitization configuration modules + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.TestDefaults import defaultTestFiles +from AthenaConfiguration.MainServicesConfig import MainServicesSerialCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg + +# Set up logging and new style config +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +# Configure +ConfigFlags.Input.Files = ['myRDO.pool.root'] +ConfigFlags.Output.RDOFileName = "myRDO_cluster.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX" +ConfigFlags.GeoModel.Align.Dynamic = False +ConfigFlags.Concurrency.NumThreads = 1 +ConfigFlags.Beam.NumberOfCollisions = 0. +#ConfigFlags.Detector.SimulateFaserSCT = True + +ConfigFlags.GeoModel.FaserVersion = "FASER-00" # Always needed +ConfigFlags.GeoModel.AtlasVersion = "ATLAS-R2-2016-01-00-01" # Always needed to fool autoconfig; value ignored + +ConfigFlags.lock() + +# Core components +acc = MainServicesSerialCfg() +acc.merge(PoolReadCfg(ConfigFlags)) +acc.merge(PoolWriteCfg(ConfigFlags)) + +#acc.merge(writeDigitizationMetadata(ConfigFlags)) + +# Inner Detector +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) + +# Output Stream customization +# oStream = acc.getEventAlgo("OutputStreamRDO") +# oStream.ItemList += ["EventInfo#*", +# "McEventCollection#TruthEvent", +# "McEventCollection#GEN_EVENT", +# "Tracker::FaserSCT_ClusterContainer#*" +# ] + +# Timing +#acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + +# Dump config +logging.getLogger('forcomps').setLevel(VERBOSE) +acc.foreach_component("*").OutputLevel = VERBOSE +acc.foreach_component("*ClassID*").OutputLevel = INFO +acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +acc.getService("StoreGateSvc").Dump = True +acc.getService("ConditionStore").Dump = True +acc.printConfig(withDetails=True) +ConfigFlags.dump() +# Execute and finish +sc = acc.run(maxEvents=-1) +# Success should be 0 +sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/CMakeLists.txt b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3d274e74d695995067a258ebe1428142e79d728f --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/CMakeLists.txt @@ -0,0 +1,44 @@ +################################################################################ +# Package: TrackerSpacePointFormation +################################################################################ + +# Declare the package name: +atlas_subdir( TrackerSpacePointFormation ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + Control/AthenaMonitoringKernel + Control/AthContainers + DetectorDescription/GeoPrimitives + DetectorDescription/Identifier + GaudiKernel + Tracker/TrackerDetDescr/TrackerReadoutGeometry + Tracker/TrackerRecEvent/TrackerPrepRawData + Tracker/TrackerRecEvent/TrackerSpacePoint + Tracker/TrackerRecTools/FaserSiSpacePointTool +# Tracking/TrkEvent/VxVertex + PRIVATE + DetectorDescription/FaserDetDescr + Event/xAOD/xAODEventInfo + Tracker/TrackerDetDescr/TrackerIdentifier + Tracking/TrkEvent/TrkSpacePoint ) + +# External dependencies: +find_package( Eigen ) + +# Component(s) in the package: +#atlas_add_library( TrackerSpacePointFormationLib +# src/*.cxx src/*.h +# PUBLIC_HEADERS TrackerSpacePointMakerAlg +# INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} +# LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel TrackerReadoutGeometry TrackerPrepRawData TrackerSpacePoint AthenaMonitoringKernelLib +# PRIVATE_LINK_LIBRARIES FaserDetDescr xAODEventInfo TrackerIdentifier ) + +atlas_add_component( TrackerSpacePointFormation + src/components/*.cxx src/*.cxx src/*.h + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel TrackerReadoutGeometry TrackerPrepRawData TrackerSpacePoint AthenaMonitoringKernelLib FaserDetDescr xAODEventInfo TrackerIdentifier FaserSiSpacePointToolLib TrkSpacePoint ) + +atlas_install_python_modules( python/*.py ) +atlas_install_scripts( test/*.py ) diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfig.py b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..014ff6e2851b32acadff54a01f39e5f8bd4093a0 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfig.py @@ -0,0 +1,93 @@ +"""Define methods to construct configured SCT Digitization tools and algorithms + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from TrackerSpacePointFormation.TrackerSpacePointFormationConf import Tracker__TrackerSpacePointFinder, Tracker__StatisticsAlg, TrackerDD__SiElementPropertiesTableCondAlg +PileUpXingFolder=CompFactory.PileUpXingFolder + +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +#SCT_RadDamageSummaryTool=CompFactory.SCT_RadDamageSummaryTool +from FaserGeoModel.SCTGMConfig import SctGeometryCfg + +#from FaserSCT_ConditionsTools.FaserSCT_DCSConditionsConfig import FaserSCT_DCSConditionsCfg +#from FaserSCT_ConditionsTools.FaserSCT_DCSConditionsConfig import FaserSCT_DCSConditionsToolCfg +from AthenaCommon.AlgSequence import AthSequencer +condSeq = AthSequencer("AthCondSeq") +condSeq += TrackerDD__SiElementPropertiesTableCondAlg(name = "SiElementPropertiesTableCondAlg") +from GaudiSvc.GaudiSvcConf import THistSvc +histSvc= THistSvc() +histSvc.Output += [ "StatisticsAlg DATAFILE='statistics.root' OPT='RECREATE'" ] + + + +def TrackerDDSiElementPropertiesTableCondAlgCfg(flags, **kwargs): + acc = ComponentAccumulator() + acc.addCondAlgo(CompFactory.TrackerDD__SiElementPropertiesTableCondAlg(name = "TrackerDDSiElementPropertiesTableCondAlg", **kwargs)) + return acc + + +def TrackerSpacePointMakerCommonCfg(flags, name="TrackerSpacePointMakerTool", **kwargs): + """Return ComponentAccumulator with common FaserSCT Clusterization tool config""" + acc = SctGeometryCfg(flags) + + kwargs.setdefault("InputObjectName", "SCT_ClusterContainer") + from FaserSiSpacePointTool.FaserSiSpacePointToolConf import Tracker__TrackerSpacePointMakerTool +# fieldSvc = acc.getService("FaserFieldSvc") + trackerSpacePointMakerTool = Tracker__TrackerSpacePointMakerTool(name) + # attach ToolHandles + acc.setPrivateTools(trackerSpacePointMakerTool) + return acc + + +def TrackerSpacePointMakerToolCfg(flags, name="TrackerSpacePointMakerTool", **kwargs): + """Return ComponentAccumulator with configured TrackerSpacePointMakerTool""" + #kwargs.setdefault("HardScatterSplittingMode", 0) + return TrackerSpacePointMakerCommonCfg(flags, name, **kwargs) + + +def TrackerSpacePointFinderBasicCfg(flags, **kwargs): + """Return ComponentAccumulator for TrackerSpacePointFinder""" + acc = ComponentAccumulator() + finderTool = acc.popToolsAndMerge(TrackerSpacePointMakerToolCfg(flags)) + kwargs.setdefault("SpacePointFinderTool", finderTool) + kwargs.setdefault("SCT_ClustersName", "SCT_ClusterContainer") + kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer") + kwargs.setdefault("SpacePointsOverlapName", "SCT_SpacePointOverlapCollection") + # kwargs.setdefault("SCT_FlaggedCondData", "SCT_Flags"); + acc.addEventAlgo(Tracker__TrackerSpacePointFinder(**kwargs)) + return acc + +def StatisticsBasicCfg(flags, **kwargs): + """Return ComponentAccumulator for TrackerSpacePointMakerAlg""" + acc = ComponentAccumulator() + acc.popToolsAndMerge(TrackerSpacePointMakerToolCfg(flags)) + kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer") + acc.addEventAlgo(Tracker__StatisticsAlg(**kwargs)) + return acc + +def TrackerSpacePointFinder_OutputCfg(flags): + """Return ComponentAccumulator with Output for SCT. Not standalone.""" + acc = ComponentAccumulator() + # ItemList = ["SpacePointContainer#*"] + ItemList = [""] + acc.merge(OutputStreamCfg(flags, "RDO", ItemList)) + ostream = acc.getEventAlgo("OutputStreamRDO") + ostream.TakeItemsFromInput=True + return acc + +# with output defaults +def TrackerSpacePointFinderCfg(flags, **kwargs): + """Return ComponentAccumulator for SCT SpacePoints and Output""" + acc=TrackerDDSiElementPropertiesTableCondAlgCfg(flags) + acc.merge(TrackerSpacePointFinderBasicCfg(flags, **kwargs)) + acc.merge(TrackerSpacePointFinder_OutputCfg(flags)) + return acc + +def StatisticsCfg(flags, **kwargs): + #acc=ComponentAccumulator(flags) + acc=StatisticsBasicCfg(flags, **kwargs) + acc.addService(histSvc) + acc.merge(TrackerSpacePointFinder_OutputCfg(flags)) + return acc diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfigDb.py b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfigDb.py new file mode 100644 index 0000000000000000000000000000000000000000..a8480a5c32793f3082a197a0e6e5ba5192ed8fad --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfigDb.py @@ -0,0 +1,4 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# from AthenaCommon.CfgGetter import addTool,addService,addAlgorithm +# addTool("FaserSiSpacePointTool.FaserSiSpacePointToolConf.TrackerSpacePointMakerTool", "TrackerSpacePointMakerTool") diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementProperties.cxx b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementProperties.cxx new file mode 100755 index 0000000000000000000000000000000000000000..30c940510ab564e97df26b6d31ec8856d8c62a6e --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementProperties.cxx @@ -0,0 +1,67 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + + ------------------- + ATLAS Collaboration + ***************************************************************************/ + +#include "Identifier/Identifier.h" +#include "SiElementProperties.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +namespace TrackerDD{ +SiElementProperties::SiElementProperties(const IdentifierHash& idHash, + const FaserSCT_ID& idHelper, + const TrackerDD::SiDetectorElement& element, + float epsilonWidth) : m_neighbours(),m_halfWidth(0) + +{ + // construct vector of neighbours of this wafer. + Identifier compact; + IdContext idCntxt(idHelper.wafer_context()); + + int res = idHelper.get_id(idHash,compact, &idCntxt); + if (res) return; // cannot convert + + //if (idHelper.side(compact)==0) return; + // if it is the stereo side do nothing + if (element.isStereo()) return; + IdentifierHash otherHash; + IdentifierHash neighbourHash; + + res = idHelper.get_other_side(idHash, otherHash); + if (res==0) m_neighbours.push_back(otherHash); + res = idHelper.get_prev_in_phi(otherHash, neighbourHash); + if (res==0) m_neighbours.push_back(neighbourHash); + res = idHelper.get_next_in_phi(otherHash, neighbourHash); + if (res==0) m_neighbours.push_back(neighbourHash); + + // These neighbours are only defined for barrel, and may fail + // because wafer is at one of the ends + //if (idHelper.is_barrel(compact)) + { + res = idHelper.get_prev_in_eta(otherHash, neighbourHash); + if (res ==0) + m_neighbours.push_back(neighbourHash); + res = idHelper.get_next_in_eta(otherHash, neighbourHash ); + if (res ==0) + m_neighbours.push_back(neighbourHash); + } + + // Find half width of wafer at centre + + m_halfWidth = (element.design().minWidth()+element.design().maxWidth())/4 + + epsilonWidth; // add a bit for safety. +} + +//------------------------------------------------------------------------- +SiElementProperties::~SiElementProperties() +{} + +} +//---------------------------------------------------------------------------- + diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementProperties.h b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementProperties.h new file mode 100755 index 0000000000000000000000000000000000000000..b174593efdab922da9a7fb2d7c682ff074b42950 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementProperties.h @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + This class contains some element properties that are used in +SiSpacePointFormation + : ie the wafer widths and wafer neighbours. These are cached during + SiSpacePointFormation initialization for the sake of efficiency. + + ATLAS Collaboration + ***************************************************************************/ + +#ifndef TRACKERSPACEPOINTMAKERALG_SIELEMENTPROPERTIES_H +#define TRACKERSPACEPOINTMAKERALG_SIELEMENTPROPERTIES_H + +#include <vector> +#include "Identifier/IdentifierHash.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +class FaserSCT_ID; + + +namespace TrackerDD{ +class SiElementProperties + +{ +public: + + SiElementProperties(const IdentifierHash& idHash, + const FaserSCT_ID& idHelper, + const TrackerDD::SiDetectorElement& element, + float epsilonWidth); + + ~SiElementProperties(); + + const std::vector<IdentifierHash>* neighbours (void); + float halfWidth (void); + +private: + std::vector<IdentifierHash> m_neighbours; + float m_halfWidth; + +}; + + + +//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> + + +//-------------------------------------------------------------------------- +inline const std::vector<IdentifierHash>* +SiElementProperties::neighbours() +{ + return &m_neighbours; +} + +//---------------------------------------------------------------------------- +inline float +SiElementProperties::halfWidth() +{ + return m_halfWidth; +} + +//---------------------------------------------------------------------------- + +} +#endif // TRACKERSPACEPOINTMAKERALG_SIELEMENTPROPERTIES_H diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTable.cxx b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTable.cxx new file mode 100755 index 0000000000000000000000000000000000000000..fc847c953f5de5f0ac596fc44daa565edd81ee4a --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTable.cxx @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + + ------------------- + ATLAS Collaboration + ***************************************************************************/ + +#include "SiElementPropertiesTable.h" + +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerReadoutGeometry/SiDetectorDesign.h" +#include "TrackerReadoutGeometry/SiLocalPosition.h" + +namespace TrackerDD{ +SiElementPropertiesTable::SiElementPropertiesTable(const FaserSCT_ID& idHelper, + const TrackerDD::SiDetectorElementCollection& elements, + float epsilonWidth) + { + size_t maxSCT = idHelper.wafer_hash_max(); + m_properties.assign(maxSCT, nullptr); + for (size_t i = 0; i < maxSCT; ++i){ + IdentifierHash hash(i); + const TrackerDD::SiDetectorElement* element = elements[hash]; + if (element != 0){ + SiElementProperties* props = new SiElementProperties(hash, idHelper,*element,epsilonWidth); + m_properties[i] = props; + } + } +} +//-------------------------------------------------------------------------- + +SiElementPropertiesTable::~SiElementPropertiesTable(){ + size_t maxSCT = m_properties.size(); + for (size_t i=0; i < maxSCT; ++i){ + delete m_properties[i];m_properties[i] =0; + } +} +} +//-------------------------------------------------------------------------- + diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTable.h b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTable.h new file mode 100755 index 0000000000000000000000000000000000000000..9d123122fc717d9ab0a13e7fe92193ea4e1b1589 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTable.h @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Stores properties that are needed in SiSpacePointFinder. + -------------------------------------------------------- + ATLAS Collaboration + ***************************************************************************/ + +// $Id: SiElementPropertiesTable.h,v 1.3 2009-01-07 17:50:36 markuse Exp $ + +#ifndef TRACKERSPACEPOINTMAKERALG_SIELEMENTPROPERTIESTABLE_H +#define TRACKERSPACEPOINTMAKERALG_SIELEMENTPROPERTIESTABLE_H + +#include "SiElementProperties.h" + +#include "Identifier/IdentifierHash.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" + +#include <vector> + + +namespace TrackerDD{ +class SiElementPropertiesTable final +{ +public: + + SiElementPropertiesTable(const FaserSCT_ID& idHelper, + const TrackerDD::SiDetectorElementCollection& elements, + float epsilonWidth); + ~SiElementPropertiesTable(); + + const std::vector<IdentifierHash>* neighbours(const IdentifierHash& waferID) const; + float halfWidth(IdentifierHash hashID) const; + +private: + std::vector<SiElementProperties*> m_properties; + +}; + + +inline const std::vector<IdentifierHash>* +SiElementPropertiesTable::neighbours(const IdentifierHash& waferID) const +{ + return (m_properties[(unsigned int)waferID])->neighbours(); +} + +inline float +SiElementPropertiesTable::halfWidth(IdentifierHash waferID) const +{ + return (m_properties[(unsigned int)waferID])->halfWidth(); +} + +} + +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF( TrackerDD::SiElementPropertiesTable , 175393198, 1 ) +#include "AthenaKernel/CondCont.h" +CONDCONT_DEF( TrackerDD::SiElementPropertiesTable , 247356960); + +#endif // TRACKERSPACEPOINTMAKERALG_SIELEMENTPROPERTIESTABLE_H diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTableCondAlg.cxx b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTableCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ab8dc4a489bf922b2840e3c775640cef42986d88 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTableCondAlg.cxx @@ -0,0 +1,94 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "SiElementPropertiesTableCondAlg.h" + +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +#include <memory> + +namespace TrackerDD { + + SiElementPropertiesTableCondAlg::SiElementPropertiesTableCondAlg(const std::string& name, ISvcLocator* pSvcLocator) + : ::AthReentrantAlgorithm(name, pSvcLocator) + , m_condSvc{"CondSvc", name} +{ +} + + StatusCode SiElementPropertiesTableCondAlg::initialize() + { + ATH_MSG_DEBUG("initialize " << name()); + + // Read Handle + ATH_CHECK(m_readKey.initialize()); + + // Write Handle + ATH_CHECK(m_writeKey.initialize()); + // CondSvc + ATH_CHECK(m_condSvc.retrieve()); + // Register write handle + ATH_CHECK(m_condSvc->regHandle(this, m_writeKey)); + + ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID")); + + return StatusCode::SUCCESS; + } + + StatusCode SiElementPropertiesTableCondAlg::execute(const EventContext& ctx) const + { + ATH_MSG_DEBUG("execute " << name()); + + // ____________ Construct Write Cond Handle and check its validity ____________ + SG::WriteCondHandle<SiElementPropertiesTable> writeHandle{m_writeKey, ctx}; + + // Do we have a valid Write Cond Handle for current time? + if (writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." + << ". In theory this should not be called, but may happen" + << " if multiple concurrent events are being processed out of order."); + return StatusCode::SUCCESS; + } + + // ____________ Get Read Cond Object ____________ + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> readHandle{m_readKey, ctx}; + const TrackerDD::SiDetectorElementCollection* readCdo{*readHandle}; + if (readCdo==nullptr) { + ATH_MSG_FATAL("Null pointer to the read conditions object of " << m_readKey.key()); + return StatusCode::FAILURE; + } + + // Define validity of the output cond object and record it + EventIDRange rangeW; + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } + + // ____________ Construct new Write Cond Object ____________ + std::unique_ptr<SiElementPropertiesTable> writeCdo{std::make_unique<SiElementPropertiesTable>(*m_idHelper, *readCdo, m_epsWidth)}; + + // ____________ Fill writeCdo using readCdo ____________ + + // Record WriteCondHandle + if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) { + ATH_MSG_FATAL("Could not record " << writeHandle.key() + << " with EventRange " << rangeW + << " into Conditions Store"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into ConditionStore"); + + return StatusCode::SUCCESS; + } + + StatusCode SiElementPropertiesTableCondAlg::finalize() + { + ATH_MSG_DEBUG("finalize " << name()); + + return StatusCode::SUCCESS; + } + +} + diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTableCondAlg.h b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTableCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..d749b9790076ea63746f0bb09e6bdc86a7b169d0 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/SiElementPropertiesTableCondAlg.h @@ -0,0 +1,86 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TrackerDDSiElementPropertiesTableCondAlg_h +#define TrackerDDSiElementPropertiesTableCondAlg_h + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/WriteCondHandleKey.h" + +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "SiElementPropertiesTable.h" + +#include "GaudiKernel/ICondSvc.h" + +class FaserSCT_ID; +namespace TrackerDD { + + /** + * @class SiElementPropertiesTableCondAlg + * This class is a condition algorithm and inherits AthReentrantAlgorithm. + * This class reads SCT_DetectorElementCollection from condition store, + * prepares SCT "neighbours" using SCT_ElementPropertiesTable class, + * register it in condition store. + * The created SCT_ElementPropertiesTable object in condition store + * is used by SiTrackerSpacePointFinder. + */ + + class SiElementPropertiesTableCondAlg : public AthReentrantAlgorithm { + public: + /** + * @name Methods of AthReentrantAlgorithm + */ + //@{ + SiElementPropertiesTableCondAlg(const std::string& name, ISvcLocator* pSvcLocator); +// virtual ~SiElementPropertiesTableCondAlg() override = default; + + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + virtual StatusCode finalize() override; + + /** Make this algorithm clonable. */ + virtual bool isClonable() const override { return true; }; + //@} + + private: + /** + * @name Input data using SG::ReadCondHandleKey + */ + //@{ + SG::ReadCondHandleKey<SiDetectorElementCollection> m_readKey{this, "ReadKey", "SCT_DetectorElementCollection", "Key of input SiDetectorElementCollection for SCT"}; + //@} + + /** + * @name Output data using SG::WriteCondHandleKey + */ + //@{ + SG::WriteCondHandleKey<SiElementPropertiesTable> m_writeKey{this, "WriteKey", "SCT_ElementPropertiesTable", "Key of output SiElementPropertiesTable for SCT"}; + //@} + + /** + * @name Parameter for SiElementPropertiesTable and SiElementProperties + */ + //@{ + FloatProperty m_epsWidth{this, "EpsWidth", 0.02, "Safety margin for half-widths, in cm"}; + //@} + + /** + * @name Service + */ + //@{ + ServiceHandle<ICondSvc> m_condSvc; //!< For SG::WriteCondHandle + //@} + + /** + * @name Id helper + */ + //@{ + const FaserSCT_ID* m_idHelper{nullptr}; + //@} + }; + + +} +#endif // SiElementPropertiesTableCondAlg_h diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx new file mode 100755 index 0000000000000000000000000000000000000000..37db71adedb02ef02b6eee58a372c45a58a47b23 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx @@ -0,0 +1,211 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/*************************************************************************** + ------------------- + ATLAS Collaboration + ***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> + + +#include "StatisticsAlg.h" + +// For processing clusters +#include "TrackerReadoutGeometry/SiLocalPosition.h" +#include "TrackerReadoutGeometry/SiDetectorDesign.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +// Space point Classes, +// #include "TrkSpacePoint/SpacePointContainer.h" +// #include "TrackerSpacePoint/TrackerSpacePointCLASS_DEF.h" +#include "TrackerIdentifier/FaserSCT_ID.h" + + +// general Atlas classes +#include "FaserDetDescr/FaserDetectorID.h" +#include "xAODEventInfo/EventInfo.h" +#include "StoreGate/ReadCondHandle.h" + +#include "AthenaMonitoringKernel/Monitored.h" + +namespace Tracker +{ +//------------------------------------------------------------------------ +StatisticsAlg::StatisticsAlg(const std::string& name, + ISvcLocator* pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator) + , m_hist_x(0) + , m_hist_y(0) + , m_hist_z(0) + , m_hist_r(0) + , m_hist_phi(0) + , m_hist_eta(0) + , m_hist_layer(0) + , m_hist_strip(0) + , m_hist_station(0) + , m_hist_x_y_plane0(0) + , m_hist_x_y_plane1(0) + , m_hist_x_y_plane2(0) + , m_hist_x_y_plane3(0) + , m_hist_x_y_plane4(0) + , m_hist_x_y_plane5(0) + , m_hist_x_y_plane6(0) + , m_hist_x_y_plane7(0) + , m_hist_x_y_plane8(0) + , m_thistSvc("THistSvc", name) +{ +} + +//----------------------------------------------------------------------- +StatusCode StatisticsAlg::initialize() +{ + ATH_MSG_DEBUG( "StatisticsAlg::initialize()" ); + + CHECK(m_thistSvc.retrieve()); + // Check that clusters, space points and ids have names + if ( m_Sct_spcontainerKey.key().empty()){ + ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_Sct_spcontainerKey.initialize() ); + + // create containers (requires the Identifier Helpers) + ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); + + // Initialize the key of input SiElementPropertiesTable and SiDetectorElementCollection for SCT + ATH_CHECK(m_SCTDetEleCollKey.initialize()); + + + m_hist_x=new TH1D("sp_x","sp_x",100,-200,200); + m_hist_y=new TH1D("sp_y","sp_y",100,-200,200); + m_hist_z=new TH1D("sp_z","sp_z",100,0,300); + m_hist_r=new TH1D("sp_r","sp_r",100,0,300); + m_hist_eta=new TH1D("sp_eta","sp_eta",100,0,5); + m_hist_phi=new TH1D("sp_phi","sp_phi",100,-3.2,3.2); + m_hist_strip=new TH1D("sp_strip","sp_strip",100,0,2000); + m_hist_layer=new TH1D("sp_layer","sp_layer",100,-10,10); + m_hist_station=new TH1D("sp_station","sp_station",100,-10,10); + m_hist_x_y_plane0=new TH2D("sp_x_y_plane0","sp_x_y_plane0",100,-200,200,100,-200,200); + m_hist_x_y_plane1=new TH2D("sp_x_y_plane1","sp_x_y_plane1",100,-200,200,100,-200,200); + m_hist_x_y_plane2=new TH2D("sp_x_y_plane2","sp_x_y_plane2",100,-200,200,100,-200,200); + m_hist_x_y_plane3=new TH2D("sp_x_y_plane3","sp_x_y_plane3",100,-200,200,100,-200,200); + m_hist_x_y_plane4=new TH2D("sp_x_y_plane4","sp_x_y_plane4",100,-200,200,100,-200,200); + m_hist_x_y_plane5=new TH2D("sp_x_y_plane5","sp_x_y_plane5",100,-200,200,100,-200,200); + m_hist_x_y_plane6=new TH2D("sp_x_y_plane6","sp_x_y_plane6",100,-200,200,100,-200,200); + m_hist_x_y_plane7=new TH2D("sp_x_y_plane7","sp_x_y_plane7",100,-200,200,100,-200,200); + m_hist_x_y_plane8=new TH2D("sp_x_y_plane8","sp_x_y_plane8",100,-200,200,100,-200,200); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x",m_hist_x)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_y",m_hist_y)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_z",m_hist_z)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_r",m_hist_r)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_eta",m_hist_eta)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_phi",m_hist_phi)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_strip",m_hist_strip)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_layer",m_hist_layer)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_station",m_hist_station)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x_y_plane0",m_hist_x_y_plane0)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x_y_plane1",m_hist_x_y_plane1)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x_y_plane2",m_hist_x_y_plane2)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x_y_plane3",m_hist_x_y_plane3)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x_y_plane4",m_hist_x_y_plane4)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x_y_plane5",m_hist_x_y_plane5)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x_y_plane6",m_hist_x_y_plane6)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x_y_plane7",m_hist_x_y_plane7)); + CHECK(m_thistSvc->regHist("/StatisticsAlg/sp/sp_x_y_plane8",m_hist_x_y_plane8)); + ATH_MSG_INFO( "StatisticsAlg::initialized for package version " << PACKAGE_VERSION ); + return StatusCode::SUCCESS; +} + +//------------------------------------------------------------------------- + +StatusCode StatisticsAlg::execute (const EventContext& ctx) const +{ + + + ++m_numberOfEvents; + const TrackerDD::SiDetectorElementCollection* elements = nullptr; + + + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEle(m_SCTDetEleCollKey, ctx); + elements = sctDetEle.retrieve(); + if (elements==nullptr) { + ATH_MSG_FATAL("Pointer of SiDetectorElementCollection (" << m_SCTDetEleCollKey.fullKey() << ") could not be retrieved"); + return StatusCode::SUCCESS; + } + + // register the IdentifiableContainer into StoreGate + + + // retrieve SCT cluster container + SG::ReadHandle<SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); + if (!sct_spcontainer.isValid()){ + msg(MSG:: FATAL) << "Could not find the data object "<< sct_spcontainer.name() << " !" << endmsg; + return StatusCode::RECOVERABLE; + } + + + ATH_MSG_DEBUG( "SCT spacepoint container found: " << sct_spcontainer->size() << " collections" ); + SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + + for (; it != itend; ++it){ + const SpacePointCollection *colNext=&(**it); + int nReceivedSPSCT = colNext->size(); + + // Create SpacePointCollection + IdentifierHash idHash = colNext->identifyHash(); + Identifier elementID = colNext->identify(); + int istation = m_idHelper->station(elementID); + int ilayer = m_idHelper->layer(elementID); + m_hist_strip->Fill(m_idHelper->strip(elementID)); + m_hist_station->Fill(istation); + m_hist_layer->Fill(ilayer); + size_t size = colNext->size(); + if (size == 0){ + ATH_MSG_VERBOSE( "StatisticsAlg algorithm found no space points" ); + } else { + //In a MT environment the cache maybe filled by another thread in which case this will delete the duplicate + SpacePointCollection::const_iterator sp_begin= colNext->begin(); + SpacePointCollection::const_iterator sp_end= colNext->end(); + for (; sp_begin != sp_end; ++sp_begin){ + const Trk::SpacePoint* sp=&(**sp_begin); + m_hist_r->Fill(sp->r()); + m_hist_eta->Fill(sp->eta()); + m_hist_phi->Fill(sp->phi()); + Amg::Vector3D gloPos=sp->globalPosition(); + m_hist_x->Fill(gloPos.x()); + m_hist_y->Fill(gloPos.y()); + m_hist_z->Fill(gloPos.z()); + if ( ((istation-1)*3+ilayer) == 0 ) m_hist_x_y_plane0->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 1 ) m_hist_x_y_plane1->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 2 ) m_hist_x_y_plane2->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 3 ) m_hist_x_y_plane3->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 4 ) m_hist_x_y_plane4->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 5 ) m_hist_x_y_plane5->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 6 ) m_hist_x_y_plane6->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 7 ) m_hist_x_y_plane7->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 8 ) m_hist_x_y_plane8->Fill(gloPos.x(),gloPos.y()); + } + ATH_MSG_VERBOSE( size << " SpacePoints successfully added to Container !" ); + } + } + + + return StatusCode::SUCCESS; +} + +//--------------------------------------------------------------------------- +StatusCode StatisticsAlg::finalize() +{ + ATH_MSG_INFO( "StatisticsAlg::finalize()" ); + ATH_MSG_INFO( m_numberOfEvents << " events processed" ); + ATH_MSG_INFO( m_numberOfSCT << " sct collections processed" ); + ATH_MSG_INFO( m_numberOfSP<< " sct SP collections processed" ); + return StatusCode::SUCCESS; +} + +//-------------------------------------------------------------------------- + +} \ No newline at end of file diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.h b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.h new file mode 100755 index 0000000000000000000000000000000000000000..2683f2ec561400dae90233c055029f6aeccca4f1 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.h @@ -0,0 +1,102 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef StatisticsAlg_TRACKERSPACEPOINTMAKERALG_H +#define StatisticsAlg_TRACKERSPACEPOINTMAKERALG_H + +#include "StoreGate/ReadCondHandleKey.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "Identifier/Identifier.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerPrepRawData/TrackerClusterContainer.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +// #include "TrackerSpacePointMakerAlg/SiElementPropertiesTable.h" +// #include "TrackerSpacePointMakerTool/TrackerSpacePointMakerTool.h" +#include "TrkSpacePoint/SpacePoint.h" +#include "TrkSpacePoint/SpacePointContainer.h" +#include "TrkSpacePoint/SpacePointOverlapCollection.h" + +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ITHistSvc.h" + +#include <string> +#include <vector> +#include "TH1.h" +#include "TH2.h" + +#include <string> + +// class TrackerSpacePointCollection; +// class TrackerSpacePointOverlapCollection; +// class TrackerSpacePointContainer; +class FaserSCT_ID; +namespace Tracker +{ + + class StatisticsAlg:public AthReentrantAlgorithm { + + public: + + /** + * @name AthReentrantAlgorithm methods + */ + //@{ + StatisticsAlg(const std::string& name, + ISvcLocator* pSvcLocator); + + virtual ~StatisticsAlg() = default; + + virtual StatusCode initialize() override; + + virtual StatusCode execute (const EventContext& ctx) const override; + + virtual StatusCode finalize() override; + + + private: + StatisticsAlg() = delete; + StatisticsAlg(const StatisticsAlg&) =delete; + StatisticsAlg &operator=(const StatisticsAlg&) = delete; + //@} + + SG::ReadHandleKey<SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT spContainer"}; + //@} + + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; + //@} + + const FaserSCT_ID* m_idHelper{nullptr}; + mutable std::atomic<int> m_numberOfEvents{0}; + mutable std::atomic<int> m_numberOfSCT{0}; + mutable std::atomic<int> m_numberOfSP{0}; + //@} + TH1* m_hist_x; + TH1* m_hist_y; + TH1* m_hist_z; + TH1* m_hist_r; + TH1* m_hist_eta; + TH1* m_hist_phi; + TH1* m_hist_station; + TH1* m_hist_strip; + TH1* m_hist_layer; + TH2* m_hist_x_y_plane0; + TH2* m_hist_x_y_plane1; + TH2* m_hist_x_y_plane2; + TH2* m_hist_x_y_plane3; + TH2* m_hist_x_y_plane4; + TH2* m_hist_x_y_plane5; + TH2* m_hist_x_y_plane6; + TH2* m_hist_x_y_plane7; + TH2* m_hist_x_y_plane8; + ServiceHandle<ITHistSvc> m_thistSvc; + + + }; + +} +#endif // TrackerSpacePointMakerAlg_TRACKERSPACEPOINTMAKERALG_H diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.cxx b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.cxx new file mode 100755 index 0000000000000000000000000000000000000000..a2355c4b2b26802a90a5eebdc66645c34a3b0e24 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.cxx @@ -0,0 +1,391 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/*************************************************************************** + ------------------- + ATLAS Collaboration + ***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> + + +#include "TrackerSpacePointFinder.h" + +// For processing clusters +#include "TrackerReadoutGeometry/SiLocalPosition.h" +#include "TrackerReadoutGeometry/SiDetectorDesign.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +// Space point Classes, +#include "TrkSpacePoint/SpacePointCollection.h" +// #include "TrkSpacePoint/SpacePointCLASS_DEF.h" +#include "TrackerIdentifier/FaserSCT_ID.h" + + +// general Atlas classes +#include "FaserDetDescr/FaserDetectorID.h" +#include "xAODEventInfo/EventInfo.h" +#include "StoreGate/ReadCondHandle.h" + +#include "AthenaMonitoringKernel/Monitored.h" + +namespace Tracker +{ + +//------------------------------------------------------------------------ +TrackerSpacePointFinder::TrackerSpacePointFinder(const std::string& name, + ISvcLocator* pSvcLocator) +: AthReentrantAlgorithm(name, pSvcLocator) +{ + declareProperty("ProcessSCTs", m_selectSCTs=true); + declareProperty("ProcessOverlaps", m_overlap=true, "process overlaps of SCT wafers."); + declareProperty("AllClusters", m_allClusters=false, "process all clusters without limits."); + declareProperty("OverlapLimitOpposite", m_overlapLimitOpposite=2.8, "overlap limit for opposite-neighbour."); + declareProperty("OverlapLimitPhi", m_overlapLimitPhi=5.64, "overlap limit for phi-neighbours."); + declareProperty("OverlapLimitEtaMin", m_overlapLimitEtaMin=1.68, "low overlap limit for eta-neighbours."); + declareProperty("OverlapLimitEtaMax", m_overlapLimitEtaMax=3.0, "high overlap limit for eta-neighbours."); + // declareProperty("OverrideBeamSpot", m_overrideBS=false); + declareProperty("VertexX", m_xVertex=0.); + declareProperty("VertexY", m_yVertex=0.); + declareProperty("VertexZ", m_zVertex=-100.); + + declareProperty("SpacePointCacheSCT", m_SpacePointCache_SCTKey=""); + +} + +//----------------------------------------------------------------------- +StatusCode TrackerSpacePointFinder::initialize() +{ + ATH_MSG_DEBUG( "initialize()" ); + + // Check that clusters, space points and ids have names + if (m_selectSCTs && m_Sct_clcontainerKey.key().empty()){ + ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_Sct_clcontainerKey.initialize(m_selectSCTs) ); + + if (m_selectSCTs && m_SpacePointContainer_SCTKey.key().empty()){ + ATH_MSG_FATAL( "No name set for SCT space points"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_SpacePointContainer_SCTKey.initialize(m_selectSCTs) ); + + if (m_spacepointoverlapCollectionKey.key().empty()){ + ATH_MSG_FATAL( "No name set for overlap space points"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_spacepointoverlapCollectionKey.initialize() ); + + // create containers (requires the Identifier Helpers) + if (m_selectSCTs) { + ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); + + // Initialize the key of input FaserSiElementPropertiesTable and SiDetectorElementCollection for SCT + ATH_CHECK(m_SCTPropertiesKey.initialize()); + ATH_CHECK(m_SCTDetEleCollKey.initialize()); + } + + ATH_CHECK(m_SiSpacePointMakerTool.retrieve()); + // ATH_CHECK(m_beamSpotKey.initialize(!m_overrideBS)); + + ATH_CHECK(m_SpacePointCache_SCTKey.initialize(!m_SpacePointCache_SCTKey.key().empty())); + m_cachemode = !m_SpacePointCache_SCTKey.key().empty(); + + if (!m_monTool.empty()) CHECK(m_monTool.retrieve()); + + ATH_MSG_INFO( "Initialized for package version " << PACKAGE_VERSION ); + return StatusCode::SUCCESS; +} + +//------------------------------------------------------------------------- + +StatusCode TrackerSpacePointFinder::execute (const EventContext& ctx) const +{ + + + ++m_numberOfEvents; + const TrackerDD::SiDetectorElementCollection* elements = nullptr; + const TrackerDD::SiElementPropertiesTable* properties = nullptr; + + auto nReceivedClustersSCT = Monitored::Scalar<int>( "numSctClusters" , 0 ); + auto nSCTspacePoints = Monitored::Scalar<int>( "numSctSpacePoints" , 0 ); + + //auto mon = Monitored::Group( m_monTool, nReceivedClustersPIX,nReceivedClustersSCT, nPIXspacePoints, nSCTspacePoints ); + + if (m_selectSCTs) { + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEle(m_SCTDetEleCollKey, ctx); + elements = sctDetEle.retrieve(); + if (elements==nullptr) { + ATH_MSG_FATAL("Pointer of SiDetectorElementCollection (" << m_SCTDetEleCollKey.fullKey() << ") could not be retrieved"); + return StatusCode::SUCCESS; + } + SG::ReadCondHandle<TrackerDD::SiElementPropertiesTable> sctProperties(m_SCTPropertiesKey, ctx); + properties = sctProperties.retrieve(); + if (properties==nullptr) { + ATH_MSG_FATAL("Pointer of FaserSiElementPropertiesTable (" << m_SCTPropertiesKey.fullKey() << ") could not be retrieved"); + return StatusCode::SUCCESS; + } + } + SPFCache r_cache(ctx); + // if (! m_overrideBS){ + // SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey, ctx }; + // const InDet::BeamSpotData* beamSpot = *beamSpotHandle; + // r_cache.vertex = beamSpot->beamVtx().position(); + // } else { + r_cache.vertex = Amg::Vector3D(m_xVertex,m_yVertex,m_zVertex); + // } + + // register the IdentifiableContainer into StoreGate + SG::WriteHandle<SpacePointContainer> spacePointContainer_SCT; + if (m_selectSCTs){ + spacePointContainer_SCT = SG::WriteHandle<SpacePointContainer>( m_SpacePointContainer_SCTKey, ctx ); + if(m_SpacePointCache_SCTKey.key().empty()){ + ATH_CHECK( spacePointContainer_SCT.record( std::make_unique<SpacePointContainer>(m_idHelper->wafer_hash_max()) ) ); + ATH_MSG_DEBUG("Created SpacePointContainer " << m_SpacePointContainer_SCTKey.key() << " N= " << m_idHelper->wafer_hash_max()); + }else{ + SG::UpdateHandle<SpacePointCache> updateH( m_SpacePointCache_SCTKey, ctx ); + ATH_CHECK(updateH.isValid()); + ATH_CHECK( spacePointContainer_SCT.record( std::make_unique<SpacePointContainer>(updateH.ptr()) ) ); + ATH_MSG_DEBUG("Created SpacePointContainer " << m_SpacePointContainer_SCTKey.key() << " from cache " << m_SpacePointCache_SCTKey.key()); + } + } + + SG::WriteHandle<SpacePointOverlapCollection> spacepointoverlapCollection( m_spacepointoverlapCollectionKey, ctx ); + ATH_CHECK( spacepointoverlapCollection.record( std::make_unique<SpacePointOverlapCollection>() ) ); + + ATH_MSG_DEBUG( "Container '" << spacepointoverlapCollection.name() << "' initialised" ); + + int sctCacheCount = 0; + + if (m_selectSCTs){ + + // retrieve SCT cluster container + SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> sct_clcontainer( m_Sct_clcontainerKey, ctx ); + if (!sct_clcontainer.isValid()){ + msg(MSG:: FATAL) << "Could not find the data object "<< sct_clcontainer.name() << " !" << endmsg; + return StatusCode::RECOVERABLE; + } + + r_cache.SCTCContainer = sct_clcontainer.cptr(); + + ATH_MSG_DEBUG( "SCT Cluster container found: " << sct_clcontainer->size() << " collections" ); + // Get hold of all clusters and iterate through them. + // Pixel clusters will be converted immediately to pixel space points. + // For SCT clusters, posssible pairs will be found and space points computed. + // It is possible, though unlikely, that there are no clusters for the + // event. Therefore we do not terminate the job if we don't find any. + Tracker::FaserSCT_ClusterContainer::const_iterator it = sct_clcontainer->begin(); + Tracker::FaserSCT_ClusterContainer::const_iterator itend = sct_clcontainer->end(); + + for (; it != itend; ++it){ + ++m_numberOfClusterCollection; + const Tracker::FaserSCT_ClusterCollection *colNext=&(**it); + nReceivedClustersSCT = colNext->size(); + m_numberOfCluster+=colNext->size();; + + // Create SpacePointCollection + IdentifierHash idHash = colNext->identifyHash(); + SpacePointContainer::IDC_WriteHandle lock = spacePointContainer_SCT->getWriteHandle(idHash); + if(lock.alreadyPresent()){ + ATH_MSG_DEBUG("SCT Hash " << idHash << " is already in cache"); + ++sctCacheCount; + continue; //Skip if already present in cache + } + + Identifier elementID = colNext->identify(); + auto spacepointCollection = std::make_unique<SpacePointCollection>(idHash); + spacepointCollection->setIdentifier(elementID); + + if ( colNext->size() != 0){ + addSCT_SpacePoints(colNext, properties, elements, + spacepointCollection.get(), spacepointoverlapCollection.ptr(), r_cache); + } else { + ATH_MSG_DEBUG( "Empty SCT cluster collection" ); + } + size_t size = spacepointCollection->size(); + nSCTspacePoints = size; + if (size == 0){ + ATH_MSG_VERBOSE( "Algorithm found no space points" ); + } else { + //In a MT environment the cache maybe filled by another thread in which case this will delete the duplicate + m_numberOfSP+=spacepointCollection->size(); + ++m_numberOfSPCollection; + StatusCode sc= lock.addOrDelete( std::move(spacepointCollection) ); + if (sc.isFailure()){ + ATH_MSG_ERROR( "Failed to add SpacePoints to container" ); + return StatusCode::RECOVERABLE; + } + ATH_MSG_VERBOSE( size << " SpacePoints successfully added to Container !" ); + } + } + } + + + // store the overlap space points. + // check that the set isn't empty. + if (spacepointoverlapCollection->size()==0) + { + ATH_MSG_DEBUG( "No overlap space points found" ); + } + else + { + ATH_MSG_DEBUG( spacepointoverlapCollection->size() <<" overlap space points registered." ); + } + if (m_selectSCTs) { + auto c = spacePointContainer_SCT->numberOfCollections(); + m_numberOfSCT += c; + } + if(m_cachemode)//Prevent unnecessary atomic counting + { + m_sctCacheHits += sctCacheCount; + } + + + return StatusCode::SUCCESS; +} + +//--------------------------------------------------------------------------- +StatusCode TrackerSpacePointFinder::finalize() +{ + ATH_MSG_INFO( "finalize()" ); + ATH_MSG_INFO( m_numberOfEvents << " events processed" ); + ATH_MSG_INFO( m_numberOfSCT << " sct collections processed" ); + ATH_MSG_INFO( m_numberOfClusterCollection << " cluster collections processed" ); + ATH_MSG_INFO( m_numberOfCluster<< " cluster processed" ); + ATH_MSG_INFO( m_numberOfSPCollection<< " spacepoint collection generatedprocessed" ); + ATH_MSG_INFO( m_numberOfSP<< " spacepoint generatedprocessed" ); + if(m_cachemode){ + //These are debug messages because they can be indeterminate in an MT environment and it could + //lead to confusing log comparisons. + ATH_MSG_DEBUG( m_sctCacheHits << " sct cache hits" ); + } + return StatusCode::SUCCESS; +} + +//-------------------------------------------------------------------------- + +void TrackerSpacePointFinder:: +addSCT_SpacePoints(const Tracker::FaserSCT_ClusterCollection* next, + const TrackerDD::SiElementPropertiesTable* properties, + const TrackerDD::SiDetectorElementCollection* elements, + SpacePointCollection* spacepointCollection, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const +{ + + // Do nothing unless this is a side 1 detector (strips of const phi). + IdentifierHash thisHash(next->identifyHash()); + + // if it is not the stereo side + const TrackerDD::SiDetectorElement *element = elements->getDetectorElement(thisHash); + if (element && !(element->isStereo())){ + // Space points are created from clusters for all possibly + // overlapping pairs in the given range if m_overlap=true. + // Otherwise just the opposite pair are processed. + // Pick up the five neighbours of detector, and check ranges + // for which overlap is possible. + // "check1" is used for opposite and eta overlaps. + // check2 for phi overlaps + + const std::vector<IdentifierHash>* + others(properties->neighbours(thisHash)); + if (others==0 || others->empty() ) return; + std::vector<IdentifierHash>::const_iterator otherHash = others->begin(); + + bool overlapColl = false; + // check opposite wafer + checkForSCT_Points(next, *otherHash, + elements, + -m_overlapLimitOpposite, +m_overlapLimitOpposite, + spacepointCollection,overlapColl,spacepointOverlapCollection, r_cache); + + if (! m_overlap) return; + + // check phi overlaps + overlapColl = true; + ++otherHash; + if (otherHash == others->end() ) return; + float hwidth(properties->halfWidth(thisHash)); + // half-width of wafer + + checkForSCT_Points(next, *otherHash, + elements, + -hwidth, -hwidth+m_overlapLimitPhi, + +hwidth-m_overlapLimitPhi, +hwidth,spacepointOverlapCollection, r_cache); + ++otherHash; + if (otherHash == others->end() ) return; + checkForSCT_Points(next, *otherHash, + elements, + +hwidth-m_overlapLimitPhi, +hwidth, + -hwidth, -hwidth+m_overlapLimitPhi,spacepointOverlapCollection, r_cache); + + // if barrel, check the eta overlaps too. + // In this case, action depends on whether layer is even or odd + // Also, whether we look at "lower in eta", which comes first, + // or "higher". + ++otherHash; + if (otherHash == others->end() ) return; + // get Identifier without hashing or so + //Identifier thisID = element->identify(); + + checkForSCT_Points(next, *otherHash, + elements, + +m_overlapLimitEtaMin, + +m_overlapLimitEtaMax, + spacepointCollection,overlapColl,spacepointOverlapCollection, r_cache); + ++otherHash; + if (otherHash == others->end() ) return; + + checkForSCT_Points(next, *otherHash, + elements, + -m_overlapLimitEtaMax, + -m_overlapLimitEtaMin, + spacepointCollection,overlapColl,spacepointOverlapCollection, r_cache); + } +} + + +//-------------------------------------------------------------------------- + +void TrackerSpacePointFinder:: +checkForSCT_Points(const Tracker::FaserSCT_ClusterCollection* clusters1, + const IdentifierHash id2, + const TrackerDD::SiDetectorElementCollection* elements, + double min, double max, + SpacePointCollection* spacepointCollection, bool overlapColl, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const +{ + + + // Get the cluster collections for these two detectors. + // Require that (xPhi2 - xPhi1) lie in the range specified. + // Used for opposite and eta modules + + //indexFindPtr is faster in the MT implementation + const Tracker::FaserSCT_ClusterCollection * clusters2 = r_cache.SCTCContainer->indexFindPtr(id2); + if (clusters2==nullptr) return; + + if (!overlapColl) { + m_SiSpacePointMakerTool->fillSCT_SpacePointCollection(clusters1, clusters2, min, max, m_allClusters, r_cache.vertex, elements, spacepointCollection); + } + else { + m_SiSpacePointMakerTool->fillSCT_SpacePointEtaOverlapCollection(clusters1, clusters2, min, max, m_allClusters, r_cache.vertex, elements, spacepointOverlapCollection); + } + } + //-------------------------------------------------------------------------- + void TrackerSpacePointFinder:: + checkForSCT_Points(const Tracker::FaserSCT_ClusterCollection* clusters1, + const IdentifierHash id2, + const TrackerDD::SiDetectorElementCollection* elements, + double min1, double max1, double min2, double max2, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const + { + + // get the cluster collections for these two detectors. Clus1 must lie + // within min1 and max1 and clus between min2 and max2. Used for phi + // overlaps. + const Tracker::FaserSCT_ClusterCollection * clusters2 (r_cache.SCTCContainer->indexFindPtr(id2)); + if (clusters2==nullptr) return; + + m_SiSpacePointMakerTool->fillSCT_SpacePointPhiOverlapCollection(clusters1, clusters2, min1, max1, min2, max2, m_allClusters, r_cache.vertex, elements, spacepointOverlapCollection); + } + +} \ No newline at end of file diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.h b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.h new file mode 100755 index 0000000000000000000000000000000000000000..ae698bc3916d29c8c825732df5e4641cb628d4c0 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.h @@ -0,0 +1,250 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TrackerSpacePointFormation_TRACKERSPACEPOINTFINDER_H +#define TrackerSpacePointFormation_TRACKERSPACEPOINTFINDER_H + +#include "StoreGate/ReadCondHandleKey.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "AthenaMonitoringKernel/GenericMonitoringTool.h" +#include "AthContainers/DataVector.h" +#include "GeoPrimitives/GeoPrimitives.h" +#include "Identifier/Identifier.h" +#include "GaudiKernel/ToolHandle.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerPrepRawData/TrackerClusterContainer.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "SiElementPropertiesTable.h" +#include "FaserSiSpacePointTool/TrackerSpacePointMakerTool.h" +#include "TrkSpacePoint/SpacePoint.h" +#include "TrkSpacePoint/SpacePointContainer.h" +#include "TrkSpacePoint/SpacePointOverlapCollection.h" + +#include <string> + +// class TrackerSpacePointCollection; +// class TrackerSpacePointOverlapCollection; +// class TrackerSpacePointContainer; +class FaserSCT_ID; + + +/** +@class TrackerSpacePointMakerAlg + This version of PointFinder uses SiCluster to find space points in + the pixel and SCT detectors. The algorithm retrieves all clusters from + StoreGate using SG::ReadHandle(Key) and uses the begin-end iterators to iterate over the + clusters. It then has to see whether the next cluster is a pixel or + SCT cluster. Pixel space points are obtained directly from the clusters. + To make SCT space points we also need the IdentifiableContainer for the + SCT clusters, since we need random access to find overlapping detectors on the + stereo layer. Space points are made by combining clusters from pairs of + overlapping detectors. The user can choose just to process the phi wafer and + its opposite on the stereo layer, or also to consider overlaps with the + four nearest neighbours of the opposite wafer. + The space points are wrtten to Storegate as SpacePointContainer for Pixels + and non-overlapping SCT space points and as SpacePointOverlapCollection for + the overlapping ones. + + + Job Options: + Process pixels: default true + Process SCTs: default true + Process overlaps: default true + SCT IdentifiableContainer name: default "SCT_Clusters" + SCT SpacePointSet name: default "SCT_SpacePoints" + + + Fatal Errors: + neither pixels nor SCTs selected + SCTs selected and no name for SCT Identifiable Collection + No name for SpacePointSet + Failure to retrieve event + StoreGate failure. + + Possible errors for which processing continues: + No clusters found for event + Implementation of SCT_Neighbours is FaserSiElementPropertiesTable, + is prepared by FaserSiElementPropertiesTableCondAlg + and is stored in StoreGate using SG::WriteCondHandle(Key). +*/ +namespace Tracker +{ + class TrackerSpacePointFinder:public AthReentrantAlgorithm { + + public: + + /** + * @name AthReentrantAlgorithm methods + */ + //@{ + TrackerSpacePointFinder(const std::string& name, + ISvcLocator* pSvcLocator); + + virtual ~TrackerSpacePointFinder() = default; + + virtual StatusCode initialize() override; + + virtual StatusCode execute (const EventContext& ctx) const override; + + virtual StatusCode finalize() override; + + /** Make this algorithm clonable. */ + virtual bool isClonable() const override { return true; }; + //@} + + private: + /// This is a temporary object to aid reentrant coding + struct SPFCache{ + Amg::Vector3D vertex; + const EventContext& ctx; + const Tracker::FaserSCT_ClusterContainer* SCTCContainer; + SPFCache(const EventContext& inctx) : ctx(inctx), SCTCContainer(nullptr) { } + }; + + // methods + + /** + * @name Disallow constructor without parameters, copy constructor, assignment operator + */ + //@{ + TrackerSpacePointFinder() = delete; + TrackerSpacePointFinder(const TrackerSpacePointFinder&) =delete; + TrackerSpacePointFinder &operator=(const TrackerSpacePointFinder&) = delete; + //@} + + /** + * @name Main SCT space point methods + */ + //@{ + void addSCT_SpacePoints + (const Tracker::FaserSCT_ClusterCollection* next, + const TrackerDD::SiElementPropertiesTable* properties, + const TrackerDD::SiDetectorElementCollection* elements, + SpacePointCollection* spacepointCollection, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; + + void checkForSCT_Points + (const Tracker::FaserSCT_ClusterCollection* clusters1, + const IdentifierHash id2, + const TrackerDD::SiDetectorElementCollection* elements, + double minDiff, double maxDiff, + SpacePointCollection* spacepointCollection, bool overlapColl, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; + + void checkForSCT_Points + (const Tracker::FaserSCT_ClusterCollection* clusters1, + const IdentifierHash id2, + const TrackerDD::SiDetectorElementCollection* elements, + double min1, double max1, + double min2, double max2, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; + //@} + + // data members + + /** + * @name Input data using SG::ReadHandleKey + */ + //@{ + SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_Sct_clcontainerKey{this, "SCT_ClustersName", "SCT clContainer"}; + //@} + + /** + * @name Input condition data using SG::ReadCondHandleKey + */ + //@{ + /// For beam spot +// SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; + /// To get SCT neighbours + SG::ReadCondHandleKey<TrackerDD::SiElementPropertiesTable> m_SCTPropertiesKey{this, "SCTPropertiesKey", "SCT_ElementPropertiesTable", "Key of input SiElementPropertiesTable for SCT"}; + /// For SCT alignment + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; + //@} + + /** + * @name Output data using SG::WriteHandleKey + */ + //@{ + SG::WriteHandleKey<SpacePointContainer> m_SpacePointContainer_SCTKey{this, "SpacePointsSCTName", "SCT_SpacePoints", "SpacePoint SCT container"}; + SG::WriteHandleKey<SpacePointOverlapCollection> m_spacepointoverlapCollectionKey{this, "SpacePointsOverlapName", "OverlapSpacePoints", "Space Point Overlap collection"}; + //@} + + /** + * @name Caches for HLT using SG::UpdateHandleKey + */ + //@{ + SG::UpdateHandleKey<SpacePointCache> m_SpacePointCache_SCTKey; + //@} + + /** + * @name ToolHandle + */ + //@{ + ToolHandle< TrackerSpacePointMakerTool > m_SiSpacePointMakerTool{this, "SpacePointFinderTool", "TrackerSpacePointMakerTool"}; + ToolHandle<GenericMonitoringTool> m_monTool{this, "monTool", "", "Monitoring tool"}; + //@} + + /** + * @name Id helpers + */ + //@{ + const FaserSCT_ID* m_idHelper{nullptr}; + //@} + + /** + * @name Configuration flags + */ + //@{ + bool m_selectSCTs; + bool m_overlap; //!< process all overlapping SCT pairs if true. + bool m_allClusters; //!< process all clusters without limits if true. + + bool m_cachemode{false}; //!< used for online MT counters + //@} + + /** + * @name Cut parameters + * @brief The following are ranges within which clusters must lie to + * make a spacepoint. Opposite and eta neighbours + * clusters must lie within range of each other. + * Phi clusters must lie in region of each wafer separately. + */ + //@{ + float m_overlapLimitOpposite; //!< overlap limit for opposite-neighbours. + float m_overlapLimitPhi; //!< overlap limit for phi-neighbours. + float m_overlapLimitEtaMin; //!< low overlap limit for eta-neighbours. + float m_overlapLimitEtaMax; //!< high overlap limit for eta-neighbours. + //@} + + /** + * @name Beam spot override + */ + //@{ +// bool m_overrideBS; + float m_xVertex; + float m_yVertex; + float m_zVertex; + //@} + + /** + * @name Counters + * Use mutable to be updated in const methods. + * AthReentrantAlgorithm is const during event processing. + * Use std::atomic to be multi-thread safe. + */ + //@{ + mutable std::atomic<int> m_numberOfEvents{0}; + mutable std::atomic<int> m_numberOfSCT{0}; + mutable std::atomic<int> m_sctCacheHits{0}; + mutable std::atomic<int> m_numberOfClusterCollection{0}; + mutable std::atomic<int> m_numberOfCluster{0}; + mutable std::atomic<int> m_numberOfSP{0}; + mutable std::atomic<int> m_numberOfSPCollection{0}; + //@} + + }; +} + +#endif // TrackerSpacePointFormation_TRACKERSPACEPOINTFINDER_H diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/components/TrackerSpacePointFormation_entries.cxx b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/components/TrackerSpacePointFormation_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..277035ee1170ee616684f824d825c5a61cdb978a --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/components/TrackerSpacePointFormation_entries.cxx @@ -0,0 +1,8 @@ +#include "../SiElementPropertiesTableCondAlg.h" +#include "../TrackerSpacePointFinder.h" +#include "../StatisticsAlg.h" + +DECLARE_COMPONENT( TrackerDD::SiElementPropertiesTableCondAlg ) +DECLARE_COMPONENT( Tracker::TrackerSpacePointFinder ) +DECLARE_COMPONENT( Tracker::StatisticsAlg ) + diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/StatisticsDbg.py b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/StatisticsDbg.py new file mode 100644 index 0000000000000000000000000000000000000000..738a0b50939ecefc4ec3f4b91ab5623c6082fee6 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/StatisticsDbg.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +"""Test various ComponentAccumulator Digitization configuration modules + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.TestDefaults import defaultTestFiles +from AthenaConfiguration.MainServicesConfig import MainServicesSerialCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg, StatisticsCfg +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg + +# Set up logging and new style config +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +# Configure +ConfigFlags.Input.Files = ['myRDO.pool.root'] +ConfigFlags.Output.RDOFileName = "myRDO_sp.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX" +ConfigFlags.GeoModel.Align.Dynamic = False +ConfigFlags.Concurrency.NumThreads = 1 +ConfigFlags.Beam.NumberOfCollisions = 0. +#ConfigFlags.Detector.SimulateFaserSCT = True + +ConfigFlags.GeoModel.FaserVersion = "FASER-00" # Always needed +ConfigFlags.GeoModel.AtlasVersion = "ATLAS-R2-2016-01-00-01" # Always needed to fool autoconfig; value ignored + +ConfigFlags.lock() + +# Core components +acc = MainServicesSerialCfg() +acc.merge(PoolReadCfg(ConfigFlags)) +acc.merge(PoolWriteCfg(ConfigFlags)) + +#acc.merge(writeDigitizationMetadata(ConfigFlags)) + +# Inner Detector +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +acc.merge(StatisticsCfg(ConfigFlags)) + +# Output Stream customization +oStream = acc.getEventAlgo("OutputStreamRDO") +oStream.TakeItemsFromInput = True +# oStream.ItemList += ["EventInfo#*", +# "McEventCollection#TruthEvent", +# "McEventCollection#GEN_EVENT", +# "FaserSCT_ClusterCollection#*" +# ] + +# Timing +#acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + +# Dump config +logging.getLogger('forcomps').setLevel(VERBOSE) +acc.foreach_component("*").OutputLevel = VERBOSE +acc.foreach_component("*ClassID*").OutputLevel = INFO +acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +acc.getService("StoreGateSvc").Dump = True +acc.getService("ConditionStore").Dump = True +acc.printConfig(withDetails=True) +ConfigFlags.dump() +# Execute and finish +sc = acc.run(maxEvents=-1) +# Success should be 0 +sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/TrackerSpacePointFormationDbg.py b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/TrackerSpacePointFormationDbg.py new file mode 100644 index 0000000000000000000000000000000000000000..d9ac5ceae2f221fd57e7f528f046da3cd4f85e9b --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/TrackerSpacePointFormationDbg.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +"""Test various ComponentAccumulator Digitization configuration modules + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.TestDefaults import defaultTestFiles +from AthenaConfiguration.MainServicesConfig import MainServicesSerialCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg + +# Set up logging and new style config +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +# Configure +ConfigFlags.Input.Files = ['myRDO.pool.root'] +ConfigFlags.Output.RDOFileName = "myRDO_sp.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX" +ConfigFlags.GeoModel.Align.Dynamic = False +ConfigFlags.Concurrency.NumThreads = 1 +ConfigFlags.Beam.NumberOfCollisions = 0. +#ConfigFlags.Detector.SimulateFaserSCT = True + +ConfigFlags.GeoModel.FaserVersion = "FASER-00" # Always needed +ConfigFlags.GeoModel.AtlasVersion = "ATLAS-R2-2016-01-00-01" # Always needed to fool autoconfig; value ignored + +ConfigFlags.lock() + +# Core components +acc = MainServicesSerialCfg() +acc.merge(PoolReadCfg(ConfigFlags)) +acc.merge(PoolWriteCfg(ConfigFlags)) + +#acc.merge(writeDigitizationMetadata(ConfigFlags)) + +# Inner Detector +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) + +# Output Stream customization +oStream = acc.getEventAlgo("OutputStreamRDO") +oStream.TakeItemsFromInput = True +# oStream.ItemList += ["EventInfo#*", +# "McEventCollection#TruthEvent", +# "McEventCollection#GEN_EVENT", +# "FaserSCT_ClusterContainer#*" +# ] + +# Timing +#acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + +# Dump config +logging.getLogger('forcomps').setLevel(VERBOSE) +acc.foreach_component("*").OutputLevel = VERBOSE +acc.foreach_component("*ClassID*").OutputLevel = INFO +acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +acc.getService("StoreGateSvc").Dump = True +acc.getService("ConditionStore").Dump = True +acc.printConfig(withDetails=True) +ConfigFlags.dump() +# Execute and finish +sc = acc.run(maxEvents=1000) +# Success should be 0 +sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/CMakeLists.txt b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3ea091fdeced2c13a1dfb50a765a30e6e1f5b520 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/CMakeLists.txt @@ -0,0 +1,46 @@ +################################################################################ +# Package: TruthSeededTrackFinder +############################################# + +# Declare the package name: +atlas_subdir( TruthSeededTrackFinder ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + Control/AthenaMonitoringKernel + Control/AthContainers + DetectorDescription/GeoPrimitives + DetectorDescription/Identifier + GaudiKernel + Generators/GeneratorObjects + Tracker/TrackerDetDescr/TrackerReadoutGeometry + Tracker/TrackerRawEvent/TrackerRawData + Tracker/TrackerRawEvent/TrackerSimData + Tracker/TrackerSimEvent + Tracker/TrackerRecEvent/TrackerPrepRawData + Tracker/TrackerRecEvent/TrackerSpacePoint + Tracking/TrkEvent/VxVertex + PRIVATE + DetectorDescription/FaserDetDescr + Event/xAOD/xAODEventInfo + Tracker/TrackerDetDescr/TrackerIdentifier ) + +# External dependencies: +find_package( Eigen ) + +# Component(s) in the package: +#atlas_add_library( TruthSeededTrackFinderLib +# src/*.cxx src/*.h +# PUBLIC_HEADERS TruthTrackSeeds +# INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} +# LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel TrackerReadoutGeometry TrackerRawData TrackerSimData GeneratorObjects TrackerSimEvent TrackerSpacePoint TrackerPrepRawData VxVertex TrackerSpacePointMakerToolLib BeamSpotConditionsData AthenaMonitoringKernelLib +# PRIVATE_LINK_LIBRARIES FaserDetDescr xAODEventInfo TrackerIdentifier ) + + atlas_add_component( TruthSeededTrackFinder + src/components/*.cxx src/*.cxx src/*.h + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel TrackerReadoutGeometry TrackerRawData TrackerSimData GeneratorObjects TrackerSimEvent TrackerSpacePoint VxVertex FaserDetDescr xAODEventInfo TrackerIdentifier TrackerPrepRawData ) + +atlas_install_python_modules( python/*.py ) +atlas_install_scripts( test/*.py ) diff --git a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/python/TruthSeededTrackFinderConfig.py b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/python/TruthSeededTrackFinderConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..ab1eb199758151b6c79a5e503ff3c535e096602d --- /dev/null +++ b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/python/TruthSeededTrackFinderConfig.py @@ -0,0 +1,36 @@ +"""Define methods to construct configured SCT Digitization tools and algorithms + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from TruthSeededTrackFinder.TruthSeededTrackFinderConf import Tracker__TruthSeededTrackFinder +PileUpXingFolder=CompFactory.PileUpXingFolder + +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +from GaudiSvc.GaudiSvcConf import THistSvc +histSvc= THistSvc() +histSvc.Output += [ "TruthTrackSeeds DATAFILE='truthtrackseeds.root' OPT='RECREATE'" ] + + +def TruthSeededTrackFinderBasicCfg(flags, **kwargs): + """Return ComponentAccumulator for TruthSeededTrackFinder""" + acc = ComponentAccumulator() + kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer") + kwargs.setdefault("SpacePointsSeedsName", "Seeds_SpacePointContainer") + acc.addEventAlgo(Tracker__TruthSeededTrackFinder(**kwargs)) + return acc + +def TruthSeededTrackFinder_OutputCfg(flags): + """Return ComponentAccumulator with Output for SCT. Not standalone.""" + acc = ComponentAccumulator() + #ItemList = ["FaserSCT_ClusterContainer#*"] + acc.merge(OutputStreamCfg(flags, "RDO")) + return acc + +def TruthSeededTrackFinderCfg(flags, **kwargs): + #acc=ComponentAccumulator(flags) + acc=TruthSeededTrackFinderBasicCfg(flags, **kwargs) + acc.addService(histSvc) + acc.merge(TruthSeededTrackFinder_OutputCfg(flags)) + return acc diff --git a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.cxx b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.cxx new file mode 100755 index 0000000000000000000000000000000000000000..49ef727fb7568300f16c48b33570bdf997ea3b4c --- /dev/null +++ b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.cxx @@ -0,0 +1,368 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/*************************************************************************** + ------------------- + ATLAS Collaboration + ***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> + + +#include "TruthSeededTrackFinder.h" + +// For processing clusters +#include "TrackerReadoutGeometry/SiLocalPosition.h" +#include "TrackerReadoutGeometry/SiDetectorDesign.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +// Space point Classes, +#include "TrkSpacePoint/SpacePointCollection.h" +// #include "TrkSpacePoint/SpacePointCLASS_DEF.h" +#include "TrackerIdentifier/FaserSCT_ID.h" + + +// general Atlas classes +#include "FaserDetDescr/FaserDetectorID.h" +#include "xAODEventInfo/EventInfo.h" +#include "StoreGate/ReadCondHandle.h" + +#include "AthenaMonitoringKernel/Monitored.h" + +namespace Tracker +{ + +//------------------------------------------------------------------------ +TruthSeededTrackFinder::TruthSeededTrackFinder(const std::string& name, + ISvcLocator* pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator) + , m_hist_n(0) + , m_hist_x(0) + , m_hist_y(0) + , m_hist_z(0) + , m_hist_r(0) + , m_hist_phi(0) + , m_hist_eta(0) + , m_hist_layer(0) + , m_hist_strip(0) + , m_hist_station(0) + , m_hist_x_y_plane0(0) + , m_hist_x_y_plane1(0) + , m_hist_x_y_plane2(0) + , m_hist_x_y_plane3(0) + , m_hist_x_y_plane4(0) + , m_hist_x_y_plane5(0) + , m_hist_x_y_plane6(0) + , m_hist_x_y_plane7(0) + , m_hist_x_y_plane8(0) + , m_hist_x_z(0) + , m_hist_y_z(0) + , m_thistSvc("THistSvc", name) +{ +} + +//----------------------------------------------------------------------- +StatusCode TruthSeededTrackFinder::initialize() +{ + // + ATH_MSG_DEBUG( "TruthTrackSeeds::initialize()" ); + + CHECK(m_thistSvc.retrieve()); + // Check that clusters, space points and ids have names + if ( m_Sct_spcontainerKey.key().empty()){ + ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_Sct_spcontainerKey.initialize() ); + + if ( m_seed_spcontainerKey.key().empty()){ + ATH_MSG_FATAL( "No name set for output seeds space points"); + return StatusCode::FAILURE; + } + + ATH_CHECK( m_seed_spcontainerKey.initialize() ); + + // create containers (requires the Identifier Helpers) + ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); + + // Initialize the key of input SiElementPropertiesTable and SiDetectorElementCollection for SCT + ATH_CHECK(m_SCTDetEleCollKey.initialize()); + + ATH_CHECK( m_mcEventKey.initialize() ); + ATH_CHECK( m_faserSiHitKey.initialize() ); + ATH_CHECK( m_faserRdoKey.initialize()); + ATH_CHECK( m_sctMap.initialize()); + ATH_MSG_INFO( "Using GenEvent collection with key " << m_mcEventKey.key()); + ATH_MSG_INFO( "Using Faser SiHit collection with key " << m_faserSiHitKey.key()); + ATH_MSG_INFO( "Using FaserSCT RDO Container with key " << m_faserRdoKey.key()); + ATH_MSG_INFO( "Using SCT_SDO_Map with key "<< m_sctMap.key()); + + m_hist_n=new TH1D("sp_n","sp_n",20,0,20); + m_hist_x=new TH1D("sp_x","sp_x",100,-200,200); + m_hist_y=new TH1D("sp_y","sp_y",100,-200,200); + m_hist_z=new TH1D("sp_z","sp_z",3500,0,3500); + m_hist_r=new TH1D("sp_r","sp_r",100,0,200); + m_hist_eta=new TH1D("sp_eta","sp_eta",100,0,5); + m_hist_phi=new TH1D("sp_phi","sp_phi",100,-3.2,3.2); + m_hist_strip=new TH1D("sp_strip","sp_strip",1000,0,1000); + m_hist_layer=new TH1D("sp_layer","sp_layer",100,-10,10); + m_hist_station=new TH1D("sp_station","sp_station",100,-10,10); + m_hist_sp_station=new TH1D("sp_all_station","sp_station",100,-10,10); + m_hist_sp_row=new TH1D("sp_all_row","sp_station",100,-10,10); + m_hist_sp_module=new TH1D("sp_all_module","sp_station",100,-10,10); + m_hist_sp_sensor=new TH1D("sp_all_sensor","sp_station",100,-10,10); + m_hist_sp_plane=new TH1D("sp_all_plane","sp_station",100,-10,10); + m_hist_sp_layer=new TH1D("sp_all_layer","sp_station",100,-10,10); + m_hist_x_z=new TH2D("sp_x_z","sp_x_z",100,-200,200,3500,0,3500); + m_hist_y_z=new TH2D("sp_y_z","sp_y_z",100,-200,200,3500,0,3500); + m_hist_x_y_plane0=new TH2D("sp_x_y_plane0","sp_x_y_plane0",100,-200,200,100,-200,200); + m_hist_x_y_plane1=new TH2D("sp_x_y_plane1","sp_x_y_plane1",100,-200,200,100,-200,200); + m_hist_x_y_plane2=new TH2D("sp_x_y_plane2","sp_x_y_plane2",100,-200,200,100,-200,200); + m_hist_x_y_plane3=new TH2D("sp_x_y_plane3","sp_x_y_plane3",100,-200,200,100,-200,200); + m_hist_x_y_plane4=new TH2D("sp_x_y_plane4","sp_x_y_plane4",100,-200,200,100,-200,200); + m_hist_x_y_plane5=new TH2D("sp_x_y_plane5","sp_x_y_plane5",100,-200,200,100,-200,200); + m_hist_x_y_plane6=new TH2D("sp_x_y_plane6","sp_x_y_plane6",100,-200,200,100,-200,200); + m_hist_x_y_plane7=new TH2D("sp_x_y_plane7","sp_x_y_plane7",100,-200,200,100,-200,200); + m_hist_x_y_plane8=new TH2D("sp_x_y_plane8","sp_x_y_plane8",100,-200,200,100,-200,200); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_n",m_hist_n)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x",m_hist_x)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_y",m_hist_y)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_z",m_hist_z)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_r",m_hist_r)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_eta",m_hist_eta)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_phi",m_hist_phi)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_strip",m_hist_strip)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_layer",m_hist_layer)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_station",m_hist_station)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_all_station",m_hist_sp_station)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_all_layer",m_hist_sp_layer)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_all_module",m_hist_sp_module)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_all_plane",m_hist_sp_plane)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_all_row",m_hist_sp_row)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_all_sensor",m_hist_sp_sensor)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_z",m_hist_x_z)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_y_z",m_hist_y_z)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_y_plane0",m_hist_x_y_plane0)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_y_plane1",m_hist_x_y_plane1)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_y_plane2",m_hist_x_y_plane2)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_y_plane3",m_hist_x_y_plane3)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_y_plane4",m_hist_x_y_plane4)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_y_plane5",m_hist_x_y_plane5)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_y_plane6",m_hist_x_y_plane6)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_y_plane7",m_hist_x_y_plane7)); + CHECK(m_thistSvc->regHist("/TruthTrackSeeds/sp/sp_x_y_plane8",m_hist_x_y_plane8)); + ATH_MSG_INFO( "TruthTrackSeeds::initialized for package version " << PACKAGE_VERSION ); + return StatusCode::SUCCESS; +} + +//------------------------------------------------------------------------- + +StatusCode TruthSeededTrackFinder::execute (const EventContext& ctx) const +{ + + + ++m_numberOfEvents; + + // Handles created from handle keys behave like pointers to the corresponding container + SG::ReadHandle<McEventCollection> h_mcEvents(m_mcEventKey, ctx); + ATH_MSG_INFO("Read McEventContainer with " << h_mcEvents->size() << " events"); + if (h_mcEvents->size() == 0) return StatusCode::FAILURE; + + SG::ReadHandle<FaserSiHitCollection> h_siHits(m_faserSiHitKey, ctx); + ATH_MSG_INFO("Read FaserSiHitCollection with " << h_siHits->size() << " hits"); + + SG::ReadHandle<FaserSCT_RDO_Container> h_sctRDO(m_faserRdoKey, ctx); + + + SG::WriteHandle<SpacePointContainer> seedContainer_SCT(m_seed_spcontainerKey, ctx ); + + ATH_CHECK( seedContainer_SCT.record( std::make_unique<SpacePointContainer>(m_idHelper->wafer_hash_max()) ) ); + ATH_MSG_DEBUG("Created SpacePointContainer " << m_seed_spcontainerKey.key() << " N= " << m_idHelper->wafer_hash_max()); + + + const TrackerDD::SiDetectorElementCollection* elements = nullptr; + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEle(m_SCTDetEleCollKey, ctx); + elements = sctDetEle.retrieve(); + if (elements==nullptr) { + ATH_MSG_FATAL("Pointer of SiDetectorElementCollection (" << m_SCTDetEleCollKey.fullKey() << ") could not be retrieved"); + return StatusCode::SUCCESS; + } + + // register the IdentifiableContainer into StoreGate + + + // retrieve SCT cluster container + SG::ReadHandle<SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); + if (!sct_spcontainer.isValid()){ + msg(MSG:: FATAL) << "Could not find the data object "<< sct_spcontainer.name() << " !" << endmsg; + return StatusCode::RECOVERABLE; + } + + + ATH_MSG_DEBUG( "SCT spacepoint container found: " << sct_spcontainer->size() << " collections" ); + SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + + //use 0 as the hash + IdentifierHash idHash(0); + Identifier id(0); + auto spCollection = std::make_unique<SpacePointCollection>(idHash); + spCollection->setIdentifier(id); + spCollection->reserve(100); + SpacePointContainer::IDC_WriteHandle lock = seedContainer_SCT->getWriteHandle(idHash); + + int nTruthSP=0; + ATH_MSG_DEBUG( "Start iteration of spacepoint collections" ); + for (; it != itend; ++it){ + ++m_numberOfSPCollection; + const SpacePointCollection *colNext=&(**it); + int nReceivedSPSCT = colNext->size(); + + // Create SpacePointCollection + IdentifierHash idHash = colNext->identifyHash(); + Identifier elementID = colNext->identify(); + size_t size = colNext->size(); + ATH_MSG_DEBUG( "Spacepoint collection in iteraction: size = " <<nReceivedSPSCT <<", IDHash = "<<idHash<<", ID = "<<elementID ); + if (size == 0){ + ATH_MSG_VERBOSE( "Algorithm found no space points" ); + ++m_numberOfEmptySPCollection; + } else { + //In a MT environment the cache maybe filled by another thread in which case this will delete the duplicate + SpacePointCollection::const_iterator sp_begin= colNext->begin(); + SpacePointCollection::const_iterator sp_end= colNext->end(); + ATH_MSG_DEBUG( "Iterate the spacepoint in collection " ); + for (; sp_begin != sp_end; ++sp_begin){ + ++m_numberOfSP; + const Trk::SpacePoint* sp=&(**sp_begin); + bool match=false; + //get truth hit + const auto identifier = sp->clusterList().first->identify(); + int station = m_idHelper->station(identifier); + int plane = m_idHelper->layer(identifier); + int row = m_idHelper->phi_module(identifier); + int module = m_idHelper->eta_module(identifier); + int sensor = m_idHelper->side(identifier); + m_hist_sp_station->Fill(station); + m_hist_sp_plane->Fill(plane); + m_hist_sp_layer->Fill((station-1)*3+plane); + m_hist_sp_row->Fill(row); + m_hist_sp_module->Fill(module); + m_hist_sp_sensor->Fill(sensor); + + ATH_MSG_DEBUG( "Spacepoint :"<<identifier ); + SG::ReadHandle<TrackerSimDataCollection> h_collectionMap(m_sctMap, ctx); + ATH_MSG_DEBUG("map size "<<h_collectionMap->size()); + if( h_collectionMap->count(identifier) == 0) + { + ATH_MSG_INFO("no map found w/identifier "<<identifier); + ++m_numberOfNoMap; + continue; + } + + //Collection map takes identifier and returns simulation data + const auto& simdata = h_collectionMap->find(identifier)->second; + const auto& deposits = simdata.getdeposits(); + + //loop through deposits to find one w/ highest energy & get barcode + float highestDep = 0; + int barcode = 0; + for( const auto& depositPair : deposits) + { + if( depositPair.second > highestDep) + { + highestDep = depositPair.second; + barcode = depositPair.first->barcode(); + depositPair.first->print(std::cout); + ATH_MSG_INFO("pdg id "<<depositPair.first->pdg_id()); + } + } + ATH_MSG_INFO("final barcode of: "<<barcode); + if(barcode%1000000 != 10001) + continue; + + //Helper function to get hit location information from RDO identifier + ATH_MSG_INFO("trying to match hit to stat/plane/row/mod/sens: "<<station<<" "<<plane<<" "<<row<<" "<<module<<" "<<sensor); + for (const FaserSiHit& hit : *h_siHits) + { + ++m_numberOfHits; + ATH_MSG_INFO("hit w/vals "<<hit.getStation()<<" "<<hit.getPlane()<<" "<<hit.getRow()<<" "<<hit.getModule()<<" "<<hit.getSensor()<<" barcode: "<<hit.trackNumber()); + //set of conditions to confirm looking at same particle in same place for SiHit as RDO + if(hit.getStation() == station + && hit.getPlane() == plane + && hit.getRow() == row + && hit.getModule() == module + && hit.getSensor() == sensor + && hit.trackNumber() == barcode) + { + ++m_numberOfMatchSP; + ATH_MSG_INFO("matched particle and plotting w/ barcode "<<barcode); + match=true; + } + } +// // +// + if(!match) + continue; +// + ++m_numberOfFills; + ++nTruthSP; +// fails, don't know why +// spCollection->push_back(const_cast<TrackerSpacePoint*>(sp)); + + m_hist_r->Fill(sp->r()); + m_hist_eta->Fill(sp->eta()); + m_hist_phi->Fill(sp->phi()); + Amg::Vector3D gloPos=sp->globalPosition(); + m_hist_x->Fill(gloPos.x()); + m_hist_y->Fill(gloPos.y()); + m_hist_z->Fill(gloPos.z()); + m_hist_strip->Fill(m_idHelper->strip(elementID)); + m_hist_station->Fill(m_idHelper->station(elementID)); + m_hist_layer->Fill(m_idHelper->layer(elementID)); + m_hist_x_z->Fill(gloPos.x(),gloPos.z()); + m_hist_y_z->Fill(gloPos.y(),gloPos.z()); + int ilayer=m_idHelper->layer(elementID); + int istation=m_idHelper->station(elementID); + if ( ((istation-1)*3+ilayer) == 0 ) m_hist_x_y_plane0->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 1 ) m_hist_x_y_plane1->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 2 ) m_hist_x_y_plane2->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 3 ) m_hist_x_y_plane3->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 4 ) m_hist_x_y_plane4->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 5 ) m_hist_x_y_plane5->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 6 ) m_hist_x_y_plane6->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 7 ) m_hist_x_y_plane7->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 8 ) m_hist_x_y_plane8->Fill(gloPos.x(),gloPos.y()); + } + ATH_MSG_VERBOSE( size << " SpacePoints successfully added to Container !" ); + } + } + + m_hist_n->Fill(nTruthSP); + StatusCode sc= lock.addOrDelete( std::move(spCollection) ); + if (sc.isFailure()){ + ATH_MSG_ERROR( "Failed to add SpacePoints to container" ); + return StatusCode::RECOVERABLE; + } + + return StatusCode::SUCCESS; +} + +//--------------------------------------------------------------------------- +StatusCode TruthSeededTrackFinder::finalize() +{ + ATH_MSG_INFO( "Finalizing" ); + ATH_MSG_INFO( m_numberOfEvents << " events processed" ); + ATH_MSG_INFO( m_numberOfSPCollection << " spacepoint collections processed" ); + ATH_MSG_INFO( m_numberOfEmptySPCollection<< " spacepoint collections empty" ); + ATH_MSG_INFO( m_numberOfSP<< " sct SP collections processed" ); + ATH_MSG_INFO( m_numberOfNoMap<< " not maped spacepoint" ); + ATH_MSG_INFO( m_numberOfHits<< " sim hits" ); + ATH_MSG_INFO( m_numberOfMatchSP<< " matched spacepoint" ); + ATH_MSG_INFO( m_numberOfFills<< " spacepoint saved" ); + return StatusCode::SUCCESS; +} + +//-------------------------------------------------------------------------- + +} diff --git a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.h b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.h new file mode 100755 index 0000000000000000000000000000000000000000..db32348e96d4245fc8f240e538832d1d33e42ff4 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.h @@ -0,0 +1,118 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +#ifndef TRUTHSEEDEDTRACKFINDER_TRUTHSEEDEDTRACKFINDER_H +#define TRUTHSEEDEDTRACKFINDER_TRUTHSEEDEDTRACKFINDER_H + +#include "StoreGate/ReadCondHandleKey.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "Identifier/Identifier.h" + +#include "GeneratorObjects/McEventCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerPrepRawData/TrackerClusterContainer.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "TrkSpacePoint/SpacePoint.h" +#include "TrkSpacePoint/SpacePointContainer.h" +#include "TrkSpacePoint/SpacePointOverlapCollection.h" +#include "TrackerSimEvent/FaserSiHitCollection.h" +#include "TrackerRawData/FaserSCT_RDO_Container.h" +#include "TrackerSimData/TrackerSimDataCollection.h" + + +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ITHistSvc.h" + +#include <string> +#include <vector> +#include "TH1.h" +#include "TH2.h" + +#include <string> + +class FaserSCT_ID; + +namespace Tracker +{ + +class TruthSeededTrackFinder:public AthReentrantAlgorithm { + + public: + + /** + * @name AthReentrantAlgorithm methods + */ + TruthSeededTrackFinder(const std::string& name, ISvcLocator* pSvcLocator); + + virtual ~TruthSeededTrackFinder() = default; + + virtual StatusCode initialize() override; + + virtual StatusCode execute (const EventContext& ctx) const override; + + virtual StatusCode finalize() override; + + + private: + TruthSeededTrackFinder() = delete; + TruthSeededTrackFinder(const TruthSeededTrackFinder&) =delete; + TruthSeededTrackFinder &operator=(const TruthSeededTrackFinder&) = delete; + SG::ReadHandleKey<SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT spContainer"}; + + SG::WriteHandleKey<SpacePointContainer> m_seed_spcontainerKey{this, "SpacePointsSeedsName", "TrackerSpacePointContainer", "output seeds"}; + + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; + + SG::ReadHandleKey<McEventCollection> m_mcEventKey { this, "McEventCollection", "GEN_EVENT" }; + SG::ReadHandleKey<FaserSiHitCollection> m_faserSiHitKey { this, "FaserSiHitCollection", "SCT_Hits" }; + SG::ReadHandleKey<FaserSCT_RDO_Container> m_faserRdoKey { this, "FaserSCT_RDO_Container", "SCT_RDOs"}; + SG::ReadHandleKey<TrackerSimDataCollection> m_sctMap {this, "TrackerSimDataCollection", "SCT_SDO_Map"}; + + + const FaserSCT_ID* m_idHelper{nullptr}; + mutable std::atomic<int> m_numberOfEvents{0}; + mutable std::atomic<int> m_numberOfSPCollection{0}; + mutable std::atomic<int> m_numberOfEmptySPCollection{0}; + mutable std::atomic<int> m_numberOfSP{0}; + mutable std::atomic<int> m_numberOfNoMap{0}; + mutable std::atomic<int> m_numberOfHits{0}; + mutable std::atomic<int> m_numberOfMatchSP{0}; + mutable std::atomic<int> m_numberOfFills{0}; + TH1* m_hist_x; + TH1* m_hist_n; + TH1* m_hist_y; + TH1* m_hist_z; + TH1* m_hist_r; + TH1* m_hist_eta; + TH1* m_hist_phi; + TH1* m_hist_sp_station; + TH1* m_hist_sp_layer; + TH1* m_hist_sp_plane; + TH1* m_hist_sp_row; + TH1* m_hist_sp_module; + TH1* m_hist_sp_sensor; + TH1* m_hist_station; + TH1* m_hist_strip; + TH1* m_hist_layer; + TH2* m_hist_x_z; + TH2* m_hist_y_z; + TH2* m_hist_x_y_plane0; + TH2* m_hist_x_y_plane1; + TH2* m_hist_x_y_plane2; + TH2* m_hist_x_y_plane3; + TH2* m_hist_x_y_plane4; + TH2* m_hist_x_y_plane5; + TH2* m_hist_x_y_plane6; + TH2* m_hist_x_y_plane7; + TH2* m_hist_x_y_plane8; + ServiceHandle<ITHistSvc> m_thistSvc; + + +}; + +} +#endif // TRUTHSEEDEDTRACKFINDER_TRUTHSEEDEDTRACKFINDER_H diff --git a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/components/TruthSeededTrackFinder_entries.cxx b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/components/TruthSeededTrackFinder_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..de277e191deea1a934510c7f795cd66458ae0bb5 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/components/TruthSeededTrackFinder_entries.cxx @@ -0,0 +1,4 @@ +#include "../TruthSeededTrackFinder.h" + +DECLARE_COMPONENT( Tracker::TruthSeededTrackFinder ) + diff --git a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/test/TruthSeededTrackFinderDbg.py b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/test/TruthSeededTrackFinderDbg.py new file mode 100644 index 0000000000000000000000000000000000000000..cf5c7cdc06a8729500ced233cce6f16ae6699e86 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/test/TruthSeededTrackFinderDbg.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +"""Test various ComponentAccumulator Digitization configuration modules + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.TestDefaults import defaultTestFiles +from AthenaConfiguration.MainServicesConfig import MainServicesSerialCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +from TruthSeededTrackFinder.TruthSeededTrackFinderConfig import TruthSeededTrackFinderCfg +#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg + +# Set up logging and new style config +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +# Configure +ConfigFlags.Input.Files = ['myRDO.pool.root'] +ConfigFlags.Output.RDOFileName = "myRDO_seeds.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX" +ConfigFlags.GeoModel.Align.Dynamic = False +ConfigFlags.Concurrency.NumThreads = 1 +ConfigFlags.Beam.NumberOfCollisions = 0. +#ConfigFlags.Detector.SimulateFaserSCT = True + +ConfigFlags.GeoModel.FaserVersion = "FASER-00" # Always needed +ConfigFlags.GeoModel.AtlasVersion = "ATLAS-R2-2016-01-00-01" # Always needed to fool autoconfig; value ignored + +ConfigFlags.lock() + +# Core components +acc = MainServicesSerialCfg() +acc.merge(PoolReadCfg(ConfigFlags)) +acc.merge(PoolWriteCfg(ConfigFlags)) + + +#acc.merge(writeDigitizationMetadata(ConfigFlags)) + +# Inner Detector +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +acc.merge(TruthSeededTrackFinderCfg(ConfigFlags)) + +# Timing +#acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + +# Dump config +logging.getLogger('forcomps').setLevel(VERBOSE) +acc.foreach_component("*").OutputLevel = VERBOSE +acc.foreach_component("*ClassID*").OutputLevel = INFO +acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +acc.getService("StoreGateSvc").Dump = True +acc.getService("ConditionStore").Dump = True +acc.printConfig(withDetails=True) +ConfigFlags.dump() +# Execute and finish +sc = acc.run(maxEvents=-1) +# Success should be 0 +sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt b/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b7135ead9d5bdae8554baa12dcec70cb65148ee8 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt @@ -0,0 +1,41 @@ +################################################################################ +# Package: TrackerPrepRawData +################################################################################ + +# Declare the package name: +atlas_subdir( TrackerPrepRawData ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthLinks + Control/CxxUtils + Control/AthenaKernel + DetectorDescription/GeoPrimitives + DetectorDescription/Identifier + Event/EventPrimitives + GaudiKernel + Tracker/TrackerDetDescr/TrackerReadoutGeometry + Tracker/TrackerRawEvent/TrackerRawData + Tracking/TrkDetDescr/TrkSurfaces + Tracking/TrkEvent/TrkEventPrimitives + Tracking/TrkEvent/TrkPrepRawData ) + +# External dependencies: +find_package( Eigen ) +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_library( TrackerPrepRawData + src/*.cxx src/*.h + PUBLIC_HEADERS TrackerPrepRawData + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthLinks CxxUtils AthenaKernel GeoPrimitives Identifier EventPrimitives GaudiKernel TrackerReadoutGeometry TrkSurfaces TrkEventPrimitives TrkPrepRawData TrackerRawData + PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ) + +atlas_add_dictionary( TrackerPrepRawDataDict + TrackerPrepRawData/TrackerPrepRawDataDict.h + TrackerPrepRawData/selection.xml + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES} AthLinks CxxUtils AthenaKernel GeoPrimitives Identifier EventPrimitives GaudiKernel TrackerReadoutGeometry TrkSurfaces TrkEventPrimitives TrkPrepRawData TrackerRawData TrackerPrepRawData EventContainers ) + diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/ATLAS_CHECK_THREAD_SAFETY b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..eea2d603ace2e0a2b502259f9316c37434536401 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +Tracker/TrackerRecEvent/TrackerPrepRawData \ No newline at end of file diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_Cluster.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_Cluster.h new file mode 100755 index 0000000000000000000000000000000000000000..109d093c41099fee1a164c9dc38580fb9e2d292d --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_Cluster.h @@ -0,0 +1,103 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + /////////////////////////////////////////////////////////////////// +// FaserSCT_Cluster.h +// Header file for class FaserSCT_Cluster +/////////////////////////////////////////////////////////////////// +// (c) Faser Detector software, migrate from Athena +/////////////////////////////////////////////////////////////////// + +#ifndef TRACKERRAWDATA_FASERSCT_CLUSTER_H +#define TRACKERRAWDATA_FASERSCT_CLUSTER_H + +// Base class +#include "TrackerPrepRawData/TrackerCluster.h" + +#include <vector> + +class Identifier; +class MsgStream; + +namespace TrackerDD +{ + class SiDetectorElement; +} + +namespace Tracker +{ +class FaserSiWidth; + +class FaserSCT_Cluster : public TrackerCluster { + public: + /** Public, Copy, operator=, constructor*/ + FaserSCT_Cluster(); + FaserSCT_Cluster(const FaserSCT_Cluster &); + FaserSCT_Cluster(FaserSCT_Cluster &&); + FaserSCT_Cluster &operator=(const FaserSCT_Cluster &); + FaserSCT_Cluster &operator=(FaserSCT_Cluster &&); + + FaserSCT_Cluster( + const Identifier& RDOId, + const Amg::Vector2D& locpos, + const std::vector<Identifier>& rdoList, + const FaserSiWidth& width, + const TrackerDD::SiDetectorElement* detEl, + const Amg::MatrixX* locErrMat + ); + + // For use by tp converter. + FaserSCT_Cluster( + const Identifier& RDOId, + const Amg::Vector2D& locpos, + std::vector<Identifier>&& rdoList, + const FaserSiWidth& width, + const TrackerDD::SiDetectorElement* detEl, + std::unique_ptr<const Amg::MatrixX> locErrMat + ); + + /** dump information about the PRD object. */ + virtual MsgStream& dump( MsgStream& stream) const; + + /** dump information about the PRD object. */ + virtual std::ostream& dump( std::ostream& stream) const; + + /** Some information about timing - which strips had 010 and which 011 */ + uint16_t hitsInThirdTimeBin() const; + + void setHitsInThirdTimeBin(uint16_t hitsInThirdTimeBin); + + int stripHasHitInThirdTimeBin(int stripNumberWithinCluster) const; + + + private: + uint16_t m_hitsInThirdTimeBin; + + + +}; + + inline uint16_t FaserSCT_Cluster::hitsInThirdTimeBin() const + { + return m_hitsInThirdTimeBin; + } + + inline void FaserSCT_Cluster::setHitsInThirdTimeBin(uint16_t hitsInThirdTimeBin) + { + m_hitsInThirdTimeBin = hitsInThirdTimeBin; + } + + + inline int FaserSCT_Cluster::stripHasHitInThirdTimeBin(int stripNumberWithinCluster) const { + return stripNumberWithinCluster <= 16 ? (int)((m_hitsInThirdTimeBin >> stripNumberWithinCluster) & 0x1): 0; + + } + + + + MsgStream& operator << (MsgStream& stream, const FaserSCT_Cluster& prd); + std::ostream& operator << (std::ostream& stream, const FaserSCT_Cluster& prd); + +} +#endif // TRACKERRAWDATA_FASERSCT_CLUSTER_H diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterCollection.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterCollection.h new file mode 100755 index 0000000000000000000000000000000000000000..0c0055c00831e0baee2e0329c64a0993e7394b3b --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterCollection.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// PrepRawDataCLASS_DEF.h +// Header file for class PrepRawDataCLASS_DEF +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Class to contain all the CLASS_DEF for Containers and Collections +/////////////////////////////////////////////////////////////////// +// Version 1.0 25/09/2002 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#ifndef FASERSCT_CLUSTERCOLLECTION_H +#define FASERSCT_CLUSTERCOLLECTION_H + +#include "AthenaKernel/CLASS_DEF.h" +#include "TrkPrepRawData/PrepRawDataCollection.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" + +// Containers +// numbers obtained using clid.db +namespace Tracker { +typedef Trk::PrepRawDataCollection< FaserSCT_Cluster > FaserSCT_ClusterCollection; + +/**Overload of << operator for MsgStream for debug output*/ +MsgStream& operator << ( MsgStream& sl, const FaserSCT_ClusterCollection& coll); + +/**Overload of << operator for std::ostream for debug output*/ +std::ostream& operator << ( std::ostream& sl, const FaserSCT_ClusterCollection& coll); +} +CLASS_DEF(Tracker::FaserSCT_ClusterCollection, 1122353123, 1) + +#endif // TRKPREPRAWDATA_PREPRAWDATACLASS_DEF_H diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterContainer.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterContainer.h new file mode 100755 index 0000000000000000000000000000000000000000..80768c29db91f4b66498dcac8826f0e9c046face --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterContainer.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// PrepRawDataCLASS_DEF.h +// Header file for class PrepRawDataCLASS_DEF +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Class to contain all the CLASS_DEF for Containers and Collections +/////////////////////////////////////////////////////////////////// +// Version 1.0 25/09/2002 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#ifndef SCT_CLUSTERCONTAINER_H +#define SCT_CLUSTERCONTAINER_H + +#include "AthenaKernel/CLASS_DEF.h" +#include "TrkPrepRawData/PrepRawDataContainer.h" +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "AthLinks/DeclareIndexingPolicy.h" + +// Containers +// numbers obtained using clid.db +namespace Tracker +{ +typedef Trk::PrepRawDataContainer< FaserSCT_ClusterCollection > FaserSCT_ClusterContainer; +typedef EventContainers::IdentifiableCache< FaserSCT_ClusterCollection > FaserSCT_ClusterContainerCache; +} +CLASS_DEF(Tracker::FaserSCT_ClusterContainer,1177445571,1) +CONTAINER_IS_IDENTCONT(Tracker::FaserSCT_ClusterContainer) + +CLASS_DEF( Tracker::FaserSCT_ClusterContainerCache , 1224107226, 1 ) + +#endif // TRKPREPRAWDATA_PREPRAWDATACLASS_DEF_H diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSiWidth.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSiWidth.h new file mode 100755 index 0000000000000000000000000000000000000000..2586d966b2cbcbf77656091dcbf4f47f0d5bd07d --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSiWidth.h @@ -0,0 +1,165 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/////////////////////////////////////////////////////////////////// +// FaserSiWidth.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef TRACKERRAWDATA_FASERSIWIDTH_H +#define TRACKERRAWDATA_FASERSIWIDTH_H + +#include "GeoPrimitives/GeoPrimitives.h" +#include "TrkEventPrimitives/ParamDefs.h" + +class MsgStream; + +/** standard namespace for the Tracker */ +namespace Tracker +{ +/** @class FaserSiWidth + +*/ + +class FaserSiWidth { + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// + public: + + // Implicit constructor: + FaserSiWidth(); + + // Copy constructor: + FaserSiWidth(const FaserSiWidth& position); + + // Constructor with parameters: <col, row> in units of RDOs (so should be int), + // <phiR width in mm, Z width in mm> + FaserSiWidth(const Amg::Vector2D& colrow, const Amg::Vector2D& phiRZ); + + // online constructor: only the col, row in units of RDOs + FaserSiWidth(const Amg::Vector2D& colrow); + + // Destructor: + virtual ~FaserSiWidth(); + + // Assignment operator: + FaserSiWidth &operator=(const FaserSiWidth& width); + + /////////////////////////////////////////////////////////////////// + // Const methods: + /////////////////////////////////////////////////////////////////// + + // return col row: + const Amg::Vector2D& colRow() const; + + // return phiRZ in mm: + const Amg::Vector2D& widthPhiRZ() const; + + // return PhiR + double phiR() const; + + // return z + double z() const; + + + /////////////////////////////////////////////////////////////////// + // Non-const methods: + /////////////////////////////////////////////////////////////////// + + void setColumn(const double col); + + void setRow(const double row); + + void setColRow(const Amg::Vector2D& colRow); + + void setPhirWidth(const double phirWidth); + + void setZWidth(const double zWidth); + + void setPhirzWidth(const Amg::Vector2D& phirzWidth); + + + // addition + + /** dump information about the PRD object. */ + virtual MsgStream& dump( MsgStream& stream) const; + + /** dump information about the PRD object. */ + virtual std::ostream& dump( std::ostream& stream) const; + + + //scaling + + /////////////////////////////////////////////////////////////////// + // Private data: + /////////////////////////////////////////////////////////////////// + private: + // Need to force proper alignment; otherwise cling gets it wrong. + alignas(16) Amg::Vector2D m_colrow;//<col, row> + alignas(16) Amg::Vector2D m_phirzWidth; +}; + +MsgStream& operator << (MsgStream& stream, const FaserSiWidth& prd); +std::ostream& operator << (std::ostream& stream, const FaserSiWidth& prd); + + +/////////////////////////////////////////////////////////////////// +// Inline methods: +/////////////////////////////////////////////////////////////////// +inline const Amg::Vector2D& FaserSiWidth::colRow() const +{ + return (m_colrow); +} + + +inline const Amg::Vector2D& FaserSiWidth::widthPhiRZ() const +{ + return m_phirzWidth; +} + +inline double FaserSiWidth::phiR() const +{ + return m_phirzWidth[0]; +} + +inline double FaserSiWidth::z() const +{ + return m_phirzWidth[1]; +} + +inline void FaserSiWidth::setColumn(const double col) +{ + m_colrow[0] = col; +} + +inline void FaserSiWidth::setRow(const double row) +{ + m_colrow[1] = row; +} + +inline void FaserSiWidth::setColRow(const Amg::Vector2D& colRow) +{ + m_colrow=colRow; +} + +inline void FaserSiWidth::setPhirWidth(const double phir) +{ + m_phirzWidth[0] = phir; +} +inline void FaserSiWidth::setZWidth(const double zwidth) +{ + m_phirzWidth[1] = zwidth; +} +inline void FaserSiWidth::setPhirzWidth(const Amg::Vector2D& phirzwidth) +{ + m_phirzWidth = phirzwidth; +} + + +/////////////////////////////////////////////////////////////////// +// Binary operators: +/////////////////////////////////////////////////////////////////// +} +#endif // TRACKERRAWDATA_FASERSIWIDTH_H diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerCluster.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerCluster.h new file mode 100755 index 0000000000000000000000000000000000000000..8337d2297fcf0d0592581be4d10637b69b16db28 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerCluster.h @@ -0,0 +1,152 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TrackerCluster.h +// Header file for class TrackerCluster +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Class to implement Cluster for Tracker +/////////////////////////////////////////////////////////////////// +// Version 1.0 15/07/2003 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#ifndef TRACKERPREPRAWDATA_TRACKERCLUSTER_H +#define TRACKERPREPRAWDATA_TRACKERCLUSTER_H + +// Base class +#include "TrkPrepRawData/PrepRawData.h" + +#include "CxxUtils/CachedUniquePtr.h" +#include "Identifier/Identifier.h" +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" // cant be forward declared + +#include "TrkSurfaces/Surface.h" + +#include <memory> + + +class MsgStream; + +class FaserSCT_ClusterContainerCnv; +class FaserSCT_ClusterContainerCnv_p1; +class TrackerClusterCnv_p1; +class FaserSCT_ClusterContainerCnv_p0; + +namespace Tracker +{ + class TrackerCluster : public Trk::PrepRawData { + + friend class ::FaserSCT_ClusterContainerCnv; + friend class FaserSCT_ClusterContainerCnv_p1; + friend class ::TrackerClusterCnv_p1; + friend class ::FaserSCT_ClusterContainerCnv_p0; + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// + public: + + /** Public, Copy, operator=, constructor*/ + TrackerCluster(); + TrackerCluster(const TrackerCluster &); + TrackerCluster(TrackerCluster &&); + TrackerCluster &operator=(const TrackerCluster &); + TrackerCluster &operator=(TrackerCluster &&); + + /** Only constructor for TrackerCluster. + Last datamember might not be always filled and will be 0 by default. + The others including SiDetectorElement have to be given! + */ + + TrackerCluster( + const Identifier& RDOId, + const Amg::Vector2D& locpos, + const std::vector<Identifier>& rdoList, + const FaserSiWidth& width, + const TrackerDD::SiDetectorElement* detEl, + const Amg::MatrixX* locErrMat = 0 + ); + + TrackerCluster( + const Identifier& RDOId, + const Amg::Vector2D& locpos, + std::vector<Identifier>&& rdoList, + const FaserSiWidth& width, + const TrackerDD::SiDetectorElement* detEl, + std::unique_ptr<const Amg::MatrixX> locErrMat + ); + + // Destructor: + virtual ~TrackerCluster(); + + /////////////////////////////////////////////////////////////////// + // Virtual methods + /////////////////////////////////////////////////////////////////// + + /** return width class reference */ + virtual const FaserSiWidth& width() const; + + /** return global position reference */ + virtual const Amg::Vector3D& globalPosition() const; + + /** return the detector element corresponding to this PRD + The pointer will be zero if the det el is not defined (i.e. it was not passed in by the ctor)*/ + virtual const TrackerDD::SiDetectorElement* detectorElement() const; + + /** dump information about the SiCluster*/ + virtual MsgStream& dump( MsgStream& stream) const; + /** dump information about the SiCluster*/ + virtual std::ostream& dump( std::ostream& stream) const; + + private: + FaserSiWidth m_width; //col, row, and width in mm + CxxUtils::CachedUniquePtr<const Amg::Vector3D> m_globalPosition; + const TrackerDD::SiDetectorElement* m_detEl; + + // Identifier m_clusId; + // /**see derived classes for definition of meaning of LocalPosition*/ + // // Need to force proper alignment; otherwise cling gets it wrong. + // alignas(16) Amg::Vector2D m_localPos; + // /**Stores the identifiers of the RDOs.*/ + // std::vector<Identifier> m_rdoList; + // /**See derived classes for definition of ErrorMatrix */ + // const Amg::MatrixX* m_localCovariance; + + // /**Stores its own position (index) in collection plus the hash id for the collection + // (needed for the EL to IDC) */ + // IdentContIndex m_indexAndHash; + + }; + + MsgStream& operator << (MsgStream& stream, const TrackerCluster& prd); + std::ostream& operator << (std::ostream& stream, const TrackerCluster& prd); + + /////////////////////////////////////////////////////////////////// + // Inline methods: + /////////////////////////////////////////////////////////////////// + + // return width: + inline const FaserSiWidth& TrackerCluster::width() const + { + return m_width; + } + // return globalPosition: + inline const Amg::Vector3D& TrackerCluster::globalPosition() const + { + if (not m_globalPosition) { + m_globalPosition.set(std::unique_ptr<const Amg::Vector3D>(m_detEl->surface(identify()).localToGlobal(localPosition()))); + } + return *m_globalPosition; + } + + inline const TrackerDD::SiDetectorElement* TrackerCluster::detectorElement() const + { + return m_detEl; + } + +} +#endif // TRACKERPREPRAWDATA_TRACKERCLUSTER_H diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerClusterCollection.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerClusterCollection.h new file mode 100755 index 0000000000000000000000000000000000000000..dc79f9ca6bc5d8ec162c635655253feeac05c417 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerClusterCollection.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// PrepRawDataCLASS_DEF.h +// Header file for class PrepRawDataCLASS_DEF +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Class to contain all the CLASS_DEF for Containers and Collections +/////////////////////////////////////////////////////////////////// +// Version 1.0 25/09/2002 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#ifndef TRACKERCLUSTERCOLLECTION_H +#define TRACKERCLUSTERCOLLECTION_H + +#include "AthenaKernel/CLASS_DEF.h" +#include "TrackerRawData/TrackerRawDataCollection.h" +#include "TrackerPrepRawData/TrackerCluster.h" + +// Containers +// numbers obtained using clid.db +namespace Tracker +{ +typedef TrackerRawDataCollection<TrackerCluster> TrackerClusterCollection; + +/**Overload of << operator for MsgStream for debug output*/ +MsgStream& operator << ( MsgStream& sl, const TrackerClusterCollection& coll); + +/**Overload of << operator for std::ostream for debug output*/ +std::ostream& operator << ( std::ostream& sl, const TrackerClusterCollection& coll); +} +CLASS_DEF(Tracker::TrackerClusterCollection, 1130122227, 1) + +#endif // TRACKERRAWDATA_PREPRAWDATACLASS_DEF_H diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerClusterContainer.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerClusterContainer.h new file mode 100755 index 0000000000000000000000000000000000000000..abf0490a8a2f5ea3f15767c640240bbf08e37e37 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerClusterContainer.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TrackerClusterContainer.h +// Header file for class TrackerClusterContainer +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef TRACKERPREPRAWDATA_TRACKERCLUSTERCONTAINER_H +#define TRACKERPREPRAWDATA_TRACKERCLUSTERCONTAINER_H + +#include "AthenaKernel/CLASS_DEF.h" +#include "TrkPrepRawData/PrepRawDataContainer.h" +#include "TrackerPrepRawData/TrackerClusterCollection.h" + +// Containers +// numbers obtained using clid.db +namespace Tracker { +typedef Trk::PrepRawDataContainer< TrackerClusterCollection > TrackerClusterContainer; +} + +CLASS_DEF(Tracker::TrackerClusterContainer,1281428575,1) + + + +// // Base classes +// #include "EventContainers/IdentifiableContainer.h" + +// namespace Tracker +// { +// template<class CollectionT> +// class TrackerClusterContainer +// : public IdentifiableContainer<CollectionT>{ + +// /////////////////////////////////////////////////////////////////// +// // Public methods: +// /////////////////////////////////////////////////////////////////// +// public: + +// /** Constructor with parameters:*/ +// TrackerClusterContainer(unsigned int max); + +// /** Constructor with External Cache*/ +// TrackerClusterContainer(EventContainers::IdentifiableCache<CollectionT>*); + +// /**default ctor - for POOL only*/ +// TrackerClusterContainer(); + +// /** Destructor:*/ +// virtual ~TrackerClusterContainer(); + +// /** return class ID */ +// static const CLID& classID(); + +// /** return class ID */ +// virtual const CLID& clID() const; + +// private: + +// TrackerClusterContainer(const TrackerClusterContainer&); +// TrackerClusterContainer &operator=(const TrackerClusterContainer&); + +// }; +// // member functions that use Collection T +// #include"TrackerPrepRawData/TrackerClusterContainer.icc" +// } + +#endif // TRACKERPREPRAWDATA_TRACKERCLUSTERCONTAINER_H + diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerClusterContainer.icc b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerClusterContainer.icc new file mode 100755 index 0000000000000000000000000000000000000000..581bd95320d58ada16d0cf39c2cf4eceb4896434 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerClusterContainer.icc @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TrackerClusterContainer.icc +// Implementation file for class TrackerClusterContainer +/////////////////////////////////////////////////////////////////// + + +template< class CollectionT> +// Constructor with parameters: +TrackerClusterContainer< CollectionT>::TrackerClusterContainer(unsigned int max) : + IdentifiableContainer<CollectionT>(max) +{ +} + +template< class CollectionT> +// Constructor with parameters: +TrackerClusterContainer< CollectionT>::TrackerClusterContainer() : + IdentifiableContainer<CollectionT>(0) +{ +} + +template< class CollectionT> +// Constructor with parameters: +TrackerClusterContainer< CollectionT>::TrackerClusterContainer(EventContainers::IdentifiableCache<CollectionT>* cache) : + IdentifiableContainer<CollectionT>(cache) +{ +} + + +template< class CollectionT> +// Destructor: +TrackerClusterContainer< CollectionT>::~TrackerClusterContainer() +{ +} + +template< class CollectionT> +const CLID& TrackerClusterContainer< CollectionT>::classID() +{ + return ClassID_traits< TrackerClusterContainer <CollectionT> > ::ID(); +} + +template< class CollectionT> +const CLID& TrackerClusterContainer< CollectionT>::clID() const +{ + return classID(); +} + diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerPrepRawDataDict.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerPrepRawDataDict.h new file mode 100644 index 0000000000000000000000000000000000000000..d238b1d0a5dea90fa7f68b92d13bc62c7c1904bf --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerPrepRawDataDict.h @@ -0,0 +1,56 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERPREPRAWDATADICT_H +#define TRACKERPREPRAWDATADICT_H 1 + +//#include "TrkPrepRawData/PrepRawDataCLASS_DEF.h" + +#include "TrackerPrepRawData/TrackerCluster.h" +#include "TrackerPrepRawData/TrackerClusterCollection.h" +#include "TrackerPrepRawData/TrackerClusterContainer.h" +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrkPrepRawData/PrepRawDataCollection.h" +#include "Identifier/Identifier.h" +#include "AthLinks/ElementLink.h" + +/** helper class to help reflex/gccxml to discover the right types + */ +template<class T> +struct PrdWrapper +{ + typedef typename T::const_iterator prd_iterator; +}; + +#define EXPAND_PRD(T, suffix) \ + T ## Container m_prd_ ## suffix ; \ + PrdWrapper<T ## Container> m_prd_wrapper_ ## suffix ; \ + PrdWrapper<T ## Container> ::prd_iterator m_prd_citr_ ## suffix ; \ + ::EventContainers::IdentifiableCache< Trk::PrepRawDataCollection< T > > m_dummy_dlv_ ## suffix ; \ + T ## Container ::const_iterator m_dummy_iter_ ## suffix + +namespace Tracker { + struct TrackerPrepRawDataDict_Dummy + { + DataVector<Identifier> m_identifierVector; + DataVector< Tracker::TrackerClusterCollection > m_dummyDVSiClusColl; + DataVector< Tracker::FaserSCT_ClusterCollection > m_dummyDVSCTClusColl; + TrackerClusterContainer m_dummySiContainer; + + EXPAND_PRD(Tracker::TrackerCluster, si_cluster); + EXPAND_PRD(Tracker::FaserSCT_Cluster, sct_cluster); + + ElementLink<Tracker::FaserSCT_ClusterContainer> m_dummyel_sct_cluster; + }; +} + +#undef EXPAND_DLV + +#endif + + + diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/selection.xml b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..18c119ec75b7e837f32e7815a0b9d134d1f4bfe4 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/selection.xml @@ -0,0 +1,65 @@ +<lcgdict> + <!-- for cluster --> + <!-- Si width used for SiCluster --> + <class name="Tracker::FaserSiWidth" /> + + <!-- Si cluster (parent of SCT) --> + <class name="Tracker::TrackerCluster" > + <field name="m_width" transient="false" /> + <field name="m_globalPosition" transient="true" /> + <field name="m_gangedPixel" transient="true" /> + <field name="m_detEl" transient="true" /> + </class> + + <class name="Trk::PrepRawDataCollection< Tracker::TrackerCluster >" /> + <class name="DataVector<Tracker::TrackerCluster>" /> + <class name="std::vector<Tracker::TrackerCluster*>" /> + + <class name="Tracker::TrackerClusterContainer" /> + + <class name="IdentifiableContainer<Trk::PrepRawDataCollection<Tracker::TrackerCluster> >" /> + + <class name="DataLinkVector<Trk::PrepRawDataCollection<Tracker::TrackerCluster> >" > + <field name="m_last" transient="true" /> + <field name="m_vect" transient="true" /> + </class> + + <class name="DataVector<Trk::PrepRawDataCollection<Tracker::TrackerCluster> >" id="185DC2D5-0448-4C19-BCEA-4C2774D1A585" /> <!--was:2DB8F9D6-B403-4C4C-9BBF-8D4E74316C9A --> + <class name="std::vector<DataLinkVector<Trk::PrepRawDataCollection<Tracker::TrackerCluster> >::Entry>" /> + <class name="std::vector<Trk::PrepRawDataCollection<Tracker::TrackerCluster>* >" /> + + <!-- SCT --> + <class name="Tracker::FaserSCT_Cluster" /> + + <class name="Trk::PrepRawDataCollection< Tracker::FaserSCT_Cluster >" /> + <class name="DataVector<Tracker::FaserSCT_Cluster>" /> + <class name="std::vector<Tracker::FaserSCT_Cluster*>" /> + + <class name="Tracker::FaserSCT_ClusterContainer" /> + + <class name="IdentifiableContainer<Trk::PrepRawDataCollection<Tracker::FaserSCT_Cluster> >" /> + + <class name="DataLinkVector<Trk::PrepRawDataCollection<Tracker::FaserSCT_Cluster> >" > + <field name="m_last" transient="true" /> + <field name="m_vect" transient="true" /> + </class> + + <class name="std::vector<DataLinkVector<Trk::PrepRawDataCollection<Tracker::FaserSCT_Cluster> >::Entry>" /> + <class name="DataVector<Trk::PrepRawDataCollection<Tracker::FaserSCT_Cluster> >" id="586ED4E3-FA8F-4A9D-A919-9D42221975B8"/> <!-- was: A180F372-0D52-49C3-8AA0-0939CB0B8179 --> + <class name="std::vector<Trk::PrepRawDataCollection<Tracker::FaserSCT_Cluster>* >" /> + + + <class name="ElementLink<Tracker::FaserSCT_ClusterContainer>"/> + <class name="ElementLink<Tracker::FaserSCT_ClusterContainer>::Base"/> + + <class name="PrdWrapper<Tracker::FaserSCT_ClusterContainer>::prd_iterator" /> + <class name="PrdWrapper<Tracker::FaserSCT_ClusterContainer>::prd_entry" /> + <class name="PrdWrapper<Tracker::FaserSCT_ClusterContainer>::prd_data_holder" /> + + <class name="PrdWrapper<Tracker::TrackerClusterContainer>::prd_iterator" /> + <class name="PrdWrapper<Tracker::TrackerClusterContainer>::prd_entry" /> + <class name="PrdWrapper<Tracker::TrackerClusterContainer>::prd_data_holder" /> + +</lcgdict> + + diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/src/FaserSCT_Cluster.cxx b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/FaserSCT_Cluster.cxx new file mode 100755 index 0000000000000000000000000000000000000000..7c4b9f474e9166376c117be1b83d1386c69e4b60 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/FaserSCT_Cluster.cxx @@ -0,0 +1,112 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + */ + +/////////////////////////////////////////////////////////////////// +// FaserSCT_Cluster.cxx +// Implementation file for class FaserSCT_Cluster +/////////////////////////////////////////////////////////////////// + +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +// forward includes +#include "GaudiKernel/MsgStream.h" +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +namespace Tracker { + +FaserSCT_Cluster::FaserSCT_Cluster( + const Identifier& RDOId, + const Amg::Vector2D& locpos, + const std::vector<Identifier>& rdoList, + const FaserSiWidth& width, + const TrackerDD::SiDetectorElement* detEl, + const Amg::MatrixX* locErrMat + ) : TrackerCluster(RDOId, locpos, rdoList, width, detEl, locErrMat) +{ + m_hitsInThirdTimeBin=0; +} + +FaserSCT_Cluster::FaserSCT_Cluster( + const Identifier& RDOId, + const Amg::Vector2D& locpos, + std::vector<Identifier>&& rdoList, + const FaserSiWidth& width, + const TrackerDD::SiDetectorElement* detEl, + std::unique_ptr<const Amg::MatrixX> locErrMat + ) : TrackerCluster(RDOId, locpos, + std::move(rdoList), width, detEl, + std::move(locErrMat)), + m_hitsInThirdTimeBin(0) +{ +} + +// Default constructor: +FaserSCT_Cluster::FaserSCT_Cluster():TrackerCluster() +{ + m_hitsInThirdTimeBin=0; +} + +//copy constructor: +FaserSCT_Cluster::FaserSCT_Cluster(const FaserSCT_Cluster& RIO): + TrackerCluster(RIO) +{ + m_hitsInThirdTimeBin = RIO.hitsInThirdTimeBin(); +} + +//move constructor: +FaserSCT_Cluster::FaserSCT_Cluster(FaserSCT_Cluster&& RIO): + TrackerCluster(std::move(RIO)), + m_hitsInThirdTimeBin (RIO.m_hitsInThirdTimeBin) +{ +} + +//assignment operator +FaserSCT_Cluster& FaserSCT_Cluster::operator=(const FaserSCT_Cluster& RIO){ + if(&RIO != this) { + TrackerCluster::operator=(RIO); + m_hitsInThirdTimeBin = RIO.m_hitsInThirdTimeBin; + } + return *this; +} + +//move operator +FaserSCT_Cluster& FaserSCT_Cluster::operator=(FaserSCT_Cluster&& RIO) { + if(&RIO != this) { + TrackerCluster::operator=(std::move(RIO)); + m_hitsInThirdTimeBin = RIO.m_hitsInThirdTimeBin; + } + return *this; +} + + +MsgStream& operator << (MsgStream& stream, const FaserSCT_Cluster& prd) +{ + return prd.dump(stream); +} + +std::ostream& operator << (std::ostream& stream, const FaserSCT_Cluster& prd) +{ + return prd.dump(stream); +} + +MsgStream& FaserSCT_Cluster::dump( MsgStream& stream) const +{ + stream << "FaserSCT_Cluster object"<<std::endl; + stream << "Base class (TrackerCluster):" << std::endl; + this->TrackerCluster::dump(stream); + + return stream; +} + +std::ostream& FaserSCT_Cluster::dump( std::ostream& stream) const +{ + stream << "FaserSCT_Cluster object"<<std::endl; + stream << "Base class (TrackerCluster):" << std::endl; + this->TrackerCluster::dump(stream); + + return stream; +} + + +} \ No newline at end of file diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/src/FaserSCT_ClusterCollection.cxx b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/FaserSCT_ClusterCollection.cxx new file mode 100644 index 0000000000000000000000000000000000000000..205f44c0344f477f0fe2391a9f7a1ebdb9bd568b --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/FaserSCT_ClusterCollection.cxx @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + */ + +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "GaudiKernel/MsgStream.h" + +namespace Tracker { +MsgStream& operator << ( MsgStream& sl, const FaserSCT_ClusterCollection& coll) +{ + sl << "FaserSCT_ClusterCollection: " + << "identify()="<< coll.identify() + // << ", identifyHash()="<< coll.identifyHash() + << ", PRD=["; + FaserSCT_ClusterCollection::const_iterator it = coll.begin(); + FaserSCT_ClusterCollection::const_iterator itEnd = coll.end(); + for (;it!=itEnd;++it) sl<< (**it)<<", "; + sl <<" ]"<<std::endl; + return sl; +} + +std::ostream& operator << ( std::ostream& sl, const FaserSCT_ClusterCollection& coll) +{ + sl << "FaserSCT_ClusterCollection: " + << "identify()="<< coll.identify() + // << ", identifyHash()="<< coll.identifyHash() + << ", PRD=["; + FaserSCT_ClusterCollection::const_iterator it = coll.begin(); + FaserSCT_ClusterCollection::const_iterator itEnd = coll.end(); + for (;it!=itEnd;++it) sl<< (**it)<<", "; + sl <<" ]"<<std::endl; + return sl; +} + +} \ No newline at end of file diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/src/FaserSiWidth.cxx b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/FaserSiWidth.cxx new file mode 100755 index 0000000000000000000000000000000000000000..9795af08edb40bca23ca8d882c0d105345fc04e8 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/FaserSiWidth.cxx @@ -0,0 +1,85 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// FaserSiWidth.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "GaudiKernel/MsgStream.h" + +namespace Tracker { +// Implicit constructor: +FaserSiWidth::FaserSiWidth() : + m_colrow(0.0, 0.0), + m_phirzWidth(0.0, 0.0) +{} + +// Copy constructor: +FaserSiWidth::FaserSiWidth(const FaserSiWidth& width) : + m_colrow(width.m_colrow), + m_phirzWidth(width.m_phirzWidth) +{} + +// Constructor with parameters: +FaserSiWidth::FaserSiWidth(const Amg::Vector2D& colrow, const Amg::Vector2D& phiRZ) : + m_colrow( colrow ), + m_phirzWidth(phiRZ) +{} + + +// online constructor: +FaserSiWidth::FaserSiWidth(const Amg::Vector2D& colrow) : + m_colrow(colrow), + m_phirzWidth(0,0) +{} + + +// Destructor: +FaserSiWidth::~FaserSiWidth() +{ +} + +// Assignment operator: +FaserSiWidth& FaserSiWidth::operator=(const FaserSiWidth &width) +{ + if (this!=&width) { + m_colrow = width.m_colrow; + m_phirzWidth = width.m_phirzWidth; + } + return *this; +} + +// addition of positions: + + +// scaling: + +// Dump methods +MsgStream& FaserSiWidth::dump( MsgStream& stream) const +{ + stream << "FaserSiWidth object"<<std::endl; + stream << "Column / Row " << m_colrow.x() << " " << m_colrow.y() << std::endl; + stream << "phi RZ width " << m_phirzWidth.x() << " " << m_phirzWidth.y() << std::endl; + return stream; +} +std::ostream& FaserSiWidth::dump( std::ostream& stream) const +{ + stream << "FaserSiWidth object"<<std::endl; + stream <<"Column / Row " << m_colrow.x() << " " << m_colrow.y() << std::endl; + stream <<"phi RZ width " << m_phirzWidth.x() << " " << m_phirzWidth.y() << std::endl; + return stream; +} + +MsgStream& operator << (MsgStream& stream, const FaserSiWidth& prd) +{ + return prd.dump(stream); +} + +std::ostream& operator << (std::ostream& stream, const FaserSiWidth& prd) +{ + return prd.dump(stream); +} + +} \ No newline at end of file diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerCluster.cxx b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerCluster.cxx new file mode 100755 index 0000000000000000000000000000000000000000..a590bf8d1bf31edec0023b52847096eecbca52ce --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerCluster.cxx @@ -0,0 +1,156 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/////////////////////////////////////////////////////////////////// +// TrackerCluster.cxx +// Implementation file for class TrackerCluster +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Version 1.0 15/07/2003 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#include "TrackerPrepRawData/TrackerCluster.h" +#include "GaudiKernel/MsgStream.h" + +namespace Tracker { +// Constructor for EF: +TrackerCluster::TrackerCluster( + const Identifier &RDOId, + const Amg::Vector2D& locpos, + const std::vector<Identifier>& rdoList, + const FaserSiWidth& width, + const TrackerDD::SiDetectorElement* detEl, + const Amg::MatrixX* locErrMat + ) : + PrepRawData(RDOId, locpos, rdoList, locErrMat), //call base class constructor + m_width(width), + m_globalPosition{}, + m_detEl(detEl) {} + + TrackerCluster::TrackerCluster( + const Identifier &RDOId, + const Amg::Vector2D& locpos, + std::vector<Identifier>&& rdoList, + const FaserSiWidth& width, + const TrackerDD::SiDetectorElement* detEl, + std::unique_ptr<const Amg::MatrixX> locErrMat + ) : + PrepRawData(RDOId, locpos, + std::move(rdoList), + std::move(locErrMat)), //call base class constructor + m_width(width), + m_globalPosition{}, + m_detEl(detEl) {} + + // Destructor: +TrackerCluster::~TrackerCluster() +{ + // do not delete m_detEl since owned by DetectorStore +} + +// Default constructor: +TrackerCluster::TrackerCluster(): + m_globalPosition{}, + m_detEl(0) +{} + +//copy constructor: +TrackerCluster::TrackerCluster(const TrackerCluster& RIO): + PrepRawData( RIO ), + m_width( RIO.m_width ), + m_globalPosition{}, + m_detEl( RIO.m_detEl ) + +{ + // copy only if it exists + if (RIO.m_globalPosition) { + m_globalPosition.set(std::make_unique<Amg::Vector3D>(*RIO.m_globalPosition)); + } +} + +//move constructor: +TrackerCluster::TrackerCluster(TrackerCluster&& RIO): + PrepRawData( std::move(RIO) ), + m_width( std::move(RIO.m_width) ), + m_globalPosition( std::move(RIO.m_globalPosition) ), + m_detEl( RIO.m_detEl ) + +{ +} + +//assignment operator +TrackerCluster& TrackerCluster::operator=(const TrackerCluster& RIO){ + if (&RIO !=this) { + Trk::PrepRawData::operator= (RIO); + m_width = RIO.m_width; + if (RIO.m_globalPosition) { + m_globalPosition.set(std::make_unique<Amg::Vector3D>(*RIO.m_globalPosition)); + } else if (m_globalPosition) { + m_globalPosition.release().reset(); + } + m_detEl = RIO.m_detEl ; + } + return *this; +} + +//move operator +TrackerCluster& TrackerCluster::operator=(TrackerCluster&& RIO){ + if (&RIO !=this) { + Trk::PrepRawData::operator= (std::move(RIO)); + m_width = RIO.m_width; + m_globalPosition = std::move(RIO.m_globalPosition); + m_detEl = RIO.m_detEl ; + } + return *this; +} + +MsgStream& TrackerCluster::dump( MsgStream& stream) const +{ + stream << "TrackerCluster object"<<std::endl; + + // have to do a lot of annoying checking to make sure that PRD is valid. + { + stream << "at global coordinates (x,y,z) = ("<<this->globalPosition().x()<<", " + <<this->globalPosition().y()<<", " + <<this->globalPosition().z()<<")"<<std::endl; + } + + stream << "FaserSiWidth: " << m_width << std::endl; + + stream << "Base class (PrepRawData):" << std::endl; + this->PrepRawData::dump(stream); + + return stream; +} + +std::ostream& TrackerCluster::dump( std::ostream& stream) const +{ + stream << "TrackerCluster object"<<std::endl; + { + stream << "at global coordinates (x,y,z) = ("<<this->globalPosition().x()<<", " + <<this->globalPosition().y()<<", " + <<this->globalPosition().z()<<")"<<std::endl; + } + + stream << "FaserSiWidth: " << m_width << std::endl; + + stream << "Base Class (PrepRawData): " << std::endl; + this->PrepRawData::dump(stream); + + return stream; +} + + +MsgStream& operator << (MsgStream& stream, const TrackerCluster& prd) +{ + return prd.dump(stream); +} + +std::ostream& operator << (std::ostream& stream, const TrackerCluster& prd) +{ + return prd.dump(stream); +} + +} diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerClusterCollection.cxx b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerClusterCollection.cxx new file mode 100644 index 0000000000000000000000000000000000000000..62dc13665a4d8adbe722c59642d921890f450d9d --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerClusterCollection.cxx @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrackerPrepRawData/TrackerClusterCollection.h" +#include "GaudiKernel/MsgStream.h" + +namespace Tracker { + +MsgStream& operator << ( MsgStream& sl, const TrackerClusterCollection& coll) +{ + sl << "TrackerClusterCollection: " + << "identify()="<< coll.identify() + // << ", identifyHash()="<< coll.identifyHash() + << ", PRD=["; + TrackerClusterCollection::const_iterator it = coll.begin(); + TrackerClusterCollection::const_iterator itEnd = coll.end(); + for (;it!=itEnd;++it) sl<< (**it)<<", "; + sl <<" ]"<<std::endl; + return sl; +} + +std::ostream& operator << ( std::ostream& sl, const TrackerClusterCollection& coll) +{ + sl << "TrackerClusterCollection: " + << "identify()="<< coll.identify() + // << ", identifyHash()="<< coll.identifyHash() + << ", PRD=["; + TrackerClusterCollection::const_iterator it = coll.begin(); + TrackerClusterCollection::const_iterator itEnd = coll.end(); + for (;it!=itEnd;++it) sl<< (**it)<<", "; + sl <<" ]"<<std::endl; + return sl; +} + +} \ No newline at end of file diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/CMakeLists.txt b/Tracker/TrackerRecEvent/TrackerSpacePoint/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ef83b3962ebd403755981f7c0331e790674e53c3 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/CMakeLists.txt @@ -0,0 +1,30 @@ +################################################################################ +# Package: TrackerSpacePoint +################################################################################ + +# Declare the package name: +atlas_subdir( TrackerSpacePoint ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + DetectorDescription/Identifier + Tracking/TrkDetDescr/TrkDetElementBase + Tracking/TrkEvent/TrkSpacePoint + PRIVATE + DetectorDescription/GeoPrimitives + Event/EventPrimitives + Tracking/TrkDetDescr/TrkSurfaces + Tracking/TrkEvent/TrkEventPrimitives + Tracking/TrkEvent/TrkPrepRawData ) + +# External dependencies: +find_package( Eigen ) + +# Component(s) in the package: +atlas_add_library( TrackerSpacePoint + src/*.cxx src/*.h + PUBLIC_HEADERS TrackerSpacePoint + PRIVATE_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES Identifier TrkDetElementBase TrkSpacePoint + PRIVATE_LINK_LIBRARIES ${EIGEN_LIBRARIES} GeoPrimitives EventPrimitives TrkSurfaces TrkEventPrimitives TrkPrepRawData ) + diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/ATLAS_CHECK_THREAD_SAFETY b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..41e637f7f57bb8ac389803efb2bdebeb3b8b6d61 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +Tracker/TrackerRecEvent/TrackerSpacePoint \ No newline at end of file diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h new file mode 100755 index 0000000000000000000000000000000000000000..8a6b7aceb2b233388699f0b7d11f7e874599de44 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h @@ -0,0 +1,105 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// SCT_SpacePoint.h +// Header file for class SCT_SpacePoint +/////////////////////////////////////////////////////////////////// +// Class to handle SPs for SCT +/////////////////////////////////////////////////////////////////// +// Version 1.0 12/12/2005 Martin Siebel +/////////////////////////////////////////////////////////////////// +#ifndef TRACKERSPACEPOINT_SCTSPACEPOINT_H +#define TRACKERSPACEPOINT_SCTSPACEPOINT_H + +#include "TrkSpacePoint/SpacePoint.h" +#include "Identifier/IdentifierHash.h" + +namespace Trk +{ + class TrackerCluster; +} + +namespace Tracker +{ + /** + * @class SCT_SpacePoint + * An SCT_SpacePoint is created from two SCT_Cluster's from two different wafers. + */ + + class FaserSCT_SpacePoint : public Trk::SpacePoint + { + + /////////////////////////////`////////////////////////////////////// + // 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 Trk::PrepRawData*, const Trk::PrepRawData*>* 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 Trk::PrepRawData*, const Trk::PrepRawData*>* clusList) ; + + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>* 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 Trk::PrepRawData*, const Trk::PrepRawData*>* clusList) ; + //@} + + /** Copy Constructor */ + FaserSCT_SpacePoint(const FaserSCT_SpacePoint &) ; + + /** Destructor */ + virtual ~FaserSCT_SpacePoint() = default; + + /** Overloading Assignment Operator */ + FaserSCT_SpacePoint &operator=(const FaserSCT_SpacePoint &); + + /** Clones */ + virtual Trk::SpacePoint* clone() const ; + + /**Interface method for output, to be overloaded by child classes* */ + virtual MsgStream& dump( MsgStream& out ) const ; + + /**Interface method for output, to be overloaded by child classes* */ + virtual std::ostream& dump( std::ostream& out ) const ; + + private: + + /** 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 Trk::PrepRawData*, const Trk::PrepRawData*>* clusList); + }; + + /////////////////////////////////////////////////////////////////// + // Inline methods: + /////////////////////////////////////////////////////////////////// + + inline Trk::SpacePoint* FaserSCT_SpacePoint::clone() const + { return new FaserSCT_SpacePoint(*this) ; } + +} +#endif // TRACKERSPACEPOINT_SCTSPACEPOINT_H diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx new file mode 100755 index 0000000000000000000000000000000000000000..c474146bf136ff558a56f2158eb455e1cc4aa3b8 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx @@ -0,0 +1,172 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrkPrepRawData/PrepRawData.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrkEventPrimitives/LocalParameters.h" +#include "TrkSurfaces/Surface.h" +#include "EventPrimitives/EventPrimitivesToStringConverter.h" +#include "GeoPrimitives/GeoPrimitivesToStringConverter.h" + +namespace Tracker +{ + //------------------------------------------------------------- + + FaserSCT_SpacePoint::FaserSCT_SpacePoint() + : + Trk::SpacePoint() + {} + + //------------------------------------------------------------- + + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>* clusList) + : + Trk::SpacePoint() + { + setup(elementIdList,*position,clusList); + setupLocalCovarianceSCT(); + setupGlobalFromLocalCovariance(); + delete position; + } + + //------------------------------------------------------------- + + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const Amg::MatrixX* loccov, + const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>* clusList) + : + Trk::SpacePoint() + { + Trk::MeasurementBase::m_localCovariance = *loccov; + setup(elementIdList,*position,clusList); + setupGlobalFromLocalCovariance(); + delete loccov; + delete position; + } + + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>* clusList) + : + Trk::SpacePoint() + { + setup(elementIdList,position,clusList); + setupLocalCovarianceSCT(); + setupGlobalFromLocalCovariance(); + } + + //------------------------------------------------------------- + + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const Amg::MatrixX& loccov, + const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>* clusList) + : + Trk::SpacePoint() + { + Trk::MeasurementBase::m_localCovariance = loccov; + setup(elementIdList,position,clusList); + setupGlobalFromLocalCovariance(); + } + + + //------------------------------------------------------------- + + void FaserSCT_SpacePoint::setup(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>* clusList) + { + m_clusList = clusList ; + m_position = position ; + m_elemIdList.first = elementIdList.first ; + m_elemIdList.second = elementIdList.second ; + assert( (clusList->first!=0) && (clusList->second!=0) ); + assert(clusList->first->detectorElement()) ; + const Amg::Vector2D* locpos = (clusList->first->detectorElement()->surface().globalToLocal(position)) ; + assert(locpos); + Trk::MeasurementBase::m_localParams = Trk::LocalParameters(*locpos ) ; + delete locpos ; + + } + + //------------------------------------------------------------- + + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const FaserSCT_SpacePoint &o) + : + Trk::SpacePoint(o) + { + } + + //------------------------------------------------------------- + + //--------------------------------------------------------------- + + void FaserSCT_SpacePoint::setupLocalCovarianceSCT() + { + + /* For performance reason only, the error is assumed constant. + numbers are taken from + Trigger/TrigTools/TrigOfflineSpacePointTool/OfflineSpacePointProviderTool */ + + double deltaY = 0.0004; // roughly pitch of SCT (80 mu) / sqrt(12) + + Amg::MatrixX cov(2,2); + cov<< + 1.*deltaY, 25.*deltaY, + 25.*deltaY, 1600.*deltaY; + + Trk::MeasurementBase::m_localCovariance = cov; + } + +//------------------------------------------------------------- + +MsgStream& FaserSCT_SpacePoint::dump( MsgStream& out ) const +{ + out << "FaserSCT_SpacePoint contains: " << std::endl; + out << "Identifier Hashes ( " << int(this->elementIdList().first) << " , " ; + out << int(this->elementIdList().second) << " ) " << std::endl ; + out << "Global Position: " << Amg::toString(this->globalPosition(),3) << std::endl; + out << "Global Covariance Matrix " << Amg::toString(this->globCovariance(),3) << std::endl; + out << "Local Parameters " << this->localParameters() << std::endl; + out << "Local Covariance " << Amg::toString(this->localCovariance()) << std::endl; + out << "Cluster 1 :" << std::endl << (*this->clusterList().first) << std::endl; + out << "Cluster 2 :" << std::endl << (*this->clusterList().second) << std::endl; + + return out; +} + +//------------------------------------------------------------- + + +std::ostream& FaserSCT_SpacePoint::dump( std::ostream& out ) const +{ + out << "FaserSCT_SpacePoint contains: " << std::endl; + out << "Identifier Hashes ( " << int(this->elementIdList().first) << " , " ; + out << int(this->elementIdList().second) << " ) " << std::endl ; + out << "Global Position: " << Amg::toString(this->globalPosition(),3) << std::endl; + out << "Global Covariance Matrix " << Amg::toString(this->globCovariance(),3) << std::endl; + out << "Local Parameters " << this->localParameters() << std::endl; + out << "Local Covariance " << Amg::toString(this->localCovariance()) << std::endl; + out << "Cluster 1 :" << std::endl << (*this->clusterList().first) << std::endl; + out << "Cluster 2 :" << std::endl << (*this->clusterList().second) << std::endl; + + return out; +} + + // ------------------------------------------------------------------ + + //assignment operator + FaserSCT_SpacePoint& FaserSCT_SpacePoint::operator=(const FaserSCT_SpacePoint& o) + { + if (&o !=this) + { + Trk::SpacePoint::operator=(o); + } + return *this; + } + +} \ No newline at end of file diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/CMakeLists.txt b/Tracker/TrackerRecTools/FaserSiClusterizationTool/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b0fd5a539a49b6b1be0b69aafe2c6433e6d7a4e2 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/CMakeLists.txt @@ -0,0 +1,61 @@ +################################################################################ +# Package: FaserSiClusterizationTool +################################################################################ + +# Declare the package name: +atlas_subdir( FaserSiClusterizationTool ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( + PUBLIC + Control/AthenaBaseComps + Control/AthenaKernel + DetectorDescription/GeoPrimitives + DetectorDescription/Identifier + Event/EventPrimitives + GaudiKernel + Tracker/TrackerRawEvent/TrackerSimData +############# InnerDetector/InDetConditions/InDetConditionsSummaryService +############# InnerDetector/InDetConditions/InDetCondTools + Tracker/TrackerDetDescr/TrackerIdentifier + Tracker/TrackerDetDescr/TrackerReadoutGeometry + Tracker/TrackerDetDescr/FaserSCT_ReadoutGeometry + Tracker/TrackerRawEvent/TrackerRawData + Tracker/TrackerRecEvent/TrackerPrepRawData + InnerDetector/InDetRecTools/InDetRecToolInterfaces + Tracking/TrkEvent/TrkParameters + PRIVATE + Control/CxxUtils + Database/AthenaPOOL/AthenaPoolUtilities + Database/AthenaPOOL/PoolSvc + Database/APR/FileCatalog + DetectorDescription/FaserDetDescr + DetectorDescription/DetDescrCond/DetDescrCondTools + Tracking/TrkDetDescr/TrkSurfaces + Tracking/TrkEvent/TrkEventPrimitives + Tracking/TrkEvent/VxVertex ) + +# External dependencies: +find_package( CLHEP ) +find_package( ROOT COMPONENTS Core MathCore Hist ) + +# Component(s) in the package: +atlas_add_library( FaserSiClusterizationToolLib + FaserSiClusterizationTool/*.h src/*.cxx src/*.h + PUBLIC_HEADERS FaserSiClusterizationTool + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + PRIVATE_INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} + PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps AthenaKernel GeoPrimitives + Identifier EventPrimitives GaudiKernel TrackerSimData TrackerIdentifier + TrackerReadoutGeometry TrackerRawData TrackerPrepRawData InDetRecToolInterfaces + TrkParameters CxxUtils + PRIVATE_LINK_LIBRARIES ${CLHEP_LIBRARIES} AthenaPoolUtilities FileCatalog FaserDetDescr + TrkSurfaces TrkEventPrimitives VxVertex ) + +atlas_add_component( FaserSiClusterizationTool + src/components/*.cxx + LINK_LIBRARIES GaudiKernel FaserSiClusterizationToolLib ) + +# Install files from the package: +atlas_install_joboptions( share/*.py ) diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/FaserSiClusterizationTool/IFaserSCT_ClusteringTool.h b/Tracker/TrackerRecTools/FaserSiClusterizationTool/FaserSiClusterizationTool/IFaserSCT_ClusteringTool.h new file mode 100644 index 0000000000000000000000000000000000000000..9041f0a827807cd04a509cb440c5396d1f8f9fa0 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/FaserSiClusterizationTool/IFaserSCT_ClusteringTool.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file IFaserSCT_ClusteringTool.h + * Header file for the IFaserSCT_ClusteringTool clas + * @author Paul J. Bell, 2004 + */ + + +#ifndef FASERSICLUSTERIZATIONTOOL_IFASERSCT_CLUSTERINGTOOL_H +#define FASERSICLUSTERIZATIONTOOL_IFASERSCT_CLUSTERINGTOOL_H + +// Base class +#include "GaudiKernel/IAlgTool.h" +#include "TrackerRawData/TrackerRawDataCollection.h" +#include "TrackerRawData/FaserSCT_RDORawData.h" + +// no forward declare ... typedef +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "GaudiKernel/ToolHandle.h" + +class FaserSCT_ID; + +class FaserSCT_ChannelStatusAlg; + +namespace Tracker { + ///Interface for SCT clustering algorithms, taking input from RDOs + class IFaserSCT_ClusteringTool : virtual public IAlgTool + { + public: + + // InterfaceID + DeclareInterfaceID(IFaserSCT_ClusteringTool, 1, 0); + + virtual ~IFaserSCT_ClusteringTool() = default; + + /** Deprecated method: Clusterize a collection of SCT raw data objects + * Called from SCT_clusterization algorithm in InDetPrepRawDataFormation, + * once per module + * @param[in] @c RDOs the raw data objects + * @param[in] @c manager the detector manager + * @param[in] @c idHelper the SCT helper class + * @param[in] @c status the class providing information on the channel status (good, masked, + * noisy, dead) for removal of bad channels from clustering + * @param[in] flag to control if bad channel removal from clusters is done + */ + virtual Tracker::FaserSCT_ClusterCollection* clusterize(const TrackerRawDataCollection<FaserSCT_RDORawData>& RDOs, + const FaserSCT_ID& idHelper, + const FaserSCT_ChannelStatusAlg* status, + const bool CTBBadChannels) const = 0; + + /** Clusterize a collection of SCT raw data objects + * Called from SCT_clusterization algorithm in InDetPrepRawDataFormation, + * once per module + * @param[in] @c RDOs the raw data objects + * @param[in] @c manager the detector manager + * @param[in] @c idHelper the SCT helper class + * @param[in] @c status the class providing information on the channel status (good/bad) for removal of bad channels from clustering + */ + virtual Tracker::FaserSCT_ClusterCollection *clusterize(const TrackerRawDataCollection<FaserSCT_RDORawData>& rdoCollection, + const FaserSCT_ID& idHelper) const = 0; + }; +} +#endif // FASERSICLUSTERIZATIONTOOL_I_FASERSCT_CLUSTERINGTOOL_H diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.cxx b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b8c6cfbae285b0470f32d511df4a8b220613d4f7 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.cxx @@ -0,0 +1,723 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file FaserSCT_ClusterigTool.cxx + * Implementation file for the FaserSCT_ClusteringTool + * @ author Paul J. Bell, 2004; Shaun Roe, 2007; Carl Gwilliam, 2008 + **/ + +#include "FaserSCT_ClusteringTool.h" +#include "TrackerRawData/TrackerRawDataCollection.h" +#include "TrackerRawData/FaserSCT_RDORawData.h" +#include "TrackerRawData/FaserSCT3_RawData.h" +#include "TrackerReadoutGeometry/SCT_ModuleSideDesign.h" +#include "TrackerReadoutGeometry/SCT_BarrelModuleSideDesign.h" +#include "TrackerReadoutGeometry/SiCellId.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" +#include "TrackerReadoutGeometry/SiDetectorDesign.h" +#include "TrackerReadoutGeometry/SiLocalPosition.h" +#include "TrackerPrepRawData/FaserSiWidth.h" +#include "Identifier/IdentifierHash.h" +#include "TrackerIdentifier/FaserSCT_ID.h" + +#include "FaserSCT_ReClustering.h" + +#include "GeoPrimitives/GeoPrimitives.h" + +#include <algorithm> + +namespace Tracker +{ + // Functor to enable sorting of RDOs by first strip + class strip_less_than { + public: + bool operator()(const FaserSCT_RDORawData* rdo1, const FaserSCT_RDORawData* rdo2) { + return rdo1->identify() < rdo2->identify(); + } + }; + + // Are two strips adjacent? + bool adjacent(unsigned int strip1, unsigned int strip2) { + return ((1 == (strip2-strip1)) or (1 == (strip1-strip2))); + } + + //version for when using rows + bool adjacent(const unsigned int strip1, const int row1, const unsigned int strip2, const int row2){ + return ((row1==row2) and ((1 == (strip2-strip1)) or (1 == (strip1-strip2)))); + } + + // Constructor with parameters: + FaserSCT_ClusteringTool::FaserSCT_ClusteringTool(const std::string& type, const std::string& name, const IInterface* parent) : + base_class(type, name, parent) + { + } + + StatusCode FaserSCT_ClusteringTool::decodeTimeBins() { + // Decode time bins from string of form e.g. "01X" to integer bits (-1 means X) + m_timeBinBits[0] = -1; + m_timeBinBits[1] = -1; + m_timeBinBits[2] = -1; + + if (m_timeBinStr.empty()) return StatusCode::SUCCESS; + if (m_timeBinStr.size() != 3) { + ATH_MSG_FATAL("Time bin string must only contain 3 bins"); + return StatusCode::FAILURE; + } + std::transform(m_timeBinStr.begin(), m_timeBinStr.end(), m_timeBinStr.begin(), ::toupper); + + for (unsigned int i(0); i<m_timeBinStr.size(); ++i) { + int timeBin(-999); + if (decodeTimeBin(m_timeBinStr[i], timeBin).isFailure()) return StatusCode::FAILURE; + m_timeBinBits[i] = timeBin; + } + + return StatusCode::SUCCESS; + } + + StatusCode FaserSCT_ClusteringTool::decodeTimeBin(char timeBin, int& bit) const { + // Decode individual time char + if (timeBin == 'X') {bit = -1; return StatusCode::SUCCESS;} + if (timeBin == '0') {bit = 0; return StatusCode::SUCCESS;} + if (timeBin == '1') {bit = 1; return StatusCode::SUCCESS;} + + ATH_MSG_FATAL("Invalid time bin string " << timeBin); + return StatusCode::FAILURE; + } + + bool FaserSCT_ClusteringTool::testTimeBins(int timeBin) const { + // Convert the given timebin to a bit set and test each bit + // if bit is -1 (i.e. X) it always passes, other wise require exact match of 0/1 + // N.B bitset has opposite order to the bit pattern we define + + const std::bitset<3> timePattern(static_cast<unsigned long>(timeBin)); + return testTimeBinsN(timePattern); + } + + bool FaserSCT_ClusteringTool::testTimeBins01X(int timeBin) const { + // Convert the given timebin to a bit set and test each bit + // if bit is -1 (i.e. X) it always passes, otherwise require exact match of 0/1 + // N.B bitset has opposite order to the bit pattern we define + + bool pass(true); + const std::bitset<3> timePattern(static_cast<unsigned long>(timeBin)); + if (timePattern.test(2) != false) pass=false; + if (timePattern.test(1) != true) pass=false; + return pass; + } + + bool FaserSCT_ClusteringTool::testTimeBinsX1X(int timeBin) const { + // Convert the given timebin to a bit set and test each bit + // if bit is -1 (i.e. X) it always passes, otherwise require exact match of 0/1 + // N.B bitset has opposite order to the bit pattern we define + + bool pass(true); + const std::bitset<3> timePattern(static_cast<unsigned long>(timeBin)); + if (timePattern.test(1) != true) pass=false; + return pass; + } + + StatusCode FaserSCT_ClusteringTool::initialize() { + ATH_MSG_INFO("Initialize clustering tool"); + + ATH_CHECK(m_clusterMaker.retrieve()); + +// if (m_checkBadChannels) { +// ATH_MSG_INFO("Clustering has been asked to look at bad channel info"); +// ATH_CHECK(m_conditionsTool.retrieve()); +// } else { +// m_conditionsTool.disable(); +// } + + if (m_doNewClustering and not m_lorentzAngleTool.empty()) { + ATH_CHECK(m_lorentzAngleTool.retrieve()); + } else { + m_lorentzAngleTool.disable(); + } + + if (decodeTimeBins().isFailure()) return StatusCode::FAILURE; + + if (!m_timeBinStr.empty()) + { + ATH_MSG_INFO("Timing requirement: m_timeBinStr " << m_timeBinStr << " is used for clustering"); + } + else + { + ATH_MSG_INFO("Timing requirement is not used for clustering"); + } + + ATH_CHECK(m_SCTDetEleCollKey.initialize()); + + return StatusCode::SUCCESS; + } + + Tracker::FaserSCT_ClusterCollection* FaserSCT_ClusteringTool::clusterize(const TrackerRawDataCollection<FaserSCT_RDORawData>& collection, + const FaserSCT_ID& idHelper, + const FaserSCT_ChannelStatusAlg* /*status */, + const bool /*CTBBadChannels */) const + { + ATH_MSG_INFO( "You have invoked the deprecated form of clusterize(...), please use the new interface, of the form clusterize(TrackerRawDataCollection<SCT_RDORawData> & collection,SCT_ID& idHelper)"); + return clusterize(collection, idHelper); + } + + void FaserSCT_ClusteringTool::addStripsToCluster(const Identifier& firstStripId, unsigned int nStrips, + std::vector<Identifier>& clusterVector, const FaserSCT_ID& idHelper) const{ + const unsigned int firstStripNumber(idHelper.strip(firstStripId)); + const unsigned int endStripNumber(firstStripNumber + nStrips); // one-past-the-end + const Identifier waferId(idHelper.wafer_id(firstStripId)); + clusterVector.reserve(clusterVector.size() + nStrips); + + for (unsigned int stripNumber(firstStripNumber); stripNumber not_eq endStripNumber; ++stripNumber) { + const Identifier stripId(idHelper.strip_id(waferId, stripNumber)); + clusterVector.push_back(stripId); + } + } + + /** + * Beware of corner cases: what if all strips are bad? the vector is empty? + * What if the last strip is bad and contiguous with the next group which is coming? + * What if its good and contiguous, but there are also some bad? + **/ + void FaserSCT_ClusteringTool::addStripsToClusterWithChecks(const Identifier& firstStripId, unsigned int nStrips, std::vector<Identifier>& clusterVector, + std::vector<std::vector<Identifier> >& idGroups, const FaserSCT_ID& idHelper) const{ + + const unsigned int firstStripNumber(idHelper.strip(firstStripId)); + const unsigned int endStripNumber(firstStripNumber + nStrips); // one-past-the-end + const Identifier waferId(idHelper.wafer_id(firstStripId)); + clusterVector.reserve(clusterVector.size() + nStrips); + + static const Identifier badId; + unsigned int nBadStrips(0); + for (unsigned int stripNumber(firstStripNumber); stripNumber not_eq endStripNumber; ++stripNumber) { + Identifier stripId(idHelper.strip_id(waferId, stripNumber)); + if (isBad(stripId)) { + ++nBadStrips; + stripId = badId; + } + clusterVector.push_back(stripId); + } + + // Maybe all the strips are bad, clear the cluster vector + if (clusterVector.size() == nBadStrips) { + clusterVector.clear(); + // No need to recluster if vector is empty (same true if empty for other reasons) + return; + } + + // Now we have one vector of stripIds, some of which may be 'bad' + if (nBadStrips != 0) { + + clusterVector=recluster(clusterVector, idGroups); + // After this, the cluster vector is either empty or has the last good cluster + } + } + + void FaserSCT_ClusteringTool::addStripsToClusterInclRows(const Identifier& firstStripId, unsigned int nStrips, std::vector<Identifier>& clusterVector, + std::vector<std::vector<Identifier> >& idGroups, const FaserSCT_ID& idHelper) const { + + const unsigned int firstStripNumber(idHelper.strip(firstStripId)); + const unsigned int firstRowNumber(idHelper.row(firstStripId)); + const unsigned int endStripNumber(firstStripNumber + nStrips); // one-past-the-end + const Identifier waferId(idHelper.wafer_id(firstStripId)); + clusterVector.reserve(clusterVector.size() + nStrips); + static const Identifier badId; + unsigned int nBadStrips(0); + for (unsigned int stripNumber(firstStripNumber); stripNumber not_eq endStripNumber; ++stripNumber) { + Identifier stripId(idHelper.strip_id(waferId, firstRowNumber, stripNumber)); + if (isBad(stripId)) { + ++nBadStrips; + stripId = badId; + } + clusterVector.push_back(stripId); + } + + // Maybe all the strips are bad, clear the cluster vector + if (clusterVector.size() == nBadStrips) { + clusterVector.clear(); + // No need to recluster if vector is empty (same true if empty for other reasons) + return; + } + + // Now we have one vector of stripIds, some of which may be 'bad' + if (nBadStrips != 0) { + clusterVector=recluster(clusterVector, idGroups); + // After this, the cluster vector is either empty or has the last good cluster + } + } + + + /** + * recluster starts with a vector of Ids, some of which may be invalid due to them being bad strips, + * and a vector of these vectors. We recursively split the original clustervector, adding to idGroups as we go. + * It should eventually either return an empty cluster or a cluster of all good strips, to be inserted by the caller. + **/ + FaserSCT_ClusteringTool::IdVec_t FaserSCT_ClusteringTool::recluster(FaserSCT_ClusteringTool::IdVec_t& clusterVector, + std::vector<FaserSCT_ClusteringTool::IdVec_t>& idGroups) const { + + // Default Identifier constructor gives a sentinel value + static const Identifier invalidId; + const unsigned int numberOfBadStrips(std::count(clusterVector.begin(), clusterVector.end(), invalidId)); + + // All the strips are good, return the original vector to be put in idGroups by the caller + if (numberOfBadStrips==0 or clusterVector.empty()) return clusterVector; + // All the strips are bad, clear the vector and return it + if (clusterVector.size() == numberOfBadStrips) { + clusterVector.clear(); + return clusterVector; + } + + // Pointer to first bad strip + FaserSCT_ClusteringTool::IdVec_t::iterator pBadId(std::find(clusterVector.begin(), clusterVector.end(), invalidId)); + // Make a new cluster, which could be empty, if the first strip is bad + FaserSCT_ClusteringTool::IdVec_t subCluster(clusterVector.begin(), pBadId); + // Remove elements including the badId + if (pBadId != clusterVector.end()) clusterVector.erase(clusterVector.begin(), ++pBadId); + if (not subCluster.empty()) idGroups.push_back(subCluster); + return recluster(clusterVector, idGroups); + } + + + Tracker::FaserSCT_ClusterCollection * + FaserSCT_ClusteringTool::clusterize(const TrackerRawDataCollection<FaserSCT_RDORawData>& collection, + const FaserSCT_ID& idHelper) const + { + ATH_MSG_VERBOSE ("FaserSCT_ClusteringTool::clusterize()"); + + if (m_doNewClustering) return clusterizeNew(collection, idHelper); + + Tracker::FaserSCT_ClusterCollection* nullResult(nullptr); + if (collection.empty()) { + ATH_MSG_DEBUG("Empty RDO collection"); + return nullResult; + } + + // Make a copy of the collection for sorting (no need to sort if theres only one RDO) + std::vector<const FaserSCT_RDORawData*> collectionCopy(collection.begin(), collection.end()); + if (collection.size() not_eq 1) std::sort(collectionCopy.begin(), collectionCopy.end(), strip_less_than()); + + // Vector of identifiers in a cluster (most likely is that there is one strip in the cluster) + IdVec_t currentVector; + // Vector of clusters to make the cluster collection (most likely equal to collection size) + std::vector<IdVec_t> idGroups; + idGroups.reserve(collection.size()); + int n01X(0); + int n11X(0); + + std::vector<uint16_t> tbinGroups; + tbinGroups.reserve(collection.size()); + + unsigned int previousStrip(0); // Should be ok? + uint16_t hitsInThirdTimeBin(0); + int stripCount(0); + for (const FaserSCT_RDORawData* pRawData: collectionCopy) { + const Identifier firstStripId(pRawData->identify()); + const unsigned int nStrips(pRawData->getGroupSize()); + const int thisStrip(idHelper.strip(firstStripId)); +// const int BEC(idHelper.barrel_ec(firstStripId)); +// const int layer(idHelper.layer_disk(firstStripId)); + + // Flushes the vector every time a non-adjacent strip is found + if (not adjacent(thisStrip, previousStrip) and not(currentVector.empty())) { + // Add this group to existing groups (and flush) + idGroups.push_back(currentVector); + currentVector.clear(); + n01X=0; + n11X=0; + tbinGroups.push_back(hitsInThirdTimeBin); + hitsInThirdTimeBin =0; + stripCount = 0; + } + + // Only use clusters with certain time bit patterns if m_timeBinStr set + bool passTiming(true); + bool pass01X(true); + bool passX1X(true); + const FaserSCT3_RawData* pRawData3(dynamic_cast<const FaserSCT3_RawData*>(pRawData)); + if (!pRawData3) { + ATH_MSG_ERROR("Casting into FaserSCT3_RawData failed. This is probably caused by use of an old RDO file."); + return nullptr; + } + const int timeBin(pRawData3->getTimeBin()); + std::bitset<3> timePattern(static_cast<unsigned long>(timeBin)); + if (not m_timeBinStr.empty()) passTiming = testTimeBins(timeBin); + + passX1X = testTimeBinsX1X(pRawData3->getTimeBin()); + if (passX1X) pass01X = testTimeBins01X(pRawData3->getTimeBin()); + if (pass01X) n01X++; + if (passX1X and (not pass01X)) n11X++; + + // Now we are either (a) pushing more contiguous strips onto an existing vector + // or (b) pushing a new set of ids onto an empty vector + if (passTiming) { + if (m_useRowInformation) { + addStripsToClusterInclRows(firstStripId, nStrips, currentVector, idGroups, idHelper); // Note this takes the current vector only + } else if (not m_checkBadChannels) { + addStripsToCluster(firstStripId, nStrips, currentVector, idHelper); // Note this takes the current vector only + } else { + addStripsToClusterWithChecks(firstStripId, nStrips, currentVector, idGroups, idHelper); // This one includes the groups of vectors as well + } + for (unsigned int iStrip=0; iStrip<nStrips; iStrip++) { + if (stripCount < 16) hitsInThirdTimeBin |= (timePattern.test(0) << stripCount); + stripCount++; + } + } + if (not currentVector.empty()) { + // Gives the last strip number in the cluster + previousStrip = idHelper.strip(currentVector.back()); + } + } + + // Still need to add this last vector + if (not currentVector.empty()) { + idGroups.push_back(currentVector); + tbinGroups.push_back(hitsInThirdTimeBin); + hitsInThirdTimeBin=0; + } + + // Find detector element for these digits + const Identifier elementID(collection.identify()); + const Identifier waferId{idHelper.wafer_id(elementID)}; + const IdentifierHash waferHash{idHelper.wafer_hash(waferId)}; + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEleHandle(m_SCTDetEleCollKey); + const TrackerDD::SiDetectorElementCollection* sctDetEle(*sctDetEleHandle); + if (not sctDetEleHandle.isValid() or sctDetEle==nullptr) { + ATH_MSG_FATAL(m_SCTDetEleCollKey.fullKey() << " is not available."); + return nullResult; + } + const TrackerDD::SiDetectorElement* element(sctDetEle->getDetectorElement(waferHash)); + if (!element) { + ATH_MSG_WARNING("Element not in the element map, ID = "<< elementID); + return nullResult; + } + + const TrackerDD::SCT_ModuleSideDesign* design; +// if (idHelper.is_barrel(elementID)) { + design = (static_cast<const TrackerDD::SCT_BarrelModuleSideDesign*>(&element->design())); +// } else { +// design = (static_cast<const TrackerDD::SCT_ForwardModuleSideDesign*>(&element->design())); +// } + + IdentifierHash idHash(collection.identifyHash()); + Tracker::FaserSCT_ClusterCollection* clusterCollection = new Tracker::FaserSCT_ClusterCollection(idHash); + clusterCollection->setIdentifier(elementID); + clusterCollection->reserve(idGroups.size()); + + int clusterNumber(0); + // All strips are assumed to be the same width. + std::vector<uint16_t>::iterator tbinIter(tbinGroups.begin()); + + /// If clusters have been split due to bad strips, would require a whole lot + /// of new logic to recalculate hitsInThirdTimeBin word - instead, just find + /// when this is the case here, and set hitsInThirdTimeBin to zero later on + const bool badStripInClusterOnThisModuleSide = (idGroups.size() != tbinGroups.size()); + + for (const IdVec_t& stripGroup: idGroups) { + const int nStrips(stripGroup.size()); + if (nStrips == 0) continue; + // + const TrackerDD::SiLocalPosition dummyPos(1, 0); + DimensionAndPosition clusterDim(dummyPos, 1.0);//just initialize with arbitrary values, will be set properly in the next two lines... + if (m_useRowInformation) clusterDim = clusterDimensionsInclRow(idHelper.strip(stripGroup.front()), idHelper.strip(stripGroup.back()), idHelper.row(stripGroup.front()), element, design); + else clusterDim = clusterDimensions(idHelper.strip(stripGroup.front()), idHelper.strip(stripGroup.back()), element, idHelper); + const Amg::Vector2D localPos(clusterDim.centre.xPhi(), clusterDim.centre.xEta()); + // Since clusterId is arbitary (it only needs to be unique) just use ID of first strip + //const Identifier clusterId = element->identifierOfPosition(clusterDim.centre); + const Identifier clusterId(stripGroup.front()); + if (!clusterId.is_valid()) ATH_MSG_VERBOSE(clusterId << " is invalid."); + // + // Find length of strip at centre + const std::pair<TrackerDD::SiLocalPosition, TrackerDD::SiLocalPosition> ends(design->endsOfStrip(clusterDim.centre)); + const double stripLength(fabs(ends.first.xEta()-ends.second.xEta())); + // + // Now make a SiCluster + clusterNumber++; + const Tracker::FaserSiWidth siWidth(Amg::Vector2D(nStrips, 1), Amg::Vector2D(clusterDim.width, stripLength)); + + Tracker::FaserSCT_Cluster* cluster = (m_clusterMaker) ? (m_clusterMaker->sctCluster(clusterId, localPos, stripGroup, siWidth, element, m_errorStrategy)) + : (new Tracker::FaserSCT_Cluster(clusterId, localPos, stripGroup, siWidth, element, 0)); + cluster->setHashAndIndex(clusterCollection->identifyHash(), clusterCollection->size()); + if (tbinIter != tbinGroups.end()) { + cluster->setHitsInThirdTimeBin(*tbinIter); + ++tbinIter; + } + if (badStripInClusterOnThisModuleSide) cluster->setHitsInThirdTimeBin(0); /// clusters had been split - recalculating HitsInThirdTimeBin too difficult to be worthwhile for this rare corner case.. + + clusterCollection->push_back(cluster); + } + + return clusterCollection; + } + + Tracker::FaserSCT_ClusterCollection* FaserSCT_ClusteringTool::clusterizeNew(const TrackerRawDataCollection<FaserSCT_RDORawData>& collection, + const FaserSCT_ID& idHelper) const + { + if (collection.empty()) return nullptr; + + std::vector<const FaserSCT_RDORawData*> collectionCopy(collection.begin(), collection.end()); + + if (collectionCopy.size() > 1) std::sort(collectionCopy.begin(), collectionCopy.end(), strip_less_than()); + + IdVec_t currentVector; + currentVector.reserve(100); + + std::vector<IdVec_t> idGroups; + idGroups.reserve(collectionCopy.size()); + + std::vector<uint16_t> tbinGroups; + tbinGroups.reserve(collectionCopy.size()); + + unsigned int previousStrip = 0; // Should be ok? + uint16_t hitsInThirdTimeBin = 0; + int stripCount = 0; + int previousRow = -1; + int thisRow = -1; + + const Identifier badId; + + for (const FaserSCT_RDORawData* pRawData: collectionCopy) { + Identifier firstStripId = pRawData->identify(); + Identifier waferId = idHelper.wafer_id(firstStripId); + unsigned int nStrips = pRawData->getGroupSize(); + int thisStrip = idHelper.strip(firstStripId); + + if (m_useRowInformation) thisRow = idHelper.row(firstStripId); + + // Flushes the vector every time a non-adjacent strip is found + // + if (not currentVector.empty() and + ((m_useRowInformation and !adjacent(thisStrip, thisRow, previousStrip, previousRow)) or + (not m_useRowInformation and !adjacent(thisStrip, previousStrip)))) { + + // Add this group to existing groups (and flush) + // + idGroups.push_back(currentVector); + currentVector.clear(); + + tbinGroups.push_back(hitsInThirdTimeBin); + hitsInThirdTimeBin = 0; + stripCount = 0; + } + + // Only use clusters with certain time bit patterns if m_timeBinStr set + + const FaserSCT3_RawData* pRawData3 = dynamic_cast<const FaserSCT3_RawData*>(pRawData); + //sroe: coverity 31562 + if (!pRawData3) { + ATH_MSG_ERROR("Casting into FaserSCT3_RawData failed. This is probably caused by use of an old RDO file."); + return nullptr; + } + + int timeBin = pRawData3->getTimeBin(); + std::bitset<3> timePattern(static_cast<unsigned long>(timeBin)); + + bool passTiming = true; + + if (!m_timeBinStr.empty()) passTiming = testTimeBinsN(timePattern); + + // Now we are either (a) pushing more contiguous strips onto an existing vector + // or (b) pushing a new set of ids onto an empty vector + // + if (passTiming) { + unsigned int nBadStrips(0); + for (unsigned int sn=thisStrip; sn!=thisStrip+nStrips; ++sn) { + Identifier stripId = m_useRowInformation ? idHelper.strip_id(waferId,thisRow,sn) : idHelper.strip_id(waferId,sn); +// if (m_conditionsTool->isGood(stripId, InDetConditions::SCT_STRIP)) { + currentVector.push_back(stripId); +// } else { +// currentVector.push_back(badId); +// ++nBadStrips; +// } + if (stripCount < 16) { + hitsInThirdTimeBin = hitsInThirdTimeBin | (timePattern.test(0) << stripCount); + } + ++stripCount; + } + + if (currentVector.size() == nBadStrips) { + currentVector.clear(); + } else if (nBadStrips) { + currentVector=recluster(currentVector, idGroups); + } + } + + if (not currentVector.empty()) { + // Gives the last strip number in the cluster + // + previousStrip = idHelper.strip(currentVector.back()); + if (m_useRowInformation) previousRow = idHelper.row(currentVector.back()); + } + } + + // Still need to add this last vector + // + if (not currentVector.empty()) { + idGroups.push_back(currentVector); + tbinGroups.push_back(hitsInThirdTimeBin); + hitsInThirdTimeBin=0; + } + + // Find detector element for these digits + // + IdentifierHash idHash = collection.identifyHash(); + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEleHandle(m_SCTDetEleCollKey); + const TrackerDD::SiDetectorElementCollection* sctDetEle(*sctDetEleHandle); + if (not sctDetEleHandle.isValid() or sctDetEle==nullptr) { + ATH_MSG_FATAL(m_SCTDetEleCollKey.fullKey() << " is not available."); + return nullptr; + } + const TrackerDD::SiDetectorElement* element(sctDetEle->getDetectorElement(idHash)); + if (!element) { + ATH_MSG_WARNING("Element not in the element map, hash = " << idHash); + return nullptr; + } + + const TrackerDD::SCT_ModuleSideDesign* design = (dynamic_cast<const TrackerDD::SCT_ModuleSideDesign*>(&element->design())); + if(design==nullptr) return nullptr; + + Tracker::FaserSCT_ClusterCollection* clusterCollection = new Tracker::FaserSCT_ClusterCollection(idHash); + Identifier elementID = collection.identify(); + clusterCollection->setIdentifier(elementID); + clusterCollection->reserve(idGroups.size()); + + int clusterNumber = 0; + + // All strips are assumed to be the same width. + // + std::vector<IdVec_t>::iterator pGroup = idGroups.begin(); + std::vector<IdVec_t>::iterator lastGroup = idGroups.end(); + std::vector<uint16_t>::iterator tbinIter = tbinGroups.begin(); + + // If clusters have been split due to bad strips, would require a whole lot + // of new logic to recalculate hitsInThirdTimeBin word - instead, just find + // when this is the case here, and set hitsInThirdTimeBin to zero later on + // + double iphipitch = 1./element->phiPitch(); + double shift = m_lorentzAngleTool->getLorentzShift(element->identifyHash()); + double stripPitch = design->stripPitch(); + bool badStripInClusterOnThisModuleSide = (idGroups.size() != tbinGroups.size()); + bool rotate = element->design().shape() == TrackerDD::Trapezoid || element->design().shape() == TrackerDD::Annulus; + double stripL = 0.; + double COV11 = 0.; + + if (not rotate) { + stripL = design->etaPitch(); + COV11 = stripL*stripL*(1./12.); + } + + for (; pGroup!=lastGroup; ++pGroup) { + int nStrips = pGroup->size(); + double dnStrips = static_cast<double>(nStrips); + Identifier clusterId = pGroup->front(); + + int firstStrip = idHelper.strip(clusterId); + double width = stripPitch; + TrackerDD::SiLocalPosition centre; + if (m_useRowInformation) { + int row = idHelper.row(clusterId); + centre = element->rawLocalPositionOfCell(design->strip1Dim(firstStrip, row)); + if (nStrips > 1) { + TrackerDD::SiLocalPosition lastStripPos(element->rawLocalPositionOfCell(design->strip1Dim(firstStrip+nStrips-1, row))); + centre = (centre+lastStripPos)*.5; + width *=dnStrips; + } + } else { + DimensionAndPosition clusterDim = clusterDimensions(idHelper.strip(pGroup->front()), idHelper.strip(pGroup->back()), element, idHelper); + centre = clusterDim.centre; + width = clusterDim.width; + } + + Amg::Vector2D localPos{centre.xPhi(), centre.xEta()}; + Amg::Vector2D locpos{centre.xPhi()+shift, centre.xEta()}; + + // Now make a SiCluster + // + double x = 0.; + // single strip - resolution close to pitch/sqrt(12) + // two-strip hits: better resolution, approx. 40% lower + // lines taken from ClusterMakerTool::sctCluster + if (nStrips == 1) { + x = 1.05*width; + } else { + if (nStrips == 2) { + x = 0.27*width; + } else { + x = width; + } + } + + double V[4] = {x*x*(1./12.), 0., 0., COV11}; + + if (rotate) { + // Find length of strip at centre + // + std::pair<TrackerDD::SiLocalPosition, TrackerDD::SiLocalPosition> ends(design->endsOfStrip(centre)); + stripL = fabs(ends.first.xEta()-ends.second.xEta()); + + double w = element->phiPitch(localPos)*iphipitch; + double sn = element->sinStereoLocal(localPos); + double sn2 = sn*sn; + double cs2 = 1.-sn2; + double v0 = V[0]*w*w; + double v1 = stripL*stripL*(1./12.); + V[0] = cs2*v0+sn2*v1; + V[1] = V[2] = sn*sqrt(cs2)*(v0-v1); + V[3] = sn2*v0+cs2*v1; + } + + Amg::MatrixX* errorMatrix(new Amg::MatrixX(2,2)); + *errorMatrix<<V[0],V[1],V[2],V[3]; + + Tracker::FaserSiWidth siWidth{Amg::Vector2D(dnStrips,1.), Amg::Vector2D(width,stripL)}; + + Tracker::FaserSCT_Cluster* cluster = new Tracker::FaserSCT_Cluster{clusterId, locpos, *pGroup , siWidth, element, errorMatrix}; + + cluster->setHashAndIndex(idHash, clusterNumber); + + if (tbinIter != tbinGroups.end()) { + cluster->setHitsInThirdTimeBin(*tbinIter); + ++tbinIter; + } + + // clusters had been split - recalculating HitsInThirdTimeBin too difficult to be worthwhile for this rare corner case.. + // + if (badStripInClusterOnThisModuleSide) cluster->setHitsInThirdTimeBin(0); + + clusterCollection->push_back(cluster); + clusterNumber++; + } + return clusterCollection; + } + + FaserSCT_ClusteringTool::DimensionAndPosition + FaserSCT_ClusteringTool::clusterDimensions(int firstStrip, int lastStrip, + const TrackerDD::SiDetectorElement* pElement, + const FaserSCT_ID& /*idHelper*/) const { //since a range check on strip numbers was removed, idHelper is no longer needed here + const int nStrips(lastStrip - firstStrip + 1); + // Consider strips before and after (in case nStrips=1), both are guaranteed + // to return sensible results, even for end strips + const TrackerDD::SiCellId cell1(firstStrip - 1); + const TrackerDD::SiCellId cell2(lastStrip + 1); + const TrackerDD::SiLocalPosition firstStripPos(pElement->rawLocalPositionOfCell(cell1)); + const TrackerDD::SiLocalPosition lastStripPos(pElement->rawLocalPositionOfCell(cell2)); + const double width((static_cast<double>(nStrips)/static_cast<double>(nStrips+1))*( lastStripPos.xPhi()-firstStripPos.xPhi())); + const TrackerDD::SiLocalPosition centre((firstStripPos+lastStripPos)/2.0); + return FaserSCT_ClusteringTool::DimensionAndPosition(centre, width); + } + + FaserSCT_ClusteringTool::DimensionAndPosition + FaserSCT_ClusteringTool::clusterDimensionsInclRow(int firstStrip, int lastStrip, int row, + const TrackerDD::SiDetectorElement* pElement, const TrackerDD::SCT_ModuleSideDesign* design) const{ + const int nStrips(lastStrip - firstStrip + 1); + const int firstStrip1D = design->strip1Dim(firstStrip, row); + const int lastStrip1D = design->strip1Dim(lastStrip, row); + const double stripPitch = design->stripPitch(); + const TrackerDD::SiCellId cell1(firstStrip1D); + const TrackerDD::SiCellId cell2(lastStrip1D); + const TrackerDD::SiLocalPosition firstStripPos(pElement->rawLocalPositionOfCell(cell1)); + const TrackerDD::SiLocalPosition lastStripPos(pElement->rawLocalPositionOfCell(cell2)); + const double width(nStrips*stripPitch); + const TrackerDD::SiLocalPosition centre((firstStripPos+lastStripPos)/2.0); + return FaserSCT_ClusteringTool::DimensionAndPosition(centre, width); + } +} \ No newline at end of file diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.h b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.h new file mode 100644 index 0000000000000000000000000000000000000000..8267f778ad64047fc7ec174081be8de51b97748e --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ClusteringTool.h @@ -0,0 +1,150 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/** @file FaserSCT_ClusteringTool.h + * Header file for FaserSCT_ClusteringTool + * + */ +#ifndef FaserSiClusterizationTool_FaserSCT_ClusteringTool_H +#define FaserSiClusterizationTool_FaserSCT_ClusteringTool_H + +//Athena +#include "AthenaBaseComps/AthAlgTool.h" +#include "Identifier/Identifier.h" +//#include "SCT_ConditionsTools/ISCT_DCSConditionsTool.h" +#include "InDetCondTools/ISiLorentzAngleTool.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "FaserSiClusterizationTool/IFaserSCT_ClusteringTool.h" +#include "TrackerClusterMakerTool.h" +#include "StoreGate/ReadCondHandleKey.h" +//Gaudi +#include "GaudiKernel/ToolHandle.h" +//STL +#include <bitset> +#include <string> +#include <vector> + +class FaserSCT_ID; +class FaserSCT_ChannelStatusAlg; +class StatusCode; + +namespace TrackerDD{ + class SCT_ModuleSideDesign; +} + +namespace Tracker +{ +/** AlgTool for FaserSCT_Clusterization. + * Input is from RDOs, assumed to be sorted. They are then scanned + * in order and neighbouring RDOs are grouped together. + */ + class FaserSCT_ClusteringTool: public extends<AthAlgTool, IFaserSCT_ClusteringTool> { + public: + ///Normal constructor for an AlgTool; 'properties' are also declared here + FaserSCT_ClusteringTool(const std::string& type, const std::string& name, const IInterface* parent); + ///Retrieve the necessary services in initialize + StatusCode initialize(); + virtual ~FaserSCT_ClusteringTool() = default; + + /// Clusterize the SCT RDOs... deprecated form passes explicit channel status object + virtual Tracker::FaserSCT_ClusterCollection* + clusterize(const TrackerRawDataCollection<FaserSCT_RDORawData>& RDOs, + const FaserSCT_ID& idHelper, + const FaserSCT_ChannelStatusAlg* status, + const bool CTBBadChannels) const; + + /// Clusterize the SCT RDOs... + virtual Tracker::FaserSCT_ClusterCollection* + clusterize(const TrackerRawDataCollection<FaserSCT_RDORawData>& RDOs, + const FaserSCT_ID& idHelper) const; + + /// Clusterize the SCT RDOs... new method originally implemented for ITk + virtual Tracker::FaserSCT_ClusterCollection* + clusterizeNew(const TrackerRawDataCollection<FaserSCT_RDORawData>& RDOs, + const FaserSCT_ID& idHelper) const; + + private: + IntegerProperty m_errorStrategy{this, "errorStrategy", 1}; + BooleanProperty m_checkBadChannels{this, "checkBadChannels", false}; + // ToolHandle<ISCT_DCSConditionsTool> m_conditionsTool{this, "FaserSCT_DCSConditionsTool", "FaserSCT_ConditionsTools", "Tool to retrieve SCT Conditions summary"}; + const FaserSCT_ID* m_pHelper; //!< ID helper for FaserSCT + + ToolHandle< TrackerClusterMakerTool > m_clusterMaker{this, "globalPosAlg", "TrackerClusterMakerTool"}; + ToolHandle<ISiLorentzAngleTool> m_lorentzAngleTool + {this, "FaserSiLorentzAngleTool", "FaserSiLorentzAngleTool", "Tool to retreive Lorentz angle of SCT"}; + typedef std::vector<Identifier> IdVec_t; + StringProperty m_timeBinStr{this, "timeBins", "01X"}; + int m_timeBinBits[3]{-1, -1, -1}; + // BooleanProperty m_innermostBarrelX1X{this, "innermostBarrelX1X", false}; + // BooleanProperty m_innertwoBarrelX1X{this, "innertwoBarrelX1X", false}; + // BooleanProperty m_majority01X{this, "majority01X", false}; + BooleanProperty m_useRowInformation{this, "useRowInformation", false}; + BooleanProperty m_doNewClustering{this, "doNewClustering", false}; + + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; + + + ///Add strips to a cluster vector without checking for bad strips + void addStripsToCluster(const Identifier& firstStripId, unsigned int nStrips, IdVec_t& clusterVector, const FaserSCT_ID& idHelper) const; + + ///Add strips to a cluster vector checking for bad strips + void addStripsToClusterWithChecks(const Identifier& firstStripId, unsigned int nStrips, IdVec_t& clusterVector, + std::vector<IdVec_t>& idGroups, const FaserSCT_ID& idHelper) const; + + void addStripsToClusterInclRows(const Identifier& firstStripId, unsigned int nStrips, IdVec_t& clusterVector, std::vector<IdVec_t>& idGroups, const FaserSCT_ID& idHelper) const; + + /** Recluster the current vector, splitting on bad strips, and insert those new groups to the idGroups vector. + * The cluster vector referenced will be changed by this, as well as the idGroups + **/ + IdVec_t recluster(IdVec_t& clusterVector, std::vector<IdVec_t>& idGroups) const; + + /// In-class struct to store the centre and width of a cluster + struct DimensionAndPosition { + TrackerDD::SiLocalPosition centre; + double width; + DimensionAndPosition(const TrackerDD::SiLocalPosition& c, double w):centre(c), width(w){} + }; + + ///Calculate the cluster position and width given the first and last strip numbers for this element + DimensionAndPosition clusterDimensions(int firstStrip, int lastStrip, const TrackerDD::SiDetectorElement* element, + const FaserSCT_ID& idHelper) const; + + DimensionAndPosition clusterDimensionsInclRow(int firstStrip, int lastStrip, int row, const TrackerDD::SiDetectorElement* element, const TrackerDD::SCT_ModuleSideDesign* design) const; + + /// In-class facade on the 'isGood' method for a strip identifier + bool isBad(const Identifier& stripId) const; + + // Convert time bin string to array of 3 bits + StatusCode decodeTimeBins(); + // Convert a single time bin char to an int, bit is modified + StatusCode decodeTimeBin(char timeBin, int& bit) const; + // Test the clusters time bin to see if matches pattern + bool testTimeBins(int timeBin) const; + bool testTimeBins01X(int timeBin) const; + bool testTimeBinsX1X(int timeBin) const; + bool testTimeBinsN(const std::bitset<3>& timePattern) const; + };//end of class + + /////////////////////////////////////////////////////////////////// + // Inline methods + /////////////////////////////////////////////////////////////////// + + inline bool FaserSCT_ClusteringTool::isBad(const Identifier& ) const { + return false; + // return (not m_conditionsTool->isGood(stripId, InDetConditions::SCT_STRIP)); + } + + inline bool FaserSCT_ClusteringTool::testTimeBinsN(const std::bitset<3>& timePattern) const { + // Convert the given timebin to a bit set and test each bit + // if bit is -1 (i.e. X) it always passes, other wise require exact match of 0/1 + // N.B bitset has opposite order to the bit pattern we define + + if (m_timeBinBits[0] != -1 and timePattern.test(2) != static_cast<bool>(m_timeBinBits[0])) return false; + if (m_timeBinBits[1] != -1 and timePattern.test(1) != static_cast<bool>(m_timeBinBits[1])) return false; + if (m_timeBinBits[2] != -1 and timePattern.test(0) != static_cast<bool>(m_timeBinBits[2])) return false; + return true; + } + +} +#endif // FaserSiClusterizationTool_FaserSCT_ClusteringTool_H diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ReClustering.cxx b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ReClustering.cxx new file mode 100644 index 0000000000000000000000000000000000000000..288e422f67e35828cd5953b7607da8b8a90ee2c7 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ReClustering.cxx @@ -0,0 +1,110 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// Paul Bell 23/7/04 +/* This utility class performs a reclustering of SCT hits necessary + to take account of dead or noisy channels. + For now the philosophy is that + BAD CHANNELS DO NOT BECOME CLUSTERS + Later we may want to distinguish between dead and noisy +*/ +#include "FaserSCT_ReClustering.h" +// #include "FaserSCT_ClusteringTool/FaserSCT_ClusteringTool.h" +#include "Identifier/Identifier.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "GaudiKernel/MsgStream.h" +#include <iostream> +#include <vector> + +// Constructor +FaserSCT_ReClustering::FaserSCT_ReClustering() +{} +//-------------------------------------------------------------------------- +std::vector<std::vector<Identifier> > FaserSCT_ReClustering::recluster(std::vector<std::vector<Identifier> > &idGroups, const FaserSCT_ID& sctID) +{ + + //std::cout << "Running the reclustering method" << std::endl; + + /* + From SCT_ClusteringTool we have a matrix of identifiers - hits on + neighboring strips are grouped togther (vector of identifiers) and + these are grouped into one big vector (idGroups) for that event. + Most of these clusters are just single channels and are now + excluded if dead/noisy. In the rarer case of several neighbouring + channels being hit, the cluster gets split up into smaller clusters. + idGroups is then remade into newidGroups and the original destroyed + */ + std::vector<ID_Vector> newidGroups; + + //Make a vector of iterators. These will point to any discontinuties + //in the vectors of identifiers + std::vector<Discont> discontV; + + //The vectors of identifiers are copied to new vectors of identifiers + //and the old ones destroyed + ID_Vector newvector; + + //Need one loop over the group members of idGroups + std::vector<ID_Vector>::iterator firstGroup = idGroups.begin(); + std::vector<ID_Vector>::iterator lastGroup = idGroups.end(); + for (; firstGroup!= lastGroup; ++firstGroup){ + + //Need a second loop over the identifiers within each idGroups member + std::vector<Identifier>::iterator fst = (*firstGroup).begin(); + std::vector<Identifier>::iterator lst = (*firstGroup).end(); + std::vector<Identifier>::iterator prt; + //std::cout << "Strip summary " << sctID.strip(*fst) << std::endl; + int prev = sctID.strip(*fst); + + //ONE/3 Store an iterator pointing to 1st strip + discontV.clear(); + discontV.push_back((*firstGroup).begin()); + + //now look at rest of strips + prt=fst; + fst++; + for (; fst!=lst; ++fst){ + //std::cout << "Strip summary cont." << sctID.strip(*fst) << std::endl; + int current = sctID.strip(*fst); + + //**CHECK STRIPS ARE CONSECUTIVE** + + //TWO/3 If not store an iterator pointing either side of the discontinuity + if (current != prev +1) { + discontV.push_back(prt); + discontV.push_back(fst); + //std::cout << "start and stop of bad strips " << (sctID.strip(*prt)) << (sctID.strip(*fst)) << std::endl; + prt=fst; + } + prev=current; + } + //THREE/3 Store an iterator pointing to last strip + discontV.push_back((*firstGroup).end()-1); + + /* + Now we have a vector of pointers discontV to the first and last + member of each idGroups member and to any discontinuties within + */ + + std::vector<Discont>::iterator fst_d = discontV.begin(); + //NB: *fst_d refers to the element pointed to by fst_d, and that + //element is an iterator! + + //Copy the old vector of identifiers into however many new ones + //are needed. If there were no discontinutities, discontV is + //of size 2 so we are just making a copy + for(unsigned int sg=1;sg<discontV.size();sg+=2){ + newvector.clear(); + newvector.assign(*fst_d,(*(fst_d+1))+1); + newidGroups.push_back(newvector); + fst_d+=2; + } + } + //delete the old idGroups and return the new one + idGroups.clear(); + newvector.clear(); + return newidGroups; +} + + diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ReClustering.h b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ReClustering.h new file mode 100644 index 0000000000000000000000000000000000000000..25d6cb3a9c76c84953e6fe5b7d24af293b47b839 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/FaserSCT_ReClustering.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + + +/** + * @file FaserSCT_ReClustering.h + * header file for FaserSCT_ReClustering class + * @author Paul J. Bell + * @date Sept 2004 + */ + + +#ifndef FaserSiClusterizationTool_FaserSCT_ReClustering_H +#define FaserSiClusterizationTool_FaserSCT_ReClustering_H + +class FaserSCT_ID; +class Identifier; +#include <vector> + +///This performs reclustering after identifying dead or noisy channels +class FaserSCT_ReClustering +{ + public: + + FaserSCT_ReClustering(); //constructor + virtual ~FaserSCT_ReClustering() = default; + + /** called by SCT_ClusteringTool. If some bad channel has broken the + * cluster (provided as a list of RDOs) in non-consecutive fragments, just split it. + */ + std::vector<std::vector<Identifier> > recluster(std::vector<std::vector<Identifier>>&, const FaserSCT_ID&); + + private: + typedef std::vector<Identifier> ID_Vector; + typedef std::vector<Identifier>::iterator Discont; +}; + +#endif // FaserSiClusterizationTool_FaserSCT_ReClustering_H diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/TrackerClusterMakerTool.cxx b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/TrackerClusterMakerTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..78bcb43a710e8e7866a06dfea1136b819c162bb8 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/TrackerClusterMakerTool.cxx @@ -0,0 +1,144 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +//*************************************************************************** +// +// Implementation for ClusterMaker +// +//**************************************************************************** + +#include "CLHEP/Units/SystemOfUnits.h" +#include "CLHEP/Matrix/SymMatrix.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ServiceHandle.h" +#include "TrackerClusterMakerTool.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" +#include "TrackerReadoutGeometry/SiLocalPosition.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerPrepRawData/FaserSiWidth.h" + +#include "EventPrimitives/EventPrimitives.h" + +using CLHEP::micrometer; + +namespace { + inline double square(const double x){ + return x*x; + } + constexpr double ONE_TWELFTH = 1./12.; +} + +namespace Tracker +{ + +// Constructor with parameters: +TrackerClusterMakerTool::TrackerClusterMakerTool(const std::string& t, + const std::string& n, + const IInterface* p) : + AthAlgTool(t,n,p) +{ + declareInterface<TrackerClusterMakerTool>(this); +} + +//================ Initialisation ============================================= + +StatusCode TrackerClusterMakerTool::initialize(){ + // Code entered here will be executed once at program start. + + ATH_MSG_INFO ( name() << " initialize()" ); + + if (not m_sctLorentzAngleTool.empty()) { + ATH_CHECK(m_sctLorentzAngleTool.retrieve()); + } else { + m_sctLorentzAngleTool.disable(); + } + +// ATH_CHECK(m_clusterErrorKey.initialize(SG::AllowEmpty)); + + return StatusCode::SUCCESS; +} + + +// Computes global position and errors for SCT cluster. + // Called by SCT Clustering tools + // + // Input parameters + // - the cluster Identifier + // - the position in local reference frame + // - the list of identifiers of the Raw Data Objects belonging to the cluster + // - the width of the cluster + // - the module the cluster belongs to + // - the error strategy, currently + // 0: Cluster Width/sqrt(12.) + // 1: Set to a different values for one and two-strip clusters (def.) + +Tracker::FaserSCT_Cluster* TrackerClusterMakerTool::sctCluster( + const Identifier& clusterID, + const Amg::Vector2D& localPos, + const std::vector<Identifier>& rdoList, + const Tracker::FaserSiWidth& width, + const TrackerDD::SiDetectorElement* element, + int errorStrategy) const{ + + double shift = m_sctLorentzAngleTool->getLorentzShift(element->identifyHash()); +// const InDetDD::SiLocalPosition& localPosition = +// InDetDD::SiLocalPosition(localPos[Trk::locY), +// localPos[Trk::locX)+shift,0); + Amg::Vector2D locpos(localPos[Trk::locX]+shift, localPos[Trk::locY]); + + // error matrix + const Amg::Vector2D& colRow = width.colRow();// made ref to avoid + // unnecessary copy EJWM + + Amg::MatrixX* errorMatrix = new Amg::MatrixX(2,2); + errorMatrix->setIdentity(); + + // switches are more readable **OPT** + // actually they're slower as well (so I'm told) so perhaps + // this should be re-written at some point EJWM + + switch (errorStrategy){ + case 0: + errorMatrix->fillSymmetric(0,0,square(width.phiR())*ONE_TWELFTH); + errorMatrix->fillSymmetric(1,1,square(width.z())*ONE_TWELFTH); + break; + case 1: + // mat(1,1) = pow(width.phiR()/colRow.x(),2)/12; + // single strip - resolution close to pitch/sqrt(12) + // two-strip hits: better resolution, approx. 40% lower + if(colRow.x() == 1){ + errorMatrix->fillSymmetric(0,0,square(1.05*width.phiR())*ONE_TWELFTH); + } + else if(colRow.x() == 2){ + errorMatrix->fillSymmetric(0,0,square(0.27*width.phiR())*ONE_TWELFTH); + } + else{ + errorMatrix->fillSymmetric(0,0,square(width.phiR())*ONE_TWELFTH); + } + errorMatrix->fillSymmetric(1,1,square(width.z()/colRow.y())*ONE_TWELFTH); + break; + default: + // single strip - resolution close to pitch/sqrt(12) + // two-strip hits: better resolution, approx. 40% lower + if(colRow.x() == 1){ + errorMatrix->fillSymmetric(0,0,square(width.phiR())*ONE_TWELFTH); + } + else if(colRow.x() == 2){ + errorMatrix->fillSymmetric(0,0,square(0.27*width.phiR())*ONE_TWELFTH); + } + else{ + errorMatrix->fillSymmetric(0,0,square(width.phiR())*ONE_TWELFTH); + } + errorMatrix->fillSymmetric(1,1,square(width.z()/colRow.y())*ONE_TWELFTH); + break; + } + + // delete localPos; + // localPos=0; + Tracker::FaserSCT_Cluster* newCluster = new Tracker::FaserSCT_Cluster(clusterID, locpos, rdoList , width, element, errorMatrix); + return newCluster; + +} + +} \ No newline at end of file diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/TrackerClusterMakerTool.h b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/TrackerClusterMakerTool.h new file mode 100644 index 0000000000000000000000000000000000000000..c8ea25e5ff96ed4b130416d2d7918601da53a285 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/TrackerClusterMakerTool.h @@ -0,0 +1,106 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +//ClusterMaker.h +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Fill the global position fields of the PrepRawData +/////////////////////////////////////////////////////////////////// +// +///////////////////////////////////////////////////////////////////////// +// First version 04/08/2003 Tommaso Lari +// +/////////////////////////////////////////////////////////////////// + +#ifndef FASERSCT_CLUSTERINGTOOL_TRACKERCLUSTERMAKERTOOL_H +#define FASERSCT_CLUSTERINGTOOL_TRACKERCLUSTERMAKERTOOL_H + +#include "AthenaBaseComps/AthAlgTool.h" + +#include "GeoPrimitives/GeoPrimitives.h" +#include "InDetCondTools/ISiLorentzAngleTool.h" + +#include "StoreGate/ReadCondHandleKey.h" + +#include "GaudiKernel/ToolHandle.h" + +#include <atomic> +#include <vector> + +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +template <class T> class ServiceHandle; +class Identifier; +class StatusCode; + +namespace TrackerDD { + class SiDetectorElement; +} + + +static const InterfaceID IID_TrackerClusterMakerTool("TrackerClusterMakerTool", 1, 0); +namespace Tracker +{ + class FaserSCT_Cluster; + class FaserSiWidth; + + class TrackerClusterMakerTool : public AthAlgTool { + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// + public: + + TrackerClusterMakerTool(const std::string &type, + const std::string &name, + const IInterface *parent); + ~TrackerClusterMakerTool() = default; + + static const InterfaceID& interfaceID() { return IID_TrackerClusterMakerTool; }; + + StatusCode initialize(); + + // Computes global position and errors for SCT cluster. + // Called by SCT Clustering tools + // + // Input parameters + // - the cluster Identifier + // - the position in local reference frame + // - the list of identifiers of the Raw Data Objects belonging to the cluster + // - the width of the cluster + // - the module the cluster belongs to + // - the error strategy, currently + // 0: Cluster Width/sqrt(12.) + // 1: Set to a different values for one and two-strip clusters (def.) + + Tracker::FaserSCT_Cluster* sctCluster(const Identifier& clusterID, + const Amg::Vector2D& localPos, + const std::vector<Identifier>& rdoList, + const Tracker::FaserSiWidth& width, + const TrackerDD::SiDetectorElement* element, + int errorStrategy) const; + + private: + + + + // ToolHandle<FaserSiLorentzAngleTool> m_sctLorentzAngleTool + // {this, "FaserSCTLorentzAngleTool", "FaserSiLorentzAngleTool/FaserSiLorentzAngleTool", "Tool to retreive Lorentz angle of SCT"}; + ToolHandle<ISiLorentzAngleTool> m_sctLorentzAngleTool + {this, "FaserSiLorentzAngleTool", "FaserSiLorentzAngleTool", "Tool to retreive Lorentz angle of SCT"}; + + // These std::atomic_bool may be dropped. + // m_issueErrorA and m_issueErrorB are changed in pixelCluster but do not affect any computation. + // The default values of m_forceErrorStrategy1A and m_forceErrorStrategy1B are unchanged. + // If they are changed in event processing and affect some computation, they are not thread-safe. + mutable std::atomic_bool m_issueErrorA{true}; + mutable std::atomic_bool m_forceErrorStrategy1A{false}; + mutable std::atomic_bool m_issueErrorB{true}; + mutable std::atomic_bool m_forceErrorStrategy1B{false}; + }; + +} +#endif // TRACKER_TRACKERCLUSTERMAKERTOOL_H diff --git a/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/components/FaserSiClusterizationTool_entries.cxx b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/components/FaserSiClusterizationTool_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..abc89e180447e8980cf56ff606ffa7b1fca8447e --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiClusterizationTool/src/components/FaserSiClusterizationTool_entries.cxx @@ -0,0 +1,5 @@ +#include "../FaserSCT_ClusteringTool.h" +#include "../TrackerClusterMakerTool.h" + +DECLARE_COMPONENT( Tracker::FaserSCT_ClusteringTool ) +DECLARE_COMPONENT( Tracker::TrackerClusterMakerTool ) diff --git a/Tracker/TrackerRecTools/FaserSiSpacePointTool/CMakeLists.txt b/Tracker/TrackerRecTools/FaserSiSpacePointTool/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ad3ea577a16ac4586bd35f5458c4c24f238d8001 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiSpacePointTool/CMakeLists.txt @@ -0,0 +1,37 @@ +################################################################################ +# Package: FaserSiSpacePointTool +################################################################################ + +# Declare the package name: +atlas_subdir( FaserSiSpacePointTool ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + Control/AthenaKernel + DetectorDescription/GeoPrimitives + Tracker/TrackerRecEvent/TrackerPrepRawData + DetectorDescription/Identifier + PRIVATE + GaudiKernel + Tracker/TrackerDetDescr/TrackerReadoutGeometry + Tracker/TrackerDetDescr/TrackerIdentifier + Tracker/TrackerRecEvent/TrackerSpacePoint + ) + +# External dependencies: +find_package( Eigen ) + +# Component(s) in the package: +atlas_add_library( FaserSiSpacePointToolLib + FaserSiSpacePointTool/*.h src/*.cxx src/*.h + PUBLIC_HEADERS FaserSiSpacePointTool + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel GeoPrimitives TrackerPrepRawData + PRIVATE_LINK_LIBRARIES GaudiKernel TrackerIdentifier TrackerReadoutGeometry TrackerSpacePoint ) + + atlas_add_component( FaserSiSpacePointTool + src/components/*.cxx + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel GeoPrimitives TrackerPrepRawData GaudiKernel TrackerIdentifier TrackerReadoutGeometry TrackerSpacePoint FaserSiSpacePointToolLib ) + diff --git a/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/FaserSCTinformation.h b/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/FaserSCTinformation.h new file mode 100644 index 0000000000000000000000000000000000000000..dccb140241e894b4cf21788acd05b98f040462cf --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/FaserSCTinformation.h @@ -0,0 +1,130 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + + +///////////////////////////////////////////////////////////////////////////////// +// Header file for class SCTinformation +///////////////////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +///////////////////////////////////////////////////////////////////////////////// +// Class for sct strips information +///////////////////////////////////////////////////////////////////////////////// +// Version 1.0 19/04/2018 I.Gavrilenko +///////////////////////////////////////////////////////////////////////////////// + +#ifndef FaserSCTinformation_h +#define FaserSCTinformation_h + + +class TrackerCluster; + +namespace Tracker +{ + class FaserSCTinformation { + + ///////////////////////////////////////////////////////////////////////////////// + // Public methods: + ///////////////////////////////////////////////////////////////////////////////// + + public: + + FaserSCTinformation(const Tracker::TrackerCluster* CL, const Amg::Vector3D& a, const Amg::Vector3D& b, const Amg::Vector3D& vec); + + FaserSCTinformation(const FaserSCTinformation&) = default; + virtual ~FaserSCTinformation() = default; + FaserSCTinformation& operator = (const FaserSCTinformation&) = default; + + const Tracker::TrackerCluster* cluster() const; + const Amg::Vector3D& a() const; + const Amg::Vector3D& q() const; + const Amg::Vector3D& s() const; + const Amg::Vector3D& qs() const; + double qm() const; + + double step(FaserSCTinformation&) const; + Amg::Vector3D position(const double s) const; + + private: + + const Tracker::TrackerCluster* m_CL; + Amg::Vector3D m_A; + Amg::Vector3D m_Q; + Amg::Vector3D m_S; + Amg::Vector3D m_QS; + double m_QM; + }; + + + ///////////////////////////////////////////////////////////////////////////////// + // Inline methods + ///////////////////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////////////////////// + // Constructor with initialisation + ///////////////////////////////////////////////////////////////////////////////// + + inline FaserSCTinformation::FaserSCTinformation + (const Tracker::TrackerCluster* CL, const Amg::Vector3D& a, const Amg::Vector3D& b, const Amg::Vector3D& vec) + { + m_CL = CL ; + m_A = 0.5*(a+b) ; // Center of strip + m_Q = a-b ; // Direction of strip a-b + m_S = 2.*(m_A-vec) ; // Direction of trajectory a+b-2*vertexVec + m_QS = m_Q.cross(m_S); // Normal to strip diretion and trjectory direction plane + m_QM = 1./m_Q.mag() ; // Invert length of the strip + } + + ///////////////////////////////////////////////////////////////////////////////// + // Getter methods + ///////////////////////////////////////////////////////////////////////////////// + inline const Tracker::TrackerCluster* FaserSCTinformation::cluster() const + { + return m_CL; + } + + inline const Amg::Vector3D& FaserSCTinformation::a() const + { + return m_A; + } + + inline const Amg::Vector3D& FaserSCTinformation::q() const + { + return m_Q; + } + + inline const Amg::Vector3D& FaserSCTinformation::s() const + { + return m_S; + } + + inline const Amg::Vector3D& FaserSCTinformation::qs() const + { + return m_QS; + } + + inline double FaserSCTinformation::qm() const + { + return m_QM; + } + + ///////////////////////////////////////////////////////////////////////////////// + // Step along strip + ///////////////////////////////////////////////////////////////////////////////// + + inline double FaserSCTinformation::step(FaserSCTinformation& In) const + { + double a = m_Q.dot(In.m_QS); + if (a!=0.) return (-m_S.dot(In.m_QS)/a); + else return 10000.; + } + + inline Amg::Vector3D FaserSCTinformation::position(const double s) const + { + return (m_A+(0.5*s)*m_Q); + } +} + +#endif // FaserSCTinformation_h diff --git a/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/TrackerSpacePointMakerTool.h b/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/TrackerSpacePointMakerTool.h new file mode 100644 index 0000000000000000000000000000000000000000..7d26b1b5a37d07a51ecc16625e4f3965524f7e5e --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/TrackerSpacePointMakerTool.h @@ -0,0 +1,154 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TrackerSpacePointMakerTool_H +#define TrackerSpacePointMakerTool_H + +#include "AthenaBaseComps/AthAlgTool.h" + +#include "AthenaKernel/SlotSpecificObj.h" +#include "GeoPrimitives/GeoPrimitives.h" +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "FaserSiSpacePointTool/FaserSCTinformation.h" +#include "TrkSpacePoint/SpacePoint.h" + +#include <mutex> +#include <string> + +class FaserSCT_ID; +class SpacePointCollection; +class SpacePointOverlapCollection; +namespace TrackerDD { + class SiDetectorElementCollection; + class SiDetectorElement; +} + +namespace Tracker { + class TrackerCluster; +} + + +namespace Tracker +{ + /** + * @class TrackerSpacePointMakerTool + * Used by SiTrackerSpacePointFinder. + * Make SCT_SpacePoints from SCT_Clusters. + * Make OverlapSpacePoints from SCT_Clusters. + */ + + class TrackerSpacePointMakerTool : public AthAlgTool { + + public: + /// Constructor + TrackerSpacePointMakerTool(const std::string& type, const std::string& name, const IInterface* parent); + + /// Default destructor + virtual ~TrackerSpacePointMakerTool() = default; + + /// Return interfaceID + static const InterfaceID& interfaceID(); + + /// Initialize + virtual StatusCode initialize() override; + + /// Finalize + virtual StatusCode finalize() override; + + /// To trigger cleanup for new event + void newEvent() const; + + /// Convert clusters to space points: SCT_Clusters -> SCT_SpacePoints + Trk::SpacePoint* makeSCT_SpacePoint(const TrackerCluster& cluster1, const TrackerCluster& cluster2, + const Amg::Vector3D& vertexVec, + const TrackerDD::SiDetectorElement* element1, const TrackerDD::SiDetectorElement* element2, double stripLengthGapTolerance) const; + + /// Convert clusters to space points: SCT_Clusters -> SCT_SpacePoints + void fillSCT_SpacePointCollection(const FaserSCT_ClusterCollection* clusters1, + const FaserSCT_ClusterCollection* clusters2, double min, double max, bool allClusters, + const Amg::Vector3D& vertexVec, const TrackerDD::SiDetectorElementCollection* elements, + SpacePointCollection* spacepointCollection) const; + + + /// Convert clusters to space points using eta direction overlaps: SCT_Clusters -> OverlapSpacePoints + void fillSCT_SpacePointEtaOverlapCollection(const FaserSCT_ClusterCollection* clusters1, + const FaserSCT_ClusterCollection* clusters2, double min, double max, bool allClusters, + const Amg::Vector3D& vertexVec, const TrackerDD::SiDetectorElementCollection* elements, + SpacePointOverlapCollection* spacepointOverlapCollection) const; + + /// Convert clusters to space points using phi direction overlaps: SCT_Clusters -> OverlapSpacePoints + void fillSCT_SpacePointPhiOverlapCollection(const FaserSCT_ClusterCollection* clusters1, + const FaserSCT_ClusterCollection* clusters2, double min1, double max1, double min2, + double max2, bool allClusters, const Amg::Vector3D& vertexVec , + const TrackerDD::SiDetectorElementCollection* elements, + SpacePointOverlapCollection* spacepointOverlapCollection) const; + + private: + /// @name Cut parameters + //@{ + DoubleProperty m_stripLengthTolerance{this, "StripLengthTolerance", 0.01}; + DoubleProperty m_SCTgapParameter{this, "SCTGapParameter", 0., "Recommend 0.001 - 0.0015 for ITK geometry"}; + //@} + + /// @name option to use closest approach of SCT strips as position for SpacePoint + //@{ + BooleanProperty m_usePerpProj{this, "UsePerpendicularProjection", false}; + //@} + + /// @name ID helper + //@{ + const FaserSCT_ID* m_idHelper{nullptr}; + //@} + + /// @name Mutex to protect data members in const methods + //@{ + mutable std::mutex m_mutex; + //@} + + /// @class CacheEntry + /// To hold event dependent data + struct CacheEntry { + EventContext::ContextEvt_t m_evt{EventContext::INVALID_CONTEXT_EVT}; //!< Event number, slot number, used to check if already processed event or not. + std::vector<Trk::SpacePoint*> m_tmpSpacePoints{}; //!< SpacePoint cache + std::vector<FaserSCTinformation> m_SCT0{}; //!< SCTinformation vector for 0-th element (side 0) + std::vector<FaserSCTinformation> m_SCT1{}; //!< SCTinformation vector for 1-st element (side 1) + const TrackerDD::SiDetectorElement* m_element0{nullptr}; //!< SiDetectorElement for 0-th element (side 0) + const TrackerDD::SiDetectorElement* m_element1{nullptr}; //!< SiDetectorElement for 1-st element (side 1) + const TrackerDD::SiDetectorElement* m_elementOLD{nullptr}; //!< SiDetectorElement cache + /// Clear all members of event dependent data + void clear() { + if (m_tmpSpacePoints.size()) { + for (Trk::SpacePoint* sp : m_tmpSpacePoints) { + delete sp; + } + } + m_tmpSpacePoints.clear(); + m_SCT0.clear(); + m_SCT1.clear(); + m_element0 = nullptr; + m_element1 = nullptr; + m_elementOLD = nullptr; + }; + }; + + /// SG::SlotSpecificObj is used to hold event dependent data cache. + /// Guarded by m_mutex in const methods. + mutable SG::SlotSpecificObj<CacheEntry> m_cache ATLAS_THREAD_SAFE; + + /// Get stripLengthGapTolerance and return offset value for two SiDetectorElement's + double offset(const TrackerDD::SiDetectorElement* element1, const TrackerDD::SiDetectorElement* element2, double& stripLengthGapTolerance) const; + + /// Get stripLengthGapTolerance for two SiDetectorElement's + void offset(double& stripLengthGapTolerance, const TrackerDD::SiDetectorElement* element1, const TrackerDD::SiDetectorElement* element2) const; + + /// Not implemented yet + bool fillSCT_Information(const FaserSCT_ClusterCollection* clusters1, const FaserSCT_ClusterCollection* clusters2, + const Amg::Vector3D& vertexVec, + const TrackerDD::SiDetectorElementCollection* elements) const; + + /// Convert clusters to space points using CacheEntry + void makeSCT_SpacePoints(const double stripLengthGapTolerance) const; + }; +} +#endif //TrackerSpacePointMakerTool_H diff --git a/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/TrackerSpacePointMakerTool.cxx b/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/TrackerSpacePointMakerTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..738797a6d3faa6b293b234e12a2cc674910b7d52 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/TrackerSpacePointMakerTool.cxx @@ -0,0 +1,528 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + */ + +#include "FaserSiSpacePointTool/TrackerSpacePointMakerTool.h" + +// Cluster and space point collections +#include "TrkSpacePoint/SpacePointCollection.h" +#include "TrkSpacePoint/SpacePointOverlapCollection.h" + +// For processing clusters +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerReadoutGeometry/SiLocalPosition.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" + +// Space points +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" + +namespace Tracker +{ + +static const InterfaceID IID_ITrackerSpacePointMakerTool +("TrackerSpacePointMakerTool", 252891434, 0); + +const InterfaceID& TrackerSpacePointMakerTool::interfaceID() { + return IID_ITrackerSpacePointMakerTool; +} + +// Constructor with parameters: +TrackerSpacePointMakerTool::TrackerSpacePointMakerTool(const std::string& type, + const std::string& name, + const IInterface* parent) : + AthAlgTool(type, name, parent) { + declareInterface< TrackerSpacePointMakerTool>(this); + } +//-------------------------------------------------------------------------- +StatusCode TrackerSpacePointMakerTool::initialize() { + // Get the SCT Helper + ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID")); + m_SCTgapParameter = fabs(m_SCTgapParameter); + if (m_SCTgapParameter > 0.002) m_SCTgapParameter = 0.002; + return StatusCode::SUCCESS; +} +//-------------------------------------------------------------------------- +StatusCode TrackerSpacePointMakerTool::finalize() { + return StatusCode::SUCCESS; +} +//-------------------------------------------------------------------------- +void TrackerSpacePointMakerTool::newEvent() const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + std::lock_guard<std::mutex> lock{m_mutex}; + CacheEntry* ent{m_cache.get(ctx)}; + if (ent->m_evt!=ctx.evt()) { // New event in this slot + ent->clear(); + ent->m_evt = ctx.evt(); + } else { + ent->m_elementOLD = nullptr; + } +} +//-------------------------------------------------------------------------- +Trk::SpacePoint* TrackerSpacePointMakerTool::makeSCT_SpacePoint(const Tracker::TrackerCluster& cluster1, + const Tracker::TrackerCluster& cluster2, + const Amg::Vector3D& vertexVec, + const TrackerDD::SiDetectorElement* element1, + const TrackerDD::SiDetectorElement* element2, + double stripLengthGapTolerance) const { + + // Find intersection of a line through a cluster on one sct detector and + // a line through a cluster on its stereo pair. Return zero if lines + // don't intersect. + + // A general point on the line joining point a to point b is + // x, where 2*x=(1+m)*a + (1-m)*b. Similarly for 2*y=(1+n)*c + (1-n)*d. + // Suppose that v is the vertex, which we take as (0,0,0); this could + // an input parameter later, if required. Requiring that the two 'general + // points' lie on a straight through v means that the vector x-v is a + // multiple of y-v. This condition fixes the parameters m and n. + // We then return the 'space-point' x, supposed to be the phi-layer. + // We require that -1<m<1, otherwise x lies + // outside the segment a to b; and similarly for n. + + Amg::Vector2D locpos = cluster1.localPosition(); + Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); + std::pair<Amg::Vector3D, Amg::Vector3D> + ends1(element1->endsOfStrip(TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.))); + + locpos = cluster2.localPosition(); + localPos = Amg::Vector2D(locpos[0], locpos[1]); + std::pair<Amg::Vector3D, Amg::Vector3D> + ends2(element2->endsOfStrip(TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.))); + + Amg::Vector3D a(ends1.first); // Top end, first cluster + Amg::Vector3D b(ends1.second); // Bottom end, first cluster + Amg::Vector3D c(ends2.first); // Top end, second cluster + Amg::Vector3D d(ends2.second); // Bottom end, second cluster + Amg::Vector3D q(a-b); // vector joining ends of line + Amg::Vector3D r(c-d); // vector joining ends of line + + Amg::Vector3D point; + + bool ok(true); + 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. + This option is especially aimed at the use with cosmics data. + */ + Amg::Vector3D mab(c - a); + 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 = 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; + } + } 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 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 (fabs( m ) > limit) ok = false; + else if (fabs((n=-(t.dot(qs)/r.dot(qs)))) > limit) ok = false; + + if ((not ok) and (stripLengthGapTolerance != 0.)) { + + double qm = q.mag() ; + double limitn = limit+(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.) or (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.) or (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 and fabs(n) < limit) ok = true; + } + } + } + if (ok) point = 0.5*(a + b + m*q); + } + if (ok) { + 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); + return new FaserSCT_SpacePoint(elementIdList, new Amg::Vector3D(point), clusList); + } + + return nullptr; +} + +//-------------------------------------------------------------------------- +void TrackerSpacePointMakerTool::fillSCT_SpacePointCollection(const Tracker::FaserSCT_ClusterCollection* clusters1, + const Tracker::FaserSCT_ClusterCollection* clusters2, + double min, double max, bool allClusters, + const Amg::Vector3D& vertexVec, + const TrackerDD::SiDetectorElementCollection* elements, + SpacePointCollection* spacepointCollection) const { + double stripLengthGapTolerance = 0.; + + // Try all combinations of clusters for space points + FaserSCT_ClusterCollection::const_iterator clusters1Next = clusters1->begin(); + FaserSCT_ClusterCollection::const_iterator clusters1Finish = clusters1->end(); + + // -ME fixme- get first element + const TrackerDD::SiDetectorElement* element1 = nullptr; + + if ((*clusters1Next) and (clusters1Next != clusters1Finish)) { + element1 = elements->getDetectorElement(clusters1->identifyHash()); + } + + if (element1==nullptr) { + ATH_MSG_ERROR("Bad cluster identifier " << m_idHelper->show_to_string((*clusters1Next)->identify())); + return; + } + + //tmpSpacePoints changed to local variable to enable rentrancy + std::vector<Trk::SpacePoint*> tmpSpacePoints; + + for (; clusters1Next!=clusters1Finish; ++clusters1Next){ + Amg::Vector2D locpos = (*clusters1Next)->localPosition(); + Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); + double xPhi1 = TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.).xPhi(); + FaserSCT_ClusterCollection::const_iterator clusters2Next=(*clusters2).begin(); + FaserSCT_ClusterCollection::const_iterator clusters2Finish=(*clusters2).end(); + + // -ME fixme- get first element + const TrackerDD::SiDetectorElement* element2 = nullptr; + if (*clusters2Next and (clusters2Next != clusters2Finish)) { + element2= elements->getDetectorElement(clusters2->identifyHash()); + } + + if (element2==nullptr) { + ATH_MSG_ERROR("Bad cluster identifier " << m_idHelper->show_to_string((*clusters2Next)->identify())); + break; + } + + if (m_SCTgapParameter != 0.) { + double dm = offset(element1, element2, stripLengthGapTolerance); + min -= dm; + max += dm; + } + + for (; clusters2Next!=clusters2Finish; ++clusters2Next){ + Amg::Vector2D locpos = (*clusters2Next)->localPosition(); + Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); + double diff = TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.).xPhi() - xPhi1; + if (((min <= diff) and (diff <= max)) or allClusters) { + Trk::SpacePoint* sp = + makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2, stripLengthGapTolerance); + if (sp) { + tmpSpacePoints.push_back(sp); + } + } + } + } + + spacepointCollection->reserve(spacepointCollection->size() + tmpSpacePoints.size()); + for (Trk::SpacePoint* sp: tmpSpacePoints) { + spacepointCollection->push_back(sp); + } +} + + + +//-------------------------------------------------------------------------- +void TrackerSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const Tracker::FaserSCT_ClusterCollection* clusters1, + const Tracker::FaserSCT_ClusterCollection* clusters2, + double min, double max, bool allClusters, + const Amg::Vector3D& vertexVec, + const TrackerDD::SiDetectorElementCollection* elements, + SpacePointOverlapCollection* spacepointoverlapCollection) const { + + double stripLengthGapTolerance = 0.; + + // Require that (xPhi2 - xPhi1) lie in the range specified. + // Used eta modules + // Try all combinations of clusters for space points + Tracker::FaserSCT_ClusterCollection::const_iterator clusters1Next = clusters1->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator clusters1Finish = clusters1->end(); + + const TrackerDD::SiDetectorElement* element1 = nullptr; + + if ((*clusters1Next) and (clusters1Next != clusters1Finish)) { + element1 = elements->getDetectorElement(clusters1->identifyHash()); + } + if (element1==nullptr) { + ATH_MSG_ERROR("Bad cluster identifier " << m_idHelper->show_to_string((*clusters1Next)->identify())); + return; + } + for (; clusters1Next!=clusters1Finish; ++clusters1Next) { + + Amg::Vector2D locpos = (*clusters1Next)->localPosition(); + Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); + double xPhi1 = TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.).xPhi(); + + Tracker::FaserSCT_ClusterCollection::const_iterator clusters2Next = (*clusters2).begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator clusters2Finish = (*clusters2).end(); + + const TrackerDD::SiDetectorElement* element2 = nullptr; + if (*clusters2Next and (clusters2Next != clusters2Finish)) { + element2 = elements->getDetectorElement(clusters2->identifyHash()); + } + if (element2==nullptr) { + ATH_MSG_ERROR("Bad cluster identifier " << m_idHelper->show_to_string((*clusters2Next)->identify())); + break; + } + if (m_SCTgapParameter != 0.) { + double dm = offset(element1, element2, stripLengthGapTolerance); + min -= dm; + max += dm; + } + + for (; clusters2Next!=clusters2Finish; ++clusters2Next){ + Amg::Vector2D locpos = (*clusters2Next)->localPosition(); + Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); + double diff = TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.).xPhi() - xPhi1; + if (((min <= diff) and (diff <= max)) or allClusters){ + Trk::SpacePoint* sp = + makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2, stripLengthGapTolerance); + if (sp) { + spacepointoverlapCollection->push_back(sp); + } + } + } + } + +} + + +//-------------------------------------------------------------------------- +void TrackerSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const Tracker::FaserSCT_ClusterCollection* clusters1, + const Tracker::FaserSCT_ClusterCollection* clusters2, + double min1, double max1, double min2, double max2, + bool allClusters, + const Amg::Vector3D& vertexVec, + const TrackerDD::SiDetectorElementCollection* elements, + SpacePointOverlapCollection* spacepointoverlapCollection) const { + + double 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 + // overlaps. + + // Try all combinations of clusters for space points + Tracker::FaserSCT_ClusterCollection::const_iterator clusters1Next = clusters1->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator clusters1Finish = clusters1->end(); + + const TrackerDD::SiDetectorElement* element1 = nullptr; + if ((*clusters1Next) and (clusters1Next != clusters1Finish)) { + element1 = elements->getDetectorElement(clusters1->identifyHash()); + } + if (element1==nullptr) { + ATH_MSG_ERROR("Bad cluster identifier " << m_idHelper->show_to_string((*clusters1Next)->identify())); + return; + } + + for (; clusters1Next!=clusters1Finish; ++clusters1Next){ + Amg::Vector2D locpos = (*clusters1Next)->localPosition(); + Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); + double xPhi1 = TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.).xPhi(); + if (((min1 <= xPhi1) and (xPhi1 <= max1)) or allClusters) { + Tracker::FaserSCT_ClusterCollection::const_iterator clusters2Next = (*clusters2).begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator clusters2Finish = (*clusters2).end(); + + const TrackerDD::SiDetectorElement* element2 = nullptr; + if (*clusters2Next and (clusters2Next != clusters2Finish)) { + element2 = elements->getDetectorElement(clusters2->identifyHash()); + } + if (element2==nullptr) { + ATH_MSG_ERROR("Bad cluster identifier " << m_idHelper->show_to_string((*clusters2Next)->identify())); + break; + } + + if (m_SCTgapParameter != 0.) { + double dm = offset(element1, element2, stripLengthGapTolerance); + min2 -= dm; + max2 += dm; + } + + for (; clusters2Next!=clusters2Finish; ++clusters2Next) { + Amg::Vector2D locpos = (*clusters2Next)->localPosition(); + Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); + double xPhi2 = TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.).xPhi(); + if (((min2<= xPhi2) and (xPhi2 <= max2)) or allClusters) { + Trk::SpacePoint* sp = + makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2, stripLengthGapTolerance); + if (sp) { + spacepointoverlapCollection->push_back(sp); + } + } + } + } + } +} + +/////////////////////////////////////////////////////////////////// +// Possible offset estimation in Z or R direction due to gap size +/////////////////////////////////////////////////////////////////// + +double TrackerSpacePointMakerTool::offset +(const TrackerDD::SiDetectorElement* element1, const TrackerDD::SiDetectorElement* element2, double& stripLengthGapTolerance) const +{ + 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)) > 0.7) d*=(r/fabs(T1(2,3))); // endcap d = d*R/Z + + stripLengthGapTolerance = d; + return dm; +} + +void TrackerSpacePointMakerTool::offset(double& stripLengthGapTolerance, + const TrackerDD::SiDetectorElement* element1, + const TrackerDD::SiDetectorElement* element2) const { + const Amg::Transform3D& T1 = element1->transform(); + const Amg::Transform3D& T2 = element2->transform(); + Amg::Vector3D C = element1->center() ; + + double r = sqrt(C[0]*C[0]+C[1]*C[1]) ; + double x12 = T1(0,0)*T2(0,0) + T1(1,0)*T2(1,0) + T1(2,0)*T2(2,0) ; + 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 = 0.; + if (element1->design().shape() == TrackerDD::Trapezoid || element1->design().shape() == TrackerDD::Annulus) { + d = dm*(1./0.04); + } else { + d = dm/sqrt((1.-x12)*(1.+x12)); + } + + if (fabs(T1(2,2)) > 0.7) d *= (r/fabs(T1(2,3))); // endcap d = d*R/Z + stripLengthGapTolerance = d; +} + +/////////////////////////////////////////////////////////////////// +// Compare SCT strips and space points production +/////////////////////////////////////////////////////////////////// + +void TrackerSpacePointMakerTool::makeSCT_SpacePoints(const double stripLengthGapTolerance) const { + // Find intersection of a line through a cluster on one sct detector and + // a line through a cluster on its stereo pair. Return zero if lines + // don't intersect. + + // A general point on the line joining point a to point b is + // x, where 2*x=(1+m)*a + (1-m)*b. Similarly for 2*y=(1+n)*c + (1-n)*d. + // Suppose that v is the vertex, which we take as (0,0,0); this could + // an input parameter later, if required. Requiring that the two 'general + // points' lie on a straight through v means that the vector x-v is a + // multiple of y-v. This condition fixes the parameters m and n. + // We then return the 'space-point' x, supposed to be the phi-layer. + // We require that -1<m<1, otherwise x lies + // outside the segment a to b; and similarly for n. + + const EventContext& ctx{Gaudi::Hive::currentContext()}; + std::lock_guard<std::mutex> lock{m_mutex}; + CacheEntry* ent{m_cache.get(ctx)}; + if (ent->m_evt!=ctx.evt()) { // New event in this slot + ent->clear(); + ent->m_evt = ctx.evt(); + } else { + if (ent->m_tmpSpacePoints.size()) { + for (Trk::SpacePoint* sp : ent->m_tmpSpacePoints) { + delete sp; + } + } + ent->m_tmpSpacePoints.clear(); + } + + std::vector<FaserSCTinformation>::iterator I = ent->m_SCT0.begin(), IE = ent->m_SCT0.end(); + std::vector<FaserSCTinformation>::iterator J,JB = ent->m_SCT1.begin(), JE = ent->m_SCT1.end(); + + double limit = 1. + m_stripLengthTolerance; + + for (; I!=IE; ++I) { + double qm = (*I).qm(); + for (J=JB; J!=JE; ++J) { + double limitm = limit+(stripLengthGapTolerance*qm); + + double a =-(*I).s().dot((*J).qs()); + double b = (*I).q().dot((*J).qs()); + if (fabs(a) > fabs(b)*limitm) continue; + + double qn = (*J).qm(); + double limitn = limit+(stripLengthGapTolerance*qn); + + double c =-(*J).s().dot((*I).qs()); + double d = (*J).q().dot((*I).qs()); + if (fabs(c) > fabs(d)*limitn) continue; + + double m = a/b; + double n = c/d; + + if (m > limit or n > limit) { + + double cs = (*I).q().dot((*J).q())*(qm*qm); + double dm = (m-1.); + double dmn = (n-1.)*cs; + if (dmn > dm) dm = dmn; + m-=dm; n-=(dm/cs); + + } else if (m < -limit or n < -limit) { + + double cs = (*I).q().dot((*J).q())*(qm*qm); + double dm = -(1.+m); + double dmn = -(1.+n)*cs; + if (dmn > dm) dm = dmn; + m+=dm; n+=(dm/cs); + + } + + if (fabs(m) > limit or fabs(n) > limit) continue; + + Amg::Vector3D point((*I).position(m)); + + ATH_MSG_VERBOSE("SpacePoint generated at: ( " << point.x() << " , " << point.y() << " , " << point.z() << " ) "); + const std::pair<IdentifierHash, IdentifierHash> elementIdList(ent->m_element0->identifyHash(), ent->m_element1->identifyHash()); + const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>* + clusList = new std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>((*I).cluster(), (*J).cluster()); + ent->m_tmpSpacePoints.push_back(new FaserSCT_SpacePoint(elementIdList, new Amg::Vector3D(point), clusList)); + } + } +} + +} \ No newline at end of file diff --git a/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/components/FaserSiSpacePointTool_entries.cxx b/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/components/FaserSiSpacePointTool_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3114514e3ac3ae9a29e7765379eee07d0c0acaf6 --- /dev/null +++ b/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/components/FaserSiSpacePointTool_entries.cxx @@ -0,0 +1,4 @@ +#include "FaserSiSpacePointTool/TrackerSpacePointMakerTool.h" + +DECLARE_COMPONENT( Tracker::TrackerSpacePointMakerTool ) + diff --git a/Tracker/TrackerSimEvent/CMakeLists.txt b/Tracker/TrackerSimEvent/CMakeLists.txt index 50e54b552625898b5a04952b1f0cd1144aefddaf..6077137cb256ce8e1742eeb4e798c5bf6ba14004 100644 --- a/Tracker/TrackerSimEvent/CMakeLists.txt +++ b/Tracker/TrackerSimEvent/CMakeLists.txt @@ -23,7 +23,7 @@ find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) # Component(s) in the package: atlas_add_library( TrackerSimEvent - src/*.cxx + src/*.cxx src/*.h PUBLIC_HEADERS TrackerSimEvent INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} diff --git a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackCollHandle_TruthTracks.cxx b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackCollHandle_TruthTracks.cxx index 47ceeb8423dfc22c372aa056b545f8713654bb7d..8e9fe62329a54c4bbd7e838678b04c744f2082cd 100644 --- a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackCollHandle_TruthTracks.cxx +++ b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackCollHandle_TruthTracks.cxx @@ -477,7 +477,7 @@ bool TrackCollHandle_TruthTracks::load() } //____________________________________________________________________ -bool TrackCollHandle_TruthTracks::cut(TrackHandleBase* handle) +bool TrackCollHandle_TruthTracks::cut(TrackHandleBase* ) { // if (!TrackCollHandleBase::cut(handle)) // return false;