This commit was generated by cvs2svn to compensate for changes in r1459,
authorfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Jun 2000 17:13:31 +0000 (17:13 +0000)
committerfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Jun 2000 17:13:31 +0000 (17:13 +0000)
which included commits to RCS files with non-trunk default branches.

163 files changed:
AliGeant4/AliColour.cxx [new file with mode: 0644]
AliGeant4/AliColour.h [new file with mode: 0644]
AliGeant4/AliColourStore.cxx [new file with mode: 0644]
AliGeant4/AliColourStore.h [new file with mode: 0644]
AliGeant4/AliDetConstruction.cxx [new file with mode: 0644]
AliGeant4/AliDetConstruction.h [new file with mode: 0644]
AliGeant4/AliDetConstructionMessenger.cxx [new file with mode: 0644]
AliGeant4/AliDetConstructionMessenger.h [new file with mode: 0644]
AliGeant4/AliDetSwitch.cxx [new file with mode: 0644]
AliGeant4/AliDetSwitch.h [new file with mode: 0644]
AliGeant4/AliEmptyPhysicsList.cxx [new file with mode: 0644]
AliGeant4/AliEmptyPhysicsList.h [new file with mode: 0644]
AliGeant4/AliEventAction.cxx [new file with mode: 0644]
AliGeant4/AliEventAction.h [new file with mode: 0644]
AliGeant4/AliEventActionMessenger.cxx [new file with mode: 0644]
AliGeant4/AliEventActionMessenger.h [new file with mode: 0644]
AliGeant4/AliFiles.cxx [new file with mode: 0644]
AliGeant4/AliFiles.h [new file with mode: 0644]
AliGeant4/AliGeant4LinkDef.h [new file with mode: 0644]
AliGeant4/AliGlobals.cxx [new file with mode: 0644]
AliGeant4/AliGlobals.h [new file with mode: 0644]
AliGeant4/AliGunParticle.cxx [new file with mode: 0644]
AliGeant4/AliGunParticle.h [new file with mode: 0644]
AliGeant4/AliLVStructure.cxx [new file with mode: 0644]
AliGeant4/AliLVStructure.h [new file with mode: 0644]
AliGeant4/AliLegoSensitiveDetector.cxx [new file with mode: 0644]
AliGeant4/AliLegoSensitiveDetector.h [new file with mode: 0644]
AliGeant4/AliMagneticField.cxx [new file with mode: 0644]
AliGeant4/AliMagneticField.h [new file with mode: 0644]
AliGeant4/AliModuleConstruction.cxx [new file with mode: 0644]
AliGeant4/AliModuleConstruction.h [new file with mode: 0644]
AliGeant4/AliModuleConstructionMessenger.cxx [new file with mode: 0644]
AliGeant4/AliModuleConstructionMessenger.h [new file with mode: 0644]
AliGeant4/AliModuleType.h [new file with mode: 0644]
AliGeant4/AliModulesComposition.cxx [new file with mode: 0644]
AliGeant4/AliModulesComposition.h [new file with mode: 0644]
AliGeant4/AliModulesCompositionMessenger.cxx [new file with mode: 0644]
AliGeant4/AliModulesCompositionMessenger.h [new file with mode: 0644]
AliGeant4/AliMoreModulesConstruction.cxx [new file with mode: 0644]
AliGeant4/AliMoreModulesConstruction.h [new file with mode: 0644]
AliGeant4/AliParticleGun.cxx [new file with mode: 0644]
AliGeant4/AliParticleGun.h [new file with mode: 0644]
AliGeant4/AliParticleGunMessenger.cxx [new file with mode: 0644]
AliGeant4/AliParticleGunMessenger.h [new file with mode: 0644]
AliGeant4/AliPrimaryGenerator.h [new file with mode: 0644]
AliGeant4/AliPrimaryGeneratorAction.cxx [new file with mode: 0644]
AliGeant4/AliPrimaryGeneratorAction.h [new file with mode: 0644]
AliGeant4/AliPrimaryGeneratorMessenger.cxx [new file with mode: 0644]
AliGeant4/AliPrimaryGeneratorMessenger.h [new file with mode: 0644]
AliGeant4/AliRunAction.cxx [new file with mode: 0644]
AliGeant4/AliRunAction.h [new file with mode: 0644]
AliGeant4/AliRunActionMessenger.cxx [new file with mode: 0644]
AliGeant4/AliRunActionMessenger.h [new file with mode: 0644]
AliGeant4/AliRunConfiguration.cxx [new file with mode: 0644]
AliGeant4/AliRunConfiguration.h [new file with mode: 0644]
AliGeant4/AliRunMessenger.cxx [new file with mode: 0644]
AliGeant4/AliRunMessenger.h [new file with mode: 0644]
AliGeant4/AliSDManager.cxx [new file with mode: 0644]
AliGeant4/AliSDManager.h [new file with mode: 0644]
AliGeant4/AliSensitiveDetector.cxx [new file with mode: 0644]
AliGeant4/AliSensitiveDetector.h [new file with mode: 0644]
AliGeant4/AliSingleModuleConstruction.cxx [new file with mode: 0644]
AliGeant4/AliSingleModuleConstruction.h [new file with mode: 0644]
AliGeant4/AliSingleModuleConstructionMessenger.cxx [new file with mode: 0644]
AliGeant4/AliSingleModuleConstructionMessenger.h [new file with mode: 0644]
AliGeant4/AliStackingAction.cxx [new file with mode: 0644]
AliGeant4/AliStackingAction.h [new file with mode: 0644]
AliGeant4/AliStackingActionMessenger.cxx [new file with mode: 0644]
AliGeant4/AliStackingActionMessenger.h [new file with mode: 0644]
AliGeant4/AliSteppingAction.cxx [new file with mode: 0644]
AliGeant4/AliSteppingAction.h [new file with mode: 0644]
AliGeant4/AliSteppingActionMessenger.cxx [new file with mode: 0644]
AliGeant4/AliSteppingActionMessenger.h [new file with mode: 0644]
AliGeant4/AliTrackingAction.cxx [new file with mode: 0644]
AliGeant4/AliTrackingAction.h [new file with mode: 0644]
AliGeant4/AliTrackingActionMessenger.cxx [new file with mode: 0644]
AliGeant4/AliTrackingActionMessenger.h [new file with mode: 0644]
AliGeant4/Makefile [new file with mode: 0644]
AliGeant4/aligeant4.cxx [new file with mode: 0644]
AliGeant4/config/doc_alc++2html.pl [new file with mode: 0755]
AliGeant4/config/doc_alcategory.pl [new file with mode: 0755]
AliGeant4/config/doc_alddl2html.pl [new file with mode: 0755]
AliGeant4/config/doc_alsorthtml.pl [new file with mode: 0755]
AliGeant4/config/doc_g4c++2html.pl [new file with mode: 0755]
AliGeant4/config/doc_g4category.pl [new file with mode: 0755]
AliGeant4/config/doc_g4ddl2html.pl [new file with mode: 0755]
AliGeant4/config/doc_g4sorthtml.pl [new file with mode: 0755]
AliGeant4/config/setup.csh [new file with mode: 0755]
AliGeant4/config/setup.sh [new file with mode: 0755]
AliGeant4/config/test_create.sh [new file with mode: 0755]
AliGeant4/config/test_create_in.sh [new file with mode: 0755]
AliGeant4/config/test_create_struct.sh [new file with mode: 0755]
AliGeant4/config/test_default_det_novis.in [new file with mode: 0644]
AliGeant4/config/test_default_det_vis.in [new file with mode: 0644]
AliGeant4/config/test_default_gen0.in [new file with mode: 0644]
AliGeant4/config/test_default_gen1.in [new file with mode: 0644]
AliGeant4/config/test_default_gen2.in [new file with mode: 0644]
AliGeant4/config/test_default_gen3.in [new file with mode: 0644]
AliGeant4/config/test_default_gen4.in [new file with mode: 0644]
AliGeant4/config/test_default_vis1.in [new file with mode: 0644]
AliGeant4/config/test_run.sh [new file with mode: 0755]
AliGeant4/config/test_run_in.sh [new file with mode: 0755]
AliGeant4/config/test_run_struct.sh [new file with mode: 0755]
AliGeant4/doc/CodePrototype.html [new file with mode: 0644]
AliGeant4/doc/G4CodePrototype.html [new file with mode: 0644]
AliGeant4/doc/README [new file with mode: 0644]
AliGeant4/doc/README.CodingConvention [new file with mode: 0644]
AliGeant4/doc/g3tog4tests.txt [new file with mode: 0644]
AliGeant4/doc/history/History [new file with mode: 0644]
AliGeant4/doc/history/alice_History [new file with mode: 0644]
AliGeant4/doc/history/alice_event_History [new file with mode: 0644]
AliGeant4/doc/history/alice_geometry_History [new file with mode: 0644]
AliGeant4/doc/history/alice_global_History [new file with mode: 0644]
AliGeant4/doc/history/alice_physics_History [new file with mode: 0644]
AliGeant4/doc/history/alice_run_History [new file with mode: 0644]
AliGeant4/doc/history/alice_visualization_History [new file with mode: 0644]
AliGeant4/doc/history/g4mc_History [new file with mode: 0644]
AliGeant4/doc/history/g4mc_geometry_History [new file with mode: 0644]
AliGeant4/doc/history/g4mc_global_History [new file with mode: 0644]
AliGeant4/doc/history/g4mc_physics_History [new file with mode: 0644]
AliGeant4/doc/history/g4mc_run_History [new file with mode: 0644]
AliGeant4/doc/history/g4mc_visualization_History [new file with mode: 0644]
AliGeant4/macro/CASTOR/Config.C [new file with mode: 0644]
AliGeant4/macro/CASTOR/Config.in [new file with mode: 0644]
AliGeant4/macro/FMD/Config.C [new file with mode: 0644]
AliGeant4/macro/FMD/Config.in [new file with mode: 0644]
AliGeant4/macro/ITS/Config.C [new file with mode: 0644]
AliGeant4/macro/ITS/Config.in [new file with mode: 0644]
AliGeant4/macro/MUON/Config.C [new file with mode: 0644]
AliGeant4/macro/MUON/Config.in [new file with mode: 0644]
AliGeant4/macro/MUON/Config_MUON.C [new file with mode: 0644]
AliGeant4/macro/PHOS/Config.C [new file with mode: 0644]
AliGeant4/macro/PHOS/Config.in [new file with mode: 0644]
AliGeant4/macro/PMD/Config.C [new file with mode: 0644]
AliGeant4/macro/PMD/Config.in [new file with mode: 0644]
AliGeant4/macro/RICH/Config.C [new file with mode: 0644]
AliGeant4/macro/RICH/Config.in [new file with mode: 0644]
AliGeant4/macro/START/Config.C [new file with mode: 0644]
AliGeant4/macro/START/Config.in [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigABSO.C [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigABSO.in [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigBODY.C [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigBODY.in [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigDIPO.C [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigDIPO.in [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigFRAME.C [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigFRAME.in [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigHALL.C [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigHALL.in [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigMAG.C [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigMAG.in [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigPIPE.C [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigPIPE.in [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigSHIL.C [new file with mode: 0644]
AliGeant4/macro/STRUCT/ConfigSHIL.in [new file with mode: 0644]
AliGeant4/macro/TOF/Config.C [new file with mode: 0644]
AliGeant4/macro/TOF/Config.in [new file with mode: 0644]
AliGeant4/macro/TPC/Config.C [new file with mode: 0644]
AliGeant4/macro/TPC/Config.in [new file with mode: 0644]
AliGeant4/macro/TRD/Config.C [new file with mode: 0644]
AliGeant4/macro/TRD/Config.in [new file with mode: 0644]
AliGeant4/macro/ZDC/Config.C [new file with mode: 0644]
AliGeant4/macro/ZDC/Config.in [new file with mode: 0644]

diff --git a/AliGeant4/AliColour.cxx b/AliGeant4/AliColour.cxx
new file mode 100644 (file)
index 0000000..1634414
--- /dev/null
@@ -0,0 +1,71 @@
+// $Id$
+// Category: visualization
+//
+// See the class description in the header file.
+
+#include "AliColour.h"
+   
+AliColour::AliColour()
+  : fName (""),
+    fRed(0.),
+    fBlue(0.),
+    fGreen(0.)
+{
+//
+}
+
+AliColour::AliColour(G4String name, G4double red, G4double blue, G4double green)
+  : fName(name),
+    fRed(red),
+    fBlue(blue),
+    fGreen(green)
+{
+//
+}
+
+AliColour::AliColour(const AliColour& right) {
+//
+  fName = right.fName;
+  fRed = right.fRed;
+  fBlue = right.fBlue;
+  fGreen = right.fGreen;
+}
+
+AliColour::~AliColour() {
+//
+}
+
+// operators
+
+AliColour& AliColour::operator=(const AliColour& right)
+{    
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  fName = right.fName;
+  fRed = right.fRed;
+  fBlue = right.fBlue;
+  fGreen = right.fGreen;
+  
+  return *this;
+}
+
+G4int AliColour::operator==(const AliColour& right) const
+{    
+//
+  G4int returnValue = 0;
+  if ( fName == right.fName && 
+       fRed == right.fRed && fBlue == right.fBlue && fGreen == right.fGreen) 
+  { returnValue = 1; };
+
+  return returnValue;  
+}
+
+G4int AliColour::operator!=(const AliColour& right) const
+{
+//    
+  G4int returnValue = 1;
+  if (*this == right) returnValue = 0; 
+  
+  return returnValue;
+}
diff --git a/AliGeant4/AliColour.h b/AliGeant4/AliColour.h
new file mode 100644 (file)
index 0000000..bc8a40a
--- /dev/null
@@ -0,0 +1,45 @@
+// $Id$
+// Category: visualization
+//
+// Data type class that defines colours with names.
+
+#ifndef ALI_COLOUR_H
+#define ALI_COLOUR_H
+
+#include <G4Colour.hh>
+#include <globals.hh>
+
+class AliColour
+{
+  public:
+    AliColour();
+    AliColour(G4String name, G4double red, G4double blue, G4double green);
+    AliColour(const AliColour& right);
+    virtual ~AliColour();
+
+    // operators
+    AliColour& operator=(const AliColour& right);
+    G4int operator==(const AliColour& right) const;
+    G4int operator!=(const AliColour& right) const;
+
+    // get methods
+    G4Colour GetColour() const;
+    G4String GetName() const;
+  
+  private:
+    G4String  fName;  //colour name
+    G4double  fRed;   //red component
+    G4double  fBlue;  //blue component
+    G4double  fGreen; //green component
+};
+
+// inline methods
+
+inline G4Colour AliColour::GetColour() const
+{ return G4Colour(fRed, fBlue, fGreen); }
+
+inline G4String AliColour::GetName() const
+{ return fName; }
+
+#endif //ALCOLOUR_H
+
diff --git a/AliGeant4/AliColourStore.cxx b/AliGeant4/AliColourStore.cxx
new file mode 100644 (file)
index 0000000..ec02e72
--- /dev/null
@@ -0,0 +1,124 @@
+// $Id$
+// Category: visualization
+//
+// See the class description in the header file.
+
+#include "AliColourStore.h"
+#include "AliGlobals.h"
+
+#include <G4Element.hh>
+
+// static data members
+
+AliColourStore* AliColourStore::fgInstance = 0;
+
+// lifecycle
+
+AliColourStore::AliColourStore() {
+//
+  fColours.insert(AliColour("White",     1.0, 1.0, 1.0));    
+  fColours.insert(AliColour("Black",     0.0, 0.0, 0.0));     
+  fColours.insert(AliColour("Red",       1.0, 0.0, 0.0));   
+  fColours.insert(AliColour("RoseDark",  1.0, 0.0, 0.5));  
+  fColours.insert(AliColour("Green",     0.0, 1.0, 0.0));     
+  fColours.insert(AliColour("Green2",    0.0, 1.0, 0.5));     
+  fColours.insert(AliColour("GreenClair",0.5, 1.0, 0.0));
+  fColours.insert(AliColour("Yellow",    1.0, 1.0, 0.0));     
+  fColours.insert(AliColour("BlueDark",  0.0, 0.0, 1.0)); 
+  fColours.insert(AliColour("BlueClair", 0.0, 1.0, 1.0)); 
+  fColours.insert(AliColour("BlueClair2",0.0, 0.5, 1.0));
+  fColours.insert(AliColour("Magenta",   1.0, 0.0, 1.0));    
+  fColours.insert(AliColour("Magenta2",  0.5, 0.0, 1.0));   
+  fColours.insert(AliColour("BrownClair",1.0, 0.5, 0.0));
+  fColours.insert(AliColour("Gray",      0.3, 0.3, 0.3));    
+  fColours.insert(AliColour("GrayClair", 0.6, 0.6, 0.6));
+}
+
+AliColourStore::AliColourStore(const AliColourStore& right) {
+// 
+  AliGlobals::Exception(
+    "Attempt to copy AliColourStore singleton.");
+}
+
+AliColourStore::~AliColourStore() {
+//
+}
+
+// operators
+
+AliColourStore& AliColourStore::operator=(const AliColourStore& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception(
+    "Attempt to assign AliColourStore singleton.");
+    
+  return *this;  
+}    
+
+// static methods
+  
+AliColourStore* AliColourStore::Instance() 
+{
+// Returns the singleton instance.
+// Creates the instance if it does not exist.
+// ---
+
+  if (fgInstance == 0 ) {
+    fgInstance = new AliColourStore();
+  }
+  
+  return fgInstance;
+}
+
+// public methods
+
+G4Colour AliColourStore::GetColour(G4String name) const
+{
+// Retrieves the colour by name.
+// ---
+
+  G4int nofCol = fColours.entries();
+  for (G4int i=0; i<nofCol; i++)
+  {
+    AliColour alColour = fColours[i];
+    if (name == alColour.GetName()) 
+    { return alColour.GetColour(); }
+  }
+  
+  G4String text = "Colour " + name + " is not defined.";
+  AliGlobals::Exception(text);
+  return 0;
+}
+    
+G4String AliColourStore::GetColoursList() const
+{
+// Returns the list of all defined colours names.
+// ---
+
+  G4String list = "";
+  G4int nofCol = fColours.entries();
+  for (G4int i=0; i<nofCol; i++)
+  {
+    list += fColours[i].GetName();
+    list += " ";
+  };
+  return list;
+} 
+       
+G4String AliColourStore::GetColoursListWithCommas() const
+{
+// Returns the list of all defined colours names
+// with commas.
+// ---
+
+  G4String list = "";
+  G4int nofCol = fColours.entries();
+  for (G4int i=0; i<nofCol; i++)
+  {
+    list += fColours[i].GetName();
+    if (i < nofCol-1) list += ", ";
+  };
+  return list;
+} 
diff --git a/AliGeant4/AliColourStore.h b/AliGeant4/AliColourStore.h
new file mode 100644 (file)
index 0000000..480af54
--- /dev/null
@@ -0,0 +1,46 @@
+// $Id$
+// Category: visualization
+//
+// Singleton data type class - store for the predefined colours.
+
+#ifndef ALI_COLOUR_STORE_H
+#define ALI_COLOUR_STORE_H
+
+#include "AliColour.h"
+
+#include <g4rw/tvordvec.h>
+
+class AliColourStore 
+{
+  typedef G4RWTValOrderedVector<AliColour>  AliColourVector;
+
+  public:
+    // --> protected
+    // AliColourStore();
+    // AliColourStore(const AliColourStore& right);
+    virtual ~AliColourStore();
+    
+    // static methods
+    static AliColourStore* Instance();
+
+    // get methods
+    G4Colour GetColour(G4String name) const;
+    G4String GetColoursList() const;
+    G4String GetColoursListWithCommas() const;
+    
+  protected:
+    AliColourStore();  
+    AliColourStore(const AliColourStore& right);
+
+    // operators
+    AliColourStore& operator=(const AliColourStore& right);
+
+  private:
+    // static data members
+    static AliColourStore*  fgInstance; //this instance
+
+    // data members
+    AliColourVector  fColours;          //vector of AliColour
+};   
+
+#endif //ALI_COLOUR_STORE_H
diff --git a/AliGeant4/AliDetConstruction.cxx b/AliGeant4/AliDetConstruction.cxx
new file mode 100644 (file)
index 0000000..d5c0a34
--- /dev/null
@@ -0,0 +1,287 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliDetConstruction.h"
+#include "AliSingleModuleConstruction.h"
+#include "AliGlobals.h"
+#include "AliRun.h"
+#include "AliModule.h"
+
+AliDetConstruction::AliDetConstruction()
+  : fTopVolumeName("ALIC")
+{
+  // initialize det switch vector: 
+  // moduleName nofVersions defaultVersion [type isStandalone] 
+
+  AliDetSwitch* detSwitch;
+  detSwitch = new AliDetSwitch("ABSO",   1, 0, kStructure);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("DIPO",   3, 2, kStructure);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("FRAME",  2, 1, kStructure, false);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("HALL",   1, 0, kStructure);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("MAG",    1, 0, kStructure);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("PIPE",   4, 0, kStructure);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("SHIL",   1, 0, kStructure);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("CASTOR", 2, 1);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("FMD",    2, 1);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("ITS",    6, 5);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("MUON",   1, 0);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("PHOS",   2, 0);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("PMD",    3, 0);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("RICH",   1, 0);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("START",  1, 0);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("TOF",    7, 1, kDetector, false);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("TPC",    4, 1);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("TRD",    2, 0, kDetector, false);
+  AddDetSwitch(detSwitch); 
+  detSwitch = new AliDetSwitch("ZDC",    2, 1);
+  AddDetSwitch(detSwitch);  
+}
+
+AliDetConstruction::AliDetConstruction(const AliDetConstruction& right)
+  : AliModulesComposition(right)
+{
+  // AliModuleComposition is protected from copying
+}  
+
+AliDetConstruction::~AliDetConstruction() {
+//
+}
+
+// operators
+
+AliDetConstruction& 
+AliDetConstruction::operator=(const AliDetConstruction& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  // base class assignement
+  // AliModuleComposition is protected from assigning
+  AliModulesComposition::operator=(right);
+
+  return *this;  
+}    
+          
+// private methods
+
+void AliDetConstruction::BuildDetectors()
+{
+// Create module constructions for AliModules 
+// that have been created and registered by gAlice 
+// ---
+
+  TObjArray* pDetectors = gAlice->Detectors();
+  TIter next(pDetectors);
+
+  // the first AliModule is expected to be the top volume
+  AliModule *module = (AliModule*)next();
+  if (G4String(module->GetName()) != "BODY") {
+    G4String text = "AliDetConstruction::BuildDetectors():\n";
+    text = text + "    Instead of BODY - the first module ";
+    text = text + module->GetName() + " has been found.";
+    AliGlobals::Exception(text);
+  }  
+  AddSingleModuleConstruction("BODY", 0, kStructure);
+
+  G4bool first = true;
+  while ((module = (AliModule*)next())) {
+    // register moduleConstruction in fDetSwitchVector
+    // in order to keep availability of /AlDet/list command
+    G4String modName = module->GetName();
+    G4int modVersion = module->IsVersion();
+    if (first)
+      // skip registering of the top volume 
+      first = false;
+    else 
+      SwitchDetOn(modName, modVersion);
+    // all modules will be processed alltogether
+    AddMoreModuleConstruction(modName, modVersion);
+
+    G4cout << "Created module construction for " 
+           << modName << "v" << modVersion << "." << endl;   
+  }
+  
+  // do not process Config.C 
+  // (it was processed when creating modules by gAlice)
+  SetProcessConfigToModules(false);    
+}
+
+void AliDetConstruction::CreateDetectors()
+{
+// Creates AliModules and their module constructions 
+// according to the fDetSwitchVector
+// ---
+
+  // add top volume (AliBODY) construction first
+  AddSingleModuleConstruction("BODY", 0, kStructure);
+
+  // add modules constructions
+  const G4RWTPtrOrderedVector<AliDetSwitch>& krDetSwitchVector 
+    = GetDetSwitchVector();
+  for (G4int id=0; id<krDetSwitchVector.entries(); id++)
+  {
+    G4String detName = krDetSwitchVector[id]->GetDetName();
+    G4int version = krDetSwitchVector[id]->GetSwitchedVersion();
+    G4bool isStandalone = krDetSwitchVector[id]->IsStandalone();
+    AliModuleType type = krDetSwitchVector[id]->GetType();
+    
+    if (version > -1)
+      if (isStandalone)
+        AddSingleModuleConstruction(detName, version, type);
+      else
+        AddMoreModuleConstruction(detName, version, type);
+  }    
+}
+
+void AliDetConstruction::CheckDetDependencies()
+{
+// Checks modules dependencies.
+// Dependent modules FRAME, TOF, TRD 
+// TOF always requires FRAMEv1
+// TRD can be built with both (??)
+// ---
+
+  const G4RWTPtrOrderedVector<AliDetSwitch>& krDetSwitchVector 
+    = GetDetSwitchVector();
+
+  // get switched versions of dependent modules
+  G4int nofDets = krDetSwitchVector.entries();
+  G4int verFRAME = -1; 
+  G4int verTOF = -1; 
+  G4int verTRD = -1; 
+  AliDetSwitch* detSwitchFRAME = 0;
+  for (G4int id=0; id<nofDets; id++) {  
+    G4String detName = krDetSwitchVector[id]->GetDetName();
+    if (detName == "FRAME") { 
+      verFRAME = krDetSwitchVector[id]->GetSwitchedVersion();  
+      detSwitchFRAME = krDetSwitchVector[id];
+    }  
+    if (detName == "TOF")  
+      verTOF = krDetSwitchVector[id]->GetSwitchedVersion();  
+    if (detName == "TRD")  
+      verTRD = krDetSwitchVector[id]->GetSwitchedVersion();  
+  }
+  
+  // check dependencies  
+  if (verTRD > -1 && verTOF > -1) {
+    // both TRD and TOF 
+    if (verFRAME != 1) {
+      detSwitchFRAME->SwitchOn(1);
+      G4String text = "AliDetConstruction::CheckDetDependencies: \n";
+      text = text + "    Switched TOF and TRD require FRAME v1.\n"; 
+      text = text + "    The det switch for FRAME has been changed."; 
+      AliGlobals::Warning(text);
+    }  
+  }
+  else if (verTRD > -1 && verTOF == -1)   {
+    // only TRD
+    if (verFRAME < 0) {
+      detSwitchFRAME->SwitchOn(1);
+      G4String text = "AliDetConstruction::CheckDetDependencies: \n";
+      text = text + "    Switched TRD require FRAME.\n"; 
+      text = text + "    The det switch for FRAME has been changed."; 
+      AliGlobals::Warning(text);
+    }  
+  }  
+  else if (verTRD == -1 && verTOF > -1)   {
+    // only TOF
+    if (verFRAME != 1) {
+      detSwitchFRAME->SwitchOn(1);
+      G4String text = "AliDetConstruction::CheckDetDependencies: \n";
+      text = text + "    Switched TOF requires FRAME v1.\n"; 
+      text = text + "    The det switch for FRAME has been changed."; 
+      AliGlobals::Warning(text);
+    }  
+  }
+/*  
+  if (verTRD > -1 && verTOF > -1) {
+    // both TRD and TOF 
+    if (verTOF == 2 || verTOF == 3 || verTOF == 5 || verTOF == 6) {
+      G4String text = "AliDetConstruction::CheckDetDependencies: \n";
+      text = text + "    Switched TOF and TRD require different FRAME versions."; 
+      AliGlobals::Exception(text);
+    }  
+    if (verFRAME != 0) {
+      detSwitchFRAME->SwitchOn(0);
+      G4String text = "AliDetConstruction::CheckDetDependencies: \n";
+      text = text + "    Switched TOF and TRD require FRAME v0.\n"; 
+      text = text + "    The det switch for FRAME has been changed."; 
+      AliGlobals::Warning(text);
+    }  
+  }
+  else if (verTRD > -1 && verTOF == -1)   {
+    // only TRD
+    if (verFRAME != 0) {
+      detSwitchFRAME->SwitchOn(0);
+      G4String text = "AliDetConstruction::CheckDetDependencies: \n";
+      text = text + "    Switched TRD requires FRAME v0.\n"; 
+      text = text + "    The det switch for FRAME has been changed."; 
+      AliGlobals::Warning(text);
+    }          
+  }  
+  else if (verTRD == -1 && verTOF > -1)   {
+    // only TOF
+    if ((verTOF == 0 || verTOF == 1 || verTOF == 4) && (verFRAME !=0)) {
+      detSwitchFRAME->SwitchOn(0);
+      G4String text = "AliDetConstruction::CheckDetDependencies: \n";
+      text = text + "    Switched TOF requires FRAME v0.\n"; 
+      text = text + "    The det switch for FRAME has been changed."; 
+      AliGlobals::Warning(text);
+    }
+    if ((verTOF == 2 || verTOF == 3 || verTOF == 5 || verTOF == 6) &&
+        (verFRAME != 1)) {
+      detSwitchFRAME->SwitchOn(1);
+      G4String text = "AliDetConstruction::CheckDetDependencies: \n";
+      text = text + "    Switched TOF requires FRAME v1.\n"; 
+      text = text + "    The det switch for FRAME has been changed."; 
+      AliGlobals::Warning(text);
+    }
+  }
+*/    
+}  
+
+// public methods
+
+G4VPhysicalVolume* AliDetConstruction::Construct()
+{
+// Constructs geometry.
+// This method is called by G4RunManager in initialization.
+// ---
+
+  if (gAlice->Modules()->GetLast() < 0) {
+    // create geometry (including AliModules) according to 
+    // the fDetSwitchVector
+    CheckDetDependencies();
+    CreateDetectors();
+  }   
+  else {
+    // create geometry for AliModules 
+    // that have been created and registered by gAlice 
+    BuildDetectors();
+  }  
+  // construct modules geometry
+  ConstructModules();
+
+  return AliSingleModuleConstruction::GetWorld();      
+}
+
diff --git a/AliGeant4/AliDetConstruction.h b/AliGeant4/AliDetConstruction.h
new file mode 100644 (file)
index 0000000..02ebe79
--- /dev/null
@@ -0,0 +1,55 @@
+// $Id$
+// Category: geometry
+//
+// Detector construction class with interactive setting of detectors setup 
+// available.  
+// In case the detector setup is not defined in Root macro Config.C
+// commands /alDet/switchOn/Off can be used either interactively or
+// in Geant4 macro.
+
+#ifndef ALI_DET_CONSTRUCTION_H
+#define ALI_DET_CONSTRUCTION_H
+
+#include "AliModulesComposition.h"
+
+#include <globals.hh>
+
+class G4VPhysicalVolume;
+
+class AliDetConstruction : public AliModulesComposition
+{
+  public:
+    AliDetConstruction();
+    // --> protected
+    // AliDetConstruction(const AliDetConstruction& right);
+    virtual ~AliDetConstruction();
+
+    // methods
+    virtual G4VPhysicalVolume* Construct();
+
+    // set methods
+    void SetTopVolumeName(G4String name);
+    
+  protected:
+    AliDetConstruction(const AliDetConstruction& right);
+
+    // operators
+    AliDetConstruction& operator=(const AliDetConstruction& right);
+
+  private:  
+    // methods
+    void BuildDetectors();
+    void CreateDetectors();
+    void CheckDetDependencies();
+  
+    // data members
+    G4String  fTopVolumeName;  //top volume name
+};
+
+// inline methods
+
+inline void AliDetConstruction::SetTopVolumeName(G4String name)
+{ fTopVolumeName = name; }
+
+#endif //ALI_DET_CONSTRUCTION_H
+
diff --git a/AliGeant4/AliDetConstructionMessenger.cxx b/AliGeant4/AliDetConstructionMessenger.cxx
new file mode 100644 (file)
index 0000000..648a279
--- /dev/null
@@ -0,0 +1,96 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliDetConstructionMessenger.h"
+#include "AliDetConstruction.h"
+#include "AliGlobals.h"
+
+#include <G4UIcmdWithABool.hh>
+
+AliDetConstructionMessenger::AliDetConstructionMessenger(
+                                AliDetConstruction* detConstruction)
+  : fDetConstruction(detConstruction)
+{
+//
+  fSetAllSensitiveCmd
+    = new G4UIcmdWithABool("/aliDet/setAllSensitive", this);
+  fSetAllSensitiveCmd 
+    ->SetGuidance("If true: set all logical volumes sensitive.");
+  fSetAllSensitiveCmd 
+    ->SetGuidance("         (Each logical is volume associated with a sensitive");
+  fSetAllSensitiveCmd 
+    ->SetGuidance("          detector.)");
+  fSetAllSensitiveCmd 
+    ->SetGuidance("If false: only volumes defined with a sensitive tracking");
+  fSetAllSensitiveCmd 
+    ->SetGuidance("          medium are associated with a sensitive detector.");
+  fSetAllSensitiveCmd->SetParameterName("sensitivity", false);
+  fSetAllSensitiveCmd->AvailableForStates(PreInit);  
+
+  fSetReadGeometryCmd 
+    = new G4UIcmdWithABool("/aliDet/readGeometry", this);
+  fSetReadGeometryCmd->SetGuidance("Read geometry from g3calls.dat files");
+  fSetReadGeometryCmd->SetParameterName("readGeometry", false);
+  fSetReadGeometryCmd->AvailableForStates(PreInit);  
+  fSetWriteGeometryCmd 
+    = new G4UIcmdWithABool("/aliDet/writeGeometry", this);
+  fSetWriteGeometryCmd->SetGuidance("Write geometry to g3calls.dat file");
+  fSetWriteGeometryCmd->SetParameterName("writeGeometry", false);
+  fSetWriteGeometryCmd->AvailableForStates(PreInit);   
+}
+
+AliDetConstructionMessenger::AliDetConstructionMessenger() {
+//
+}
+
+AliDetConstructionMessenger::AliDetConstructionMessenger(
+                                const AliDetConstructionMessenger& right)
+{
+//
+  AliGlobals::Exception(
+    "AliDetConstructionMessenger is protected from copying.");
+}
+
+AliDetConstructionMessenger::~AliDetConstructionMessenger() {
+//
+  delete fSetAllSensitiveCmd;
+  delete fSetReadGeometryCmd;
+  delete fSetWriteGeometryCmd;
+}
+
+// operators
+
+AliDetConstructionMessenger& 
+AliDetConstructionMessenger::operator=(const AliDetConstructionMessenger& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception(
+     "AliDetConstructionMessenger is protected from assigning.");
+    
+  return *this;  
+}    
+          
+// public methods
+  
+void AliDetConstructionMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
+{
+// Applies command to the associated object.
+// ---
+
+  if (command == fSetAllSensitiveCmd) {
+    fDetConstruction->SetAllLVSensitive(
+                         fSetAllSensitiveCmd->GetNewBoolValue(newValues));
+  }
+  else if (command == fSetReadGeometryCmd) {
+    fDetConstruction->SetReadGeometry(newValues);
+  }  
+  else if (command == fSetWriteGeometryCmd) {
+    fDetConstruction->SetWriteGeometry(newValues);
+  }    
+}
+
diff --git a/AliGeant4/AliDetConstructionMessenger.h b/AliGeant4/AliDetConstructionMessenger.h
new file mode 100644 (file)
index 0000000..f708221
--- /dev/null
@@ -0,0 +1,46 @@
+// $Id$
+// Category: geometry
+//
+// Messenger class that defines commands for AliDetConstruction.
+
+#ifndef ALI_DET_CONSTRUCTION_MESSENGER_H
+#define ALI_DET_CONSTRUCTION_MESSENGER_H
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliDetConstruction;
+
+class G4UIcommand;
+class G4UIcmdWithABool;
+
+class AliDetConstructionMessenger: public G4UImessenger
+{
+  public:
+    AliDetConstructionMessenger(AliDetConstruction* detConstruction);
+    // --> protected
+    // AliDetConstructionMessenger();  
+    // AliDetConstructionMessenger(const AliDetConstructionMessenger& right);
+    virtual ~AliDetConstructionMessenger();
+
+    // methods
+    virtual void SetNewValue(G4UIcommand* command, G4String newValues);
+
+  protected:
+    AliDetConstructionMessenger();
+    AliDetConstructionMessenger(const AliDetConstructionMessenger& right);
+
+    // operators
+    AliDetConstructionMessenger& operator=(
+                                const AliDetConstructionMessenger& right);
+  
+  private:
+    // data members
+    AliDetConstruction*  fDetConstruction;     //associated class
+    G4UIcmdWithABool*    fSetAllSensitiveCmd;  //command: setAllSensitive   
+    G4UIcmdWithABool*    fSetReadGeometryCmd;  //command: setReadGeometry   
+    G4UIcmdWithABool*    fSetWriteGeometryCmd; //command: setWriteGeometry   
+};
+
+#endif //ALI_DET_CONSTRUCTION_MESSENGER_H
+
diff --git a/AliGeant4/AliDetSwitch.cxx b/AliGeant4/AliDetSwitch.cxx
new file mode 100644 (file)
index 0000000..22ee551
--- /dev/null
@@ -0,0 +1,101 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliDetSwitch.h"
+#include "AliGlobals.h"
+
+AliDetSwitch::AliDetSwitch(G4String detName, G4int nofVersions, 
+                 G4int defaultVersion, AliModuleType modType, 
+                G4bool isStandalone)
+  : fDetName(detName),
+    fNofVersions(nofVersions),
+    fDefaultVersion(defaultVersion),
+    fIsStandalone(isStandalone),
+    fType(modType),
+    fSwitchedVersion(-1)
+{
+//
+}
+
+AliDetSwitch::AliDetSwitch(const AliDetSwitch& right) {
+//
+  fDetName = right.fDetName;
+  fNofVersions = right.fNofVersions;
+  fDefaultVersion = right.fDefaultVersion;
+  fIsStandalone = right.fIsStandalone;
+  fType = right.fType;
+  fSwitchedVersion = right.fSwitchedVersion;
+}
+
+AliDetSwitch::~AliDetSwitch(){
+//
+}
+
+// operators
+AliDetSwitch& AliDetSwitch::operator=(const AliDetSwitch& right)
+{    
+  // check assignement to self
+  if (this == &right) return *this;
+
+  fDetName = right.fDetName;
+  fNofVersions = right.fNofVersions;
+  fDefaultVersion = right.fDefaultVersion;
+  fSwitchedVersion = right.fSwitchedVersion;
+  fType = right.fType;
+  fIsStandalone = right.fIsStandalone;
+  
+  return *this;
+}
+
+G4int AliDetSwitch::operator==(const AliDetSwitch& right) const
+{    
+//
+  G4int returnValue = 0;
+  if (fDetName == right.fDetName )
+     returnValue = 1;
+
+  return returnValue;  
+}
+
+G4int AliDetSwitch::operator!=(const AliDetSwitch& right) const
+{ 
+//   
+  G4int returnValue = 1;
+  if (*this == right) returnValue = 0; 
+  
+  return returnValue;
+}
+  
+// public methods
+
+void AliDetSwitch::SwitchOn(G4int iVersion)
+{
+// Switchs on the iVersion version.
+// ---
+
+  if ((iVersion < 0) || (iVersion >= fNofVersions)) {
+    G4String text = "Wrong version number for ";
+    text = text + fDetName + ".";
+    AliGlobals::Exception(text);
+  }  
+   
+  fSwitchedVersion = iVersion;
+}
+
+void AliDetSwitch::SwitchOnDefault()
+{
+// Switchs on the default version.
+// ---
+
+  fSwitchedVersion = fDefaultVersion;
+}
+
+void AliDetSwitch::SwitchOff()
+{
+// No version is switched on.
+// ---
+
+  fSwitchedVersion = -1;
+}
diff --git a/AliGeant4/AliDetSwitch.h b/AliGeant4/AliDetSwitch.h
new file mode 100644 (file)
index 0000000..12a8b11
--- /dev/null
@@ -0,0 +1,70 @@
+// $Id$
+// Category: geometry
+//
+// Data type class that stores available detector option.
+// Used in interactive detector setup.
+
+#ifndef ALI_DET_SWITCH_H
+#define ALI_DET_SWITCH_H
+
+#include "AliModuleType.h"
+
+#include <globals.hh>
+
+class AliDetSwitch
+{
+  public:
+    AliDetSwitch(G4String detName, G4int nofVersions, G4int defaultVersion,
+                 AliModuleType modType = kDetector, G4bool isStandalone = true);
+    AliDetSwitch(const AliDetSwitch& right);
+    virtual ~AliDetSwitch();
+
+    //operators
+    AliDetSwitch& operator=(const AliDetSwitch& right);
+    G4int operator==(const AliDetSwitch& right) const;
+    G4int operator!=(const AliDetSwitch& right) const;
+    
+    // methods
+    void SwitchOn(G4int version); 
+    void SwitchOnDefault(); 
+    void SwitchOff(); 
+
+    // get methods
+    G4String GetDetName() const;
+    G4int GetNofVersions() const;
+    G4int GetDefaultVersion() const;
+    G4bool IsStandalone() const;
+    AliModuleType GetType() const;
+    G4int GetSwitchedVersion() const;
+
+  private:
+    // data members
+    G4String       fDetName;         //module name
+    G4int          fNofVersions;     //number of versions
+    G4int          fDefaultVersion;  //default version
+    G4bool         fIsStandalone;    //true if module can be built standalone
+    AliModuleType  fType;            //type of module (detector or structure)
+    G4int          fSwitchedVersion; //current selected version
+};
+    
+// inline methods    
+    
+inline G4String AliDetSwitch::GetDetName() const
+{ return fDetName; }
+
+inline G4int AliDetSwitch::GetNofVersions() const
+{ return fNofVersions; }
+
+inline G4int AliDetSwitch::GetDefaultVersion() const
+{ return fDefaultVersion; }
+
+inline G4int AliDetSwitch::GetSwitchedVersion() const
+{ return fSwitchedVersion; }
+
+inline AliModuleType AliDetSwitch::GetType() const
+{ return fType; }
+
+inline G4bool AliDetSwitch::IsStandalone() const
+{ return fIsStandalone; }
+
+#endif //ALI_DET_SWITCH_H
diff --git a/AliGeant4/AliEmptyPhysicsList.cxx b/AliGeant4/AliEmptyPhysicsList.cxx
new file mode 100644 (file)
index 0000000..936ffc3
--- /dev/null
@@ -0,0 +1,91 @@
+// $Id$
+// Category: physics
+//
+// See the class description in the header file.
+
+#include "AliEmptyPhysicsList.h"
+#include "AliGlobals.h"
+
+#include <G4Geantino.hh>
+#include <G4ChargedGeantino.hh>
+
+#include <iomanip.h>                
+
+AliEmptyPhysicsList::AliEmptyPhysicsList() {
+//
+  defaultCutValue = AliGlobals::DefaultCut();
+  SetVerboseLevel(1);
+}
+
+AliEmptyPhysicsList::~AliEmptyPhysicsList() {
+//
+}
+
+// public methods
+
+void AliEmptyPhysicsList::ConstructParticle()
+{
+// In this method, static member functions should be called
+// for all particles which you want to use.
+// This ensures that objects of these particle types will be
+// created in the program. 
+// ---
+
+  ConstructBosons();
+  ConstructLeptons();
+  ConstructMesons();
+  ConstructBarions();
+}
+
+void AliEmptyPhysicsList::ConstructBosons()
+{
+// Constructs pseudo-particles only.
+// ---
+
+  G4Geantino::GeantinoDefinition();
+  G4ChargedGeantino::ChargedGeantinoDefinition();
+}
+
+void AliEmptyPhysicsList::ConstructLeptons()
+{
+  // no leptons
+}
+
+void AliEmptyPhysicsList::ConstructMesons()
+{
+ //  no mesons
+}
+
+void AliEmptyPhysicsList::ConstructBarions()
+{
+ // no barions
+}
+
+void AliEmptyPhysicsList::ConstructProcess()
+{
+// Constructs physics processes.
+// ---
+
+  AddTransportation();
+  ConstructEM();
+  ConstructGeneral();
+}
+
+void AliEmptyPhysicsList::ConstructEM()
+{
+  // no EM
+}
+
+void AliEmptyPhysicsList::ConstructGeneral()
+{
+  // no Decay Process
+}
+
+void AliEmptyPhysicsList::SetCuts()
+{
+// Sets the default range cut values for all defined particles.
+// ---
+
+  SetCutsWithDefault();
+}
+
diff --git a/AliGeant4/AliEmptyPhysicsList.h b/AliGeant4/AliEmptyPhysicsList.h
new file mode 100644 (file)
index 0000000..de792d1
--- /dev/null
@@ -0,0 +1,40 @@
+// $Id$
+// Category: physics
+//
+// Empty physics list for geometry tests.
+
+#ifndef ALI_EMPTY_PHYSICS_LIST_H
+#define ALI_EMPTY_PHYSICS_LIST_H
+
+#include <G4VUserPhysicsList.hh>
+#include <globals.hh>
+
+class AliEmptyPhysicsList: public G4VUserPhysicsList
+{
+  public:
+    AliEmptyPhysicsList();
+    virtual ~AliEmptyPhysicsList();
+
+  protected:
+    // methods
+    // construct particle and physics
+    virtual void ConstructParticle();
+    virtual void ConstructProcess();
+    virtual void SetCuts();
+    
+    // construct particles methods
+    void ConstructBosons();
+    void ConstructLeptons();
+    void ConstructMesons();
+    void ConstructBarions();
+
+    // construct physics processes and register them
+    void ConstructGeneral();
+    void ConstructEM();    
+};
+
+#endif //ALI_EMPTY_PHYSICS_LIST_H
+
+
+
diff --git a/AliGeant4/AliEventAction.cxx b/AliGeant4/AliEventAction.cxx
new file mode 100644 (file)
index 0000000..1b3b8d8
--- /dev/null
@@ -0,0 +1,145 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliEventAction.h"
+#include "AliEventActionMessenger.h"
+#include "AliRun.h"
+#include "AliTrackingAction.h"
+#include "AliSensitiveDetector.h"
+#include "AliGlobals.h"
+
+#include "TG4GeometryManager.h"
+
+#include <G4Event.hh>
+#include <G4TrajectoryContainer.hh>
+#include <G4Trajectory.hh>
+#include <G4VVisManager.hh>
+#include <G4UImanager.hh>
+#include <G4LogicalVolumeStore.hh>
+#include <G4VSensitiveDetector.hh>
+
+AliEventAction::AliEventAction()
+  : fVerboseLevel(1), 
+    fDrawFlag("CHARGED")
+{
+//
+  fMessenger = new AliEventActionMessenger(this);
+}
+
+AliEventAction::AliEventAction(const AliEventAction& right) {
+//
+  AliGlobals::Exception("AliEventAction is protected from copying.");
+}
+
+AliEventAction::~AliEventAction() {
+//
+  delete fMessenger;
+}
+
+// operators
+
+AliEventAction& AliEventAction::operator=(const AliEventAction &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliEventAction is protected from assigning.");
+
+  return *this;
+}
+
+// private methods
+
+void AliEventAction::DisplayEvent(const G4Event* event) const
+{
+// Draws trajectories.
+// ---
+
+
+  // trajectories processing
+  G4TrajectoryContainer* trajectoryContainer 
+    = event->GetTrajectoryContainer();
+
+  G4int nofTrajectories = 0;
+  if (trajectoryContainer)
+  { nofTrajectories = trajectoryContainer->entries(); }
+  
+  if (fVerboseLevel>0) {
+    G4cout << "    " << nofTrajectories; 
+    G4cout << " trajectories stored." << endl;
+  }  
+
+  G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
+  if(pVVisManager && nofTrajectories>0)
+  {
+    G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current");
+
+    for (G4int i=0; i<nofTrajectories; i++)
+    { 
+      G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i];
+      G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory);
+      if (!trajectory) {
+        AliGlobals::Exception(
+         "AliEventAction::DisplayEvent: Unknown trajectory type.");
+      }
+      else if ( (fDrawFlag == "ALL") ||
+               ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){
+        trajectory->DrawTrajectory(2000); 
+      }        
+    }      
+    G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view");
+  }  
+}
+
+// public methods
+
+void AliEventAction::BeginOfEventAction(const G4Event* event)
+{
+// Called by G4 kernel at the beginning of event.
+// ---
+
+  G4int eventID = event->GetEventID();
+
+  // reset the counters (primary tracks, saved tracks)
+  AliTrackingAction* trackingAction
+    = AliTrackingAction::Instance();
+  trackingAction->PrepareNewEvent();   
+
+  if (fVerboseLevel>0)
+    G4cout << ">>> Event " << event->GetEventID() << endl;
+}
+
+void AliEventAction::EndOfEventAction(const G4Event* event)
+{
+// Called by G4 kernel at the end of event.
+// ---
+
+  // save the last primary track store of
+  // the current event
+  AliTrackingAction* trackingAction
+    = AliTrackingAction::Instance();
+  trackingAction->SaveAndDestroyTrack();   
+
+  if (fVerboseLevel>0) {
+    G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
+    G4cout  << "    " << nofPrimaryTracks << 
+               " primary tracks processed." << endl;
+  }           
+
+  // display event
+  DisplayEvent(event);
+
+  // aliroot
+  // store event header data
+  gAlice->GetHeader()->SetEvent(event->GetEventID());
+  gAlice->GetHeader()->SetNvertex(event->GetNumberOfPrimaryVertex());
+  gAlice->GetHeader()->SetNprimary(trackingAction->GetNofPrimaryTracks());
+  gAlice->GetHeader()->SetNtrack(trackingAction->GetNofSavedTracks());
+
+  gAlice->FinishEvent();    
+}
+
+
+
diff --git a/AliGeant4/AliEventAction.h b/AliGeant4/AliEventAction.h
new file mode 100644 (file)
index 0000000..d8ab0f3
--- /dev/null
@@ -0,0 +1,68 @@
+// $Id$
+// Category: event
+//
+// Class that defines actions at the beginning and the end of event.
+
+#ifndef ALI_EVENT_ACTION_H
+#define ALI_EVENT_ACTION_H 
+
+#include <G4UserEventAction.hh>
+#include <globals.hh>
+
+class AliEventActionMessenger;
+
+class G4Event;
+
+class AliEventAction : public G4UserEventAction
+{
+  public:
+    AliEventAction();
+    // --> protected
+    // AliEventAction(const AliEventAction& right);
+    virtual ~AliEventAction();
+    
+    // methods
+    virtual void BeginOfEventAction(const G4Event* event);
+    virtual void EndOfEventAction(const G4Event* event);
+    
+    // set methods
+    void SetVerboseLevel(G4int level);
+    void SetDrawFlag(G4String drawFlag);
+    
+    // get methods
+    G4int GetVerboseLevel() const;
+    G4String GetDrawFlag() const;
+    
+  protected:
+    AliEventAction(const AliEventAction& right);
+
+    // operators
+    AliEventAction& operator=(const AliEventAction& right);
+
+  private:
+    // methods 
+    void DisplayEvent(const G4Event* event) const;
+  
+    // data members
+    AliEventActionMessenger*  fMessenger;    //messenger
+    G4int                     fVerboseLevel; //verbose level
+    G4String                  fDrawFlag;     //control drawing of the event
+};
+
+// inline methods
+
+inline void AliEventAction::SetVerboseLevel(G4int level)
+{ fVerboseLevel = level; }
+
+inline void AliEventAction::SetDrawFlag(G4String drawFlag)
+{ fDrawFlag = drawFlag; }
+
+inline G4int AliEventAction::GetVerboseLevel() const
+{ return fVerboseLevel; }
+
+inline G4String AliEventAction::GetDrawFlag() const
+{ return fDrawFlag; }
+
+#endif //ALI_EVENT_ACTION_H
+
+    
diff --git a/AliGeant4/AliEventActionMessenger.cxx b/AliGeant4/AliEventActionMessenger.cxx
new file mode 100644 (file)
index 0000000..d043f77
--- /dev/null
@@ -0,0 +1,84 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliEventActionMessenger.h"
+#include "AliEventAction.h"
+#include "AliGlobals.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithAString.hh>
+#include <G4UIcmdWithAnInteger.hh>
+
+AliEventActionMessenger::AliEventActionMessenger(AliEventAction* eventAction)
+  :fEventAction(eventAction)
+{ 
+//
+  fEventDirectory = new G4UIdirectory("/aliEvent/");
+  fEventDirectory->SetGuidance("AliEventAction control commands.");
+
+  fDrawTracksCmd = new G4UIcmdWithAString("/aliEvent/drawTracks", this);
+  fDrawTracksCmd->SetGuidance("Draw the tracks in the event");
+  fDrawTracksCmd->SetGuidance("  Choice : NONE, CHARGED(default), ALL");
+  fDrawTracksCmd->SetParameterName("Choice", true);
+  fDrawTracksCmd->SetDefaultValue("CHARGED");
+  fDrawTracksCmd->SetCandidates("NONE CHARGED ALL");
+  fDrawTracksCmd->AvailableForStates(Idle);
+  fVerboseCmd = new G4UIcmdWithAnInteger("/aliEvent/verbose", this);
+  fVerboseCmd->SetGuidance("Set verbose level for AliEventAction");
+  fVerboseCmd->SetParameterName("VerboseLevel", true);
+  fVerboseCmd->SetDefaultValue(0);
+  fVerboseCmd->SetRange("VerboseLevel >= 0 && VerboseLevel <= 2");
+  fVerboseCmd->AvailableForStates(Idle);
+}
+
+AliEventActionMessenger::AliEventActionMessenger(){
+//
+}
+
+AliEventActionMessenger::AliEventActionMessenger(
+                                 const AliEventActionMessenger& right) {
+//                              
+  AliGlobals::Exception("AliEventActionMessenger is protected from copying.");
+}
+
+AliEventActionMessenger::~AliEventActionMessenger() {
+//
+  delete fEventDirectory;
+  delete fDrawTracksCmd;
+  delete fVerboseCmd;
+}
+
+// operators
+
+AliEventActionMessenger& 
+AliEventActionMessenger::operator=(const AliEventActionMessenger &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliEventActionMessenger is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliEventActionMessenger::SetNewValue(G4UIcommand* command, 
+       G4String newValue)
+{ 
+// Applies command to the associated object.
+// ---
+
+  if(command == fDrawTracksCmd)
+  { 
+    fEventAction->SetDrawFlag(newValue); 
+  }   
+  else if(command == fVerboseCmd)
+  { 
+    fEventAction
+      ->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue)); 
+  }   
+}
diff --git a/AliGeant4/AliEventActionMessenger.h b/AliGeant4/AliEventActionMessenger.h
new file mode 100644 (file)
index 0000000..5257515
--- /dev/null
@@ -0,0 +1,46 @@
+// $Id$
+// Category: event
+//
+// Messenger class that defines commands for AliEventAction.
+
+#ifndef ALI_EVENT_ACTION_MESSENGER_H
+#define ALI_EVENT_ACTION_MESSENGER_H 
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliEventAction;
+
+class G4UIdirectory;
+class G4UIcmdWithAString;
+class G4UIcmdWithAnInteger;
+
+class AliEventActionMessenger: public G4UImessenger
+{
+  public:
+    AliEventActionMessenger(AliEventAction* eventAction);
+    // --> protected
+    // AliEventActionMessenger();
+    // AliEventActionMessenger(const AliEventActionMessenger& right);
+    virtual ~AliEventActionMessenger();
+   
+    // methods 
+    virtual void SetNewValue(G4UIcommand* command, G4String string);
+    
+  protected:
+    AliEventActionMessenger();
+    AliEventActionMessenger(const AliEventActionMessenger& right);
+
+    // operators
+    AliEventActionMessenger& operator=(
+                            const AliEventActionMessenger& right);
+
+  private:
+    // data members
+    AliEventAction*        fEventAction;    //associated class
+    G4UIdirectory*         fEventDirectory; //command directory
+    G4UIcmdWithAString*    fDrawTracksCmd;  //command: drawTracks
+    G4UIcmdWithAnInteger*  fVerboseCmd;     //command: verbose
+};
+
+#endif //ALI_EVENT_ACTION_MESSENGER_H
diff --git a/AliGeant4/AliFiles.cxx b/AliGeant4/AliFiles.cxx
new file mode 100644 (file)
index 0000000..c3d30f4
--- /dev/null
@@ -0,0 +1,32 @@
+// $Id$
+// Category: global
+//
+// See the class description in the header file.
+
+#include "AliFiles.h"
+
+#include <stdlib.h>
+
+// static data members
+
+const G4String AliFiles::fgTop =    getenv("AG4_INSTALL");    
+const G4String AliFiles::fgConfig = fgTop + "/../macros/Config.C";    
+const G4String AliFiles::fgDetConfig1 = fgTop + "/macro/";    
+const G4String AliFiles::fgDetConfig2 = "/Config";    
+const G4String AliFiles::fgDetConfig3 = ".C";    
+const G4String AliFiles::fgDetConfig4 = ".in";    
+const G4String AliFiles::fgDetConfigName1 = "Config(";    
+const G4String AliFiles::fgDetConfigName2 = ")";    
+const G4String AliFiles::fgDetData1 = fgTop + "/macro/";
+const G4String AliFiles::fgDetData2 = "/g3calls_";    
+const G4String AliFiles::fgDetData3 = ".dat";    
+const G4String AliFiles::fgSTRUCT = "STRUCT/";
+
+AliFiles::AliFiles() {
+//
+}
+  
+AliFiles::~AliFiles() {
+//
+}
+  
diff --git a/AliGeant4/AliFiles.h b/AliGeant4/AliFiles.h
new file mode 100644 (file)
index 0000000..d259cff
--- /dev/null
@@ -0,0 +1,92 @@
+// $Id$
+// Category: global
+//
+// Class for file names and paths.
+// It is protected from instantiating (only static data members
+// and static methods are defined).
+
+#ifndef ALI_FILES_H
+#define ALI_FILES_H
+
+#include <globals.hh>
+
+#ifdef G4USE_STL
+#include <string>
+#endif
+
+class AliFiles
+{
+  public:
+    // --> protected
+    // AliFiles();
+    virtual ~AliFiles();
+
+    // static get methods
+    static G4String Config();   
+    static G4String DetConfig1();
+    static G4String DetConfig2();
+    static G4String DetConfig3();
+    static G4String DetConfig4();
+    static G4String DetConfigName1();
+    static G4String DetConfigName2();
+    static G4String DetData1();
+    static G4String DetData2();
+    static G4String DetData3();
+    static G4String STRUCT();
+
+  protected:
+    AliFiles();  
+       // only static data members and methods
+    
+  private:       
+    // static data members  
+    static const G4String  fgTop;        //top directory
+    static const G4String  fgConfig;     //path to general Config.C
+    static const G4String  fgDetConfig1; //path (part 1) to module Config.C/in
+    static const G4String  fgDetConfig2; //path (part 2) to module Config.C/in
+    static const G4String  fgDetConfig3; //path (part 3) to module Config.C/in
+    static const G4String  fgDetConfig4; //path (part 2) to module Config.C/in
+    static const G4String  fgDetConfigName1;  //config macro name (part 1)
+    static const G4String  fgDetConfigName2;  //config macro name (part 2)
+    static const G4String  fgDetData1;   //path (part 1) to module g3calls.dat
+    static const G4String  fgDetData2;   //path (part 2) to module g3calls.dat
+    static const G4String  fgDetData3;   //path (part 3) to module g3calls.dat
+    static const G4String  fgSTRUCT;     //structure directory name
+};  
+
+// inline methods
+
+inline G4String AliFiles::Config()
+{ return fgConfig; }
+
+inline G4String AliFiles::DetConfig1()
+{ return fgDetConfig1; }
+
+inline G4String AliFiles::DetConfig2()
+{ return fgDetConfig2; }
+
+inline G4String AliFiles::DetConfig3()
+{ return fgDetConfig3; }
+
+inline G4String AliFiles::DetConfig4()
+{ return fgDetConfig4; }
+
+inline G4String AliFiles::DetConfigName1()
+{ return fgDetConfigName1; }
+
+inline G4String AliFiles::DetConfigName2()
+{ return fgDetConfigName2; }
+
+inline G4String AliFiles::DetData1()
+{ return fgDetData1; }
+
+inline G4String AliFiles::DetData2()
+{ return fgDetData2; }
+
+inline G4String AliFiles::DetData3()
+{ return fgDetData3; }
+
+inline G4String AliFiles::STRUCT()
+{ return fgSTRUCT; }
+
+#endif //ALI_FILES_H
diff --git a/AliGeant4/AliGeant4LinkDef.h b/AliGeant4/AliGeant4LinkDef.h
new file mode 100644 (file)
index 0000000..eecb14d
--- /dev/null
@@ -0,0 +1,11 @@
+// $Id$
+
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+#pragma link C++ class  AliRunConfiguration;
+
+#endif
diff --git a/AliGeant4/AliGlobals.cxx b/AliGeant4/AliGlobals.cxx
new file mode 100644 (file)
index 0000000..ca9ca15
--- /dev/null
@@ -0,0 +1,103 @@
+// $Id$
+// Category: global
+//
+// See the class description in the header file.
+
+#include "AliGlobals.h"
+
+#include <stdlib.h>
+
+// static data members
+const G4double AliGlobals::fgDefaultCut = 2.0*mm;
+
+AliGlobals::AliGlobals() {
+//
+}
+  
+AliGlobals::~AliGlobals() {
+//
+}
+  
+// static methods
+
+void AliGlobals::Exception(const char* s)
+{
+// Prints error message end exits the program.
+// ---
+
+  if (s)
+  {  cerr << endl << "    " << s << endl; }
+  cerr << "*** AliceException: Aborting execution ***" << endl;   
+  exit(1);
+}
+
+void AliGlobals::Warning(const char* s)
+{
+// Prints warning message.
+// ---
+
+  cerr << "+++ Alice Warning: +++" << endl;   
+  if (s)
+  {  cerr  << "    " << s << endl; }
+  cerr << "++++++++++++++++++++++" << endl;   
+}
+
+#ifdef G4USE_STL
+void AliGlobals::Exception(G4std::string s) {
+//
+  AliGlobals::Exception(s.c_str());
+}
+
+void AliGlobals::Exception(G4String s) {
+//
+   AliGlobals::Exception(s.c_str());
+}
+
+void AliGlobals::Warning(G4std::string s) {
+//
+  AliGlobals::Warning(s.c_str());
+}
+
+void AliGlobals::Warning(G4String s) {
+//
+  AliGlobals::Warning(s.c_str());
+}
+#endif
+
+void AliGlobals::AppendNumberToString(G4String& s, G4int a)
+{
+// Appends number to string.
+// ---
+
+  const char* kpNumber="0123456789";
+  G4String p=""; G4String q="";
+  do 
+  {
+    G4int b=a/10;
+    G4int c=a%10;
+    p=kpNumber[c];
+    q=p.append(q);
+    a=b;        
+  } while (a>0);
+  s.append(q);
+};
+
+G4int AliGlobals::StringToInt(G4String s)
+{
+// Converts one char string to integer number.
+// ---
+
+  // make better
+  if (s=="0") return 0;
+  if (s=="1") return 1;
+  if (s=="2") return 2;
+  if (s=="3") return 3;
+  if (s=="4") return 4;
+  if (s=="5") return 5;
+  if (s=="6") return 6;
+  if (s=="7") return 7;
+  if (s=="8") return 8;
+  if (s=="9") return 9;
+  return -1;
+}
diff --git a/AliGeant4/AliGlobals.h b/AliGeant4/AliGlobals.h
new file mode 100644 (file)
index 0000000..69504ab
--- /dev/null
@@ -0,0 +1,58 @@
+// $Id$
+// Category: global
+//
+// Class for generally used basic functions.
+// It is protected from instantiating (only static data members
+// and static methods are defined).
+
+
+#ifndef ALI_GLOBALS_H
+#define ALI_GLOBALS_H
+
+#include <globals.hh>
+
+#ifdef G4USE_STL
+#include <string>
+#endif
+
+class AliGlobals
+{
+  public:
+    // --> protected
+    // AliGlobals();
+    virtual ~AliGlobals();
+
+    // static methods
+    static void Exception(const char* s=0);
+      // Global error function prints string to cerr, and aborts
+      // program - according to G4Exception.cc
+    static void Warning(const char* s=0);
+      // Global warning function prints string to cerr
+#ifdef G4USE_STL
+    static void Exception(G4std::string s);
+    static void Exception(G4String s);
+    static void Warning(G4std::string s);
+    static void Warning(G4String s);
+#endif
+
+    static void AppendNumberToString(G4String& string, G4int number);
+    static G4int StringToInt(G4String string);
+    
+    // static get methods
+    static G4double DefaultCut();
+
+  protected:
+    AliGlobals();  
+       // only static data members and methods
+    
+  private:       
+    // static data members  
+    static const G4double  fgDefaultCut; //default cut value
+};  
+
+// inline methods
+
+inline G4double AliGlobals::DefaultCut()
+{ return fgDefaultCut; }
+
+#endif //ALI_GLOBALS_H
diff --git a/AliGeant4/AliGunParticle.cxx b/AliGeant4/AliGunParticle.cxx
new file mode 100644 (file)
index 0000000..76d0fa7
--- /dev/null
@@ -0,0 +1,146 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliGunParticle.h"
+
+#include <G4ios.hh>
+
+AliGunParticle::AliGunParticle()
+  : fParticleDefinition(0),
+    fParticleMomentum(G4ThreeVector(0., 0., 1.)),
+    fPosition(G4ThreeVector()),
+    fTime(0),
+    fPolarization(G4ThreeVector())
+{
+//
+}
+
+AliGunParticle::AliGunParticle(G4ParticleDefinition* particleDef,
+                   G4ParticleMomentum momentum, G4ThreeVector position, 
+                   G4double time, G4ThreeVector polarization )
+  : fParticleDefinition(particleDef),
+    fParticleMomentum(momentum),
+    fPosition(position),
+    fTime(time),
+    fPolarization(polarization)
+{
+//
+}
+
+AliGunParticle::AliGunParticle( G4ParticleDefinition* particleDef, 
+                   G4ParticleMomentum momentumDir, G4double kinEnergy,
+                  G4ThreeVector position, G4double time, 
+                  G4ThreeVector polarization )
+  : fParticleDefinition(particleDef),
+    fPosition(position),
+    fTime(time),
+    fPolarization(polarization)
+{
+//   
+  G4double mass = fParticleDefinition->GetPDGMass();
+  G4double energy = kinEnergy + mass;
+  G4double pmag = sqrt(energy*energy - mass*mass);
+  fParticleMomentum = pmag*momentumDir;
+}
+
+AliGunParticle::AliGunParticle(const AliGunParticle& right) {
+//
+  fParticleDefinition = right.fParticleDefinition;
+  fParticleMomentum = right.fParticleMomentum;
+  fPosition = right.fPosition; 
+  fTime = right.fTime;
+  fPolarization = right.fPolarization; 
+}
+
+AliGunParticle::~AliGunParticle() {
+//
+}
+
+// operators
+
+AliGunParticle& AliGunParticle::operator=(const AliGunParticle& right)
+{    
+  // check assignement to self
+  if (this == &right) return *this;
+
+  fParticleDefinition = right.fParticleDefinition;
+  fParticleMomentum = right.fParticleMomentum;
+  fPosition = right.fPosition; 
+  fTime = right.fTime;
+  fPolarization = right.fPolarization; 
+  
+  return *this;
+}
+
+G4int AliGunParticle::operator==(const AliGunParticle& right) const 
+{
+//    
+  G4int returnValue = 0;
+  if (fParticleDefinition == right.fParticleDefinition 
+      && fParticleMomentum == right.fParticleMomentum 
+      && fPosition == right.fPosition 
+      && fTime == right.fTime 
+      && fPolarization == right.fPolarization)  returnValue = 1; 
+
+  return returnValue;  
+}
+
+G4int AliGunParticle::operator!=(const AliGunParticle& right) const
+{
+//    
+  G4int returnValue = 1;
+  if (*this == right) returnValue = 0; 
+  
+  return returnValue;
+}
+
+// public methods
+
+void AliGunParticle::Print() const
+{
+// Prints particle properties.
+// ---
+
+  G4cout << "    particle name: ";
+  G4cout << fParticleDefinition->GetParticleName() << endl;
+  G4cout << "    particle momentum: ";
+  G4cout << fParticleMomentum << endl;
+  G4cout << "    particle position: ";
+  G4cout << fPosition << " mm" << endl;
+  G4cout << "    particle time: ";
+  G4cout << fTime     << " s" << endl;
+  G4cout << "    particle polarization: ";
+  G4cout << fPolarization << endl;
+}  
+
+void AliGunParticle::SetKineticEnergy(G4double kinEnergy)
+{
+// Sets kinetic energy.
+// ---
+
+  G4double mass = fParticleDefinition->GetPDGMass();
+  G4double energy = kinEnergy + mass;
+  G4double pmag = sqrt(energy*energy - mass*mass);
+  fParticleMomentum.setMag(pmag); 
+}
+
+G4double AliGunParticle::GetKineticEnergy() const
+{
+// Gets kinetic energy.
+// ---
+
+  G4double mass = fParticleDefinition->GetPDGMass();
+  G4double energy 
+   = sqrt(fParticleMomentum.mag()*fParticleMomentum.mag() + mass*mass);
+  return energy - mass;
+}
+
+
+
+
+
+
+
+
diff --git a/AliGeant4/AliGunParticle.h b/AliGeant4/AliGunParticle.h
new file mode 100644 (file)
index 0000000..34e51f9
--- /dev/null
@@ -0,0 +1,102 @@
+// $Id$
+// Category: event
+//
+// Data type class that stores properties of a gun particle.
+// Used in AliParticleGun.
+
+#ifndef ALI_GUN_PARTICLE_H
+#define ALI_GUN_PARTICLE_H
+
+#include <G4ParticleMomentum.hh>
+#include <G4ParticleDefinition.hh>
+#include <G4ThreeVector.hh>
+#include <globals.hh>
+
+class AliGunParticle
+{
+  public:
+    AliGunParticle();
+    AliGunParticle(G4ParticleDefinition* particleDef, G4ParticleMomentum momentum, 
+       G4ThreeVector position, G4double time, G4ThreeVector polarization );
+    AliGunParticle( G4ParticleDefinition* particleDef, G4ParticleMomentum momentumDir, 
+      G4double kinEnergy, G4ThreeVector position, G4double time, 
+      G4ThreeVector polarization );
+    AliGunParticle(const AliGunParticle& right);
+    ~AliGunParticle();     
+
+    // operators
+    AliGunParticle& operator=(const AliGunParticle& right);
+    G4int operator==(const AliGunParticle& right) const;
+    G4int operator!=(const AliGunParticle& right) const;
+
+    // methods
+    void Print() const;  
+
+    // set methods
+    void SetParticleDefinition(G4ParticleDefinition* particleDef);
+    void SetMomentum(G4ParticleMomentum  momentum);
+    void SetPosition(G4ThreeVector position);
+    void SetTime(G4double time);
+    void SetPolarization(G4ThreeVector polarization);
+    void SetMomentumDirection(G4ParticleMomentum  momentumDir);
+    void SetKineticEnergy(G4double kinEnergy);
+      
+    // get methods  
+    G4ParticleDefinition* GetParticleDefinition() const;
+    G4ParticleMomentum GetMomentum() const;
+    G4ThreeVector GetPosition() const;
+    G4double GetTime() const;
+    G4ThreeVector GetPolarization() const;
+    G4ParticleMomentum GetMomentumDirection() const;
+    G4double GetKineticEnergy() const;
+                         
+  private:
+    // data members
+    G4ParticleDefinition*  fParticleDefinition; //G4ParticleDefinition
+    G4ParticleMomentum     fParticleMomentum;   //G4ParticleMomentum
+    G4ThreeVector          fPosition;           //position
+    G4double               fTime;               //time
+    G4ThreeVector          fPolarization;       //polarization
+};
+
+// inline methods
+
+inline void AliGunParticle::SetParticleDefinition(G4ParticleDefinition* particleDef)
+{ fParticleDefinition = particleDef; }
+
+inline void AliGunParticle::SetMomentum(G4ParticleMomentum  momentum)
+{ fParticleMomentum = momentum; }
+
+inline void AliGunParticle::SetPosition(G4ThreeVector position)
+{ fPosition = position; }
+
+inline void AliGunParticle::SetTime(G4double time)
+{ fTime = time; }
+
+inline void AliGunParticle::SetPolarization(G4ThreeVector polarization)
+{ fPolarization = polarization; }
+
+inline void AliGunParticle::SetMomentumDirection(G4ParticleMomentum  momentumDir)
+{ fParticleMomentum = fParticleMomentum.mag()*momentumDir.unit(); }
+
+inline G4ParticleDefinition* AliGunParticle::GetParticleDefinition() const
+{ return fParticleDefinition; }
+
+inline G4ParticleMomentum AliGunParticle::GetMomentum() const
+{ return fParticleMomentum; }
+
+inline G4ThreeVector AliGunParticle::GetPosition() const
+{ return fPosition; }
+
+inline G4double AliGunParticle::GetTime() const
+{ return fTime; }
+
+inline G4ThreeVector AliGunParticle::GetPolarization() const
+{ return fPolarization; }
+
+inline G4ParticleMomentum AliGunParticle::GetMomentumDirection() const
+{ return fParticleMomentum.unit(); }
+
+#endif //ALI_GUN_PARTICLE_H   
+   
+
diff --git a/AliGeant4/AliLVStructure.cxx b/AliGeant4/AliLVStructure.cxx
new file mode 100644 (file)
index 0000000..3065607
--- /dev/null
@@ -0,0 +1,298 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliLVStructure.h"
+#include "AliGlobals.h"
+
+#ifdef ALICE_VISUALIZE
+#include "AliColourStore.h"
+
+#include <G4Colour.hh>
+#include <G4VisAttributes.hh>
+#endif //ALICE_VISUALIZE
+#include <globals.hh>
+
+AliLVStructure::AliLVStructure(G4String path)
+  : fPathName(path),
+    fDirName(path),
+    fVerboseLevel(0)
+{
+//
+  G4int i = fDirName.length();
+  if (i > 1) {
+    fDirName.remove(i-1);
+    G4int isl = fDirName.last('/');
+    fDirName.remove(0,isl+1);
+    fDirName += "/";
+  }
+}
+
+AliLVStructure::AliLVStructure(const AliLVStructure& right)
+{
+  // copy vector of structures
+  fStructures.clearAndDestroy();
+  G4int i;
+  for (i=0; i<right.fStructures.entries(); i++) {
+    // new full structure tree has to be created
+    AliLVStructure* rhsStructure = right.fStructures[i];
+    fStructures.insert(new AliLVStructure(*rhsStructure)); 
+  }  
+  
+  // copy vector of logical volumes
+  fLogicalVolumes.clear();
+  for (i=0; i<right.fLogicalVolumes.entries(); i++) {
+    G4LogicalVolume* rhsLV = right.fLogicalVolumes[i];
+    fLogicalVolumes.insert(rhsLV); 
+  }  
+  
+  fPathName = right.fPathName;
+  fDirName = right.fPathName;
+  fVerboseLevel = right.fVerboseLevel;
+}
+
+AliLVStructure::AliLVStructure() {
+//
+}
+
+AliLVStructure::~AliLVStructure() {
+//
+  fStructures.clearAndDestroy();
+  fLogicalVolumes.clear();
+}
+
+// operators
+
+AliLVStructure& AliLVStructure::operator=(const AliLVStructure &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  // copy vector of structures
+  fStructures.clearAndDestroy();
+  G4int i;
+  for (i=0; i<right.fStructures.entries(); i++) {
+    // new full structure tree has to be created
+    AliLVStructure* rhsStructure = right.fStructures[i];
+    fStructures.insert(new AliLVStructure(*rhsStructure)); 
+  }  
+  
+  // copy vector of logical volumes
+  fLogicalVolumes.clear();
+  for (i=0; i<right.fLogicalVolumes.entries(); i++) {
+    G4LogicalVolume* rhsLV = right.fLogicalVolumes[i];
+    fLogicalVolumes.insert(rhsLV); 
+  }  
+  
+  fPathName = right.fPathName;
+  fDirName = right.fPathName;
+  fVerboseLevel = right.fVerboseLevel;
+
+  return *this;
+}
+
+G4int AliLVStructure::operator==(const AliLVStructure &right) const
+{
+  // check == to self
+  if (this == &right) return true;
+
+  return false;
+}
+
+// private methods
+
+AliLVStructure* AliLVStructure::FindSubDirectory(G4String subDir)
+{
+// Finds the subdirectory.
+// ---
+
+  for( G4int i=0; i<fStructures.entries(); i++ ) {
+    if (subDir == fStructures(i)->fDirName) return fStructures(i);
+  } 
+  return 0;
+}
+
+G4String AliLVStructure::ExtractDirName(G4String name)
+{
+// Extracts the directory name from the path.
+// ---
+
+  G4String subDir = name;
+  G4int i = name.first('/');
+  if (i != G4std::string::npos) subDir.remove(i+1);
+  return subDir;
+}
+
+// public methods
+
+void AliLVStructure::AddNewVolume(G4LogicalVolume* lv, 
+                      G4String treeStructure)
+{
+// Adds new logical volume to the structure.
+// ---
+
+  G4String remainingPath = treeStructure;
+  remainingPath.remove(0, fPathName.length());  
+  if (!remainingPath.isNull()) { 
+    // The lv should be kept in subdirectory.
+    // First, check if the subdirectoy exists.
+    G4String subDir = ExtractDirName( remainingPath );
+    AliLVStructure* targetLVS = FindSubDirectory(subDir);
+    if (targetLVS == 0) { 
+      // Subdirectory not found. Create a new directory.
+      subDir.prepend(fPathName);
+      targetLVS = new AliLVStructure(subDir);
+      fStructures.insert( targetLVS );
+    }
+    targetLVS->AddNewVolume(lv, treeStructure);
+  }
+  else { 
+    // the logical volumes should be kept in this directory.
+    G4LogicalVolume* targetLV = GetVolume(lv->GetName());
+    if (targetLV != 0) {
+      // G4cout << lv->GetName() << " had already stored in "
+      //        << fPathName << endl;
+    }
+    else {
+      fLogicalVolumes.insert(lv);
+    }
+  }
+}
+
+G4LogicalVolume* AliLVStructure::GetVolume(G4String lvName)
+{
+// Returns logical volume of lvName if present in the structure,
+// returns 0 otherwise.
+// ---
+
+  for (G4int i=0; i<fLogicalVolumes.entries(); i++) {
+    G4LogicalVolume* targetLV = fLogicalVolumes(i);
+    if (lvName == targetLV->GetName()) return targetLV;
+  }
+  return 0;
+}
+
+G4LogicalVolume* AliLVStructure::FindVolume(G4String name)
+{
+// Finds logical volume of given name in all structure tree.
+// ---
+
+  G4String path = name;
+  path.remove(0, fPathName.length());
+  if (path.first('/') != G4std::string::npos) { 
+    // SD exists in sub-directory
+    G4String subDir = ExtractDirName(path);
+    AliLVStructure* targetLVS = FindSubDirectory(subDir);
+    if (targetLVS == 0) {  
+      // The subdirectory is not found
+      G4String text = subDir + " is not found in " + fPathName;
+      AliGlobals:: Warning(text);
+      return 0;
+    }
+    else { 
+      return targetLVS->FindVolume(name); 
+    }
+  }
+  else { 
+    // LV must exist in this directory
+    G4LogicalVolume* targetLV = GetVolume(path);
+    if (targetLV == 0) {  
+      // The fLogicalVolumes is not found.
+      G4String text = path + " is not found in " + fPathName;
+      AliGlobals::Warning(text);
+    }
+    return targetLV;
+  }
+}
+
+void AliLVStructure::ListTree() const
+{
+// Prints LV tree structure.
+// ---
+
+  for (G4int i=0; i<fLogicalVolumes.entries(); i++) {
+    G4LogicalVolume* lv = fLogicalVolumes(i);
+    G4cout << fPathName << lv->GetName() << endl;
+  }
+  for (G4int j=0; j<fStructures.entries(); j++) { 
+    fStructures(j)->ListTree(); 
+  }
+}
+        
+void AliLVStructure::ListTreeLong() const
+{
+// Prints LV tree structure with number of
+// daughters (physical volume)
+// ---
+
+  for (G4int i=0; i<fLogicalVolumes.entries(); i++) {
+    G4LogicalVolume* lv = fLogicalVolumes(i);
+    G4cout << fPathName << lv->GetName() 
+           << " (" << lv->GetNoDaughters() << ")" << endl;
+  }
+  for (G4int j=0; j<fStructures.entries(); j++) { 
+    fStructures(j)->ListTreeLong(); 
+  }
+}
+        
+void AliLVStructure::SetVerboseLevel(G4int verbose) 
+{
+// Sets verbose level.
+// ---
+
+  fVerboseLevel = verbose;  
+  for (G4int i=0; i<fStructures.entries(); i++) { 
+    fStructures(i)->SetVerboseLevel(verbose); 
+  }
+}
+
+#ifdef ALICE_VISUALIZE
+void AliLVStructure::SetTreeVisibility(G4bool visibility)       
+{
+// Sets visibility to all logical volumes in the structure 
+// tree.
+// ---
+
+  for (G4int i=0; i<fLogicalVolumes.entries(); i++) {
+    G4LogicalVolume* lv = fLogicalVolumes(i);
+
+    const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes ();
+    G4VisAttributes* newVisAttributes = new G4VisAttributes(kpVisAttributes); 
+    delete kpVisAttributes;
+
+    newVisAttributes->SetVisibility(visibility); 
+
+    lv->SetVisAttributes(newVisAttributes);
+  }
+  for (G4int j=0; j<fStructures.entries(); j++) { 
+    fStructures(j)->SetTreeVisibility(visibility); 
+  }
+}
+
+void AliLVStructure::SetTreeColour(G4String colName)
+{
+// Sets colour specified  by name to all logical volumes
+// in the structure tree.
+// ---
+
+  for (G4int i=0; i<fLogicalVolumes.entries(); i++) {
+    G4LogicalVolume* lv = fLogicalVolumes(i);
+
+    const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes ();
+    G4VisAttributes* newVisAttributes = new G4VisAttributes(kpVisAttributes); 
+    delete kpVisAttributes;
+
+    AliColourStore* pColours = AliColourStore::Instance();
+    G4Colour colour = pColours->GetColour(colName);
+    newVisAttributes->SetColour(colour);
+
+    lv->SetVisAttributes(newVisAttributes);
+  }
+  for (G4int j=0; j<fStructures.entries(); j++) { 
+    fStructures(j)->SetTreeColour(colName); 
+  }
+}
+#endif             
+
+
diff --git a/AliGeant4/AliLVStructure.h b/AliGeant4/AliLVStructure.h
new file mode 100644 (file)
index 0000000..c2837ed
--- /dev/null
@@ -0,0 +1,66 @@
+// $Id$
+// Category: geometry
+//
+// Class that associates the name tree with logical volumes tree. 
+// Used for printing volumes trees.  
+
+#ifndef ALI_LV_STRUCTURE_H
+#define ALI_LV_STRUCTURE_H
+
+#include <G4LogicalVolume.hh>
+#include <globals.hh>
+
+#include <g4rw/tpordvec.h>
+
+class AliLVStructure 
+{
+  public:
+    AliLVStructure(G4String aPath);
+    AliLVStructure(const AliLVStructure& right);
+    // --> protected 
+    // AliLVStructure();
+    virtual ~AliLVStructure();
+
+    // operators
+    AliLVStructure& operator=(const AliLVStructure& right);
+    G4int operator==(const AliLVStructure &right) const;
+
+    // methods
+    void AddNewVolume(G4LogicalVolume* lv, G4String treeStructure);
+    void ListTree() const;
+    void ListTreeLong() const;
+
+    // set methods
+    void SetVerboseLevel(G4int verbose); 
+#ifdef ALICE_VISUALIZE
+    void SetTreeVisibility(G4bool visibility);       
+    void SetTreeColour(G4String colName);
+#endif             
+
+    // get methods
+    G4LogicalVolume* GetVolume(G4String name);
+    G4LogicalVolume* FindVolume(G4String name);
+
+  protected:
+    AliLVStructure(); 
+
+  private:
+    // methods
+    AliLVStructure* FindSubDirectory(G4String subDir);
+    G4String ExtractDirName(G4String path);
+
+    // data members
+    G4RWTPtrOrderedVector<AliLVStructure>   fStructures;                     //.
+                                                //vector of
+                                                //contained structures
+    G4RWTPtrOrderedVector<G4LogicalVolume>  fLogicalVolumes;                 //.
+                                                //vector of
+                                                //contained logical volumes
+                                               //(parallel to fStructures)
+    G4String  fPathName;     //full path name
+    G4String  fDirName;      //directory name
+    G4int     fVerboseLevel; //verbose level
+};
+
+#endif //ALI_LV_STRUCTURE_H
+
diff --git a/AliGeant4/AliLegoSensitiveDetector.cxx b/AliGeant4/AliLegoSensitiveDetector.cxx
new file mode 100644 (file)
index 0000000..fcf85fc
--- /dev/null
@@ -0,0 +1,91 @@
+// $Id$ //
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliLegoSensitiveDetector.h"
+#include "AliLego.h"
+
+#include "TG4StepManager.h"
+
+AliLegoSensitiveDetector::AliLegoSensitiveDetector(
+                             G4String name, AliLego* lego, 
+                            G4VSensitiveDetector* standardSD)
+  : TG4VSensitiveDetector(name),
+    fLego(lego),
+    fStandardSD(standardSD),
+    fStepManager(TG4StepManager::Instance())
+{
+//
+}
+
+AliLegoSensitiveDetector::AliLegoSensitiveDetector(
+                                 const AliLegoSensitiveDetector& right)
+  : TG4VSensitiveDetector(right)                            
+{
+//
+  fLego = right.fLego;
+  fStandardSD = right.fStandardSD;
+  fStepManager = right.fStepManager;
+}
+
+AliLegoSensitiveDetector::AliLegoSensitiveDetector() {
+//
+}
+
+AliLegoSensitiveDetector::~AliLegoSensitiveDetector() {
+//
+}
+
+// operators
+
+AliLegoSensitiveDetector& 
+AliLegoSensitiveDetector::operator=(const AliLegoSensitiveDetector &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  // base class assignement
+  TG4VSensitiveDetector::operator=(right);
+
+  fLego = right.fLego;
+  fStandardSD = right.fStandardSD;
+  fStepManager = right.fStepManager;
+  
+  return *this;
+}
+
+// public methods
+
+void AliLegoSensitiveDetector::Initialize(G4HCofThisEvent* hc)
+{
+// This method is called at the beginning of event action
+// before user defined BeginOfEventAction() method.
+}
+
+G4bool AliLegoSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*)
+{
+// Calls StepManager of associated lego.
+// ---
+
+  // let lego process step
+  fStepManager->SetStep(step);
+  fLego->StepManager();
+
+  return true;
+}
+
+void AliLegoSensitiveDetector::EndOfEvent(G4HCofThisEvent* hce){
+//
+}
+
+//void AliLegoSensitiveDetector::clear()
+//{} 
+
+void AliLegoSensitiveDetector::PrintAll() {
+//
+} 
+
+void AliLegoSensitiveDetector::DrawAll() {
+//
+} 
diff --git a/AliGeant4/AliLegoSensitiveDetector.h b/AliGeant4/AliLegoSensitiveDetector.h
new file mode 100644 (file)
index 0000000..b48ccac
--- /dev/null
@@ -0,0 +1,62 @@
+// $Id$
+// Category: geometry
+//
+// Special sensitive detector class for lego run.
+// It implements G4VSensitiveDetector::ProcessHits() 
+// with AliLego:: StepManager().
+
+#ifndef ALI_LEGO_SENSITIVE_DETECTOR_H
+#define ALI_LEGO_SENSITIVE_DETECTOR_H
+
+#include "TG4VSensitiveDetector.h"
+
+#include <globals.hh>
+
+class AliLego;
+class TG4StepManager;
+
+class G4HCofThisEvent;
+class G4Step;
+
+class AliLegoSensitiveDetector : public TG4VSensitiveDetector
+{
+  public:
+    AliLegoSensitiveDetector(G4String name, AliLego* lego,
+                             G4VSensitiveDetector* standardSD);
+    AliLegoSensitiveDetector(const AliLegoSensitiveDetector& right);
+    // --> protected
+    // AliLegoSensitiveDetector();
+    virtual ~AliLegoSensitiveDetector();
+
+    // operators
+    AliLegoSensitiveDetector& operator=(const AliLegoSensitiveDetector& right);
+
+    // methods
+    virtual void Initialize(G4HCofThisEvent* hc);
+    virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history);
+    virtual void EndOfEvent(G4HCofThisEvent* hce);
+    //virtual void clear();
+    virtual void PrintAll();
+    virtual void DrawAll();
+    
+    // get methods
+    G4VSensitiveDetector* GetStandardSD() const;
+    
+  protected:  
+    AliLegoSensitiveDetector();
+    
+  private:
+    // data members
+    AliLego*               fLego;        //lego from AliRoot
+    G4VSensitiveDetector*  fStandardSD;  //standard sensitive detector
+    TG4StepManager*        fStepManager; //TG4StepManager
+};
+
+// inline methods
+
+inline G4VSensitiveDetector* AliLegoSensitiveDetector::GetStandardSD() const
+{ return fStandardSD; }
+
+#endif //ALI_LEGO_SENSITIVE_DETECTOR_H
+
+
diff --git a/AliGeant4/AliMagneticField.cxx b/AliGeant4/AliMagneticField.cxx
new file mode 100644 (file)
index 0000000..234f058
--- /dev/null
@@ -0,0 +1,92 @@
+// $Id$
+// Category: geometry
+//
+// According to:
+// Id: ExN02MagneticField.cc,v 1.1 1999/01/07 16:05:49 gunter Exp 
+// GEANT4 tag Name: geant4-00-01
+
+#include "AliMagneticField.h"
+
+#include <G4FieldManager.hh>
+#include <G4TransportationManager.hh>
+
+//  Constructors
+
+AliMagneticField::AliMagneticField()
+  : G4UniformMagField(G4ThreeVector()) 
+{
+//
+  GetGlobalFieldManager()->CreateChordFinder(this);
+}
+
+AliMagneticField::AliMagneticField(G4ThreeVector fieldVector)
+  : G4UniformMagField(fieldVector)
+{    
+//
+  GetGlobalFieldManager()->CreateChordFinder(this);
+}
+
+AliMagneticField::AliMagneticField(const AliMagneticField& right)
+  : G4UniformMagField(right)
+{
+//  
+  GetGlobalFieldManager()->CreateChordFinder(this);
+}
+
+AliMagneticField::~AliMagneticField() {
+//
+}
+
+// operators
+
+AliMagneticField& 
+AliMagneticField::operator=(const AliMagneticField& right)
+{                                
+  // check assignement to self
+  if (this == &right) return *this;
+
+  // base class assignement
+  G4UniformMagField::operator=(right);
+  
+  return *this;
+}  
+
+// public methods
+
+void AliMagneticField::SetFieldValue(G4double fieldValue)
+{
+// Sets the value of the Global Field to fieldValue along Z.
+// ---
+
+  G4UniformMagField::SetFieldValue(G4ThreeVector(0,0,fieldValue));
+}
+
+void AliMagneticField::SetFieldValue(G4ThreeVector fieldVector)
+{
+// Sets the value of the Global Field.
+// ---
+
+  // Find the Field Manager for the global field
+  G4FieldManager* fieldMgr= GetGlobalFieldManager();
+    
+  if(fieldVector!=G4ThreeVector(0.,0.,0.)) { 
+    G4UniformMagField::SetFieldValue(fieldVector); 
+    fieldMgr->SetDetectorField(this);
+  } 
+  else {
+    // If the new field's value is Zero, then it is best to
+    //  insure that it is not used for propagation.
+    G4MagneticField* magField = NULL;
+    fieldMgr->SetDetectorField(magField);
+  }
+}
+
+G4FieldManager*  AliMagneticField::GetGlobalFieldManager()
+{
+// Utility method/
+// ---
+
+  return G4TransportationManager::GetTransportationManager()
+           ->GetFieldManager();
+}
+    
diff --git a/AliGeant4/AliMagneticField.h b/AliGeant4/AliMagneticField.h
new file mode 100644 (file)
index 0000000..c837312
--- /dev/null
@@ -0,0 +1,40 @@
+//  $Id$
+// Category: geometry
+//
+// Uniform magnetic field.
+// According to:
+// Id: ExN02MagneticField.hh,v 1.1 1999/01/07 16:05:47 gunter Exp 
+// GEANT4 tag Name: geant4-00-01 
+
+#ifndef ALI_MAGNETIC_FIELD_H
+#define ALI_MAGNETIC_FIELD_H
+
+#include <G4UniformMagField.hh>
+
+class G4FieldManager;
+
+class AliMagneticField: public G4UniformMagField
+{
+  public:
+    AliMagneticField();                   //  A zero field
+    AliMagneticField(G4ThreeVector fied); //  The value of the field
+    AliMagneticField(const AliMagneticField& right);
+    virtual ~AliMagneticField();  
+      
+    // operators
+    AliMagneticField& operator=(const AliMagneticField& right);
+
+    // set methods
+    void SetFieldValue(G4ThreeVector fieldVector);
+    void SetFieldValue(G4double      fieldValue);
+              // Set the field to (0, 0, fieldValue)
+
+    // get methods
+    G4ThreeVector GetConstantFieldValue();
+
+  protected:
+    // Find the global Field Manager
+    G4FieldManager* GetGlobalFieldManager(); 
+};
+
+#endif //ALI_MAGNETIC_FIELD_H
diff --git a/AliGeant4/AliModuleConstruction.cxx b/AliGeant4/AliModuleConstruction.cxx
new file mode 100644 (file)
index 0000000..a9da9bc
--- /dev/null
@@ -0,0 +1,347 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliModuleConstruction.h"
+#include "AliGlobals.h"
+#include "AliLVStructure.h"
+
+#ifdef ALICE_VISUALIZE
+#include "AliColourStore.h"
+
+#include <G4Colour.hh>
+#include <G4VisAttributes.hh>
+#endif //ALICE_VISUALIZE
+#include <G4LogicalVolumeStore.hh>
+#include <G4LogicalVolume.hh>
+
+#include <fstream.h>
+
+AliModuleConstruction::AliModuleConstruction(G4String moduleName) 
+  : fModuleName(moduleName), 
+    fModuleFrameName(moduleName),
+    fModuleFrameLV(0),
+    fAliModule(0),
+    fReadGeometry(false),
+    fWriteGeometry(false),
+    fDataFilePath("")    
+{
+//
+  moduleName.toLower();
+  fMessenger = new AliModuleConstructionMessenger(this, moduleName);
+}
+
+AliModuleConstruction::AliModuleConstruction(const AliModuleConstruction& right)
+{
+//
+  fModuleName = right.fModuleName; 
+  fModuleFrameName = right.fModuleFrameName;
+  fModuleFrameLV = right.fModuleFrameLV;
+  fAliModule = right.fAliModule;
+  fReadGeometry = right.fReadGeometry;
+  fWriteGeometry = right.fWriteGeometry;
+  fDataFilePath = right.fDataFilePath;
+
+  // new messenger
+  G4String moduleName = fModuleName;
+  moduleName.toLower();
+  fMessenger = new AliModuleConstructionMessenger(this, moduleName);
+}
+
+AliModuleConstruction::AliModuleConstruction()
+  : fModuleName(""), 
+    fModuleFrameName(""),
+    fModuleFrameLV(0),
+    fMessenger(0),
+    fAliModule(0),
+    fReadGeometry(false),
+    fWriteGeometry(false),
+    fDataFilePath("")    
+{
+//
+}
+
+AliModuleConstruction::~AliModuleConstruction()
+{
+//
+  delete fMessenger;
+  delete fAliModule;
+}
+
+// operators
+
+AliModuleConstruction& 
+AliModuleConstruction::operator=(const AliModuleConstruction& right)
+{    
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  fModuleName = right.fModuleName; 
+  fModuleFrameName = right.fModuleFrameName;
+  fModuleFrameLV = right.fModuleFrameLV;
+  fAliModule = right.fAliModule;
+  fReadGeometry = right.fReadGeometry;
+  fWriteGeometry = right.fWriteGeometry;
+  fDataFilePath = right.fDataFilePath;
+
+  return *this;
+}
+
+G4int 
+AliModuleConstruction::operator==(const AliModuleConstruction& right) const
+{
+//    
+  return 0;
+}
+
+G4int 
+AliModuleConstruction::operator!=(const AliModuleConstruction& right) const
+{
+//    
+  G4int returnValue = 1;
+  if (*this == right) returnValue = 0; 
+  
+  return returnValue;
+}
+
+// protected methods
+
+void AliModuleConstruction::RegisterLogicalVolume(G4LogicalVolume* lv,
+       G4String path, AliLVStructure& lvStructure)
+{
+// Registers logical volume lv in the structure.
+// ---        
+
+  G4String lvName = lv->GetName();
+  lvStructure.AddNewVolume(lv, path);
+  
+  // register daughters
+  G4int nofDaughters = lv->GetNoDaughters();
+  if (nofDaughters>0) {
+    G4String previousName = "";
+    for (G4int i=0; i<nofDaughters; i++) {
+      G4LogicalVolume* lvd = lv->GetDaughter(i)->GetLogicalVolume();
+      G4String currentName = lvd->GetName();
+      if (currentName != lvName && currentName != previousName) { 
+        G4String newPath = path + lvName +"/";
+        RegisterLogicalVolume(lvd, newPath, lvStructure);
+       previousName = currentName;
+      }
+    }
+  }     
+}          
+
+// public methods
+
+void AliModuleConstruction::SetDetFrame(G4bool warn)
+{ 
+// The logical volume with name identical with
+// fModuleName is retrieved from G4LogicalVolumeStore.
+// ---
+
+  fModuleFrameLV = FindLogicalVolume(fModuleFrameName, true);
+  
+  if (fModuleFrameLV == 0 && warn) {
+    G4String text = "AliModuleConstruction: Detector frame for ";
+    text = text + fModuleFrameName + " has not been found.";
+    AliGlobals::Warning(text); 
+  }  
+}
+
+void AliModuleConstruction::SetDetFrame(G4String frameName, G4bool warn)
+{ 
+// The logical volume with frameName
+// is retrieved from G4LogicalVolumeStore.
+// ---
+
+  fModuleFrameName = frameName;
+  SetDetFrame(warn);
+}
+
+void AliModuleConstruction::ListAllLVTree()
+{
+// Lists all logical volumes tree if the frame logical volume 
+// is defined.
+// ---- 
+
+  if (fModuleFrameLV) 
+    ListLVTree(fModuleFrameLV->GetName());
+  else {
+    G4String text = "AliModuleConstruction::ListAllLVTree:\n";
+    text = text + "    Detector frame is not defined.";    
+    AliGlobals::Warning(text);
+  }   
+}
+
+void AliModuleConstruction::ListAllLVTreeLong()
+{
+// Lists all logical volume tree if the frame logical volume 
+// is defined with numbers of daughters (physical volumes).
+// ---- 
+
+  if (fModuleFrameLV) 
+    ListLVTreeLong(fModuleFrameLV->GetName());
+  else {
+    G4String text = "AliModuleConstruction::ListAllLVTreeLong:\n";
+    text = text + "    Detector frame is not defined.";    
+    AliGlobals::Warning(text);
+  }  
+}
+
+void AliModuleConstruction::ListLVTree(G4String lvName)
+{
+// Lists logical volumes tree (daughters) of the logical volume 
+// with specified lvName.
+// ---- 
+
+  G4LogicalVolume* lv = FindLogicalVolume(lvName);
+  if (lv)
+  {
+    G4String path = "";
+    AliLVStructure lvStructure(path);
+    RegisterLogicalVolume(lv, path, lvStructure);
+    lvStructure.ListTree();
+  }
+}
+
+void AliModuleConstruction::ListLVTreeLong(G4String lvName)
+{
+// Lists logical volumes tree (daughters) of the logical volume 
+// with specified lvName with numbers of daughters (physical volumes).
+// ---- 
+
+  G4LogicalVolume* lv = FindLogicalVolume(lvName);
+  if (lv) {
+    G4String path = "";
+    AliLVStructure lvStructure(path);
+    RegisterLogicalVolume(lv, path, lvStructure);
+    lvStructure.ListTreeLong();
+  }
+}
+
+G4LogicalVolume* AliModuleConstruction::FindLogicalVolume(
+                                          G4String name, G4bool silent) const
+{
+// Finds logical volume with specified name in G4LogicalVolumeStore.
+// (To do: use this method only for retrieving detector frame;
+//  add method FindLogicalVolumeInDet - that will search only
+//  in the detector frame LVTree.)
+// ---
+
+  G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
+  
+  for (G4int i=0; i<pLVStore->entries(); i++) {
+    G4LogicalVolume* lv = pLVStore->at(i);
+    if (lv->GetName() == name) return lv;
+  }
+  
+  G4String text = "AliModuleConstruction: Logical volume "; 
+  text = text + name + " does not exist.";
+  if (!silent) AliGlobals::Warning(text);
+  return 0;                     
+}  
+
+#ifdef ALICE_VISUALIZE
+
+void AliModuleConstruction::SetDetVisibility(G4bool visibility)
+{
+// Sets visibility to all detector logical volumes if
+// frame logical volume is defined.
+// ---
+
+  if (fModuleFrameLV) 
+    SetLVTreeVisibility(fModuleFrameLV, visibility);  
+  else  {
+    G4String text = "AliModuleConstruction::SetDetVisibility:\n";
+    text = text + "    Detector frame is not defined.";    
+    AliGlobals::Warning(text);
+  }  
+}
+
+
+void AliModuleConstruction::SetLVTreeVisibility(G4LogicalVolume* lv, 
+                             G4bool visibility)
+{ 
+// Sets visibility to the logical volumes tree (daughters) of 
+// the logical volume lv.
+// ---
+
+  if (lv) {
+    G4String path = "";
+    AliLVStructure lvStructure(path);
+    RegisterLogicalVolume(lv, path, lvStructure);
+    lvStructure.SetTreeVisibility(visibility);
+  }
+}
+
+void AliModuleConstruction::SetVolumeVisibility(G4LogicalVolume* lv, 
+                             G4bool visibility)
+{ 
+// Sets visibility to the specified logical volume.
+// ---
+
+  if (lv) {
+    const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes ();
+    G4VisAttributes* newVisAttributes = new G4VisAttributes(kpVisAttributes); 
+    delete kpVisAttributes;
+
+    newVisAttributes->SetVisibility(visibility); 
+
+    lv->SetVisAttributes(newVisAttributes);
+  }
+}
+
+void AliModuleConstruction::SetDetColour(G4String colName)
+{
+// Sets colour to all detector logical volumes if
+// frame logical volume is defined.
+// ---
+
+  if (fModuleFrameLV) 
+    SetLVTreeColour(fModuleFrameLV, colName);  
+  else { 
+    G4String text = "AliModuleConstruction::SetDetColour:\n";
+    text = text + "    Detector frame is not defined.";    
+    AliGlobals::Warning(text);
+  }  
+}
+
+void AliModuleConstruction::SetLVTreeColour(G4LogicalVolume* lv, 
+                             G4String colName)
+{ 
+// Sets colour to the logical volumes tree (daughters) of 
+// the logical volume lv.
+// ---
+
+  if (lv) {
+    G4String path = "";
+    AliLVStructure lvStructure(path);
+    RegisterLogicalVolume(lv, path, lvStructure);
+    lvStructure.SetTreeVisibility(true);
+    lvStructure.SetTreeColour(colName);
+  }
+}
+
+void AliModuleConstruction::SetVolumeColour(G4LogicalVolume* lv,
+                             G4String colName)
+{
+// Sets colour to the specified logical volume.
+// ---
+
+  if (lv) {
+    const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes ();
+    G4VisAttributes* newVisAttributes = new G4VisAttributes(kpVisAttributes); 
+    delete kpVisAttributes;
+
+    AliColourStore* pColours = AliColourStore::Instance();
+    const G4Colour kColour = pColours->GetColour(colName);
+    newVisAttributes->SetVisibility(true); 
+    newVisAttributes->SetColour(kColour);
+
+    lv->SetVisAttributes(newVisAttributes);
+  }      
+}
+
+#endif //ALICE_VISUALIZE
+
diff --git a/AliGeant4/AliModuleConstruction.h b/AliGeant4/AliModuleConstruction.h
new file mode 100644 (file)
index 0000000..32382a0
--- /dev/null
@@ -0,0 +1,125 @@
+// $Id$
+// Category: geometry
+//
+// Abstract base class for modular construction of geometry,
+// providing methods for browsing geometry (list volumes trees, 
+// visualization).
+
+#ifndef ALI_MODULE_CONSTRUCTION_H
+#define ALI_MODULE_CONSTRUCTION_H
+
+#include "AliModuleConstructionMessenger.h"
+#include "AliModule.h"
+
+#include <globals.hh>
+#ifdef ALICE_VISUALIZE
+#include <G4VisAttributes.hh>
+#endif
+
+class AliLVStructure;
+
+class G4VPhysicalVolume;
+class G4LogicalVolume;
+#ifdef ALICE_VISUALIZE
+class G4Colour;
+#endif
+
+class AliModuleConstruction
+{
+  public:
+    AliModuleConstruction(G4String moduleName);
+    AliModuleConstruction(const AliModuleConstruction& right);
+    // --> protected
+    // AliModuleConstruction();
+    virtual ~AliModuleConstruction();
+
+    // operators
+    AliModuleConstruction& operator=(const AliModuleConstruction &right);
+    G4int operator==(const AliModuleConstruction& right) const;
+    G4int operator!=(const AliModuleConstruction& right) const;
+
+    // methods
+    virtual void Construct() = 0;
+    void ListAllLVTree();
+    void ListAllLVTreeLong();
+    void ListLVTree(G4String lvName);
+    void ListLVTreeLong(G4String lvName);
+    G4LogicalVolume* FindLogicalVolume(G4String name, 
+                                       G4bool silent = false) const;
+
+    // set methods
+    void SetDetFrame(G4bool warn = true);
+    void SetDetFrame(G4String frameName, G4bool warn = true);
+    void SetReadGeometry(G4bool readGeometry);
+    void SetWriteGeometry(G4bool writeGeometry);
+#ifdef ALICE_VISUALIZE
+    void SetDetVisibility(G4bool visibility);
+    void SetLVTreeVisibility(G4LogicalVolume* lv, G4bool visibility);
+    void SetVolumeVisibility(G4LogicalVolume* lv, G4bool visibility);
+    void SetDetColour(G4String colName);
+    void SetLVTreeColour(G4LogicalVolume* lv, G4String colName);
+    void SetVolumeColour(G4LogicalVolume* lv, G4String colName);     
+#endif
+
+    // get methods
+    G4String GetDetName() const;
+    G4LogicalVolume* GetDetFrame() const;
+    AliModule* GetAliModule() const;
+    G4bool GetReadGeometry() const;
+    G4bool GetWriteGeometry() const;
+    G4String GetDataFilePath() const;
+
+  protected:
+    AliModuleConstruction(); 
+
+    // data members
+    G4String            fModuleName;      //module name
+    G4String            fModuleFrameName; //module frame name
+                                          //(used for retrieving the frame LV)
+    G4LogicalVolume*    fModuleFrameLV;   //module frame logical volume
+
+    // to be moved to AliSingleModuleConstruction
+    // in order to make AliModuleConstruction independent on
+    // AliRoot
+    AliModule*          fAliModule;       //AliModule
+    G4bool              fReadGeometry;    //if true: geometry is read from file
+    G4bool              fWriteGeometry;   //if true: geometry is written to file
+    G4String            fDataFilePath;    //path to geometry data file
+
+  private:
+    // methods
+    void RegisterLogicalVolume(G4LogicalVolume* lv, G4String path, 
+           AliLVStructure& lvStructure);
+
+    // data members
+    AliModuleConstructionMessenger*  fMessenger; //messenger     
+};
+
+// inline methods
+
+inline void AliModuleConstruction::SetReadGeometry(G4bool readGeometry)
+{ fReadGeometry = readGeometry; }  
+
+inline void AliModuleConstruction::SetWriteGeometry(G4bool writeGeometry)
+{ fWriteGeometry = writeGeometry; }  
+
+inline G4String AliModuleConstruction::GetDetName() const
+{ return fModuleName; }
+
+inline G4LogicalVolume* AliModuleConstruction::GetDetFrame() const
+{ return fModuleFrameLV; }
+
+inline AliModule* AliModuleConstruction::GetAliModule() const
+{ return fAliModule; }
+
+inline G4bool AliModuleConstruction::GetReadGeometry() const
+{ return fReadGeometry; }
+
+inline G4bool AliModuleConstruction::GetWriteGeometry() const
+{ return fWriteGeometry; }
+
+inline G4String AliModuleConstruction::GetDataFilePath() const
+{ return fDataFilePath; }
+
+#endif //ALI_MODULE_CONSTRUCTION_H
+
diff --git a/AliGeant4/AliModuleConstructionMessenger.cxx b/AliGeant4/AliModuleConstructionMessenger.cxx
new file mode 100644 (file)
index 0000000..94a1cd5
--- /dev/null
@@ -0,0 +1,234 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliModuleConstructionMessenger.h"
+#include "AliModuleConstruction.h"
+#include "AliGlobals.h"
+#ifdef ALICE_VISUALIZE
+#include "AliColourStore.h"
+#endif
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithABool.hh>
+#include <G4UIcmdWithAString.hh>
+#include <G4UIcmdWithoutParameter.hh>
+#include <G4LogicalVolume.hh>
+
+AliModuleConstructionMessenger::AliModuleConstructionMessenger(
+   AliModuleConstruction* moduleConstruction, G4String moduleName)
+ : fModuleConstruction(moduleConstruction)
+{
+//
+  G4String dirName = "/aliDet/"; 
+  dirName = dirName + moduleName + "/"; 
+  fModuleDirectory = new G4UIdirectory(dirName);
+  G4String guidance = "AlSubDetConstruction ";
+  guidance = guidance + moduleName + " control commands.";
+  fModuleDirectory->SetGuidance(guidance);
+
+  G4String commandPath = dirName + "setFrame";
+  fSetFrameCmd= new G4UIcmdWithAString(commandPath, this);
+  fSetFrameCmd ->SetGuidance("Set detector frame");
+  fSetFrameCmd->SetParameterName("frameName", false);
+  fSetFrameCmd->AvailableForStates(PreInit, Idle);  
+  commandPath = dirName + "list";
+  fListCmd = new G4UIcmdWithoutParameter(commandPath, this);
+  guidance = "List all logical volumes of ";
+  guidance = guidance + moduleName + " detector";
+  fListCmd->SetGuidance(guidance);
+  fListCmd->AvailableForStates(PreInit,Idle);  
+  commandPath = dirName + "listLong";
+  fListLongCmd = new G4UIcmdWithoutParameter(commandPath, this);
+  fListLongCmd
+    ->SetGuidance("List all logical volumes and number of its physical volumes");
+  guidance = "of " + moduleName + " detector";
+  fListLongCmd->SetGuidance(guidance);
+  fListLongCmd->AvailableForStates(PreInit,Idle);  
+  commandPath = dirName + "listDaughters";
+  fListDaughtersCmd = new G4UIcmdWithAString(commandPath, this);
+  fListDaughtersCmd->SetGuidance("List daughters of the given logical volumes");
+  fListDaughtersCmd->SetParameterName("lvName", false);
+  fListDaughtersCmd->AvailableForStates(PreInit,Idle);  
+  commandPath = dirName + "listLongDaughters";
+  fListLongDaughtersCmd = new G4UIcmdWithAString(commandPath, this);
+  fListLongDaughtersCmd
+    ->SetGuidance("List daughters of the given logical volumes");
+  fListLongDaughtersCmd->SetGuidance("and number of its physical volumes");
+  fListLongDaughtersCmd->SetParameterName("lvName", false);
+  fListLongDaughtersCmd->AvailableForStates(PreInit,Idle);  
+#ifdef ALICE_VISUALIZE
+  fCurrentVolume = 0;
+
+  commandPath = dirName + "setVolume";
+  fSetCurrentLVCmd = new G4UIcmdWithAString(commandPath, this);
+  fSetCurrentLVCmd->SetGuidance("Set the current logical volume.");
+  fSetCurrentLVCmd->SetParameterName("curVolume", false);
+  fSetCurrentLVCmd->AvailableForStates(PreInit,Idle);  
+  commandPath = dirName + "setVisibility";
+  fSetDetVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
+  guidance = "Make ";
+  guidance = guidance + moduleName + " detector visible/invisible.";
+  fSetDetVisibilityCmd->SetGuidance(guidance);
+  fSetDetVisibilityCmd->SetParameterName("detVisibility", false);
+  fSetDetVisibilityCmd->AvailableForStates(PreInit,Idle);  
+  commandPath = dirName + "setLVTreeVisibility";
+  fSetLVTreeVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
+  fSetLVTreeVisibilityCmd 
+    ->SetGuidance("Make current volume tree visible/invisible.");
+  fSetLVTreeVisibilityCmd->SetParameterName("volVisibility", false);
+  fSetLVTreeVisibilityCmd->AvailableForStates(PreInit,Idle);  
+  commandPath = dirName + "setVolVisibility";
+  fSetVolVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
+  fSetVolVisibilityCmd 
+    ->SetGuidance("Make current volume visible/invisible.");
+  fSetVolVisibilityCmd->SetParameterName("volVisibility", false);
+  fSetVolVisibilityCmd->AvailableForStates(PreInit,Idle);  
+  commandPath = dirName + "setColour";
+  fSetDetColourCmd = new G4UIcmdWithAString(commandPath, this);
+  AliColourStore* pColours = AliColourStore::Instance();
+  guidance = "Set colour for all ";
+  guidance = guidance + moduleName + " detector volumes.";
+  fSetDetColourCmd->SetGuidance(guidance);
+  fSetDetColourCmd->SetGuidance("Available colours:");
+  fSetDetColourCmd->SetGuidance(pColours->GetColoursListWithCommas());
+  fSetDetColourCmd->SetParameterName("detColour", false);
+  G4String candidatesList = pColours->GetColoursList();  
+  fSetDetColourCmd->SetCandidates(candidatesList);
+  fSetDetColourCmd->AvailableForStates(PreInit,Idle);  
+
+  commandPath = dirName + "setLVTreeColour";
+  fSetLVTreeColourCmd = new G4UIcmdWithAString(commandPath, this);
+  fSetLVTreeColourCmd->SetGuidance("Set colour for the current volume tree.");
+  fSetLVTreeColourCmd->SetGuidance("Available colours:");
+  fSetLVTreeColourCmd->SetGuidance(pColours->GetColoursListWithCommas());
+  fSetLVTreeColourCmd->SetParameterName("volColour", false);
+  candidatesList = pColours->GetColoursList();  
+  fSetLVTreeColourCmd->SetCandidates(candidatesList);
+  fSetLVTreeColourCmd->AvailableForStates(PreInit,Idle);  
+
+  commandPath = dirName + "setVolColour";
+  fSetVolColourCmd = new G4UIcmdWithAString(commandPath, this);
+  fSetVolColourCmd->SetGuidance("Set colour for the current volume.");
+  fSetVolColourCmd->SetGuidance("Available colours:");
+  fSetVolColourCmd->SetGuidance(pColours->GetColoursListWithCommas());
+  fSetVolColourCmd->SetParameterName("volColour", false);
+  candidatesList = pColours->GetColoursList();  
+  fSetVolColourCmd->SetCandidates(candidatesList);
+  fSetVolColourCmd->AvailableForStates(PreInit,Idle);  
+#endif //ALICE_VISUALIZE
+}
+
+AliModuleConstructionMessenger::AliModuleConstructionMessenger() {
+//
+}
+
+AliModuleConstructionMessenger::AliModuleConstructionMessenger(
+                                const AliModuleConstructionMessenger& right)
+{
+//
+  AliGlobals::Exception(
+    "AliModuleConstructionMessenger is protected from copying.");
+}
+
+AliModuleConstructionMessenger::~AliModuleConstructionMessenger()
+{
+//
+  delete fModuleDirectory;
+  delete fSetFrameCmd;  
+  delete fListCmd;
+  delete fListLongCmd;
+  delete fListDaughtersCmd;
+  delete fListLongDaughtersCmd;
+#ifdef ALICE_VISUALIZE
+  delete fSetDetVisibilityCmd;
+  delete fSetDetColourCmd;
+  delete fSetCurrentLVCmd;
+  delete fSetVolVisibilityCmd;    
+  delete fSetVolColourCmd;    
+  delete fSetLVTreeVisibilityCmd;    
+  delete fSetLVTreeColourCmd;    
+#endif //ALICE_VISUALIZE
+}
+
+// operators
+
+AliModuleConstructionMessenger& 
+AliModuleConstructionMessenger::operator=(
+                                const AliModuleConstructionMessenger& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception(
+     "AliModuleConstructionMessenger is protected from assigning.");
+    
+  return *this;  
+}    
+          
+// public methods
+  
+void AliModuleConstructionMessenger::SetNewValue(G4UIcommand* command,
+                                                 G4String newValues)
+{
+// Applies command to the associated object.
+// ---
+
+  if (command == fSetFrameCmd) {
+    fModuleConstruction->SetDetFrame(newValues);
+  }
+  else if (command == fListCmd) {
+    fModuleConstruction->ListAllLVTree();
+  }
+  else if (command == fListLongCmd) {
+    fModuleConstruction->ListAllLVTreeLong();
+  }
+  else if (command == fListDaughtersCmd) {
+    fModuleConstruction->ListLVTree(newValues);
+  }
+  else if (command == fListLongDaughtersCmd) {
+    fModuleConstruction->ListLVTreeLong(newValues);
+  }
+#ifdef ALICE_VISUALIZE
+  if (command == fSetCurrentLVCmd) {
+    fCurrentVolume = fModuleConstruction->FindLogicalVolume(newValues);
+  }    
+  else if (command == fSetDetVisibilityCmd) {
+    fModuleConstruction
+      ->SetDetVisibility(fSetDetVisibilityCmd->GetNewBoolValue(newValues)); 
+  } 
+  else if (command == fSetLVTreeVisibilityCmd) {
+    fModuleConstruction
+      ->SetLVTreeVisibility(fCurrentVolume,
+          fSetVolVisibilityCmd->GetNewBoolValue(newValues)); 
+  } 
+  else if (command == fSetVolVisibilityCmd) {
+    fModuleConstruction
+      ->SetVolumeVisibility(fCurrentVolume,
+          fSetVolVisibilityCmd->GetNewBoolValue(newValues)); 
+  } 
+  else if (command == fSetDetColourCmd) {
+    fModuleConstruction
+      ->SetDetColour(newValues);
+  }     
+  else if (command == fSetLVTreeColourCmd) {
+    fModuleConstruction
+      ->SetLVTreeColour(fCurrentVolume, newValues);
+  }     
+  else if (command == fSetVolColourCmd) {
+    fModuleConstruction
+      ->SetVolumeColour(fCurrentVolume, newValues);
+  }     
+#endif //ALICE_VISUALIZE
+}
+
diff --git a/AliGeant4/AliModuleConstructionMessenger.h b/AliGeant4/AliModuleConstructionMessenger.h
new file mode 100644 (file)
index 0000000..3d8b6d3
--- /dev/null
@@ -0,0 +1,68 @@
+// $Id$
+// Category: geometry
+//
+// Messenger class that defines command directory for each
+// AliModuleConstruction instance.
+
+#ifndef ALI_MODULE_CONSTRUCTION_MESSENGER_H
+#define ALI_MODULE_CONSTRUCTION_MESSENGER_H
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliModuleConstruction;
+
+class G4UIdirectory;
+class G4UIcmdWithABool;
+class G4UIcmdWithAString;
+class G4UIcmdWithoutParameter;
+class G4LogicalVolume;
+
+class AliModuleConstructionMessenger: public G4UImessenger
+{
+  public:
+    AliModuleConstructionMessenger(
+       AliModuleConstruction* moduleConstruction, G4String moduleName);
+    // --> protected   
+    // AliModuleConstructionMessenger();
+    // AliModuleConstructionMessenger(
+    //       const AliModuleConstructionMessenger& right);
+    virtual ~AliModuleConstructionMessenger();
+
+    // methods
+    virtual void SetNewValue(G4UIcommand* command, G4String newValues);
+
+  protected:
+    AliModuleConstructionMessenger();
+    AliModuleConstructionMessenger(
+             const AliModuleConstructionMessenger& right);
+
+    // operators
+    AliModuleConstructionMessenger& operator=(
+             const AliModuleConstructionMessenger &right);
+             
+  private:
+    // data members
+    AliModuleConstruction*    fModuleConstruction;   //associated class
+    G4UIdirectory*            fModuleDirectory;      //command directory
+    G4UIcmdWithAString*       fSetFrameCmd;          //command: setFrame
+    G4UIcmdWithoutParameter*  fListCmd;              //command: list
+    G4UIcmdWithoutParameter*  fListLongCmd;          //command: listLong
+    G4UIcmdWithAString*       fListDaughtersCmd;     //command: listDaughters
+    G4UIcmdWithAString*       fListLongDaughtersCmd; //command: listLongDaughters  
+    
+#ifdef ALICE_VISUALIZE
+    // commands data members
+    G4LogicalVolume*          fCurrentVolume;          //current logical volume
+    G4UIcmdWithAString*       fSetCurrentLVCmd;        //command: setVolume
+    G4UIcmdWithABool*         fSetDetVisibilityCmd;    //command: setDetVisibility
+    G4UIcmdWithABool*         fSetLVTreeVisibilityCmd; //command: setLVTreeVisibility   
+    G4UIcmdWithABool*         fSetVolVisibilityCmd;    //command: setVolVisibility
+    G4UIcmdWithAString*       fSetDetColourCmd;        //command: setDetColour
+    G4UIcmdWithAString*       fSetLVTreeColourCmd;     //command: setLVTreeColour  
+    G4UIcmdWithAString*       fSetVolColourCmd;        //command: setVolColour
+#endif //ALICE_VISUALIZE
+};
+
+#endif //ALI_MODULE_CONSTRUCTION_MESSENGER_H
+
diff --git a/AliGeant4/AliModuleType.h b/AliGeant4/AliModuleType.h
new file mode 100644 (file)
index 0000000..21d2ab9
--- /dev/null
@@ -0,0 +1,8 @@
+// $Id$
+
+#ifndef ALI_MODULE_TYPE_H
+#define ALI_MODULE_TYPE_H
+
+enum AliModuleType { kDetector, kStructure };
+
+#endif //ALI_MODULE_TYPE_H
diff --git a/AliGeant4/AliModulesComposition.cxx b/AliGeant4/AliModulesComposition.cxx
new file mode 100644 (file)
index 0000000..d7e9288
--- /dev/null
@@ -0,0 +1,451 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliModulesComposition.h"
+#include "AliModulesCompositionMessenger.h"
+#include "AliSingleModuleConstruction.h"
+#include "AliMoreModulesConstruction.h"
+#include "AliMagneticField.h"
+#include "AliGlobals.h"
+
+#include <G4UniformMagField.hh>
+#include <G4FieldManager.hh>
+#include <G4TransportationManager.hh>
+
+AliModulesComposition::AliModulesComposition()
+  : fAllLVSensitive(false),
+    fReadGeometry(false),
+    fWriteGeometry(false)    
+{
+//
+  fMoreModulesConstruction = new AliMoreModulesConstruction();
+  fMagneticField = new AliMagneticField();
+  fMessenger = new AliModulesCompositionMessenger(this);
+}
+
+AliModulesComposition::AliModulesComposition(const AliModulesComposition& right)
+{
+//
+  AliGlobals::Exception("AliModulesComposition is protected from copying.");  
+}
+
+AliModulesComposition::~AliModulesComposition() {
+//   
+  delete fMoreModulesConstruction;
+  delete fMagneticField;
+  delete fMessenger; 
+  
+  // destroy det switch vector
+  fDetSwitchVector.clearAndDestroy();  
+  
+  // destroy det construction vector
+  fModuleConstructionVector.clearAndDestroy();
+}
+
+// operators
+
+AliModulesComposition& 
+AliModulesComposition::operator=(const AliModulesComposition& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliModulesComposition is protected from assigning.");  
+
+  return *this;  
+}    
+          
+// protected methods
+
+void AliModulesComposition::AddDetSwitch(AliDetSwitch* detSwitch)
+{
+// Adds detSwitch to the detSwitch vector.
+// ---
+
+  fDetSwitchVector.insert(detSwitch);
+  fMessenger->SetCandidates();
+}  
+  
+void AliModulesComposition::AddSingleModuleConstruction(G4String moduleName, 
+                               G4int version, AliModuleType moduleType)
+{
+// Adds SingleModuleConstruction.
+// ---
+
+  AliSingleModuleConstruction* moduleConstruction
+    = new AliSingleModuleConstruction(moduleName, version, moduleType);
+  fModuleConstructionVector.insert(moduleConstruction);
+}  
+                 
+void AliModulesComposition::AddMoreModuleConstruction(G4String moduleName, 
+                               G4int version, AliModuleType moduleType)
+{
+// Adds module to MoreModulesConstruction (construction of dependent
+// modules.)
+// ---
+
+  fMoreModulesConstruction->AddModule(moduleName, version, moduleType);
+}  
+                                 
+void AliModulesComposition::ConstructModules()
+{
+// Construct geometry of all modules (both standalone and dependent.)
+// ---
+
+  // set common options
+  SetReadGeometryToModules(fReadGeometry);
+  SetWriteGeometryToModules(fWriteGeometry);
+  SetAllLVSensitiveToModules(fAllLVSensitive);
+     // common setAllLVSensitive is overridden by Config.in
+     // macro
+  
+  // one module constructions
+  G4int nofDets = fModuleConstructionVector.entries();
+  for (G4int i=0; i<nofDets; i++) {
+    G4cout << "Module " << fModuleConstructionVector[i]->GetDetName()
+           << " will be constructed now." << endl;
+    fModuleConstructionVector[i]->Construct();
+  }  
+    
+  // more modules construction
+  G4int nofModules = fMoreModulesConstruction->GetNofModules();
+  if (nofModules>0) {
+    G4cout << "Dependent modules will be constructed now." << endl;
+    fMoreModulesConstruction->Construct();
+  }  
+}  
+
+void AliModulesComposition::SetReadGeometryToModules(G4bool readGeometry)
+{
+// Sets readGeometry control to all modules.
+// ---
+
+  // single module constructions
+  G4int nofDets = fModuleConstructionVector.entries();
+  G4int i;
+  for (i=0; i<nofDets; i++)
+    fModuleConstructionVector[i]->SetReadGeometry(readGeometry);
+
+  // more modules construction
+  nofDets = fMoreModulesConstruction->GetNofModules();
+  for (i=0; i<nofDets; i++) { 
+    AliSingleModuleConstruction* moduleConstruction
+      = fMoreModulesConstruction->GetModuleConstruction(i);
+    moduleConstruction->SetReadGeometry(readGeometry);
+  }  
+}    
+  
+void AliModulesComposition::SetWriteGeometryToModules(G4bool writeGeometry)
+{
+// Sets writeGeometry control to all modules.
+// ---
+
+  // single module constructions
+  G4int nofDets = fModuleConstructionVector.entries();
+  G4int i;
+  for (i=0; i<nofDets; i++)
+    fModuleConstructionVector[i]->SetWriteGeometry(writeGeometry);
+
+  // more modules construction
+  nofDets = fMoreModulesConstruction->GetNofModules();
+  for (i=0; i<nofDets; i++) { 
+    AliSingleModuleConstruction* moduleConstruction
+      = fMoreModulesConstruction->GetModuleConstruction(i);
+    moduleConstruction->SetWriteGeometry(writeGeometry);
+  }  
+}    
+
+void AliModulesComposition::SetAllLVSensitiveToModules(G4bool allSensitive)
+{
+// Sets setAllSensitive control to all modules.
+// ---
+
+  // single module constructions
+  G4int nofDets = fModuleConstructionVector.entries();
+  G4int i;
+  for (i=0; i<nofDets; i++) {
+    AliSingleModuleConstruction* moduleConstruction
+      = dynamic_cast<AliSingleModuleConstruction*>(fModuleConstructionVector[i]);
+    if (!moduleConstruction) {
+      G4String text = "AliModulesComposition::SetProcessConfig: \n";
+      text = text + "    Unknown module construction type.";
+      AliGlobals::Exception(text);
+    }      
+    moduleConstruction->SetAllLVSensitive(allSensitive);
+  }  
+
+  // more modules construction
+  nofDets = fMoreModulesConstruction->GetNofModules();
+  for (i=0; i<nofDets; i++) { 
+    AliSingleModuleConstruction* moduleConstruction
+      = fMoreModulesConstruction->GetModuleConstruction(i);
+    moduleConstruction->SetAllLVSensitive(allSensitive);
+  }  
+}    
+
+void AliModulesComposition::SetProcessConfigToModules(G4bool processConfig)
+{
+// Sets processConfig control to all modules.
+// ---
+
+  // single module constructions
+  G4int nofDets = fModuleConstructionVector.entries();
+  G4int i;
+  for (i=0; i<nofDets; i++) {
+    AliSingleModuleConstruction* moduleConstruction
+      = dynamic_cast<AliSingleModuleConstruction*>(fModuleConstructionVector[i]);
+    if (!moduleConstruction) {
+      G4String text = "AliModulesComposition::SetProcessConfig: \n";
+      text = text + "    Unknown module construction type.";
+      AliGlobals::Exception(text);
+    }      
+    moduleConstruction->SetProcessConfig(processConfig);
+  }  
+  
+  // more modules construction
+  nofDets = fMoreModulesConstruction->GetNofModules();
+  for (i=0; i<nofDets; i++) { 
+    AliSingleModuleConstruction* moduleConstruction
+      = fMoreModulesConstruction->GetModuleConstruction(i);
+    moduleConstruction->SetProcessConfig(processConfig);
+  }    
+}    
+
+// public methods
+
+void AliModulesComposition::SwitchDetOn(G4String moduleNameVer)
+{ 
+// Switchs on module specified by name and version.
+// ---
+
+  G4int nofDets = fDetSwitchVector.entries(); 
+  if (moduleNameVer == "ALL") {
+    for (G4int id=0; id<nofDets; id++) {
+      G4int defaultVersion = fDetSwitchVector[id]->GetDefaultVersion();
+      fDetSwitchVector[id]->SwitchOn(defaultVersion); 
+    }  
+  }
+  else if (moduleNameVer == "NONE") {
+    for (G4int id=0; id<nofDets; id++)
+      fDetSwitchVector[id]->SwitchOff(); 
+  }
+  else {
+    // get version number
+    G4int len = moduleNameVer.length();
+    G4String moduleName = moduleNameVer(0, len-1);
+    G4String version = moduleNameVer(len-1, 1);
+    G4int iVersion = AliGlobals::StringToInt(version);
+
+    if (iVersion < 0) {
+      // in case the version number is not provided
+      // the default one is set
+      SwitchDetOnDefault(moduleNameVer);
+    }  
+    else 
+      SwitchDetOn(moduleName, iVersion);
+  }
+}
+
+void AliModulesComposition::SwitchDetOn(G4String moduleName, G4int version)
+{ 
+// Switchs on module specified by name and version.
+// ---
+
+  G4int nofDets = fDetSwitchVector.entries(); 
+  for (G4int id=0; id<nofDets; id++) {
+    G4String iDetName = fDetSwitchVector[id]->GetDetName();
+    if (iDetName == moduleName) {
+      fDetSwitchVector[id]->SwitchOn(version);
+      return;
+    }
+  }
+  AliGlobals::Exception(
+    "AliModulesComposition: Wrong detector name for " + moduleName + ".");
+}
+
+void AliModulesComposition::SwitchDetOnDefault(G4String moduleName)
+{ 
+// Switchs on module specified by name with default version.
+// ---
+
+  G4int nofDets = fDetSwitchVector.entries(); 
+  for (G4int id=0; id<nofDets; id++) {
+    G4String iDetName = fDetSwitchVector[id]->GetDetName();
+    if (iDetName == moduleName) {
+      fDetSwitchVector[id]->SwitchOnDefault();
+      return;
+    }
+  }
+  AliGlobals::Exception(
+    "AliModulesComposition: Wrong detector name for " + moduleName + ".");
+}
+
+void AliModulesComposition::SwitchDetOff(G4String moduleName)
+{ 
+// Switchs off module specified by name.
+// ---
+
+  G4int nofDets = fDetSwitchVector.entries(); 
+  if (moduleName == "ALL") {
+    for (G4int id=0; id<nofDets; id++)
+      fDetSwitchVector[id]->SwitchOff(); 
+  }
+  else {
+    for (G4int id=0; id<nofDets; id++) {
+      G4String iDetName = fDetSwitchVector[id]->GetDetName();
+      if (iDetName == moduleName) { 
+        fDetSwitchVector[id]->SwitchOff();
+        return;
+      }
+    }
+  }
+  AliGlobals::Exception(
+    "AliModulesComposition: Wrong detector name for " + moduleName + ".");
+}
+
+void AliModulesComposition::PrintSwitchedDets() const
+{ 
+// Lists switched detectors.
+// ---
+
+  G4String svList = GetSwitchedDetsList();
+    
+  G4cout << "Switched Alice detectors: " << endl;
+  G4cout << "--------------------------" << endl;
+  G4cout << svList << endl;
+}
+
+void AliModulesComposition::PrintAvailableDets() const
+{ 
+// Lists available detectors.
+// ---
+
+  G4String avList = GetAvailableDetsList();
+    
+  G4cout << "Available Alice detectors: " << endl;
+  G4cout << "---------------------------" << endl;
+  G4cout << avList << endl;
+}
+
+G4String AliModulesComposition::GetSwitchedDetsList() const
+{ 
+// Returns list of switched detectors.
+// ---
+
+  G4String svList = "";
+  
+  G4int nofDets = fDetSwitchVector.entries(); 
+  G4int nofSwitchedDets = 0;
+  for (G4int id=0; id<nofDets; id++) {
+    G4int iVersion = fDetSwitchVector[id]->GetSwitchedVersion();
+    if (iVersion > -1) {
+      nofSwitchedDets++;
+      G4String moduleNameVer = fDetSwitchVector[id]->GetDetName();
+      AliGlobals::AppendNumberToString(moduleNameVer, iVersion);
+      svList += moduleNameVer;
+      svList += " "; 
+    }
+  }
+
+  if (nofSwitchedDets ==  nofDets) svList = "ALL: " + svList;
+  if (nofSwitchedDets ==  0)       svList = "NONE";   
+
+  return svList;
+}
+
+const G4RWTPtrOrderedVector<AliDetSwitch>& 
+AliModulesComposition::GetDetSwitchVector() const
+{
+// Returns detSwitch vector.
+// ---
+
+  //const AliDetSwitchVector& vector = fDetSwitchVector;
+  const G4RWTPtrOrderedVector<AliDetSwitch>& vector = fDetSwitchVector;
+  return vector;
+}  
+
+G4String AliModulesComposition::GetAvailableDetsList() const
+{ 
+// Returns list of available detectors.
+// ---
+
+  G4String svList = "";
+  
+  G4int nofDets = fDetSwitchVector.entries(); 
+  for (G4int id=0; id<nofDets; id++) {
+    G4int nofVersions = fDetSwitchVector[id]->GetNofVersions();
+    for (G4int iv=0; iv<nofVersions; iv++) {
+      G4String moduleNameVer = fDetSwitchVector[id]->GetDetName();
+      AliGlobals::AppendNumberToString(moduleNameVer, iv);
+      svList += moduleNameVer;
+      svList += " ";
+    }
+  }
+
+  return svList;
+}
+
+G4String AliModulesComposition::GetAvailableDetsListWithCommas() const
+{ 
+// Returns list of available detectors with commas.
+// ---
+
+  G4String svList = "";
+  
+  G4int nofDets = fDetSwitchVector.entries(); 
+  for (G4int id=0; id<nofDets; id++) {
+    G4int nofVersions = fDetSwitchVector[id]->GetNofVersions();
+    for (G4int iv=0; iv<nofVersions; iv++) {
+      G4String moduleNameVer = fDetSwitchVector[id]->GetDetName();
+      AliGlobals::AppendNumberToString(moduleNameVer, iv);
+      svList += moduleNameVer;
+      if (iv<nofVersions-1)    svList += "/";
+      else if (id < nofDets-1) svList += ", ";
+    }
+  }
+
+  return svList;
+}
+
+G4String AliModulesComposition::GetDetNamesList() const
+{ 
+// Returns list of detector names.
+// ---
+
+  G4String svList = "";
+  
+  G4int nofDets = fDetSwitchVector.entries(); 
+  for (G4int id=0; id<nofDets; id++) { 
+    svList += fDetSwitchVector[id]->GetDetName();
+    svList += " ";
+  }
+
+  return svList;
+}
+
+G4String AliModulesComposition::GetDetNamesListWithCommas() const
+{ 
+// Returns list of detector names with commas.
+// ---
+
+  G4String svList = "";
+  
+  G4int nofDets = fDetSwitchVector.entries(); 
+  for (G4int id=0; id<nofDets; id++) { 
+    svList += fDetSwitchVector[id]->GetDetName();
+    if (id < nofDets-1) svList += ", ";
+  }
+
+  return svList;
+}
+
+void AliModulesComposition::SetMagField(G4double fieldValue)
+{
+// Sets uniform magnetic field to specified value.
+// ---
+
+  fMagneticField->SetFieldValue(fieldValue);
+}
+
diff --git a/AliGeant4/AliModulesComposition.h b/AliGeant4/AliModulesComposition.h
new file mode 100644 (file)
index 0000000..3db3679
--- /dev/null
@@ -0,0 +1,107 @@
+// $Id$
+// Category: geometry
+//
+// Detector construction base class for building geometry
+// composed from independent modules with availability of interactive modules
+// setup.
+
+#ifndef ALI_MODULES_COMPOSITION_H
+#define ALI_MODULES_COMPOSITION_H
+
+#include "AliModuleConstruction.h"
+#include "AliDetSwitch.h"
+#include "AliModuleType.h"
+
+#include <G4VUserDetectorConstruction.hh>
+#include <globals.hh>
+
+#include <g4rw/tpordvec.h>
+
+class AliModulesCompositionMessenger;
+class AliMoreModulesConstruction;
+class AliMagneticField;
+
+class G4VPhysicalVolume;
+
+class AliModulesComposition : public G4VUserDetectorConstruction
+{
+  typedef G4RWTPtrOrderedVector<AliDetSwitch>          AliDetSwitchVector;
+  typedef G4RWTPtrOrderedVector<AliModuleConstruction> AliModuleConstructionVector; 
+
+  public:
+    AliModulesComposition();
+    // --> protected
+    // AliModulesComposition(const AliModulesComposition& right);
+    virtual ~AliModulesComposition();
+
+    // methods
+    virtual G4VPhysicalVolume* Construct() = 0;
+    void SwitchDetOn(G4String moduleNameVer);
+    void SwitchDetOn(G4String moduleName, G4int version);
+    void SwitchDetOnDefault(G4String moduleName);
+    void SwitchDetOff(G4String moduleName);
+    void PrintSwitchedDets() const;
+    void PrintAvailableDets() const;
+
+    // set methods
+    void SetMagField(G4double fieldValue);
+    void SetAllLVSensitive(G4bool allLVSensitive);
+    void SetReadGeometry(G4bool readGeometry);
+    void SetWriteGeometry(G4bool writeGeometry);
+    void SetProcessConfigToModules(G4bool processConfig);
+    
+    // get methods
+    const G4RWTPtrOrderedVector<AliDetSwitch>& GetDetSwitchVector() const;
+    G4String GetSwitchedDetsList() const;
+    G4String GetAvailableDetsList() const;
+    G4String GetAvailableDetsListWithCommas() const;
+    G4String GetDetNamesList() const;
+    G4String GetDetNamesListWithCommas() const;
+    //G4ThreeVector GetMagField() const;
+    
+  protected:
+    AliModulesComposition(const AliModulesComposition& right);
+
+    // operators
+    AliModulesComposition& operator=(const AliModulesComposition& right);
+
+    // methods  
+    void AddDetSwitch(AliDetSwitch* detSwitch);
+    void AddSingleModuleConstruction(G4String moduleName, G4int version,
+                                     AliModuleType moduleType = kDetector);
+    void AddMoreModuleConstruction(G4String moduleName, G4int version,
+                                     AliModuleType moduleType = kDetector);
+    void ConstructModules();
+
+  private:    
+    // methods
+    void SetReadGeometryToModules(G4bool readGeometry);
+    void SetWriteGeometryToModules(G4bool writeGeometry);
+    void SetAllLVSensitiveToModules(G4bool allSensitive);
+
+    // data members
+    AliDetSwitchVector           fDetSwitchVector;          //vector of AliDetSwitch
+    AliModuleConstructionVector  fModuleConstructionVector; //vector of 
+                                                           //AliModuleConstruction 
+    AliMoreModulesConstruction*  fMoreModulesConstruction;  //AliMoreModulesConstruction
+
+    AliMagneticField*                fMagneticField;  //magnetic field
+    AliModulesCompositionMessenger*  fMessenger;      //messenger
+    G4bool                           fAllLVSensitive; //option applied to all modules
+    G4bool                           fReadGeometry;   //option applied to all modules
+    G4bool                           fWriteGeometry;  //option applied to all modules  
+};
+
+// inline methods
+
+inline void AliModulesComposition::SetAllLVSensitive(G4bool allLVSensitive)
+{ fAllLVSensitive = allLVSensitive; }
+
+inline void AliModulesComposition::SetReadGeometry(G4bool readGeometry)
+{ fReadGeometry = readGeometry; }
+
+inline void AliModulesComposition::SetWriteGeometry(G4bool writeGeometry)
+{ fWriteGeometry = writeGeometry; }
+
+#endif //ALI_MODULES_COMPOSITION_H
+
diff --git a/AliGeant4/AliModulesCompositionMessenger.cxx b/AliGeant4/AliModulesCompositionMessenger.cxx
new file mode 100644 (file)
index 0000000..c07faf0
--- /dev/null
@@ -0,0 +1,188 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliModulesCompositionMessenger.h"
+#include "AliModulesComposition.h"
+#include "AliGlobals.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithAString.hh>
+#include <G4UIcmdWithoutParameter.hh>
+#include <G4UIcmdWithABool.hh>
+#include <G4UIcmdWithADoubleAndUnit.hh>
+
+AliModulesCompositionMessenger::AliModulesCompositionMessenger(
+                                   AliModulesComposition* modulesComposition)
+  : fModulesComposition(modulesComposition)
+{
+//
+  fDirectory = new G4UIdirectory("/aliDet/");
+  fDirectory->SetGuidance("Detector construction control commands.");
+
+  fSwitchOnCmd = new G4UIcmdWithAString("/aliDet/switchOn", this);
+  fSwitchOnCmd->SetGuidance("Define the module to be built.");
+  fSwitchOnCmd->SetGuidance("Available modules:");
+  G4String listAvailableDets = "NONE, ALL, ";  
+  listAvailableDets 
+    = listAvailableDets + modulesComposition->GetAvailableDetsListWithCommas();
+  fSwitchOnCmd->SetGuidance(listAvailableDets);
+  fSwitchOnCmd->SetParameterName("module", false);
+  fSwitchOnCmd->AvailableForStates(PreInit);;
+
+  fSwitchOffCmd = new G4UIcmdWithAString("/aliDet/switchOff", this);
+  fSwitchOffCmd->SetGuidance("Define the module not to be built.");
+  fSwitchOffCmd->SetGuidance("Available modules:");
+  G4String listDetsNames = "ALL, "; 
+  listDetsNames
+    = listDetsNames + modulesComposition->GetDetNamesListWithCommas();
+  fSwitchOffCmd->SetGuidance(listDetsNames);
+  fSwitchOffCmd->SetParameterName("module", false);
+  fSwitchOffCmd->AvailableForStates(PreInit);;
+
+  fListCmd 
+    = new G4UIcmdWithoutParameter("/aliDet/list", this);
+  fListCmd->SetGuidance("List the currently switched modules.");
+  fListCmd
+    ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
+
+  fListAvailableCmd 
+    = new G4UIcmdWithoutParameter("/aliDet/listAvailable", this);
+  fListAvailableCmd->SetGuidance("List all available modules.");
+  fListAvailableCmd
+    ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
+
+  fFieldValueCmd = new G4UIcmdWithADoubleAndUnit("/aliDet/fieldValue", this);
+  fFieldValueCmd->SetGuidance("Define magnetic field in Z direction.");
+  fFieldValueCmd->SetParameterName("fieldValue", false, false);
+  fFieldValueCmd->SetDefaultUnit("tesla");
+  fFieldValueCmd->SetUnitCategory("Magnetic flux density");
+  fFieldValueCmd->AvailableForStates(PreInit,Idle);  
+  
+  fSetAllSensitiveCmd
+    = new G4UIcmdWithABool("/aliDet/setAllSensitive", this);
+  fSetAllSensitiveCmd 
+    ->SetGuidance("If true: set all logical volumes sensitive.");
+  fSetAllSensitiveCmd 
+    ->SetGuidance("         (Each logical is volume associated with a sensitive");
+  fSetAllSensitiveCmd 
+    ->SetGuidance("          detector.)");
+  fSetAllSensitiveCmd 
+    ->SetGuidance("If false: only volumes defined with a sensitive tracking");
+  fSetAllSensitiveCmd 
+    ->SetGuidance("          medium are associated with a sensitive detector.");
+  fSetAllSensitiveCmd->SetParameterName("sensitivity", false);
+  fSetAllSensitiveCmd->AvailableForStates(PreInit);  
+
+  fSetReadGeometryCmd 
+    = new G4UIcmdWithABool("/aliDet/readGeometry", this);
+  fSetReadGeometryCmd->SetGuidance("Read geometry from g3calls.dat files");
+  fSetReadGeometryCmd->SetParameterName("readGeometry", false);
+  fSetReadGeometryCmd->AvailableForStates(PreInit);  
+  fSetWriteGeometryCmd 
+    = new G4UIcmdWithABool("/aliDet/writeGeometry", this);
+  fSetWriteGeometryCmd->SetGuidance("Write geometry to g3calls.dat file");
+  fSetWriteGeometryCmd->SetParameterName("writeGeometry", false);
+  fSetWriteGeometryCmd->AvailableForStates(PreInit);   
+
+  // set candidates list
+  SetCandidates();
+
+  // set default values to a detector
+  fModulesComposition->SwitchDetOn("NONE");
+  fModulesComposition->SetMagField(0.0*tesla);    
+}
+
+AliModulesCompositionMessenger::AliModulesCompositionMessenger() {
+//
+}
+
+AliModulesCompositionMessenger::AliModulesCompositionMessenger(
+                                const AliModulesCompositionMessenger& right)
+{
+//
+  AliGlobals::Exception(
+    "AliModulesCompositionMessenger is protected from copying.");
+}
+
+AliModulesCompositionMessenger::~AliModulesCompositionMessenger() {
+//
+  delete fDirectory;
+  delete fSwitchOnCmd;
+  delete fSwitchOffCmd;
+  delete fListCmd;
+  delete fListAvailableCmd;
+  delete fFieldValueCmd;
+  delete fSetAllSensitiveCmd;
+  delete fSetReadGeometryCmd;
+  delete fSetWriteGeometryCmd;
+}
+
+// operators
+
+AliModulesCompositionMessenger& 
+AliModulesCompositionMessenger::operator=(
+                                const AliModulesCompositionMessenger& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception(
+     "AliModulesCompositionMessenger is protected from assigning.");
+    
+  return *this;  
+}    
+          
+// public methods
+  
+void AliModulesCompositionMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
+{
+// Applies command to the associated object.
+// ---
+
+  if (command == fSwitchOnCmd) {  
+    fModulesComposition->SwitchDetOn(newValues); 
+  }
+  else if (command == fSwitchOffCmd) {  
+    fModulesComposition->SwitchDetOff(newValues); 
+  }
+  else if (command == fListCmd) {  
+    fModulesComposition->PrintSwitchedDets(); 
+  }
+  else if (command == fListAvailableCmd) {  
+    fModulesComposition->PrintAvailableDets(); 
+  }
+  else if (command == fFieldValueCmd) {  
+    fModulesComposition
+      ->SetMagField(fFieldValueCmd->GetNewDoubleValue(newValues)); 
+  }
+  else if (command == fSetAllSensitiveCmd) {
+    fModulesComposition->SetAllLVSensitive(
+                         fSetAllSensitiveCmd->GetNewBoolValue(newValues));
+  }
+  else if (command == fSetReadGeometryCmd) {
+    fModulesComposition->SetReadGeometry(
+                         fSetReadGeometryCmd->GetNewBoolValue(newValues));
+  }  
+  else if (command == fSetWriteGeometryCmd) {
+    fModulesComposition->SetWriteGeometry(
+                         fSetWriteGeometryCmd->GetNewBoolValue(newValues));
+  }    
+}
+
+void AliModulesCompositionMessenger::SetCandidates() 
+{
+// Builds candidates list.
+// ---
+
+  G4String candidatesList = "NONE ALL ";
+  candidatesList += fModulesComposition->GetDetNamesList();;
+  candidatesList += fModulesComposition->GetAvailableDetsList();
+  fSwitchOnCmd->SetCandidates(candidatesList);
+
+  candidatesList = "ALL ";
+  candidatesList += fModulesComposition->GetDetNamesList();;
+  fSwitchOffCmd->SetCandidates(candidatesList);
+}
diff --git a/AliGeant4/AliModulesCompositionMessenger.h b/AliGeant4/AliModulesCompositionMessenger.h
new file mode 100644 (file)
index 0000000..576525a
--- /dev/null
@@ -0,0 +1,60 @@
+// $Id$
+// Category: geometry
+//
+// Messenger class that defines commands for AliModulesComposition.
+
+#ifndef ALI_MODULES_COMPOSITION_MESSENGER_H
+#define ALI_MODULES_COMPOSITION_MESSENGER_H
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliModulesComposition;
+
+class G4UIcommand;
+class G4UIdirectory;
+class G4UIcmdWithAString;
+class G4UIcmdWithoutParameter;
+class G4UIcmdWithABool;
+class G4UIcmdWithADoubleAndUnit;
+
+class AliModulesCompositionMessenger: public G4UImessenger
+{
+  public:
+    AliModulesCompositionMessenger(AliModulesComposition* modulesComposition);
+    // --> protected
+    // AliModulesCompositionMessenger();
+    // AliModulesCompositionMessenger(
+    //       const AliModulesCompositionMessenger& right);
+    virtual ~AliModulesCompositionMessenger();
+
+    // methods
+    virtual void SetNewValue(G4UIcommand* command, G4String newValues);
+    void SetCandidates();
+    
+  protected:
+    AliModulesCompositionMessenger();
+    AliModulesCompositionMessenger(
+             const AliModulesCompositionMessenger& right);
+
+    // operators
+    AliModulesCompositionMessenger& operator=(
+             const AliModulesCompositionMessenger &right);
+             
+  private:
+    AliModulesComposition*  fModulesComposition; //associated class
+    G4UIdirectory*          fDirectory;          //command directory
+    
+    // commands data members
+    G4UIcmdWithAString*         fSwitchOnCmd;         //command: switchOn 
+    G4UIcmdWithAString*         fSwitchOffCmd;        //command: switchOn
+    G4UIcmdWithoutParameter*    fListCmd;             //command: list
+    G4UIcmdWithoutParameter*    fListAvailableCmd;    //command: listAvailable
+    G4UIcmdWithADoubleAndUnit*  fFieldValueCmd;       //command: fieldValue
+    G4UIcmdWithABool*           fSetAllSensitiveCmd;  //command: setAllSensitive   
+    G4UIcmdWithABool*           fSetReadGeometryCmd;  //command: readGeometry   
+    G4UIcmdWithABool*           fSetWriteGeometryCmd; //command: writeGeometry    
+};
+
+#endif //ALI_MODULES_COMPOSITION_MESSENGER_H
+
diff --git a/AliGeant4/AliMoreModulesConstruction.cxx b/AliGeant4/AliMoreModulesConstruction.cxx
new file mode 100644 (file)
index 0000000..0a1d26d
--- /dev/null
@@ -0,0 +1,248 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliMoreModulesConstruction.h"
+#include "AliSingleModuleConstruction.h"
+#include "AliSDManager.h"
+#include "AliSensitiveDetector.h"
+#include "AliModule.h"
+#include "AliRun.h"
+#include "AliGlobals.h"
+
+#include "TG4GeometryManager.h"
+
+#include <G4SDManager.hh>
+#include <G4LogicalVolume.hh>
+#include <G4LogicalVolumeStore.hh>
+
+#include <TROOT.h> 
+#include <TCint.h> 
+
+AliMoreModulesConstruction::AliMoreModulesConstruction() {
+//
+  fSDManager = AliSDManager::Instance();
+}
+
+AliMoreModulesConstruction::AliMoreModulesConstruction(
+                               const AliMoreModulesConstruction& right)
+{
+  // delete current module constructions
+  fModuleConstructionVector.erase(
+    fModuleConstructionVector.begin(), fModuleConstructionVector.end());
+    
+  // create new module constructions   
+  G4int nofModules = right.fModuleConstructionVector.size();
+  for (G4int i=0; i<nofModules; i++) {
+    G4String name = right.fModuleConstructionVector[i]->GetDetName();
+    G4int version = right.fModuleConstructionVector[i]->GetVersion();
+    AliModuleType type = right.fModuleConstructionVector[i]->GetType();
+    AddModule(name, version, type);
+  }  
+  
+  fSDManager = right.fSDManager;
+}  
+                              
+
+AliMoreModulesConstruction::~AliMoreModulesConstruction()
+{
+  // delete module constructions
+  fModuleConstructionVector.erase(
+    fModuleConstructionVector.begin(), fModuleConstructionVector.end());
+}
+
+// operators
+
+AliMoreModulesConstruction& 
+AliMoreModulesConstruction::operator=(const AliMoreModulesConstruction& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  // delete current module constructions
+  fModuleConstructionVector.erase(
+    fModuleConstructionVector.begin(), fModuleConstructionVector.end());
+    
+  // create new module constructions   
+  G4int nofModules = right.fModuleConstructionVector.size();
+  for (G4int i=0; i<nofModules; i++) {
+    G4String name = right.fModuleConstructionVector[i]->GetDetName();
+    G4int version = right.fModuleConstructionVector[i]->GetVersion();
+    AliModuleType type = right.fModuleConstructionVector[i]->GetType();
+    AddModule(name, version, type);
+  }  
+  
+  fSDManager = right.fSDManager;
+
+  return *this;  
+}    
+          
+// private methods
+
+void AliMoreModulesConstruction::CreateSensitiveDetectors(
+                                   G4bool allLVSensitive)
+{
+// Creates sensitive detectors.
+// ---
+
+  if (allLVSensitive)
+    CreateSensitiveDetectors1();
+  else
+    CreateSensitiveDetectors2();
+
+  // set static number of logical volumes already processed
+  G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
+  fSDManager->SetNofLVWithSD(pLVStore->entries());  
+}    
+
+void AliMoreModulesConstruction::CreateSensitiveDetectors1()
+{ 
+// Creates sensitive detectors.
+// Sensitive detectors are set to all logical volumes
+// ---
+
+  G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
+  G4int nofLV = pLVStore->entries();
+  
+  G4int nofLVWithSD = fSDManager->GetNofLVWithSD();
+  for (G4int i=nofLVWithSD; i<nofLV; i++) {
+    G4LogicalVolume* lv = (*pLVStore)[i];
+    AliModule* module = fSDManager->FindAliModule(lv);
+    fSDManager->CreateSD(lv, module);
+  }
+}
+
+void AliMoreModulesConstruction::CreateSensitiveDetectors2()
+{ 
+// Creates sensitive detectors.
+// Sensitive detectors are set only to logical volumes
+// in G3SensVolVector.
+// ---
+
+  TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
+
+  G3SensVolVector pSVVector
+    = pGeometryManager->GetG3SensVolVector();
+
+  G4int nofSV = pSVVector.entries();
+  if (nofSV>0)
+    for (G4int isv=0; isv<nofSV; isv++) {
+      G4LogicalVolume* lv = pSVVector[isv];
+      AliModule* module = fSDManager->FindAliModule(lv);    
+      fSDManager->CreateSD(lv, module);
+    } 
+}
+
+// public methods
+
+void AliMoreModulesConstruction::AddModule(G4String moduleName, G4int version,
+                                           AliModuleType moduleType)
+{                                         
+// Adds module specified by name, version and type.
+// ---
+
+  // create module construction
+  AliSingleModuleConstruction* moduleConstruction 
+    = new AliSingleModuleConstruction(moduleName, version, moduleType);
+
+  // add module, module construction to vectors
+  fModuleConstructionVector.push_back(moduleConstruction);
+}  
+                                          
+void AliMoreModulesConstruction::Construct()
+{ 
+// Constructs geometry.
+// G3 tables are process for all modules alltogether.
+// --
+
+  // number of modules
+  G4int nofModules = fModuleConstructionVector.size();
+
+  if (nofModules == 0) {
+    AliGlobals::Warning(
+      "AliMoreModulesConstruction::Construct(): No modules are defined.");
+  }
+  else {      
+    // get geometry manager
+    TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
+
+    G4bool allLVSensitive = false;    
+    G4int i;
+    for (i=0; i<nofModules; i++) {
+
+      fModuleConstructionVector[i]->Configure();
+    
+      // register module name in the name map
+      AliModule* module = fModuleConstructionVector[i]->GetAliModule();
+      pGeometryManager->SetMapSecond(module->GetName());       
+
+      G4bool readGeometry = fModuleConstructionVector[i]->GetReadGeometry();
+      G4bool writeGeometry = fModuleConstructionVector[i]->GetWriteGeometry();
+      G4String dataFilePath = fModuleConstructionVector[i]->GetDataFilePath();
+
+      if (readGeometry) {
+        // create G3 geometry from g3calls.dat
+        pGeometryManager->SetWriteGeometry(false);
+        pGeometryManager->ReadG3Geometry(dataFilePath);
+      }
+      else {               
+        // set geometry output stream for this module
+        pGeometryManager->SetWriteGeometry(writeGeometry);
+        if (writeGeometry) 
+          pGeometryManager->OpenOutFile(dataFilePath);
+        
+        // create geometry from AliRoot
+      
+        // construct materials
+        module->CreateMaterials();   
+
+        // construct G3 geometry
+        module->CreateGeometry();
+      }        
+
+      // all logical volumes will be made sensitive if any
+      // module requires this
+      if (fModuleConstructionVector[i]->GetAllLVSensitive()) 
+         allLVSensitive = true;
+    }  
+  
+    // construct G4 geometry
+    pGeometryManager->CreateG4Geometry();
+
+    // print name map
+    // pGeometryManager->PrintNameMap();
+    
+    // create sensitive detectors
+    CreateSensitiveDetectors(allLVSensitive);
+         // each single module construction can build sensitive detectors
+         // for all modules as all modules are in memory
+         // (volumes entities do not know to which module belong)
+  
+    for (i=0; i<nofModules; i++) {
+      // set the detector frame (envelope)
+      // (without warning output if enevelope is not defined)
+      fModuleConstructionVector[i]->SetDetFrame(false);
+
+      // build sensitive detectors table
+      fModuleConstructionVector[i]->GetAliModule()->Init();
+    }  
+
+    // reset TG4GeometryManager 
+    pGeometryManager->ClearG3Tables();
+  
+    // print current total number of logical volumes
+    G4cout << "Current total number of sensitive volumes: "
+           << pGeometryManager->NofVolumes() << endl;
+
+#ifdef ALICE_VISUALIZE
+    // set visualization attributes
+    for (i=0; i<nofModules; i++) {
+      if (fModuleConstructionVector[i]->GetDetFrame()) {
+        fModuleConstructionVector[i]->SetDetVisibility(true);
+        fModuleConstructionVector[i]->SetDetColour("Yellow");
+      }
+    }  
+#endif
+  }
+}
diff --git a/AliGeant4/AliMoreModulesConstruction.h b/AliGeant4/AliMoreModulesConstruction.h
new file mode 100644 (file)
index 0000000..2cae0fe
--- /dev/null
@@ -0,0 +1,62 @@
+// $Id$
+// Category: geometry
+//
+// Class for geometry construction of a set of dependent
+// modules (AliModule). 
+
+
+#ifndef ALI_MORE_MODULES_CONSTRUCTION_H
+#define ALI_MORE_MODULES_CONSTRUCTION_H
+
+#include "AliModuleType.h"
+
+#include <G3VolTable.hh>
+#include <globals.hh>
+
+#include <vector.h>
+
+class AliSingleModuleConstruction;
+class AliSDManager;
+
+class AliMoreModulesConstruction
+{  
+  public:
+    AliMoreModulesConstruction();
+    AliMoreModulesConstruction(const AliMoreModulesConstruction& right);
+    virtual ~AliMoreModulesConstruction();
+
+    // operators
+    AliMoreModulesConstruction& operator=(
+                               const AliMoreModulesConstruction& right);
+
+    // methods
+    void AddModule(G4String moduleName, G4int version, 
+                   AliModuleType moduleType);
+    void Construct();
+    
+    // get methods
+    G4int GetNofModules() const;
+    AliSingleModuleConstruction* GetModuleConstruction(G4int i) const;
+        
+  private:    
+    // methods
+    void CreateSensitiveDetectors(G4bool allLVSensitive);
+    void CreateSensitiveDetectors1();
+    void CreateSensitiveDetectors2();
+
+    // data members
+    vector<AliSingleModuleConstruction*>  fModuleConstructionVector;        //.
+                                //vector of AliSingleModuleConstruction
+    AliSDManager*  fSDManager;  //AliSDManager                                            
+};                                                
+
+// inline methods
+
+inline G4int AliMoreModulesConstruction::GetNofModules() const
+{ return fModuleConstructionVector.size(); }
+
+inline AliSingleModuleConstruction* 
+  AliMoreModulesConstruction::GetModuleConstruction(G4int i) const 
+{ return fModuleConstructionVector[i]; }
+
+#endif //ALI_MORE_MODULES_CONSTRUCTION_H
diff --git a/AliGeant4/AliParticleGun.cxx b/AliGeant4/AliParticleGun.cxx
new file mode 100644 (file)
index 0000000..9b4b7d2
--- /dev/null
@@ -0,0 +1,174 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliParticleGun.h"
+#include "AliParticleGunMessenger.h"
+#include "AliGlobals.h"
+
+#include <G4PrimaryParticle.hh>
+#include <G4Event.hh>
+#include <G4ios.hh>
+
+
+AliParticleGun::AliParticleGun() {
+//
+  fMessenger = new AliParticleGunMessenger(this);
+}
+
+AliParticleGun::AliParticleGun(const AliParticleGun& right)
+{
+  // particles vector
+  fGunParticlesVector.clearAndDestroy();
+  for (G4int i=0; i<right.fGunParticlesVector.entries(); i++) {
+    AliGunParticle* rhsParticle = right.fGunParticlesVector[i];
+    AliGunParticle* newParticle = new AliGunParticle(*rhsParticle);
+    fGunParticlesVector.insert(newParticle);
+  }  
+
+  fMessenger = new AliParticleGunMessenger(this);
+}
+
+AliParticleGun::~AliParticleGun() {
+//
+  fGunParticlesVector.clearAndDestroy();
+  delete fMessenger;
+}
+
+// operators
+
+AliParticleGun& AliParticleGun::operator=(const AliParticleGun& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  // particles vector
+  fGunParticlesVector.clearAndDestroy();
+  for (G4int i=0; i<right.fGunParticlesVector.entries(); i++) {
+    AliGunParticle* rhsParticle = right.fGunParticlesVector[i];
+    AliGunParticle* newParticle = new AliGunParticle(*rhsParticle);
+    fGunParticlesVector.insert(newParticle);
+  }
+  
+  return *this;  
+}
+  
+// public methods
+
+void AliParticleGun::AddParticle(AliGunParticle* particle)
+{ 
+// Adds particle.
+// ---
+
+  fGunParticlesVector.insert(particle); 
+}
+
+void AliParticleGun::RemoveParticle(G4int iParticle)
+{ 
+// Removes particle.
+// ---
+
+  AliGunParticle* particle = fGunParticlesVector[iParticle];
+  fGunParticlesVector.remove(particle); 
+  delete particle;  
+}
+
+void AliParticleGun::GeneratePrimaryVertex(G4Event* event)
+{
+// Generates primary vertices.
+// ---
+
+  G4PrimaryVertex* previousVertex = 0;
+  G4ThreeVector previousPosition = G4ThreeVector(); 
+  G4double previousTime = 0.; 
+
+  G4int nofGunParticles = fGunParticlesVector.entries();
+  for( G4int i=0; i<nofGunParticles; i++ )
+  {    
+    AliGunParticle* particle = fGunParticlesVector[i];
+
+    G4ParticleDefinition* particleDefinition
+      = particle->GetParticleDefinition();
+    if (particleDefinition==0) {
+      AliGlobals::Exception(
+        "AliParticleGun::GeneratePrimaryVertex: Unknown particle definition.");
+    }  
+
+    G4ThreeVector position = particle->GetPosition(); 
+    G4double time = particle->GetTime(); 
+    G4PrimaryVertex* vertex;
+    if ( i==0 || position != previousPosition || time != previousTime ) {   
+      // create a new vertex 
+      // in case position and time of gun particle are different from 
+      // previous values
+      // (vertex objects are destroyed in G4EventManager::ProcessOneEvent()
+      // when event is deleted)  
+      vertex = new G4PrimaryVertex(position, time);
+      event->AddPrimaryVertex(vertex);
+
+      previousVertex = vertex;
+      previousPosition = position;
+      previousTime = time;
+    }
+    else 
+      vertex = previousVertex;
+
+    // create a primary particle and add it to the vertex
+    // (primaryParticle objects are destroyed in G4EventManager::ProcessOneEvent()
+    // when event and then vertex is deleted)
+    G4double px = particle->GetMomentum().x();
+    G4double py = particle->GetMomentum().y();
+    G4double pz = particle->GetMomentum().z();
+    G4PrimaryParticle* primaryParticle 
+      = new G4PrimaryParticle(particleDefinition, px, py, pz);
+      
+    G4double mass =  particleDefinition->GetPDGMass();
+    primaryParticle->SetMass(mass);
+    primaryParticle->SetPolarization(particle->GetPolarization().x(),
+                                     particle->GetPolarization().y(),
+                                    particle->GetPolarization().z());    
+    
+    vertex->SetPrimary(primaryParticle);
+  }
+  
+  // delete gun particles
+  fGunParticlesVector.clearAndDestroy();
+
+  // add verbose
+  G4cout << "AliParticleGun::GeneratePrimaryVertex:" << endl;
+  G4cout << "   " 
+         << event->GetNumberOfPrimaryVertex() << " of primary vertices,"
+         << "   " << nofGunParticles << " of primary particles " << endl;  
+}
+
+void AliParticleGun::Reset()
+{ 
+// Resets the particle gun.
+// ---
+
+  fGunParticlesVector.clearAndDestroy(); 
+}
+
+void AliParticleGun::List()
+{
+// Lists the particle gun.
+// ---
+
+  G4int nofGunParticles = fGunParticlesVector.entries();
+
+  G4cout << "Particle Gun: " << endl;
+
+  if (nofGunParticles==0)
+  { G4cout << "   No particles are defined." << endl; }
+  else
+  {
+    for (G4int i=0; i<nofGunParticles; i++)
+    {
+      G4cout << i << " th particle properties: " << endl;
+      G4cout << "============================" << endl;
+      fGunParticlesVector[i]->Print();
+    }
+  }
+}
+
diff --git a/AliGeant4/AliParticleGun.h b/AliGeant4/AliParticleGun.h
new file mode 100644 (file)
index 0000000..df96faa
--- /dev/null
@@ -0,0 +1,60 @@
+// $Id$
+// Category: event
+//
+// Particle gun that can be interactively composed by a user.
+
+#ifndef ALI_PARTICLE_GUN_H
+#define ALI_PARTICLE_GUN_H
+
+#include "AliGunParticle.h"
+
+#include <G4VPrimaryGenerator.hh>
+#include <G4PrimaryVertex.hh>
+#include <globals.hh>
+
+#include <g4rw/tpordvec.h>
+
+class G4Event;
+class AliParticleGunMessenger;
+
+class AliParticleGun : public G4VPrimaryGenerator
+{
+  typedef G4RWTPtrOrderedVector<AliGunParticle>  AliGunParticleVector;
+
+  public:
+     AliParticleGun();
+     AliParticleGun(const AliParticleGun &right);
+     virtual ~AliParticleGun();
+
+     // operators
+     AliParticleGun& operator=(const AliParticleGun& right);
+
+     // methods
+     void AddParticle(AliGunParticle* particle);
+     void RemoveParticle(G4int iParticle);
+     virtual void GeneratePrimaryVertex(G4Event* evt);
+     void Reset();
+     void List();
+
+     // get methods
+     G4int GetNofGunParticles() const;
+  
+  private:
+     // data members
+     AliGunParticleVector      fGunParticlesVector; //vector of AliGunParticle
+     AliParticleGunMessenger*  fMessenger;          //messenger
+};
+
+// inline methods
+
+inline G4int AliParticleGun::GetNofGunParticles() const
+{ return fGunParticlesVector.entries(); }
+
+#endif //ALI_PARTICLE_GUN_H
+
+
+
+
+
+
+
diff --git a/AliGeant4/AliParticleGunMessenger.cxx b/AliGeant4/AliParticleGunMessenger.cxx
new file mode 100644 (file)
index 0000000..9048930
--- /dev/null
@@ -0,0 +1,287 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliParticleGunMessenger.h"
+#include "AliParticleGun.h"
+#include "AliGunParticle.h"
+#include "AliGlobals.h"
+
+#include <G4Geantino.hh>
+#include <G4ThreeVector.hh>
+#include <G4ParticleTable.hh>
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithoutParameter.hh>
+#include <G4UIcmdWithAString.hh>
+#include <G4UIcmdWithADoubleAndUnit.hh>
+#include <G4UIcmdWithAnInteger.hh>
+#include <G4UIcmdWith3Vector.hh>
+#include <G4UIcmdWith3VectorAndUnit.hh>
+
+AliParticleGunMessenger::AliParticleGunMessenger(AliParticleGun* gun)
+  :fGun(gun)
+{
+//
+  fParticleTable = G4ParticleTable::GetParticleTable();
+
+  fGunDirectory = new G4UIdirectory("/aliGun/");
+  fGunDirectory->SetGuidance("AliParticleGun control commands.");
+
+  fListAvailableCmd 
+    = new G4UIcmdWithoutParameter("/aliGun/listAvailable", this);
+  fListAvailableCmd->SetGuidance("List available particles.");
+  fListAvailableCmd->SetGuidance(" Invoke G4ParticleTable.");
+  fListAvailableCmd->AvailableForStates(PreInit,Idle);
+
+  fListCurrentCmd 
+    = new G4UIcmdWithoutParameter("/aliGun/listCurrent", this);
+  fListCurrentCmd->SetGuidance("List current particle properties.");
+  fListCurrentCmd
+    ->SetGuidance("(Use addParticle to add this particle to the gun.");
+  fListCurrentCmd->AvailableForStates(PreInit,Idle);
+
+  fParticleCmd 
+    = new G4UIcmdWithAString("/aliGun/particle", this);
+  fParticleCmd->SetGuidance("Set particle to be generated.");
+  fParticleCmd->SetGuidance(" (geantino is default)");
+  fParticleCmd->SetParameterName("particleName", true);
+  fParticleCmd->SetDefaultValue("geantino");
+  G4String candidateList; 
+  G4int nofPTEntries = fParticleTable->entries();
+  for (G4int i=0; i<nofPTEntries; i++)
+  {
+    candidateList += fParticleTable->GetParticleName(i);
+    candidateList += " ";
+  }
+  fParticleCmd->SetCandidates(candidateList);
+  fParticleCmd->AvailableForStates(PreInit,Idle);
+
+  fMomentumCmd 
+    = new G4UIcmdWith3VectorAndUnit("/aliGun/momentum", this);
+  fMomentumCmd->SetGuidance("Set momentum.");
+  fMomentumCmd->SetParameterName("Px","Py","Pz", true, true);
+  fMomentumCmd->SetDefaultUnit("MeV");
+  fMomentumCmd->SetUnitCategory("Energy"); 
+  fMomentumCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
+  fMomentumCmd->AvailableForStates(PreInit,Idle);
+
+  fPositionCmd 
+    = new G4UIcmdWith3VectorAndUnit("/aliGun/position", this);
+  fPositionCmd->SetGuidance("Set starting position of the particle.");
+  fPositionCmd->SetParameterName("X","Y","Z", true, true);
+  fPositionCmd->SetDefaultUnit("cm");
+  fPositionCmd->SetUnitCategory("Length");
+  fPositionCmd->AvailableForStates(PreInit,Idle);
+
+  fTimeCmd 
+    = new G4UIcmdWithADoubleAndUnit("/aliGun/time", this);
+  fTimeCmd->SetGuidance("Set initial time of the particle.");
+  fTimeCmd->SetParameterName("t0", true, true);
+  fTimeCmd->SetDefaultUnit("ns");
+  fTimeCmd->SetUnitCategory("Time");
+  fTimeCmd->AvailableForStates(PreInit,Idle);
+  
+  fPolarizationCmd 
+    = new G4UIcmdWith3Vector("/aliGun/polarization", this);
+  fPolarizationCmd->SetGuidance("Set polarization.");
+  fPolarizationCmd->SetParameterName("Px","Py","Pz", true, true); 
+  fPolarizationCmd
+    ->SetRange("Px>=-1. && Px<=1. && Py>=-1. && Py<=1. && Pz>=-1. && Pz<=1.");
+  fPolarizationCmd->AvailableForStates(PreInit,Idle);
+  
+  fDirectionCmd 
+    = new G4UIcmdWith3Vector("/aliGun/direction", this);
+  fDirectionCmd->SetGuidance("Set momentum direction.");
+  fDirectionCmd->SetGuidance("Direction needs not to be a unit vector.");
+  fDirectionCmd->SetParameterName("Dx","Dy","Dz", true, true); 
+  fDirectionCmd->SetRange("Dx != 0 || Dy != 0 || Dz != 0");
+  fDirectionCmd->AvailableForStates(PreInit,Idle);
+  
+  fKinEnergyCmd 
+    = new G4UIcmdWithADoubleAndUnit("/aliGun/kinEnergy", this);
+  fKinEnergyCmd->SetGuidance("Set kinetic energy.");
+  fKinEnergyCmd->SetParameterName("KineticEnergy", true, true);
+  fKinEnergyCmd->SetDefaultUnit("GeV");
+  fKinEnergyCmd->SetUnitCategory("Energy");
+  fKinEnergyCmd->AvailableForStates(PreInit,Idle);
+
+  fListCmd 
+    = new G4UIcmdWithoutParameter("/aliGun/list",this);
+  fListCmd->SetGuidance("List the Alice gun particles.");
+  fListCmd->AvailableForStates(PreInit,Idle);
+
+  fAddParticleCmd 
+    = new G4UIcmdWithoutParameter("/aliGun/addParticle", this);
+  fAddParticleCmd->SetGuidance("Add the particle to the Alice particle gun.");
+  fAddParticleCmd->AvailableForStates(PreInit,Idle);
+
+  fRemoveParticleCmd 
+    = new G4UIcmdWithAnInteger("/aliGun/removeParticle", this);
+  fRemoveParticleCmd
+    ->SetGuidance("Remove the i-th particle friom the Alice particle gun.");
+  fRemoveParticleCmd->SetParameterName("iParticle", false);
+  fRemoveParticleCmd->SetRange("iParticle>=0");
+  fRemoveParticleCmd->AvailableForStates(PreInit,Idle);
+
+  fResetCmd 
+    = new G4UIcmdWithoutParameter("/aliGun/reset", this);
+  fResetCmd->SetGuidance("ReSet the Alice particle gun.");
+  fResetCmd->AvailableForStates(PreInit,Idle);
+
+  // Set initial value to AliGunParticle
+  fParticle = new AliGunParticle();
+
+  fParticle->SetParticleDefinition(G4Geantino::Geantino());
+  fParticle->SetMomentumDirection(G4ThreeVector(1.0,0.0,0.0));
+  fParticle->SetKineticEnergy(1.0*GeV);
+  fParticle->SetPosition(G4ThreeVector(0.0*cm, 0.0*cm, 0.0*cm));
+  fParticle->SetTime(0.0*ns);
+  fParticle->SetPolarization(G4ThreeVector(0.0*cm, 0.0*cm, 0.0*cm));
+}
+
+AliParticleGunMessenger::AliParticleGunMessenger() {
+//
+}
+
+AliParticleGunMessenger::AliParticleGunMessenger(
+                                 const AliParticleGunMessenger& right) {
+//                              
+  AliGlobals::Exception("AliParticleGunMessenger is protected from copying.");
+}
+
+AliParticleGunMessenger::~AliParticleGunMessenger() {
+//
+  delete fListAvailableCmd;
+  delete fParticleCmd;
+  delete fMomentumCmd;
+  delete fPositionCmd;
+  delete fTimeCmd;
+  delete fPolarizationCmd;
+  delete fDirectionCmd;
+  delete fKinEnergyCmd;
+  delete fListCmd;
+  delete fAddParticleCmd;
+  delete fRemoveParticleCmd;
+  delete fResetCmd;
+  delete fGunDirectory;
+  delete fParticle;
+}
+
+// operators
+
+AliParticleGunMessenger& 
+AliParticleGunMessenger::operator=(const AliParticleGunMessenger &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliParticleGunMessenger is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliParticleGunMessenger::SetNewValue(G4UIcommand * command, 
+       G4String newValues)
+{
+// Applies command to the associated object.
+// ---
+
+  // Alice gun particle set commands
+  if (command==fListAvailableCmd)
+  { 
+    fParticleTable->DumpTable(); 
+  } 
+  else if (command == fParticleCmd)
+  {
+    G4ParticleDefinition* particleDef 
+      = fParticleTable->FindParticle(newValues);
+    if (particleDef != 0)
+    { fParticle->SetParticleDefinition(particleDef); }
+  } 
+  else if (command == fListCurrentCmd)
+  { 
+    fParticle->Print(); 
+  } 
+  else if (command == fMomentumCmd)
+  { 
+    fParticle->SetMomentum(fMomentumCmd->GetNew3VectorValue(newValues)); 
+  } 
+  else if (command == fPositionCmd)
+  { 
+    fParticle->SetPosition(fDirectionCmd->GetNew3VectorValue(newValues)); 
+  }
+  else if (command == fTimeCmd)
+  { 
+    fParticle->SetTime(fTimeCmd->GetNewDoubleValue(newValues)); 
+  }
+  else if (command == fPolarizationCmd)
+  { 
+    fParticle
+      ->SetPolarization(fPolarizationCmd->GetNew3VectorValue(newValues)); 
+  } 
+  else if (command == fDirectionCmd)
+  { 
+    fParticle
+      ->SetMomentumDirection(fDirectionCmd->GetNew3VectorValue(newValues)); 
+  } 
+  else if (command == fKinEnergyCmd)
+  { 
+    fParticle->SetKineticEnergy(fKinEnergyCmd->GetNewDoubleValue(newValues)); 
+  }
+
+  // Alice particle gun commands 
+  else if (command == fListCmd)
+  { 
+    fGun->List(); 
+  }
+  else if (command == fAddParticleCmd)
+  { 
+    fGun->AddParticle(fParticle);
+    fParticle = new AliGunParticle(*fParticle); 
+  } 
+  else if (command == fRemoveParticleCmd)
+  { 
+    fGun->RemoveParticle(fRemoveParticleCmd->GetNewIntValue(newValues)); 
+  }
+  else if (command == fResetCmd)
+  { 
+    fGun->Reset(); 
+  }
+}
+
+G4String AliParticleGunMessenger::GetCurrentValue(G4UIcommand * command)
+{
+// Returns current command parameters as string.
+// ---
+
+  G4String curValue;
+
+  if( command==fDirectionCmd )
+  { 
+    curValue 
+      = fDirectionCmd->ConvertToString(fParticle->GetMomentumDirection()); 
+  } 
+  else if( command==fKinEnergyCmd )
+  { 
+    curValue 
+      = fKinEnergyCmd->ConvertToString(fParticle->GetKineticEnergy(),"GeV"); 
+  } 
+  else if( command==fPositionCmd )
+  { 
+    curValue = fPositionCmd->ConvertToString(fParticle->GetPosition(),"cm"); 
+  } 
+  else if( command==fTimeCmd )
+  { 
+    curValue = fTimeCmd->ConvertToString(fParticle->GetTime(),"ns"); 
+  } 
+  else if( command==fPolarizationCmd )
+  { 
+    curValue = fPolarizationCmd->ConvertToString(fParticle->GetPolarization()); 
+  }
+  
+ return curValue;
+}
+
diff --git a/AliGeant4/AliParticleGunMessenger.h b/AliGeant4/AliParticleGunMessenger.h
new file mode 100644 (file)
index 0000000..e596d7b
--- /dev/null
@@ -0,0 +1,70 @@
+// $Id$
+// Category: event
+//
+// Messenger class that defines commands for AliParticleGun.
+
+#ifndef ALI_PARTICLE_GUN_MESSENGER_H
+#define ALI_PARTICLE_GUN_MESSENGER_H
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliParticleGun;
+class AliGunParticle;
+class G4ParticleTable;
+class G4UIcommand;
+class G4UIdirectory;
+class G4UIcmdWithoutParameter;
+class G4UIcmdWithAString;
+class G4UIcmdWithADoubleAndUnit;
+class G4UIcmdWithAnInteger;
+class G4UIcmdWith3Vector;
+class G4UIcmdWith3VectorAndUnit;
+
+class AliParticleGunMessenger: public G4UImessenger
+{
+  public:
+    AliParticleGunMessenger(AliParticleGun* gun);
+    // --> protected
+    // AliParticleGunMessenger();
+    // AliParticleGunMessenger(const AliParticleGunMessenger& right);
+    virtual ~AliParticleGunMessenger();
+
+    // methods
+    virtual void SetNewValue(G4UIcommand* command, G4String newValues);
+    virtual G4String GetCurrentValue(G4UIcommand* command);
+
+  protected:
+    AliParticleGunMessenger();
+    AliParticleGunMessenger(const AliParticleGunMessenger& right);
+
+    // operators
+    AliParticleGunMessenger& operator=(
+                            const AliParticleGunMessenger& right);
+
+  private:
+    // data members
+    AliParticleGun*   fGun;           //associated class
+    AliGunParticle*   fParticle;      //current AliGunParticle
+    G4ParticleTable*  fParticleTable; //G4ParticleTable
+    // commands data members
+    G4UIdirectory*              fGunDirectory;      //command directory
+    G4UIcmdWithoutParameter*    fListAvailableCmd;  //command: listAvailable
+    G4UIcmdWithoutParameter*    fListCurrentCmd;    //command: listCurrent
+    G4UIcmdWithAString*         fParticleCmd;       //command: particle
+    G4UIcmdWith3VectorAndUnit*  fMomentumCmd;       //command: momentum
+    G4UIcmdWith3VectorAndUnit*  fPositionCmd;       //command: position
+    G4UIcmdWithADoubleAndUnit*  fTimeCmd;           //command: time
+    G4UIcmdWith3Vector*         fPolarizationCmd;   //command: polarization
+    G4UIcmdWith3Vector*         fDirectionCmd;      //command: direction 
+    G4UIcmdWithADoubleAndUnit*  fKinEnergyCmd;      //command: kinEnergy
+    G4UIcmdWithoutParameter*    fListCmd;           //command: list
+    G4UIcmdWithoutParameter*    fAddParticleCmd;    //command: addParticle
+    G4UIcmdWithAnInteger*       fRemoveParticleCmd; //command: removeParticle
+    G4UIcmdWithoutParameter*    fResetCmd;          //command: reset
+};
+
+#endif //ALI_PARTICLE_GUN_MESSENGER_H
+
+
diff --git a/AliGeant4/AliPrimaryGenerator.h b/AliGeant4/AliPrimaryGenerator.h
new file mode 100644 (file)
index 0000000..552bad8
--- /dev/null
@@ -0,0 +1,15 @@
+// $Id$
+
+#ifndef ALI_PRIMARY_GENERATOR_H
+#define ALI_PRIMARY_GENERATOR_H
+
+// available primary generators
+
+enum AliPrimaryGenerator {
+    kGun,               // gun (can be set interactively) 
+    kGeantino,          // geantino with random direction
+    kChargedGeantino,   // chargedgeantino with random direction
+    kAliGenerator       // AliGenerator from AliRoot
+};  
+
+#endif //ALI_PRIMARY_GENERATOR_H
diff --git a/AliGeant4/AliPrimaryGeneratorAction.cxx b/AliGeant4/AliPrimaryGeneratorAction.cxx
new file mode 100644 (file)
index 0000000..d990a4a
--- /dev/null
@@ -0,0 +1,304 @@
+// $Id$
+// Category: run
+//
+// See the class description in the header file.
+
+#include "AliPrimaryGeneratorAction.h"
+#include "AliPrimaryGeneratorMessenger.h"
+#include "AliTrackingAction.h"
+#include "AliParticleGun.h"
+#include "AliGunParticle.h"
+#include "AliGlobals.h"
+#include "AliRun.h"
+#include "AliGenerator.h"
+
+#include "TG3Units.h"
+
+#include <G4Event.hh>
+#include <G4ParticleTable.hh>
+#include <G4ParticleDefinition.hh>
+
+#include <Randomize.hh>
+
+#include <TParticle.h>
+
+AliPrimaryGeneratorAction::AliPrimaryGeneratorAction()
+  : fGenerator(kAliGenerator),
+    fNofGunParticles(1),
+    fVerboseLevel(0),
+    fParticleArray(0)
+{
+//
+  fParticleGun = new AliParticleGun();
+  fMessenger = new AliPrimaryGeneratorMessenger(this);
+}
+
+AliPrimaryGeneratorAction::AliPrimaryGeneratorAction(
+                                    const AliPrimaryGeneratorAction& right) {
+//                                 
+  AliGlobals::Exception(
+    "AliPrimaryGeneratorAction is protected from copying.");
+}
+
+AliPrimaryGeneratorAction::~AliPrimaryGeneratorAction() {
+//
+  delete fMessenger;
+  delete fParticleGun;
+}
+
+// operators
+
+AliPrimaryGeneratorAction& 
+AliPrimaryGeneratorAction::operator=(const AliPrimaryGeneratorAction &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception(
+    "AliPrimaryGeneratorAction is protected from assigning.");
+
+  return *this;
+}
+
+// private methods
+
+void AliPrimaryGeneratorAction::ConstructGenerator()
+{
+// Constructs selected generator.
+// ---
+
+  fParticleArray = 0;
+  switch (fGenerator) { 
+    case kGun:
+      // gun is constructed interactively      
+      return;
+    case kGeantino: 
+      ConstructGeantinoGenerator(false);
+      return;
+    case kChargedGeantino:  
+      ConstructGeantinoGenerator(true);
+      return;
+    case kAliGenerator:
+      ConstructAliGenerator();
+      return;
+  }
+}   
+      
+void AliPrimaryGeneratorAction::ConstructGeantinoGenerator(G4bool isCharged)
+{
+// Geantino with random momentum direction
+// (the default generator).
+// ---
+
+  // reset gun
+  fParticleGun->Reset();     
+
+  G4ParticleTable* particleTable 
+    = G4ParticleTable::GetParticleTable();
+
+  for (G4int i=0; i< fNofGunParticles; i++)
+  {
+    G4ParticleDefinition* particleDef = 0; 
+    if (!isCharged)
+      particleDef = particleTable->FindParticle("geantino");
+    else  
+      particleDef = particleTable->FindParticle("chargedgeantino");
+
+    if (!particleDef) {
+      G4String text = "AliPrimaryGeneratorAction::GenerateGeantino:\n";
+      text = text + "   G4ParticleTable::FindParticle() failed.";
+      AliGlobals::Exception(text);
+    }  
+      
+    G4double rn[3];
+    RandFlat::shootArray(3,rn);
+    G4double px=rn[0];
+    G4double py=rn[1];
+    G4double pz=rn[2];
+    G4ThreeVector momentumDir(px, py, pz);
+
+    G4double energy = 1.*GeV;
+    G4ThreeVector position(0.,0.,0.);
+    G4double time = 0.;
+    G4ThreeVector polarization(0.,0.,0.);
+    
+    AliGunParticle * gunParticle
+      = new AliGunParticle(particleDef, momentumDir, energy, position, time, 
+              polarization);
+
+    fParticleGun->AddParticle(gunParticle);     
+  } 
+  if (fVerboseLevel>1) { 
+    G4cout << "Geantino generator has been built." << endl; 
+  }
+} 
+            
+void AliPrimaryGeneratorAction::ConstructAliGenerator()
+{
+// Generator from AliRoot
+// AliGenerator::Generate() fills the AliRun::fParticles array.
+// ---
+
+  // check if AliGenerator is set
+  AliGenerator* generator = gAlice->Generator();
+  if (!generator) {
+    G4String text = "AliPrimaryGeneratorAction::ConstructGenerator:\n";
+    text = text + "   No AliGenerator is defined in gAlice.";
+    AliGlobals::Exception(text);
+  }  
+  // fill AliRun::fParticles array 
+  generator->Generate();
+  fParticleArray = gAlice->Particles();
+}
+
+void AliPrimaryGeneratorAction::GenerateAliGeneratorPrimaries(G4Event* event)
+{
+// Creates a new G4PrimaryVertex objects for each TParticle
+// in fParticles array.
+// ---
+
+  G4PrimaryVertex* previousVertex = 0;
+  G4ThreeVector previousPosition = G4ThreeVector(); 
+  G4double previousTime = 0.; 
+
+  G4int nofParticles = gAlice->GetNtrack();
+  // add verbose
+  //G4cout << " nofParticles: " <<  nofParticles << endl;
+  for( G4int i=0; i<nofParticles; i++ ) {    
+  
+    // get particle from TClonesArray
+    TObject* particleTObject
+      = fParticleArray->UncheckedAt(i);      
+    TParticle* particle
+      = dynamic_cast<TParticle*>(particleTObject);
+
+    // check particle type
+    if (!particle) {
+      G4String text =
+        "AliPrimaryGeneratorAction::GenerateAliGeneratorPrimaries\n";
+      text = text + "Unknown particle type";           
+      AliGlobals::Exception(text);
+    }  
+     
+    // get particle definition from G4ParticleTable
+    G4int pdgEncoding = particle->GetPdgCode();
+    G4ParticleTable* particleTable 
+      = G4ParticleTable::GetParticleTable();                
+    G4ParticleDefinition* particleDefinition = 0;    
+    if (pdgEncoding != 0) 
+      particleDefinition = particleTable->FindParticle(pdgEncoding);
+    else {
+      G4String name = particle->GetName();
+      if (name == "Rootino")   
+        particleDefinition = particleTable->FindParticle("geantino");
+    }  
+  
+    if (particleDefinition==0) {
+      G4cout << "pdgEncoding: " << pdgEncoding << endl;
+      G4String text = 
+        "AliPrimaryGeneratorAction::GenerateAliGeneratorPrimaries:\n";
+      text = text + "   G4ParticleTable::FindParticle() failed.";
+      AliGlobals::Exception(text);
+    }  
+
+    // get/create vertex
+    G4ThreeVector position 
+      = G4ThreeVector(particle->Vx()*TG3Units::Length(),
+                      particle->Vy()*TG3Units::Length(),
+                     particle->Vz()*TG3Units::Length());
+    G4double time = particle->T()*TG3Units::Time(); 
+    G4PrimaryVertex* vertex;
+    if ( i==0 || position != previousPosition || time != previousTime ) {   
+      // create a new vertex 
+      // in case position and time of gun particle are different from 
+      // previous values
+      // (vertex objects are destroyed in G4EventManager::ProcessOneEvent()
+      // when event is deleted)  
+      vertex = new G4PrimaryVertex(position, time);
+      event->AddPrimaryVertex(vertex);
+
+      previousVertex = vertex;
+      previousPosition = position;
+      previousTime = time;
+    }
+    else 
+      vertex = previousVertex;
+
+    // create a primary particle and add it to the vertex
+    // (primaryParticle objects are destroyed in G4EventManager::ProcessOneEvent()
+    // when event and then vertex is deleted)
+    G4double px = particle->Px()*TG3Units::Energy();
+    G4double py = particle->Py()*TG3Units::Energy();
+    G4double pz = particle->Pz()*TG3Units::Energy();
+    G4PrimaryParticle* primaryParticle 
+      = new G4PrimaryParticle(particleDefinition, px, py, pz);
+      
+    // set polarization
+    TVector3 polarization;
+    particle->GetPolarisation(polarization);
+    primaryParticle
+      ->SetPolarization(polarization.X(), polarization.Y(), polarization.Z());    
+    
+    // add primary particle to the vertex
+    vertex->SetPrimary(primaryParticle);
+  }
+}
+
+// public methods
+
+void AliPrimaryGeneratorAction::GeneratePrimaries(G4Event* event)
+{
+// Generates primary particles by the selected generator.
+// ---
+
+  // reset AliRun
+  gAlice->BeginEvent();
+
+  // fill particle gun/particle array
+  ConstructGenerator();
+  
+  // generate primary vertices
+  if (fParticleArray)  {
+    // use AliGenerator if set
+    GenerateAliGeneratorPrimaries(event);
+
+    // do not save primary particles
+    // (they would be stored twice)
+    AliTrackingAction* trackingAction
+      =  AliTrackingAction::Instance();
+    trackingAction->SetSavePrimaries(false);
+  }  
+  else {
+    // use particle gun otherwise
+    fParticleGun->GeneratePrimaryVertex(event);
+
+    // primary particles have to be saved
+    AliTrackingAction* trackingAction
+      =  AliTrackingAction::Instance();
+    trackingAction->SetSavePrimaries(true);
+  }  
+}
+
+void AliPrimaryGeneratorAction::SetGenerator(AliPrimaryGenerator generator)
+{ 
+// Sets generator.
+// ---
+
+  fGenerator = generator; 
+}
+
+void AliPrimaryGeneratorAction::SetNofGunParticles(G4int nofParticles)
+{ 
+// Sets number of primary particles.
+// This method is applied only to "gun" type generators
+// (and not to AliGenerator from AliRoot).
+// ---
+
+  fNofGunParticles = nofParticles;
+}
+
+
+
+
+
+
diff --git a/AliGeant4/AliPrimaryGeneratorAction.h b/AliGeant4/AliPrimaryGeneratorAction.h
new file mode 100644 (file)
index 0000000..8c0b2f6
--- /dev/null
@@ -0,0 +1,86 @@
+// $Id$
+// Category: run
+//
+// Class that defines primary generator action. 
+// Available primary generators (AliPrimaryGenerator):
+//  kGun,               // gun (can be set interactively) 
+//  kGeantino,          // geantino with random direction
+//  kChargedGeantino,   // chargedgeantino with random direction
+//  kAliGenerator       // AliGenerator from AliRoot
+
+#ifndef ALI_PRIMARY_GENERATOR_ACTION_H
+#define ALI_PRIMARY_GENERATOR_ACTION_H
+
+#include "AliPrimaryGenerator.h"
+
+#include <G4VUserPrimaryGeneratorAction.hh>
+#include <globals.hh>
+
+#include <TClonesArray.h>
+
+class AliParticleGun;
+class AliPrimaryGeneratorMessenger;
+class G4ParticleGun;
+class G4Event;
+
+class AliPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
+{
+  public:
+    AliPrimaryGeneratorAction();
+    // --> protected
+    // AliPrimaryGeneratorAction(const AliPrimaryGeneratorAction& right);
+    virtual ~AliPrimaryGeneratorAction();
+
+    // methods
+    virtual void GeneratePrimaries(G4Event* event);
+    
+    // set methods
+    void SetGenerator(AliPrimaryGenerator generator);
+    void SetNofGunParticles(G4int nofParticles);
+    void SetVerboseLevel(G4int level);
+
+    // get methods
+    AliPrimaryGenerator GetGenerator() const;
+    G4int GetNofGunParticles() const;
+    G4int GetVerboseLevel() const;
+    
+  protected:
+    AliPrimaryGeneratorAction(const AliPrimaryGeneratorAction& right);
+
+    // operators
+    AliPrimaryGeneratorAction& operator=(
+                              const AliPrimaryGeneratorAction& right);
+
+  private:
+    // methods
+    void ConstructGenerator();
+    void ConstructGeantinoGenerator(G4bool isCharged);
+    void ConstructAliGenerator();
+    void GenerateAliGeneratorPrimaries(G4Event* event);
+    
+    // data members
+    AliPrimaryGenerator  fGenerator;       //selected AliPrimaryGenerator
+    G4int                fNofGunParticles; //number of gun particles
+    G4int                fVerboseLevel;    //verbose level
+    AliParticleGun*      fParticleGun;     //AliParticleGun
+    TClonesArray*        fParticleArray;   //AliRun::fParticles
+    AliPrimaryGeneratorMessenger*  fMessenger; //messenger
+};
+
+// inline methods
+
+inline void AliPrimaryGeneratorAction::SetVerboseLevel(G4int level)
+{ fVerboseLevel = level; }
+
+inline AliPrimaryGenerator AliPrimaryGeneratorAction::GetGenerator() const
+{ return fGenerator; }
+
+inline G4int AliPrimaryGeneratorAction::GetNofGunParticles() const
+{ return fNofGunParticles; }
+
+inline G4int AliPrimaryGeneratorAction::GetVerboseLevel() const
+{ return fVerboseLevel; }
+
+#endif //ALI_PRIMARY_GENERATOR_ACTION_H
+
+
diff --git a/AliGeant4/AliPrimaryGeneratorMessenger.cxx b/AliGeant4/AliPrimaryGeneratorMessenger.cxx
new file mode 100644 (file)
index 0000000..490395a
--- /dev/null
@@ -0,0 +1,112 @@
+// $Id$
+// Category: run
+//
+// See the class description in the header file.
+
+#include "AliPrimaryGeneratorMessenger.h"
+#include "AliPrimaryGeneratorAction.h"
+#include "AliPrimaryGenerator.h"
+#include "AliGlobals.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithAString.hh>
+#include <G4UIcmdWithAnInteger.hh>
+
+AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger(
+  AliPrimaryGeneratorAction* primaryGenAction)
+  : fPrimaryGenAction(primaryGenAction)
+{
+// 
+  fPrimariesDirectory = new G4UIdirectory("/aliGenerator/");
+  fPrimariesDirectory->SetGuidance("AliPrimaryGeneratorAction control commands.");
+
+  fGeneratorCmd = new G4UIcmdWithAString("/aliGenerator/set", this);
+  G4String guidance =   "Set one of the defined primary generators:\n";
+  guidance = guidance + "  Gun:               particle gun (default)\n";
+  guidance = guidance + "  Geantino:          geantino with random momentum(default)\n";
+  guidance = guidance + "  ChargedGeantino:   chargedgeantino with random momentum\n";
+  guidance = guidance + "  AliGenerator:      standard aliroot generator";
+  fGeneratorCmd->SetGuidance(guidance);
+  fGeneratorCmd->SetParameterName("Generator", true);
+  fGeneratorCmd->SetCandidates("Gun Geantino ChargedGeantino AliGenerator");   
+  fGeneratorCmd->SetDefaultValue("AliGenerator");
+  fGeneratorCmd->AvailableForStates(PreInit,Idle);
+
+  fNofParticlesCmd = new G4UIcmdWithAnInteger("/aliGenerator/nofParticles", this);
+  fNofParticlesCmd->SetGuidance("Give number of primary particles:");
+  fNofParticlesCmd->SetGuidance("It is applied only to \"gun\" type generators.");
+  fNofParticlesCmd->SetParameterName("NofParticles", true);
+  fNofParticlesCmd->SetDefaultValue(1);
+  fNofParticlesCmd->SetRange("NofParticles >= 0");
+  fNofParticlesCmd->AvailableForStates(PreInit,Idle);
+
+  fVerboseCmd = new G4UIcmdWithAnInteger("/aliGenerator/verbose", this);
+  fVerboseCmd->SetGuidance("Set verbose level for AliPrimaryGeneratorAction");
+  fVerboseCmd->SetParameterName("VerboseLevel", true);
+  fVerboseCmd->SetDefaultValue(0);
+  fVerboseCmd->SetRange("VerboseLevel >= 0 && VerboseLevel <= 2");
+  fVerboseCmd->AvailableForStates(Idle);
+}
+
+AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger() {
+//
+}
+
+AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger(
+                                 const AliPrimaryGeneratorMessenger& right) {
+//                              
+  AliGlobals::Exception(
+    "AliPrimaryGeneratorMessenger is protected from copying.");
+}
+
+AliPrimaryGeneratorMessenger::~AliPrimaryGeneratorMessenger() {
+//
+  delete fPrimariesDirectory;
+  delete fGeneratorCmd;
+  delete fNofParticlesCmd;
+  delete fVerboseCmd;
+}
+
+// operators
+
+AliPrimaryGeneratorMessenger& 
+AliPrimaryGeneratorMessenger::operator=(
+                                const AliPrimaryGeneratorMessenger &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception(
+    "AliPrimaryGeneratorMessenger is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliPrimaryGeneratorMessenger::SetNewValue(G4UIcommand * command,
+       G4String newValue)
+{ 
+// Applies command to the associated object.
+// ---
+
+  if( command == fGeneratorCmd ) { 
+    if (newValue == "Gun") 
+      fPrimaryGenAction->SetGenerator(kGun); 
+    else if (newValue == "Geantino") 
+      fPrimaryGenAction->SetGenerator(kGeantino); 
+    else if (newValue == "ChargedGeantino")  
+      fPrimaryGenAction->SetGenerator(kChargedGeantino); 
+    else if (newValue == "AliGenerator")  
+      fPrimaryGenAction->SetGenerator(kAliGenerator);       
+  }
+  else if( command == fNofParticlesCmd ) { 
+    fPrimaryGenAction
+      ->SetNofGunParticles(fNofParticlesCmd->GetNewIntValue(newValue)); 
+  }   
+  else if(command == fVerboseCmd) { 
+    fPrimaryGenAction
+      ->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue)); 
+  }
+}
+
diff --git a/AliGeant4/AliPrimaryGeneratorMessenger.h b/AliGeant4/AliPrimaryGeneratorMessenger.h
new file mode 100644 (file)
index 0000000..7fb492b
--- /dev/null
@@ -0,0 +1,48 @@
+// $Id$
+// Category: run
+//
+// Messenger class that defines commands for AliPrimaryGeneratorAction.
+
+#ifndef ALI_PRIMARY_GENERATOR_MESSENGER_H
+#define ALI_PRIMARY_GENERATOR_MESSENGER_H
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliPrimaryGeneratorAction;
+
+class G4UIdirectory;
+class G4UIcmdWithAString;
+class G4UIcmdWithAnInteger;
+
+class AliPrimaryGeneratorMessenger: public G4UImessenger
+{
+  public:
+    AliPrimaryGeneratorMessenger(AliPrimaryGeneratorAction* primaryGenAction);
+    // --> protected
+    // AliPrimaryGeneratorMessenger();
+    // AliPrimaryGeneratorMessenger(const AliPrimaryGeneratorMessenger& right);
+    virtual ~AliPrimaryGeneratorMessenger();
+    
+    // methods
+    void SetNewValue(G4UIcommand* command, G4String string);
+    
+  protected:
+    AliPrimaryGeneratorMessenger();
+    AliPrimaryGeneratorMessenger(const AliPrimaryGeneratorMessenger& right);
+
+    // operators
+    AliPrimaryGeneratorMessenger& operator=(
+                                 const AliPrimaryGeneratorMessenger& right);
+
+  private:
+    // data members
+    AliPrimaryGeneratorAction*  fPrimaryGenAction;   //associated class
+    G4UIdirectory*              fPrimariesDirectory; //command directory
+    G4UIcmdWithAString*         fGeneratorCmd;       //command: set
+    G4UIcmdWithAnInteger*       fNofParticlesCmd;    //command: nofParticles
+    G4UIcmdWithAnInteger*       fVerboseCmd;         //command: verbose
+};
+
+#endif //ALI_PRIMARY_GENERATOR_MESSENGER_H
+
diff --git a/AliGeant4/AliRunAction.cxx b/AliGeant4/AliRunAction.cxx
new file mode 100644 (file)
index 0000000..c643b53
--- /dev/null
@@ -0,0 +1,103 @@
+// $Id$
+// Category: run
+//
+// See the class description in the header file.
+
+#include <G4Timer.hh>
+   // in order to avoid the odd dependency for the
+   // times system function this include must be the first
+
+#include "AliRunAction.h"
+#include "AliRunActionMessenger.h"
+#include "AliSDManager.h"
+#include "AliGlobals.h"
+#include "AliRun.h"
+#include "AliLego.h"
+
+#include "TG4GeometryManager.h"
+
+#include <G4Run.hh>
+#include <G4UImanager.hh>
+
+#include <TFile.h>
+
+AliRunAction::AliRunAction()
+  : fRunID(-1),
+    fVerboseLevel(0)
+{
+//
+  fMessenger = new AliRunActionMessenger(this);
+  fTimer = new G4Timer;
+}
+
+AliRunAction::AliRunAction(const AliRunAction& right) {
+//
+  AliGlobals::Exception("AliRunAction is protected from copying.");
+}
+
+AliRunAction::~AliRunAction() {
+//
+  delete fMessenger;
+  delete fTimer;
+}
+
+// operators
+
+AliRunAction& AliRunAction::operator=(const AliRunAction &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliRunAction is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliRunAction::BeginOfRunAction(const G4Run* run)
+{
+// Called by G4 kernel at the beginning of run.
+// ---
+
+  fRunID++;
+  
+  // aliroot
+  // store runID in the event header
+  gAlice->GetHeader()->SetRun(fRunID);
+
+  // clear remaining G3 tables
+  if (fRunID == 0)
+    TG4GeometryManager::Instance()->ClearG3TablesFinal();
+
+  // create lego sensitive detectors 
+  // if lego is instantiated
+  AliLego* lego = gAlice->Lego();
+  if (lego) {
+    AliSDManager::Instance()->SetLego(lego);
+    G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 0");
+    G4UImanager::GetUIpointer()->ApplyCommand("/aliGenerator/set AliGenerator");
+  }  
+
+  G4cout << "### Run " << run->GetRunID() << " start." << endl;
+  fTimer->Start();
+}
+
+void AliRunAction::EndOfRunAction(const G4Run* run)
+{
+// Called by G4 kernel at the end of run.
+// ---
+
+  fTimer->Stop();
+
+  // delete lego sensitive detectors 
+  // if lego is instantiated
+  AliLego* lego = gAlice->Lego();
+  if (lego) {
+    AliSDManager::Instance()->UnsetLego();
+    G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 1");
+  }  
+
+  G4cout << "Number of events = " << run->GetNumberOfEvent() 
+         << " " << *fTimer << endl;
+}    
diff --git a/AliGeant4/AliRunAction.h b/AliGeant4/AliRunAction.h
new file mode 100644 (file)
index 0000000..8320199
--- /dev/null
@@ -0,0 +1,60 @@
+// $Id$
+// Category: run
+//
+// Class that defines actions at the beginning and the end of run.
+
+#ifndef ALI_RUN_ACTION_H
+#define ALI_RUN_ACTION_H
+
+#include <globals.hh>
+#include <G4UserRunAction.hh>
+
+class G4Timer;
+    // in order to avoid the odd dependency for the
+    // times system function this declaration must be the first
+
+class AliRunActionMessenger;
+class G4Run;
+
+class AliRunAction : public G4UserRunAction
+{
+  public:
+    AliRunAction();
+    // --> protected
+    // AliRunAction(const AliRunAction& right);
+    virtual ~AliRunAction();
+
+    // methods
+    virtual void BeginOfRunAction(const G4Run* run);
+    virtual void EndOfRunAction(const G4Run* run);
+
+    // set methods
+    void SetVerboseLevel(G4int level);
+
+    // get methods
+    G4int GetVerboseLevel() const;
+
+  protected:
+    AliRunAction(const AliRunAction& right);
+
+    // operators
+    AliRunAction& operator=(const AliRunAction& right);
+
+  private:
+    // data members
+    AliRunActionMessenger*  fMessenger;    //messenger 
+    G4Timer*                fTimer;        //G4Timer
+    G4int                   fRunID;        //run ID
+    G4int                   fVerboseLevel; //verbose level
+};
+
+// inline methods
+
+inline void AliRunAction::SetVerboseLevel(G4int level)
+{ fVerboseLevel = level; }
+
+inline G4int AliRunAction::GetVerboseLevel() const
+{ return fVerboseLevel; }
+
+#endif //ALI_RUN_ACTION_H
+
diff --git a/AliGeant4/AliRunActionMessenger.cxx b/AliGeant4/AliRunActionMessenger.cxx
new file mode 100644 (file)
index 0000000..1dc1e66
--- /dev/null
@@ -0,0 +1,70 @@
+// $Id$
+// Category: run
+//
+// See the class description in the header file.
+
+#include "AliRunActionMessenger.h"
+#include "AliRunAction.h"
+#include "AliGlobals.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithAnInteger.hh>
+#include <G4UIcmdWithoutParameter.hh>
+
+AliRunActionMessenger::AliRunActionMessenger(AliRunAction* runAction)
+  : fRunAction(runAction)
+{
+// 
+  fRunActionDirectory = new G4UIdirectory("/aliRunAction/");
+  fRunActionDirectory->SetGuidance("AliRunAction control commands.");
+
+  fVerboseCmd = new G4UIcmdWithAnInteger("/aliRunAction/verbose", this);
+  fVerboseCmd->SetGuidance("Set verbose level for AliRunAction");
+  fVerboseCmd->SetParameterName("VerboseLevel", true);
+  fVerboseCmd->SetDefaultValue(0);
+  fVerboseCmd->SetRange("VerboseLevel >= 0 && VerboseLevel <= 2");
+  fVerboseCmd->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
+}
+
+AliRunActionMessenger::AliRunActionMessenger() {
+//
+}
+
+AliRunActionMessenger::AliRunActionMessenger(const AliRunActionMessenger& right)
+{
+//
+  AliGlobals::Exception("AliRunActionMessenger is protected from copying.");
+}
+
+AliRunActionMessenger::~AliRunActionMessenger() {
+//
+  delete fRunActionDirectory;
+  delete fVerboseCmd;
+}
+
+// operators
+
+AliRunActionMessenger& 
+AliRunActionMessenger::operator=(const AliRunActionMessenger &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliRunActionMessenger is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliRunActionMessenger::SetNewValue(G4UIcommand* command, 
+       G4String newValue)
+{ 
+// Applies command to the associated object.
+// ---
+
+  if(command == fVerboseCmd) { 
+    fRunAction
+      ->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue)); 
+  }   
+}
diff --git a/AliGeant4/AliRunActionMessenger.h b/AliGeant4/AliRunActionMessenger.h
new file mode 100644 (file)
index 0000000..7320ded
--- /dev/null
@@ -0,0 +1,44 @@
+// $Id$
+// Category: run
+//
+// Messenger class that defines commands for AliRunAction.
+
+#ifndef ALI_RUN_ACTION_MESSENGER_H
+#define ALI_RUN_ACTION_MESSENGER_H 
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliRunAction;
+
+class G4UIdirectory;
+class G4UIcmdWithAnInteger;
+
+class AliRunActionMessenger: public G4UImessenger
+{
+  public:
+    AliRunActionMessenger(AliRunAction* eventAction);
+    // --> protected
+    // AliRunActionMessenger();
+    // AliRunActionMessenger(const AliRunActionMessenger& right);
+    virtual ~AliRunActionMessenger();
+   
+    // methods 
+    virtual void SetNewValue(G4UIcommand* command, G4String string);
+    
+  protected:
+    AliRunActionMessenger();
+    AliRunActionMessenger(const AliRunActionMessenger& right);
+
+    // operators
+    AliRunActionMessenger& operator=(
+                            const AliRunActionMessenger& right);
+
+  private:
+    // data members
+    AliRunAction*          fRunAction;          //associated class
+    G4UIdirectory*         fRunActionDirectory; //command directory
+    G4UIcmdWithAnInteger*  fVerboseCmd;         //command: verbose 
+};
+
+#endif //ALI_RUN_ACTION_MESSENGER_H
diff --git a/AliGeant4/AliRunConfiguration.cxx b/AliGeant4/AliRunConfiguration.cxx
new file mode 100644 (file)
index 0000000..5a16807
--- /dev/null
@@ -0,0 +1,82 @@
+// $Id$
+// Category: run
+//
+// See the class description in the header file.
+
+#include "AliRunConfiguration.h"
+#include "AliRunMessenger.h"
+#include "AliGlobals.h"
+
+#include "AliDetConstruction.h"
+#include "AliEmptyPhysicsList.h"
+#include "AliPrimaryGeneratorAction.h"
+#include "AliRunAction.h"
+#include "AliEventAction.h"
+#include "AliTrackingAction.h"
+#include "AliStackingAction.h"
+#include "AliSteppingAction.h"
+
+#include "TG4PhysicsList.h"
+
+AliRunConfiguration::AliRunConfiguration(){
+//
+  fRunMessenger = new AliRunMessenger();
+  CreateUserConfiguration();
+}
+
+AliRunConfiguration::AliRunConfiguration(const AliRunConfiguration& right)
+  : TG4VRunConfiguration(right)
+{
+  // TG4VRunConfiguration is protected from copying
+}
+
+AliRunConfiguration::~AliRunConfiguration() {
+//
+  delete fRunMessenger;
+
+  // all user action data members are deleted 
+  // in G4RunManager::~G4RunManager()
+}
+
+// operators
+
+AliRunConfiguration& 
+AliRunConfiguration::operator=(const AliRunConfiguration& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  // base class assignement
+  // TG4VRunConfiguration is protected from assigning
+  TG4VRunConfiguration::operator=(right);
+
+  return *this;  
+}    
+          
+// protected methods
+
+void AliRunConfiguration::CreateUserConfiguration()
+{
+// Creates the mandatory Geant4 classes and 
+// the other user action classes. 
+// ---
+
+  // create mandatory Geant4 classes
+  fDetectorConstruction = new AliDetConstruction();
+#ifndef ALICE_EMPTY_PHYSICS_LIST
+  fPhysicsList = new TG4PhysicsList();
+#else
+  fPhysicsList = new AliEmptyPhysicsList();
+#endif
+  fPrimaryGenerator = new AliPrimaryGeneratorAction();
+
+  // create the other user action classes
+  fRunAction = new AliRunAction();
+  fEventAction = new AliEventAction();
+  fTrackingAction = new AliTrackingAction();
+  fSteppingAction = new AliSteppingAction();
+#ifdef ALICE_STACKING
+  fStackingAction = new AliStackingAction();
+#endif
+}
diff --git a/AliGeant4/AliRunConfiguration.h b/AliGeant4/AliRunConfiguration.h
new file mode 100644 (file)
index 0000000..c7de077
--- /dev/null
@@ -0,0 +1,40 @@
+// $Id$
+// Category: run
+//
+// This class creates all Ali* specific action classes
+// that will be initialized and managed by Geant4 kernel (G4RunManager)
+// and creates AliRunMessenger that implements commands for
+// AliRun methods.
+
+#ifndef ALI_RUN_CONFIGURATION_H
+#define ALI_RUN_CONFIGURATION_H
+
+#include "TG4VRunConfiguration.h"
+
+class AliRunMessenger;
+
+class G4RunManager;
+
+class AliRunConfiguration : public TG4VRunConfiguration
+{
+  public:
+    AliRunConfiguration();
+    // --> protected
+    // AliRunConfiguration(const AliRunConfiguration& right);
+    virtual ~AliRunConfiguration();
+
+  protected:
+    AliRunConfiguration(const AliRunConfiguration& right);
+
+    // operators
+    AliRunConfiguration& operator=(const AliRunConfiguration& right);
+
+    // methods
+    virtual void CreateUserConfiguration();
+    
+  private:
+    AliRunMessenger*  fRunMessenger;  //messenger  
+};
+
+#endif //ALI_RUN_CONFIGURATION_H
+
diff --git a/AliGeant4/AliRunMessenger.cxx b/AliGeant4/AliRunMessenger.cxx
new file mode 100644 (file)
index 0000000..50af6b1
--- /dev/null
@@ -0,0 +1,85 @@
+// $Id$
+// Category: run
+//
+// See the class description in the header file.
+
+#include "AliRunMessenger.h"
+#include "AliFiles.h"
+#include "AliGlobals.h"
+#include "AliRun.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithAnInteger.hh>
+#include <G4UIcmdWithoutParameter.hh>
+
+AliRunMessenger::AliRunMessenger()
+{
+// 
+  fRunDirectory = new G4UIdirectory("/aliRun/");
+  fRunDirectory->SetGuidance("AliRun control commands.");
+
+  fInitializeCmd = new G4UIcmdWithoutParameter("/aliRun/initialize", this);
+  fInitializeCmd->SetGuidance("Initialize AliRun");
+  fInitializeCmd->AvailableForStates(PreInit);
+
+  fBeamOnCmd = new G4UIcmdWithAnInteger("/aliRun/beamOn", this);
+  fBeamOnCmd->SetGuidance("Run the specified number of events");
+  fBeamOnCmd->SetParameterName("NofEvents", true);
+  fBeamOnCmd->SetDefaultValue(1);
+  fBeamOnCmd->SetRange("NofEvents >= 0");
+  fBeamOnCmd->AvailableForStates(Idle);
+
+  fLegoCmd = new G4UIcmdWithoutParameter("/aliRun/lego", this);
+  fLegoCmd->SetGuidance("Lego run");
+  fLegoCmd->AvailableForStates(Idle);
+}
+
+AliRunMessenger::AliRunMessenger(const AliRunMessenger& right) {
+//
+  AliGlobals::Exception("AliRunMessenger is protected from copying.");
+}
+
+AliRunMessenger::~AliRunMessenger() {
+//
+  delete fRunDirectory;
+  delete fInitializeCmd;
+  delete fBeamOnCmd;
+  delete fLegoCmd;
+}
+
+// operators
+
+AliRunMessenger& AliRunMessenger::operator=(const AliRunMessenger &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliRunMessenger is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliRunMessenger::SetNewValue(G4UIcommand* command, 
+       G4String newValue)
+{ 
+// Applies command to the associated object.
+// ---
+
+  // test gAlice
+  if (!gAlice) {
+    AliGlobals::Exception(
+      "AliRunMessenger: gAlice has not been instantiated yet.");
+  }      
+
+  if(command == fInitializeCmd) { 
+    gAlice->Init(AliFiles::Config()); 
+  }   
+  else if(command == fBeamOnCmd) { 
+    gAlice->Run(fBeamOnCmd->GetNewIntValue(newValue)); 
+  }   
+  else if(command == fLegoCmd) { 
+    gAlice->RunLego(); 
+  }   
+}
diff --git a/AliGeant4/AliRunMessenger.h b/AliGeant4/AliRunMessenger.h
new file mode 100644 (file)
index 0000000..5b601d5
--- /dev/null
@@ -0,0 +1,41 @@
+// $Id$
+// Category: run
+//
+// Messenger class that defines commands for AliRun.
+
+#ifndef ALI_RUN_MESSENGER_H
+#define ALI_RUN_MESSENGER_H 
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class G4UIdirectory;
+class G4UIcmdWithoutParameter;
+class G4UIcmdWithAnInteger;
+
+class AliRunMessenger: public G4UImessenger
+{
+  public:
+    AliRunMessenger();
+    // --> protected
+    // AliRunMessenger(const AliRunMessenger& right);
+    virtual ~AliRunMessenger();
+   
+    // methods 
+    virtual void SetNewValue(G4UIcommand* command, G4String string);
+    
+  protected:
+    AliRunMessenger(const AliRunMessenger& right);
+
+    // operators
+    AliRunMessenger& operator=(const AliRunMessenger& right);
+
+  private:
+    // data members
+    G4UIdirectory*            fRunDirectory;  //command directory
+    G4UIcmdWithoutParameter*  fInitializeCmd; //command: initialize
+    G4UIcmdWithAnInteger*     fBeamOnCmd;     //command: beamOn
+    G4UIcmdWithoutParameter*  fLegoCmd;       //command: lego
+};
+
+#endif //ALI_RUN_MESSENGER_H
diff --git a/AliGeant4/AliSDManager.cxx b/AliGeant4/AliSDManager.cxx
new file mode 100644 (file)
index 0000000..b6f56e8
--- /dev/null
@@ -0,0 +1,231 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliSDManager.h"
+//#include "AliSDMessenger.h"
+#include "AliSensitiveDetector.h"
+#include "AliLegoSensitiveDetector.h"
+#include "AliGlobals.h"
+#include "AliFiles.h"
+#include "AliRun.h"
+
+#include "TG4GeometryManager.h"
+
+#include <G3SensVolVector.hh>
+#include <G4SDManager.hh>
+#include <G4UImanager.hh>
+#include <G4LogicalVolume.hh>
+#include <G4LogicalVolumeStore.hh>
+
+AliSDManager* AliSDManager::fgInstance = 0;
+
+AliSDManager* AliSDManager::Instance()
+{
+// Returns the singleton instance.
+// Creates the instance if it does not exist.
+// ---
+
+  if (!fgInstance) new AliSDManager();
+  
+  return fgInstance;
+}  
+    
+AliSDManager::AliSDManager() {
+//
+  //fMessenger = new AliSDMessenger(this);
+  fgInstance = this;
+}
+
+AliSDManager::AliSDManager(const AliSDManager& right) {
+//
+  AliGlobals::Exception(
+    "Singleton AliSDManager is protected from copying.");
+}
+
+AliSDManager::~AliSDManager()
+{
+  //delete fMessenger;
+}
+
+// operators
+
+AliSDManager& AliSDManager::operator=(const AliSDManager& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception(
+     "Singleton AliSDManager is protected from assigning.");
+    
+  return *this;  
+}    
+          
+// private methods
+
+void AliSDManager::CreateLegoSD(G4LogicalVolume* lv, AliLego* lego) const
+{ 
+// Replaces the existing sensitive detector of the logical volume
+// with the lego sensitive detector.
+// ---
+
+  TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
+  G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
+
+  G4String lvName = lv->GetName(); 
+  G4String sdName = "/Alice/lego/" + lvName;
+
+  // cut copy number from sdName
+  pGeometryManager->G4ToG3VolumeName(sdName);
+  
+  // retrieve the standard sensitive detector
+  G4VSensitiveDetector* sd = lv->GetSensitiveDetector();
+
+  // create/retrieve the lego sensitive detector
+  G4VSensitiveDetector* legoVSD = 0; 
+  legoVSD = pSDManager->FindSensitiveDetector(sdName);
+
+  if (!legoVSD) {
+    AliLegoSensitiveDetector* legoSD
+      = new AliLegoSensitiveDetector(sdName, lego, sd);        
+    pSDManager->AddNewDetector(legoSD);
+    // add verbose
+    G4cout << "Lego sensitive detector " << sdName 
+         << ") has been created." << endl;
+    legoVSD = legoSD;  
+  }      
+  lv->SetSensitiveDetector(legoVSD);        
+}
+
+void AliSDManager::UnsetLegoSD(G4LogicalVolume* lv) const
+{ 
+// Replace the lego sensitive detector of the logical volume
+// with the standard sensitive detector.
+// ---
+
+  G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
+
+  // get the lego sensitive detector
+  G4VSensitiveDetector* sd = lv->GetSensitiveDetector();
+  AliLegoSensitiveDetector* legoSD = 0; 
+  if (sd) {
+    // check type
+    legoSD = dynamic_cast<AliLegoSensitiveDetector*>(sd);
+    if (!legoSD) {
+      G4String text = "AliSDManager::UnsetLego: \n";
+      text = text + "    Wrong sensitive detector type.";
+      AliGlobals::Exception(text);
+    }  
+  }
+  // get the standard sensitive detector
+  G4VSensitiveDetector* standardSD = legoSD->GetStandardSD();
+
+  // set the standard sensitive detector
+  lv->SetSensitiveDetector(standardSD);             
+}
+
+
+// public methods
+
+void AliSDManager::CreateSD(G4LogicalVolume* lv, AliModule* module) const
+{ 
+// Creates/retrieves a sensitive detector for the logical volume.
+// ---
+
+  TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
+  G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
+
+  G4String lvName = lv->GetName(); 
+  
+  G4String moduleName = module->GetName();
+  G4String sdName = "/Alice/" + moduleName + "/" + lvName;
+
+  // cut copy number from sdName
+  pGeometryManager->G4ToG3VolumeName(sdName);
+  
+  // create/retrieve the sensitive detector
+  G4VSensitiveDetector* sd = 0; 
+  sd = pSDManager->FindSensitiveDetector(sdName);
+  if (!sd) {
+    AliSensitiveDetector* asd 
+      = new AliSensitiveDetector(sdName, module);      
+    pSDManager->AddNewDetector(asd);
+    // add verbose
+    G4cout << "Sensitive detector " << sdName << "(" 
+           << asd->GetID() << ") has been created." << endl;
+    sd = asd;  
+  }    
+  lv->SetSensitiveDetector(sd);             
+}
+
+AliModule* AliSDManager::FindAliModule(G4LogicalVolume* lv) const
+{
+// Finds the module containing specified logical volume.
+// ---
+
+  // geometry manager
+  TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
+
+  // get g3 volume name
+  G4String g3Name = lv->GetName();
+  pGeometryManager->G4ToG3VolumeName(g3Name);
+  
+  // get module name from the map
+  G4String moduleName = pGeometryManager->GetMapSecond(g3Name);
+  
+  // find module from gAlice
+  AliModule* module = gAlice->GetModule(moduleName);
+  if (!module) {
+    G4String text = "AliSDManager::Configure:\n";
+    text = text + "    AliModule " + moduleName;
+    text = text + " has not been found in gAlice.";
+    AliGlobals::Exception(text);
+  }  
+   
+  return module;
+}  
+
+void AliSDManager::SetLego(AliLego* lego) const 
+{ 
+// Replaces the existing sensitive detectors 
+// with lego sensitive detectors.
+// ---
+
+  if (!lego) {
+    G4String text = "AliSDManager::SetLego: \n";
+    text = text + "    No AliLego is defined.";
+    AliGlobals::Warning(text);
+    return;
+  }  
+
+  G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
+  G4int nofLV = pLVStore->entries();
+  
+  for (G4int i=0; i<nofLV; i++) {
+    G4LogicalVolume* lv = (*pLVStore)[i];
+    CreateLegoSD(lv, lego);
+  }
+}
+
+void AliSDManager::UnsetLego() const
+{
+// Replace the lego sensitive detectors 
+// back with standard sensitive detectors.
+// ---
+
+  G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
+  G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
+  G4int nofLV = pLVStore->entries();
+  
+  // set back standard sensitive detectors
+  for (G4int i=0; i<nofLV; i++) {
+    G4LogicalVolume* lv = (*pLVStore)[i];
+    UnsetLegoSD(lv);
+  }  
+
+  // The lego sensitive detectors are not deleted here
+  // as there is no way how to unregister them
+  // from G4SDManager
+}
diff --git a/AliGeant4/AliSDManager.h b/AliGeant4/AliSDManager.h
new file mode 100644 (file)
index 0000000..3ac71aa
--- /dev/null
@@ -0,0 +1,70 @@
+// $Id$
+// Category: geometry
+//
+// Class providing methods for creating sensitive detectors
+// and switching between lego sensitive detectors and 
+// the standard ones.
+
+#ifndef ALI_SD_MANAGER_H
+#define ALI_SD_MANAGER_H
+
+#include <globals.hh>
+
+//class AliSDMessenger;
+class AliLego;
+class AliModule;
+
+class G4VPhysicalVolume;
+class G4LogicalVolume;
+
+class AliSDManager 
+{  
+  public:
+    // --> protected
+    // AliSDManager();
+    // AliSDManager(const AliSDManager& right);
+    virtual ~AliSDManager();
+    
+    // static methods
+    static AliSDManager* Instance();
+    
+    // methods
+    void CreateSD(G4LogicalVolume* lv, AliModule* module) const;
+    AliModule* FindAliModule(G4LogicalVolume* lv) const;
+    void SetLego(AliLego* lego) const;
+    void UnsetLego() const;
+
+    // set/get methods 
+    inline void SetNofLVWithSD(G4int nofLV);
+    inline G4int GetNofLVWithSD() const;
+    
+  protected:
+    AliSDManager();
+    AliSDManager(const AliSDManager& right);
+
+    // operators
+    AliSDManager& operator=(const AliSDManager& right);
+  
+  private:
+    // methods
+    void CreateLegoSD(G4LogicalVolume* lv, AliLego* lego) const;
+    void UnsetLegoSD(G4LogicalVolume* lv) const;
+
+    // static data members
+    static AliSDManager*    fgInstance;   //this instance
+
+    // data members
+    G4int                   fNofLVWithSD; //counter of logical volumes
+                                          //with sensitive detectors
+    //AliSDManagerMessenger*  fMessenger;
+};             
+
+// inline methods
+
+inline G4int AliSDManager::GetNofLVWithSD() const
+{ return fNofLVWithSD; }
+
+inline void AliSDManager::SetNofLVWithSD(G4int nofLV)
+{ fNofLVWithSD = nofLV; }
+
+#endif //ALI_SD_MANAGER_H
diff --git a/AliGeant4/AliSensitiveDetector.cxx b/AliGeant4/AliSensitiveDetector.cxx
new file mode 100644 (file)
index 0000000..2e56cf4
--- /dev/null
@@ -0,0 +1,107 @@
+// $Id$ //
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliSensitiveDetector.h"
+#include "AliModule.h" 
+#include "AliRun.h"
+
+#include "TG4StepManager.h"
+
+AliSensitiveDetector::AliSensitiveDetector(G4String sdName, AliModule* module)
+  : TG4VSensitiveDetector(sdName),
+    fModule(module),
+    fStepManager(TG4StepManager::Instance())
+{
+//
+}
+
+AliSensitiveDetector::AliSensitiveDetector(G4String sdName, AliModule* module, 
+                                           G4int id)
+  : TG4VSensitiveDetector(sdName, id),
+    fModule(module),
+    fStepManager(TG4StepManager::Instance())
+{
+//
+}
+
+AliSensitiveDetector::AliSensitiveDetector(const AliSensitiveDetector& right)
+  : TG4VSensitiveDetector(right)
+{
+//
+  fModule = right.fModule;
+  fStepManager = right.fStepManager;
+}  
+  
+AliSensitiveDetector::AliSensitiveDetector(){
+//
+}
+
+AliSensitiveDetector::~AliSensitiveDetector() {
+//
+}
+
+// operators
+
+AliSensitiveDetector& 
+AliSensitiveDetector::operator=(const AliSensitiveDetector& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  // base class assignement
+  TG4VSensitiveDetector::operator=(right);
+
+  fModule = right.fModule;
+  fStepManager = right.fStepManager;
+
+  return *this;  
+}    
+          
+// public methods
+
+void AliSensitiveDetector::Initialize(G4HCofThisEvent* hc)
+{
+// This method is called at the beginning of event action
+// before user defined BeginOfEventAction() method.
+}
+
+G4bool AliSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*)
+{
+// Calls StepManager of associated AliModules.
+// ---
+
+  // add energy deposit of the current step
+  // directly to AliRun
+  G4int copy;
+  gAlice->AddEnergyDeposit(fID, step->GetTotalEnergyDeposit());
+
+  // parent ID -> shunt
+  G4int parentID
+    = step->GetTrack()->GetParentID();
+  Int_t shunt = 0;
+  if (parentID==0) shunt = 1;
+  fModule->SetIshunt(shunt);
+
+  // let AliModule process step
+  fStepManager->SetStep(step);
+  fModule->StepManager();
+
+  return true;
+}
+
+void AliSensitiveDetector::EndOfEvent(G4HCofThisEvent* hce){
+//
+}
+
+//void AliSensitiveDetector::clear()
+//{} 
+
+void AliSensitiveDetector::PrintAll() {
+//
+} 
+
+void AliSensitiveDetector::DrawAll() {
+//
+} 
diff --git a/AliGeant4/AliSensitiveDetector.h b/AliGeant4/AliSensitiveDetector.h
new file mode 100644 (file)
index 0000000..e06fda8
--- /dev/null
@@ -0,0 +1,53 @@
+// $Id$
+// Category: geometry
+//
+// Sensitive detector class,
+// that implements G4VSensitiveDetector::ProcessHits()
+// with AliDetector:: StepManager().
+
+#ifndef ALI_SENSITIVE_DETECTOR_H
+#define ALI_SENSITIVE_DETECTOR_H
+
+#include "TG4VSensitiveDetector.h"
+
+#include <globals.hh>
+
+class AliModule;
+class TG4StepManager;
+
+class G4HCofThisEvent;
+class G4Step;
+
+class AliSensitiveDetector : public TG4VSensitiveDetector
+{
+  public:
+    AliSensitiveDetector(G4String sdName, AliModule* module);
+    AliSensitiveDetector(G4String sdName, AliModule* module, G4int id);
+    AliSensitiveDetector(const AliSensitiveDetector& right);
+    // --> protected
+    // AliSensitiveDetector();
+    virtual ~AliSensitiveDetector();
+
+    // operators
+    AliSensitiveDetector& operator=(const AliSensitiveDetector& right);
+  
+    // methods
+    virtual void Initialize(G4HCofThisEvent* hc);
+    virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history);
+    virtual void EndOfEvent(G4HCofThisEvent* hce);
+    //virtual void clear();
+    virtual void PrintAll();
+    virtual void DrawAll();
+    
+  protected:  
+    AliSensitiveDetector();
+    
+  private:
+    // data members
+    AliModule*       fModule;      //AliModule
+    TG4StepManager*  fStepManager; //TG4StepManager
+};
+
+#endif //ALI_SENSITIVE_DETECTOR_H
+
+
diff --git a/AliGeant4/AliSingleModuleConstruction.cxx b/AliGeant4/AliSingleModuleConstruction.cxx
new file mode 100644 (file)
index 0000000..3e2a4f0
--- /dev/null
@@ -0,0 +1,297 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliSingleModuleConstruction.h"
+#include "AliSingleModuleConstructionMessenger.h"
+#include "AliSDManager.h"
+#include "AliSensitiveDetector.h"
+#include "AliGlobals.h"
+#include "AliFiles.h"
+#include "AliRun.h"
+
+#include "TG4GeometryManager.h"
+
+#include <G3SensVolVector.hh>
+#include <G4SDManager.hh>
+#include <G4UImanager.hh>
+//#include <G4Element.hh>
+#include <G4LogicalVolume.hh>
+#include <G4LogicalVolumeStore.hh>
+
+#include <TROOT.h> 
+#include <TCint.h> 
+
+G4VPhysicalVolume* AliSingleModuleConstruction::fgWorld = 0;
+
+AliSingleModuleConstruction::AliSingleModuleConstruction(
+                                G4String moduleName, G4int version,
+                               AliModuleType moduleType)
+  : AliModuleConstruction(moduleName),
+    fVersion(version),
+    fType(moduleType),
+    fProcessConfig(true),
+    fAllLVSensitive(false)
+{
+//
+  fSDManager = AliSDManager::Instance();
+
+  moduleName.toLower();
+  fMessenger = new AliSingleModuleConstructionMessenger(this, moduleName);
+}
+
+AliSingleModuleConstruction::AliSingleModuleConstruction(
+                                const AliSingleModuleConstruction& right)
+  : AliModuleConstruction(right)                               
+{
+//
+  fVersion = right.fVersion;
+  fType = right.fType;
+  fProcessConfig = right.fProcessConfig;
+  fAllLVSensitive = right.fAllLVSensitive;
+  fSDManager = right.fSDManager;
+
+  G4String moduleName = right.fModuleName;
+  moduleName.toLower();
+  fMessenger = new AliSingleModuleConstructionMessenger(this, moduleName);
+}
+
+AliSingleModuleConstruction::AliSingleModuleConstruction() {
+//
+}
+
+AliSingleModuleConstruction::~AliSingleModuleConstruction() {
+//
+  delete fMessenger;
+}
+
+// operators
+
+AliSingleModuleConstruction& 
+AliSingleModuleConstruction::operator=(const AliSingleModuleConstruction& right)
+{    
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  // base class assignement
+  AliModuleConstruction::operator=(right);
+  
+  fVersion = right.fVersion;
+  fType = right.fType;
+  fProcessConfig = right.fProcessConfig;
+  fAllLVSensitive = right.fAllLVSensitive;
+  fSDManager = right.fSDManager;
+  
+  return *this;
+}
+
+// private methods
+
+void AliSingleModuleConstruction::CreateSensitiveDetectors()
+{
+// Creates sensitive detectors.
+// ---
+
+  if (fAllLVSensitive)
+    CreateSensitiveDetectors1();
+  else
+    CreateSensitiveDetectors2();
+
+  // set static number of logical volumes already processed
+  G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
+  fSDManager->SetNofLVWithSD(pLVStore->entries());  
+}   
+
+void AliSingleModuleConstruction::CreateSensitiveDetectors1()
+{ 
+// Creates sensitive detectors.
+// Sensitive detectors are set to all logical volumes
+// ---
+
+  G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
+  G4int nofLV = pLVStore->entries();
+  
+  G4int nofLVWithSD = fSDManager->GetNofLVWithSD();
+  
+  for (G4int i=nofLVWithSD; i<nofLV; i++) {
+    G4LogicalVolume* lv = (*pLVStore)[i];
+    fSDManager->CreateSD(lv, fAliModule);
+  }
+}
+
+void AliSingleModuleConstruction::CreateSensitiveDetectors2()
+{ 
+// Creates sensitive detectors.
+// Sensitive detectors are set only to logical volumes
+// in G3SensVolVector.
+// ---
+
+  TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
+
+  G3SensVolVector pSVVector
+    = pGeometryManager->GetG3SensVolVector();
+
+  G4int nofSV = pSVVector.entries();
+  if (nofSV>0)
+    for (G4int isv=0; isv<nofSV; isv++) {
+      G4LogicalVolume* lv = pSVVector[isv];
+      fSDManager->CreateSD(lv, fAliModule);
+    } 
+}
+
+// public methods 
+
+void AliSingleModuleConstruction::Configure()
+{ 
+// Executes the detector setup Root macro
+// (extracted from AliRoot Config.C) and
+// G4 macro.
+// ---
+         
+  // filepaths and macro names 
+  G4String rootFilePath;
+  G4String g4FilePath;
+
+  if (fType == kDetector) {
+    // macro file path 
+    //$AG4_INSTALL/macro/XXX/Config.C
+    //$AG4_INSTALL/macro/XXX/Config.in
+    rootFilePath = AliFiles::DetConfig1();
+    rootFilePath.append(fModuleName);
+    rootFilePath.append(AliFiles::DetConfig2());
+    g4FilePath = rootFilePath;
+
+    rootFilePath.append(AliFiles::DetConfig3());
+    g4FilePath.append(AliFiles::DetConfig4());
+
+    // path to g3calls.dat file
+    //$AG4_INSTALL/macro/XXX/g3calls_vN.dat
+    fDataFilePath = AliFiles::DetData1();
+    fDataFilePath.append(fModuleName);
+    fDataFilePath.append(AliFiles::DetData2());
+    G4String version("v");
+    AliGlobals::AppendNumberToString(version,fVersion);
+    fDataFilePath.append(version);
+    fDataFilePath.append(AliFiles::DetData3());          
+  }  
+  else if (fType == kStructure) {    
+    // macro file path is set to 
+    //$AG4_INSTALL/macro/STRUCT/XXXConfig.C
+    //$AG4_INSTALL/macro/STRUCT/XXXConfig.in
+    rootFilePath = AliFiles::DetConfig1();
+    rootFilePath.append(AliFiles::STRUCT());
+    rootFilePath.append(AliFiles::DetConfig2());
+    rootFilePath.append(fModuleName);
+    g4FilePath = rootFilePath;
+
+    rootFilePath.append(AliFiles::DetConfig3());
+    g4FilePath.append(AliFiles::DetConfig4());
+
+    // path to g3calls.dat file
+    //$AG4_INSTALL/macro/STRUCT/g3calls_XXXvN.dat
+    fDataFilePath = AliFiles::DetData1();
+    fDataFilePath.append(AliFiles::STRUCT());
+    fDataFilePath.append(AliFiles::DetData2());
+    fDataFilePath.append(fModuleName);
+    G4String version("v");
+    AliGlobals::AppendNumberToString(version,fVersion);
+    fDataFilePath.append(version);
+    fDataFilePath.append(AliFiles::DetData3());
+  }  
+  
+  if (fProcessConfig) {
+    // load and execute aliroot macro
+    gROOT->LoadMacro(rootFilePath);
+    G4String macroName = AliFiles::DetConfigName1();
+    AliGlobals::AppendNumberToString(macroName, fVersion);
+    macroName.append(AliFiles::DetConfigName2());
+    gInterpreter->ProcessLine(macroName);
+  } 
+  
+  // add process g4 config macro
+  // execute Geant4 macro if file is specified as an argument 
+  G4String command = "/control/execute ";
+  G4UImanager* pUI = G4UImanager::GetUIpointer();  
+  pUI->ApplyCommand(command + g4FilePath);
+  
+  // get AliModule created in Config.C macro
+  fAliModule = gAlice->GetModule(fModuleName);
+  if (!fAliModule) {
+    G4String text = "AliSingleModuleConstruction::Configure:\n";
+    text = text + "    AliModule " + fModuleName;
+    text = text + " has not been found in gAlice.";
+    AliGlobals::Exception(text);
+  }  
+}
+
+void AliSingleModuleConstruction::Construct()
+{ 
+// Constructs geometry.
+// ---
+
+  // print default element table
+  // const G4ElementTable* table = G4Element::GetElementTable();
+  // G4cout << "Default elemnt table: " << endl;
+  // for (G4int i=0; i<table->entries(); i++) {
+  //   G4cout << *(*table)[i] << endl;
+  // }  
+
+  Configure();
+
+  // get geometry manager
+  TG4GeometryManager* pGeometryManager = TG4GeometryManager::Instance();
+
+  // register module name in the name map
+  pGeometryManager->SetMapSecond(fAliModule->GetName());       
+
+  if (fReadGeometry) {
+    // create G3 geometry from g3calls.dat
+    pGeometryManager->SetWriteGeometry(false);
+    pGeometryManager->ReadG3Geometry(fDataFilePath);
+  }
+  else {
+    // set geometry output stream for this module
+    pGeometryManager->SetWriteGeometry(fWriteGeometry);
+    if (fWriteGeometry) 
+      pGeometryManager->OpenOutFile(fDataFilePath);
+
+    // create geometry from AliRoot
+
+    // construct materials
+    fAliModule->CreateMaterials();
+
+    // construct G3 geometry
+    fAliModule->CreateGeometry();
+  }  
+  
+  // construct G4 geometry
+  G4VPhysicalVolume* world = pGeometryManager->CreateG4Geometry();
+  if (!fgWorld) fgWorld = world; 
+  
+  // set the detector frame (envelope)
+  // (without warning output if enevelope is not defined)
+  SetDetFrame(false);
+
+  // create sensitive detectors
+  CreateSensitiveDetectors();
+
+  // build sensitive detectors table
+  fAliModule->Init();
+
+  // reset TG4GeometryManager 
+  pGeometryManager->ClearG3Tables();
+  
+  // print current total number of logical volumes
+  G4cout << "Current total number of sensitive volumes: "
+         << pGeometryManager->NofVolumes() << endl;
+
+#ifdef ALICE_VISUALIZE
+  if (GetDetFrame()) {
+    // set visualization attributes
+    // if detector envelope is defined
+    SetDetVisibility(true);
+    SetDetColour("Yellow");
+  }  
+#endif
+}
diff --git a/AliGeant4/AliSingleModuleConstruction.h b/AliGeant4/AliSingleModuleConstruction.h
new file mode 100644 (file)
index 0000000..e035d71
--- /dev/null
@@ -0,0 +1,108 @@
+// $Id$
+// Category: geometry
+//
+// Class for geometry construction of a standalone
+// module (AliModule). 
+
+#ifndef ALI_SINGLE_MODULE_CONSTRUCTION_H
+#define ALI_SINGLE_MODULE_CONSTRUCTION_H
+
+#include "AliModuleConstruction.h"
+#include "AliModuleType.h"
+
+#include <globals.hh>
+
+class AliSingleModuleConstructionMessenger;
+class AliSDManager;
+
+class G4VPhysicalVolume;
+class G4LogicalVolume;
+
+class AliSingleModuleConstruction : public AliModuleConstruction
+{  
+  public:
+    AliSingleModuleConstruction(G4String moduleName, G4int version,
+                                AliModuleType moduleType = kDetector);
+    AliSingleModuleConstruction(const AliSingleModuleConstruction& right);
+    // --> protected
+    // AliSingleModuleConstruction();
+    virtual ~AliSingleModuleConstruction();
+    
+    // operators
+    AliSingleModuleConstruction& operator=(
+                                const AliSingleModuleConstruction &right);
+
+    // static set/get methods 
+    static void SetWorld(G4VPhysicalVolume* world);
+    static G4VPhysicalVolume* GetWorld();
+
+    // methods
+    void Configure();    
+    virtual void Construct();
+
+    // set methods
+    void SetProcessConfig(G4bool processConfig);
+    void SetAllLVSensitive(G4bool allLVSensitive);
+    void SetModuleFrameName(G4String moduleFrameName);
+    void SetModuleType(AliModuleType type);
+
+    // get methods
+    G4int  GetVersion() const;
+    AliModuleType GetType() const;
+    G4bool GetAllLVSensitive() const;
+    G4bool GetProcessConfig() const;
+    
+  protected:
+    AliSingleModuleConstruction();
+
+  private:
+    // methods
+    void CreateSensitiveDetectors();
+    void CreateSensitiveDetectors1();
+    void CreateSensitiveDetectors2();
+    
+    // static data members
+    static G4VPhysicalVolume* fgWorld;       //top (world) physical volume
+
+    // data members
+    AliSDManager*   fSDManager;      //AliSDManager
+    G4int           fVersion;        //module version
+    AliModuleType   fType;           //module type (detector/structure)
+    G4bool          fAllLVSensitive; //control for setting sensitive detectors
+    G4bool          fProcessConfig;  //control for processing Config.C
+    AliSingleModuleConstructionMessenger*  fMessenger; //messenger
+};             
+
+// inline methods
+
+inline G4VPhysicalVolume* AliSingleModuleConstruction::GetWorld()
+{ return fgWorld; }
+
+inline void AliSingleModuleConstruction::SetWorld(G4VPhysicalVolume* world)
+{ fgWorld = world; }
+
+inline void AliSingleModuleConstruction::SetProcessConfig(G4bool processConfig)
+{ fProcessConfig = processConfig; }
+
+inline void AliSingleModuleConstruction::SetAllLVSensitive(G4bool allLVSensitive)
+{ fAllLVSensitive = allLVSensitive; }
+
+inline void AliSingleModuleConstruction::SetModuleFrameName(G4String name)
+{ fModuleFrameName = name; }
+
+inline void AliSingleModuleConstruction::SetModuleType(AliModuleType type)
+{ fType = type; }
+
+inline G4int AliSingleModuleConstruction::GetVersion() const
+{ return fVersion; }
+
+inline AliModuleType AliSingleModuleConstruction::GetType() const
+{ return fType; }
+
+inline G4bool AliSingleModuleConstruction::GetAllLVSensitive() const
+{ return fAllLVSensitive; }
+
+inline G4bool AliSingleModuleConstruction::GetProcessConfig() const
+{ return fProcessConfig; }
+
+#endif //ALI_SINGLE_MODULE_CONSTRUCTION_H
diff --git a/AliGeant4/AliSingleModuleConstructionMessenger.cxx b/AliGeant4/AliSingleModuleConstructionMessenger.cxx
new file mode 100644 (file)
index 0000000..2909c79
--- /dev/null
@@ -0,0 +1,78 @@
+// $Id$
+// Category: geometry
+//
+// See the class description in the header file.
+
+#include "AliSingleModuleConstructionMessenger.h"
+#include "AliSingleModuleConstruction.h"
+#include "AliGlobals.h"
+
+#include <G4UIcmdWithABool.hh>
+
+AliSingleModuleConstructionMessenger::AliSingleModuleConstructionMessenger(
+   AliSingleModuleConstruction* moduleConstruction, G4String moduleName)
+ : fModuleConstruction(moduleConstruction)
+{
+//
+  G4String dirName = "/aliDet/"; 
+  dirName = dirName + moduleName + "/"; 
+
+  G4String commandPath = dirName + "setAllSensitive";
+  fSetAllSensitiveCmd = new G4UIcmdWithABool(commandPath, this);
+  G4String guidance =   "If true: set all " + moduleName;
+  guidance = guidance + "logical volumes sensitive.\n";
+  guidance = guidance + "      (Each logical is volume associated with ";
+  guidance = guidance + "a sensitive detector.)";    
+  guidance = guidance + "If false: only volumes defined with a sensitive ";
+  guidance = guidance + "tracking medium\n";
+  guidance = guidance + "are associated with a sensitive detector.";
+  fSetAllSensitiveCmd->SetGuidance(guidance);
+  fSetAllSensitiveCmd->SetParameterName("detSensitivity", false);
+  fSetAllSensitiveCmd->AvailableForStates(PreInit, Init);  
+}
+
+AliSingleModuleConstructionMessenger::AliSingleModuleConstructionMessenger() {
+//
+}
+
+AliSingleModuleConstructionMessenger::AliSingleModuleConstructionMessenger(
+                            const AliSingleModuleConstructionMessenger& right) {
+//
+  AliGlobals::Exception(
+    "AliSingleModuleConstructionMessenger is protected from copying.");
+}
+
+AliSingleModuleConstructionMessenger::~AliSingleModuleConstructionMessenger() {
+//
+  delete fSetAllSensitiveCmd;  
+}
+
+// operators
+
+AliSingleModuleConstructionMessenger& 
+AliSingleModuleConstructionMessenger::operator=(
+                            const AliSingleModuleConstructionMessenger& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception(
+     "AliSingleModuleConstructionMessenger is protected from assigning.");
+    
+  return *this;  
+}    
+          
+// public methods
+  
+void AliSingleModuleConstructionMessenger::SetNewValue(G4UIcommand* command,
+                                                 G4String newValues)
+{
+// Applies command to the associated object.
+// ---
+
+  if (command == fSetAllSensitiveCmd) {
+    fModuleConstruction
+      ->SetAllLVSensitive(fSetAllSensitiveCmd->GetNewBoolValue(newValues)); 
+  } 
+}
+
diff --git a/AliGeant4/AliSingleModuleConstructionMessenger.h b/AliGeant4/AliSingleModuleConstructionMessenger.h
new file mode 100644 (file)
index 0000000..0e1df17
--- /dev/null
@@ -0,0 +1,48 @@
+// $Id$
+// Category: geometry
+//
+// Messenger class that defines command directory for the
+// AliSingleModuleConstruction instances.
+
+#ifndef ALI_SINGLE_MODULE_CONSTRUCTION_MESSENGER_H
+#define ALI_SINGLE_MODULE_CONSTRUCTION_MESSENGER_H
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliSingleModuleConstruction;
+
+class G4UIcmdWithABool;
+
+class AliSingleModuleConstructionMessenger: public G4UImessenger
+{
+  public:
+    AliSingleModuleConstructionMessenger(
+       AliSingleModuleConstruction* moduleConstruction, G4String moduleName);
+    // --> protected
+    // AliSingleModuleConstructionMessenger();
+    // AliSingleModuleConstructionMessenger(
+    //                 const AliSingleModuleConstructionMessenger& right); 
+    virtual ~AliSingleModuleConstructionMessenger();
+
+    // methods
+    virtual void SetNewValue(G4UIcommand* command, G4String newValues);
+
+  protected:
+    AliSingleModuleConstructionMessenger();
+    AliSingleModuleConstructionMessenger(
+                       const AliSingleModuleConstructionMessenger& right);
+
+    // operators
+    AliSingleModuleConstructionMessenger& operator=(
+                       const AliSingleModuleConstructionMessenger& right);
+  
+  private:
+    // data members
+    AliSingleModuleConstruction*  fModuleConstruction; //associated class
+
+    G4UIcmdWithABool*  fSetAllSensitiveCmd; //command: setAllSensitive   
+};
+
+#endif //ALI_MODULE_CONSTRUCTION_MESSENGER_H
+
diff --git a/AliGeant4/AliStackingAction.cxx b/AliGeant4/AliStackingAction.cxx
new file mode 100644 (file)
index 0000000..36518b5
--- /dev/null
@@ -0,0 +1,132 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliStackingAction.h"
+#include "AliStackingActionMessenger.h"
+#include "AliTrackingAction.h"
+#include "AliGlobals.h"
+
+#include <G4Track.hh>
+#include <G4StackedTrack.hh>
+#include <G4StackManager.hh>
+#include <G4ios.hh>
+
+AliStackingAction::AliStackingAction()
+  : fStage(0), 
+    fVerboseLevel(0),
+    fSavePrimaries(true),
+    fTrackingAction(0) 
+{
+// 
+  fPrimaryStack = new G4TrackStack();
+  fMessenger = new AliStackingActionMessenger(this);
+}
+
+AliStackingAction::AliStackingAction(const AliStackingAction& right) {
+//
+  AliGlobals::Exception("AliStackingAction is protected from copying.");
+}
+
+AliStackingAction::~AliStackingAction() {
+// 
+  delete fPrimaryStack;
+  delete fMessenger; 
+}
+
+// operators
+
+AliStackingAction& 
+AliStackingAction::operator=(const AliStackingAction &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliStackingAction is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+G4ClassificationOfNewTrack 
+AliStackingAction::ClassifyNewTrack(const G4Track* track)
+{
+// Classifies the new track.
+// ---
+
+  G4ClassificationOfNewTrack classification;
+  if (fStage == 0) { 
+    // move all primaries to PrimaryStack
+    G4Track* nonconstTrack = (G4Track*)track;
+    G4StackedTrack* newTrack = new G4StackedTrack(nonconstTrack);
+    fPrimaryStack->PushToStack(newTrack);  
+    classification = fPostpone;
+
+    // save primary particle info
+    // (secondary particles are stored 
+    //  by AlTrackingAction::PreUserTrackingAction() method)
+    if (fSavePrimaries)
+      fTrackingAction->SaveParticle(track, "primary");
+  }  
+  else {
+     G4int parentID = track->GetParentID();
+     if (parentID ==0) { 
+       classification = fUrgent; 
+     }
+     else { 
+       classification = fWaiting; 
+     }
+  }
+  return classification;
+}
+
+void AliStackingAction::NewStage()
+{
+// Called by G4 kernel at the new stage of stacking.
+// ---
+
+  fStage++;
+  if (fVerboseLevel>0) 
+  {
+    G4cout << "AliStackingAction::NewStage " << fStage 
+           << " has been started." << endl;
+  }
+
+  G4int nofUrgent = stackManager->GetNUrgentTrack();
+  if (nofUrgent == 0)
+  {
+    G4int nofPrimary = fPrimaryStack->GetNTrack();
+    if (nofPrimary>0)
+    { 
+       G4StackedTrack* stackedTrack
+         = fPrimaryStack->PopFromStack();
+       G4Track* primaryTrack
+         = stackedTrack->GetTrack();
+       delete stackedTrack;
+       stackManager->PushOneTrack(primaryTrack);
+     }
+  }
+}
+    
+void AliStackingAction::ClearPrimaryStack()
+{
+// Clears the primary stack.
+// ---
+
+  stackManager->ClearPostponeStack();
+}
+
+void AliStackingAction::PrepareNewEvent()
+{
+// Called by G4 kernel at the beginning of event.
+// ---
+
+  fStage = 0;
+  ClearPrimaryStack();
+  fTrackingAction = AliTrackingAction::Instance();
+  fSavePrimaries = fTrackingAction->GetSavePrimaries();
+}
+
+
diff --git a/AliGeant4/AliStackingAction.h b/AliGeant4/AliStackingAction.h
new file mode 100644 (file)
index 0000000..73040dc
--- /dev/null
@@ -0,0 +1,64 @@
+// $Id$
+// Category: event
+//
+// Class that defines Alice stacking mechanism.
+
+#ifndef ALI_STACKING_ACTION_H
+#define ALI_STACKING_ACTION_H
+
+#include <G4UserStackingAction.hh>
+#include <G4TrackStack.hh>
+
+#include <globals.hh>
+
+class AliStackingActionMessenger;
+class AliTrackingAction;
+class G4Track;
+
+class AliStackingAction : public G4UserStackingAction
+{
+  public:
+    AliStackingAction();
+    // --> protected
+    // AliStackingAction(const AliStackingAction& right);
+    virtual ~AliStackingAction();
+
+    // methods
+    G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* track);
+    void NewStage();
+    void ClearPrimaryStack();
+    void PrepareNewEvent();
+
+    // set methods
+    void SetVerboseLevel(G4int level);
+
+    // get methods
+    G4int GetVerboseLevel() const;
+
+  protected:
+    AliStackingAction(const AliStackingAction& right);
+
+    // operators
+    AliStackingAction& operator=(const AliStackingAction& right);
+
+  private:
+    // data members
+    G4int                        fStage;          //stage number
+    G4int                        fVerboseLevel;   //verbose level
+    G4bool                       fSavePrimaries;  //control of saving primaries
+    G4TrackStack*                fPrimaryStack;   //stack of primary tracks
+    AliTrackingAction*           fTrackingAction; //AliTrackingAction
+    AliStackingActionMessenger*  fMessenger;      //messenger
+};
+
+
+// inline methods
+
+inline void AliStackingAction::SetVerboseLevel(G4int level)
+{ fVerboseLevel = level; }
+
+inline G4int AliStackingAction::GetVerboseLevel() const
+{ return fVerboseLevel; }
+
+#endif //ALI_STACKING_ACTION_H
+
diff --git a/AliGeant4/AliStackingActionMessenger.cxx b/AliGeant4/AliStackingActionMessenger.cxx
new file mode 100644 (file)
index 0000000..2a11f81
--- /dev/null
@@ -0,0 +1,80 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliStackingActionMessenger.h"
+#include "AliStackingAction.h"
+#include "AliGlobals.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithAnInteger.hh>
+#include <G4UIcmdWithoutParameter.hh>
+
+AliStackingActionMessenger::AliStackingActionMessenger(
+                              AliStackingAction* stackingAction)
+  :fStackingAction(stackingAction)
+{
+// 
+  fStackingDirectory = new G4UIdirectory("/aliStacking/");
+  fStackingDirectory->SetGuidance("AliStackingAction control commands.");
+
+  fClearStackCmd = new G4UIcmdWithoutParameter("/aliStacking/clearStack", this);
+  fClearStackCmd->SetGuidance("Clears the primary stack.");
+  fClearStackCmd->AvailableForStates(EventProc);
+
+  fVerboseCmd = new G4UIcmdWithAnInteger("/aliStacking/verbose", this);
+  fVerboseCmd->SetGuidance("Set verbose level for AliStackingAction");
+  fVerboseCmd->SetParameterName("VerboseLevel", true);
+  fVerboseCmd->SetDefaultValue(0);
+  fVerboseCmd->SetRange("VerboseLevel >= 0 && VerboseLevel <= 1");
+  fVerboseCmd->AvailableForStates(Idle);
+}
+
+AliStackingActionMessenger::AliStackingActionMessenger() {
+//
+}
+
+AliStackingActionMessenger::AliStackingActionMessenger(
+                                 const AliStackingActionMessenger& right) {
+//                              
+  AliGlobals::Exception("AliStackingActionMessenger is protected from copying.");
+}
+
+AliStackingActionMessenger::~AliStackingActionMessenger() {
+//
+  delete fStackingDirectory;
+  delete fClearStackCmd;
+  delete fVerboseCmd;
+}
+
+// operators
+
+AliStackingActionMessenger& 
+AliStackingActionMessenger::operator=(const AliStackingActionMessenger &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception(
+    "AliStackingActionMessenger is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliStackingActionMessenger::SetNewValue(G4UIcommand* command, 
+       G4String newValue)
+{ 
+// Applies command to the associated object.
+// ---
+
+  if (command == fClearStackCmd) { 
+    fStackingAction->ClearPrimaryStack(); 
+  }
+  else if (command == fVerboseCmd) { 
+    fStackingAction
+      ->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue)); 
+  }  
+}
diff --git a/AliGeant4/AliStackingActionMessenger.h b/AliGeant4/AliStackingActionMessenger.h
new file mode 100644 (file)
index 0000000..85bdb11
--- /dev/null
@@ -0,0 +1,46 @@
+// $Id$
+// Category: event
+//
+// Messenger class that defines commands for AliStackingAction.
+
+#ifndef ALI_STACKING_ACTION_MESSENGER_H
+#define ALI_STACKING_ACTION_MESSENGER_H 
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliStackingAction;
+
+class G4UIdirectory;
+class G4UIcmdWithAnInteger;
+class G4UIcmdWithoutParameter;
+
+class AliStackingActionMessenger: public G4UImessenger
+{
+  public:
+    AliStackingActionMessenger(AliStackingAction* trackingAction);
+    // --> protected
+    // AliStackingActionMessenger();
+    // AliStackingActionMessenger(const AliStackingActionMessenger& right);
+    virtual ~AliStackingActionMessenger();
+   
+    // methods 
+    virtual void SetNewValue(G4UIcommand* command, G4String string);
+    
+  protected:
+    AliStackingActionMessenger();
+    AliStackingActionMessenger(const AliStackingActionMessenger& right);
+
+    // operators
+    AliStackingActionMessenger& operator=(
+                            const AliStackingActionMessenger& right);
+
+  private:
+    // data members
+    AliStackingAction*        fStackingAction;    //associated class 
+    G4UIdirectory*            fStackingDirectory; //command directory
+    G4UIcmdWithoutParameter*  fClearStackCmd;     //command: clearStack
+    G4UIcmdWithAnInteger*     fVerboseCmd;        //command: verbose
+};
+
+#endif //ALI_STACKING_ACTION_MESSENGER_H
diff --git a/AliGeant4/AliSteppingAction.cxx b/AliGeant4/AliSteppingAction.cxx
new file mode 100644 (file)
index 0000000..6ae9927
--- /dev/null
@@ -0,0 +1,157 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliSteppingAction.h"
+#include "AliSteppingActionMessenger.h"
+#include "AliGlobals.h"
+
+#include <G4Track.hh>
+#include <G4SteppingManager.hh>
+
+const G4double AliSteppingAction::fgTolerance = 1e-6*mm;
+
+AliSteppingAction::AliSteppingAction()
+  : fKeptStepPoint(G4ThreeVector()),
+    fLoopVerboseLevel(1),
+    fStandardVerboseLevel(0),
+    fLoopStepCounter(0)
+{
+//
+  fMessenger = new AliSteppingActionMessenger(this);
+}
+
+AliSteppingAction::AliSteppingAction(const AliSteppingAction& right) {
+//
+  AliGlobals::Exception("AliSteppingAction is protected from copying.");
+}
+
+AliSteppingAction::~AliSteppingAction() {
+//
+  delete fMessenger;
+}
+
+// operators
+
+AliSteppingAction& 
+AliSteppingAction::operator=(const AliSteppingAction &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliSteppingAction is protected from assigning.");
+
+  return *this;
+}
+
+// private methods
+
+void AliSteppingAction::PrintTrackInfo(const G4Track* track) const
+{
+// Prints the track info
+// - taken from private G4TrackingManager::Verbose()
+// and the standard header for verbose tracking
+// - taken from G4SteppingVerbose::TrackingStarted().
+// ---
+
+  // print track info
+  G4cout << endl;
+  G4cout << "*******************************************************"
+         << "**************************************************"
+         << endl;
+  G4cout << "* G4Track Information: " 
+         << "  Particle = " << track->GetDefinition()->GetParticleName() 
+         << "," 
+        << "   Track ID = " << track->GetTrackID() 
+         << "," 
+        << "   Parent ID = " << track->GetParentID() 
+         << endl;
+  G4cout << "*******************************************************"
+         << "**************************************************"
+         << endl;
+  G4cout << endl;
+      
+  // print header    
+#ifdef G4_USE_G4BESTUNIT_FOR_VERBOSE
+    G4cout << setw( 5) << "Step#"  << " "
+           << setw( 8) << "X"      << "     "
+          << setw( 8) << "Y"      << "     "  
+          << setw( 8) << "Z"      << "     "
+          << setw( 9) << "KineE"  << "     "
+          << setw( 8) << "dE"     << "     "  
+          << setw(12) << "StepLeng"   << " "  
+          << setw(12) << "TrackLeng"  << " "
+          << setw(12) << "NextVolume" << " "
+          << setw( 8) << "ProcName"   << endl;      
+#else
+    G4cout << setw( 5) << "Step#"      << " "
+          << setw( 8) << "X(mm)"      << " "
+          << setw( 8) << "Y(mm)"      << " "  
+          << setw( 8) << "Z(mm)"      << " "
+          << setw( 9) << "KinE(MeV)"  << " "
+          << setw( 8) << "dE(MeV)"    << " "  
+          << setw( 8) << "StepLeng"   << " "  
+          << setw( 9) << "TrackLeng"  << " "
+          << setw(11) << "NextVolume" << " "
+          << setw( 8) << "ProcName"   << endl;      
+#endif
+}
+
+// public methods
+
+void AliSteppingAction::UserSteppingAction(const G4Step* step)
+{
+// After processing the given number of steps (kCheckNofSteps)
+// the particle position is compared with the previus one
+// - in case the distance is less than fgTolerance value
+// the verbose mode is switched on, particle is let 
+// to process a small number of steps (kMaxNofLoopSteps)
+// and then stopped and killed.
+// ---
+
+  G4Track* track = step->GetTrack();  
+
+  // reset parameters at beginning of tracking
+  G4int stepNumber = track->GetCurrentStepNumber();
+  if (stepNumber == 0) {
+    fKeptStepPoint = G4ThreeVector();
+    fLoopStepCounter = 0;
+    fStandardVerboseLevel = fpSteppingManager->GetverboseLevel();
+    return;
+  }  
+    
+  if (fLoopStepCounter) {
+    // count steps after detecting looping track
+    fLoopStepCounter++;
+    if (fLoopStepCounter == kMaxNofLoopSteps) {
+
+      // stop the looping track
+      track->SetTrackStatus(fStopAndKill);      
+
+      // reset back parameters
+      fpSteppingManager->SetVerboseLevel(fStandardVerboseLevel);
+      fKeptStepPoint = G4ThreeVector();
+      fLoopStepCounter = 0;
+    }  
+  }  
+
+  if (stepNumber % kCheckNofSteps == 0) {  
+    // detect looping track
+    G4ThreeVector newStepPoint = step->GetPreStepPoint()->GetPosition();
+    G4double trajectory = (newStepPoint-fKeptStepPoint).mag();
+    if (trajectory < fgTolerance) {
+
+      // print looping info
+      if (fLoopVerboseLevel > 0) {
+        G4cout << "*** Particle is looping. ***" << endl;
+       if (fStandardVerboseLevel == 0) PrintTrackInfo(track);
+      }        
+      // set loop verbose level 
+      fpSteppingManager->SetVerboseLevel(fLoopVerboseLevel);
+      
+      fLoopStepCounter++;
+    }  
+    fKeptStepPoint = newStepPoint;
+  }  
+}
diff --git a/AliGeant4/AliSteppingAction.h b/AliGeant4/AliSteppingAction.h
new file mode 100644 (file)
index 0000000..90f40a5
--- /dev/null
@@ -0,0 +1,70 @@
+// $Id$
+// Category: event
+//
+// Class for detecting and stopping looping particles
+
+#ifndef ALI_STEPPING_ACTION_H
+#define ALI_STEPPING_ACTION_H
+
+#include <G4UserSteppingAction.hh>
+#include <G4ThreeVector.hh>
+#include <globals.hh>
+
+class AliSteppingActionMessenger;
+
+class G4Track;
+
+class AliSteppingAction : public G4UserSteppingAction
+{
+  enum { 
+    kCheckNofSteps = 100,
+    kMaxNofLoopSteps = 5
+  };
+
+  public:
+    AliSteppingAction();
+    // protected
+    // AliSteppingAction(const AliSteppingAction& right);
+    virtual ~AliSteppingAction();
+
+    // methods
+    virtual void UserSteppingAction(const G4Step* step);
+    
+    // set methods
+    void SetLoopVerboseLevel(G4int level);
+    
+    // get methods
+    G4int GetLoopVerboseLevel() const;
+
+  protected:
+    AliSteppingAction(const AliSteppingAction& right);
+
+    // operators
+    AliSteppingAction& operator=(const AliSteppingAction& right);
+
+  private:
+    // methods
+    void PrintTrackInfo(const G4Track* track) const;
+  
+    // static data members
+    static const G4double fgTolerance;
+
+    // data members
+    G4ThreeVector   fKeptStepPoint;        //kept step point
+    G4int           fLoopVerboseLevel;     //tracking verbose level
+                                           //for looping particles
+    G4int           fStandardVerboseLevel; //standard tracking verbose level
+    G4int           fLoopStepCounter;      //loop steps counter
+    AliSteppingActionMessenger*  fMessenger;  //messenger
+};
+
+// inline methods
+
+inline void AliSteppingAction::SetLoopVerboseLevel(G4int level)
+{ fLoopVerboseLevel = level; }
+
+inline G4int AliSteppingAction::GetLoopVerboseLevel() const
+{ return fLoopVerboseLevel; }
+
+#endif //ALI_STEPPING_ACTION_H
+
diff --git a/AliGeant4/AliSteppingActionMessenger.cxx b/AliGeant4/AliSteppingActionMessenger.cxx
new file mode 100644 (file)
index 0000000..70a3f54
--- /dev/null
@@ -0,0 +1,69 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliSteppingActionMessenger.h"
+#include "AliSteppingAction.h"
+#include "AliGlobals.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithAnInteger.hh>
+
+AliSteppingActionMessenger::AliSteppingActionMessenger(
+                              AliSteppingAction* trackingAction)
+  :fSteppingAction(trackingAction)
+{
+// 
+  fLoopVerboseCmd = new G4UIcmdWithAnInteger("/aliTracking/loopVerbose", this);
+  fLoopVerboseCmd
+    ->SetGuidance("Set tracking verbose level for detected looping tracks.");
+  fLoopVerboseCmd->SetParameterName("LoopVerboseLevel", true);
+  fLoopVerboseCmd->SetDefaultValue(1);
+  fLoopVerboseCmd->SetRange("LoopVerboseLevel >= 0 && LoopVerboseLevel <= 5");
+  fLoopVerboseCmd->AvailableForStates(Idle);
+}
+
+AliSteppingActionMessenger::AliSteppingActionMessenger() {
+//
+}
+
+AliSteppingActionMessenger::AliSteppingActionMessenger(
+                                 const AliSteppingActionMessenger& right) {
+//                              
+  AliGlobals::Exception(
+    "AliSteppingActionMessenger is protected from copying.");
+}
+
+AliSteppingActionMessenger::~AliSteppingActionMessenger() {
+//
+  delete fLoopVerboseCmd;
+}
+
+// operators
+
+AliSteppingActionMessenger& 
+AliSteppingActionMessenger::operator=(const AliSteppingActionMessenger &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception(
+    "AliSteppingActionMessenger is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliSteppingActionMessenger::SetNewValue(G4UIcommand* command, 
+       G4String newValue)
+{ 
+// Applies command to the associated object.
+// ---
+
+  if(command == fLoopVerboseCmd) { 
+    fSteppingAction
+      ->SetLoopVerboseLevel(fLoopVerboseCmd->GetNewIntValue(newValue)); 
+  }   
+}
diff --git a/AliGeant4/AliSteppingActionMessenger.h b/AliGeant4/AliSteppingActionMessenger.h
new file mode 100644 (file)
index 0000000..57b9b30
--- /dev/null
@@ -0,0 +1,43 @@
+// $Id$
+// Category: event
+//
+// Messenger class that defines commands for AliSteppingAction.
+
+#ifndef ALI_STEPPING_ACTION_MESSENGER_H
+#define ALI_STEPPING_ACTION_MESSENGER_H 
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliSteppingAction;
+
+class G4UIdirectory;
+class G4UIcmdWithAnInteger;
+
+class AliSteppingActionMessenger: public G4UImessenger
+{
+  public:
+    AliSteppingActionMessenger(AliSteppingAction* trackingAction);
+    // --> protected
+    // AliSteppingActionMessenger();
+    // AliSteppingActionMessenger(const AliSteppingActionMessenger& right);
+    virtual ~AliSteppingActionMessenger();
+   
+    // methods 
+    virtual void SetNewValue(G4UIcommand* command, G4String string);
+    
+  protected:
+    AliSteppingActionMessenger();
+    AliSteppingActionMessenger(const AliSteppingActionMessenger& right);
+
+    // operators
+    AliSteppingActionMessenger& operator=(
+                            const AliSteppingActionMessenger& right);
+
+  private:
+    // data members
+    AliSteppingAction*     fSteppingAction; //associated class  
+    G4UIcmdWithAnInteger*  fLoopVerboseCmd; //command: loopVerbose
+};
+
+#endif //ALI_STEPPING_ACTION_MESSENGER_H
diff --git a/AliGeant4/AliTrackingAction.cxx b/AliGeant4/AliTrackingAction.cxx
new file mode 100644 (file)
index 0000000..ab197e0
--- /dev/null
@@ -0,0 +1,274 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliTrackingAction.h"
+#include "AliTrackingActionMessenger.h"
+#include "AliRun.h"
+#include "AliGlobals.h"  
+#include "TG4StepManager.h"
+
+#include <G4TrackingManager.hh>
+#include <G4Track.hh>
+#include <G4Event.hh>
+#include <G4SDManager.hh>
+#include <G4VHitsCollection.hh>
+
+#include <TParticle.h>
+
+// static data members
+AliTrackingAction* AliTrackingAction::fgInstance = 0;
+
+// static methods
+AliTrackingAction* AliTrackingAction::Instance() {
+// 
+  return fgInstance; 
+}
+
+AliTrackingAction::AliTrackingAction()
+  : fParticles(0),
+    fPrimaryTrackID(0),
+    fVerboseLevel(2),
+    fSavePrimaries(true),
+    fPrimariesCounter(0),
+    fParticlesCounter(0),
+    fLastParticleIndex(-1)
+{
+//
+  if (fgInstance) { 
+    AliGlobals::Exception("AliTrackingAction constructed twice."); 
+  }
+
+  fMessenger = new AliTrackingActionMessenger(this);
+  fgInstance = this;
+}
+
+AliTrackingAction::AliTrackingAction(const AliTrackingAction& right) {
+//
+  AliGlobals::Exception("AliTrackingAction is protected from copying.");
+}
+
+AliTrackingAction::~AliTrackingAction() {
+//
+  delete fMessenger;
+}
+
+// operators
+
+AliTrackingAction& 
+AliTrackingAction::operator=(const AliTrackingAction &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliTrackingAction is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliTrackingAction::PrepareNewEvent()
+{
+// Called by G4 kernel at the beginning of event.
+// ---
+
+  // aliroot
+  if (!fParticles) fParticles = gAlice->Particles();
+
+  // set the particles and primaries counter to the
+  // number of tracks already stored in AliRun::fParticles
+  // (fParticles can already contain primary particles
+  //  saved by AliGenerator)
+  G4int nofTracks = gAlice->GetNtrack();
+  fPrimariesCounter = nofTracks;
+  fParticlesCounter = nofTracks;
+  fLastParticleIndex = nofTracks-1;
+
+  // set g4 stepping manager pointer
+  G4SteppingManager* pG4StepManager 
+    = fpTrackingManager->GetSteppingManager();
+  TG4StepManager* pStepManager = TG4StepManager::Instance();
+  pStepManager->SetSteppingManager(pG4StepManager);
+}
+
+void AliTrackingAction::PreUserTrackingAction(const G4Track* aTrack)
+{
+// Called by G4 kernel before starting tracking.
+// ---
+
+  // aliroot
+  // track index in the particles array
+  G4int trackID = aTrack->GetTrackID();
+  G4int parentID = aTrack->GetParentID();
+  Int_t trackIndex;
+  if (parentID==0) { 
+    trackIndex = trackID; 
+  } 
+  else { 
+    trackIndex = GetNofSavedTracks(); 
+  }
+
+  // in AliRoot (from V3.0) track numbering starts from 0
+  gAlice->SetCurrentTrack(--trackIndex);
+
+  if (parentID == 0) {  
+    // save primary track
+    SaveAndDestroyTrack();
+    fPrimaryTrackID = aTrack->GetTrackID();
+  }
+  else { 
+    // save secondary particles info 
+    // improve this later with retrieving the generation process
+    // (primary particles are stored 
+    //  by AlStackingAction in ClassifyNewTrack() method)
+    G4String origin = "secondary"; 
+    SaveParticle(aTrack, origin);
+  };
+}
+
+void AliTrackingAction::PostUserTrackingAction(const G4Track* aTrack)
+{
+// Called by G4 kernel after finishing tracking.
+// ---
+
+  G4String particleName 
+    = aTrack->GetDynamicParticle()->GetDefinition()->GetParticleName();
+  if (particleName == "opticalphoton") {
+    G4cout << "$$$ Track " <<  aTrack->GetTrackID()
+           << " is optical photon." << endl;
+  }                    
+}
+
+void AliTrackingAction::SaveAndDestroyTrack()
+{
+// Calls AliRun::PurifyKine and fills trees of hits
+// after finishing tracking of each primary track.
+// !! This method has to be also called from AlEventAction::EndOfEventAction() 
+// for storing the last primary track of the current event.
+// --- 
+
+  if (fPrimaryTrackID>0)
+  {
+     if (fVerboseLevel == 3) { 
+       G4cout << "$$$ Primary track " << fPrimaryTrackID << endl;
+     } 
+     else if ( fVerboseLevel == 2 &&  fPrimaryTrackID % 10 == 0 ) {
+         G4cout << "$$$ Primary track " << fPrimaryTrackID  << endl;
+     } 
+     else if ( fVerboseLevel == 1 &&  fPrimaryTrackID % 100 == 0 ) {
+         G4cout << "$$$ Primary track " << fPrimaryTrackID  << endl;
+     } 
+     
+     // aliroot
+     G4int lastSavedTrack 
+       = gAlice->PurifyKine(fLastParticleIndex, fParticlesCounter);
+     G4int nofPuredSavedTracks 
+       = gAlice->GetNtrack();
+     fLastParticleIndex = lastSavedTrack;
+     fParticlesCounter = nofPuredSavedTracks;
+
+     if(gAlice->TreeH()) gAlice->TreeH()->Fill();
+     gAlice->ResetHits();
+   }
+   else { 
+     fLastParticleIndex = fPrimariesCounter-1; 
+   }
+   fPrimaryTrackID = 0;
+}  
+
+void AliTrackingAction::SaveParticle(const G4Track* track, 
+                                     G4String processName)
+{
+// Converts G4track to TParticle and saves it in AliRun::fParticles
+// array.
+// ----
+
+  fParticlesCounter++;
+
+  // track history
+  G4int firstDaughter = -1; 
+  G4int lastDaughter = -1;      
+  G4int parentID = track->GetParentID();
+  G4int motherIndex1;
+  G4int motherIndex2 = -1;
+  if (parentID == 0) { 
+    motherIndex1 = -1; 
+    fPrimariesCounter++;    
+  }
+  else {
+    // set first/last child for already defined particles
+    motherIndex1 = GetParticleIndex(parentID);
+    // aliroot
+    TParticle* parent 
+      = dynamic_cast<TParticle*>(fParticles->UncheckedAt(motherIndex1));
+    if (parent) {  
+      if (parent->GetFirstDaughter()<0) 
+        parent->SetFirstDaughter(fParticlesCounter);
+      parent->SetLastDaughter(fParticlesCounter);
+    }
+    else {
+      AliGlobals::Exception(
+        "AliTrackingAction::SaveParticle: Unknown particle type");
+    }          
+  };
+     
+  // ?? status of particle 
+  // temporarily used for storing trackID from G4
+  G4int ks = track->GetTrackID();
+   
+  // particle type
+  // is this G3 ekvivalent ?? - check
+  G4int pdg = track->GetDefinition()->GetPDGEncoding();
+
+  // track kinematics
+  G4ThreeVector momentum = track->GetMomentum(); 
+  G4double px = momentum.x()/GeV;
+  G4double py = momentum.y()/GeV;
+  G4double pz = momentum.z()/GeV;
+  G4double e = track->GetTotalEnergy()/GeV;
+
+  G4ThreeVector position = track->GetPosition(); 
+  G4double vx = position.x()/cm;
+  G4double vy = position.y()/cm;
+  G4double vz = position.z()/cm;
+  // time of production - check if ekvivalent with G4
+  G4double t = track->GetGlobalTime();
+
+  G4ThreeVector polarization = track->GetPolarization(); 
+  G4double polX = polarization.x();
+  G4double polY = polarization.y();
+  G4double polZ = polarization.z();
+
+  // aliroot
+  TClonesArray& theCollectionRef = *fParticles;
+  G4int nofParticles = theCollectionRef.GetEntriesFast();
+  TParticle* particle 
+   = new(theCollectionRef[nofParticles]) 
+       TParticle(pdg, ks, motherIndex1, motherIndex1, 
+         firstDaughter, lastDaughter, px, py, pz, e, vx, vy, vz, t);
+  particle->SetPolarisation(polX, polY, polZ);
+  particle->SetBit(Keep_Bit, false); 
+}
+
+G4int AliTrackingAction::GetParticleIndex(G4int trackID)
+{
+// Converts the trackID into the index of the particle
+// in AliRun::fParticles array.
+// ---
+
+  if (trackID <= fPrimariesCounter) { 
+    return trackID-1; 
+  }
+  else
+    for (G4int i=fLastParticleIndex+1; i<fParticlesCounter; i++) {
+      // aliroot
+      TParticle* particle
+        = (TParticle*)fParticles->UncheckedAt(i);
+      if (trackID == particle->GetStatusCode()) return i;
+    }
+
+  AliGlobals::Exception("AliTrackingAction::GetParticleIndex() has failed.");
+  return 0;   
+}
diff --git a/AliGeant4/AliTrackingAction.h b/AliGeant4/AliTrackingAction.h
new file mode 100644 (file)
index 0000000..bf41d49
--- /dev/null
@@ -0,0 +1,90 @@
+// $Id$
+// Category: event
+//
+// Class that takes care of storing kinematics.
+
+#ifndef ALI_TRACKING_ACTION_H
+#define ALI_TRACKING_ACTION_H
+
+#include <G4UserTrackingAction.hh>
+#include <globals.hh>
+
+#include <TClonesArray.h>
+
+class AliTrackingActionMessenger;
+
+class G4Track;
+
+class AliTrackingAction : public G4UserTrackingAction 
+{
+  public:
+    AliTrackingAction();
+    // --> protected
+    // AliTrackingAction(const AliTrackingAction& right);
+    ~AliTrackingAction();
+   
+    // static get method
+    static AliTrackingAction* Instance();
+
+    // methods
+    void PrepareNewEvent();
+    virtual void PreUserTrackingAction(const G4Track* aTrack);
+    virtual void PostUserTrackingAction(const G4Track* aTrack);
+    void SaveParticle(const G4Track* track, G4String processName);
+    void SaveAndDestroyTrack();
+
+    // set methods
+    void SetVerboseLevel(G4int level);
+    void SetSavePrimaries(G4bool savePrimaries);
+
+    // get methods
+    G4int GetVerboseLevel() const;
+    G4bool GetSavePrimaries() const;
+    G4int GetNofPrimaryTracks() const;
+    G4int GetNofSavedTracks() const;
+
+  protected:
+    AliTrackingAction(const AliTrackingAction& right);
+
+    // operators
+    AliTrackingAction& operator=(const AliTrackingAction& right);
+
+  private:
+    // methods
+    G4int GetParticleIndex(G4int trackID);
+  
+    // static data members
+    static AliTrackingAction*    fgInstance; //this instance
+
+    // data members
+    TClonesArray*  fParticles;         //AliRun::fParticles
+    G4int          fPrimaryTrackID;    //primary track ID 
+    G4bool         fSavePrimaries;     //control of saving primaries
+    G4int          fVerboseLevel;      //verbose level
+    G4int          fPrimariesCounter;  //primary particles counter
+    G4int          fParticlesCounter;  //particles counter
+    G4int          fLastParticleIndex; //index of the last particle in fParticles
+    AliTrackingActionMessenger*  fMessenger; //messenger
+};
+
+// inline methods
+
+inline void AliTrackingAction::SetVerboseLevel(G4int level)
+{ fVerboseLevel = level; }
+
+inline void AliTrackingAction::SetSavePrimaries(G4bool savePrimaries)
+{ fSavePrimaries = savePrimaries; }
+
+inline G4int AliTrackingAction::GetVerboseLevel() const
+{ return fVerboseLevel; }
+
+inline G4bool AliTrackingAction::GetSavePrimaries() const
+{ return fSavePrimaries; }
+
+inline G4int AliTrackingAction::GetNofPrimaryTracks() const
+{ return fPrimariesCounter; }
+
+inline G4int AliTrackingAction::GetNofSavedTracks() const
+{ return fParticlesCounter; }
+
+#endif //ALI_TRACKING_ACTION_H
diff --git a/AliGeant4/AliTrackingActionMessenger.cxx b/AliGeant4/AliTrackingActionMessenger.cxx
new file mode 100644 (file)
index 0000000..4f61bef
--- /dev/null
@@ -0,0 +1,73 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "AliTrackingActionMessenger.h"
+#include "AliTrackingAction.h"
+#include "AliGlobals.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithAnInteger.hh>
+
+AliTrackingActionMessenger::AliTrackingActionMessenger(
+                              AliTrackingAction* trackingAction)
+  :fTrackingAction(trackingAction)
+{
+// 
+  fTrackingDirectory = new G4UIdirectory("/aliTracking/");
+  fTrackingDirectory->SetGuidance("AliTrackingAction control commands.");
+
+  fVerboseCmd = new G4UIcmdWithAnInteger("/aliTracking/verbose", this);
+  fVerboseCmd->SetGuidance("Set verbose level for AliTrackingAction");
+  fVerboseCmd->SetParameterName("VerboseLevel", true);
+  fVerboseCmd->SetDefaultValue(2);
+  fVerboseCmd->SetRange("VerboseLevel >= 0 && VerboseLevel <= 3");
+  fVerboseCmd->AvailableForStates(Idle);
+}
+
+AliTrackingActionMessenger::AliTrackingActionMessenger() {
+//
+}
+
+AliTrackingActionMessenger::AliTrackingActionMessenger(
+                                 const AliTrackingActionMessenger& right) {
+//                              
+  AliGlobals::Exception(
+    "AliTrackingActionMessenger is protected from copying.");
+}
+
+AliTrackingActionMessenger::~AliTrackingActionMessenger() {
+//
+  delete fTrackingDirectory;
+  delete fVerboseCmd;
+}
+
+// operators
+
+AliTrackingActionMessenger& 
+AliTrackingActionMessenger::operator=(const AliTrackingActionMessenger &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception(
+    "AliTrackingActionMessenger is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void AliTrackingActionMessenger::SetNewValue(G4UIcommand* command, 
+       G4String newValue)
+{ 
+// Applies command to the associated object.
+// ---
+
+  if(command == fVerboseCmd)
+  { 
+    fTrackingAction
+      ->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue)); 
+  };   
+}
diff --git a/AliGeant4/AliTrackingActionMessenger.h b/AliGeant4/AliTrackingActionMessenger.h
new file mode 100644 (file)
index 0000000..621451c
--- /dev/null
@@ -0,0 +1,44 @@
+// $Id$
+// Category: event
+//
+// Messenger class that defines commands for AliTrackingAction.
+
+#ifndef ALI_TRACKING_ACTION_MESSENGER_H
+#define ALI_TRACKING_ACTION_MESSENGER_H 
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliTrackingAction;
+
+class G4UIdirectory;
+class G4UIcmdWithAnInteger;
+
+class AliTrackingActionMessenger: public G4UImessenger
+{
+  public:
+    AliTrackingActionMessenger(AliTrackingAction* trackingAction);
+    // --> protected
+    // AliTrackingActionMessenger();
+    // AliTrackingActionMessenger(const AliTrackingActionMessenger& right);
+    virtual ~AliTrackingActionMessenger();
+   
+    // methods 
+    virtual void SetNewValue(G4UIcommand* command, G4String string);
+    
+  protected:
+    AliTrackingActionMessenger();
+    AliTrackingActionMessenger(const AliTrackingActionMessenger& right);
+
+    // operators
+    AliTrackingActionMessenger& operator=(
+                            const AliTrackingActionMessenger& right);
+
+  private:
+    // data members
+    AliTrackingAction*     fTrackingAction;    //associated class 
+    G4UIdirectory*         fTrackingDirectory; //command directory
+    G4UIcmdWithAnInteger*  fVerboseCmd;        //command: verbose
+};
+
+#endif //ALI_TRACKING_ACTION_MESSENGER_H
diff --git a/AliGeant4/Makefile b/AliGeant4/Makefile
new file mode 100644 (file)
index 0000000..4772146
--- /dev/null
@@ -0,0 +1,96 @@
+# $Id$
+
+############################### AliGeant4 Makefile #############################
+
+# Include Geant4 specific definitions
+
+include $(G4INSTALL)/config/architecture.gmk
+
+# Include machine specific definitions
+
+include $(ALICE_ROOT)/conf/GeneralDef
+include $(ALICE_ROOT)/conf/MachineDef.$(ALICE_TARGET)
+
+# Include Alice Geant4 specific definitions
+
+NEED_G4_LIBS := 1
+include $(ALICE_ROOT)/conf/Geant4.gmk
+
+PACKAGE = AliGeant4
+TARGET  = aligeant4
+
+# C++ sources
+
+SRCS           = $(wildcard *.cxx)
+
+# C++ Headers
+
+HDRS          =  $(wildcard *.icc) $(wildcard *.h)
+
+# Library dictionary
+# only for selected classes
+
+DICT          = AliGeant4Cint.cxx
+DICTH         = AliRunConfiguration.h AliGeant4LinkDef.h
+DICTO         = $(patsubst %.cxx,tgt_$(ALICE_TARGET)/%.o,$(DICT))
+
+# C++ Objects
+
+OBJS          = $(patsubst %.cxx,tgt_$(ALICE_TARGET)/%.o,$(SRCS)) $(DICTO)
+
+# Program C++ source, objects
+
+PSRC          = $(TARGET).cxx
+POBJ          = $(patsubst %.cxx,tgt_$(ALICE_TARGET)/%.o,$(PSRC))
+
+# C++ compilation flags
+
+CXXFLAGS      = $(CXXOPTS) -I$(ROOTSYS)/include -I. -I$(ALICE_ROOT)/include/ \
+               -I$(ALICE_ROOT)/TGeant4/
+
+##### TARGETS #####
+# Target
+
+SLIBRARY       = $(LIBDIR)/libAliGeant4.$(SL)
+ALIBRARY       = $(LIBDIR)/lib/libAliGeant4.a
+PROGRAM                = $(BINDIR)/$(TARGET)
+
+default:       $(SLIBRARY) $(PROGRAM)
+
+$(LIBDIR)/libAliGeant4.$(SL):          $(OBJS)
+
+$(BINDIR)/$(TARGET):                   $(POBJ)
+
+$(DICT):                               $(DICTH)
+
+depend:                                        $(SRCS)
+
+#HEADERS =     $(filter-out %LinkDef.h,$(HDRS))
+
+# filter-out Geant3 dependent libraries (ZDC requires symbols from G3)
+# and add Geant4 dependent ones
+ALILIBS := $(filter-out -lTGeant3,$(ALILIBS))
+ALILIBS := $(filter-out -lZDC,$(ALILIBS))
+ALILIBS += -lTGeant4 -lAliGeant4
+
+LIBS = $(ALILIBS) $(G4LDLIBS) $(CLIBS) $(GLIBS) -lEG -lEGPythia -lpythia -lpdf
+
+TOCLEAN              = $(OBJS) *Cint.cxx *Cint.h
+
+CHECKS        = $(patsubst %.cxx,check/%.viol,$(SRCS))
+
+############################### General Macros ################################
+
+include $(ALICE_ROOT)/conf/GeneralMacros
+
+
+# Geant4 specific compiler flags
+
+CXXFLAGS += $(CPPFLAGS)
+
+
+############################ Dependencies #####################################
+
+-include tgt_$(ALICE_TARGET)/Make-depend 
diff --git a/AliGeant4/aligeant4.cxx b/AliGeant4/aligeant4.cxx
new file mode 100644 (file)
index 0000000..3a49d48
--- /dev/null
@@ -0,0 +1,65 @@
+// $Id$
+
+#include "AliRunConfiguration.h"
+#include "AliFiles.h"
+#include "AliRun.h"
+
+#include "TGeant4.h"
+#include "TG4RunManager.h"
+
+#include <TROOT.h>
+#include <TRint.h>
+
+extern void InitGui();
+
+#include <stdlib.h>
+
+int main(int argc, char** argv) 
+{
+  // ROOT  ===================
+#ifdef G4VIS_USE_OPACS
+  // Root graphics does not work when OPACS graphics is build 
+  TROOT aTROOT("Alice","Alice G4 prototype Root I/O");
+#else
+  VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
+  TROOT aTROOT("Alice","Alice G4 prototype Root I/O",initfuncs);
+#endif
+
+  // ALICE ======================
+
+  // AliRun
+  AliRun* run
+    = new AliRun("gAlice","The Alice run manager");
+  G4cout << "AliRun has been created." << endl;
+
+  // AliRunConfiguration for Geant4
+  AliRunConfiguration* runConfiguration 
+    = new AliRunConfiguration();
+  G4cout << "AliRunConfiguration has been created." << endl;
+   
+  // Geant4 ======================
+
+  // TGeant4
+  TGeant4* geant4 
+    = new TGeant4("TGeant4", "The Geant4 Monte Carlo",
+                   runConfiguration, argc, argv );
+  G4cout << "TGeant4 has been created." << endl;
+  
+  // start UI ===================
+
+  TG4RunManager* runManager = TG4RunManager::Instance();
+
+  // Root interactive session
+  //runManager->StartRootUI();
+
+  // Geant4 interactive session
+  runManager->StartGeantUI();
+
+  delete run;
+  //runConfiguration is deleted in TG4RunManager
+  //geant4 is deleted in AliRun destructor 
+
+  G4cout << "Everything has been deleted." << endl;
+  return 0;
+}
+
diff --git a/AliGeant4/config/doc_alc++2html.pl b/AliGeant4/config/doc_alc++2html.pl
new file mode 100755 (executable)
index 0000000..cd464cc
--- /dev/null
@@ -0,0 +1,86 @@
+#!/usr/local/bin/perl
+# $Id$
+# Ivana Hrivnacova 12.2.99
+#
+# HTML documentation is created for all 
+# source code files: *.h *.cxx 
+# makefiles: Makefile, *.gmk 
+# and configuration setup scripts
+
+# create doc directory if it does not exist
+$CURDIR = `pwd`;
+chdir $ENV{'AG4_INSTALL'};
+if (! grep(/doc/, `ls`)) {
+  `mkdir doc` ;
+  print "Directory doc has been created." . "\n";
+};
+# move doc/HTML directory to doc/HTML.old
+chdir doc;
+if (grep(/HTML.old/, `ls`)) {
+  print "Cleaning HTML.old" . "\n";
+  `rm -fr HTML.old`;
+}
+if (grep(/HTML/, `ls`)) {
+  `mkdir HTML.old`;
+  `mv HTML HTML.old`;
+  print "Old HTML directory has been saved." . "\n";
+}
+chdir $ENV{'AG4_INSTALL'};
+
+# create tmpdoc directory is it does not exist
+# or clean it
+if (! grep(/tmpdoc/, `ls`)) {
+  `mkdir tmpdoc` ;
+  print "Directory tmpdoc has been created." . "\n";
+} else {
+  print "Cleaning tmpdoc" . "\n";
+  `rm -fr tmpdoc/*`;
+}  
+
+# select directory that will be processed
+$SOURCEDIR = ". ../TGeant4";
+
+# copy everything for documentation to tmpdoc
+@FILELIST = `find $SOURCEDIR -name "*.ddl"`;
+@FILELIST = (@FILELIST, `find $SOURCEDIR -name "*.h"`);
+@FILELIST = (@FILELIST, `find $SOURCEDIR -name "*.cxx"`);
+@FILELIST = (@FILELIST, `find $SOURCEDIR -name "*.icc"`);
+@FILELIST = (@FILELIST, `find $SOURCEDIR -name "Makefile"`);
+@FILELIST = (@FILELIST, `find $SOURCEDIR -name "*.gmk"`);
+@FILELIST = (@FILELIST, `find $SOURCEDIR -name "setup*"`);
+
+print "Copying files to tmpdoc" . "\n";
+foreach $FILE (@FILELIST) {
+  chop $FILE;
+  # exclude dictionary classes
+  if (!grep(/Dict/,$FILE)) {
+    `cp $FILE tmpdoc`;
+  }  
+  #print "$FILE has been copied to tmpdoc" . "\n";
+}
+
+# mv *.cxx to *.C 
+# what is recquired by ddl2html.pl
+chdir tmpdoc;
+print "Renaming files" . "\n";
+@CXXLIST = `ls *.cxx`;
+foreach $CXXFILE (@CXXLIST) {
+  chop $CXXFILE;
+  $CFILE = `echo $CXXFILE | sed s/.cxx/.C/g`;
+  `mv $CXXFILE $CFILE`;
+}
+
+# execute the modified P.Binko's script
+system $ENV{'AG4_INSTALL'} . "/config/doc_alddl2html.pl ALICE G4 Project";
+
+# move HTML to doc and remove tmpdoc
+$DOCDIR = $ENV{'AG4_INSTALL'} . "/doc";
+`mv HTML $DOCDIR`;  
+print "Removing tmpdoc" . "\n";
+chdir $ENV{'AG4_INSTALL'};
+`rm -fr tmpdoc`;
+
+# generate the category pages
+system $ENV{'AG4_INSTALL'} . "/config/doc_alsorthtml.pl";
+
+chdir $CURDIR;
diff --git a/AliGeant4/config/doc_alcategory.pl b/AliGeant4/config/doc_alcategory.pl
new file mode 100755 (executable)
index 0000000..a7c8183
--- /dev/null
@@ -0,0 +1,93 @@
+#!/usr/local/bin/perl
+# $Id$
+# Ivana Hrivnacova 15.2.00
+#
+# This script generates the class category page
+# from all *.h files found in the category directory
+
+# no test of arguments is performed
+$CAT = $ARGV[0];
+$NAME = $ARGV[1];
+
+# open output file
+$output =  $ENV{'AG4_INSTALL'} . "/doc/HTML/" . $NAME . "Category.html";
+open(OUTPUT, ">" . $output);
+
+print "Processing class category: " . $NAME . "\n"; 
+
+# print the begining of file
+print OUTPUT "<HTML>\n";
+print OUTPUT "\n";
+print OUTPUT "<HEAD>\n";
+print OUTPUT "<TITLE>Class category: ". $NAME . "</TITLE></HEAD>\n";
+print OUTPUT "\n";
+print OUTPUT "\n";
+print OUTPUT "<BODY bgcolor=#FFFFFF>\n";
+print OUTPUT "\n";
+print OUTPUT "<!-- Header material -->\n";
+print OUTPUT "<table border=0   cellpadding=5 cellspacing=0 width=\"100%\">\n";
+print OUTPUT "  <tr bgcolor=#d0ffd0>\n";
+print OUTPUT "     <td align=left width=30%>\n";
+print OUTPUT "     <img alt=\"Alice\"\n";
+print OUTPUT "       src=\"http://AliSoft.cern.ch/offline/geant4/gif/AliceLogo.gif\"\n";
+print OUTPUT "     width=\"60\" height=\"60\" align=\"absmiddle\" border=1>\n";
+print OUTPUT "     <td align=center width=40%>\n";
+print OUTPUT "        <font size=\"+2\">\n";
+print OUTPUT "           Alice Geant4 Simulation Code Prototype        </font>\n";
+print OUTPUT "     <td align=right width=30% valign=bottom>\n";
+print OUTPUT "        <font size=\"-1\">\n";
+print OUTPUT "        <script language=\"JavaScript\">\n";
+print OUTPUT "        document.write(\"Last modified \"+ document.lastModified)\n";
+print OUTPUT "        // end of script -->\n";
+print OUTPUT "        </script></font>\n";
+print OUTPUT "     </td>\n";
+print OUTPUT "  </tr>\n";
+print OUTPUT "</table>\n";
+print OUTPUT "<CENTER>\n";
+print OUTPUT "<H2>Class category: " . $NAME . "</H2>\n";
+print OUTPUT "</CENTER>\n";
+print OUTPUT "\n";
+print OUTPUT "<P><HR SIZE=5><BR>\n";
+print OUTPUT "\n";
+print OUTPUT "<UL><BR>\n";
+print OUTPUT "\n";
+print OUTPUT "<LI><STRONG>C++ header files:</STRONG>\n";
+print OUTPUT "\n";
+print OUTPUT "  <UL>\n";
+
+# print the linked header files
+$CATSTRING = "\"Category: " . $CAT . "\"";
+@FILELIST = `find . -name \"*.h\" -exec grep -l  $CATSTRING  {} \\;`;
+
+foreach $FILEPATH (@FILELIST) { 
+  @TEMP = split('/',$FILEPATH);
+  $FILE = @TEMP[@TEMP - 1];
+  chop $FILE;
+  print "   Linking file " . $FILE . "\n"; 
+  print OUTPUT "  <LI><A HREF=\"" . $FILE . ".html\">" . $FILE . "</A>\n";
+}
+
+# print the end of file
+$today = localtime(time);
+$today =~ s/ \d\d:\d\d:\d\d / /;
+@list = getpwuid($<);
+$user = $list[6];
+print OUTPUT "</UL>\n";
+print OUTPUT "\n";
+print OUTPUT "</UL>\n";
+print OUTPUT "\n";
+print OUTPUT "<P><HR SIZE=5>\n";
+print OUTPUT "\n";
+print OUTPUT "<ADDRESS>\n";
+print OUTPUT "Created on $today by <B>$user</B> <BR>\n";
+print OUTPUT "using the HTML generator\n";
+print OUTPUT "<A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.html\">Ddl2Html description</A>\n";
+print OUTPUT " (the source <A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.code\">Perl5 code</A>)\n";
+print OUTPUT "</ADDRESS>\n";
+print OUTPUT "\n";
+print OUTPUT "</BODY bgcolor=#FFFFFF >\n";
+print OUTPUT "\n";
+print OUTPUT "</HTML>\n";
+
+# close output file
+close(OUTPUT);    
diff --git a/AliGeant4/config/doc_alddl2html.pl b/AliGeant4/config/doc_alddl2html.pl
new file mode 100755 (executable)
index 0000000..331839c
--- /dev/null
@@ -0,0 +1,728 @@
+#!/usr/local/bin/perl5
+# $Id$
+################################################################################
+#
+# Automatic HTML generator for projects using Objectivity
+#
+# Author : Pavel Binko
+#
+# Last update : 09/04/96
+#
+################################################################################
+# Modified for Alice specifics by Ivana Hrivnacova: 22.5.98;
+# some more changes 12.2.99;
+#
+# ------------------------------------------------------------------------------
+# Analyse the command arguments
+#
+if( $#ARGV == -1 )
+{
+  $pwd = `pwd`;
+  chop($pwd);
+  @help = split(/\//,$pwd);
+  $help[$#help] =~ tr/a-z/A-Z/;
+  $html_title = "The ".$help[$#help]." Project";
+  undef $help;
+}
+elsif( $#ARGV == 0 && $ARGV[0] =~ /^-[?hH]/ )
+{
+  print "\n";
+  print "The Ddl2Html functionality :\n\n";
+  print "  Ddl2Html has to be started from the project directory you'd like\n";
+  print "           to document (to convert to html)\n";
+  print "  Ddl2Html creates (if not existing) the directory HTML in the project\n";
+  print "           directory and adds the afs access rights \"cern:nodes rl\"\n";
+  print "           to both HTML and project directories\n";
+  print "  Ddl2Html creates index.html file and *.ddl.html, *.h.html and\n";
+  print "           *.C.html files in the HTML directory\n\n";
+  print "  Contents of the project directory remains unchanged.\n\n\n";
+  print "The Ddl2Html command syntax :\n\n";
+  print "  Ddl2Html [ arguments ] \n\n";
+  print "    No argument : The project directory name will be chosen\n";
+  print "                  as the project name (in upper case)\n\n";
+  print "    One argument : a) If the argument starts with -h or -H or -?,\n";
+  print "                      this help text will be printed\n";
+  print "                   b) If the argument matches with a file name\n";
+  print "                      in the project directory, the first line\n";
+  print "                      from the file will be the project title\n";
+  print "                   c) Othetwise  the whole text from the command\n";
+  print "                      line will be the project title\n\n";
+  print "    More than one argument : The whole text from the command line\n";
+  print "                             will be the project title\n\n\n";
+  print "For further details see the :\n";
+  die "    http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.html\n\n";
+}
+elsif( $#ARGV == 0 && -e $ARGV[0] )
+{
+  $first = 1;
+  while( <> )
+  {
+    if( $first )
+    {
+      chop($_);
+      $html_title = $_;
+      $first = 0;
+    }
+  }
+  undef $first;
+}
+else
+{
+  $html_title = join( " ", @ARGV );
+}
+
+study();
+
+print "\n\n";
+print "*****************************************************************\n";
+print "*\n";
+print "*  $html_title\n";
+print "*\n";
+print "*****************************************************************\n\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get some information about the creator
+#
+# UID is in the variable $<
+@list = getpwuid($<);
+$user = $list[6];
+
+#
+# ==============================================================================
+# Get a list of all .ddl files
+#
+@ddls = <*.ddl>;
+print "List of Objectivity DDL files = @ddls\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get a list of .h files, where no .ddl files exist (ignore _ref.h files)
+#
+while( $hdrname = <*.h> )
+{
+  if( ! ( $hdrname =~ /_ref.h$/ ) )
+  {
+    $helpname = $hdrname;
+    $helpname =~ s/.h$/.ddl/;
+    if( ! -e $helpname )
+    { @hdrs = (@hdrs, $hdrname);
+    }
+  }
+}
+print "List of C++ header files = @hdrs\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get a list of all C++ programs
+#
+while( $cppname = <*.C> )
+{
+  if( ! ( $cppname =~ /_ddl.C$/ ) )
+  {
+    $helpname = $cppname;
+    $helpname =~ s/.C$//;
+    if( -e "$helpname.ddl" )
+    { @cppddls = (@cppddls, $cppname);
+    }
+    elsif( -e "$helpname.h" )
+    { @cpphdrs = (@cpphdrs, $cppname);
+    }
+    else
+    { @cppmain = (@cppmain, $cppname);
+    }
+  }
+}
+print "List of C++ programs to the *.ddl = @cppddls\n\n";
+print "List of C++ programs to the *.h = @cpphdrs\n\n";
+print "List of main programs = @cppmain\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get a list of all Makefiles, makefiles, s.Makefiles and s.makefiles
+#
+@maks = <*.gmk>;
+print "List of Makefiles = @maks\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get a list of all config.* files
+#
+#@cnfs = <config.*>;
+@cnfs = <setup* *boot*>;
+print "List of configuration files = @cnfs\n\n";
+
+#
+# ==============================================================================
+# Analyse the .ddl and .h files
+#
+print "Analysing the .ddl and .h files ...\n\n";
+
+foreach $file (@ddls, @hdrs)
+{
+  open (HF, $file);
+  $fileline = 0;
+
+  while (<HF>)
+  {
+    $fileline += 1;
+    chop;
+    if ( ! (/^[ \t]*\/\//) )   # ignore C++ comment lines
+    {
+      s/\/\/.*//;              # ignore all after C++ comment sign //
+
+      if ( /\bclass\b/ && ! ( /template.*<.*class.*>/ ) )
+      {
+        @words = split();                      # split line read in
+        for( $i = 0 ; $i < $#words ; $i++ )
+        {
+          if( $words[$i] eq "class" )
+          {
+            $words[$i+1] =~ s/:.*//;
+            $words[$i+1] =~ s/{.*//;
+            if( !($words[$i+1] =~ /;/ ) && !($words[$i+2] =~ /^;/ )
+                                        && ($words[$i+1] ne "") )
+            {
+              $fileclass{$words[$i+1]} = $file."//".$fileline;
+              $i = $#words;
+            }
+          }
+        }
+      }
+
+      if ( /\benum\b/ )
+      {
+        @words = split();                      # split line read in
+        for( $i = 0 ; $i < $#words ; $i++ )
+        {
+          if( $words[$i] eq "enum" )
+          {
+            $words[$i+1] =~ s/{.*//;
+            if( $words[$i+1] ne "" )
+            {
+              $fileenum{$words[$i+1]} = $file."//".$fileline;
+              $i = $#words;
+            }
+          }
+        }
+      }
+
+    }
+  }
+  close(HF);
+}
+
+# debug
+# print "\n\n\nDEBUG INFORMATION :\n";
+# foreach $class (keys %fileclass)
+# { print "DEBUG: class $class found in $fileclass{$class}\n";
+# }
+# foreach $enum (keys %fileenum)
+# { print "DEBUG: enum $enum found in $fileenum{$enum}\n";
+# }
+# print "\n\n";
+# end debug
+
+#
+# ==============================================================================
+# Some variables needed for html files
+#
+$today = localtime(time);
+$today =~ s/ \d\d:\d\d:\d\d / /;
+
+#
+# ------------------------------------------------------------------------------
+# Create the directory html (if not existing)
+#
+if( ! -e "HTML" )
+{
+  `mkdir HTML`;
+}
+if( -e "/usr/sue/bin/fs" )
+{
+  `/usr/sue/bin/fs setacl . cern:nodes rl`;
+  `/usr/sue/bin/fs setacl HTML cern:nodes rl`;
+}
+
+#
+# ==============================================================================
+# Create *.ddl.html and *.h.html files
+#
+foreach $file (@ddls, @hdrs)
+{
+print "Writing file $file.html ... \n";
+
+# Open the .ddl or .h file and the .html file
+open (HDRF, $file);
+open (HLPF,">HTML/$file.html");
+
+&html_header($file);
+#print HLPF "<HR SIZE=5><P>\n\n";
+#&centred_header1($html_title);
+#print HLPF "<P><HR SIZE=5><P>\n\n";
+&see_source_file;
+print HLPF "<P><HR SIZE=5><P>\n\n";
+&centred_header1($file);
+print HLPF "<P><HR><P>\n\n";
+
+print HLPF "<PRE>\n\n";
+&html_ddl_h_cpp_code;
+print HLPF "\n</PRE>\n\n";
+
+print HLPF "<P><HR SIZE=5><P>\n\n";
+&back_to_index_see_source_file;
+&create_address;
+
+close(HLPF);
+close(HDRF);
+}
+print "\nHTML for Objectivity DDL files and C++ header files created ... \n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Create *.C.html files
+#
+foreach $file (@cppddls, @cpphdrs, @cppmain)
+{
+print "Writing file $file.html ... \n";
+
+# Open the C++ file and the .html file
+open (HDRF, $file);
+open (HLPF,">HTML/$file.html");
+
+&html_header($file);
+#print HLPF "<HR SIZE=5><P>\n\n";
+#&centred_header1($html_title);
+#print HLPF "<P><HR SIZE=5><P>\n\n";
+&see_ddl_h_file;
+print HLPF "<P><HR SIZE=5><P>\n\n";
+&centred_header1($file);
+print HLPF "<P><HR><P>\n\n";
+
+print HLPF "<PRE>\n\n";
+&html_ddl_h_cpp_code;
+print HLPF "\n</PRE>\n\n";
+
+print HLPF "<P><HR SIZE=5><P>\n\n";
+&back_to_index_see_ddl_h_file;
+&create_address;
+
+close(HLPF);
+close(HDRF);
+}
+print "\nHTML for C++ files created ... \n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Copy Make and Config files
+#
+foreach $file (@maks, @cnfs)
+{
+print "Copying file $file ... \n";
+`cp $file HTML/$file`;
+}
+print "\nMake and Config files copied ... \n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Write index.html
+#
+print "Writing index file ... \n";
+
+open (HLPF,">HTML/index.html");
+
+&html_header($html_title);
+
+#print HLPF "<H1 ALIGN=RIGHT>";
+#print HLPF "<TABLE COLSPEC=\"20\" BORDER=5 CELLPADDING=0 CELLSPACING=0>\n";
+#print HLPF "<TR><TH>";
+#print HLPF "<A HREF=\"index.html\" TARGET=_top>No Frame</A>";
+#print HLPF "</TH></TR>\n";
+#print HLPF "</TABLE></H1>\n\n";
+
+print HLPF "<!-- Header material -->\n";
+print HLPF "<table border=0   cellpadding=5 cellspacing=0 width=\"100%\">\n";
+print HLPF "  <tr bgcolor=#d0ffd0>\n";
+print HLPF "     <td align=left width=30%>\n";
+print HLPF "     <img alt=\"Alice\"\n"; 
+print HLPF "        src=\"http://AliSoft.cern.ch/offline/geant4/gif/AliceLogo.gif\"\n"; 
+print HLPF "       width=\"60\" height=\"60\" align=\"absmiddle\" border=1>\n";
+print HLPF "     <td align=center width=40%>\n";
+print HLPF "        <font size=\"+2\">\n";
+print HLPF "           Alice Geant4 Simulation Code Prototype";
+print HLPF "        </font>\n";
+print HLPF "     <td align=right width=30% valign=bottom>\n"; 
+print HLPF "        <font size=\"-1\">\n"; 
+print HLPF "        <script language=\"JavaScript\">\n"; 
+print HLPF "        document.write(\"Last modified \"+ document.lastModified)\n"; 
+print HLPF "        // end of script -->\n"; 
+print HLPF "        </script></font>\n"; 
+print HLPF "     </td>\n";
+print HLPF "  </tr>\n";
+print HLPF "</table>\n";
+
+#&centred_header1($html_title);
+#print HLPF "<P><HR SIZE=5><P>\n\n";
+
+print HLPF "<UL><BR>\n\n";
+
+if( @hdrs )
+{
+print HLPF "<LI><STRONG>C++ header files:</STRONG>\n";
+  print HLPF "  <UL>\n";
+  foreach $file (@hdrs)
+  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+  }
+
+if( @cpphdrs )
+{
+#  &and_cpp_code;
+#  foreach $file (@cpphdrs)
+#  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+#  }
+}
+print HLPF "  </UL>\n\n";
+
+print HLPF "<P><HR><P>\n\n";
+}
+
+if( @ddls )
+{
+print HLPF "<LI><STRONG>Objectivity DDL files:</STRONG>\n";
+  print HLPF "  <UL>\n";
+  foreach $file (@ddls)
+  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+  }
+
+if( @cppddls )
+{
+#  &and_cpp_code;
+#  foreach $file (@cppddls)
+#  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+#  }
+}
+print HLPF "  </UL>\n\n";
+
+print HLPF "<P><HR><P>\n\n";
+}
+
+if( @cppmain )
+{
+print HLPF "<LI><STRONG>Main programs/Extern methods:</STRONG>\n";
+  print HLPF "  <UL>\n";
+  foreach $file (@cppmain)
+  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+  }
+  print HLPF "  </UL>\n\n";
+
+print HLPF "<P><HR><P>\n\n";
+}
+
+if( @maks || @cnfs )
+{
+print HLPF "<LI><STRONG>Makefiles and configuration files:</STRONG>\n";
+  print HLPF "  <UL>\n";
+  foreach $file (@maks)
+#   { print HLPF "  <LI><A HREF=\"../$file\">$file</A>\n";
+  { print HLPF "  <LI><A HREF=\"$file\">$file</A>\n";
+  }
+  foreach $file (@cnfs)
+#   { print HLPF "  <LI><A HREF=\"../$file\">$file</A>\n";
+  { print HLPF "  <LI><A HREF=\"$file\">$file</A>\n";
+  }
+  print HLPF "  </UL>\n\n";
+}
+
+print HLPF "</UL>\n\n";
+
+&create_address;
+
+close(HLPF);
+
+print "\n\n";
+
+########################  END OF THE PROGRAM  ##################################
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine create_address
+#
+sub create_address
+{
+  print HLPF "<P><HR SIZE=5><BR>\n\n";
+
+  print HLPF "<ADDRESS>\n";
+  print HLPF "Created on $today by <B>$user</B> <BR>\n";
+  print HLPF "using the HTML generator\n";
+  print HLPF "<A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.html\">Ddl2Html description</A>\n";
+  print HLPF " (the source ";
+  print HLPF "<A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.code\">Perl5 code</A>)\n";
+  print HLPF "</ADDRESS>\n\n";
+
+  print HLPF "</BODY bgcolor=#FFFFFF >\n\n";
+
+  print HLPF "</HTML>\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine back_to_index
+#
+sub back_to_index
+{
+  print HLPF "<H4>Back to: ";
+  print HLPF "<A HREF=\"../CodePrototype.html\"> Class categories index, </A>";
+  print HLPF "<A HREF=\"index.html\">Alphabetical index</A>";
+  print HLPF "</H4>\n\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine see_source_file
+#
+sub see_source_file
+{
+  # The C++ file corresponding to the .ddl or .h file
+  $cfile = $file;
+  $cfile =~ s/.h$/.C/;
+  $cfile =~ s/.ddl$/.C/;
+
+  if( -e $cfile )
+  {
+    print HLPF "<H4>See the source file ";
+    print HLPF "<A HREF=\"$cfile.html\">$cfile</A>";
+    print HLPF "</H4>\n\n";
+  }
+  undef $cfile;
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine see_ddl_h_file
+#
+sub see_ddl_h_file
+{
+  # The .ddl or .h file corresponding to the C++ file
+  $ddlfile = $file;
+  $ddlfile =~ s/.C$/.ddl/;
+  if( -e $ddlfile )
+  {
+    print HLPF "<H4>See the Objectivity DDL file ";
+    print HLPF "<A HREF=\"$ddlfile.html\">$ddlfile</A>";
+    print HLPF "</H4>\n\n";
+  }
+  else
+  {
+    $hfile = $file;
+    $hfile =~ s/.C$/.h/;
+    if( -e $hfile )
+    {
+      print HLPF "<H4>See the C++ header file ";
+      print HLPF "<A HREF=\"$hfile.html\">$hfile</A>";
+      print HLPF "</H4>\n\n";
+    }
+  }
+  undef $ddlfile;
+  undef $hfile;
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine back_to_index_see_source_file
+#
+sub back_to_index_see_source_file
+{
+  &back_to_index;
+  &see_source_file;
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine back_to_index_see_ddl_h_file
+#
+sub back_to_index_see_ddl_h_file
+{
+  &back_to_index;
+  &see_ddl_h_file;
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine and_cpp_code
+#
+sub and_cpp_code
+{
+  print HLPF "<P>\n";
+  print HLPF "<STRONG>... and the corresponding C++ code :</STRONG>\n\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine centred_header1
+#
+sub centred_header1
+{
+  local($sometitle) = @_;
+
+  print HLPF "<CENTER>\n";
+  print HLPF "<H1>$sometitle</H1>\n";
+  print HLPF "</CENTER>\n\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine html_header
+#
+sub html_header
+{
+  local($sometitle) = @_;
+
+  print HLPF "<HTML>\n\n";
+
+  print HLPF "<HEAD>\n";
+  print HLPF "<TITLE>$sometitle</TITLE>";
+  print HLPF "</HEAD>\n\n";
+
+  print HLPF "<BODY bgcolor=#FFFFFF>\n\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine html_ddl_h_cpp_code
+#
+sub html_ddl_h_cpp_code
+{
+$fileline = 0;
+
+while (<HDRF>)
+{
+  $fileline += 1;
+  chop;
+               
+  s/</&lt\;/g;                 # convert special characters to html
+  s/>/&gt\;/g;
+
+# Write the HTML
+  foreach $class (keys %fileclass)             # add links for classes 
+  {
+    undef $newstr;
+    undef $newerstr;
+
+    ( $locfileclass, $locfileline ) = split( /\/\//, $fileclass{$class} );
+
+    if( ($file eq $locfileclass) && ($fileline eq $locfileline) )
+    { print HLPF "<A NAME=\"$class\_classdef\">\n";
+    }
+
+    if ( /\b$class\b/ )
+    {
+      if( $file eq $locfileclass )
+      { $newstr="<a href=\"\#$class\_classdef\">$class</a>";
+      }
+      else
+      { $newstr="<a href=\"$locfileclass.html\#$class\_classdef\">$class</a>";
+      }
+
+undef $hotovo;
+
+while( $_ ne "" )
+{
+  if( /\b$class\b/ )
+  {
+    $hotovo = $hotovo.$`;
+    $zbytek = $';
+
+    if( !( ($hotovo =~ /<a href="$/) && ($zbytek =~ /^\./) ) )
+    {
+      $hotovo = $hotovo.$newstr;
+    }
+    else
+    {
+      $hotovo = $hotovo.$class
+    }
+
+    $_ = $zbytek;
+    /\b$class\b/;
+  }
+  else
+  {
+    $hotovo = $hotovo.$_;
+    $_ = "";
+  }
+}
+
+$_ = $hotovo;
+
+      if ( /$newstr\.h/ )
+      {
+        if( -e "$class.ddl" )
+        { $newerstr="<a href=\"$class.ddl.html\">$class.h</a>";
+          s/$newstr\.h/$newerstr/g; 
+        }
+        else
+        { $newerstr="<a href=\"$class.h.html\">$class.h</a>";
+          s/$newstr\.h/$newerstr/g; 
+        }
+      }
+
+      if ( /$newstr\.C/ )
+      { $newerstr="<a href=\"$class.C.html\">$class.C</a>";
+        s/$newstr\.C/$newerstr/g; 
+      }
+
+    }
+  }
+
+  foreach $enum (keys %fileenum)               # add links for enums
+  {
+    undef $newstr;
+    undef $newerstr;
+
+    ( $locfileenum, $locfileline ) = split( /\/\//, $fileenum{$enum} );
+
+    if( ($file eq $locfileenum) && ($fileline eq $locfileline) )
+    { print HLPF "<A NAME=\"$enum\_enumdef\">\n";
+    }
+
+    if ( /\b$enum\b/ )
+    {
+      if( $file eq $locfileenum )
+      { $newstr="<a href=\"\#$enum\_enumdef\">$enum</a>";
+        s/\b$enum\b/$newstr/g; 
+      }
+      else
+      { $newstr="<a href=\"$locfileenum.html\#$enum\_enumdef\">$enum</a>";
+        s/\b$enum\b/$newstr/g; 
+      }
+
+      if ( /$newstr\.ddl/ )
+      { $newerstr="<a href=\"$enum.ddl.html\">$enum.ddl</a>";
+        s/$newstr\.ddl/$newerstr/g; 
+      }
+
+      if ( /$newstr\.h/ )
+      {
+        if( -e "$enum.ddl" )
+        { $newerstr="<a href=\"$enum.ddl.html\">$enum.h</a>";
+          s/$newstr\.h/$newerstr/g; 
+        }
+        else
+        { $newerstr="<a href=\"$enum.h.html\">$enum.h</a>";
+          s/$newstr\.h/$newerstr/g; 
+        }
+      }
+
+      if ( /$newstr\.C/ )
+      { $newerstr="<a href=\"$enum.C.html\">$enum.C</a>";
+        s/$newstr\.C/$newerstr/g; 
+      }
+
+    }
+  }
+
+  print HLPF "$_\n";           # output line to html file
+}
+}
+
+# ------------------------------------------------------------------------------
+
diff --git a/AliGeant4/config/doc_alsorthtml.pl b/AliGeant4/config/doc_alsorthtml.pl
new file mode 100755 (executable)
index 0000000..21e301a
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/local/bin/perl
+# $Id$
+# Ivana Hrivnacova 15.2.00
+#
+# This script defines the class categories
+# and calls doc_alcategory.pl to generate 
+# the html category pages
+
+
+print "Generating html pages for class categories\n"; 
+
+# main categories (packages)
+@DIRLIST = "TGeant4";
+@DIRLIST = (@DIRLIST,"AliGeant4");
+@NAMELIST = "TGeant4";
+@NAMELIST = (@NAMELIST,"AliGeant4");
+
+# subcategories
+@CATLIST = "global";
+@CATLIST = (@CATLIST,"geometry");
+@CATLIST = (@CATLIST,"physics");
+@CATLIST = (@CATLIST,"event");
+@CATLIST = (@CATLIST,"run");
+@CATLIST = (@CATLIST,"visualization");
+
+# categories
+for( $i = 0 ; $i < $#DIRLIST+1 ; $i++ ) {
+#foreach $DIR (@DIRLIST) {
+  $DIR = @DIRLIST[$i];
+  $NAME = @NAMELIST[$i];
+  $DIRPATH = $ENV{'AG4_INSTALL'} . "/../" . $DIR;
+  chdir $DIRPATH;
+  foreach $CAT (@CATLIST) {
+    #chop $CAT;
+    # exclude other subdirectories
+
+    print "Processing category: " . $CAT . " of " . $NAME . "\n"; 
+    $CATDIRPATH = $DIRPATH . "/" . $CAT;
+    $CATNAME = $NAME . "_" . $CAT;      
+    # generate the category pages
+    system $ENV{'AG4_INSTALL'} . "/config/doc_alcategory.pl " . $CAT . " " . $CATNAME;
+  }  
+}      
diff --git a/AliGeant4/config/doc_g4c++2html.pl b/AliGeant4/config/doc_g4c++2html.pl
new file mode 100755 (executable)
index 0000000..8cad65d
--- /dev/null
@@ -0,0 +1,97 @@
+#!/usr/local/bin/perl
+# $Id$
+# Ivana Hrivnacova 12.2.99
+#
+# HTML documentation is created for all 
+# source code files: *.hh *.cc *.icc 
+# generic makefiles: *.gmk 
+# and configuration setup scripts
+
+# file extensions
+#$INCEXT = ".hh"
+#$SRCEXT = ".cc"
+#$MKFEXT = ".gmk"
+
+# create doc directory if it does not exist
+$CURDIR = `pwd`;
+chdir $ENV{'G4INSTALL'};
+if (! grep(/doc/, `ls`)) {
+  `mkdir doc` ;
+  print "Directory doc has been created." . "\n";
+};
+# move doc/HTML directory to doc/HTML.old
+chdir doc;
+if (grep(/HTML.old/, `ls`)) {
+  print "Cleaning HTML.old" . "\n";
+  `rm -fr HTML.old`;
+}
+if (grep(/HTML/, `ls`)) {
+  `mkdir HTML.old`;
+  `mv HTML HTML.old`;
+  print "Old HTML directory has been saved." . "\n";
+}
+chdir $ENV{'G4INSTALL'};
+
+# create tmpdoc directory is it does not exist
+# or clean it
+if (! grep(/tmpdoc/, `ls`)) {
+  `mkdir tmpdoc` ;
+  print "Directory tmpdoc has been created." . "\n";
+} else {
+  print "Cleaning tmpdoc" . "\n";
+  `rm -fr tmpdoc/*`;
+}  
+
+# copy everything for documentation to tmpdoc
+@FILELIST = `find . -name "*.ddl"`;
+@FILELIST = (@FILELIST, `find . -name "*.h"`);
+@FILELIST = (@FILELIST, `find . -name "*.hh"`);
+@FILELIST = (@FILELIST, `find . -name "*.cc"`);
+@FILELIST = (@FILELIST, `find . -name "*.icc"`);
+@FILELIST = (@FILELIST, `find config -name "*.gmk"`);
+@FILELIST = (@FILELIST, `find config -name "setup*"`);
+@FILELIST = (@FILELIST, `find config -name "*boot"`);
+
+print "Copying files to tmpdoc" . "\n";
+foreach $FILE (@FILELIST) {
+  chop $FILE;
+  # exclude dictionary classes
+  if (!grep(/Dict/,$FILE)) {
+    `cp $FILE tmpdoc`;
+  }  
+  #print "$FILE has been copied to tmpdoc" . "\n";
+}
+
+# mv *.cc to *.C
+# what is recquired by ddl2html.pl
+chdir tmpdoc;
+print "Renaming files" . "\n";
+@CXXLIST = `ls *.cc`;
+foreach $CXXFILE (@CXXLIST) {
+  chop $CXXFILE;
+  $CFILE = `echo $CXXFILE | sed s/.cc/.C/g`;
+  `mv $CXXFILE $CFILE`;
+}
+
+# mv *.hh to *.h 
+@HHLIST = `ls *.hh`;
+foreach $HHFILE (@HHLIST) {
+  chop $HHFILE;
+  $HFILE = `echo $HHFILE | sed s/.hh/.h/g`;
+  `mv $HHFILE $HFILE`;
+}
+
+# execute the modified P.Binko's script
+system $ENV{'AG4_INSTALL'} . "/config/doc_g4ddl2html.pl GEANT4 Project";
+
+# move HTML to doc and remove tmpdoc
+$DOCDIR = $ENV{'G4INSTALL'} . "/doc";
+`mv HTML $DOCDIR`;  
+print "Removing tmpdoc" . "\n";
+chdir $ENV{'G4INSTALL'};
+`rm -fr tmpdoc`;
+
+# generate the category pages
+system $ENV{'AG4_INSTALL'} . "/config/doc_g4sorthtml.pl";
+
+chdir $CURDIR;
diff --git a/AliGeant4/config/doc_g4category.pl b/AliGeant4/config/doc_g4category.pl
new file mode 100755 (executable)
index 0000000..2f15048
--- /dev/null
@@ -0,0 +1,97 @@
+#!/usr/local/bin/perl
+# $Id$
+# Ivana Hrivnacova 15.2.00
+#
+# This script generates the class category page
+# from all *.h files found in the category directory
+
+# no test of arguments is performed
+$DIR = $ARGV[0];
+$NAME = $ARGV[1];
+
+# open output file
+$output =  $ENV{'G4INSTALL'} . "/doc/HTML/" . $NAME . "Category.html";
+open(OUTPUT, ">" . $output);
+
+print "Processing class category: " . $NAME . "\n"; 
+
+# print the begining of file
+print OUTPUT "<HTML>\n";
+print OUTPUT "\n";
+print OUTPUT "<HEAD>\n";
+print OUTPUT "<TITLE>Class category: ". $NAME . "</TITLE></HEAD>\n";
+print OUTPUT "\n";
+print OUTPUT "\n";
+print OUTPUT "<BODY bgcolor=#FFFFFF>\n";
+print OUTPUT "\n";
+print OUTPUT "<!-- Header material -->\n";
+print OUTPUT "<table border=0   cellpadding=5 cellspacing=0 width=\"100%\">\n";
+print OUTPUT "  <tr bgcolor=#d0ffd0>\n";
+print OUTPUT "     <td align=left width=30%>\n";
+print OUTPUT "     <img alt=\"Alice\"\n";
+print OUTPUT "       src=\"http://AliSoft.cern.ch/offline/geant4/gif/AliceLogo.gif\"\n";
+print OUTPUT "     width=\"60\" height=\"60\" align=\"absmiddle\" border=1>\n";
+print OUTPUT "     <td align=center width=40%>\n";
+print OUTPUT "        <font size=\"+2\">\n";
+print OUTPUT "           Alice Geant4 Simulation <br> \n";
+print OUTPUT "           Geant4 Code </font>\n";
+print OUTPUT "     <td align=right width=30% valign=bottom>\n";
+print OUTPUT "        <font size=\"-1\">\n";
+print OUTPUT "        <script language=\"JavaScript\">\n";
+print OUTPUT "        document.write(\"Last modified \"+ document.lastModified)\n";
+print OUTPUT "        // end of script -->\n";
+print OUTPUT "        </script></font>\n";
+print OUTPUT "     </td>\n";
+print OUTPUT "  </tr>\n";
+print OUTPUT "</table>\n";
+print OUTPUT "<CENTER>\n";
+print OUTPUT "<H2>Class category: " . $NAME . "</H2>\n";
+print OUTPUT "</CENTER>\n";
+print OUTPUT "\n";
+print OUTPUT "<P><HR SIZE=5><BR>\n";
+print OUTPUT "\n";
+print OUTPUT "<UL><BR>\n";
+print OUTPUT "\n";
+print OUTPUT "<LI><STRONG>C++ header files:</STRONG>\n";
+print OUTPUT "\n";
+print OUTPUT "  <UL>\n";
+
+# print the linked header files
+#chdir $ENV{'AG4_INSTALL'} . "/source/" . $DIR;
+chdir $DIR;
+@FILELIST = `find . -name "*.h"`;
+@FILELIST = (@FILELIST, `find . -name "*.hh"`);
+
+foreach $FILEPATH (@FILELIST) { 
+  @TEMP = split('/',$FILEPATH);
+  $FILE = @TEMP[@TEMP - 1];
+  chop $FILE;
+  print "   Linking file " . $FILE . "\n";
+  $HFILE = `echo $FILE | sed s/.hh/.h/g`;   
+  print OUTPUT "  <LI><A HREF=\"" . $HFILE . ".html\">" . $FILE . "</A>\n";
+}
+
+# print the end of file
+$today = localtime(time);
+$today =~ s/ \d\d:\d\d:\d\d / /;
+@list = getpwuid($<);
+$user = $list[6];
+print OUTPUT "</UL>\n";
+print OUTPUT "\n";
+print OUTPUT "</UL>\n";
+print OUTPUT "\n";
+print OUTPUT "<P><HR SIZE=5>\n";
+print OUTPUT "\n";
+print OUTPUT "<ADDRESS>\n";
+print OUTPUT "Created on $today by <B>$user</B> <BR>\n";
+print OUTPUT "using the HTML generator\n";
+print OUTPUT "<A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.html\">Ddl2Html description</A>\n";
+print OUTPUT " (the source <A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.code\">Perl5 code</A>)\n";
+print OUTPUT "</ADDRESS>\n";
+print OUTPUT "\n";
+print OUTPUT "</BODY bgcolor=#FFFFFF >\n";
+print OUTPUT "\n";
+print OUTPUT "</HTML>\n";
+
+# close output file
+close(OUTPUT);    
diff --git a/AliGeant4/config/doc_g4ddl2html.pl b/AliGeant4/config/doc_g4ddl2html.pl
new file mode 100755 (executable)
index 0000000..e45f61c
--- /dev/null
@@ -0,0 +1,728 @@
+#!/usr/local/bin/perl5
+# $Id$
+################################################################################
+#
+# Automatic HTML generator for projects using Objectivity
+#
+# Author : Pavel Binko
+#
+# Last update : 09/04/96
+#
+################################################################################
+# Modified for Alice specifics by Ivana Hrivnacova: 22.5.98;
+# some more changes 12.2.99;
+#
+# ------------------------------------------------------------------------------
+# Analyse the command arguments
+#
+if( $#ARGV == -1 )
+{
+  $pwd = `pwd`;
+  chop($pwd);
+  @help = split(/\//,$pwd);
+  $help[$#help] =~ tr/a-z/A-Z/;
+  $html_title = "The ".$help[$#help]." Project";
+  undef $help;
+}
+elsif( $#ARGV == 0 && $ARGV[0] =~ /^-[?hH]/ )
+{
+  print "\n";
+  print "The Ddl2Html functionality :\n\n";
+  print "  Ddl2Html has to be started from the project directory you'd like\n";
+  print "           to document (to convert to html)\n";
+  print "  Ddl2Html creates (if not existing) the directory HTML in the project\n";
+  print "           directory and adds the afs access rights \"cern:nodes rl\"\n";
+  print "           to both HTML and project directories\n";
+  print "  Ddl2Html creates index.html file and *.ddl.html, *.h.html and\n";
+  print "           *.C.html files in the HTML directory\n\n";
+  print "  Contents of the project directory remains unchanged.\n\n\n";
+  print "The Ddl2Html command syntax :\n\n";
+  print "  Ddl2Html [ arguments ] \n\n";
+  print "    No argument : The project directory name will be chosen\n";
+  print "                  as the project name (in upper case)\n\n";
+  print "    One argument : a) If the argument starts with -h or -H or -?,\n";
+  print "                      this help text will be printed\n";
+  print "                   b) If the argument matches with a file name\n";
+  print "                      in the project directory, the first line\n";
+  print "                      from the file will be the project title\n";
+  print "                   c) Othetwise  the whole text from the command\n";
+  print "                      line will be the project title\n\n";
+  print "    More than one argument : The whole text from the command line\n";
+  print "                             will be the project title\n\n\n";
+  print "For further details see the :\n";
+  die "    http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.html\n\n";
+}
+elsif( $#ARGV == 0 && -e $ARGV[0] )
+{
+  $first = 1;
+  while( <> )
+  {
+    if( $first )
+    {
+      chop($_);
+      $html_title = $_;
+      $first = 0;
+    }
+  }
+  undef $first;
+}
+else
+{
+  $html_title = join( " ", @ARGV );
+}
+
+study();
+
+print "\n\n";
+print "*****************************************************************\n";
+print "*\n";
+print "*  $html_title\n";
+print "*\n";
+print "*****************************************************************\n\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get some information about the creator
+#
+# UID is in the variable $<
+@list = getpwuid($<);
+$user = $list[6];
+
+#
+# ==============================================================================
+# Get a list of all .ddl files
+#
+@ddls = <*.ddl>;
+print "List of Objectivity DDL files = @ddls\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get a list of .h files, where no .ddl files exist (ignore _ref.h files)
+#
+while( $hdrname = <*.h> )
+{
+  if( ! ( $hdrname =~ /_ref.h$/ ) )
+  {
+    $helpname = $hdrname;
+    $helpname =~ s/.h$/.ddl/;
+    if( ! -e $helpname )
+    { @hdrs = (@hdrs, $hdrname);
+    }
+  }
+}
+print "List of C++ header files = @hdrs\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get a list of all C++ programs
+#
+while( $cppname = <*.C> )
+{
+  if( ! ( $cppname =~ /_ddl.C$/ ) )
+  {
+    $helpname = $cppname;
+    $helpname =~ s/.C$//;
+    if( -e "$helpname.ddl" )
+    { @cppddls = (@cppddls, $cppname);
+    }
+    elsif( -e "$helpname.h" )
+    { @cpphdrs = (@cpphdrs, $cppname);
+    }
+    else
+    { @cppmain = (@cppmain, $cppname);
+    }
+  }
+}
+print "List of C++ programs to the *.ddl = @cppddls\n\n";
+print "List of C++ programs to the *.h = @cpphdrs\n\n";
+print "List of main programs = @cppmain\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get a list of all Makefiles, makefiles, s.Makefiles and s.makefiles
+#
+@maks = <*.gmk>;
+print "List of Makefiles = @maks\n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Get a list of all config.* files
+#
+#@cnfs = <config.*>;
+@cnfs = <setup* *boot*>;
+print "List of configuration files = @cnfs\n\n";
+
+#
+# ==============================================================================
+# Analyse the .ddl and .h files
+#
+print "Analysing the .ddl and .h files ...\n\n";
+
+foreach $file (@ddls, @hdrs)
+{
+  open (HF, $file);
+  $fileline = 0;
+
+  while (<HF>)
+  {
+    $fileline += 1;
+    chop;
+    if ( ! (/^[ \t]*\/\//) )   # ignore C++ comment lines
+    {
+      s/\/\/.*//;              # ignore all after C++ comment sign //
+
+      if ( /\bclass\b/ && ! ( /template.*<.*class.*>/ ) )
+      {
+        @words = split();                      # split line read in
+        for( $i = 0 ; $i < $#words ; $i++ )
+        {
+          if( $words[$i] eq "class" )
+          {
+            $words[$i+1] =~ s/:.*//;
+            $words[$i+1] =~ s/{.*//;
+            if( !($words[$i+1] =~ /;/ ) && !($words[$i+2] =~ /^;/ )
+                                        && ($words[$i+1] ne "") )
+            {
+              $fileclass{$words[$i+1]} = $file."//".$fileline;
+              $i = $#words;
+            }
+          }
+        }
+      }
+
+      if ( /\benum\b/ )
+      {
+        @words = split();                      # split line read in
+        for( $i = 0 ; $i < $#words ; $i++ )
+        {
+          if( $words[$i] eq "enum" )
+          {
+            $words[$i+1] =~ s/{.*//;
+            if( $words[$i+1] ne "" )
+            {
+              $fileenum{$words[$i+1]} = $file."//".$fileline;
+              $i = $#words;
+            }
+          }
+        }
+      }
+
+    }
+  }
+  close(HF);
+}
+
+# debug
+# print "\n\n\nDEBUG INFORMATION :\n";
+# foreach $class (keys %fileclass)
+# { print "DEBUG: class $class found in $fileclass{$class}\n";
+# }
+# foreach $enum (keys %fileenum)
+# { print "DEBUG: enum $enum found in $fileenum{$enum}\n";
+# }
+# print "\n\n";
+# end debug
+
+#
+# ==============================================================================
+# Some variables needed for html files
+#
+$today = localtime(time);
+$today =~ s/ \d\d:\d\d:\d\d / /;
+
+#
+# ------------------------------------------------------------------------------
+# Create the directory html (if not existing)
+#
+if( ! -e "HTML" )
+{
+  `mkdir HTML`;
+}
+if( -e "/usr/sue/bin/fs" )
+{
+  `/usr/sue/bin/fs setacl . cern:nodes rl`;
+  `/usr/sue/bin/fs setacl HTML cern:nodes rl`;
+}
+
+#
+# ==============================================================================
+# Create *.ddl.html and *.h.html files
+#
+foreach $file (@ddls, @hdrs)
+{
+print "Writing file $file.html ... \n";
+
+# Open the .ddl or .h file and the .html file
+open (HDRF, $file);
+open (HLPF,">HTML/$file.html");
+
+&html_header($file);
+#print HLPF "<HR SIZE=5><P>\n\n";
+#&centred_header1($html_title);
+#print HLPF "<P><HR SIZE=5><P>\n\n";
+&see_source_file;
+print HLPF "<P><HR SIZE=5><P>\n\n";
+&centred_header1($file);
+print HLPF "<P><HR><P>\n\n";
+
+print HLPF "<PRE>\n\n";
+&html_ddl_h_cpp_code;
+print HLPF "\n</PRE>\n\n";
+
+print HLPF "<P><HR SIZE=5><P>\n\n";
+&back_to_index_see_source_file;
+&create_address;
+
+close(HLPF);
+close(HDRF);
+}
+print "\nHTML for Objectivity DDL files and C++ header files created ... \n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Create *.C.html files
+#
+foreach $file (@cppddls, @cpphdrs, @cppmain)
+{
+print "Writing file $file.html ... \n";
+
+# Open the C++ file and the .html file
+open (HDRF, $file);
+open (HLPF,">HTML/$file.html");
+
+&html_header($file);
+#print HLPF "<HR SIZE=5><P>\n\n";
+#&centred_header1($html_title);
+#print HLPF "<P><HR SIZE=5><P>\n\n";
+&see_ddl_h_file;
+print HLPF "<P><HR SIZE=5><P>\n\n";
+&centred_header1($file);
+print HLPF "<P><HR><P>\n\n";
+
+print HLPF "<PRE>\n\n";
+&html_ddl_h_cpp_code;
+print HLPF "\n</PRE>\n\n";
+
+print HLPF "<P><HR SIZE=5><P>\n\n";
+&back_to_index_see_ddl_h_file;
+&create_address;
+
+close(HLPF);
+close(HDRF);
+}
+print "\nHTML for C++ files created ... \n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Copy Make and Config files
+#
+foreach $file (@maks, @cnfs)
+{
+print "Copying file $file ... \n";
+`cp $file HTML/$file`;
+}
+print "\nMake and Config files copied ... \n\n";
+
+#
+# ------------------------------------------------------------------------------
+# Write index.html
+#
+print "Writing index file ... \n";
+
+open (HLPF,">HTML/index.html");
+
+&html_header($html_title);
+
+#print HLPF "<H1 ALIGN=RIGHT>";
+#print HLPF "<TABLE COLSPEC=\"20\" BORDER=5 CELLPADDING=0 CELLSPACING=0>\n";
+#print HLPF "<TR><TH>";
+#print HLPF "<A HREF=\"index.html\" TARGET=_top>No Frame</A>";
+#print HLPF "</TH></TR>\n";
+#print HLPF "</TABLE></H1>\n\n";
+
+print HLPF "<!-- Header material -->\n";
+print HLPF "<table border=0   cellpadding=5 cellspacing=0 width=\"100%\">\n";
+print HLPF "  <tr bgcolor=#d0ffd0>\n";
+print HLPF "     <td align=left width=30%>\n";
+print HLPF "     <img alt=\"Alice\"\n"; 
+print HLPF "        src=\"http://AliSoft.cern.ch/offline/geant4/gif/AliceLogo.gif\"\n"; 
+print HLPF "       width=\"60\" height=\"60\" align=\"absmiddle\" border=1>\n";
+print HLPF "     <td align=center width=40%>\n";
+print HLPF "        <font size=\"+2\">\n";
+print HLPF "           Geant4 Project";
+print HLPF "        </font>\n";
+print HLPF "     <td align=right width=30% valign=bottom>\n"; 
+print HLPF "        <font size=\"-1\">\n"; 
+print HLPF "        <script language=\"JavaScript\">\n"; 
+print HLPF "        document.write(\"Last modified \"+ document.lastModified)\n"; 
+print HLPF "        // end of script -->\n"; 
+print HLPF "        </script></font>\n"; 
+print HLPF "     </td>\n";
+print HLPF "  </tr>\n";
+print HLPF "</table>\n";
+
+#&centred_header1($html_title);
+#print HLPF "<P><HR SIZE=5><P>\n\n";
+
+print HLPF "<UL><BR>\n\n";
+
+if( @hdrs )
+{
+print HLPF "<LI><STRONG>C++ header files:</STRONG>\n";
+  print HLPF "  <UL>\n";
+  foreach $file (@hdrs)
+  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+  }
+
+if( @cpphdrs )
+{
+#  &and_cpp_code;
+#  foreach $file (@cpphdrs)
+#  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+#  }
+}
+print HLPF "  </UL>\n\n";
+
+print HLPF "<P><HR><P>\n\n";
+}
+
+if( @ddls )
+{
+print HLPF "<LI><STRONG>Objectivity DDL files:</STRONG>\n";
+  print HLPF "  <UL>\n";
+  foreach $file (@ddls)
+  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+  }
+
+if( @cppddls )
+{
+#  &and_cpp_code;
+#  foreach $file (@cppddls)
+#  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+#  }
+}
+print HLPF "  </UL>\n\n";
+
+print HLPF "<P><HR><P>\n\n";
+}
+
+if( @cppmain )
+{
+print HLPF "<LI><STRONG>Main programs/Extern methods:</STRONG>\n";
+  print HLPF "  <UL>\n";
+  foreach $file (@cppmain)
+  { print HLPF "  <LI><A HREF=\"$file.html\">$file</A>\n";
+  }
+  print HLPF "  </UL>\n\n";
+
+print HLPF "<P><HR><P>\n\n";
+}
+
+if( @maks || @cnfs )
+{
+print HLPF "<LI><STRONG>Makefiles and configuration files:</STRONG>\n";
+  print HLPF "  <UL>\n";
+  foreach $file (@maks)
+#   { print HLPF "  <LI><A HREF=\"../$file\">$file</A>\n";
+  { print HLPF "  <LI><A HREF=\"$file\">$file</A>\n";
+  }
+  foreach $file (@cnfs)
+#   { print HLPF "  <LI><A HREF=\"../$file\">$file</A>\n";
+  { print HLPF "  <LI><A HREF=\"$file\">$file</A>\n";
+  }
+  print HLPF "  </UL>\n\n";
+}
+
+print HLPF "</UL>\n\n";
+
+&create_address;
+
+close(HLPF);
+
+print "\n\n";
+
+########################  END OF THE PROGRAM  ##################################
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine create_address
+#
+sub create_address
+{
+  print HLPF "<P><HR SIZE=5><BR>\n\n";
+
+  print HLPF "<ADDRESS>\n";
+  print HLPF "Created on $today by <B>$user</B> <BR>\n";
+  print HLPF "using the HTML generator\n";
+  print HLPF "<A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.html\">Ddl2Html description</A>\n";
+  print HLPF " (the source ";
+  print HLPF "<A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.code\">Perl5 code</A>)\n";
+  print HLPF "</ADDRESS>\n\n";
+
+  print HLPF "</BODY bgcolor=#FFFFFF >\n\n";
+
+  print HLPF "</HTML>\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine back_to_index
+#
+sub back_to_index
+{
+  print HLPF "<H4>Back to: ";
+  print HLPF "<A HREF=\"../G4CodePrototype.html\"> Class categories index, </A>";
+  print HLPF "<A HREF=\"index.html\">Alphabetical index</A>";
+  print HLPF "</H4>\n\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine see_source_file
+#
+sub see_source_file
+{
+  # The C++ file corresponding to the .ddl or .h file
+  $cfile = $file;
+  $cfile =~ s/.h$/.C/;
+  $cfile =~ s/.ddl$/.C/;
+
+  if( -e $cfile )
+  {
+    print HLPF "<H4>See the source file ";
+    print HLPF "<A HREF=\"$cfile.html\">$cfile</A>";
+    print HLPF "</H4>\n\n";
+  }
+  undef $cfile;
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine see_ddl_h_file
+#
+sub see_ddl_h_file
+{
+  # The .ddl or .h file corresponding to the C++ file
+  $ddlfile = $file;
+  $ddlfile =~ s/.C$/.ddl/;
+  if( -e $ddlfile )
+  {
+    print HLPF "<H4>See the Objectivity DDL file ";
+    print HLPF "<A HREF=\"$ddlfile.html\">$ddlfile</A>";
+    print HLPF "</H4>\n\n";
+  }
+  else
+  {
+    $hfile = $file;
+    $hfile =~ s/.C$/.h/;
+    if( -e $hfile )
+    {
+      print HLPF "<H4>See the C++ header file ";
+      print HLPF "<A HREF=\"$hfile.html\">$hfile</A>";
+      print HLPF "</H4>\n\n";
+    }
+  }
+  undef $ddlfile;
+  undef $hfile;
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine back_to_index_see_source_file
+#
+sub back_to_index_see_source_file
+{
+  &back_to_index;
+  &see_source_file;
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine back_to_index_see_ddl_h_file
+#
+sub back_to_index_see_ddl_h_file
+{
+  &back_to_index;
+  &see_ddl_h_file;
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine and_cpp_code
+#
+sub and_cpp_code
+{
+  print HLPF "<P>\n";
+  print HLPF "<STRONG>... and the corresponding C++ code :</STRONG>\n\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine centred_header1
+#
+sub centred_header1
+{
+  local($sometitle) = @_;
+
+  print HLPF "<CENTER>\n";
+  print HLPF "<H1>$sometitle</H1>\n";
+  print HLPF "</CENTER>\n\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine html_header
+#
+sub html_header
+{
+  local($sometitle) = @_;
+
+  print HLPF "<HTML>\n\n";
+
+  print HLPF "<HEAD>\n";
+  print HLPF "<TITLE>$sometitle</TITLE>";
+  print HLPF "</HEAD>\n\n";
+
+  print HLPF "<BODY bgcolor=#FFFFFF>\n\n";
+}
+
+#
+# ------------------------------------------------------------------------------
+# Subroutine html_ddl_h_cpp_code
+#
+sub html_ddl_h_cpp_code
+{
+$fileline = 0;
+
+while (<HDRF>)
+{
+  $fileline += 1;
+  chop;
+               
+  s/</&lt\;/g;                 # convert special characters to html
+  s/>/&gt\;/g;
+
+# Write the HTML
+  foreach $class (keys %fileclass)             # add links for classes 
+  {
+    undef $newstr;
+    undef $newerstr;
+
+    ( $locfileclass, $locfileline ) = split( /\/\//, $fileclass{$class} );
+
+    if( ($file eq $locfileclass) && ($fileline eq $locfileline) )
+    { print HLPF "<A NAME=\"$class\_classdef\">\n";
+    }
+
+    if ( /\b$class\b/ )
+    {
+      if( $file eq $locfileclass )
+      { $newstr="<a href=\"\#$class\_classdef\">$class</a>";
+      }
+      else
+      { $newstr="<a href=\"$locfileclass.html\#$class\_classdef\">$class</a>";
+      }
+
+undef $hotovo;
+
+while( $_ ne "" )
+{
+  if( /\b$class\b/ )
+  {
+    $hotovo = $hotovo.$`;
+    $zbytek = $';
+
+    if( !( ($hotovo =~ /<a href="$/) && ($zbytek =~ /^\./) ) )
+    {
+      $hotovo = $hotovo.$newstr;
+    }
+    else
+    {
+      $hotovo = $hotovo.$class
+    }
+
+    $_ = $zbytek;
+    /\b$class\b/;
+  }
+  else
+  {
+    $hotovo = $hotovo.$_;
+    $_ = "";
+  }
+}
+
+$_ = $hotovo;
+
+      if ( /$newstr\.h/ )
+      {
+        if( -e "$class.ddl" )
+        { $newerstr="<a href=\"$class.ddl.html\">$class.h</a>";
+          s/$newstr\.h/$newerstr/g; 
+        }
+        else
+        { $newerstr="<a href=\"$class.h.html\">$class.h</a>";
+          s/$newstr\.h/$newerstr/g; 
+        }
+      }
+
+      if ( /$newstr\.C/ )
+      { $newerstr="<a href=\"$class.C.html\">$class.C</a>";
+        s/$newstr\.C/$newerstr/g; 
+      }
+
+    }
+  }
+
+  foreach $enum (keys %fileenum)               # add links for enums
+  {
+    undef $newstr;
+    undef $newerstr;
+
+    ( $locfileenum, $locfileline ) = split( /\/\//, $fileenum{$enum} );
+
+    if( ($file eq $locfileenum) && ($fileline eq $locfileline) )
+    { print HLPF "<A NAME=\"$enum\_enumdef\">\n";
+    }
+
+    if ( /\b$enum\b/ )
+    {
+      if( $file eq $locfileenum )
+      { $newstr="<a href=\"\#$enum\_enumdef\">$enum</a>";
+        s/\b$enum\b/$newstr/g; 
+      }
+      else
+      { $newstr="<a href=\"$locfileenum.html\#$enum\_enumdef\">$enum</a>";
+        s/\b$enum\b/$newstr/g; 
+      }
+
+      if ( /$newstr\.ddl/ )
+      { $newerstr="<a href=\"$enum.ddl.html\">$enum.ddl</a>";
+        s/$newstr\.ddl/$newerstr/g; 
+      }
+
+      if ( /$newstr\.h/ )
+      {
+        if( -e "$enum.ddl" )
+        { $newerstr="<a href=\"$enum.ddl.html\">$enum.h</a>";
+          s/$newstr\.h/$newerstr/g; 
+        }
+        else
+        { $newerstr="<a href=\"$enum.h.html\">$enum.h</a>";
+          s/$newstr\.h/$newerstr/g; 
+        }
+      }
+
+      if ( /$newstr\.C/ )
+      { $newerstr="<a href=\"$enum.C.html\">$enum.C</a>";
+        s/$newstr\.C/$newerstr/g; 
+      }
+
+    }
+  }
+
+  print HLPF "$_\n";           # output line to html file
+}
+}
+
+# ------------------------------------------------------------------------------
+
diff --git a/AliGeant4/config/doc_g4sorthtml.pl b/AliGeant4/config/doc_g4sorthtml.pl
new file mode 100755 (executable)
index 0000000..cb55abd
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/local/bin/perl
+# $Id$
+# Ivana Hrivnacova 15.2.00
+#
+# This script defines the class categories
+# and calls doc_alcategory.pl to generate 
+# the html category pages
+
+print "Generating html pages for class categories\n"; 
+
+# main categories list
+$G4SOURCE = $ENV{'G4INSTALL'} . "/source";
+chdir $G4SOURCE;
+@DIRLIST = `ls`;
+
+# categories
+foreach $DIR (@DIRLIST) {
+  chop $DIR;
+  # exclude unwanted subdirectories/files
+  if ($DIR ne "GNUmakefile" && $DIR ne "History" && $DIR ne "nohup.out") {  
+    # subcategories are considered only in one level
+    $DIRPATH = $G4SOURCE . "/" . $DIR;
+    chdir $DIRPATH;
+    
+    # test if subcategories are present
+    @INCLUDE = `find . -name "include"`;
+    $FIRSTINCLUDE = @INCLUDE[0];
+    chop $FIRSTINCLUDE;
+    if ($FIRSTINCLUDE eq "./include") {
+      @CATLIST = ".";
+    } 
+    else {      
+      @CATLIST = `ls`;    
+    }  
+   
+    # process subcategories
+    foreach $CAT (@CATLIST) {
+      chop $CAT;
+      # exclude other subdirectories
+      if ($CAT ne "GNUmakefile" && $CAT ne "History" && $CAT ne "nohup.out") {
+        print "Processing category: " . $CAT . " of " . $DIR . "\n&qu