Print

Print


Commit in slic on MAIN
src/LcioMcpFactory.cc+17-151.3 -> 1.4
include/LcioMcpFactory.hh+6-41.3 -> 1.4
+23-19
2 modified files
Use a local variable to set current G4TrajectoryContainer.  createFinalCollection() changed to take a G4Event pointer instead of no arguments.

slic/src
LcioMcpFactory.cc 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- LcioMcpFactory.cc	21 Sep 2005 00:14:25 -0000	1.3
+++ LcioMcpFactory.cc	21 Sep 2005 22:14:59 -0000	1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpFactory.cc,v 1.3 2005/09/21 00:14:25 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpFactory.cc,v 1.4 2005/09/21 22:14:59 jeremy Exp $
 #include "LcioMcpFactory.hh"
 
 // slic
@@ -12,6 +12,7 @@
 
 // geant4
 #include "globals.hh"
+#include "G4Event.hh"
 #include "G4EventManager.hh"
 #include "G4TrajectoryContainer.hh"
 
@@ -29,6 +30,8 @@
 {
 
   LcioMcpFactory::LcioMcpFactory(LcioMcpManager* manager)
+    : m_finalColl(0),
+      m_currentTrajectoryContainer(0)
   {
     m_manager = manager;
   }
@@ -36,7 +39,7 @@
   LcioMcpFactory::~LcioMcpFactory()
   {}
 
-  void LcioMcpFactory::createFinalMcpCollection()
+  void LcioMcpFactory::createFinalMcpCollection(const G4Event* event)
   {
     // new coll for final Mcps
     m_finalColl = static_cast<LCCollectionVec*>(m_manager->getFinalMcpCollection());
@@ -50,10 +53,11 @@
     // G4 source using traj only
     else {
 
+      /* Set current G4TrajectoryContainer */
+      m_currentTrajectoryContainer = event->GetTrajectoryContainer();
+
       /* Create from trj cont of current G4Event, only. */
-      createFinalMcpCollectionFromTrajectoryContainer(G4EventManager::GetEventManager()
-						      ->GetNonconstCurrentEvent()
-						      ->GetTrajectoryContainer() );
+      createFinalMcpCollectionFromTrajectoryContainer( m_currentTrajectoryContainer );
     }
 
     /* Fill supplementary collection storing Mcp endpoint energies. */
@@ -227,11 +231,10 @@
     LcioMcpStatusSetter::setGeneratorStatus( mcpInit, mcp );
 
     // loop over all trajectories to find trajectory daughter
-    G4TrajectoryContainer* trjCont = G4EventManager::GetEventManager()->GetNonconstCurrentEvent()->GetTrajectoryContainer();
-    int numTrj = trjCont->entries();
+    int numTrj = m_currentTrajectoryContainer->entries();
     for( int j=0; j < numTrj; j++ ) {
 
-      Trajectory* thisTrj = static_cast<Trajectory*> ((*trjCont)[j]);
+      Trajectory* thisTrj = static_cast<Trajectory*> ((*m_currentTrajectoryContainer)[j]);
 
       // found daughter
       if ( thisTrj->GetParentID() == trj->GetTrackID() ) {
@@ -382,17 +385,17 @@
     }
   }
 
-  void LcioMcpFactory::createFinalMcpCollectionFromTrajectoryContainer(G4TrajectoryContainer* trjCont)
+  void LcioMcpFactory::createFinalMcpCollectionFromTrajectoryContainer(G4TrajectoryContainer* m_currentTrajectoryContainer)
   {
-    if ( trjCont ) {
+    if ( m_currentTrajectoryContainer ) {
 
       // loop over trj cont
-      int n_trj = trjCont->entries();
+      int n_trj = m_currentTrajectoryContainer->entries();
       for ( int i = 0;
 	    i < n_trj;
 	    i++ ) {
 
-	Trajectory* trj = static_cast<Trajectory*> ((*trjCont)[i]);
+	Trajectory* trj = static_cast<Trajectory*> ((*m_currentTrajectoryContainer)[i]);
 
 	// only add primary trajectories; daughters are picked up within
 	if ( trj->GetParentID() == 0 ) {
@@ -417,13 +420,12 @@
 							       int parTrkID)
   {
     // loop over trj cont
-    G4TrajectoryContainer* trjCont = G4EventManager::GetEventManager()->GetNonconstCurrentEvent()->GetTrajectoryContainer();
-    int n_trj = trjCont->entries();
+    int n_trj = m_currentTrajectoryContainer->entries();
     for ( int i = 0;
 	  i < n_trj;
 	  i++ ) {
 
-      Trajectory* trj = static_cast<Trajectory*> ((*trjCont)[i]);
+      Trajectory* trj = static_cast<Trajectory*> ((*m_currentTrajectoryContainer)[i]);
 
       if ( trj->GetParentID() == parTrkID ) {
 

slic/include
LcioMcpFactory.hh 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- LcioMcpFactory.hh	21 Sep 2005 00:14:25 -0000	1.3
+++ LcioMcpFactory.hh	21 Sep 2005 22:14:59 -0000	1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpFactory.hh,v 1.3 2005/09/21 00:14:25 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpFactory.hh,v 1.4 2005/09/21 22:14:59 jeremy Exp $
 #ifndef slic_LcioMcpFactory_hh
 #define slic_LcioMcpFactory_hh 1
 
@@ -13,6 +13,7 @@
 
 class G4PrimaryParticle;
 class G4TrajectoryContainer;
+class G4Event;
 
 namespace slic
 {
@@ -36,7 +37,9 @@
     EVENT::LCCollection* createEmptyMcpCollection(const std::string& collName, bool errorOnExist = true);
 
     // chooses to create from initial or traj cont
-    void createFinalMcpCollection();
+    void createFinalMcpCollection(const G4Event* event);
+
+  private:
 
     // use StdHep-generated mcpVec to create final mcpVec for an event
     void createFinalMcpCollectionFromInitial(EVENT::LCCollection* mcpVecInitial);
@@ -44,8 +47,6 @@
     // These two functions create the Mcp coll from trajectories only in case of G4 GPS or gun
     void createFinalMcpCollectionFromTrajectoryContainer(G4TrajectoryContainer* trjCont);
 
-  private:
-
     /* Create Mcp daughters of a trajectory with the given track ID. */
     void addMcpDaughtersFromTrajectoryContainer(IMPL::MCParticleImpl* parMcp, int parTrkID);
 
@@ -86,6 +87,7 @@
   private:
     LcioMcpManager* m_manager;
     IMPL::LCCollectionVec* m_finalColl;
+    G4TrajectoryContainer* m_currentTrajectoryContainer;
   };
 }
 
CVSspam 0.2.8