diff --git a/DDG4/examples/initAClick.C b/DDG4/examples/initAClick.C index f1b5f674d6f7c47ceafaa42b8793b21609593d17..56f0df96e97d82e7600791643d4fe3381097966f 100644 --- a/DDG4/examples/initAClick.C +++ b/DDG4/examples/initAClick.C @@ -3,12 +3,15 @@ #include <string> using namespace std; + string make_str(const char* data) { cout << "make_str: '" << (data ? data : "Bad-Pointer") << "'" << endl; return string(data); } void initAClick() { + string cwd = gSystem->WorkingDirectory(); + cout << "CWD:" << cwd << endl; string rootsys = make_str(gSystem->Getenv("ROOTSYS")); string g4_base = make_str(gSystem->Getenv("Geant4_DIR")); string dd4hep = make_str(gSystem->Getenv("DD4hep_DIR")); diff --git a/DDG4/examples/run.C b/DDG4/examples/run.C index d32535fc4174a45e51450b2b8aed6b5013259bdb..954995bec5d85c5c7f6a4fee055953c443270438 100644 --- a/DDG4/examples/run.C +++ b/DDG4/examples/run.C @@ -2,6 +2,7 @@ void run() { gInterpreter->ProcessLine(".X initAClick.C"); gInterpreter->ProcessLine(".L dictionaries.C+"); - gInterpreter->ProcessLine(".L xmlAClick.C+"); + //gInterpreter->ProcessLine(".L xmlAClick.C+"); + gInterpreter->ProcessLine(".L TEve.C+"); } diff --git a/DDG4/examples/sequences.xml b/DDG4/examples/sequences.xml index 363520c5a21b87ec1250f0f974e021f3824ec5df..06b2fc69debcc927f1e0d143678cd92491207ba4 100644 --- a/DDG4/examples/sequences.xml +++ b/DDG4/examples/sequences.xml @@ -12,7 +12,7 @@ -- -- To run batch: set UI="" --> - <kernel UI="UI" NumEvents="1"/> + <kernel UI="UI" NumEvents="5"/> <!-- List of globally known actions. These actions will be registered with the Geant4Kernel -- object and may be retrieved by there using the action name. @@ -23,20 +23,23 @@ --> <actions> <action name="Geant4TestRunAction/RunInit"> - <properties Property_int="12345" + <properties Control="true" + Property_int="12345" Property_double="-5e15" Property_string="Startrun: Hello_2"/> </action> <action name="Geant4TestEventAction/UserEvent_2"> - <properties Property_int="1234" + <properties Control="true" + Property_int="1234" Property_double="5e15" Property_string="Hello_2"/> - </action> + </action> <!-- UI handler initializing vis and ui. NAME IS FIXED/COMMON KNOWLEDGE --> <action name="Geant4UIManager/UI"> - <properties HaveVIS="1" + <properties HaveVIS="0" HaveUI="1" + SetupUI="run.mac" SessionType="csh"/> </action> <!-- void and empty for the time being.... NAME IS FIXED/COMMON KNOWLEDGE --> @@ -54,7 +57,8 @@ <phase type="RunAction/begin"> <action name="RunInit"/> <action name="Geant4TestRunAction/UserRunInit"> - <properties Property_int="1234" + <properties Conrol="true" + Property_int="1234" Property_double="5e15" Property_string="'Hello_2'"/> </action> @@ -79,13 +83,13 @@ <filters> <filter name="GeantinoRejectFilter/GeantinoRejector"/> <filter name="ParticleRejectFilter/OpticalPhotonRejector"> - <properties particle="opticalphoton"/> + <properties particle="opticalphoton" Control="true"/> </filter> <filter name="ParticleSelectFilter/OpticalPhotonSelector"> - <properties particle="opticalphoton"/> + <properties particle="opticalphoton" Control="true"/> </filter> <filter name="EnergyDepositMinimumCut"> - <properties Cut="10*keV"/> + <properties Cut="10*keV" Control="true"/> </filter> </filters> @@ -97,31 +101,38 @@ --> <sequences> <sequence name="Geant4EventActionSequence/EventAction"> + <properties Control="true"/> <action name="Geant4TestEventAction/UserEvent_1"> - <properties Property_int="01234" + <properties Control="true" + Property_int="01234" Property_double="1e11" Property_string="'Hello_1'"/> </action> <action name="UserEvent_2"/> <action name="Geant4Output2ROOT/RootOutput"> - <properties Output="simple.root"/> + <properties Control="true" Output="simple.root"/> </action> <action name="Geant4Output2LCIO/LCIOOutput"> - <properties Output="simple_lcio"/> + <properties Control="true" Output="simple_lcio"/> </action> </sequence> <sequence name="Geant4GeneratorActionSequence/GeneratorAction"> <action name="Geant4ParticleGun/Gun"> - <properties energy="500*MeV" + <properties Control="true" + energy="500*MeV" particle="'e-'" - multiplicity="1"/> + multiplicity="1" + direction="(1,1,1)"/> </action> </sequence> <sequence sd="SiVertexBarrel" type="Geant4SensDetActionSequence"> + <properties Control="true"/> <filter name="GeantinoRejector"/> <filter name="EnergyDepositMinimumCut"/> - <action name="Geant4SimpleTrackerAction/SiVertexBarrelHandler"/> + <action name="Geant4SimpleTrackerAction/SiVertexBarrelHandler"> + <properties Control="true"/> + </action> </sequence> <sequence sd="SiVertexEndcap" type="Geant4SensDetActionSequence"> <filter name="GeantinoRejector"/> @@ -134,9 +145,11 @@ <action name="Geant4SimpleTrackerAction/SiTrackerBarrelHandler"/> </sequence> <sequence sd="SiTrackerEndcap" type="Geant4SensDetActionSequence"> + <properties Control="true"/> <action name="Geant4SimpleTrackerAction/SiTrackerEndcapHandler"/> </sequence> <sequence sd="SiTrackerForward" type="Geant4SensDetActionSequence"> + <properties Control="true"/> <action name="Geant4SimpleTrackerAction/SiTrackerForwardHandler"/> </sequence> <sequence sd="EcalBarrel" type="Geant4SensDetActionSequence"> @@ -146,10 +159,13 @@ <action name="Geant4SimpleCalorimeterAction/EcalEndCapHandler"/> </sequence> <sequence sd="HcalBarrel" type="Geant4SensDetActionSequence"> + <properties Control="true"/> <action name="Geant4SimpleCalorimeterAction/HcalBarrelHandler"> + <properties Control="true"/> <filter name="OpticalPhotonRejector"/> </action> <action name="Geant4SimpleOpticalCalorimeterAction/HcalBarrelHandler"> + <properties Control="true"/> <filter name="OpticalPhotonSelector"/> </action> </sequence> diff --git a/DDG4/g4gdmlDisplay.cpp b/DDG4/g4gdmlDisplay.cpp index 130940f6e7adcc79c1a79d1250d0853113d89bbf..ea97f3615b49f144a8e0b4fcfabe14d360b5599a 100644 --- a/DDG4/g4gdmlDisplay.cpp +++ b/DDG4/g4gdmlDisplay.cpp @@ -1,7 +1,7 @@ //#define G4UI_USE //#define G4VIS_USE //#define G4INTY_USE_XT -#define G4VIS_USE_OPENGL +//#define G4VIS_USE_OPENGL //#define G4UI_USE_TCSH #include "G4PVPlacement.hh" diff --git a/DDG4/legacy/Geant4TrackerSD.cpp b/DDG4/legacy/Geant4TrackerSD.cpp index 81a1e1811e8d316bf4c4d79a8ae18cf1637610ca..1617cecb02dc07fd3cc42a309beea215b4544434 100644 --- a/DDG4/legacy/Geant4TrackerSD.cpp +++ b/DDG4/legacy/Geant4TrackerSD.cpp @@ -13,6 +13,9 @@ #include "DDG4/Geant4Mapping.h" //#include "DDSegmentation/BitField64.h" +// C include files +#include <stdexcept> + /* * DD4hep::Simulation namespace declaration */ @@ -43,18 +46,18 @@ namespace DD4hep { namespace Simulation { h.track->GetDefinition()->GetPDGEncoding(), step->GetTotalEnergyDeposit(), h.track->GetGlobalTime()); - - HitContribution contrib = Geant4Hit::extractContribution(step); - - hit->cellID = getVolumeID( step ) ; - hit->energyDeposit = contrib.deposit ; - - hit->position = position; - hit->momentum = direction; - hit->length = hit_len; - collection(0)->insert(hit); - return hit != 0; + if ( hit ) { + HitContribution contrib = Geant4Hit::extractContribution(step); + hit->cellID = getVolumeID( step ) ; + hit->energyDeposit = contrib.deposit ; + hit->position = position; + hit->momentum = direction; + hit->length = hit_len; + collection(0)->insert(hit); + return 1; + } + throw std::runtime_error("new() failed: Cannot allocate hit object"); } typedef Geant4GenericSD<Tracker> Geant4Tracker; }} // End namespace DD4hep::Simulation diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index 02929b0a0e77cdcc7c77a674d1976be445f55d58..b6cb6af0c9d312cae0bc76e3ba927ee4f36c68db 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -138,16 +138,18 @@ namespace DD4hep { h.track->GetDefinition()->GetPDGEncoding(), step->GetTotalEnergyDeposit(), h.track->GetGlobalTime()); - - HitContribution contrib = Hit::extractContribution(step); - hit->cellID = volumeID( step ) ; - hit->energyDeposit = contrib.deposit ; - hit->position = position; - hit->momentum = direction; - hit->length = hit_len; - collection(m_collectionID)->add(hit); - mcTruthMgr().mark(h.track,true); - return hit != 0; + if ( hit ) { + HitContribution contrib = Hit::extractContribution(step); + hit->cellID = volumeID( step ) ; + hit->energyDeposit = contrib.deposit ; + hit->position = position; + hit->momentum = direction; + hit->length = hit_len; + collection(m_collectionID)->add(hit); + mcTruthMgr().mark(h.track,true); + return true; + } + throw std::runtime_error("new() failed: Cannot allocate hit object"); } typedef Geant4SensitiveAction<SimpleTracker> Geant4SimpleTrackerAction; diff --git a/DDG4/plugins/Geant4XMLSetup.cpp b/DDG4/plugins/Geant4XMLSetup.cpp index fa182a966ac00a2f3501e2dc951446c2340740be..f854df4c736fce29fb6a35c2633ecfaada899d3c 100644 --- a/DDG4/plugins/Geant4XMLSetup.cpp +++ b/DDG4/plugins/Geant4XMLSetup.cpp @@ -31,6 +31,10 @@ namespace DD4hep { template <typename TYPE, typename PTR> TYPE* _action(PTR* in) { return dynamic_cast<TYPE*>(in); } + template <typename T> static void installMessenger(const T& handle) { + handle->installMessengers(); + } + template <typename T> static void _setAttributes(const T& handle, xml_h& e) { XML::Handle_t props(e); // Now we set the object properties @@ -47,6 +51,9 @@ namespace DD4hep { if ( props ) { _setAttributes(handle, props); } + if ( action.hasAttr(_Unicode(Control)) ) { + handle["Control"].str(props.attr<string>(_Unicode(Control))); + } } static Action _convertSensitive(LCDD& lcdd, xml_h e, const string& detector) { @@ -59,10 +66,9 @@ namespace DD4hep { for(xml_coll_t f(e,_Unicode(filter)); f; ++f) { string nam = f.attr<string>(_U(name)); Filter filter(kernel.globalFilter(nam,false)); - filter->installMessengers(); handle->adopt(filter); } - handle->installMessengers(); + installMessenger(handle); printout(INFO,"Geant4Setup","+++ Added sensitive element %s of type %s", tn.second.c_str(),tn.first.c_str()); return Action(handle); @@ -76,9 +82,10 @@ namespace DD4hep { Action handle(kernel,action.attr<string>(_U(name))); _setProperties(handle,e); printout(INFO,"Geant4Setup","+++ Added action %s of type %s",tn.second.c_str(),tn.first.c_str()); - handle->installMessengers(); + installMessenger(handle); return handle; } + enum { SENSITIVE, ACTION, FILTER }; Action _createAction(LCDD& lcdd, xml_h a, const std::string& seqType, int what) { string nam = a.attr<string>(_U(name)); @@ -303,7 +310,7 @@ namespace DD4hep { for(xml_coll_t a(seq,_Unicode(filter)); a; ++a) { string nam = a.attr<string>(_U(name)); Action action(_createAction(lcdd,a,"",FILTER)); - action->installMessengers(); + installMessenger(action); printout(INFO,"Geant4Setup","+++ ActionSequence %s added filter object:%s", seqType.second.c_str(),action->name().c_str()); if ( sdSeq.get() ) diff --git a/DDG4/src/ComponentProperties.cpp b/DDG4/src/ComponentProperties.cpp index 816fc35db4f55622e50f9f60fc71c6054ccd5de8..00e5d3ee85ea330048df60c8723ccd15bd56987d 100644 --- a/DDG4/src/ComponentProperties.cpp +++ b/DDG4/src/ComponentProperties.cpp @@ -55,8 +55,10 @@ Property::Property(const Property& property) /// Assignment operator Property& Property::operator=(const Property& property) { - m_par = property.m_par; - m_hdl = property.m_hdl; + if ( &property != this ) { + m_par = property.m_par; + m_hdl = property.m_hdl; + } return *this; } diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index d09f88eb0db555907294864dcd7042a319ceed66..cb7f8ae0352c325a3a6fe9d99e2a940633d86fd2 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -535,8 +535,8 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) node->GetName(), node->IsA()->GetName(), vol); } else if (0 == vol) { - printout(FATAL, "Geant4Converter", "++ Unknown G4 volume:%p %s of type %s vol:%s ptr:%p", node, node->GetName(), - node->IsA()->GetName(), vol->IsA()->GetName(), vol); + printout(FATAL, "Geant4Converter", "++ Unknown G4 volume:%p %s of type %s ptr:%p", node, node->GetName(), + node->IsA()->GetName(), vol); } else { int copy = node->GetNumber(); @@ -561,6 +561,9 @@ 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 ) { + throw logic_error("Geant4Converter: Invalid mother volume found!"); + } else if (daughter_is_assembly) { printout(DEBUG, "Geant4Converter", "++ Assembly: makeImprint: %16p dau:%s " "Tr:x=%8.3f y=%8.3f z=%8.3f Rot:phi=%7.3f theta=%7.3f psi=%7.3f\n", ass_dau, @@ -570,6 +573,7 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) AssemblyChildMap::iterator i = info.g4AssemblyChildren.find(ass_dau); if (i == info.g4AssemblyChildren.end()) { printout(ERROR, "Geant4Converter", "++ Non-existing assembly [%p]", ass_dau); + throw logic_error("Geant4Converter: Dealing with invalid daughter assembly!"); } const AssemblyChildren& v = (*i).second; ass_dau->imprint(phys_volumes, g4mot, transform, copy, m_checkOverlaps); @@ -684,8 +688,10 @@ void* Geant4Converter::handleSensitive(const TNamed* sens_det, const set<const T if (!g4) { PluginDebug dbg; g4 = ROOT::Reflex::PluginService::Create<G4VSensitiveDetector*>(type, name, &m_lcdd); - throw runtime_error("Geant4Converter<SensitiveDetector>: FATAL Failed to " - "create Geant4 sensitive detector factory " + name + " of type " + type + "."); + if ( !g4 ) { + throw runtime_error("Geant4Converter<SensitiveDetector>: FATAL Failed to " + "create Geant4 sensitive detector factory " + name + " of type " + type + "."); + } } } g4->Activate(true); @@ -737,7 +743,7 @@ void Geant4Converter::handleProperties(LCDD::Properties& prp) const { } else { char txt[32]; - ::sprintf(txt, "%d", ++s_idd); + ::snprintf(txt, sizeof(txt), "%d", ++s_idd); id = txt; } processors.insert(make_pair(id, nam)); @@ -816,9 +822,9 @@ void* Geant4Converter::printPlacement(const string& name, const TGeoNode* node) G4ThreeVector tr = g4->GetObjectTranslation(); G4VSensitiveDetector* sd = vol->GetSensitiveDetector(); - if (!sd) + if (!sd) { return g4; - + } stringstream str; str << "G4Cnv::placement: + " << name << " No:" << node->GetNumber() << " Vol:" << vol->GetName() << " Solid:" << sol->GetName(); @@ -832,7 +838,7 @@ void* Geant4Converter::printPlacement(const string& name, const TGeoNode* node) << " Mother:" << (char*) (mot ? mot->GetName().c_str() : "---"); printout(DEBUG, "G4Placement", str.str().c_str()); str.str(""); - str << " |" << " SD:" << (char*) (sd ? sd->GetName().c_str() : "---"); + str << " |" << " SD:" << sd->GetName(); printout(DEBUG, "G4Placement", str.str().c_str()); return g4; } diff --git a/DDG4/src/Geant4Data.cpp b/DDG4/src/Geant4Data.cpp index e20c0a2b22cd82b421cb5e1c9866ea23d970b91e..5f08fbe82188371dd18ed5b3082ce31db037943a 100644 --- a/DDG4/src/Geant4Data.cpp +++ b/DDG4/src/Geant4Data.cpp @@ -64,13 +64,13 @@ SimpleHit::Contribution SimpleHit::extractContribution(G4Step* step) { /// Default constructor SimpleTracker::Hit::Hit() - : SimpleHit(), position(), momentum(), length(0.0), truth() { + : SimpleHit(), position(), momentum(), length(0.0), truth(), energyDeposit(0.0) { InstanceCount::increment(this); } /// Standard initializing constructor SimpleTracker::Hit::Hit(int track_id, int pdg_id, double deposit, double time_stamp) - : SimpleHit(), position(), momentum(), length(0.0), truth(track_id, pdg_id, deposit, time_stamp) { + : SimpleHit(), position(), momentum(), length(0.0), truth(track_id, pdg_id, deposit, time_stamp), energyDeposit(deposit) { InstanceCount::increment(this); } @@ -81,10 +81,12 @@ SimpleTracker::Hit::~Hit() { /// Assignment operator SimpleTracker::Hit& SimpleTracker::Hit::operator=(const Hit& c) { - position = c.position; - momentum = c.momentum; - length = c.length; - truth = c.truth; + if ( &c != this ) { + position = c.position; + momentum = c.momentum; + length = c.length; + truth = c.truth; + } return *this; } diff --git a/DDG4/src/Geant4Handle.cpp b/DDG4/src/Geant4Handle.cpp index 8b0c31939b073b45722dbbb350e8d3264c707f5f..69bb7c98356991d01bafc8aa77a1b1969bcf3779 100644 --- a/DDG4/src/Geant4Handle.cpp +++ b/DDG4/src/Geant4Handle.cpp @@ -133,20 +133,20 @@ template <typename TYPE> Geant4Action* Geant4Handle<TYPE>::action() const { } template <typename TYPE> Geant4Handle<TYPE>& Geant4Handle<TYPE>::operator=(const Geant4Handle& handle) { - if (value) - value->release(); - value = handle.get(); - if (value) - value->addRef(); + if ( &handle != this ) { + if (value) value->release(); + value = handle.get(); + if (value) value->addRef(); + } return *this; } template <typename TYPE> Geant4Handle<TYPE>& Geant4Handle<TYPE>::operator=(TYPE* typ) { - if (value) - value->release(); - value = typ; - if (value) - value->addRef(); + if ( typ != value ) { + if (value) value->release(); + value = typ; + if (value) value->addRef(); + } return *this; } diff --git a/DDG4/src/Geant4HierarchyDump.cpp b/DDG4/src/Geant4HierarchyDump.cpp index eaf7427dbaa083386935d207d253180fadf7eea9..eccd587e1a4d9953fad2e046b387fea9f010b1f5 100644 --- a/DDG4/src/Geant4HierarchyDump.cpp +++ b/DDG4/src/Geant4HierarchyDump.cpp @@ -120,7 +120,7 @@ void Geant4HierarchyDump::dump(const string& indent, const G4VPhysicalVolume* v) printout(INFO, "Geant4Hierarchy", "%s Limits:%s ", indent.c_str(), _T(ul->GetType())); } for (G4int idau = 0; idau < ndau; ++idau) { - ::sprintf(text, " %-3d", idau); + ::snprintf(text, sizeof(text), " %-3d", idau); dump(indent + text, lv->GetDaughter(idau)); } } diff --git a/DDG4/src/Geant4Hits.cpp b/DDG4/src/Geant4Hits.cpp index 41526b79b0d362d19a486c123217e0c1af6df37c..8c50f3a243824bc93211fc335b8380312d03c2ca 100644 --- a/DDG4/src/Geant4Hits.cpp +++ b/DDG4/src/Geant4Hits.cpp @@ -49,20 +49,23 @@ static G4Allocator<Geant4TrackerHit> TrackerHitAllocator; /// Default constructor Geant4TrackerHit::Geant4TrackerHit() - : Geant4Hit(), position(), momentum(), length(0.0), truth() { + : Geant4Hit(), position(), momentum(), length(0.0), truth(), energyDeposit(0.0) { } /// Standard initializing constructor Geant4TrackerHit::Geant4TrackerHit(int track_id, int pdg_id, double deposit, double time_stamp) - : Geant4Hit(), position(), momentum(), length(0.0), truth(track_id, pdg_id, deposit, time_stamp) { + : Geant4Hit(), position(), momentum(), length(0.0), truth(track_id, pdg_id, deposit, time_stamp), energyDeposit(deposit) { } /// Assignment operator Geant4TrackerHit& Geant4TrackerHit::operator=(const Geant4TrackerHit& c) { - position = c.position; - momentum = c.momentum; - length = c.length; - truth = c.truth; + if ( this != &c ) { + position = c.position; + momentum = c.momentum; + length = c.length; + truth = c.truth; + energyDeposit = c.energyDeposit; + } return *this; } @@ -72,6 +75,7 @@ Geant4TrackerHit& Geant4TrackerHit::clear() { momentum.SetXYZ(0, 0, 0); length = 0.0; truth.clear(); + energyDeposit = 0.0; return *this; } @@ -85,6 +89,7 @@ Geant4TrackerHit& Geant4TrackerHit::storePoint(G4Step* step, G4StepPoint* pnt) { truth.pdgID = trk->GetDefinition()->GetPDGEncoding(); truth.deposit = step->GetTotalEnergyDeposit(); truth.time = trk->GetGlobalTime(); + energyDeposit = step->GetTotalEnergyDeposit(); position.SetXYZ(pos.x(), pos.y(), pos.z()); momentum.SetXYZ(mom.x(), mom.y(), mom.z()); length = 0; diff --git a/DDG4/src/Geant4PhysicsList.cpp b/DDG4/src/Geant4PhysicsList.cpp index c7a428887875458551c44c7307b4dddab70f4c71..be1c0dbaea7ed5ca85080ead84478f3535e5957a 100644 --- a/DDG4/src/Geant4PhysicsList.cpp +++ b/DDG4/src/Geant4PhysicsList.cpp @@ -79,10 +79,12 @@ Geant4PhysicsList::Process::Process(const Process& p) /// Assignment operator Geant4PhysicsList::Process& Geant4PhysicsList::Process::operator=(const Process& p) { - name = p.name; - ordAtRestDoIt = p.ordAtRestDoIt; - ordAlongSteptDoIt = p.ordAlongSteptDoIt; - ordPostStepDoIt = p.ordPostStepDoIt; + if ( this != &p ) { + name = p.name; + ordAtRestDoIt = p.ordAtRestDoIt; + ordAlongSteptDoIt = p.ordAlongSteptDoIt; + ordPostStepDoIt = p.ordPostStepDoIt; + } return *this; } diff --git a/DDG4/src/Geant4TrackPersistency.cpp b/DDG4/src/Geant4TrackPersistency.cpp index 91edb34f68780e5481ef876dd7fc2dfd53358536..086c7144cd8fa8faf9d31857fa7d018540202e67 100644 --- a/DDG4/src/Geant4TrackPersistency.cpp +++ b/DDG4/src/Geant4TrackPersistency.cpp @@ -144,22 +144,22 @@ bool cleanTree(Geant4TrackPersistency* p, const string& proc, Track* trk) { if ( remove ) { string pnam = trk->process ? trk->process->GetProcessName().c_str() : "---"; - if ( remove || pnam == proc ) { + //if ( pnam == proc ) { bool keep = keepTrackTree(proc,trk); if ( !keep ) { releaseTrack(p,trk); return true; } - } + //} } return false; } void printTree(const Track* trk,const char* msg, int cnt) { char text[64]; - ::sprintf(text," %-8d | ",cnt); + ::snprintf(text,sizeof(text)," %-8d | ",cnt); printf(" %-6d ",cnt); - ::sprintf(text,"| "); + ::snprintf(text,sizeof(text),"| "); std::string m(text); m += msg; printTrack(trk, 1, msg); @@ -197,7 +197,7 @@ void printSecondaries(const Track* trk) { char text[256]; int ndau = 1; for(TrackMap2::const_iterator j=trk->secondaries.begin(); j!=trk->secondaries.end(); ++j, ++ndau) { - ::sprintf(text," ---> Daughter [%3d]",ndau); + ::snprintf(text,sizeof(text)," ---> Daughter [%3d]",ndau); ::printTrack((*j).second,2,text); } } @@ -205,7 +205,7 @@ void printParents(const Track* trk) { char text[256]; int npar = 1; for(Track* p=trk->parent; p; p=p->parent, ++npar) { - ::sprintf(text," ---> Parent [%3d]",npar); + ::snprintf(text,sizeof(text)," ---> Parent [%3d]",npar); printTrack(p,4,text); } } @@ -295,6 +295,7 @@ void deleteTrackTree(Track* trk) { /// Standard constructor Geant4TrackPersistency::TrackInfo::TrackInfo() : G4VUserTrackInformation() { + this->info = 0; this->manager = 0; this->track = 0; this->store = false; diff --git a/DDG4/src/Geant4TrackingPostAction.cpp b/DDG4/src/Geant4TrackingPostAction.cpp index 1967542596b267391d97b2153c3de2375464a260..21288755aa7ee9c718e7d0709406fcb5a2b5f318 100644 --- a/DDG4/src/Geant4TrackingPostAction.cpp +++ b/DDG4/src/Geant4TrackingPostAction.cpp @@ -38,8 +38,9 @@ struct FindString { Geant4TrackingPostAction::Geant4TrackingPostAction(Geant4Context* context, const std::string& name) : Geant4TrackingAction(context, name) { InstanceCount::increment(this); - declareProperty("IgnoredProcesses", m_ignoredProcs); + declareProperty("IgnoredProcesses", m_ignoredProcs); declareProperty("RequiredProcesses", m_requiredProcs); + declareProperty("StoreMarkedTracks", m_storeMarkedTracks=true); } /// Default destructor diff --git a/DDG4/src/Geant4UIManager.cpp b/DDG4/src/Geant4UIManager.cpp index 28a4723fb5c3dc030287f80641a6c17229c4d88b..1c6990872e2b64a67f6e54a788ada6ed3638f73c 100644 --- a/DDG4/src/Geant4UIManager.cpp +++ b/DDG4/src/Geant4UIManager.cpp @@ -67,7 +67,8 @@ void Geant4UIManager::start() { // Start visualization if ( m_haveVis || !m_visSetup.empty() ) { m_vis = startVis(); - m_haveUI = true; // No graphics without UI! + m_haveVis = true; // If graphics setup, vis is always true + m_haveUI = true; // No graphics without UI! } // Start UI instance if ( m_haveUI || !m_uiSetup.empty() ) { @@ -86,7 +87,7 @@ void Geant4UIManager::start() { printout(INFO,"Geant4UIManager","++ Executed UI setup:%s",m_uiSetup.c_str()); } // Start UI session if present - if ( m_ui ) { + if ( m_haveUI && m_ui ) { m_ui->SessionStart(); return; }