diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp index 69b38d75bb352395581ee06ed269943a8502d531..4baecf652e49a6eff20d5225ab06792a1e2f2864 100644 --- a/DDCore/src/VolumeManager.cpp +++ b/DDCore/src/VolumeManager.cpp @@ -60,11 +60,11 @@ namespace { Chain chain; SensitiveDetector sd = parent_sd; m_entries.clear(); -#if 0 Encoding coding; scanPhysicalVolume(de, de, pv, coding, ids, sd, chain); -#endif +#if 0 scanPhysicalVolume(de, de, pv, ids, sd, chain); +#endif continue; } printout(WARNING, "VolumeManager", "++ Detector element %s of type %s has no placement.", @@ -90,7 +90,8 @@ namespace { } /// Scan a single physical volume and look for sensitive elements below size_t scanPhysicalVolume(DetElement& parent, DetElement e, PlacedVolume pv, - Encoding parent_encoding, VolIDs ids, SensitiveDetector& sd, Chain& chain) + Encoding parent_encoding, + VolIDs ids, SensitiveDetector& sd, Chain& chain) { TGeoNode* node = pv.ptr(); size_t count = 0; @@ -132,13 +133,18 @@ namespace { if ( !got_readout && !pv_ids.empty() ) { ids.VolIDs::Base::insert(ids.end(), pv_ids.begin(), pv_ids.end()); } + bool compound = e.type() == "compound"; + if ( compound ) { + sd = SensitiveDetector(0); + volume_encoding = Encoding(); + } for (Int_t idau = 0, ndau = node->GetNdaughters(); idau < ndau; ++idau) { TGeoNode* daughter = node->GetDaughter(idau); PlacedVolume placement(daughter); if ( placement.data() ) { size_t cnt; PlacedVolume pv_dau = Ref_t(daughter); - DetElement de_dau = findElt(e, daughter); + DetElement de_dau = findElt(e, daughter); if ( de_dau.isValid() ) { Chain dau_chain; cnt = scanPhysicalVolume(parent, de_dau, pv_dau, volume_encoding, ids, sd, dau_chain); @@ -156,6 +162,10 @@ namespace { throw runtime_error("Invalid not instrumented placement:"+string(daughter->GetName())+ " [Internal error -- bad detector constructor]"); } + if ( compound ) { + sd = SensitiveDetector(0); + volume_encoding = Encoding(); + } } if ( count == 0 ) { sd = SensitiveDetector(0); diff --git a/DDG4/examples/initAClick.C b/DDG4/examples/initAClick.C index 36287da3996b445c1099a7368b4922fd1e9a2ae9..8ecb908bf93cd365bbb2a6565175403c5bb38f0d 100644 --- a/DDG4/examples/initAClick.C +++ b/DDG4/examples/initAClick.C @@ -61,6 +61,7 @@ int initAClick(const char* command=0) { std::string geant4 = make_str(gSystem->Getenv("G4INSTALL")); std::string dd4hep = make_str(gSystem->Getenv("DD4hepINSTALL")); std::string clhep = make_str(gSystem->Getenv("CLHEP_DIR")); + std::string defs = ""; std::string libs = " -L"+rootsys+"/lib"; std::string inc = " -I"+dd4hep+"/examples/DDG4/examples -I"+dd4hep + " -I"+dd4hep+"/include"; libs += " -L"+dd4hep+"/lib -lDDCore -lDDG4 -lDDSegmentation"; @@ -73,7 +74,7 @@ int initAClick(const char* command=0) { // if CLHEP is not included in Geant4... inc += " -I"+clhep+"/include"; } - inc += " -Wno-shadow -g -O0"; + inc += " -Wno-shadow -g -O0" + defs; if ( ROOT_VERSION_CODE < ROOT_VERSION(6,0,0) ) libs += " -lCint"; libs += " -lCore -lMathCore -pthread -lm -ldl -rdynamic"; diff --git a/DDG4/examples/run.C b/DDG4/examples/run.C index 0e1fc31c6cdef44ba53db4667c292d018333dc61..51ed9ebadc8484261033a9d38cb3d1537f650821 100644 --- a/DDG4/examples/run.C +++ b/DDG4/examples/run.C @@ -20,6 +20,7 @@ // Run a ROOT macro void run(const char* macro) { + int status; char cmd[1024]; const char* dd4hep_install = getenv("DD4hepINSTALL"); if ( dd4hep_install ) { @@ -28,7 +29,7 @@ void run(const char* macro) { else { ::sprintf(cmd,".L examples/DDG4/examples/initAClick.C+"); } - int status = gInterpreter->ProcessLine(cmd); + status = gInterpreter->ProcessLine(cmd); ::printf("Status(%s) = %d\n",cmd,status); status = gInterpreter->ProcessLine("initAClick()"); ::printf("Status(%s) = %d\n",cmd,status); diff --git a/DDG4/include/DDG4/Geant4Primary.h b/DDG4/include/DDG4/Geant4Primary.h index e35370fb7f5a78a3a8d2dd1c64f1768f1637972b..bc0c9941d73f27b22892026641d10d9aa13ee190 100644 --- a/DDG4/include/DDG4/Geant4Primary.h +++ b/DDG4/include/DDG4/Geant4Primary.h @@ -65,12 +65,25 @@ namespace DD4hep { class Geant4PrimaryMap { public: typedef std::map<const G4PrimaryParticle*,Geant4Particle*> Primaries; + private: /// Mapping of primary particles of this event - Primaries primaryMap; //! not persistent + Primaries m_primaryMap; //! not persistent + + public: /// Default constructor Geant4PrimaryMap() {} /// Default destructor virtual ~Geant4PrimaryMap(); + /// Add a new object pair (G4 primary particle, DDG4 particle) into the maps + void insert(G4PrimaryParticle* g4_particle,Geant4Particle* particle); + /// Access DDG4 particle by G4 primary particle + Geant4Particle* get(const G4PrimaryParticle* particle); + /// Access DDG4 particle by G4 primary particle (const) + const Geant4Particle* get(const G4PrimaryParticle* particle) const; + /// Access primary map directly + Primaries& primaries() { return m_primaryMap; } + /// Access primary map directly (const) + const Primaries& primaries() const { return m_primaryMap; } }; diff --git a/DDG4/include/DDG4/Geant4TrackHandler.h b/DDG4/include/DDG4/Geant4TrackHandler.h index b8997c2f20c7a6eb13fa1adfb5a5ecf4ddd9d91d..0be8fde42fdf3cfbdfe7eda377ead96ab1f8bf43 100644 --- a/DDG4/include/DDG4/Geant4TrackHandler.h +++ b/DDG4/include/DDG4/Geant4TrackHandler.h @@ -23,6 +23,7 @@ #include "G4VTouchable.hh" #include "G4VSensitiveDetector.hh" #include "G4ParticleDefinition.hh" +#include "G4DynamicParticle.hh" #include "G4VProcess.hh" #include <stdexcept> @@ -189,6 +190,16 @@ namespace DD4hep { G4ParticleDefinition* def = trackDef(); return def ? def->GetPDGEncoding() : 0; } + /// Access the dynamic particle of the track object + const G4DynamicParticle* dynamic() const { + return track->GetDynamicParticle(); + } + /// Access the primary particle of the track object (if present) + const G4PrimaryParticle* primary() const { + const G4DynamicParticle* d = track->GetDynamicParticle(); + if ( d ) return d->GetPrimaryParticle(); + return 0; + } }; } // End namespace Simulation diff --git a/DDG4/src/Geant4InputHandling.cpp b/DDG4/src/Geant4InputHandling.cpp index 7bf1e53c13c12763786c403e0a95ef729575237f..8cadf14bbbf35294bfaf6e646cee0c6da98198a9 100644 --- a/DDG4/src/Geant4InputHandling.cpp +++ b/DDG4/src/Geant4InputHandling.cpp @@ -86,7 +86,7 @@ DD4hep::Simulation::createPrimary(int particle_id, static void collectPrimaries(Geant4PrimaryMap* pm, Geant4PrimaryInteraction* interaction, Geant4Vertex* particle_origine, - const G4PrimaryParticle* gp) + G4PrimaryParticle* gp) { int pid = int(interaction->particles.size()); Geant4Particle* p = createPrimary(pid,particle_origine,gp); @@ -99,7 +99,7 @@ static void collectPrimaries(Geant4PrimaryMap* pm, p->mask = mask; particle_origine->out.insert(p->id); // Insert pair in map. Do not forget to increase reference count! - pm->primaryMap.insert(make_pair(gp,p->addRef())); + pm->insert(gp,p); if ( dau ) { Geant4Vertex* dv = new Geant4Vertex(*particle_origine); @@ -462,7 +462,7 @@ int DD4hep::Simulation::generatePrimaries(const Geant4Action* caller, } for(map<int,G4PrimaryParticle*>::iterator i=prim.begin(); i!=prim.end(); ++i) { Geant4ParticleHandle p = pm[(*i).first]; - primaries->primaryMap[(*i).second] = p->addRef(); + primaries->insert((*i).second,p); } } return 1; diff --git a/DDG4/src/Geant4ParticleHandler.cpp b/DDG4/src/Geant4ParticleHandler.cpp index 3ed0126eb41fd54c78d826dd384116b41ff8e16a..3d022eac70065d11f5ef088a6de654ae343f516f 100644 --- a/DDG4/src/Geant4ParticleHandler.cpp +++ b/DDG4/src/Geant4ParticleHandler.cpp @@ -47,19 +47,6 @@ using namespace DD4hep::Simulation; typedef ReferenceBitMask<int> PropertyMask; -namespace { - const G4PrimaryParticle* primary(int id, Geant4PrimaryMap::Primaries const& primaryMap) { - Geant4PrimaryMap::Primaries::const_iterator iprim = primaryMap.begin(); - Geant4PrimaryMap::Primaries::const_iterator primEnd = primaryMap.end(); - for (; iprim != primEnd; ++iprim) { - if( iprim->first->GetTrackID() == id ){ - return iprim->first; - } - } - return 0; - } -} - /// Standard constructor Geant4ParticleHandler::Geant4ParticleHandler(Geant4Context* ctxt, const string& nam) : Geant4GeneratorAction(ctxt,nam), Geant4MonteCarloTruth(), m_userHandler(0), m_primaryMap(0) @@ -211,15 +198,14 @@ void Geant4ParticleHandler::begin(const G4Track* track) { G4ThreeVector m = h.momentum(); const G4ThreeVector& v = h.vertex(); int reason = (kine > m_kinEnergyCut) ? G4PARTICLE_ABOVE_ENERGY_THRESHOLD : 0; - const G4PrimaryParticle* prim = primary(h.id(),m_primaryMap->primaryMap); + const G4PrimaryParticle* prim = h.primary(); Particle* prim_part = 0; if ( prim ) { - Geant4PrimaryMap::Primaries::const_iterator iprim = m_primaryMap->primaryMap.find(prim); - if ( iprim == m_primaryMap->primaryMap.end() ) { + prim_part = m_primaryMap->get(prim); + if ( !prim_part ) { except("+++ Tracking preaction: Primary particle without generator particle!"); } - prim_part = (*iprim).second; reason |= (G4PARTICLE_PRIMARY|G4PARTICLE_ABOVE_ENERGY_THRESHOLD); m_particleMap[h.id()] = prim_part->addRef(); } diff --git a/DDG4/src/Geant4Primary.cpp b/DDG4/src/Geant4Primary.cpp index 652c5db3787460149bb4ceeb7a51a7e6d62a1c8f..48c177c87e2e8ecd460fbc5e5d9fae43be51dc49 100644 --- a/DDG4/src/Geant4Primary.cpp +++ b/DDG4/src/Geant4Primary.cpp @@ -17,6 +17,9 @@ #include "DD4hep/InstanceCount.h" #include "DDG4/Geant4Primary.h" +// Geant4 include files +#include "G4PrimaryParticle.hh" + // C/C++ include files #include <stdexcept> #include <cstdio> @@ -30,7 +33,24 @@ PrimaryExtension::~PrimaryExtension() { /// Default destructor Geant4PrimaryMap::~Geant4PrimaryMap() { - releaseObjects(primaryMap)(); + releaseObjects(m_primaryMap)(); +} + +/// Add a new object pair (G4 primary particle, DDG4 particle) into the maps +void Geant4PrimaryMap::insert(G4PrimaryParticle* g4,Geant4Particle* p) { + m_primaryMap.insert(std::make_pair(g4,p->addRef())); +} + +/// Access DDG4 particle by G4 primary particle +Geant4Particle* Geant4PrimaryMap::get(const G4PrimaryParticle* particle) { + Primaries::iterator i=m_primaryMap.find(particle); + return i != m_primaryMap.end() ? (*i).second : 0; +} + +/// Access DDG4 particle by G4 primary particle (const) +const Geant4Particle* Geant4PrimaryMap::get(const G4PrimaryParticle* particle) const { + Primaries::const_iterator i=m_primaryMap.find(particle); + return i != m_primaryMap.end() ? (*i).second : 0; } /// Default constructor diff --git a/DDRec/CMakeLists.txt b/DDRec/CMakeLists.txt index be8a53031aba147e0dfe349feb96f829baa2c10d..37ae59486a7a530cfc47248246b4c7feef60ec00 100644 --- a/DDRec/CMakeLists.txt +++ b/DDRec/CMakeLists.txt @@ -13,6 +13,7 @@ #========================================================================== dd4hep_package(DDRec USES DDCore DDSurfaces + [ROOT REQUIRED COMPONENTS Geom] INCLUDE_DIRS include INSTALL_INCLUDES include/DDRec) diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt index 2c758ab36fe7eb9202ccd4b4f56f0756b43f5a51..242e7e959394c833d1cd35e1fc941fbe8addf046 100644 --- a/UtilityApps/CMakeLists.txt +++ b/UtilityApps/CMakeLists.txt @@ -9,7 +9,10 @@ # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. # #========================================================================== -dd4hep_package(UtilityApps USES DDCore) +dd4hep_package(UtilityApps + USES DDCore + [ROOT REQUIRED COMPONENTS Geom] + ) #----------------------------------------------------------------------------------- dd4hep_add_executable( geoDisplay src/display.cpp ) #----------------------------------------------------------------------------------- diff --git a/doc/CompileAllOptionPermutations.sh b/doc/CompileAllOptionPermutations.sh index 3d17fd113bc163db3aa1069dec5fffe9015e61dd..c2d23a75a182d6af890bc43b454d63748ee0d094 100755 --- a/doc/CompileAllOptionPermutations.sh +++ b/doc/CompileAllOptionPermutations.sh @@ -9,6 +9,14 @@ CHECKOUT=${dir_name}/../../DD4hep.trunk/checkout; GEANT_VERSION=10.01.p02; ROOT_VERSION=5.34.25 ROOT_VERSION=6.04.10; + +#INSTALL_G4=${SW}/g4_10.02.p02_dbg/lib/Geant4-10.2.2; +#GEANT_VERSION=10.02.p02; +ROOT_VERSION=6.06.06; +#source ${INSTALL_G4}/../../bin/geant4.sh; +export CXX="`which g++-5` -D_GLIBCXX_USE_CXX11_ABI=0"; +export CC="`which gcc-5` -D_GLIBCXX_USE_CXX11_ABI=0"; + # ============================================================================== # Parse arguments # ============================================================================== @@ -83,14 +91,14 @@ make_opt() make_build() { - echo ${fCMD}; + echo ${CMD}; eval ${CMD}; if [ $? -ne 0 ]; then make_output "DANGER WILL ROBINSON DANGER!" "++++ Failed CMAKE command:" echo ${CMD}; exit 1 fi - make install VERBOSE=1 -j 4; + make install VERBOSE=1 -j 1; if [ $? -ne 0 ]; then make_output "DANGER WILL ROBINSON DANGER!" "++++ Failed BUILD!" echo ${CMD}; @@ -118,6 +126,8 @@ build_all() #G4_MODES="ON"; #XERCES_MODES="OFF"; #LCIO_MODES="ON"; + BUILD_TYPE=; + BUILD_TYPE="-DCMAKE_BUILD_TYPE=Debug"; for DOGEANT4 in ${G4_MODES}; do for DOXERCESC in ${XERCES_MODES}; do for DOGEAR in OFF; do @@ -134,7 +144,7 @@ build_all() `make_opt ${DOXERCESC} -DDD4HEP_USE_XERCESC -DXERCESC_ROOT_DIR=${INSTALL_XERCESC}` \ -DDD4HEP_NO_REFLEX=ON -DDD4HEP_USE_CXX11=OFF \ -DROOTSYS=${ROOTSYS} -DCMAKE_INSTALL_PREFIX=${WORK_DIR}/DD4hep"; - CMD="cd ${dir_name}/$folder ; cmake ${OPTS} ${CHECKOUT};"; + CMD="cd ${dir_name}/$folder ; cmake ${BUILD_TYPE} ${OPTS} ${CHECKOUT};"; make_build; unset ROOTSYS; @@ -146,7 +156,7 @@ build_all() -DDD4HEP_NO_REFLEX=ON -DDD4HEP_USE_CXX11=OFF \ -DROOTSYS=${ROOTSYS}"; source ${DD4hep_DIR}/bin/thisdd4hep.sh; - CMD="cd ${WORK_DIR}/EX; cmake ${OPTS} -DDD4hep_DIR=${DD4hep_DIR} ${CHECKOUT}/examples;"; + CMD="cd ${WORK_DIR}/EX; cmake ${BUILD_TYPE} ${OPTS} -DDD4hep_DIR=${DD4hep_DIR} ${CHECKOUT}/examples;"; make_build; # cd ../..; diff --git a/doc/DDAlignDesign.pdf b/doc/DDAlignDesign.pdf index 8d5fb1b94ebc69495eb4e344353562f70646191a..9a7ed13db28043fb55f582f11eaee9772d9753bb 100644 Binary files a/doc/DDAlignDesign.pdf and b/doc/DDAlignDesign.pdf differ diff --git a/doc/LaTex/DDAlignDesign.tex b/doc/LaTex/DDAlignDesign.tex index e097c1c58b55889f2d92317b0c44e88962475f70..08bce04d3abb7907cac491766b806d7a13280b23 100644 --- a/doc/LaTex/DDAlignDesign.tex +++ b/doc/LaTex/DDAlignDesign.tex @@ -5,13 +5,11 @@ % \pagestyle{fancyplain}{\fancyfoot[C]{\sffamily{Software Design of the Alignment Extension of the DD4hep Detector Description Toolkit\\ --- DRAFT --}}} +}}} % \begin{document} % \mytitle{ --- DRAFT -- \\ -\vspace{0.5cm} DDAlign \vspace{-0.5cm} }{ @@ -79,6 +77,8 @@ Document & & \\ version & Date & Author \\[0.2cm] \hline & & \\ 1.0 & 01/03/2016 & Markus Frank CERN/LHCb \\ +1.1 & 30/06/2016 & Markus Frank CERN/LHCb \\ + & & Revised by workgroup \\ & & \\ \hline \end{tabular} }}} diff --git a/doc/LaTex/LaTex-template/setup/AIDA2020-setup.tex b/doc/LaTex/LaTex-template/setup/AIDA2020-setup.tex index 8e80cd68d71c95ff9e778d91fa62f5a4d9ab3f32..54bd520d049b17c1f223c4d161d0a8adde213188 100644 --- a/doc/LaTex/LaTex-template/setup/AIDA2020-setup.tex +++ b/doc/LaTex/LaTex-template/setup/AIDA2020-setup.tex @@ -6,7 +6,7 @@ \usepackage{fix-cm} \usepackage{setup/lineno} \usepackage{fancyhdr} -\usepackage{amsmath} +%\usepackage{amsmath} % \oddsidemargin 0.1 in \evensidemargin 0.1 in diff --git a/doc/LaTex/setup b/doc/LaTex/setup new file mode 120000 index 0000000000000000000000000000000000000000..5b5449e399060524fcf28ef2d8f27b3ed850cc6f --- /dev/null +++ b/doc/LaTex/setup @@ -0,0 +1 @@ +LaTex-template/setup \ No newline at end of file diff --git a/examples/CLICSiD/CMakeLists.txt b/examples/CLICSiD/CMakeLists.txt index 542179435e34a5b63549b46e504d5666466c7d9c..c8857021ab05b6b1bacd1b64ad3e333a5c17adfb 100644 --- a/examples/CLICSiD/CMakeLists.txt +++ b/examples/CLICSiD/CMakeLists.txt @@ -22,10 +22,10 @@ dd4hep_install_dir( compact scripts sim DESTINATION ${DD4hep_DIR}/examples/CLICS #-------------------------------------------------------------------------- if (DD4HEP_USE_GEANT4) dd4hep_add_executable(CLICSiDXML SOURCES scripts/CLICSiDXML.C - USES [DD4hep REQUIRED COMPONENTS DDG4] GEANT4 ) + USES [DD4hep REQUIRED COMPONENTS DDCore DDG4] GEANT4 ) #-------------------------------------------------------------------------- dd4hep_add_executable(CLICSiDAClick SOURCES scripts/CLICSiDAClick.C - USES [DD4hep REQUIRED COMPONENTS DDG4] GEANT4 ) + USES [DD4hep REQUIRED COMPONENTS DDCore DDG4] GEANT4 ) endif() # dd4hep_configure_scripts ( CLICSiD DEFAULT_SETUP WITH_TESTS )