diff --git a/DDAlign/include/DDAlign/AlignmentTags.h b/DDAlign/include/DDAlign/AlignmentTags.h index 7287c19e9525c96b7b8676fb6e92a3998a97c516..ca6fccc6c5a919b860c03d262f995847ac457b5e 100644 --- a/DDAlign/include/DDAlign/AlignmentTags.h +++ b/DDAlign/include/DDAlign/AlignmentTags.h @@ -26,7 +26,6 @@ namespace DD4hep { namespace DDAlign { // Alignment tags - UNICODE(DetectorAlignment); UNICODE(subdetectors); UNICODE(subdetector); diff --git a/DDAlign/src/AlignmentTags.cpp b/DDAlign/src/AlignmentTags.cpp index 0f209765dc28beee45381de76ab07f1be5e27fb7..23ade0de292280e040a7bf0e04844aaeee2d595f 100644 --- a/DDAlign/src/AlignmentTags.cpp +++ b/DDAlign/src/AlignmentTags.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -17,6 +16,6 @@ // Define unicode tags #ifndef UNICODE -#define UNICODE(x) DECLARE_UNICODE_TAG(x) +#define UNICODE(x) extern const ::DD4hep::XML::Tag_t Unicode_##x #endif #include "DDAlign/AlignmentTags.h" diff --git a/DDCond/src/ConditionsTags.cpp b/DDCond/src/ConditionsTags.cpp index 50c5ab75cc62c6f223fecca4ccc51a2803154fbb..0056eff3dabe034ef4723bd0b8d07083a0028d4e 100644 --- a/DDCond/src/ConditionsTags.cpp +++ b/DDCond/src/ConditionsTags.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -17,6 +16,6 @@ // Define unicode tags #ifndef UNICODE -#define UNICODE(x) DECLARE_UNICODE_TAG(x) +#define UNICODE(x) extern const ::DD4hep::XML::Tag_t Unicode_##x #endif #include "DDCond/ConditionsTags.h" diff --git a/DDCore/include/XML/XMLTags.h b/DDCore/include/XML/XMLTags.h index c73cac3c43835bd891b25e7738f7f6460a8a53b9..6e563219b2e40176a5d428bb1e9479e8d834a8f0 100644 --- a/DDCore/include/XML/XMLTags.h +++ b/DDCore/include/XML/XMLTags.h @@ -14,7 +14,7 @@ #ifndef DD4HEP_XML_TAGS_H #define DD4HEP_XML_TAGS_H -#define DECLARE_UNICODE_TAG(x) extern const ::DD4hep::XML::Tag_t Unicode_##x (#x) +#define DECLARE_UNICODE_TAG(x) namespace DD4hep { namespace XML { extern const Tag_t Unicode_##x (#x); }} // Framework include files #include "XML/XMLElements.h" diff --git a/DDDB/src/DDDBTags.cpp b/DDDB/src/DDDBTags.cpp index e31661b1b8400734c086241442e52b81da781e8d..0519b7463356760a01bf39ff206fc6ae26898063 100644 --- a/DDDB/src/DDDBTags.cpp +++ b/DDDB/src/DDDBTags.cpp @@ -22,6 +22,6 @@ // Define unicode tags #ifndef UNICODE -#define UNICODE(x) DECLARE_UNICODE_TAG(x) +#define UNICODE(x) extern const ::DD4hep::XML::Tag_t Unicode_##x #endif #include "DDDB/DDDBTags.h" diff --git a/DDG4/include/DDG4/Geant4DataDump.h b/DDG4/include/DDG4/Geant4DataDump.h index 5b8dff9101e166d783fb672c3c494c7a3d4ab6dd..352df0e5b70984aa16a02ae2a556bfb6edfb6991 100644 --- a/DDG4/include/DDG4/Geant4DataDump.h +++ b/DDG4/include/DDG4/Geant4DataDump.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -59,18 +58,21 @@ namespace DD4hep { /// Print a single particle to the output logging using the specified print level void print(PrintLevel level, Geant4ParticleHandle p) const; #endif + /// Print the particle map to the output logging using the specified print level + void print(PrintLevel level, const Geant4ParticleMap* parts) const; + /// Print the particle container to the output logging using the specified print level - void print(PrintLevel level, const std::string& container, const Particles* parts); + void print(PrintLevel level, const std::string& container, const Particles* parts) const; /// Print a single tracker hit to the output logging using the specified print level - void print(PrintLevel level, const TrackerHit* h); + void print(PrintLevel level, const TrackerHit* h) const; /// Print the tracker hits container to the output logging using the specified print level - void print(PrintLevel level, const std::string& container, const TrackerHits* hits); + void print(PrintLevel level, const std::string& container, const TrackerHits* hits) const; /// Print a calorimeter tracker hit to the output logging using the specified print level - void print(PrintLevel level, const CalorimeterHit* h); + void print(PrintLevel level, const CalorimeterHit* h) const; /// Print the calorimeter hits container to the output logging using the specified print level - void print(PrintLevel level, const std::string& container, const CalorimeterHits* hits); + void print(PrintLevel level, const std::string& container, const CalorimeterHits* hits) const; }; } // End namespace Simulation diff --git a/DDG4/include/DDG4/Geant4EventAction.h b/DDG4/include/DDG4/Geant4EventAction.h index e8d3a78e088e07a455ebb7d539dd607ffe963b5e..ba1aec3aeff5aaa56cfe1491e95ddab89cb0c5a0 100644 --- a/DDG4/include/DDG4/Geant4EventAction.h +++ b/DDG4/include/DDG4/Geant4EventAction.h @@ -56,6 +56,8 @@ namespace DD4hep { protected: /// Inhibit copy constructor Geant4EventAction() = default; + /// Inhibit move constructor + Geant4EventAction(Geant4EventAction&& copy) = delete; /// Inhibit copy constructor Geant4EventAction(const Geant4EventAction& copy) = delete; /// Inhibit assignment operator diff --git a/DDG4/include/DDG4/Geant4InteractionMerger.h b/DDG4/include/DDG4/Geant4InteractionMerger.h index 17866e2fb40af15ea3cbd1d87038faae17fd22f5..260b37963a330e930b93f5f12e3355a226de03ea 100644 --- a/DDG4/include/DDG4/Geant4InteractionMerger.h +++ b/DDG4/include/DDG4/Geant4InteractionMerger.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/include/DDG4/Geant4InteractionVertexBoost.h b/DDG4/include/DDG4/Geant4InteractionVertexBoost.h index 06da5648bfbc31d1924cc46dc333767ba1df0202..05265a2f4d06a94ab8b723fce204e6d37d94c633 100644 --- a/DDG4/include/DDG4/Geant4InteractionVertexBoost.h +++ b/DDG4/include/DDG4/Geant4InteractionVertexBoost.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/include/DDG4/Geant4InteractionVertexSmear.h b/DDG4/include/DDG4/Geant4InteractionVertexSmear.h index da4cf55069bffbc0eb61677296f13b5a6c425ed9..75a3a21a9419a8346402c61f8ebc6a0abbe0a050 100644 --- a/DDG4/include/DDG4/Geant4InteractionVertexSmear.h +++ b/DDG4/include/DDG4/Geant4InteractionVertexSmear.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/include/DDG4/Geant4IsotropeGenerator.h b/DDG4/include/DDG4/Geant4IsotropeGenerator.h index 37e4b18ab708889fabcdbf57354c4bab9e0eb3ee..9ab7dd6527c88bd9023d3b3fe3b5c041afe5637d 100644 --- a/DDG4/include/DDG4/Geant4IsotropeGenerator.h +++ b/DDG4/include/DDG4/Geant4IsotropeGenerator.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/include/DDG4/Geant4Mapping.h b/DDG4/include/DDG4/Geant4Mapping.h index 10355984b6448f656dd9168a097084630571f97b..ad7049d14145091f7b6ebcb691565386c1ac04c2 100644 --- a/DDG4/include/DDG4/Geant4Mapping.h +++ b/DDG4/include/DDG4/Geant4Mapping.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/include/DDG4/Geant4OutputAction.h b/DDG4/include/DDG4/Geant4OutputAction.h index 3f309c99b94cc28508004ca507c20137fcd9b4b2..3e664dfcab99429c6131037a5577404ad4db993e 100644 --- a/DDG4/include/DDG4/Geant4OutputAction.h +++ b/DDG4/include/DDG4/Geant4OutputAction.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/lcio/Geant4Output2LCIO.cpp b/DDG4/lcio/Geant4Output2LCIO.cpp index a059081f702ffb6a5f83a062c5f6cd9029413203..0e4f955754f7727f94430ee60c1711ba68d17ef0 100644 --- a/DDG4/lcio/Geant4Output2LCIO.cpp +++ b/DDG4/lcio/Geant4Output2LCIO.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4.10.PhysicsConstructors.h b/DDG4/plugins/Geant4.10.PhysicsConstructors.h index 4a4acc5a20c4e705e8323420de256eed806609b3..49422095dd5cfaa55acc0ab79a8a64d3c34abf87 100644 --- a/DDG4/plugins/Geant4.10.PhysicsConstructors.h +++ b/DDG4/plugins/Geant4.10.PhysicsConstructors.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4.9.PhysicsConstructors.h b/DDG4/plugins/Geant4.9.PhysicsConstructors.h index 79f1d78aba258c8f4a43b77495b31450461b6373..9b29920ef1e8175aacf6e314c0dc8e387cf7f7e6 100644 --- a/DDG4/plugins/Geant4.9.PhysicsConstructors.h +++ b/DDG4/plugins/Geant4.9.PhysicsConstructors.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4DefaultRangeCut.cpp b/DDG4/plugins/Geant4DefaultRangeCut.cpp index 4027ad2cb49fa8487cb2faf1c63712fa4a799b04..da9dc7417f14c4abf9c4d9ea8293ba33ace0d1d0 100644 --- a/DDG4/plugins/Geant4DefaultRangeCut.cpp +++ b/DDG4/plugins/Geant4DefaultRangeCut.cpp @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4DetectorSensitivesConstruction.cpp b/DDG4/plugins/Geant4DetectorSensitivesConstruction.cpp index b4bf026b615e2ce3954cf2678ab8eb3b40d1b9c4..df4d61f16cb66994e861dff65027986abbeaf1da 100644 --- a/DDG4/plugins/Geant4DetectorSensitivesConstruction.cpp +++ b/DDG4/plugins/Geant4DetectorSensitivesConstruction.cpp @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,7 +11,6 @@ // \date 2015-11-09 // //========================================================================== -// $Id$ // Framework include files #include "DDG4/Geant4DetectorConstruction.h" diff --git a/DDG4/plugins/Geant4EscapeCounter.cpp b/DDG4/plugins/Geant4EscapeCounter.cpp index 9090cfe469135ecda3d7799b70be3aa091c6e652..60d17ff59ad3476604b9c409da065adf841c8a6a 100644 --- a/DDG4/plugins/Geant4EscapeCounter.cpp +++ b/DDG4/plugins/Geant4EscapeCounter.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -36,6 +35,7 @@ namespace DD4hep { class Geant4EscapeCounter : /* virtual public Geant4SteppingAction, virtual */ public Geant4Sensitive { /// Collection identifiers size_t m_collectionID; + /// Detector name set std::vector<std::string> m_detectorNames; public: /// Standard constructor @@ -43,7 +43,7 @@ namespace DD4hep { /// Default destructor virtual ~Geant4EscapeCounter(); /// G4VSensitiveDetector interface: Method for generating hit(s) using the information of G4Step object. - virtual bool process(G4Step* step, G4TouchableHistory* history); + virtual bool process(G4Step* step, G4TouchableHistory* history) override; }; } // End namespace Simulation @@ -51,12 +51,16 @@ namespace DD4hep { #endif /* DD4HEP_DDG4_GEANT4ESCAPECOUNTER_H */ -// $Id: Geant4Converter.cpp 603 2013-06-13 21:15:14Z markus.frank $ //==================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // -// Author : M.Frank +// Author : M.Frank // //==================================================================== #include "DD4hep/Printout.h" diff --git a/DDG4/plugins/Geant4EventReaderGuineaPig.cpp b/DDG4/plugins/Geant4EventReaderGuineaPig.cpp index dce3c087ca404ad16785fd5af048e2b483787f5e..afb735d5ff492600d508edd29fa8da9fd8dc8eb2 100644 --- a/DDG4/plugins/Geant4EventReaderGuineaPig.cpp +++ b/DDG4/plugins/Geant4EventReaderGuineaPig.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4EventReaderHepEvt.cpp b/DDG4/plugins/Geant4EventReaderHepEvt.cpp index 07438183de15f7afdc207820525c564713e14977..6cfea5313aed5fb615b00568a146f4762a5a48a6 100644 --- a/DDG4/plugins/Geant4EventReaderHepEvt.cpp +++ b/DDG4/plugins/Geant4EventReaderHepEvt.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -55,10 +54,16 @@ namespace DD4hep { } /* End namespace Simulation */ } /* End namespace DD4hep */ -// $Id: Geant4Converter.cpp 603 2013-06-13 21:15:14Z markus.frank $ //==================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank // //==================================================================== // #include "DDG4/Geant4EventReaderHepEvt" diff --git a/DDG4/plugins/Geant4EventSeed.cpp b/DDG4/plugins/Geant4EventSeed.cpp index f94b8e7eec542a74a210a58bdd715c9308148b7c..87ade680d0ae73461d3ec4c44a1d0692ace610b7 100644 --- a/DDG4/plugins/Geant4EventSeed.cpp +++ b/DDG4/plugins/Geant4EventSeed.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4ExtraParticles.cpp b/DDG4/plugins/Geant4ExtraParticles.cpp index 3387fe5af0376ba676737f324a8d88dca0d1e421..aaab732c9f27c4010c8d67c6e9c80b9a959fde24 100644 --- a/DDG4/plugins/Geant4ExtraParticles.cpp +++ b/DDG4/plugins/Geant4ExtraParticles.cpp @@ -1,10 +1,8 @@ // // Authors: Tomohiko Tanabe <tomohiko@icepp.s.u-tokyo.ac.jp> // Taikan Suehara <suehara@icepp.s.u-tokyo.ac.jp> -// Proted from Mokka by A.Sailer (CERN ) +// Ported from Mokka by A.Sailer (CERN ) // -// $Id$ -// $Name: $ /** \addtogroup Geant4PhysicsConstructor * diff --git a/DDG4/plugins/Geant4Factories.cpp b/DDG4/plugins/Geant4Factories.cpp index bec66e5d6a3a7709891cd04f674e0d53c5fe2404..77e48b74221d36675e0b2a9fabec9315078c5dcf 100644 --- a/DDG4/plugins/Geant4Factories.cpp +++ b/DDG4/plugins/Geant4Factories.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4FieldTrackingSetup.cpp b/DDG4/plugins/Geant4FieldTrackingSetup.cpp index 93f0d525702379140df4f2d0a8d5c76780601844..b80c0de67e33169246d677366069c52abab03dd1 100644 --- a/DDG4/plugins/Geant4FieldTrackingSetup.cpp +++ b/DDG4/plugins/Geant4FieldTrackingSetup.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4HitDumpAction.cpp b/DDG4/plugins/Geant4HitDumpAction.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ba631f582e6ca83972368298eae090f15160a7c3 --- /dev/null +++ b/DDG4/plugins/Geant4HitDumpAction.cpp @@ -0,0 +1,152 @@ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== +#ifndef DD4HEP_DDG4_GEANT4HITDUMPACTION_H +#define DD4HEP_DDG4_GEANT4HITDUMPACTION_H + +// Framework include files +#include "DDG4/Geant4EventAction.h" + +// Forward declarations +class G4VHitsCollection; + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + + /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit + namespace Simulation { + + // Forward declarations + class Geant4ParticleMap; + + /// Class to measure the energy of escaping tracks + /** Class to measure the energy of escaping tracks of a detector using Geant 4 + * Measure escaping energy.... + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_SIMULATION + */ + class Geant4HitDumpAction : public Geant4EventAction { + public: + typedef std::vector<std::string> CollectionNames; + /// Property: collection names to be dumped + CollectionNames m_containers; + + /// Dump single container of hits + void dumpCollection(G4VHitsCollection* hc); + + public: + /// Standard constructor + Geant4HitDumpAction(Geant4Context* context, const std::string& nam); + /// Default destructor + virtual ~Geant4HitDumpAction(); + /// Geant4EventAction interface: Begin-of-event callback + virtual void begin(const G4Event* event) override; + /// Geant4EventAction interface: End-of-event callback + virtual void end(const G4Event* event) override; + }; + + } // End namespace Simulation +} // End namespace DD4hep + +#endif /* DD4HEP_DDG4_GEANT4HITDUMPACTION_H */ + +//==================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//==================================================================== + +// Framework include files +#include "DD4hep/InstanceCount.h" +#include "DDG4/Geant4DataDump.h" +#include "DDG4/Geant4HitCollection.h" + +// Geant 4 includes +#include "G4HCofThisEvent.hh" +#include "G4Event.hh" + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Simulation; + +/// Standard constructor +Geant4HitDumpAction::Geant4HitDumpAction(Geant4Context* ctxt, const string& nam) + : Geant4EventAction(ctxt, nam), m_containers{"*"} +{ + m_needsControl = true; + declareProperty("Collections",m_containers); + InstanceCount::increment(this); +} + +/// Default destructor +Geant4HitDumpAction::~Geant4HitDumpAction() { + InstanceCount::decrement(this); +} + +/// Geant4EventAction interface: Begin-of-event callback +void Geant4HitDumpAction::begin(const G4Event* /* event */) { +} + +/// Dump single container of hits +void Geant4HitDumpAction::dumpCollection(G4VHitsCollection* collection) { + Geant4HitCollection* coll = dynamic_cast<Geant4HitCollection*>(collection); + string nam = collection->GetName(); + if ( coll ) { + Geant4DataDump::CalorimeterHits cal_hits; + Geant4DataDump::TrackerHits trk_hits; + Geant4DataDump dump(name()); + size_t nhits = coll->GetSize(); + for(size_t i=0; i<nhits; ++i) { + Geant4HitData* h = coll->hit(i); + Geant4Tracker::Hit* trk_hit = dynamic_cast<Geant4Tracker::Hit*>(h); + if ( 0 != trk_hit ) { + trk_hits.push_back(trk_hit); + } + Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h); + if ( 0 != cal_hit ) { + cal_hits.push_back(cal_hit); + } + } + if ( !trk_hits.empty() ) + dump.print(ALWAYS,nam,&trk_hits); + if ( !cal_hits.empty() ) + dump.print(ALWAYS,nam,&cal_hits); + } +} + +/// Geant4EventAction interface: End-of-event callback +void Geant4HitDumpAction::end(const G4Event* event) { + G4HCofThisEvent* hce = event->GetHCofThisEvent(); + if ( hce ) { + int nCol = hce->GetNumberOfCollections(); + bool all = !m_containers.empty() && m_containers[0] == "*"; + for (int i = 0; i < nCol; ++i) { + G4VHitsCollection* hc = hce->GetHC(i); + if ( all || find(m_containers.begin(),m_containers.end(),hc->GetName()) != m_containers.end() ) + dumpCollection(hc); + } + return; + } + warning("+++ [Event:%d] The value of G4HCofThisEvent is NULL.",event->GetEventID()); +} + +#include "DDG4/Factories.h" +DECLARE_GEANT4ACTION(Geant4HitDumpAction) diff --git a/DDG4/plugins/Geant4HitExtractor.cpp b/DDG4/plugins/Geant4HitExtractor.cpp index 8c897a660e9d26c7bcf1bbead1972750cf8153c7..7379fb0f899f211ae86b0b1c5bb95debda4b37f0 100644 --- a/DDG4/plugins/Geant4HitExtractor.cpp +++ b/DDG4/plugins/Geant4HitExtractor.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4HitTruthHandler.cpp b/DDG4/plugins/Geant4HitTruthHandler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1cdf5efd9b1939d67c6915991c93e8b891be3d7c --- /dev/null +++ b/DDG4/plugins/Geant4HitTruthHandler.cpp @@ -0,0 +1,157 @@ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== +#ifndef DD4HEP_DDG4_GEANT4HITTRUTHHANDLER_H +#define DD4HEP_DDG4_GEANT4HITTRUTHHANDLER_H + +// Framework include files +#include "DDG4/Geant4EventAction.h" + +// Forward declarations +class G4VHitsCollection; + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + + /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit + namespace Simulation { + + // Forward declarations + class Geant4ParticleMap; + + /// Class to measure the energy of escaping tracks + /** Class to measure the energy of escaping tracks of a detector using Geant 4 + * Measure escaping energy.... + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_SIMULATION + */ + class Geant4HitTruthHandler : public Geant4EventAction { + public: + typedef std::vector<std::string> CollectionNames; + /// Dump single container of hits + void handleCollection(Geant4ParticleMap* truth, G4VHitsCollection* hc); + + public: + /// Standard constructor + Geant4HitTruthHandler(Geant4Context* context, const std::string& nam); + /// Default destructor + virtual ~Geant4HitTruthHandler(); + /// Geant4EventAction interface: Begin-of-event callback + virtual void begin(const G4Event* event) override; + /// Geant4EventAction interface: End-of-event callback + virtual void end(const G4Event* event) override; + }; + + } // End namespace Simulation +} // End namespace DD4hep + +#endif /* DD4HEP_DDG4_GEANT4HITTRUTHHANDLER_H */ + +//==================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//==================================================================== + +// Framework include files +#include "DD4hep/InstanceCount.h" +#include "DDG4/Geant4DataDump.h" +#include "DDG4/Geant4HitCollection.h" + +// Geant 4 includes +#include "G4HCofThisEvent.hh" +#include "G4Event.hh" + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Simulation; + +/// Standard constructor +Geant4HitTruthHandler::Geant4HitTruthHandler(Geant4Context* ctxt, const string& nam) + : Geant4EventAction(ctxt, nam) +{ + m_needsControl = true; + InstanceCount::increment(this); +} + +/// Default destructor +Geant4HitTruthHandler::~Geant4HitTruthHandler() { + InstanceCount::decrement(this); +} + +/// Geant4EventAction interface: Begin-of-event callback +void Geant4HitTruthHandler::begin(const G4Event* /* event */) { +} + +/// Dump single container of hits +void Geant4HitTruthHandler::handleCollection(Geant4ParticleMap* truth, G4VHitsCollection* collection) { + Geant4HitCollection* coll = dynamic_cast<Geant4HitCollection*>(collection); + if ( coll ) { + size_t nhits = coll->GetSize(); + for(size_t i=0; i<nhits; ++i) { + Geant4HitData* h = coll->hit(i); + Geant4Tracker::Hit* trk_hit = dynamic_cast<Geant4Tracker::Hit*>(h); + if ( 0 != trk_hit ) { + if ( truth ) { + Geant4HitData::Contribution& t = trk_hit->truth; + int trackID = t.trackID; + t.trackID = truth->particleID(trackID); + } + } + Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h); + if ( 0 != cal_hit ) { + if ( truth ) { + Geant4HitData::Contributions& c = cal_hit->truth; + for(Geant4HitData::Contributions::iterator j=c.begin(); j!=c.end(); ++j) { + Geant4HitData::Contribution& t = *j; + int trackID = t.trackID; + t.trackID = truth->particleID(trackID); + } + } + } + } + } +} + +/// Geant4EventAction interface: End-of-event callback +void Geant4HitTruthHandler::end(const G4Event* event) { + G4HCofThisEvent* hce = event->GetHCofThisEvent(); + if ( hce ) { + int nCol = hce->GetNumberOfCollections(); + Geant4ParticleMap* truth = context()->event().extension<Geant4ParticleMap>(false); + if ( truth && !truth->isValid() ) { + truth = 0; + printout(WARNING,name(),"+++ [Event:%d] No valid MC truth info present. " + "Is a Particle handler installed ?",event->GetEventID()); + } + for (int i = 0; i < nCol; ++i) { + G4VHitsCollection* hc = hce->GetHC(i); + handleCollection(truth, hc); + } + return; + } + warning("+++ [Event:%d] The value of G4HCofThisEvent is NULL. No collections saved!", + event->GetEventID()); +} + +#include "DDG4/Factories.h" +DECLARE_GEANT4ACTION(Geant4HitTruthHandler) + diff --git a/DDG4/plugins/Geant4MaterialScanner.cpp b/DDG4/plugins/Geant4MaterialScanner.cpp index 4b53d9c5f5268ee57596d982d97e9b17ec028513..0594bf7bd5f8ddcc7a3bd5be5edbaade2ed3aa55 100644 --- a/DDG4/plugins/Geant4MaterialScanner.cpp +++ b/DDG4/plugins/Geant4MaterialScanner.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4ParticleDumpAction.cpp b/DDG4/plugins/Geant4ParticleDumpAction.cpp new file mode 100644 index 0000000000000000000000000000000000000000..77bcbb194a60b7743bf784d27eb694cac7ac18b4 --- /dev/null +++ b/DDG4/plugins/Geant4ParticleDumpAction.cpp @@ -0,0 +1,111 @@ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== +#ifndef DD4HEP_DDG4_GEANT4PARTICLEDUMPACTION_H +#define DD4HEP_DDG4_GEANT4PARTICLEDUMPACTION_H + +// Framework include files +#include "DDG4/Geant4EventAction.h" + +// Forward declarations +class G4VHitsCollection; + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + + /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit + namespace Simulation { + + // Forward declarations + class Geant4ParticleMap; + + /// Class to measure the energy of escaping tracks + /** Class to measure the energy of escaping tracks of a detector using Geant 4 + * Measure escaping energy.... + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_SIMULATION + */ + class Geant4ParticleDumpAction : public Geant4EventAction { + public: + /// Standard constructor + Geant4ParticleDumpAction(Geant4Context* context, const std::string& nam); + /// Default destructor + virtual ~Geant4ParticleDumpAction(); + /// Geant4EventAction interface: Begin-of-event callback + virtual void begin(const G4Event* event) override; + /// Geant4EventAction interface: End-of-event callback + virtual void end(const G4Event* event) override; + }; + + } // End namespace Simulation +} // End namespace DD4hep + +#endif /* DD4HEP_DDG4_GEANT4PARTICLEDUMPACTION_H */ + +//==================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//==================================================================== + +// Framework include files +#include "DD4hep/InstanceCount.h" +#include "DDG4/Geant4DataDump.h" +#include "DDG4/Geant4HitCollection.h" + +// Geant 4 includes +#include "G4HCofThisEvent.hh" +#include "G4Event.hh" + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Simulation; + +/// Standard constructor +Geant4ParticleDumpAction::Geant4ParticleDumpAction(Geant4Context* ctxt, const string& nam) + : Geant4EventAction(ctxt, nam) +{ + m_needsControl = true; + InstanceCount::increment(this); +} + +/// Default destructor +Geant4ParticleDumpAction::~Geant4ParticleDumpAction() { + InstanceCount::decrement(this); +} + +/// Geant4EventAction interface: Begin-of-event callback +void Geant4ParticleDumpAction::begin(const G4Event* /* event */) { +} + +/// Geant4EventAction interface: End-of-event callback +void Geant4ParticleDumpAction::end(const G4Event* event) { + Geant4ParticleMap* parts = context()->event().extension<Geant4ParticleMap>(); + if ( parts ) { + Geant4DataDump dump(name()); + dump.print(ALWAYS,parts); + return; + } + warning("+++ [Event:%d] No particle map available!",event->GetEventID()); +} + +#include "DDG4/Factories.h" +DECLARE_GEANT4ACTION(Geant4ParticleDumpAction) diff --git a/DDG4/plugins/Geant4Particles.cpp b/DDG4/plugins/Geant4Particles.cpp index 66e4891c228b8ed7b9d4cbe6e1ef0420de749c17..2d03ff39e5cae3f0ed58f71fcea3281dc4bad106 100644 --- a/DDG4/plugins/Geant4Particles.cpp +++ b/DDG4/plugins/Geant4Particles.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4PhysicsConstructors.cpp b/DDG4/plugins/Geant4PhysicsConstructors.cpp index 2577b638054e379cc10cac6ce2ba58f47a14a2a9..0f2ec244736e852904a27e7d94cda484b6c0502a 100644 --- a/DDG4/plugins/Geant4PhysicsConstructors.cpp +++ b/DDG4/plugins/Geant4PhysicsConstructors.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4PrimaryGenerators.cpp b/DDG4/plugins/Geant4PrimaryGenerators.cpp index 018938ec24ca3005fac30bc3123937f6f0ed4169..1490a4873c0b0beb3847e0d0bb681ca8b2d2bad1 100644 --- a/DDG4/plugins/Geant4PrimaryGenerators.cpp +++ b/DDG4/plugins/Geant4PrimaryGenerators.cpp @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4Processes.cpp b/DDG4/plugins/Geant4Processes.cpp index acb54b661d0692e42ecb10c63dabf54f33d1ea2f..4bf4ba4d6cd42a8722505eb89d5496951854c67c 100644 --- a/DDG4/plugins/Geant4Processes.cpp +++ b/DDG4/plugins/Geant4Processes.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index 00bbd71d4a860cd3ca000ad49809641a38becc47..35f13bd0da7ae10a3fcdc83ca7deeb2cb7c38dfc 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4SensDet.cpp b/DDG4/plugins/Geant4SensDet.cpp index 5061a4388e2d0e6cbc432422dce7d1093e7e89ec..90e487e628b68f4e1a08523b86a28163048a0065 100644 --- a/DDG4/plugins/Geant4SensDet.cpp +++ b/DDG4/plugins/Geant4SensDet.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4SensDetFilters.cpp b/DDG4/plugins/Geant4SensDetFilters.cpp index 12047d9b66804b17cddd341c4d7ae2231ef851cf..d50de3db734ea264d1bdee9fc26d0b8f7728e040 100644 --- a/DDG4/plugins/Geant4SensDetFilters.cpp +++ b/DDG4/plugins/Geant4SensDetFilters.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4Steppers.cpp b/DDG4/plugins/Geant4Steppers.cpp index 09be6c08b5262bb9cb783b44555fdef89786a421..4832327b26ee3417d89347cbaf27776cf1a77bfa 100644 --- a/DDG4/plugins/Geant4Steppers.cpp +++ b/DDG4/plugins/Geant4Steppers.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4TCUserParticleHandler.cpp b/DDG4/plugins/Geant4TCUserParticleHandler.cpp index efde51e2e7c3b36a6896d81ac1f32aa4df1efbe6..febdc16eac2b0f0ddbbc900228bc1565914ed721 100644 --- a/DDG4/plugins/Geant4TCUserParticleHandler.cpp +++ b/DDG4/plugins/Geant4TCUserParticleHandler.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/plugins/Geant4UserActionInitialization.cpp b/DDG4/plugins/Geant4UserActionInitialization.cpp index 41dfec1cce24f67dadfc55e8ce719b3c1d9799c1..ccd41f8b3f144c5e684dc4278f1bc86d7fa0d3f6 100644 --- a/DDG4/plugins/Geant4UserActionInitialization.cpp +++ b/DDG4/plugins/Geant4UserActionInitialization.cpp @@ -11,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ #ifndef DD4HEP_DDG4_GEANT4USERACTIONINITIALIZATION_H #define DD4HEP_DDG4_GEANT4USERACTIONINITIALIZATION_H diff --git a/DDG4/plugins/Geant4XMLSetup.cpp b/DDG4/plugins/Geant4XMLSetup.cpp index 0e2796fb784985307f567f987c612727f02b32ce..f91a82344bb75e0575af8b297d0f6a1e46cf840f 100644 --- a/DDG4/plugins/Geant4XMLSetup.cpp +++ b/DDG4/plugins/Geant4XMLSetup.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/Geant4Action.cpp b/DDG4/src/Geant4Action.cpp index 24142792ff275f9a5b567be1403ef14b4befc9e5..9bd58d723d9d952f73a876dcf4f190144d35c44b 100644 --- a/DDG4/src/Geant4Action.cpp +++ b/DDG4/src/Geant4Action.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/Geant4DataDump.cpp b/DDG4/src/Geant4DataDump.cpp index 539d43ee1a264bff9415b9e46dbf9e0a7a236f93..54cb0eb93cac1d1fb37eacb38cf6c15dc74a486b 100644 --- a/DDG4/src/Geant4DataDump.cpp +++ b/DDG4/src/Geant4DataDump.cpp @@ -51,53 +51,70 @@ void Geant4DataDump::print(PrintLevel level, Geant4ParticleHandle p) const { } /// Print the particle container to the output logging using the specified print level -void Geant4DataDump::print(PrintLevel level, const std::string& container, const Particles* parts) { +void Geant4DataDump::print(PrintLevel level, const std::string& container, const Particles* parts) const { if ( parts ) { + PrintLevel low_lvl = level == ALWAYS ? ALWAYS : PrintLevel(level-1); printout(level,m_tag,"+++ Track container: %-21s --------------- Track KEEP reasoning ---------------",container.c_str()); printout(level,m_tag,"+++ # of Tracks:%6d PDG Parent Primary Secondary Energy %-8s Calo Tracker Process/Par", int(parts->size()),"in [MeV]"); - for(Particles::const_iterator i=parts->begin(); i!= parts->end(); ++i) - print(PrintLevel(level-1), *i); - return; + for(Particle* p : *parts) { + Geant4ParticleHandle ph(p); + print(low_lvl, ph); + } + } +} + +/// Print the particle map to the output logging using the specified print level +void Geant4DataDump::print(PrintLevel level, const Geant4ParticleMap* parts) const { + if ( parts ) { + PrintLevel low_lvl = level == ALWAYS ? ALWAYS : PrintLevel(level-1); + typedef Geant4ParticleMap::ParticleMap ParticleMap; + const ParticleMap& pm = parts->particles(); + printout(level,m_tag,"+++ Geant4 Particle map %-18s --------------- Track KEEP reasoning ---------------",""); + printout(level,m_tag,"+++ # of Tracks:%6d PDG Parent Primary Secondary Energy %-8s Calo Tracker Process/Par", + int(pm.size()),"in [MeV]"); + for(const auto& p : pm) + print(low_lvl, p.second); } } /// Print a single tracker hit to the output logging using the specified print level -void Geant4DataDump::print(PrintLevel level, const TrackerHit* h) { +void Geant4DataDump::print(PrintLevel level, const TrackerHit* h) const { const SimpleHit::Contribution& t = h->truth; printout(level,m_tag," +++ Hit: Cell: %016llX Pos:(%9.3g,%9.3g,%9.3g) Len:%9.3g [mm] E:%9.3g MeV TrackID:%6d PDG:%12d dep:%9.3g time:%9.3g [ns]", h->cellID,h->position.x(),h->position.y(),h->position.z(),h->length,h->energyDeposit,t.trackID,t.pdgID,t.deposit,t.time); } /// Print the tracker hits container to the output logging using the specified print level -void Geant4DataDump::print(PrintLevel level, const std::string& container, const TrackerHits* hits) { +void Geant4DataDump::print(PrintLevel level, const std::string& container, const TrackerHits* hits) const { if ( hits ) { - printout(level,m_tag,"+++ %s: # Tracker hits %d",container.c_str(),int(hits->size())); - for(TrackerHits::const_iterator i=hits->begin(); i!= hits->end(); ++i) - print(PrintLevel(level-1), *i); - return; + PrintLevel low_lvl = level == ALWAYS ? ALWAYS : PrintLevel(level-1); + printout(level,m_tag,"+++ Hit Collection: %s # Tracker hits %d",container.c_str(),int(hits->size())); + for(const TrackerHit* hit : *hits) + print(low_lvl, hit); } } /// Print a calorimeter tracker hit to the output logging using the specified print level -void Geant4DataDump::print(PrintLevel level, const CalorimeterHit* h) { +void Geant4DataDump::print(PrintLevel level, const CalorimeterHit* h) const { + PrintLevel low_lvl = level == ALWAYS ? ALWAYS : PrintLevel(level-1); printout(level,m_tag," +++ Hit: Cell: %016llX Pos:(%9.3g,%9.3g,%9.3g) [mm] E:%9.3g MeV #Contributions:%3d", h->cellID,h->position.x(),h->position.y(),h->position.z(),h->energyDeposit,h->truth.size()); - const SimpleHit::Contributions& t = h->truth; int cnt=0; - for(SimpleHit::Contributions::const_iterator i=t.begin(); i!=t.end(); ++i,++cnt) { - const SimpleHit::Contribution& c = *i; - printout(PrintLevel(level-1),m_tag," Contribution #%3d TrackID:%6d PDG:%12d %9.3g MeV %9.3g ns", + for(const SimpleHit::Contribution& c : h->truth) { + printout(low_lvl,m_tag," Contribution #%3d TrackID:%6d PDG:%12d %9.3g MeV %9.3g ns", cnt,c.trackID,c.pdgID,c.deposit,c.time); + ++cnt; } } /// Print the calorimeter hits container to the output logging using the specified print level -void Geant4DataDump::print(PrintLevel level, const std::string& container, const CalorimeterHits* hits) { +void Geant4DataDump::print(PrintLevel level, const std::string& container, const CalorimeterHits* hits) const { if ( hits ) { - printout(level,m_tag,"+++ %s: # Calorimeter hits %d",container.c_str(),int(hits->size())); - for(CalorimeterHits::const_iterator i=hits->begin(); i!= hits->end(); ++i) - print(PrintLevel(level-1), *i); + PrintLevel low_lvl = level == ALWAYS ? ALWAYS : PrintLevel(level-1); + printout(level,m_tag,"+++ Hit Collection: %s # Calorimeter hits %d",container.c_str(),int(hits->size())); + for(const CalorimeterHit* hit : *hits) + print(low_lvl, hit); return; } } diff --git a/DDG4/src/Geant4Output2ROOT.cpp b/DDG4/src/Geant4Output2ROOT.cpp index b78710f266ca4267b3093b6fbba74f2f6c468823..a479c17c8baf4301624dc59b8f76b35830bd10e4 100644 --- a/DDG4/src/Geant4Output2ROOT.cpp +++ b/DDG4/src/Geant4Output2ROOT.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/Geant4Particle.cpp b/DDG4/src/Geant4Particle.cpp index 217334f73894389a2a10229f82c296906dbea667..2a2bf897e3645946b47fcc96368a1fd486ef2346 100644 --- a/DDG4/src/Geant4Particle.cpp +++ b/DDG4/src/Geant4Particle.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/Geant4ParticleHandler.cpp b/DDG4/src/Geant4ParticleHandler.cpp index 823963b85923c7551fae6834778875fcdd0b0c1f..30cc6b75c141bc1055d699514074b2b9cffd0dc4 100644 --- a/DDG4/src/Geant4ParticleHandler.cpp +++ b/DDG4/src/Geant4ParticleHandler.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/doc/LaTex/DDG4-optimization-vtunes.0.png b/doc/LaTex/DDG4-optimization-vtunes.0.png new file mode 100644 index 0000000000000000000000000000000000000000..066d5ecffa977b1dc776e20faa2c190785b8cbe1 Binary files /dev/null and b/doc/LaTex/DDG4-optimization-vtunes.0.png differ diff --git a/doc/LaTex/DDG4-optimization-vtunes.1.png b/doc/LaTex/DDG4-optimization-vtunes.1.png new file mode 100644 index 0000000000000000000000000000000000000000..72f83ba74b89822f43a9a3dc5847a9282a4089d9 Binary files /dev/null and b/doc/LaTex/DDG4-optimization-vtunes.1.png differ diff --git a/examples/ClientTests/scripts/MultiSegmentCollections.py b/examples/ClientTests/scripts/MultiSegmentCollections.py new file mode 100644 index 0000000000000000000000000000000000000000..6b51b930ce67af2c6edf6575260bbed070bf152c --- /dev/null +++ b/examples/ClientTests/scripts/MultiSegmentCollections.py @@ -0,0 +1,84 @@ +import os, sys, time, DDG4 +from DDG4 import OutputLevel as Output +from SystemOfUnits import * +# +# +""" + + DD4hep example setup using the python configuration + + \author M.Frank + \version 1.0 + +""" +def run(): + batch = False + kernel = DDG4.Kernel() + install_dir = os.environ['DD4hepINSTALL'] + geometry = "file:"+install_dir+"/examples/ClientTests/compact/MultiSegmentCollections.xml" + kernel.setOutputLevel('Geant4Converter',Output.DEBUG) + kernel.setOutputLevel('Gun',Output.INFO) + for i in xrange(len(sys.argv)): + if sys.argv[i]=='-compact': + geometry = sys.argv[i+1] + elif sys.argv[i]=='-input': + geometry = sys.argv[i+1] + elif sys.argv[i]=='-batch': + batch = True + elif sys.argv[i]=='batch': + batch = True + + kernel.loadGeometry(geometry) + geant4 = DDG4.Geant4(kernel) + geant4.printDetectors() + geant4.setupCshUI() + if batch: kernel.UI = '' + + # Configure field + field = geant4.setupTrackingField(prt=True) + # Setup particle gun + geant4.setupGun("Gun",particle='pi-',energy=50*GeV,multiplicity=1) + + # Now the test calorimeter with multiple collections + seq,act = geant4.setupCalorimeter('TestCal') + + # And handle the simulation particles. + part = DDG4.GeneratorAction(kernel,"Geant4ParticleHandler/ParticleHandler") + kernel.generatorAction().adopt(part) + part.MinimalKineticEnergy = 1*MeV + part.enableUI() + + # Add the particle dumper to associate the MC truth + evt = DDG4.EventAction(kernel,"Geant4ParticleDumpAction/ParticleDump") + kernel.eventAction().adopt(evt) + evt.enableUI() + + # Add the hit dumper BEFORE any hit truth is fixed + evt = DDG4.EventAction(kernel,"Geant4HitDumpAction/RawDump") + kernel.eventAction().adopt(evt) + evt.enableUI() + + # Add the hit dumper to the event action sequence + evt = DDG4.EventAction(kernel,"Geant4HitTruthHandler/HitTruth") + kernel.eventAction().adopt(evt) + evt.enableUI() + + # Add the hit dumper AFTER any hit truth is fixed. We should see the reduced track references + evt = DDG4.EventAction(kernel,"Geant4HitDumpAction/HitDump") + kernel.eventAction().adopt(evt) + evt.enableUI() + + # Configure I/O + evt_root = geant4.setupROOTOutput('RootOutput','Multi_coll_'+time.strftime('%Y-%m-%d_%H-%M'),mc_truth=True) + evt_root.HandleMCTruth = False + + # Now build the physics list: + phys = kernel.physicsList() + phys.extends = 'QGSP_BERT' + phys.enableUI() + phys.dump() + # and run + geant4.execute() + +if __name__ == "__main__": + run()