diff --git a/DDG4/include/DDG4/Geant4AssemblyVolume.h b/DDG4/include/DDG4/Geant4AssemblyVolume.h index 4cf17d9e5548be32243560f071dbe5d18b9fefcf..328dc4537adfbf3e05e86d9692b9bd76e220f8e5 100644 --- a/DDG4/include/DDG4/Geant4AssemblyVolume.h +++ b/DDG4/include/DDG4/Geant4AssemblyVolume.h @@ -43,11 +43,21 @@ namespace dd4hep { typedef std::vector<const TGeoNode*> Chain; std::vector<const TGeoNode*> m_entries; + std::vector<Geant4AssemblyVolume*> m_places; G4AssemblyVolume* m_assembly; /// Default constructor with initialization Geant4AssemblyVolume(); - + + /// Inhibit move construction + Geant4AssemblyVolume(Geant4AssemblyVolume&& copy) = delete; + /// Inhibit copy construction + Geant4AssemblyVolume(const Geant4AssemblyVolume& copy) = delete; + /// Inhibit move assignment + Geant4AssemblyVolume& operator=(Geant4AssemblyVolume&& copy) = delete; + /// Inhibit copy assignment + Geant4AssemblyVolume& operator=(const Geant4AssemblyVolume& copy) = delete; + /// Default destructor virtual ~Geant4AssemblyVolume(); diff --git a/DDG4/src/Geant4AssemblyVolume.cpp b/DDG4/src/Geant4AssemblyVolume.cpp index e1c7617a00ff5a3c8527769de530f7b39f6f9edd..6cae442f8ff2255fa9c4c2b0752ce2107251f12e 100644 --- a/DDG4/src/Geant4AssemblyVolume.cpp +++ b/DDG4/src/Geant4AssemblyVolume.cpp @@ -45,6 +45,7 @@ long Geant4AssemblyVolume::placeVolume(const TGeoNode* n, { size_t id = m_assembly->TotalTriplets(); m_entries.emplace_back(n); + m_places.emplace_back(nullptr); m_assembly->AddPlacedVolume(pPlacedVolume, transformation); return (long)id; } @@ -55,6 +56,7 @@ long Geant4AssemblyVolume::placeAssembly(const TGeoNode* n, { size_t id = m_assembly->TotalTriplets(); m_entries.emplace_back(n); + m_places.emplace_back(pPlacedVolume); m_assembly->AddPlacedAssembly(pPlacedVolume->m_assembly, transformation); return (long)id; } @@ -69,27 +71,24 @@ void Geant4AssemblyVolume::imprint(Geant4GeometryInfo& info, G4bool surfCheck) { struct _Wrap : public G4AssemblyVolume { - void imprintsCountPlus() { this->G4AssemblyVolume::ImprintsCountPlus(); } - } *parent_wrapper = nullptr; - static int level=0; + static void imprintsCountPlus(G4AssemblyVolume* p) + { _Wrap* w = (_Wrap*)p; w->ImprintsCountPlus(); } + }; TGeoVolume* vol = parent->GetVolume(); + G4AssemblyVolume* par_ass = pParentAssembly->m_assembly; unsigned int numberOfDaughters = (copyNumBase == 0) ? pMotherLV->GetNoDaughters() : copyNumBase; - parent_wrapper = (_Wrap*)pParentAssembly->m_assembly; - ++level; - // We start from the first available index - // numberOfDaughters++; - parent_wrapper->imprintsCountPlus(); + _Wrap::imprintsCountPlus(par_ass); //cout << " Assembly:" << detail::tools::placementPath(chain) << endl; - - std::vector<G4AssemblyTriplet>::iterator iter = pParentAssembly->m_assembly->GetTripletsIterator(); - for( unsigned int i = 0, n = parent_wrapper->TotalTriplets(); i < n; i++, iter++ ) { + std::vector<G4AssemblyTriplet>::iterator iter = par_ass->GetTripletsIterator(); + for( unsigned int i = 0, n = par_ass->TotalTriplets(); i < n; i++, iter++ ) { Chain new_chain = chain; const auto& triplet = *iter; const TGeoNode* node = pParentAssembly->m_entries[i]; + Geant4AssemblyVolume* avol = pParentAssembly->m_places[i]; new_chain.emplace_back(node); //cout << " Assembly: Entry: " << detail::tools::placementPath(new_chain) << endl; @@ -170,15 +169,11 @@ void Geant4AssemblyVolume::imprint(Geant4GeometryInfo& info, } else if ( triplet.GetAssembly() ) { // Place volumes in this assembly with composed transformation - imprint(info, parent, new_chain, (Geant4AssemblyVolume*)triplet.GetAssembly(), - pMotherLV, Tfinal, i*100+copyNumBase, surfCheck ); + imprint(info, parent, new_chain, avol, pMotherLV, Tfinal, i*100+copyNumBase, surfCheck ); } else { - --level; G4Exception("Geant4AssemblyVolume::imprint(..)", "GeomVol0003", FatalException, "Triplet has no volume and no assembly"); } } - //cout << "Imprinted assembly level:" << level << " in mother:" << pMotherLV->GetName() << endl; - --level; } diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index 04969bbacf6f8bf42f2676839d8eb28647407620..d158682e622da3a1ecfac9019cc757f845865b59 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -682,7 +682,7 @@ void* Geant4Converter::handleAssembly(const string& name, const TGeoNode* node) __FILE__, __LINE__, name.c_str(), dau->GetName()); return 0; } - g4->placeAssembly(dau,(*ia).second,transform); + g4->placeAssembly(dau, (*ia).second, transform); printout(lvl, "Geant4Converter", "+++ Assembly: AddPlacedAssembly : dau:%s " "to mother %s Tr:x=%8.3f y=%8.3f z=%8.3f", dau_vol->GetName(), mot_vol->GetName(),