]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
initial version - added with redesign of detector construction classes (see AliGeant4...
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Oct 2001 12:16:36 +0000 (12:16 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Oct 2001 12:16:36 +0000 (12:16 +0000)
AliGeant4/AliDetSwitchVector.cxx [new file with mode: 0644]
AliGeant4/AliDetSwitchVector.h [new file with mode: 0644]
AliGeant4/AliDetSwitchVectorMessenger.cxx [new file with mode: 0644]
AliGeant4/AliDetSwitchVectorMessenger.h [new file with mode: 0644]
AliGeant4/AliLVTree.cxx [new file with mode: 0644]
AliGeant4/AliLVTree.h [new file with mode: 0644]
AliGeant4/AliLVTreeMessenger.cxx [new file with mode: 0644]
AliGeant4/AliLVTreeMessenger.h [new file with mode: 0644]

diff --git a/AliGeant4/AliDetSwitchVector.cxx b/AliGeant4/AliDetSwitchVector.cxx
new file mode 100644 (file)
index 0000000..1d31a2f
--- /dev/null
@@ -0,0 +1,280 @@
+// $Id$
+// Category: geometry
+//
+// Author: I. Hrivnacova
+//
+// Class AliDetSwitchVector
+// ---------------------------
+// See the class description in the header file.
+
+#include "AliDetSwitchVector.h"
+#include "AliDetSwitch.h"
+#include "AliGlobals.h"
+#include "AliFiles.h"
+
+//_____________________________________________________________________________
+AliDetSwitchVector::AliDetSwitchVector()
+  : fMessenger(this)
+{
+//
+}
+
+//_____________________________________________________________________________
+AliDetSwitchVector::AliDetSwitchVector(const AliDetSwitchVector& right)
+  : fMessenger(this)
+{
+//
+  AliGlobals::Exception("AliDetSwitchVector is protected from copying.");  
+}
+
+//_____________________________________________________________________________
+AliDetSwitchVector::~AliDetSwitchVector() {
+//   
+  // destroy det switch vector
+  DetSwitchIterator it;
+  for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++)
+    delete *it; 
+}
+
+// operators
+
+//_____________________________________________________________________________
+AliDetSwitchVector& 
+AliDetSwitchVector::operator=(const AliDetSwitchVector& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  AliGlobals::Exception("AliDetSwitchVector is protected from assigning.");  
+
+  return *this;  
+}    
+          
+// protected methods
+
+//_____________________________________________________________________________
+AliDetSwitch* 
+AliDetSwitchVector::GetDetSwitch(const G4String& moduleName) const
+{
+// Returns the detector switch with given detector name.
+// ---
+
+  DetSwitchConstIterator it;
+  for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++)
+    if ((*it)->GetDetName() == moduleName) return *it; 
+
+  G4String text = "AliDetSwitchVector::GetDetSwitch:\n";
+  text = text + "Wrong detector name for " + moduleName;   
+  AliGlobals::Exception(text);
+  return 0;  
+} 
+
+// public methods
+
+//_____________________________________________________________________________
+void AliDetSwitchVector::Add(AliDetSwitch* detSwitch)
+{
+// Adds detSwitch to the detSwitch vector.
+// ---
+
+  fDetSwitchVector.push_back(detSwitch);
+  fMessenger.SetCandidates();
+}  
+  
+//_____________________________________________________________________________
+void AliDetSwitchVector::SwitchDetOn(const G4String& moduleNameVer)
+{ 
+// Switchs on module specified by name and version.
+// ---
+
+  DetSwitchIterator it;
+
+  if (moduleNameVer == "ALL") {
+    for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++)
+      (*it)->SwitchOnDefault(); 
+  }
+  else if (moduleNameVer == "NONE") {
+    for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++)
+      (*it)->SwitchOff(); 
+  }
+  else {
+    // get version number
+    G4int len = moduleNameVer.length();
+    G4String moduleName = moduleNameVer.substr(0, len-1);
+    G4String version = moduleNameVer.substr(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 AliDetSwitchVector::SwitchDetOn(const G4String& moduleName, 
+                                     G4int version)
+{ 
+// Switchs on module specified by name and version.
+// ---
+
+  GetDetSwitch(moduleName)->SwitchOn(version);
+}
+
+//_____________________________________________________________________________
+void AliDetSwitchVector::SwitchDetOnDefault(const G4String& moduleName)
+{ 
+// Switchs on module specified by name with default version.
+// ---
+
+  GetDetSwitch(moduleName)->SwitchOnDefault();
+}
+
+//_____________________________________________________________________________
+void AliDetSwitchVector::SwitchDetOff(const G4String& moduleName)
+{ 
+// Switchs off module specified by name.
+// ---
+
+  if (moduleName == "ALL") {
+    DetSwitchIterator it;
+    for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++)
+      (*it)->SwitchOff(); 
+  }
+  else 
+    GetDetSwitch(moduleName)->SwitchOff();
+}
+
+//_____________________________________________________________________________
+void AliDetSwitchVector::PrintSwitchedDets() const
+{ 
+// Lists switched detectors.
+// ---
+
+  G4String svList = GetSwitchedDetsList();
+    
+  G4cout << "Switched Alice detectors: " << G4endl;
+  G4cout << "--------------------------" << G4endl;
+  G4cout << svList << G4endl;
+}
+
+//_____________________________________________________________________________
+void AliDetSwitchVector::PrintAvailableDets() const
+{ 
+// Lists available detectors.
+// ---
+
+  G4String avList = GetAvailableDetsList();
+    
+  G4cout << "Available Alice detectors: " << G4endl;
+  G4cout << "---------------------------" << G4endl;
+  G4cout << avList << G4endl;
+}
+
+//_____________________________________________________________________________
+G4String AliDetSwitchVector::GetSwitchedDetsList() const
+{ 
+// Returns list of switched detectors.
+// ---
+
+  G4String svList = "";  
+  G4int nofSwitchedDets = 0;
+  DetSwitchConstIterator it;
+  
+  for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++) {
+    G4int iVersion = (*it)->GetSwitchedVersion();
+    if (iVersion > -1) {
+      nofSwitchedDets++;
+      G4String moduleNameVer = (*it)->GetDetName();
+      AliGlobals::AppendNumberToString(moduleNameVer, iVersion);
+      svList += moduleNameVer;
+      svList += " "; 
+    }
+  }
+
+  if (nofSwitchedDets == fDetSwitchVector.size()) svList = "ALL: " + svList;
+  if (nofSwitchedDets == 0) svList = "NONE";   
+
+  return svList;
+}
+
+//_____________________________________________________________________________
+G4String AliDetSwitchVector::GetAvailableDetsList() const
+{ 
+// Returns list of available detectors.
+// ---
+
+  G4String svList = "";
+  DetSwitchConstIterator it;
+  
+  for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++)
+    for (G4int iv=0; iv<(*it)->GetNofVersions(); iv++) {
+      G4String moduleNameVer = (*it)->GetDetName();
+      AliGlobals::AppendNumberToString(moduleNameVer, iv);
+      svList += moduleNameVer;
+      svList += " ";
+    } 
+
+  return svList;
+}
+
+//_____________________________________________________________________________
+G4String AliDetSwitchVector::GetAvailableDetsListWithCommas() const
+{ 
+// Returns list of available detectors with commas.
+// ---
+
+  G4String svList = "";
+  G4int id =0;
+  DetSwitchConstIterator it;
+
+  for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++)
+    for (G4int iv=0; iv<(*it)->GetNofVersions(); iv++) {
+      G4String moduleNameVer = (*it)->GetDetName();
+      AliGlobals::AppendNumberToString(moduleNameVer, iv);
+      svList += moduleNameVer;
+      if (iv < (*it)->GetNofVersions()-1)        svList += "/";
+      else if (id++ < fDetSwitchVector.size()-1) svList += ", ";
+    }
+
+  return svList;
+}
+
+//_____________________________________________________________________________
+G4String AliDetSwitchVector::GetDetNamesList() const
+{ 
+// Returns list of detector names.
+// ---
+
+  G4String svList = "";
+  DetSwitchConstIterator it;
+  
+  for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++) {
+    svList += (*it)->GetDetName();
+    svList += " ";
+  }
+
+  return svList;
+}
+
+//_____________________________________________________________________________
+G4String AliDetSwitchVector::GetDetNamesListWithCommas() const
+{ 
+// Returns list of detector names with commas.
+// ---
+
+  G4String svList = "";
+  G4int id =0;
+  DetSwitchConstIterator it;
+
+  for (it = fDetSwitchVector.begin(); it != fDetSwitchVector.end(); it++) {
+    svList += (*it)->GetDetName();
+    if (id++ < fDetSwitchVector.size()-1) svList += ", ";
+  }
+
+  return svList;
+}
+
diff --git a/AliGeant4/AliDetSwitchVector.h b/AliGeant4/AliDetSwitchVector.h
new file mode 100644 (file)
index 0000000..63dc15e
--- /dev/null
@@ -0,0 +1,73 @@
+// $Id$
+// Category: geometry
+//
+// Author: I. Hrivnacova
+//
+// Class AliDetSwitchVector
+// ---------------------------
+// The class contains a vector of detector switches
+// and provides methods for their interactive setting.
+
+#ifndef ALI_DET_SWITCH_VECTOR_H
+#define ALI_DET_SWITCH_VECTOR_H
+
+#include "AliDetSwitchVectorMessenger.h"
+
+#include <globals.hh>
+#include <g4std/vector>
+
+class AliDetSwitch;
+
+class AliDetSwitchVector
+{
+  typedef G4std::vector<AliDetSwitch*>    DetSwitchVector;
+  typedef DetSwitchVector::iterator       DetSwitchIterator;
+  typedef DetSwitchVector::const_iterator DetSwitchConstIterator;
+
+  public:
+    AliDetSwitchVector();
+    // --> protected
+    // AliDetSwitchVector(const AliDetSwitchVector& right);
+    virtual ~AliDetSwitchVector();
+
+    // methods
+    void Add(AliDetSwitch* detSwitch);
+    void SwitchDetOn(const G4String& moduleNameVer);
+    void SwitchDetOn(const G4String& moduleName, G4int version);
+    void SwitchDetOnDefault(const G4String& moduleName);
+    void SwitchDetOff(const G4String& moduleName);
+    void PrintSwitchedDets() const;
+    void PrintAvailableDets() const;
+
+    // get methods
+    G4int GetSize() const;
+    AliDetSwitch* GetDetSwitch(G4int i) const;
+    AliDetSwitch* GetDetSwitch(const G4String& moduleName) const;
+    G4String GetSwitchedDetsList() const;
+    G4String GetAvailableDetsList() const;
+    G4String GetAvailableDetsListWithCommas() const;
+    G4String GetDetNamesList() const;
+    G4String GetDetNamesListWithCommas() const;
+    
+  protected:
+    AliDetSwitchVector(const AliDetSwitchVector& right);
+
+    // operators
+    AliDetSwitchVector& operator=(const AliDetSwitchVector& right);
+    
+  private:    
+    // data members
+    AliDetSwitchVectorMessenger  fMessenger;       //messenger
+    DetSwitchVector              fDetSwitchVector; //vector of AliDetSwitch
+};
+
+// inline methods
+
+inline G4int AliDetSwitchVector::GetSize() const
+{ return fDetSwitchVector.size(); }
+
+inline AliDetSwitch* AliDetSwitchVector::GetDetSwitch(G4int i) const
+{ return fDetSwitchVector[i]; }
+
+#endif //ALI_DET_SWITCH_VECTOR_H
+
diff --git a/AliGeant4/AliDetSwitchVectorMessenger.cxx b/AliGeant4/AliDetSwitchVectorMessenger.cxx
new file mode 100644 (file)
index 0000000..0a24dd2
--- /dev/null
@@ -0,0 +1,138 @@
+// $Id$
+// Category: geometry
+//
+// Author: I. Hrivnacova
+//
+// Class AliDetSwitchVectorMessenger
+// ------------------------------------
+// See the class description in the header file.
+
+#include "AliDetSwitchVectorMessenger.h"
+#include "AliDetSwitchVector.h"
+#include "AliGlobals.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithAString.hh>
+#include <G4UIcmdWithoutParameter.hh>
+
+//_____________________________________________________________________________
+AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger(
+                                         AliDetSwitchVector* switchVector)
+  : fDetSwitchVector(switchVector)
+{
+//
+  fSwitchOnCmd = new G4UIcmdWithAString("/aliDet/switchOn", this);
+  fSwitchOnCmd->SetGuidance("Define the module to be built.");
+  fSwitchOnCmd->SetGuidance("Available modules:");
+  G4String listAvailableDets = "NONE, ALL, ";  
+  listAvailableDets 
+    = listAvailableDets + fDetSwitchVector->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 + fDetSwitchVector->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);
+
+  // set candidates list
+  SetCandidates();
+
+  // set default values to a detector
+  fDetSwitchVector->SwitchDetOn("NONE");
+}
+
+//_____________________________________________________________________________
+AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger() {
+//
+}
+
+//_____________________________________________________________________________
+AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger(
+                                   const AliDetSwitchVectorMessenger& right)
+{
+//
+  AliGlobals::Exception(
+    "AliDetSwitchVectorMessenger is protected from copying.");
+}
+
+//_____________________________________________________________________________
+AliDetSwitchVectorMessenger::~AliDetSwitchVectorMessenger() {
+//
+  delete fSwitchOnCmd;
+  delete fSwitchOffCmd;
+  delete fListCmd;
+  delete fListAvailableCmd;
+}
+
+// operators
+
+//_____________________________________________________________________________
+AliDetSwitchVectorMessenger& 
+AliDetSwitchVectorMessenger::operator=(const AliDetSwitchVectorMessenger& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception(
+     "AliDetSwitchVectorMessenger is protected from assigning.");
+    
+  return *this;  
+}    
+          
+// public methods
+  
+//_____________________________________________________________________________
+void AliDetSwitchVectorMessenger::SetNewValue(G4UIcommand* command, 
+                                              G4String newValues)
+{
+// Applies command to the associated object.
+// ---
+
+  if (command == fSwitchOnCmd) {  
+    fDetSwitchVector->SwitchDetOn(newValues); 
+  }
+  else if (command == fSwitchOffCmd) {  
+    fDetSwitchVector->SwitchDetOff(newValues); 
+  }
+  else if (command == fListCmd) {  
+    fDetSwitchVector->PrintSwitchedDets(); 
+  }
+  else if (command == fListAvailableCmd) {  
+    fDetSwitchVector->PrintAvailableDets(); 
+  }
+}
+
+//_____________________________________________________________________________
+void AliDetSwitchVectorMessenger::SetCandidates() 
+{
+// Builds candidates list.
+// ---
+
+  G4String candidatesList = "NONE ALL ";
+  candidatesList += fDetSwitchVector->GetDetNamesList();;
+  candidatesList += fDetSwitchVector->GetAvailableDetsList();
+  fSwitchOnCmd->SetCandidates(candidatesList);
+
+  candidatesList = "ALL ";
+  candidatesList += fDetSwitchVector->GetDetNamesList();;
+  fSwitchOffCmd->SetCandidates(candidatesList);
+}
diff --git a/AliGeant4/AliDetSwitchVectorMessenger.h b/AliGeant4/AliDetSwitchVectorMessenger.h
new file mode 100644 (file)
index 0000000..9f28e81
--- /dev/null
@@ -0,0 +1,55 @@
+// $Id$
+// Category: geometry
+//
+// Author: I. Hrivnacova
+//
+// Class AliDetSwitchVectorMessenger
+// ------------------------------------
+// Messenger class that defines commands for AliDetSwitchVector.
+
+#ifndef ALI_DET_SWITCH_VECTOR_MESSENGER_H
+#define ALI_DET_SWITCH_VECTOR_MESSENGER_H
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliDetSwitchVector;
+
+class G4UIcommand;
+class G4UIdirectory;
+class G4UIcmdWithAString;
+class G4UIcmdWithoutParameter;
+
+class AliDetSwitchVectorMessenger: public G4UImessenger
+{
+  public:
+    AliDetSwitchVectorMessenger(AliDetSwitchVector* detSwitchVector);
+    // --> protected
+    // AliDetSwitchVectorMessenger();
+    // AliDetSwitchVectorMessenger(const AliDetSwitchVectorMessenger& right);
+    virtual ~AliDetSwitchVectorMessenger();
+
+    // methods
+    virtual void SetNewValue(G4UIcommand* command, G4String newValues);
+    void SetCandidates();
+    
+  protected:
+    AliDetSwitchVectorMessenger();
+    AliDetSwitchVectorMessenger(const AliDetSwitchVectorMessenger& right);
+
+    // operators
+    AliDetSwitchVectorMessenger& 
+    operator=(const AliDetSwitchVectorMessenger &right);
+             
+  private:
+    AliDetSwitchVector*  fDetSwitchVector; //associated class
+    
+    // commands data members
+    G4UIcmdWithAString*         fSwitchOnCmd;     //command: switchOn 
+    G4UIcmdWithAString*         fSwitchOffCmd;    //command: switchOn
+    G4UIcmdWithoutParameter*    fListCmd;         //command: list
+    G4UIcmdWithoutParameter*    fListAvailableCmd;//command: listAvailable
+};
+
+#endif //ALI_DET_SWITCH_VECTOR_MESSENGER_H
+
diff --git a/AliGeant4/AliLVTree.cxx b/AliGeant4/AliLVTree.cxx
new file mode 100644 (file)
index 0000000..340112b
--- /dev/null
@@ -0,0 +1,293 @@
+// $Id$
+// Category: geometry
+//
+// Author: I. Hrivnacova
+//
+// Class AliLVTree
+// ---------------------------
+// See the class description in the header file.
+
+#include "AliLVTree.h"
+#include "AliGlobals.h"
+#include "AliLVStructure.h"
+#include "AliModule.h"
+#ifdef ALICE_VISUALIZE
+#include "AliColourStore.h"
+#endif
+
+#include "TG4GeometryServices.h"
+
+#include <G4LogicalVolumeStore.hh>
+#include <G4LogicalVolume.hh>
+#ifdef ALICE_VISUALIZE
+#include <G4Colour.hh>
+#include <G4VisAttributes.hh>
+#endif
+
+AliLVTree* AliLVTree::fgInstance = 0;
+
+//_____________________________________________________________________________
+AliLVTree* AliLVTree::Instance() 
+{
+// Static singleton access method.
+// ---
+
+  if (!fgInstance) new AliLVTree();
+  
+  return fgInstance;
+}  
+
+//_____________________________________________________________________________
+AliLVTree::AliLVTree()
+  : fMessenger(this) 
+{
+// Protected singleton constructor.
+// ---
+
+  fgInstance = this;
+}
+
+//_____________________________________________________________________________
+AliLVTree::AliLVTree(const AliLVTree& right)
+  : fMessenger(this)
+{
+// Protected singleton copy constructor.
+// ---
+//
+  AliGlobals::Exception(
+    "Attempt to copy AliLVTree singleton.");
+}
+
+//_____________________________________________________________________________
+AliLVTree::~AliLVTree() {
+//
+}
+
+// operators
+
+//_____________________________________________________________________________
+AliLVTree& AliLVTree::operator=(const AliLVTree& right)
+{    
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception(
+    "Attempt to assign AliLVTree singleton.");
+    
+  return *this;  
+
+}
+
+// protected methods
+
+//_____________________________________________________________________________
+void AliLVTree::RegisterLogicalVolume(G4LogicalVolume* lv, const G4String& path,
+                                     AliLVStructure& lvStructure) const
+{
+// Registers logical volume lv in the structure.
+// ---        
+
+  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 != lv->GetName() && currentName != previousName) { 
+        G4String newPath = path + lv->GetName() +"/";
+        RegisterLogicalVolume(lvd, newPath, lvStructure);
+       previousName = currentName;
+      }
+    }
+  }     
+}          
+
+//_____________________________________________________________________________
+void AliLVTree::Warn(const G4String& where, const G4String& lvName) const                             
+{
+// Prints warning "volume not found".
+// ---
+  
+   G4String text("AliLVTree::" + where + ": " + lvName + " volume not found.");
+   AliGlobals::Warning(text);
+}
+
+//_____________________________________________________________________________
+void AliLVTree::Warn(const G4String& where) const
+{                             
+// Prints warning "volume not specified".
+// ---
+  
+   G4String text("AliLVTree::" + where + ": " + " volume not specified.");
+   AliGlobals::Warning(text);
+}
+
+// public methods
+
+//_____________________________________________________________________________
+void AliLVTree::List(const G4String& lvName) const
+{
+// Lists logical volumes tree (daughters) of the logical volume 
+// with specified lvName.
+// ---- 
+
+  G4LogicalVolume* lv 
+    = TG4GeometryServices::Instance()->FindLogicalVolume(lvName);
+
+  if (lv) {
+    G4String path = "";
+    AliLVStructure lvStructure(path);
+    RegisterLogicalVolume(lv, path, lvStructure);
+    lvStructure.ListTree();
+  }
+  else 
+    Warn("List", lvName);
+}    
+
+//_____________________________________________________________________________
+void AliLVTree::List(G4LogicalVolume* lv) const
+{
+// Lists logical volumes tree of the given lv.
+// ---- 
+
+  if (!lv) {
+    Warn("List");
+    return; 
+  }  
+  
+  List(lv->GetName());
+}
+
+//_____________________________________________________________________________
+void AliLVTree::ListLong(const G4String& lvName) const
+{
+// Lists logical volumes tree (daughters) of the logical volume 
+// with specified lvName with numbers of daughters (physical volumes).
+// ---- 
+
+  G4LogicalVolume* lv 
+    = TG4GeometryServices::Instance()->FindLogicalVolume(lvName);
+
+  if (lv) {
+    G4String path = "";
+    AliLVStructure lvStructure(path);
+    RegisterLogicalVolume(lv, path, lvStructure);
+    lvStructure.ListTreeLong();
+  }
+  else 
+    Warn("ListLong", lvName);
+}
+
+//_____________________________________________________________________________
+void AliLVTree::ListLong(G4LogicalVolume* lv) const
+{
+// Lists logical volumes tree with numbers of daughters 
+// (physical volumes) of the given lv.
+// ---- 
+
+  if (!lv) {
+    Warn("ListLong");
+    return; 
+  }  
+  
+  ListLong(lv->GetName());
+}
+
+#ifdef G4VIS_USE
+
+//_____________________________________________________________________________
+void AliLVTree::SetLVTreeVisibility(G4LogicalVolume* lv, 
+                                    G4bool visibility) const
+{ 
+// Sets visibility to the logical volumes tree (daughters) of 
+// the logical volume lv.
+// ---
+
+  if (!lv) {
+    Warn("SetLVTreeVisibility");
+    return; 
+  }  
+  
+  G4String path = "";
+  AliLVStructure lvStructure(path);
+  RegisterLogicalVolume(lv, path, lvStructure);
+  lvStructure.SetTreeVisibility(visibility);
+}
+
+//_____________________________________________________________________________
+void AliLVTree::SetVolumeVisibility(G4LogicalVolume* lv, 
+                                    G4bool visibility) const
+{ 
+// Sets visibility to the specified logical volume.
+// ---
+
+  if (!lv) {
+    Warn("SetVolumeVisibility");
+    return; 
+  }  
+  
+  const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes ();
+  G4VisAttributes* newVisAttributes; 
+  if (kpVisAttributes) {
+    G4Colour oldColour   = kpVisAttributes->GetColour();
+    newVisAttributes = new G4VisAttributes(oldColour); 
+  }  
+  else
+    newVisAttributes = new G4VisAttributes();
+  delete kpVisAttributes;
+
+  newVisAttributes->SetVisibility(visibility); 
+
+  lv->SetVisAttributes(newVisAttributes);
+}
+
+//_____________________________________________________________________________
+void AliLVTree::SetLVTreeColour(G4LogicalVolume* lv, 
+                                const G4String& colName) const
+{ 
+// Sets colour to the logical volumes tree (daughters) of 
+// the logical volume lv.
+// ---
+
+  if (!lv) {
+    Warn("SetLVTreeColour");
+    return; 
+  }  
+  
+  G4String path = "";
+  AliLVStructure lvStructure(path);
+  RegisterLogicalVolume(lv, path, lvStructure);
+  lvStructure.SetTreeVisibility(true);
+  lvStructure.SetTreeColour(colName);
+}
+
+//_____________________________________________________________________________
+void AliLVTree::SetVolumeColour(G4LogicalVolume* lv,
+                                const G4String& colName) const
+{
+// Sets colour to the specified logical volume.
+// ---
+
+  if (!lv) {
+    Warn("SetVolumeColour");
+    return; 
+  }  
+  
+  const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes ();
+  delete kpVisAttributes;
+
+  G4VisAttributes* newVisAttributes = new G4VisAttributes(); 
+
+  AliColourStore* pColours = AliColourStore::Instance();
+  const G4Colour kColour = pColours->GetColour(colName);
+  newVisAttributes->SetVisibility(true); 
+  newVisAttributes->SetColour(kColour);
+
+  lv->SetVisAttributes(newVisAttributes);
+}
+
+#endif //G4VIS_USE
+
diff --git a/AliGeant4/AliLVTree.h b/AliGeant4/AliLVTree.h
new file mode 100644 (file)
index 0000000..ce479f0
--- /dev/null
@@ -0,0 +1,73 @@
+// $Id$
+// Category: geometry
+//
+// Author: I. Hrivnacova
+//
+// Class AliLVTree
+// ---------------------------
+// Class provides methods for browsing volumes trees, 
+// and setting their visualization attributes.
+
+#ifndef ALI_LV_TREE_H
+#define ALI_LV_TREE_H
+
+#include "AliLVTreeMessenger.h"
+
+#include <globals.hh>
+
+class AliLVStructure;
+
+class G4LogicalVolume;
+#ifdef G4VIS_USE
+class G4Colour;
+#endif
+
+class AliLVTree
+{
+  public:
+    // --> protected
+    // AliLVTree();
+    // AliLVTree(const AliLVTree& right);
+    virtual ~AliLVTree();
+
+    // static methods
+    static AliLVTree* Instance();
+
+    // methods
+    void List(const G4String& lvName) const;
+    void List(G4LogicalVolume* lv) const;
+    void ListLong(const G4String& lvName) const;
+    void ListLong(G4LogicalVolume* lv) const;
+
+#ifdef G4VIS_USE
+    void SetLVTreeVisibility(G4LogicalVolume* lv, G4bool visibility) const;
+    void SetVolumeVisibility(G4LogicalVolume* lv, G4bool visibility) const;
+    void SetLVTreeColour(G4LogicalVolume* lv, const G4String& colName) const;
+    void SetVolumeColour(G4LogicalVolume* lv, const G4String& colName) const;     
+#endif
+
+  protected:
+    AliLVTree(); 
+    AliLVTree(const AliLVTree& right);
+
+    // operators
+    AliLVTree& operator=(const AliLVTree &right);
+
+  private:
+    // methods
+    void RegisterLogicalVolume(G4LogicalVolume* lv, const G4String& path, 
+                               AliLVStructure& lvStructure) const;
+    void Warn(const G4String& where, const G4String& lvName) const;                           
+    void Warn(const G4String& where) const;                           
+
+    // static data members
+    static AliLVTree* fgInstance;
+
+    // data members
+    AliLVTreeMessenger  fMessenger; //messenger     
+};
+
+// inline methods
+
+#endif //ALI_LV_TREE_H
+
diff --git a/AliGeant4/AliLVTreeMessenger.cxx b/AliGeant4/AliLVTreeMessenger.cxx
new file mode 100644 (file)
index 0000000..a1d0224
--- /dev/null
@@ -0,0 +1,181 @@
+// $Id$
+// Category: geometry
+//
+// Author: I. Hrivnacova
+//
+// Class AliLVTreeMessenger
+// ------------------------------------
+// See the class description in the header file.
+
+#include "AliLVTreeMessenger.h"
+#include "AliLVTree.h"
+#include "AliGlobals.h"
+#ifdef ALICE_VISUALIZE
+#include "AliColourStore.h"
+#endif
+
+#include "TG4GeometryServices.h"
+
+#include <G4UIdirectory.hh>
+#include <G4UIcmdWithABool.hh>
+#include <G4UIcmdWithAString.hh>
+#include <G4UIcmdWithoutParameter.hh>
+
+//_____________________________________________________________________________
+AliLVTreeMessenger::AliLVTreeMessenger(AliLVTree* lvTree)
+ : fLVTree(lvTree),
+   fCurrentVolume(0)
+{
+//
+  G4String dirName = "/aliTree/"; 
+  fDirectory = new G4UIdirectory(dirName);
+  fDirectory->SetGuidance("LV tree control commands.");
+
+  G4String 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 + "list";
+  fListCmd = new G4UIcmdWithoutParameter(commandPath, this);
+  G4String guidance = "List LV tree of the current volume. ";
+  fListCmd->SetGuidance(guidance);
+  fListCmd->AvailableForStates(PreInit,Idle);  
+  commandPath = dirName + "listLong";
+  fListLongCmd = new G4UIcmdWithoutParameter(commandPath, this);
+  guidance = "List LV tree of the current volume \n";
+  guidance = guidance + "including number of its daughters.";
+  fListLongCmd->SetGuidance(guidance);
+  fListLongCmd->AvailableForStates(PreInit,Idle);  
+#ifdef G4VIS_USE
+  commandPath = dirName + "setLVTreeVisibility";
+  fSetLVTreeVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
+  fSetLVTreeVisibilityCmd 
+    ->SetGuidance("Make current volume tree visible/invisible.");
+  fSetLVTreeVisibilityCmd->SetParameterName("lvtreeVisibility", 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 + "setLVTreeColour";
+  fSetLVTreeColourCmd = new G4UIcmdWithAString(commandPath, this);
+  fSetLVTreeColourCmd->SetGuidance("Set colour for the current volume tree.");
+  fSetLVTreeColourCmd->SetGuidance("Available colours:");
+  guidance = AliColourStore::Instance()->GetColoursListWithCommas();
+  fSetLVTreeColourCmd->SetGuidance(guidance);
+  fSetLVTreeColourCmd->SetParameterName("lvtreeColour", false);
+  G4String candidatesList = AliColourStore::Instance()->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:");
+  guidance = AliColourStore::Instance()->GetColoursListWithCommas();
+  fSetVolColourCmd->SetGuidance(guidance);
+  fSetVolColourCmd->SetParameterName("volColour", false);
+  candidatesList = AliColourStore::Instance()->GetColoursList();  
+  fSetVolColourCmd->SetCandidates(candidatesList);
+  fSetVolColourCmd->AvailableForStates(PreInit,Idle);  
+#endif //G4VIS_USE
+}
+
+//_____________________________________________________________________________
+AliLVTreeMessenger::AliLVTreeMessenger() {
+//
+}
+
+//_____________________________________________________________________________
+AliLVTreeMessenger::AliLVTreeMessenger(const AliLVTreeMessenger& right)
+{
+//
+  AliGlobals::Exception(
+    "AliLVTreeMessenger is protected from copying.");
+}
+
+//_____________________________________________________________________________
+AliLVTreeMessenger::~AliLVTreeMessenger()
+{
+//
+  delete fDirectory;
+  delete fSetCurrentLVCmd;
+  delete fListCmd;
+  delete fListLongCmd;
+#ifdef G4VIS_USE
+  delete fSetLVTreeVisibilityCmd;    
+  delete fSetVolVisibilityCmd;    
+  delete fSetLVTreeColourCmd;    
+  delete fSetVolColourCmd;    
+#endif //G4VIS_USE
+}
+
+// operators
+
+//_____________________________________________________________________________
+AliLVTreeMessenger& 
+AliLVTreeMessenger::operator=(const AliLVTreeMessenger& right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+
+  AliGlobals::Exception(
+     "AliLVTreeMessenger is protected from assigning.");
+    
+  return *this;  
+}    
+          
+// public methods
+  
+//_____________________________________________________________________________
+void AliLVTreeMessenger::SetNewValue(G4UIcommand* command,
+                                     G4String newValues)
+{
+// Applies command to the associated object.
+// ---
+
+  G4String dirName = "/aliTree/"; 
+  fDirectory = new G4UIdirectory(dirName);
+  G4String guidance = "LV tree control commands ";
+  fDirectory->SetGuidance(guidance);
+
+  if (command == fSetCurrentLVCmd) {
+    fCurrentVolume 
+      = TG4GeometryServices::Instance()->FindLogicalVolume(newValues);
+  }    
+  else if (command == fListCmd) {
+    fLVTree->List(fCurrentVolume);
+  }
+  else if (command == fListLongCmd) {
+    fLVTree->ListLong(fCurrentVolume);
+  }
+#ifdef G4VIS_USE
+  if (command == fSetLVTreeVisibilityCmd) {
+    fLVTree
+      ->SetLVTreeVisibility(fCurrentVolume,
+          fSetVolVisibilityCmd->GetNewBoolValue(newValues)); 
+  } 
+  else if (command == fSetVolVisibilityCmd) {
+    fLVTree
+      ->SetVolumeVisibility(fCurrentVolume,
+          fSetVolVisibilityCmd->GetNewBoolValue(newValues)); 
+  } 
+  else if (command == fSetLVTreeColourCmd) {
+    fLVTree
+      ->SetLVTreeColour(fCurrentVolume, newValues);
+  }     
+  else if (command == fSetVolColourCmd) {
+    fLVTree
+      ->SetVolumeColour(fCurrentVolume, newValues);
+  }     
+#endif //G4VIS_USE
+}
+
diff --git a/AliGeant4/AliLVTreeMessenger.h b/AliGeant4/AliLVTreeMessenger.h
new file mode 100644 (file)
index 0000000..944742a
--- /dev/null
@@ -0,0 +1,63 @@
+// $Id$
+// Category: geometry
+//
+// Author: I. Hrivnacova
+//
+// Class AliLVTreeMessenger
+// ------------------------------------
+// Messenger class that defines commands for AliLVTree.
+
+#ifndef ALI_LV_TREE_MESSENGER_H
+#define ALI_LV_TREE_MESSENGER_H
+
+#include <G4UImessenger.hh>
+#include <globals.hh>
+
+class AliLVTree;
+
+class G4UIdirectory;
+class G4UIcmdWithABool;
+class G4UIcmdWithAString;
+class G4UIcmdWithoutParameter;
+class G4LogicalVolume;
+
+class AliLVTreeMessenger: public G4UImessenger
+{
+  public:
+    AliLVTreeMessenger(AliLVTree* lvTree);
+    // --> protected   
+    // AliLVTreeMessenger();
+    // AliLVTreeMessenger(const AliLVTreeMessenger& right);
+    virtual ~AliLVTreeMessenger();
+
+    // methods
+    virtual void SetNewValue(G4UIcommand* command, G4String newValues);
+
+  protected:
+    AliLVTreeMessenger();
+    AliLVTreeMessenger(const AliLVTreeMessenger& right);
+
+    // operators
+    AliLVTreeMessenger& operator=(const AliLVTreeMessenger &right);
+             
+  private:
+    // data members
+    AliLVTree*                fLVTree;               //associated class
+    G4LogicalVolume*          fCurrentVolume;        //current logical volume
+    G4UIdirectory*            fDirectory;            //command directory
+    G4UIcmdWithAString*       fSetCurrentLVCmd;      //command: setVolume
+    G4UIcmdWithoutParameter*  fListCmd;              //command: list
+    G4UIcmdWithoutParameter*  fListLongCmd;          //command: listLong
+    G4UIcmdWithAString*       fListDaughtersCmd;     //command: listDaughters
+    G4UIcmdWithAString*       fListLongDaughtersCmd; //command: listLongDaughters  
+
+#ifdef G4VIS_USE
+    G4UIcmdWithABool*         fSetLVTreeVisibilityCmd; //command: setLVTreeVisibility   
+    G4UIcmdWithABool*         fSetVolVisibilityCmd;    //command: setVolVisibility
+    G4UIcmdWithAString*       fSetLVTreeColourCmd;     //command: setLVTreeColour  
+    G4UIcmdWithAString*       fSetVolColourCmd;        //command: setVolColour
+#endif //G4VIS_USE
+};
+
+#endif //ALI_LV_TREE_MESSENGER_H
+