diff --git a/DetectorDescription/GeoModel/GeoModelTest/CMakeLists.txt b/Control/CalypsoExample/GeoModelTest/CMakeLists.txt similarity index 100% rename from DetectorDescription/GeoModel/GeoModelTest/CMakeLists.txt rename to Control/CalypsoExample/GeoModelTest/CMakeLists.txt diff --git a/DetectorDescription/GeoModel/GeoModelTest/python/GeoModelTestConfig.py b/Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py similarity index 100% rename from DetectorDescription/GeoModel/GeoModelTest/python/GeoModelTestConfig.py rename to Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py diff --git a/DetectorDescription/GeoModel/GeoModelTest/python/__init__.py b/Control/CalypsoExample/GeoModelTest/python/__init__.py similarity index 100% rename from DetectorDescription/GeoModel/GeoModelTest/python/__init__.py rename to Control/CalypsoExample/GeoModelTest/python/__init__.py diff --git a/DetectorDescription/GeoModel/GeoModelTest/share/geoDebug.py b/Control/CalypsoExample/GeoModelTest/share/geoDebug.py similarity index 100% rename from DetectorDescription/GeoModel/GeoModelTest/share/geoDebug.py rename to Control/CalypsoExample/GeoModelTest/share/geoDebug.py diff --git a/DetectorDescription/GeoModel/GeoModelTest/src/GeoModelTestAlg.cxx b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx similarity index 100% rename from DetectorDescription/GeoModel/GeoModelTest/src/GeoModelTestAlg.cxx rename to Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx diff --git a/DetectorDescription/GeoModel/GeoModelTest/src/GeoModelTestAlg.h b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h similarity index 100% rename from DetectorDescription/GeoModel/GeoModelTest/src/GeoModelTestAlg.h rename to Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h diff --git a/DetectorDescription/GeoModel/GeoModelTest/src/components/GeoModelTest_entries.cxx b/Control/CalypsoExample/GeoModelTest/src/components/GeoModelTest_entries.cxx similarity index 100% rename from DetectorDescription/GeoModel/GeoModelTest/src/components/GeoModelTest_entries.cxx rename to Control/CalypsoExample/GeoModelTest/src/components/GeoModelTest_entries.cxx diff --git a/Control/CalypsoExample/SimHitExample/CMakeLists.txt b/Control/CalypsoExample/SimHitExample/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..44195b2b5edde8e403ff14ba96dff267b12e4cb5 --- /dev/null +++ b/Control/CalypsoExample/SimHitExample/CMakeLists.txt @@ -0,0 +1,15 @@ +atlas_subdir( SimHitExample ) + +atlas_depends_on_subdirs( PRIVATE + Generators/GeneratorObjects + Control/AthenaBaseComps + Tracker/TrackerSimEvent + ) + +atlas_add_component( SimHitExample + src/SimHitAlg.cxx + src/components/SimHitExample_entries.cxx + LINK_LIBRARIES AthenaBaseComps GeneratorObjects TrackerSimEvent + ) + +atlas_install_joboptions( share/*.py ) \ No newline at end of file diff --git a/Control/CalypsoExample/SimHitExample/share/SimHitExample_jobOptions.py b/Control/CalypsoExample/SimHitExample/share/SimHitExample_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..6b173f04181f98c411d11efc28905920d5409f44 --- /dev/null +++ b/Control/CalypsoExample/SimHitExample/share/SimHitExample_jobOptions.py @@ -0,0 +1,16 @@ +from AthenaCommon.GlobalFlags import globalflags + +globalflags.InputFormat.set_Value_and_Lock('pool') + +import AthenaPoolCnvSvc.ReadAthenaPool + +svcMgr.EventSelector.InputCollections = ["g4.HITS.root"] + +alg = CfgMgr.SimHitAlg() +athAlgSeq += alg + +theApp.EvtMax=-1 +alg.McEventCollection = "TruthEvent" + +svcMgr += CfgMgr.THistSvc() +svcMgr.THistSvc.Output += ["HIST DATAFILE='myHistoFile.root' OPT='RECREATE'"] \ No newline at end of file diff --git a/Control/CalypsoExample/SimHitExample/src/SimHitAlg.cxx b/Control/CalypsoExample/SimHitExample/src/SimHitAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6e937ba7221863c0257b402b5cc73912b2d623ac --- /dev/null +++ b/Control/CalypsoExample/SimHitExample/src/SimHitAlg.cxx @@ -0,0 +1,58 @@ +#include "SimHitAlg.h" + +SimHitAlg::SimHitAlg(const std::string& name, ISvcLocator* pSvcLocator) +: AthHistogramAlgorithm(name, pSvcLocator) { m_hist = nullptr; } + +SimHitAlg::~SimHitAlg() { } + +StatusCode SimHitAlg::initialize() +{ + // initialize a histogram + // letter at end of TH1 indicated variable type (D double, F float etc) + m_hist = new TH1D("eLoss", "SCT Hit Energy Loss", 100, 0, 1); //first string is root object name, second is histogram title + ATH_CHECK(histSvc()->regHist("/HIST/myhist", m_hist)); + + // initialize data handle keys + ATH_CHECK( m_mcEventKey.initialize() ); + ATH_CHECK( m_faserSiHitKey.initialize() ); + ATH_MSG_INFO( "Using GenEvent collection with key " << m_mcEventKey.key()); + ATH_MSG_INFO( "Using Faser SiHit collection with key " << m_faserSiHitKey.key()); + return StatusCode::SUCCESS; +} + +StatusCode SimHitAlg::execute() +{ + // Handles created from handle keys behave like pointers to the corresponding container + SG::ReadHandle<McEventCollection> h_mcEvents(m_mcEventKey); + 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); + ATH_MSG_INFO("Read FaserSiHitCollection with " << h_siHits->size() << " hits"); + + // Since we have no pile-up, there should always be a single GenEvent in the container + const HepMC::GenEvent* ev = (*h_mcEvents)[0]; + if (ev == nullptr) + { + ATH_MSG_FATAL("GenEvent pointer is null"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("Event contains " << ev->particles_size() << " truth particles" ); + + // The hit container might be empty because particles missed the wafers + if (h_siHits->size() == 0) return StatusCode::SUCCESS; + + // Loop over all hits; print and fill histogram + for (const FaserSiHit& hit : *h_siHits) + { + hit.print(); + m_hist->Fill( hit.energyLoss() ); + } + + return StatusCode::SUCCESS; +} + +StatusCode SimHitAlg::finalize() +{ + return StatusCode::SUCCESS; +} \ No newline at end of file diff --git a/Control/CalypsoExample/SimHitExample/src/SimHitAlg.h b/Control/CalypsoExample/SimHitExample/src/SimHitAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..cfc1d0d38162f8e864323d5c7259f765b22b2dbf --- /dev/null +++ b/Control/CalypsoExample/SimHitExample/src/SimHitAlg.h @@ -0,0 +1,27 @@ +#include "AthenaBaseComps/AthHistogramAlgorithm.h" +#include "GeneratorObjects/McEventCollection.h" +#include "TrackerSimEvent/FaserSiHitCollection.h" +#include <TH1.h> + +/* SimHit reading example - Ryan Rice-Smith, UC Irvine */ + +class SimHitAlg : public AthHistogramAlgorithm +{ + public: + SimHitAlg(const std::string& name, ISvcLocator* pSvcLocator); + + virtual ~SimHitAlg(); + + StatusCode initialize(); + StatusCode execute(); + StatusCode finalize(); + + private: + TH1* m_hist; // Example histogram + + // Read handle keys for data containers + // Any other event data can be accessed identically + // Note the key names ("GEN_EVENT" or "SCT_Hits") are Gaudi properties and can be configured at run-time + SG::ReadHandleKey<McEventCollection> m_mcEventKey { this, "McEventCollection", "GEN_EVENT" }; + SG::ReadHandleKey<FaserSiHitCollection> m_faserSiHitKey { this, "FaserSiHitCollection", "SCT_Hits" }; +}; \ No newline at end of file diff --git a/Control/CalypsoExample/SimHitExample/src/components/SimHitExample_entries.cxx b/Control/CalypsoExample/SimHitExample/src/components/SimHitExample_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..caba1d271a3b63d25e11c153cc741d8d4e106d18 --- /dev/null +++ b/Control/CalypsoExample/SimHitExample/src/components/SimHitExample_entries.cxx @@ -0,0 +1,3 @@ +#include "../SimHitAlg.h" + +DECLARE_COMPONENT( SimHitAlg ) \ No newline at end of file diff --git a/Tracker/TrackerSimEvent/src/FaserSiHit.cxx b/Tracker/TrackerSimEvent/src/FaserSiHit.cxx index c622b461245d5c074d510f29c4f7f4dd83fdb8fd..80b632ff9d3b39838d48f60c998642dafa56510e 100644 --- a/Tracker/TrackerSimEvent/src/FaserSiHit.cxx +++ b/Tracker/TrackerSimEvent/src/FaserSiHit.cxx @@ -161,7 +161,7 @@ int FaserSiHit::getSensor() const { } void FaserSiHit::print() const { - std::cout << "*** Veto Hit " << std::endl; + std::cout << "*** Faser Si Hit " << std::endl; std::cout << " Station Number " << getStation() << std::endl; std::cout << " Plane Number " << getPlane() << std::endl; std::cout << " Row Number " << getRow() << std::endl;