Commit in slic on MAIN
include/LcioMcpFactory.hh+6-21.2 -> 1.3
src/LcioMcpFactory.cc+42-91.2 -> 1.3
+48-11
2 modified files
Added writing of MCParticle end point energy for RC

slic/include
LcioMcpFactory.hh 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- LcioMcpFactory.hh	16 Sep 2005 23:04:35 -0000	1.2
+++ LcioMcpFactory.hh	21 Sep 2005 00:14:25 -0000	1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpFactory.hh,v 1.2 2005/09/16 23:04:35 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpFactory.hh,v 1.3 2005/09/21 00:14:25 jeremy Exp $
 #ifndef slic_LcioMcpFactory_hh
 #define slic_LcioMcpFactory_hh 1
 
@@ -44,6 +44,8 @@
     // 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);
 
@@ -79,9 +81,11 @@
     // add daughters to a MCP based on associated intial MCP from StdHep
     void addMcpDaughtersFromInitial( IMPL::MCParticleImpl* mcpNew, EVENT::MCParticle* mcpInit );
 
+    void fillMcpEndPointEnergy(IMPL::LCCollectionVec* mcpColl);
+
   private:
     LcioMcpManager* m_manager;
-    EVENT::LCCollection* m_finalColl;
+    IMPL::LCCollectionVec* m_finalColl;
   };
 }
 

slic/src
LcioMcpFactory.cc 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- LcioMcpFactory.cc	15 Sep 2005 04:34:25 -0000	1.2
+++ LcioMcpFactory.cc	21 Sep 2005 00:14:25 -0000	1.3
@@ -1,26 +1,29 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpFactory.cc,v 1.2 2005/09/15 04:34:25 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpFactory.cc,v 1.3 2005/09/21 00:14:25 jeremy Exp $
 #include "LcioMcpFactory.hh"
 
 // slic
+#include "EventSourceManager.hh"
+#include "LcioManager.hh"
 #include "LcioMcpManager.hh"
+#include "LcioMcpStatusSetter.hh"
 #include "LcioMcpUtil.hh"
 #include "Trajectory.hh"
-#include "EventSourceManager.hh"
 #include "TrajectoryManager.hh"
-#include "LcioMcpStatusSetter.hh"
 
 // geant4
 #include "globals.hh"
-#include "G4TrajectoryContainer.hh"
 #include "G4EventManager.hh"
+#include "G4TrajectoryContainer.hh"
 
 // lcio
 #include "IMPL/LCCollectionVec.h"
+#include "IMPL/LCGenericObjectImpl.h"
 
+using IMPL::LCCollectionVec;
+using IMPL::LCGenericObjectImpl;
 using EVENT::LCIO;
 using EVENT::MCParticle;
 using IMPL::MCParticleImpl;
-using IMPL::LCCollectionVec;
 
 namespace slic
 {
@@ -36,7 +39,7 @@
   void LcioMcpFactory::createFinalMcpCollection()
   {
     // new coll for final Mcps
-    m_finalColl = m_manager->getFinalMcpCollection();
+    m_finalColl = static_cast<LCCollectionVec*>(m_manager->getFinalMcpCollection());
 
     // using StdHep or LCIO e.g. a file-based source?
     if ( EventSourceManager::instance()->isFileSource() ) {
@@ -52,6 +55,9 @@
 						      ->GetNonconstCurrentEvent()
 						      ->GetTrajectoryContainer() );
     }
+
+    /* Fill supplementary collection storing Mcp endpoint energies. */
+    fillMcpEndPointEnergy(m_finalColl);
   }
 
   void LcioMcpFactory::createFinalMcpCollectionFromInitial(EVENT::LCCollection* mcpVecInitial)
@@ -137,10 +143,10 @@
     /*
      * No trajectory?
      *
-     * This is a trap for G4Primaries with unrecognized PDGid,
-     * aka the dreaded "unknown particle".  In this case, no
+     * This is a trap for G4Primaries with unrecognized PDG IDs,
+     * aka the dreaded Uunknown Particles.  In this case, no
      * trajectory was created, so the final Mcp must be composed
-     * from trajectory and initial Mcp information.
+     * from initial MCParticle and G4PrimaryParticle information, only.
      *
      */
     if ( !trj ) {
@@ -469,4 +475,31 @@
       mcpChildFinal->addParent( mcpNew );
     }
   }
+
+  void LcioMcpFactory::fillMcpEndPointEnergy(LCCollectionVec* mcpColl)
+  {
+    /* Add endpoint energies to LCGenericObject collection. */
+    LcioMcpMaps* maps = LcioMcpManager::instance()->getMaps();
+    LCCollectionVec* epColl = new LCCollectionVec( LCIO::LCGENERICOBJECT );
+    for ( LCCollectionVec::iterator it = mcpColl->begin();
+	  it != mcpColl->end();
+	  it++ ) {
+
+      MCParticle* mcp = static_cast<MCParticle*>(*it);
+      G4int trkID = maps->findTrackIDFromFinalMcp(mcp);
+      double epE = -1.0;
+      if ( trkID != -1 ) {
+	Trajectory* trj = TrajectoryManager::instance()->findTrajectory(trkID);
+
+	if ( 0 != trj ) {
+	  epE = trj->getEndPointEnergy();
+	}
+      }
+
+      LCGenericObjectImpl* obj = new LCGenericObjectImpl();
+      obj->setFloatVal( 0, epE );
+      epColl->push_back( obj );
+    }
+    LcioManager::instance()->getCurrentLCEvent()->addCollection( epColl, "MCParticleEndPointEnergy" );
+  }
 }
CVSspam 0.2.8