From 01e107e38eb01c95d3228c9cd73ecc14a0284368 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Mon, 16 Jun 2014 14:52:28 +0000 Subject: [PATCH] - some debug printout for surfaces - protect against missing collections in test_surfaces --- DDRec/src/Surface.cpp | 18 +++++++++--------- DDRec/src/SurfaceManager.cpp | 19 +++++++++++++++++++ examples/ILDExSimu/src/test_surfaces.cc | 22 +++++++++++++++++----- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/DDRec/src/Surface.cpp b/DDRec/src/Surface.cpp index 885dfbfd2..18df477fb 100644 --- a/DDRec/src/Surface.cpp +++ b/DDRec/src/Surface.cpp @@ -254,13 +254,13 @@ namespace DD4hep { volList.push_back( pv ) ; - // unsigned count = volList.size() ; - // for(unsigned i=0 ; i < count ; ++i) { - // std::cout << " **" ; - // } - // std::cout << " searching for volume: " << theVol.name() << " " << std::hex << theVol.ptr() << " <-> pv.volume : " << pv.name() << " " << pv.volume().ptr() - // << " pv.volume().ptr() == theVol.ptr() " << (pv.volume().ptr() == theVol.ptr() ) - // << std::endl ; + // unsigned count = volList.size() ; + // for(unsigned i=0 ; i < count ; ++i) { + // std::cout << " **" ; + // } + // std::cout << " searching for volume: " << theVol.name() << " " << std::hex << theVol.ptr() << " <-> pv.volume : " << pv.name() << " " << pv.volume().ptr() + // << " pv.volume().ptr() == theVol.ptr() " << (pv.volume().ptr() == theVol.ptr() ) + // << std::endl ; if( pv.volume().ptr() == theVol.ptr() ) { @@ -421,8 +421,8 @@ namespace DD4hep { Volume theVol = _volSurf.volume() ; if( ! findVolume( pv, theVol , pVList ) ){ - - throw std::runtime_error( " ***** ERROR: No Volume found for DetElement with surface " ) ; + std::stringstream sst ; sst << " ***** ERROR: Volume " << theVol.name() << " not found for DetElement " << _det.name() << " with surface " ; + throw std::runtime_error( sst.str() ) ; } // std::cout << " **** Surface::initialize() # placements for surface = " << pVList.size() diff --git a/DDRec/src/SurfaceManager.cpp b/DDRec/src/SurfaceManager.cpp index 80c24bb2e..2677aad9a 100644 --- a/DDRec/src/SurfaceManager.cpp +++ b/DDRec/src/SurfaceManager.cpp @@ -58,11 +58,30 @@ namespace DD4hep { DetElement det = (*li) ; + + // create surfaces DetectorSurfaces ds( det ) ; const SurfaceList& detSL = ds.surfaceList() ; + + // // ---------------------- debug printout + // std::cout << " ---- DetElement id: " << det.volumeID() << " name : " << det.name() << " #surfaces : " << detSL.size() << std::endl ; + // PlacedVolume pv = det.placement() ; + // if( pv.isValid() ) { + // try{ // needed as above is also true for world whcih has invalid placment ... + // PlacedVolume::VolIDs volIDs = pv.volIDs() ; + // for(unsigned i=0,n=volIDs.size(); i<n ; ++i){ + // std::cout << " " << volIDs[i].first << " : " << volIDs[i].second << std::endl ; + // } + // }catch(...){} + // }else{ + // std::cout << " invalid placement for DetElement ??? !! " << std::endl ; + // } + // // ------------------------- end debug printout + + // and add copy them to this list _sL.insert( _sL.end(), detSL.begin(), detSL.end() ); } diff --git a/examples/ILDExSimu/src/test_surfaces.cc b/examples/ILDExSimu/src/test_surfaces.cc index 8ebd76d13..d70b9e2d6 100644 --- a/examples/ILDExSimu/src/test_surfaces.cc +++ b/examples/ILDExSimu/src/test_surfaces.cc @@ -60,9 +60,9 @@ int main(int argc, char** argv ){ Surface* surf = *it ; // std::cout << " ------------------------- " - // << " surface: " << *surf << std::endl - // << " ------------------------- " << std::endl ; - + // << " surface: " << *surf << std::endl + // << " ------------------------- " << std::endl ; + surfMap[ surf->id() ] = surf ; @@ -84,15 +84,27 @@ int main(int argc, char** argv ){ std::vector< std::string > colNames ; colNames.push_back( "VXDCollection" ) ; - // colNames.push_back( "SITCollection" ) ; + colNames.push_back( "SITCollection" ) ; + colNames.push_back( "SETCollection" ) ; + colNames.push_back( "FTDCollection" ) ; + colNames.push_back( "TPCCollection" ) ; while( ( evt = rdr->readNextEvent() ) != 0 ){ for(unsigned icol=0, ncol = colNames.size() ; icol < ncol ; ++icol ){ - LCCollection* col = evt->getCollection( colNames[ icol ] ) ; + + LCCollection* col = 0 ; + try{ + + col = evt->getCollection( colNames[ icol ] ) ; + + }catch(lcio::DataNotAvailableException&e){ + std::cout << " --- collection : " << colNames[ icol ] << " not in event ... " << std::endl ; + continue ; + } int nHit = col->getNumberOfElements() ; -- GitLab