]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - AliGeant4/AliLVStructure.cxx
added comment lines separating methods
[u/mrichter/AliRoot.git] / AliGeant4 / AliLVStructure.cxx
index 7036b82bb4ee773fc44aec7308372e20026d9f61..e73ea43bbaaa6266acfb1d68ea4a2e7a3d9a74ac 100644 (file)
@@ -12,8 +12,9 @@
 #include <G4Colour.hh>
 #include <G4VisAttributes.hh>
 #endif //ALICE_VISUALIZE
-#include <globals.hh>
+#include <G4LogicalVolume.hh>
 
+//_____________________________________________________________________________
 AliLVStructure::AliLVStructure(G4String path)
   : fPathName(path),
     fDirName(path),
@@ -29,33 +30,19 @@ AliLVStructure::AliLVStructure(G4String path)
   }
 }
 
+//_____________________________________________________________________________
 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;
+  // copy stuff
+  *this = right;
 }
 
+//_____________________________________________________________________________
 AliLVStructure::AliLVStructure() {
 //
 }
 
+//_____________________________________________________________________________
 AliLVStructure::~AliLVStructure() {
 //
   fStructures.clearAndDestroy();
@@ -64,6 +51,7 @@ AliLVStructure::~AliLVStructure() {
 
 // operators
 
+//_____________________________________________________________________________
 AliLVStructure& AliLVStructure::operator=(const AliLVStructure &right)
 {
   // check assignement to self
@@ -92,6 +80,7 @@ AliLVStructure& AliLVStructure::operator=(const AliLVStructure &right)
   return *this;
 }
 
+//_____________________________________________________________________________
 G4int AliLVStructure::operator==(const AliLVStructure &right) const
 {
   // check == to self
@@ -102,6 +91,7 @@ G4int AliLVStructure::operator==(const AliLVStructure &right) const
 
 // private methods
 
+//_____________________________________________________________________________
 AliLVStructure* AliLVStructure::FindSubDirectory(G4String subDir)
 {
 // Finds the subdirectory.
@@ -113,6 +103,7 @@ AliLVStructure* AliLVStructure::FindSubDirectory(G4String subDir)
   return 0;
 }
 
+//_____________________________________________________________________________
 G4String AliLVStructure::ExtractDirName(G4String name)
 {
 // Extracts the directory name from the path.
@@ -126,6 +117,7 @@ G4String AliLVStructure::ExtractDirName(G4String name)
 
 // public methods
 
+//_____________________________________________________________________________
 void AliLVStructure::AddNewVolume(G4LogicalVolume* lv, 
                       G4String treeStructure)
 {
@@ -160,6 +152,7 @@ void AliLVStructure::AddNewVolume(G4LogicalVolume* lv,
   }
 }
 
+//_____________________________________________________________________________
 G4LogicalVolume* AliLVStructure::GetVolume(G4String lvName)
 {
 // Returns logical volume of lvName if present in the structure,
@@ -173,6 +166,7 @@ G4LogicalVolume* AliLVStructure::GetVolume(G4String lvName)
   return 0;
 }
 
+//_____________________________________________________________________________
 G4LogicalVolume* AliLVStructure::FindVolume(G4String name)
 {
 // Finds logical volume of given name in all structure tree.
@@ -206,6 +200,7 @@ G4LogicalVolume* AliLVStructure::FindVolume(G4String name)
   }
 }
 
+//_____________________________________________________________________________
 void AliLVStructure::ListTree() const
 {
 // Prints LV tree structure.
@@ -220,6 +215,7 @@ void AliLVStructure::ListTree() const
   }
 }
         
+//_____________________________________________________________________________
 void AliLVStructure::ListTreeLong() const
 {
 // Prints LV tree structure with number of
@@ -236,6 +232,7 @@ void AliLVStructure::ListTreeLong() const
   }
 }
         
+//_____________________________________________________________________________
 void AliLVStructure::SetVerboseLevel(G4int verbose) 
 {
 // Sets verbose level.
@@ -248,6 +245,7 @@ void AliLVStructure::SetVerboseLevel(G4int verbose)
 }
 
 #ifdef ALICE_VISUALIZE
+//_____________________________________________________________________________
 void AliLVStructure::SetTreeVisibility(G4bool visibility)       
 {
 // Sets visibility to all logical volumes in the structure 
@@ -257,11 +255,16 @@ void AliLVStructure::SetTreeVisibility(G4bool visibility)
   for (G4int i=0; i<fLogicalVolumes.entries(); i++) {
     G4LogicalVolume* lv = fLogicalVolumes(i);
 
-    const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes ();
-    G4Colour colour   = kpVisAttributes->GetColour();
+    const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes();
+    G4VisAttributes* newVisAttributes; 
+    if (kpVisAttributes) {
+      G4Colour colour   = kpVisAttributes->GetColour();
+      newVisAttributes = new G4VisAttributes(colour); 
+    }
+    else
+      newVisAttributes = new G4VisAttributes();
     delete kpVisAttributes;
 
-    G4VisAttributes* newVisAttributes = new G4VisAttributes(colour); 
     newVisAttributes->SetVisibility(visibility); 
 
     lv->SetVisAttributes(newVisAttributes);
@@ -271,6 +274,7 @@ void AliLVStructure::SetTreeVisibility(G4bool visibility)
   }
 }
 
+//_____________________________________________________________________________
 void AliLVStructure::SetTreeColour(G4String colName)
 {
 // Sets colour specified  by name to all logical volumes
@@ -281,11 +285,15 @@ void AliLVStructure::SetTreeColour(G4String colName)
     G4LogicalVolume* lv = fLogicalVolumes(i);
 
     const G4VisAttributes* kpVisAttributes = lv->GetVisAttributes ();
-    G4bool oldVisibility = kpVisAttributes->IsVisible();
+    G4VisAttributes* newVisAttributes; 
+    if (kpVisAttributes) {
+      G4bool oldVisibility = kpVisAttributes->IsVisible();
+      newVisAttributes = new G4VisAttributes(oldVisibility); 
+    }
+    else
+      newVisAttributes = new G4VisAttributes();
     delete kpVisAttributes;
 
-    G4VisAttributes* newVisAttributes = new G4VisAttributes(oldVisibility); 
-
     AliColourStore* pColours = AliColourStore::Instance();
     G4Colour colour = pColours->GetColour(colName);
     newVisAttributes->SetColour(colour);