diff --git a/DDExamples/ILDExSimu/src/ILDExEventAction.cpp b/DDExamples/ILDExSimu/src/ILDExEventAction.cpp index de7f1d1821d866c7e114f80319740fa5ee000f50..478b78d79f5db63fad4432509f5abdc189533e90 100644 --- a/DDExamples/ILDExSimu/src/ILDExEventAction.cpp +++ b/DDExamples/ILDExSimu/src/ILDExEventAction.cpp @@ -190,36 +190,38 @@ void ILDExEventAction::EndOfEventAction(const G4Event* evt) DD4hep::Geometry::VolumeManager::VolumeID volume_id = dynamic_cast<DD4hep::Simulation::Geant4Hit*>( hCol->GetHit(0) )->cellID ; - // std::cout << " looking up placed volume for id " << std::hex << volume_id << std::dec << std::endl ; + std::cout << " looking up placed volume for id " << std::hex << volume_id << std::dec << std::endl ; - const DD4hep::Geometry::PlacedVolume & pv = vm.lookupPlacement ( volume_id ) ; + if( volume_id ) { + const DD4hep::Geometry::PlacedVolume & pv = vm.lookupPlacement ( volume_id ) ; #if DEBUG - const DD4hep::Geometry::DetElement & detElem = vm.lookupDetElement( volume_id) ; - if ( detElem.isValid() ) - std::cout << " ILDExEventAction::EndOfEventAction --- for detector element : " << detElem.name() << std::endl ; - else - std::cout << " ILDExEventAction::EndOfEventAction --- detector element not found " << std::endl ; + const DD4hep::Geometry::DetElement & detElem = vm.lookupDetElement( volume_id) ; + if ( detElem.isValid() ) + std::cout << " ILDExEventAction::EndOfEventAction --- for detector element : " << detElem.name() << std::endl ; + else + std::cout << " ILDExEventAction::EndOfEventAction --- detector element not found " << std::endl ; #endif - if( pv.isValid() && pv.volume().isSensitive() ) { - - DD4hep::Geometry::Volume vol = pv.volume(); - DD4hep::Geometry::SensitiveDetector sd = vol.sensitiveDetector(); - DD4hep::Geometry::Readout ro = sd.readout(); - DD4hep::Geometry::IDDescriptor iddesc = ro.idSpec(); - + if( pv.isValid() && pv.volume().isSensitive() ) { + + DD4hep::Geometry::Volume vol = pv.volume(); + DD4hep::Geometry::SensitiveDetector sd = vol.sensitiveDetector(); + DD4hep::Geometry::Readout ro = sd.readout(); + DD4hep::Geometry::IDDescriptor iddesc = ro.idSpec(); + + + cellIDDesc = iddesc.fieldDescription() ; - cellIDDesc = iddesc.toString() ; + } else { - } else { + std::cout << " **** WARNING: could not get sensitive placedVolume for cellID : " << std::hex << volume_id << std::dec << std::endl ; + } - std::cout << " **** WARNING: could not get sensitive placedVolume for cellID : " << std::hex << volume_id << std::dec << std::endl ; } - if( isTracker ) { //----------------------------------------------------------------- lcio::LCCollectionVec* col = new lcio::LCCollectionVec( lcio::LCIO::SIMTRACKERHIT ) ;