diff --git a/Scintillator/ScintEventCnv/ScintSimAthenaPool/CMakeLists.txt b/Scintillator/ScintEventCnv/ScintSimEventAthenaPool/CMakeLists.txt similarity index 100% rename from Scintillator/ScintEventCnv/ScintSimAthenaPool/CMakeLists.txt rename to Scintillator/ScintEventCnv/ScintSimEventAthenaPool/CMakeLists.txt diff --git a/Scintillator/ScintEventCnv/ScintSimAthenaPool/ScintSimEventAthenaPool/ScintSimDataCollection_p1.h b/Scintillator/ScintEventCnv/ScintSimEventAthenaPool/ScintSimEventAthenaPool/ScintSimDataCollection_p1.h similarity index 100% rename from Scintillator/ScintEventCnv/ScintSimAthenaPool/ScintSimEventAthenaPool/ScintSimDataCollection_p1.h rename to Scintillator/ScintEventCnv/ScintSimEventAthenaPool/ScintSimEventAthenaPool/ScintSimDataCollection_p1.h diff --git a/Scintillator/ScintEventCnv/ScintSimAthenaPool/ScintSimEventAthenaPool/ScintSimData_p1.h b/Scintillator/ScintEventCnv/ScintSimEventAthenaPool/ScintSimEventAthenaPool/ScintSimData_p1.h similarity index 100% rename from Scintillator/ScintEventCnv/ScintSimAthenaPool/ScintSimEventAthenaPool/ScintSimData_p1.h rename to Scintillator/ScintEventCnv/ScintSimEventAthenaPool/ScintSimEventAthenaPool/ScintSimData_p1.h diff --git a/Scintillator/ScintEventCnv/ScintSimAthenaPool/ScintSimEventAthenaPool/ScintSimEventAthenaPoolCnvDict.h b/Scintillator/ScintEventCnv/ScintSimEventAthenaPool/ScintSimEventAthenaPool/ScintSimEventAthenaPoolCnvDict.h similarity index 100% rename from Scintillator/ScintEventCnv/ScintSimAthenaPool/ScintSimEventAthenaPool/ScintSimEventAthenaPoolCnvDict.h rename to Scintillator/ScintEventCnv/ScintSimEventAthenaPool/ScintSimEventAthenaPool/ScintSimEventAthenaPoolCnvDict.h diff --git a/Scintillator/ScintEventCnv/ScintSimAthenaPool/ScintSimEventAthenaPool/selection.xml b/Scintillator/ScintEventCnv/ScintSimEventAthenaPool/ScintSimEventAthenaPool/selection.xml similarity index 100% rename from Scintillator/ScintEventCnv/ScintSimAthenaPool/ScintSimEventAthenaPool/selection.xml rename to Scintillator/ScintEventCnv/ScintSimEventAthenaPool/ScintSimEventAthenaPool/selection.xml diff --git a/Scintillator/ScintEventCnv/ScintSimAthenaPool/src/ScintHitCollectionCnv.cxx b/Scintillator/ScintEventCnv/ScintSimEventAthenaPool/src/ScintHitCollectionCnv.cxx similarity index 100% rename from Scintillator/ScintEventCnv/ScintSimAthenaPool/src/ScintHitCollectionCnv.cxx rename to Scintillator/ScintEventCnv/ScintSimEventAthenaPool/src/ScintHitCollectionCnv.cxx diff --git a/Scintillator/ScintEventCnv/ScintSimAthenaPool/src/ScintHitCollectionCnv.h b/Scintillator/ScintEventCnv/ScintSimEventAthenaPool/src/ScintHitCollectionCnv.h similarity index 100% rename from Scintillator/ScintEventCnv/ScintSimAthenaPool/src/ScintHitCollectionCnv.h rename to Scintillator/ScintEventCnv/ScintSimEventAthenaPool/src/ScintHitCollectionCnv.h diff --git a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ff1dad0f13a7f756d9226cd816b8e304d7d30f36 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/CMakeLists.txt @@ -0,0 +1,37 @@ +################################################################################ +# Package: TrackerSimEventAthenaPool +################################################################################ + +# Declare the package name: +atlas_subdir( TrackerSimEventAthenaPool ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PRIVATE + AtlasTest/TestTools + Database/AthenaPOOL/AthenaPoolCnvSvc + Database/AthenaPOOL/AthenaPoolUtilities + Database/AtlasSealCLHEP + GaudiKernel + Tracker/TrackerEventCnv/TrackerSimEventTPCnv + Tracker/TrackerSimEvent ) + +# External dependencies: +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_poolcnv_library( TrackerSimEventAthenaPoolPoolCnv + src/*.cxx + FILES TrackerSimEvent/FaserSiHitCollection.h + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaPoolCnvSvcLib AthenaPoolUtilities AtlasSealCLHEP GaudiKernel TrackerSimEventTPCnv TrackerSimEvent ) + +atlas_add_dictionary( TrackerSimEventAthenaPoolCnvDict + TrackerSimEventAthenaPool/TrackerSimEventAthenaPoolCnvDict.h + TrackerSimEventAthenaPool/selection.xml + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaPoolCnvSvcLib AthenaPoolUtilities AtlasSealCLHEP GaudiKernel TrackerSimEventTPCnv TrackerSimEvent ) + +# Install files from the package: +atlas_install_headers( TrackerSimEventAthenaPool ) +atlas_install_joboptions( share/*.py ) + diff --git a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/TrackerSimDataCollection_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/TrackerSimDataCollection_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..2298acdeb1092567af4e6b0e3d194a7184f22b62 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/TrackerSimDataCollection_p1.h @@ -0,0 +1,4 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + diff --git a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/TrackerSimData_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/TrackerSimData_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..2298acdeb1092567af4e6b0e3d194a7184f22b62 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/TrackerSimData_p1.h @@ -0,0 +1,4 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + diff --git a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/TrackerSimEventAthenaPoolCnvDict.h b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/TrackerSimEventAthenaPoolCnvDict.h new file mode 100644 index 0000000000000000000000000000000000000000..e17d593c961a0c4b94b7ac70fa0aeee3e98353d1 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/TrackerSimEventAthenaPoolCnvDict.h @@ -0,0 +1,9 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCINTSIMEVENTATHENAPOOLDICT_H +#define SCINTSIMEVENTATHENAPOOLDICT_H + + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/selection.xml b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..2eff49dff6688999d781e8922c8138fc7a36b1e8 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/TrackerSimEventAthenaPool/selection.xml @@ -0,0 +1,2 @@ +<lcgdict> +</lcgdict> diff --git a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.cxx b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a4725975ac05e81da114e34f703a482c8df7fbf5 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.cxx @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h" +#include "FaserSiHitCollectionCnv.h" + + +FaserSiHitCollection_PERS* FaserSiHitCollectionCnv::createPersistent(FaserSiHitCollection* transCont) { + MsgStream mlog(msgSvc(), "FaserSiHitCollectionConverter" ); + FaserSiHitCollectionCnv_PERS converter; + FaserSiHitCollection_PERS *persObj = converter.createPersistent( transCont, mlog ); + return persObj; +} + + +FaserSiHitCollection* FaserSiHitCollectionCnv::createTransient() { + MsgStream mlog(msgSvc(), "FaserSiHitCollectionConverter" ); + FaserSiHitCollectionCnv_p1 converter_p1; + + static const pool::Guid p1_guid("FF9508DE-3E25-425D-9556-16D319DCE0E1"); + + FaserSiHitCollection *trans_cont(0); + if( this->compareClassGuid(p1_guid)) { + std::unique_ptr< FaserSiHitCollection_p1 > col_vect( this->poolReadObject< FaserSiHitCollection_p1 >() ); + trans_cont = converter_p1.createTransient( col_vect.get(), mlog ); + } else { + throw std::runtime_error("Unsupported persistent version of Data container"); + } + return trans_cont; +} diff --git a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.h b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..1467731fec80812428550f9c75cc3393dcf07047 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSIHITCOLLECTIONCNV +#define FASERSIHITCOLLECTIONCNV + +#include "TrackerSimEvent/FaserSiHitCollection.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" +// typedef to the latest persistent version +typedef FaserSiHitCollection_p1 FaserSiHitCollection_PERS; +typedef FaserSiHitCollectionCnv_p1 FaserSiHitCollectionCnv_PERS; + +class FaserSiHitCollectionCnv : public T_AthenaPoolCustomCnv<FaserSiHitCollection, FaserSiHitCollection_PERS > { + friend class CnvFactory<FaserSiHitCollectionCnv>; +public: + FaserSiHitCollectionCnv(ISvcLocator* svcloc) : + T_AthenaPoolCustomCnv<FaserSiHitCollection, FaserSiHitCollection_PERS >( svcloc) {} +protected: + FaserSiHitCollection_PERS* createPersistent(FaserSiHitCollection* transCont); + FaserSiHitCollection* createTransient (); +}; + + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2272315026127c4232d2a10bbdfd4334458bfa63 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt @@ -0,0 +1,37 @@ +############################################################################### +# Package: TrackerSimEventTPCnv +################################################################################ + +# Declare the package name: +atlas_subdir( TrackerSimEventTPCnv ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Database/AthenaPOOL/AthenaPoolCnvSvc + GaudiKernel + Generators/GeneratorObjectsTPCnv + Tracker/TrackerSimEvent + PRIVATE + AtlasTest/TestTools + Control/StoreGate + DetectorDescription/Identifier ) + +# External dependencies: +find_package( CLHEP ) +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_library( TrackerSimEventTPCnv + src/TrackerHits/*.cxx + PUBLIC_HEADERS TrackerSimEventTPCnv + PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} + LINK_LIBRARIES GaudiKernel GeneratorObjectsTPCnv TrackerSimEvent AthenaPoolCnvSvcLib StoreGateLib SGtests + PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} TestTools Identifier ) + +atlas_add_dictionary( TrackerSimEventTPCnvDict + TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h + TrackerSimEventTPCnv/selection.xml + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv TrackerSimEvent TestTools StoreGateLib SGtests Identifier TrackerSimEventTPCnv ) + diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..3a4bec3cdaca91575a51d5589310e9b89306c395 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSIHITCNV_P1_H +#define FASERSIHITCNV_P1_H + +/* +Transient/Persistent converter for FaserSiHit class +*/ + +#include "TrackerSimEvent/FaserSiHit.h" +#include "FaserSiHit_p1.h" + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" + +class MsgStream; + + +class FaserSiHitCnv_p1 : public T_AthenaPoolTPCnvBase<FaserSiHit, FaserSiHit_p1> +{ +public: + + FaserSiHitCnv_p1() {} + + virtual void persToTrans(const FaserSiHit_p1* persObj, FaserSiHit* +transObj, MsgStream &log); + virtual void transToPers(const FaserSiHit* transObj, FaserSiHit_p1* +persObj, MsgStream &log); +}; + + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..488221edc81c645ae56e453a2cafb18195f1242d --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSIHITCOLLECTIONCNV_P1_H +#define FASERSIHITCOLLECTIONCNV_P1_H + +// FaserSiHitCollectionCnv_p1, T/P separation of FaserSi Hits +// author D.Costanzo <davide.costanzo@cern.ch> +// author O.Arnaez <olivier.arnaez@cern.ch> + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "TrackerSimEvent/FaserSiHitCollection.h" +#include "FaserSiHitCollection_p1.h" + + +class FaserSiHitCollectionCnv_p1 : public T_AthenaPoolTPCnvBase<FaserSiHitCollection, FaserSiHitCollection_p1> +{ + public: + + FaserSiHitCollectionCnv_p1() {}; + + virtual FaserSiHitCollection* createTransient(const FaserSiHitCollection_p1* persObj, MsgStream &log); + + virtual void persToTrans(const FaserSiHitCollection_p1* persCont, + FaserSiHitCollection* transCont, + MsgStream &log) ; + virtual void transToPers(const FaserSiHitCollection* transCont, + FaserSiHitCollection_p1* persCont, + MsgStream &log) ; + + private: + + static const double m_persEneUnit; + static const double m_persLenUnit; + static const double m_persAngUnit; + static const double m_2bHalfMaximum; + static const int m_2bMaximum; +}; + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..fa4018a016b99d2bc7baf9e46a8711fa6278e787 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSIHITCOLLECTION_P1_H +#define FASERSIHITCOLLECTION_P1_H + +/* + +Authors: Davide Costanzo Rob Duxfield + +*/ + +#include <vector> +#include <string> + +class FaserSiHitCollection_p1 +{ + public: +/// Default constructor + FaserSiHitCollection_p1 (); + //private: + + std::vector<float> m_hit1_meanTime; // 1 element per string + std::vector<float> m_hit1_x0; // + std::vector<float> m_hit1_y0; // + std::vector<float> m_hit1_z0; // + std::vector<float> m_hit1_theta; // + std::vector<float> m_hit1_phi; // + std::vector<unsigned short> m_nHits; // + + std::vector<unsigned short> m_hitEne_2b; // 1 element per hit + std::vector<unsigned short> m_hitLength_2b; // + + std::vector<unsigned short> m_dTheta; // 1 element per hit except for first hit in string + std::vector<unsigned short> m_dPhi; // + + std::vector<float> m_hitEne_4b; // 1 element per hit with m_hitEne_2b[i] == 2**16 + + std::vector<float> m_hitLength_4b; // 1 element per hit with m_hitLength_2b[i] == 2**16 + + std::vector<unsigned long> m_barcode; + std::vector<unsigned short> m_mcEvtIndex; + std::vector<char> m_evtColl; + std::vector<unsigned short> m_nBC; + + std::vector<unsigned long> m_id; + std::vector<unsigned short> m_nId; +}; + + +// inlines + +inline +FaserSiHitCollection_p1::FaserSiHitCollection_p1 () {} + +#endif diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h new file mode 100644 index 0000000000000000000000000000000000000000..159caf56dd047bd4d7d7fa505b3076dd96b07534 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h @@ -0,0 +1,19 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERSIHIT_P1_H +#define FASERSIHIT_P1_H + +#include "GeneratorObjectsTPCnv/HepMcParticleLink_p2.h" + +class FaserSiHit_p1 { + public: + float m_stX, m_stY, m_stZ; + float m_enX, m_enY, m_enZ; + float m_energyLoss; // deposited energy + float m_meanTime; // time of energy deposition + HepMcParticleLink_p2 m_partLink; + unsigned int m_ID; +}; +#endif diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h new file mode 100644 index 0000000000000000000000000000000000000000..6146be90a917d1eaf49b9a7c9996f5cc4eb66262 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h @@ -0,0 +1,20 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERSIMEVENTTPCNV_TRACKERSIMEVENTTPCNVDICT_H +#define TRACKERSIMEVENTTPCNV_TRACKERSIMEVENTTPCNVDICT_H + +//----------------------------------------------------------------------------- +// +// file: TrackerSimEventTPCnvDict_p1.h +// +//----------------------------------------------------------------------------- + + +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h" + +#endif // TRACKERSIMEVENTTPCNV_TRACKERSIMEVENTTPCNVDICT_H diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/selection.xml b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..72a04265e6367e090af8a543dd0a550d4e948af5 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/selection.xml @@ -0,0 +1,6 @@ +<lcgdict> + <!-- FaserSiHits --> + <class name="FaserSiHit_p1" /> + <class name="std::vector<FaserSiHit_p1>" /> + <class name="FaserSiHitCollection_p1" id="FF9508DE-3E25-425D-9556-16D319DCE0E1" /> +</lcgdict> diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCnv_p1.cxx b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCnv_p1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a6e9c320e1118143f505e4f3ad3f7234a3afd498 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCnv_p1.cxx @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrackerSimEvent/FaserSiHit.h" +#include "Identifier/Identifier.h" +#include "GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p2.h" + +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h" + + +void +FaserSiHitCnv_p1::persToTrans(const FaserSiHit_p1* persObj, FaserSiHit* transObj, MsgStream &log) +{ + HepMcParticleLinkCnv_p2 HepMcPLCnv; + HepMcParticleLink link; + HepMcPLCnv.persToTrans(&(persObj->m_partLink),&link, log); + + *transObj = FaserSiHit (HepGeom::Point3D<double> (persObj->m_stX, + persObj->m_stY, + persObj->m_stZ), + HepGeom::Point3D<double> (persObj->m_enX, + persObj->m_enY, + persObj->m_enZ), + persObj->m_energyLoss, + persObj->m_meanTime, + link, + persObj->m_ID + ); +} + + +void +FaserSiHitCnv_p1::transToPers(const FaserSiHit* transObj, FaserSiHit_p1* persObj, MsgStream &log) +{ +// if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "FaserSiHitCnv_p1::transToPers called " << endmsg; + HepMcParticleLinkCnv_p2 HepMcPLCnv; + + HepGeom::Point3D<double> st = transObj->localStartPosition(); + persObj->m_stX = st.x(); + persObj->m_stY = st.y(); + persObj->m_stZ = st.z(); + + HepGeom::Point3D<double> en = transObj->localEndPosition(); + persObj->m_enX = en.x(); + persObj->m_enY = en.y(); + persObj->m_enZ = en.z(); + + persObj->m_energyLoss = transObj->energyLoss(); + persObj->m_meanTime = transObj->meanTime(); + persObj->m_ID = transObj->identify(); + HepMcPLCnv.transToPers(&(transObj->particleLink()),&(persObj->m_partLink), log); +} diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p1.cxx b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c31eed267329943e8a0627881057281bcb7248df --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p1.cxx @@ -0,0 +1,312 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrackerSimEvent/FaserSiHit.h" +#include "TrackerSimEvent/FaserSiHitCollection.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h" +#include "GeneratorObjects/HepMcParticleLink.h" + +#include <cmath> + +//CLHEP +#include "CLHEP/Geometry/Point3D.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" +// Athena +#include "StoreGate/StoreGateSvc.h" + +// * * * stolen from eflowRec * * * // +inline double phicorr(double a) +{ + if (a <= -M_PI) + { + return a+(2*M_PI*floor(-(a-M_PI)/(2*M_PI))); + } + else if (a > M_PI) + { + return a-(2*M_PI*floor((a+M_PI)/(2*M_PI))); + } + else + { + return a; + } +} + +// * * * stolen from eflowRec * * * // +inline double cycle(double a, double b) +{ + double del = b-a; + if (del > M_PI) + { + return a+2.0*M_PI; + } + else if (del < -M_PI) + { + return a-2.0*M_PI; + } + else + { + return a; + } +} + + +const double FaserSiHitCollectionCnv_p1::m_persEneUnit = 1.0e-5; +const double FaserSiHitCollectionCnv_p1::m_persLenUnit = 1.0e-5; +const double FaserSiHitCollectionCnv_p1::m_persAngUnit = 1.0e-5; +const double FaserSiHitCollectionCnv_p1::m_2bHalfMaximum = pow(2.0, 15.0); +const int FaserSiHitCollectionCnv_p1::m_2bMaximum = (unsigned short)(-1); + + +void FaserSiHitCollectionCnv_p1::transToPers(const FaserSiHitCollection* transCont, FaserSiHitCollection_p1* persCont, MsgStream &/*log*/) +{ + // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and + // persistifies the end point of each hit plus the start point of the first hit in each string. + // + // Further compression is achieved by optimising the storage of the position vectors:- start (x,y,z) and (theta,phi) of + // first hit are stored as floats, (delta_theta,delta_phi) relative to the fisrst hit are stored as 2 byte numbers and + // used to specify the hit direction. All hit lengths are stored as 2 byte numbers. + // + // Additional savings are achieved by storing the energy loss for each hit as a 2 byte number and only storing the mean + // time of the first hit per string. + // + // See http://indico.cern.ch/getFile.py/access?contribId=11&resId=2&materialId=slides&confId=30893 for more info. + + static const double dRcut = 1.0e-7; + static const double dTcut = 1.0; + + const HepMcParticleLink * lastLink=nullptr; + int lastId = -1; + double stringFirstTheta = 0.0; + double stringFirstPhi = 0.0; + double lastT = 0.0; + double persSumE = 0.0; + double transSumE = 0.0; + unsigned int idx = 0; + unsigned int endBC = 0; + unsigned int endId = 0; + unsigned int endHit = 0; + HepGeom::Point3D<double> lastTransEnd(0.0, 0.0, 0.0); + HepGeom::Point3D<double> lastPersEnd(0.0, 0.0, 0.0); + + for (FaserSiHitCollection::const_iterator it = transCont->begin(); it != transCont->end(); ++it) { + + FaserSiHitCollection::const_iterator siHit = it; + + + if ( !lastLink || (siHit->particleLink() != *lastLink) ) { + + // store barcode once for set of consecutive hits with same barcode + + lastLink = &(siHit->particleLink()); + persCont->m_barcode.push_back(lastLink->barcode()); + persCont->m_mcEvtIndex.push_back(lastLink->eventIndex()); + persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); + + if (idx > 0) { + persCont->m_nBC.push_back(idx - endBC); + endBC = idx; + } + } + + if ( (int)siHit->identify() != lastId ) { + + // store id once for set of consecutive hits with same barcode + + lastId = siHit->identify(); + persCont->m_id.push_back(lastId); + + if (idx > 0) { + persCont->m_nId.push_back(idx - endId); + endId = idx; + } + } + + HepGeom::Point3D<double> st = siHit->localStartPosition(); + HepGeom::Point3D<double> en = siHit->localEndPosition(); + + const double dx = st.x() - lastTransEnd.x(); + const double dy = st.y() - lastTransEnd.y(); + const double dz = st.z() - lastTransEnd.z(); + const double t = siHit->meanTime(); + + const double dRLast = sqrt(dx * dx + dy * dy + dz * dz); // dR between end of previous hit and start of current one + const double dTLast = fabs(t - lastT); + + CLHEP::Hep3Vector direction(0.0, 0.0, 0.0); + double theta = 0.0; + double phi = 0.0; + bool startNewString = false; + + if (dRLast < dRcut && dTLast < dTcut) { + + // hit is part of existing string + + direction = CLHEP::Hep3Vector( en.x() - lastPersEnd.x(), en.y() - lastPersEnd.y(), en.z() - lastPersEnd.z() ); + + theta = direction.theta(); + phi = phicorr( direction.phi() ); + + const int dTheta_2b = (int)( (theta - stringFirstTheta) / m_persAngUnit + m_2bHalfMaximum + 0.5 ); + const int dPhi_2b = (int)( (cycle(phi, stringFirstPhi) - stringFirstPhi) / m_persAngUnit + m_2bHalfMaximum + 0.5 ); + + if ( dTheta_2b < m_2bMaximum && dTheta_2b >= 0 && dPhi_2b < m_2bMaximum && dPhi_2b >= 0) { + persCont->m_dTheta.push_back(dTheta_2b); + persCont->m_dPhi.push_back(dPhi_2b); + theta = stringFirstTheta + ( (double)dTheta_2b - m_2bHalfMaximum ) * m_persAngUnit; + phi = stringFirstPhi + ( (double)dPhi_2b - m_2bHalfMaximum ) * m_persAngUnit; + phi = phicorr(phi); + } + else { + startNewString = true; + } + } + + if (startNewString || dRLast >= dRcut || dTLast >= dTcut) { + + // begin new hit string + + direction = CLHEP::Hep3Vector( en.x() - st.x(), en.y() - st.y(), en.z() - st.z() ); + + theta = direction.theta(); + phi = phicorr( direction.phi() ); + + persCont->m_hit1_meanTime.push_back(t); + persCont->m_hit1_x0.push_back(st.x()); + persCont->m_hit1_y0.push_back(st.y()); + persCont->m_hit1_z0.push_back(st.z()); + persCont->m_hit1_theta.push_back(theta); + persCont->m_hit1_phi.push_back(phi); + + lastPersEnd = HepGeom::Point3D<double>(st.x(), st.y(), st.z()); + + stringFirstTheta = theta; + stringFirstPhi = phi; + + if (idx > 0) { + persCont->m_nHits.push_back(idx - endHit); + endHit = idx; + } + } + + lastTransEnd = HepGeom::Point3D<double>(en.x(), en.y(), en.z()); + transSumE += siHit->energyLoss(); + + const int eneLoss_2b = (int)((transSumE - persSumE) / m_persEneUnit + 0.5); // calculated to allow recovery sum over + // whole hit string to chosen precision + + const int hitLength_2b = (int)(direction.mag() / m_persLenUnit + 0.5); // calculated to give the correct position to + // the chosen precision, NOT the length of the + // hit (small difference in practice). + double eneLoss = 0.0; + + if (eneLoss_2b >= m_2bMaximum) { + eneLoss = siHit->energyLoss(); + persCont->m_hitEne_2b.push_back(m_2bMaximum); + persCont->m_hitEne_4b.push_back(eneLoss); + } + else { + eneLoss = eneLoss_2b * m_persEneUnit; + persCont->m_hitEne_2b.push_back(eneLoss_2b); + } + + double length = 0.0; + + if (hitLength_2b >= m_2bMaximum) { + length = direction.mag(); + persCont->m_hitLength_2b.push_back(m_2bMaximum); + persCont->m_hitLength_4b.push_back(direction.mag()); + } + else { + length = hitLength_2b * m_persLenUnit; + persCont->m_hitLength_2b.push_back(hitLength_2b); + } + + CLHEP::Hep3Vector persDir(length, 0.0, 0.0); + persDir.setTheta(theta); + persDir.setPhi(phi); + + lastPersEnd = (CLHEP::Hep3Vector)lastPersEnd + persDir; + persSumE += eneLoss; + lastT = t; + + ++idx; + } + + persCont->m_nBC.push_back(idx - endBC); + persCont->m_nId.push_back(idx - endId); + persCont->m_nHits.push_back(idx - endHit); +} + + +FaserSiHitCollection* FaserSiHitCollectionCnv_p1::createTransient(const FaserSiHitCollection_p1* persObj, MsgStream &log) { + std::unique_ptr<FaserSiHitCollection> trans(std::make_unique<FaserSiHitCollection>("DefaultCollectionName",persObj->m_nHits.size())); + persToTrans(persObj, trans.get(), log); + return(trans.release()); +} + + +void FaserSiHitCollectionCnv_p1::persToTrans(const FaserSiHitCollection_p1* persCont, FaserSiHitCollection* transCont, MsgStream &/*log*/) +{ + unsigned int hitCount = 0; + unsigned int angleCount = 0; + unsigned int idxBC = 0; + unsigned int idxId = 0; + unsigned int idxEne4b = 0; + unsigned int idxLen4b = 0; + unsigned int endHit = 0; + unsigned int endBC = 0; + unsigned int endId = 0; + + for (unsigned int i = 0; i < persCont->m_nHits.size(); i++) { + + if (persCont->m_nHits[i]) { + + const unsigned int start = endHit; + endHit += persCont->m_nHits[i]; + + const double t0 = persCont->m_hit1_meanTime[i]; + const double theta0 = persCont->m_hit1_theta[i]; + const double phi0 = persCont->m_hit1_phi[i]; + HepGeom::Point3D<double> endLast(persCont->m_hit1_x0[i], persCont->m_hit1_y0[i], persCont->m_hit1_z0[i]); + + for (unsigned int j = start; j < endHit; j++) { + + if (j >= endBC + persCont->m_nBC[idxBC]) + endBC += persCont->m_nBC[idxBC++]; + + if (j >= endId + persCont->m_nId[idxId]) + endId += persCont->m_nId[idxId++]; + + const double eneLoss_2b = persCont->m_hitEne_2b[hitCount]; + const double hitLength_2b = persCont->m_hitLength_2b[hitCount]; + + const double eneLoss = (eneLoss_2b < m_2bMaximum) ? eneLoss_2b * m_persEneUnit : persCont->m_hitEne_4b[idxEne4b++]; + const double length = (hitLength_2b < m_2bMaximum) ? hitLength_2b * m_persLenUnit : persCont->m_hitLength_4b[idxLen4b++]; + + const double dTheta = (j > start) ? ((double)persCont->m_dTheta[angleCount] - m_2bHalfMaximum) * m_persAngUnit : 0.0; + const double dPhi = (j > start) ? ((double)persCont->m_dPhi[angleCount] - m_2bHalfMaximum) * m_persAngUnit : 0.0; + + const double meanTime = t0; + const double theta = theta0 + dTheta; + const double phi = phicorr(phi0 + dPhi); + + CLHEP::Hep3Vector r(length, 0.0, 0.0); + r.setTheta(theta); + r.setPhi(phi); + + HepGeom::Point3D<double> endThis( endLast + r ); + + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), HepMcParticleLink::IS_INDEX ); + transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); + + endLast = endThis; + + ++hitCount; + if (j > start) ++angleCount; + } + } + } +} diff --git a/Tracker/TrackerSimEvent/CMakeLists.txt b/Tracker/TrackerSimEvent/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..50e54b552625898b5a04952b1f0cd1144aefddaf --- /dev/null +++ b/Tracker/TrackerSimEvent/CMakeLists.txt @@ -0,0 +1,39 @@ +################################################################################ +# Package: TrackerSimEvent +################################################################################ + +# Declare the package name: +atlas_subdir( TrackerSimEvent ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaKernel + Control/AthAllocators + Control/CxxUtils + Generators/GeneratorObjects + Simulation/HitManagement + PRIVATE + Control/StoreGate + Tracker/TrackerDetDescr/TrackerIdentifier ) + +# External dependencies: +find_package( CLHEP ) +find_package( Geant4 ) +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_library( TrackerSimEvent + src/*.cxx + PUBLIC_HEADERS TrackerSimEvent + INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} + PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} + DEFINITIONS ${CLHEP_DEFINITIONS} + LINK_LIBRARIES ${CLHEP_LIBRARIES} AthAllocators AthenaKernel CxxUtils GeneratorObjects HitManagement StoreGateLib SGtests + PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} TrackerIdentifier ) + +atlas_add_dictionary( TrackerSimEventDict + TrackerSimEvent/TrackerSimEventDict.h + TrackerSimEvent/selection.xml + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthAllocators CxxUtils GeneratorObjects HitManagement StoreGateLib SGtests TrackerIdentifier TrackerSimEvent ) + diff --git a/Tracker/TrackerSimEvent/TrackerSimEvent/FaserSiHit.h b/Tracker/TrackerSimEvent/TrackerSimEvent/FaserSiHit.h new file mode 100644 index 0000000000000000000000000000000000000000..8669b8809f5a98c6c0e579dd4703f72448bcf539 --- /dev/null +++ b/Tracker/TrackerSimEvent/TrackerSimEvent/FaserSiHit.h @@ -0,0 +1,189 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// FaserSiHit.h +// Header file for class FaserSiHit +/////////////////////////////////////////////////////////////////// +// Class for the Faser SCT hits +/////////////////////////////////////////////////////////////////// + +#ifndef TRACKERSIMEVENT_FASERSIHIT_H +#define TRACKERSIMEVENT_FASERSIHIT_H + +// Data members classes +#include "CLHEP/Geometry/Point3D.h" +#include "GeneratorObjects/HepMcParticleLink.h" + +class FaserSiHit { + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// +public: + + // Constructor with parameters: + // local start position of the energy deposit + // local end position of the energy deposit + // deposited energy + // time of energy deposition + // number of track which released this energy + // + FaserSiHit(const HepGeom::Point3D<double> &localStartPosition, + const HepGeom::Point3D<double> &localEndPosition, + const double energyLoss, + const double meanTime, + const int trackNumber, + const unsigned int id); + + FaserSiHit(const HepGeom::Point3D<double> &localStartPosition, + const HepGeom::Point3D<double> &localEndPosition, + const double energyLoss, + const double meanTime, + const int trackNumber, + const int, const int, const int, const int, const int); + // Constructor with parameters: + // local start position of the energy deposit + // local end position of the energy deposit + // deposited energy + // time of energy deposition + // link to particle which released this energy + // + FaserSiHit(const HepGeom::Point3D<double> &localStartPosition, + const HepGeom::Point3D<double> &localEndPosition, + const double energyLoss, + const double meanTime, + const HepMcParticleLink &track, + const unsigned int id); + + FaserSiHit(const HepGeom::Point3D<double> &localStartPosition, + const HepGeom::Point3D<double> &localEndPosition, + const double energyLoss, + const double meanTime, + const HepMcParticleLink &track, + const int, const int, const int, const int, const int); + // needed by athenaRoot + FaserSiHit(); + + // Destructor: + virtual ~FaserSiHit(); + + //move assignment defaulted + FaserSiHit & operator = (FaserSiHit &&) = default; + //assignment defaulted + FaserSiHit & operator = (const FaserSiHit &) = default; + //copy c'tor defaulted + FaserSiHit(const FaserSiHit &) = default; + + /////////////////////////////////////////////////////////////////// + // Const methods: + /////////////////////////////////////////////////////////////////// + + unsigned int identify() const; + + // local start position of the energy deposit: + HepGeom::Point3D<double> localStartPosition() const; + + HepGeom::Point3D<double> localEndPosition() const; + + // deposited energy: + double energyLoss() const; + + // time of energy deposition: FIXME name! + double meanTime() const; + + // Set the time of energy deposition: FIXME name! + void setMeanTime(float meanTime); + + // number of track which released this energy: + int trackNumber() const; + + // link to the particle generating the hit + const HepMcParticleLink& particleLink() const; + + // Station + int getStation() const; + + // Plane + int getPlane() const; + + // Row + int getRow() const; + + // Module + int getModule() const; + + // Sensor + int getSensor() const; + + // some print-out: + void print() const; + + bool operator < (const FaserSiHit& rhs) const + {return m_ID < rhs.m_ID;} + + /////////////////////////////////////////////////////////////////// + // Non-const methods: + /////////////////////////////////////////////////////////////////// + // Scale the length, used to go from cm to mm, of whatever we like. + void ScaleLength(double); + + /////////////////////////////////////////////////////////////////// + // Private data: + /////////////////////////////////////////////////////////////////// +private: + + float m_stX, m_stY, m_stZ; + float m_enX, m_enY, m_enZ; + float m_energyLoss; // deposited energy + float m_meanTime; // time of energy deposition + HepMcParticleLink m_partLink; + unsigned int m_ID; +public: + // enum + // { xDep = 2, xPhi = 0, xEta = 1}; +}; + + +/////////////////////////////////////////////////////////////////// +// Inline methods: +/////////////////////////////////////////////////////////////////// + +inline unsigned int FaserSiHit::identify() const +{ + return m_ID; +} + +inline double FaserSiHit::energyLoss() const +{ + return (double) m_energyLoss; +} + +inline double FaserSiHit::meanTime() const +{ + return (double) m_meanTime; +} + +inline void FaserSiHit::setMeanTime(float meanTime) +{ + m_meanTime=meanTime; +} + +inline const HepMcParticleLink& FaserSiHit::particleLink() const +{ + return m_partLink; +} + + + +/////////////////////////////////////////////////////////////////// +// open functions: +/////////////////////////////////////////////////////////////////// + +inline float hitTime(const FaserSiHit& hit) +{ + return (float) hit.meanTime(); +} + +#endif // TRACKERSIMEVENT_FASERSIHIT_H diff --git a/Tracker/TrackerSimEvent/TrackerSimEvent/FaserSiHitCollection.h b/Tracker/TrackerSimEvent/TrackerSimEvent/FaserSiHitCollection.h new file mode 100644 index 0000000000000000000000000000000000000000..bd3043b76023cc9faf95f333d86b12b5d274dfa6 --- /dev/null +++ b/Tracker/TrackerSimEvent/TrackerSimEvent/FaserSiHitCollection.h @@ -0,0 +1,20 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERSIMEVENT_FASERSIHITCOLLECTION_H +#define TRACKERSIMEVENT_FASERSIHITCOLLECTION_H + +#include "TrackerSimEvent/FaserSiHit.h" +#include "HitManagement/AtlasHitsVector.h" +#include "AthenaKernel/CLASS_DEF.h" + +typedef AtlasHitsVector<FaserSiHit> FaserSiHitCollection; +typedef AtlasHitsVector<FaserSiHit>::iterator FaserSiHitIterator; +typedef AtlasHitsVector<FaserSiHit>::const_iterator FaserSiHitConstIterator; + +#ifndef __CINT__ + CLASS_DEF(FaserSiHitCollection, 1272740890, 1 ) +#endif + +#endif // TRACKERSIMEVENT_FASERSIHITCOLLECTION_H diff --git a/Tracker/TrackerSimEvent/TrackerSimEvent/FaserSiHitIdHelper.h b/Tracker/TrackerSimEvent/TrackerSimEvent/FaserSiHitIdHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..f4f7ddf0be4de47caabd993e5a0519702b896bcf --- /dev/null +++ b/Tracker/TrackerSimEvent/TrackerSimEvent/FaserSiHitIdHelper.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERSIMEVENT_FASERSIHITIDHELPER +#define TRACKERSIMEVENT_FASERSIHITIDHELPER + +// +// This is a helper class to build an identifing integer used by +// the simulation. It inherits from HitIdHelper, in order to get +// all the packing and shifting for free. +// The class is a singleton and a static GetHelper() is provided +// the constructor calls the Initialize() method which sets all the +// field dimensions +// Methods are provided to get access to the ScintTracker Geometry +// description +// + + +// +// Base Class +#include "HitManagement/HitIdHelper.h" + +// This class is singleton and static method and variable are used. +#include "CxxUtils/checker_macros.h" +ATLAS_NO_CHECK_FILE_THREAD_SAFETY; + +class FaserSiHitIdHelper : HitIdHelper { + public: + // + // Access to the helper + static FaserSiHitIdHelper* GetHelper(); + // + // Info retrieval: + + // Station + int getStation(const int& hid) const; + + // Plane + int getPlane(const int& hid) const; + + // Row + int getRow(const int& hid) const; + + // Module + int getModule(const int& hid) const; + + // Sensor + int getSensor(const int& hid) const; + + // + // Info packing: + int buildHitId(const int, const int, const int, const int, const int) const; + + private: + // + // private constructor to have a singleton + FaserSiHitIdHelper(); + // + // Initialize the helper, only called by the constructor + void Initialize(); +}; + +#endif // TRACKERSIMEVENT_FASERSIHITIDHELPER diff --git a/Tracker/TrackerSimEvent/TrackerSimEvent/TrackerSimEventDict.h b/Tracker/TrackerSimEvent/TrackerSimEvent/TrackerSimEventDict.h new file mode 100644 index 0000000000000000000000000000000000000000..fe9005ae912fd5ba6e42d50df931f8de01113bf3 --- /dev/null +++ b/Tracker/TrackerSimEvent/TrackerSimEvent/TrackerSimEventDict.h @@ -0,0 +1,10 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKERSIMEVENT_TRACKERSIMEVENTDICT_H +#define TRACKERSIMEVENT_TRACKERSIMEVENTDICT_H + +#include "TrackerSimEvent/FaserSiHitCollection.h" + +#endif \ No newline at end of file diff --git a/Tracker/TrackerSimEvent/TrackerSimEvent/selection.xml b/Tracker/TrackerSimEvent/TrackerSimEvent/selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..5a42f6d0a2567271333947308db269e8c145fe5f --- /dev/null +++ b/Tracker/TrackerSimEvent/TrackerSimEvent/selection.xml @@ -0,0 +1,5 @@ +<lcgdict> + <class name="AtlasHitsVector<FaserSiHit>" /> + <class name="std::vector<FaserSiHit>" /> + <class name="FaserSiHit" /> +</lcgdict> diff --git a/Tracker/TrackerSimEvent/src/FaserSiHit.cxx b/Tracker/TrackerSimEvent/src/FaserSiHit.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c622b461245d5c074d510f29c4f7f4dd83fdb8fd --- /dev/null +++ b/Tracker/TrackerSimEvent/src/FaserSiHit.cxx @@ -0,0 +1,175 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrackerSimEvent/FaserSiHit.h" +#include "TrackerSimEvent/FaserSiHitIdHelper.h" + +// Default consdtructor needed by athenaroot +// +FaserSiHit::FaserSiHit( ) : + m_stX(0.), + m_stY(0.), + m_stZ(0.), + m_enX(0.), + m_enY(0.), + m_enZ(0.), + m_energyLoss(0.), + m_meanTime(0.), + m_partLink(), + m_ID(0xffff) +{ + +} + +FaserSiHit::~FaserSiHit() {} + + +// Constructor +FaserSiHit::FaserSiHit(const HepGeom::Point3D<double> &localStartPosition, + const HepGeom::Point3D<double> &localEndPosition, + const double energyLoss, + const double meanTime, + const int trackNumber, + const unsigned int id) : + m_stX( (float) localStartPosition.x() ), + m_stY( (float) localStartPosition.y() ), + m_stZ( (float) localStartPosition.z() ), + m_enX( (float) localEndPosition.x() ), + m_enY( (float) localEndPosition.y() ), + m_enZ( (float) localEndPosition.z() ), + m_energyLoss(energyLoss), + m_meanTime(meanTime), + m_partLink(trackNumber), + m_ID(id) +{ +} + +// Constructor +FaserSiHit::FaserSiHit(const HepGeom::Point3D<double> &localStartPosition, + const HepGeom::Point3D<double> &localEndPosition, + const double energyLoss, + const double meanTime, + const int trackNumber, + const int station, + const int plane, + const int row, + const int module, + const int sensor) : + m_stX( (float) localStartPosition.x() ), + m_stY( (float) localStartPosition.y() ), + m_stZ( (float) localStartPosition.z() ), + m_enX( (float) localEndPosition.x() ), + m_enY( (float) localEndPosition.y() ), + m_enZ( (float) localEndPosition.z() ), + m_energyLoss(energyLoss), + m_meanTime(meanTime), + m_partLink(trackNumber), + m_ID(0) +{ + // Compress the location info into the integer: + m_ID = FaserSiHitIdHelper::GetHelper()->buildHitId(station, + plane, + row, + module, + sensor); +} + +// Constructor +FaserSiHit::FaserSiHit(const HepGeom::Point3D<double> &localStartPosition, + const HepGeom::Point3D<double> &localEndPosition, + const double energyLoss, + const double meanTime, + const HepMcParticleLink &track, + const unsigned int id) : + m_stX( (float) localStartPosition.x() ), + m_stY( (float) localStartPosition.y() ), + m_stZ( (float) localStartPosition.z() ), + m_enX( (float) localEndPosition.x() ), + m_enY( (float) localEndPosition.y() ), + m_enZ( (float) localEndPosition.z() ), + m_energyLoss(energyLoss), + m_meanTime(meanTime), + m_partLink(track), + m_ID(id) +{ +} + +// Constructor +FaserSiHit::FaserSiHit(const HepGeom::Point3D<double> &localStartPosition, + const HepGeom::Point3D<double> &localEndPosition, + const double energyLoss, + const double meanTime, + const HepMcParticleLink &track, + const int station, + const int plane, + const int row, + const int module, + const int sensor) : + m_stX( (float) localStartPosition.x() ), + m_stY( (float) localStartPosition.y() ), + m_stZ( (float) localStartPosition.z() ), + m_enX( (float) localEndPosition.x() ), + m_enY( (float) localEndPosition.y() ), + m_enZ( (float) localEndPosition.z() ), + m_energyLoss(energyLoss), + m_meanTime(meanTime), + m_partLink(track), + m_ID(0) +{ + // Compress the location info into the integer: + m_ID = FaserSiHitIdHelper::GetHelper()->buildHitId(station, + plane, + row, + module, + sensor); +} + +void FaserSiHit::ScaleLength(double sfactor) { + m_stX *= (float) sfactor; + m_stY *= (float) sfactor; + m_stZ *= (float) sfactor; + m_enX *= (float) sfactor; + m_enY *= (float) sfactor; + m_enZ *= (float) sfactor; +} + +HepGeom::Point3D<double> FaserSiHit::localStartPosition() const +{ + return HepGeom::Point3D<double>((double) m_stX, (double) m_stY, (double) m_stZ); +} + +HepGeom::Point3D<double> FaserSiHit::localEndPosition() const +{ + return HepGeom::Point3D<double>((double) m_enX, (double) m_enY, (double) m_enZ); +} + +int FaserSiHit::getStation() const { + return FaserSiHitIdHelper::GetHelper()->getStation(m_ID); +} +int FaserSiHit::getPlane() const { + return FaserSiHitIdHelper::GetHelper()->getPlane(m_ID); +} +int FaserSiHit::getRow() const { + return FaserSiHitIdHelper::GetHelper()->getRow(m_ID); +} +int FaserSiHit::getModule() const { + return FaserSiHitIdHelper::GetHelper()->getModule(m_ID); +} +int FaserSiHit::getSensor() const { + return FaserSiHitIdHelper::GetHelper()->getSensor(m_ID); +} + +void FaserSiHit::print() const { + std::cout << "*** Veto Hit " << std::endl; + std::cout << " Station Number " << getStation() << std::endl; + std::cout << " Plane Number " << getPlane() << std::endl; + std::cout << " Row Number " << getRow() << std::endl; + std::cout << " Module Number " << getModule() << std::endl; + std::cout << " Sensor " << getSensor() << std::endl; +} + +int FaserSiHit::trackNumber() const +{ + return m_partLink.barcode(); +} diff --git a/Tracker/TrackerSimEvent/src/FaserSiHitIdHelper.cxx b/Tracker/TrackerSimEvent/src/FaserSiHitIdHelper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6d3882dcd603a3d032abea775e181187844978bb --- /dev/null +++ b/Tracker/TrackerSimEvent/src/FaserSiHitIdHelper.cxx @@ -0,0 +1,105 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include <mutex> + +#include "TrackerSimEvent/FaserSiHitIdHelper.h" +#include "StoreGate/StoreGateSvc.h" +#include "StoreGate/StoreGate.h" +#include "TrackerIdentifier/FaserSCT_ID.h" + +#include "G4Types.hh" +#ifdef G4MULTITHREADED +# include "GaudiKernel/ContextSpecificPtr.h" +#endif + +static std::mutex sgMutex; + +// This class is singleton and static method and variable are used. +ATLAS_NO_CHECK_FILE_THREAD_SAFETY; + +// +// private constructor +FaserSiHitIdHelper::FaserSiHitIdHelper() :HitIdHelper() { + Initialize(); +} + +FaserSiHitIdHelper* FaserSiHitIdHelper::GetHelper() { +#ifdef G4MULTITHREADED + // Context-specific singleton + static Gaudi::Hive::ContextSpecificPtr<FaserSiHitIdHelper> helperPtr; + if(!helperPtr) helperPtr = new FaserSiHitIdHelper(); + return helperPtr.get(); +#else + static FaserSiHitIdHelper helper; + return &helper; +#endif +} + +void FaserSiHitIdHelper::Initialize() { + + // in which case eta module field is expanded. + // Need to lock this thread-unsafe retrieval + const FaserSCT_ID* pix; + StoreGateSvc* detStore(nullptr); + { + std::lock_guard<std::mutex> lock(sgMutex); + detStore = StoreGate::pointer("DetectorStore"); + if (detStore->retrieve(pix, "FaserSCT_ID").isFailure()) { pix = 0; } + } + + InitializeField("Station", -1, 1); + InitializeField("Plane", 0, 3); + InitializeField("Row", 0, 4); + InitializeField("Module", -1, 1); + InitializeField("Sensor", 0, 1); +} + +// Info retrieval: +// Station +int FaserSiHitIdHelper::getStation(const int& hid) const +{ + return this->GetFieldValue("Station", hid); +} + +// Plane +int FaserSiHitIdHelper::getPlane(const int& hid) const +{ + return this->GetFieldValue("Plane", hid); +} + +// Row +int FaserSiHitIdHelper::getRow(const int& hid) const +{ + return this->GetFieldValue("Row", hid); +} + +// Module +int FaserSiHitIdHelper::getModule(const int& hid) const +{ + return this->GetFieldValue("Module", hid); +} + +// Sensor +int FaserSiHitIdHelper::getSensor(const int& hid) const +{ + return this->GetFieldValue("Sensor", hid); +} + +// +// Info packing: +int FaserSiHitIdHelper::buildHitId(const int station, + const int plane, + const int row, + const int module, + const int sensor) const +{ + int theID(0); + this->SetFieldValue("Station", station, theID); + this->SetFieldValue("Plane", plane, theID); + this->SetFieldValue("Row", row, theID); + this->SetFieldValue("Module", module, theID); + this->SetFieldValue("Sensor", sensor, theID); + return theID; +}