Commit in slic on MAIN
include/PhysicsListFactory.hh+35-81.10 -> 1.11
       /PhysicsListManager.hh+1-61.13 -> 1.14
src/PhysicsListFactory.cc+139-541.13 -> 1.14
   /PhysicsMessenger.cc+3-31.18 -> 1.19
   /PhysicsListManager.cc+4-41.16 -> 1.17
+182-75
5 modified files
JM: Revamp of physics list creation for Geant4 8.2

slic/include
PhysicsListFactory.hh 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- PhysicsListFactory.hh	5 Sep 2006 23:21:47 -0000	1.10
+++ PhysicsListFactory.hh	16 Dec 2006 00:06:20 -0000	1.11
@@ -1,8 +1,11 @@
-// $Header: /cvs/lcd/slic/include/PhysicsListFactory.hh,v 1.10 2006/09/05 23:21:47 jeremy Exp $
-
+// $Header: /cvs/lcd/slic/include/PhysicsListFactory.hh,v 1.11 2006/12/16 00:06:20 jeremy Exp $
 #ifndef SLIC_PHYSICSLISTFACTORY_HH
 #define SLIC_PHYSICSLISTFACTORY_HH 1
 
+// slic
+#include "PhysicsListBuilder.hh"
+#include "Singleton.hh"
+
 // geant4
 #include "G4VUserPhysicsList.hh"
 
@@ -12,21 +15,45 @@
 namespace slic
 {
 
+  class VPhysicsListBuilder;
+
   /**
    * @class PhysicsListFactory
    * @brief Instantiates a Geant4 physics list based on the name.
-   * @note  This class is derived from Mokka's PhysicsListFactory.
    */
 
-  class PhysicsListFactory
+  class PhysicsListFactory : public Singleton<PhysicsListFactory>
   {
+
+  public:
+    PhysicsListFactory();
+
+    virtual ~PhysicsListFactory();
+
   public:
+    
+    // Map of list names to their builders.
+    typedef std::map<G4String, VPhysicsListBuilder*> BuilderMap;
+
+  public:
+
+    // Initialize the default set of physics list builders,
+    // which is all the lists from $G4INSTALL/source/physics_lists/lists/include
+    // in the Geant4 8.2 version.
+    void initializeBuilders();
+
+    // Add a builder that can instantiate a physics list.
+    void addBuilder( VPhysicsListBuilder* );
+
+    // Return the physics list matching name.
+    G4VUserPhysicsList* create( const std::string& name ) ;
+
+    // Print the available lists with their descriptions.
+    std::ostream& printAvailableLists(std::ostream &os) ;
 
-    // only method of class - returns list for name (LCPhys is the default)
-    static G4VUserPhysicsList* create( const std::string& name ) ;
+  private:
 
-    // print which lists SLIC makes available
-    static void printAvailableLists(std::ostream &os);
+    BuilderMap m_builders;
   };
 }
 

slic/include
PhysicsListManager.hh 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- PhysicsListManager.hh	5 Sep 2006 23:21:48 -0000	1.13
+++ PhysicsListManager.hh	16 Dec 2006 00:06:20 -0000	1.14
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/PhysicsListManager.hh,v 1.13 2006/09/05 23:21:48 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/PhysicsListManager.hh,v 1.14 2006/12/16 00:06:20 jeremy Exp $
 
 #ifndef SLIC_PHYSICSLISTMANAGER_HH
 #define SLIC_PHYSICSLISTMANAGER_HH 1
@@ -50,11 +50,6 @@
       return m_currentListName;
     }
 
-    static void printLists(std::ostream& os)
-    {
-      PhysicsListFactory::printAvailableLists( os );
-    }
-
     bool isInitialized()
     {
       return m_isInitialized;

slic/src
PhysicsListFactory.cc 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- PhysicsListFactory.cc	5 Dec 2005 21:12:19 -0000	1.13
+++ PhysicsListFactory.cc	16 Dec 2006 00:06:20 -0000	1.14
@@ -1,88 +1,173 @@
-// $Header: /cvs/lcd/slic/src/PhysicsListFactory.cc,v 1.13 2005/12/05 21:12:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PhysicsListFactory.cc,v 1.14 2006/12/16 00:06:20 jeremy Exp $
 #include "PhysicsListFactory.hh"
 
-// slic
-#include "G4Application.hh"
-
-// G4 physics lists
+// geant4 physics lists
 #include "FTFC.hh"
 #include "FTFP.hh"
+#include "LBE.hh"
 #include "LHEP.hh"
-#include "QGSP_BERT.hh"
+#include "LHEP_BERT.hh"
+#include "LHEP_BERT_HP.hh"
+#include "LHEP_BIC.hh"
+#include "LHEP_BIC_HP.hh"
+#include "LHEP_EMV.hh"
+#include "LHEP_HP.hh"
+#include "LHEP_LEAD.hh"
+#include "LHEP_LEAD_HP.hh"
+#include "LHEP_PRECO.hh"
+#include "LHEP_PRECO_HP.hh"
+#include "QBBC.hh"
 #include "QGSC.hh"
+#include "QGSC_LEAD.hh"
+#include "QGSC_LEAD_HP.hh"
 #include "QGSP.hh"
-#include "LHEP_BERT.hh"
+#include "QGSP_BERT.hh"
+#include "QGSP_BERT_HP.hh"
 #include "QGSP_BIC.hh"
+#include "QGSP_EMV.hh"
+#include "QGSP_EMX.hh"
+#include "QGSP_HP.hh"
+
+#include "PhysicsListBuilder.hh"
 
 // Dennis Wright's LC Physics list
 #ifdef SLIC_USE_LCPHYS
 #include "LCPhysicsList.hh"
 #endif
 
+using namespace std;
+
+// Define a physics list builder with class and string name.
+#define BUILDER(list,name,description) this->addBuilder( new TPhysicsListBuilder<list>( name, description ) );
+
 namespace slic
 {
 
+  PhysicsListFactory::PhysicsListFactory()
+  {
+    initializeBuilders();
+  }
+  
+  PhysicsListFactory::~PhysicsListFactory()
+  {
+    for ( BuilderMap::const_iterator it = m_builders.begin();
+	  it != m_builders.end();
+	  it++ ) {
+      delete it->second;
+    }      
+    m_builders.clear();
+  }
+  
   /**
    * @param name The name of the physics list to instantiate.
    * @return    G4VUserPhysicsList base object with concrete type such as LHEP.
    */
   G4VUserPhysicsList* PhysicsListFactory::create( const std::string& name )
-  {
-
+  {    
     G4cout << "Creating physics list <" << name << ">." << G4endl;
 
-    // Fritiof with CHIPS
-    if( name == "FTFC" ) return new FTFC;
-
-    // DW's LC physics
-#ifdef SLIC_USE_LCPHYS
-    else if ( name == "LCPhys" ) return new LCPhysicsList;
-#endif
-
-    // Fritiof with precompound
-    else if( name == "FTFP" ) return new FTFP;
-
-    // low/high energy param
-    else if( name == "LHEP" ) return new LHEP;
-
-    // quark gluon-string with CHIPS
-    else if( name == "QGSC" ) return new QGSC;
-
-    // quark-gluon-string with precompound
-    else if( name == "QGSP" ) return new QGSP;
+    G4VUserPhysicsList* physicslist = 0;
+    
+    VPhysicsListBuilder* builder = m_builders[ name ];
+
+    if ( builder != 0 ) {
+      physicslist = builder->create();
+    }     
+    else {
+      G4Exception("ERROR: No builder found for physics list <" + name + ">.");
+    }
 
-    // QGSP and Bertini, "best" for calorimetry
-    else if( name == "QGSP_BERT" ) return new  QGSP_BERT;
+    return physicslist;
+  }
+  
+  std::ostream& PhysicsListFactory::printAvailableLists(std::ostream &os)
+  {
+    os << std::endl;
+    os << "----GEANT4 PHYSICS LISTS----" << std::endl << std::endl;
+    os << "NAME           DESCRIPTION" << std::endl;
+    os << "------------------------------------------------------------------" << std::endl;
+    for ( BuilderMap::const_iterator it = m_builders.begin();
+	  it != m_builders.end();
+	  it++ ) {
+      os.width(15);
+      os << left << it->first;
+      os << it->second->getDescription() << std::endl;
+    }
+    return os;
+  }
 
-    // param with Bertini
-    else if( name == "LHEP_BERT" ) return new LHEP_BERT;
+  void PhysicsListFactory::initializeBuilders()
+  {
 
-    // QGSP with binary cascade
-    else if( name == "QGSP_BIC" ) return new  QGSP_BIC;
+#ifdef SLIC_USE_LCPHYS
+    std::cout << "LCPhys enabled!" << std::endl;
+    BUILDER(LCPhysicsList,"LCPhys","ILC Physics List by Dennis Wright.")
+#endif
 
-    // didn't find it
-    else {
-      G4Exception("Unknown physics list <" + name + ">.");
-    }
+    BUILDER(LHEP, "LHEP", "Low and High Energy Parameterised")
+    BUILDER(FTFC, "FTFC", "Fritiof with CHIPS")
+    BUILDER(FTFP, "FTFP", "Fritiof with precompound")
+    BUILDER(LBE, "LBE", "")
+    BUILDER(LHEP_BERT, "LHEP_BERT", "LHEP with Bertini Cascade")
+    BUILDER(LHEP_BERT_HP, "LHEP_BERT_HP", "")
+    BUILDER(LHEP_BIC, "LHEP_BIC", "LHEP with Binary Cascade")
+    BUILDER(LHEP_BIC_HP, "LHEP_BIC_HP", "")
+    BUILDER(LHEP_EMV, "LHEP_EMV", "")
+    BUILDER(LHEP_HP, "LHEP_HP", "")
+    BUILDER(LHEP_LEAD, "LHEP_LEAD", "LHEP with leading particle")
+    BUILDER(LHEP_LEAD_HP, "LHEP_LEAD_HP", "LHEP with leading particle and HP")
+    BUILDER(LHEP_PRECO, "LHEP_PRECO", "LHEP with precompound")
+    BUILDER(LHEP_PRECO_HP,"LHEP_PRECO_HP","LHEP_PRECO with HP")      
+    BUILDER(QGSC, "QGSC", "quark gluon-string with CHIPS")
+    BUILDER(QGSC_LEAD, "QGSC_LEAD", "QGSC with leading particle")
+    BUILDER(QGSC_LEAD_HP, "QGSC_LEAD_HP", "QGSC_LEAD with HP")
+    BUILDER(QGSP, "QGSP", "quark-gluon-string with precompound")
+    BUILDER(QGSP_BERT, "QGSP_BERT", "QGSP with Bertini Cascade")
+    BUILDER(QGSP_BERT_HP, "QGSP_BERT_HP", "")
+    BUILDER(QGSP_BIC, "QGSP_BIC", "QGSP with Binary Cascade")
+    BUILDER(QGSP_EMV, "QGSP_EMV", "")
+    BUILDER(QGSP_EMX, "QGSP_EMX", "")
+    BUILDER(QGSP_HP, "QGSP_HP", "")
 
-    // compiler happy
-    return 0;
+    // This one causes a compile error.
+    // BUILDER(QBBC,"")
   }
 
-  void PhysicsListFactory::printAvailableLists(std::ostream &os)
+  void PhysicsListFactory::addBuilder( VPhysicsListBuilder* builder)
   {
-    os << std::endl;
-    os << "Available Physics Lists" << std::endl << std::endl;
-    os << "List       Description" << std::endl;
-    os << "------------------------------------------------------------------" << std::endl;
-    os << "LCPhys     Linear Collider Physics List by Dennis Wright (DEFAULT)" << std::endl;
-    os << "FTFC       Fritiof with CHIPS" << std::endl;
-    os << "FTFP       Fritiof with Precompound" << std::endl;
-    os << "LHEP       Low and High Energy Parameterised" << std::endl;
-    os << "LHEP_BERT  LHEP with Bertini Cascade" << std::endl;
-    os << "QGSC       Quark Gluon String with CHIPS" << std::endl;
-    os << "QGSP       Quark Gluon String with Precompound" << std::endl;
-    os << "QGSP_BERT  QGSP with Bertini Cascade" << std::endl;
-    os << "QGSP_BIC   QGSP with Bertini Cascade" << std::endl << std::endl;
+    const G4String& name = builder->getName();
+    m_builders[ name ] = builder;
   }
 }
+
+/*
+
+complete list of physics_lists from source/physics_lists/include
+
+FTFC           - Fritiof with CHIPS
+FTFP           - Fritiof with precompound
+LBE 
+LHEP           - Low and High Energy Parameterised
+LHEP_BERT      - LHEP with Bertini Cascade
+LHEP_BERT_HP
+LHEP_BIC       - LHEP with Binary Cascade
+LHEP_BIC_HP
+LHEP_EMV
+LHEP_HP
+LHEP_LEAD      - LHEP with leading particle
+LHEP_LEAD_HP
+LHEP_PRECO     - LHEP with precompound
+LHEP_PRECO_HP
+QBBC
+QGSC           - quark gluon-string with CHIPS
+QGSC_LEAD      - QGSC with leading
+QGSC_LEAD_HP
+QGSP           - quark-gluon-string with precompound
+QGSP_BERT      - QGSP with bertini
+QGSP_BERT_HP   
+QGSP_BIC       - QGSP with binary cascade
+QGSP_EMV
+QGSP_EMX
+QGSP_HP
+
+*/

slic/src
PhysicsMessenger.cc 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- PhysicsMessenger.cc	18 May 2006 00:35:12 -0000	1.18
+++ PhysicsMessenger.cc	16 Dec 2006 00:06:20 -0000	1.19
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/PhysicsMessenger.cc,v 1.18 2006/05/18 00:35:12 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PhysicsMessenger.cc,v 1.19 2006/12/16 00:06:20 jeremy Exp $
 #include "PhysicsMessenger.hh"
 
 // slic
@@ -42,8 +42,8 @@
       mgr->setCurrentListName( s );
     }
     // print available lists
-    else if ( cmd == m_printListsCmd ) {
-      PhysicsListManager::printLists( std::cout );
+    else if ( cmd == m_printListsCmd ) {      
+      PhysicsListFactory::instance()->printAvailableLists( std::cout );
     }
     // print current list and whether initialized
     else if ( cmd == m_printCurrentCmd ) {

slic/src
PhysicsListManager.cc 1.16 -> 1.17
diff -u -r1.16 -r1.17
--- PhysicsListManager.cc	5 Sep 2006 23:22:02 -0000	1.16
+++ PhysicsListManager.cc	16 Dec 2006 00:06:20 -0000	1.17
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/PhysicsListManager.cc,v 1.16 2006/09/05 23:22:02 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PhysicsListManager.cc,v 1.17 2006/12/16 00:06:20 jeremy Exp $
 #include "PhysicsListManager.hh"
 
 // geant4
@@ -10,7 +10,7 @@
 namespace slic
 {
 
-  // LCPhys is default
+  // LCPhys is the default, or LHEP if LCPhys is not available.
   const std::string PhysicsListManager::m_defaultListName =
 #ifdef SLIC_USE_LCPHYS
   std::string( "LCPhys" )
@@ -34,7 +34,7 @@
     m_messenger = new PhysicsMessenger();
 
     /* Initialize a default (or dummy) physics list, for Geant4 initialization ordering. */
-    G4RunManager::GetRunManager()->SetUserInitialization( PhysicsListFactory::create( m_defaultListName ) );
+    G4RunManager::GetRunManager()->SetUserInitialization( PhysicsListFactory::instance()->create( m_defaultListName ) );
   }
 
   void PhysicsListManager::setCurrentListName(const std::string& n)
@@ -53,7 +53,7 @@
       }
 
       // create list
-      m_currentList = PhysicsListFactory::create( m_currentListName );
+      m_currentList = PhysicsListFactory::instance()->create( m_currentListName );
       G4RunManager::GetRunManager()->SetUserInitialization( m_currentList );
 
       std::cout << "Registered physics list <" << m_currentListName << "> with G4RunManager" << std::endl;
CVSspam 0.2.8