diff --git a/DDG4/examples/run.C b/DDG4/examples/run.C index 954995bec5d85c5c7f6a4fee055953c443270438..ecf14ab7440794a66ddaf7360166eb506ce77293 100644 --- a/DDG4/examples/run.C +++ b/DDG4/examples/run.C @@ -2,7 +2,8 @@ void run() { gInterpreter->ProcessLine(".X initAClick.C"); gInterpreter->ProcessLine(".L dictionaries.C+"); - //gInterpreter->ProcessLine(".L xmlAClick.C+"); - gInterpreter->ProcessLine(".L TEve.C+"); + //gInterpreter->ProcessLine(".L exampleAClick.C+"); + gInterpreter->ProcessLine(".L xmlAClick.C+"); + //gInterpreter->ProcessLine(".L TEve.C+"); } diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index b6cb6af0c9d312cae0bc76e3ba927ee4f36c68db..66a74f1ed41c2c37524b71cb48a6da5f14aa56c4 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -12,6 +12,8 @@ #include "DDG4/Geant4Data.h" #include "DD4hep/Printout.h" +using namespace std; + /* * DD4hep namespace declaration */ @@ -29,7 +31,7 @@ namespace DD4hep { public: typedef SimpleHit::Contribution HitContribution; /// Standard , initializing constructor - Geant4SensitiveAction(Geant4Context* context, const std::string& name, DetElement det, LCDD& lcdd); + Geant4SensitiveAction(Geant4Context* context, const string& name, DetElement det, LCDD& lcdd); /// Default destructor virtual ~Geant4SensitiveAction(); /// Define collections created by this sensitivie action object @@ -53,7 +55,7 @@ namespace DD4hep { /// Standard , initializing constructor template <typename T> Geant4SensitiveAction<T>::Geant4SensitiveAction(Geant4Context* context, - const std::string& name, + const string& name, DetElement det, LCDD& lcdd) : Geant4Sensitive(context,name,det,lcdd), m_collectionID(0) @@ -147,9 +149,13 @@ namespace DD4hep { hit->length = hit_len; collection(m_collectionID)->add(hit); mcTruthMgr().mark(h.track,true); + if ( 0 == hit->cellID ) { + hit->cellID = volumeID( step ) ; + throw runtime_error("Invalid CELL ID for hit!"); + } return true; } - throw std::runtime_error("new() failed: Cannot allocate hit object"); + throw runtime_error("new() failed: Cannot allocate hit object"); } typedef Geant4SensitiveAction<SimpleTracker> Geant4SimpleTrackerAction; @@ -175,6 +181,10 @@ namespace DD4hep { coll->add(hit) ; printout(DEBUG,"SimpleTracker","%s> CREATE hit with deposit:%f Pos:%f %f %f", c_name(),contrib.deposit,pos.X(),pos.Y(),pos.Z()); + if ( 0 == hit->cellID ) { + hit->cellID = volumeID( step ) ; + throw runtime_error("Invalid CELL ID for hit!"); + } } else { printout(DEBUG,"SimpleTracker","%s> UPDATE hit with deposit:%f Pos:%f %f %f", @@ -214,8 +224,13 @@ namespace DD4hep { Position pos = h.prePos(); Hit* hit = coll->find<Hit>(PositionCompare<Hit>(pos)); if ( !hit ) { - hit=new Hit(pos); + hit = new Hit(pos); + hit->cellID = volumeID( step ) ; coll->add(hit); + if ( 0 == hit->cellID ) { + hit->cellID = volumeID( step ) ; + throw runtime_error("Invalid CELL ID for hit!"); + } } hit->energyDeposit += contrib.deposit; hit->truth.push_back(contrib); diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index cb7f8ae0352c325a3a6fe9d99e2a940633d86fd2..1f081bebbc23cb8063dd9fcae456bc239b40c240 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -35,6 +35,7 @@ #include "TGeoParaboloid.h" #include "TGeoCompositeShape.h" #include "TGeoShapeAssembly.h" +#include "TGeoManager.h" #include "TClass.h" #include "TMath.h" @@ -561,7 +562,7 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) info.g4AssemblyChildren[ass_mot].push_back(make_pair(id, node)); return 0; } - else if ( 0 == g4mot ) { + else if ( node != gGeoManager->GetTopNode() && 0 == g4mot ) { throw logic_error("Geant4Converter: Invalid mother volume found!"); } else if (daughter_is_assembly) { diff --git a/DDG4/src/Geant4VolumeManager.cpp b/DDG4/src/Geant4VolumeManager.cpp index 20f141854ff6cd82b88f8984198e652eb6730cbb..e110fce841e64f829fd193aee297eec71e011559 100644 --- a/DDG4/src/Geant4VolumeManager.cpp +++ b/DDG4/src/Geant4VolumeManager.cpp @@ -86,7 +86,8 @@ namespace { } for (Int_t idau = 0, ndau = node->GetNdaughters(); idau < ndau; ++idau) { TGeoNode* daughter = node->GetDaughter(idau); - if (dynamic_cast<const PlacedVolume::Object*>(daughter)) { + PlacedVolume placement(daughter); + if ( placement.data() ) { scanPhysicalVolume(daughter, ids, sd, chain); } }