diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index 00a0c56610f8af621342aa7413546ba57f5c8304..dcf8adf28878ab9485f0fb4b5ca0bfbb19af2147 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -81,7 +81,26 @@ namespace DD4hep { StepHandler h(step); HitContribution contrib = Hit::extractContribution(step); HitCollection* coll = collection(m_collectionID); - long long int cell = cellID(step); + long long int cell; + try { + cell = cellID(step); + } catch(std::runtime_error &e) { + std::stringstream out; + out << std::setprecision(20) << std::scientific; + out << "ERROR: " << e.what() << std::endl; + out << "Position: " + << "Pre (" << std::setw(24) << step->GetPreStepPoint()->GetPosition() << ") " + << "Post (" << std::setw(24) << step->GetPostStepPoint()->GetPosition() << ") " + << std::endl; + out << "Momentum: " + << " Pre (" <<std::setw(24) << step->GetPreStepPoint() ->GetMomentum() << ") " + << " Post (" <<std::setw(24) << step->GetPostStepPoint()->GetMomentum() << ") " + << std::endl; + + std::cout << out; + + return true; + } Hit* hit = coll->find<Hit>(CellIDCompare<Hit>(cell)); if ( h.totalEnergy() < std::numeric_limits<double>::epsilon() ) {