]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STRUCT/AliALIFE.cxx
Problem found with gcc (4.0.2) and corrected by Ivana Hrivnacova.
[u/mrichter/AliRoot.git] / STRUCT / AliALIFE.cxx
index 785153c6ea00e8fa64b4e2d539c2d3e134dfba9d..43cd60080c68cd14cef5d3d50a7981ff8ce65615 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-*/
+/* $Id$ */
+
+//----------------------------------------------------------------------
+// Helper class to write geometry in ALIFE format
+// in parallel with Geant geometry definition.
+// Author: A.Morsch
+//----------------------------------------------------------------------
 
 #include <AliALIFE.h>
 
 ClassImp(AliALIFE)
 
-    AliALIFE::AliALIFE(const char* file1, const char* file2)
+
+AliALIFE::AliALIFE(const char* file1, const char* file2)
 {  
 // Constructor
     fNBodies = 0; 
@@ -36,7 +41,7 @@ ClassImp(AliALIFE)
     fDefaultVolume2 = "DEFAU2";    
 }
 
-    AliALIFE::AliALIFE()
+AliALIFE::AliALIFE()
 {
 // Default constructor
     fBodyFile   = "FlukaBody.inp";  
@@ -73,13 +78,15 @@ void AliALIFE::VolumeHeader()
 void AliALIFE:: Cylinder(Float_t rmin, Float_t rmax, 
                         Float_t zmin, Float_t zmax, 
                         Float_t pos[3], 
-                        char* Material, char* Field, char* Cuts) 
+                        const char* Material,
+                        const char* Field,
+                        const char* Cuts) 
 {
 // Simple cylinder
 //
 // Bodies
 // ^^^^^^
-    char name1[5], name2[5], name3[5], name4[5];
+    char name1[6], name2[6], name3[6], name4[6];
 
 //  outer radius
     sprintf(name1, "R%4.4d", fNBodies++);
@@ -109,8 +116,8 @@ void AliALIFE:: Cylinder(Float_t rmin, Float_t rmax,
 }
 
 void AliALIFE::OnionCylinder(Float_t* r, Int_t nr, Float_t zmin, Float_t zmax,
-                            Float_t pos[3], char** Materials, 
-                            char** Fields, char** Cuts) 
+                            Float_t pos[3], const char** Materials, 
+                            const char** Fields, const char** Cuts) 
 {
 //
 // Concentric cylinders
@@ -160,7 +167,7 @@ void AliALIFE::OnionCylinder(Float_t* r, Int_t nr, Float_t zmin, Float_t zmax,
            fprintf(fFile2,"+%5s-%5s+%5s\n", nameZou, nameZin, nameRou);
        }
        fprintf(fFile2,"\n");
-       nameRin=nameRou;
+       strcpy(nameRin,nameRou);
     }
 }
 
@@ -169,7 +176,9 @@ void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
                     Float_t rmax1, Float_t rmax2,
                     Float_t zmin, Float_t zmax, 
                     Float_t pos[3], 
-                    char* Material, char* Field, char* Cuts) 
+                    const char* Material,
+                    const char* Field,
+                    const char* Cuts) 
 {
 // Simple cone 
 
@@ -188,6 +197,7 @@ void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
     
 //  outer radius
     d=zmax-zmin;
+    sprintf(nameCou, "C%4.4d", fNBodies++);
     if (rmax1 >= 0. && rmax2 >= 0.) {
        if (rmax1!=rmax2) {
            if (rmax1 > rmax2) {
@@ -200,22 +210,21 @@ void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
                r1=rmax2;
                r2=rmax1;
            }
-           sprintf(nameCou, "C%4.4d", fNBodies++);
            fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
                    nameCou, pos[0], pos[1], pos[2], 0., 0., d); 
            fprintf(fFile1,"         %10.3f%10.3f\n",r1,r2);
        } else {
-           sprintf(nameCou, "C%4.4d", fNBodies++);
            fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
                    nameCou, pos[0], pos[1], rmax1); 
        } 
     }else {
-       strcpy(nameCou,fDefaultVolume1);
+      fDefaultVolume1 = nameCou;
     }
 
     
     
 // inner radius
+    sprintf(nameCin, "C%4.4d", fNBodies++);
     if (rmin1 >= 0. && rmin2 >= 0.) {
        if (rmin1!=rmin2) {
            if (rmin1 != 0 && rmin2 !=0) {
@@ -230,18 +239,16 @@ void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
                    r2=rmin1;
                    d=-d;
                }
-               sprintf(nameCin, "C%4.4d", fNBodies++);
                fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
                        nameCin, pos[0], pos[1], pos[2], 0., 0., d); 
                fprintf(fFile1,"         %10.3f%10.3f\n",r1,r2);
            } 
        } else {
-           sprintf(nameCin, "C%4.4d", fNBodies++);
            fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
                    nameCin, pos[0], pos[1], rmin1); 
        } 
     }else {
-       strcpy(nameCin,fDefaultVolume2);
+      fDefaultVolume2 = nameCin;
     }
 
 
@@ -262,8 +269,8 @@ void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
 
 void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr, 
                          Float_t zmin, Float_t zmax,
-                         Float_t pos[3], char** Materials, char** Fields,
-                         char** Cuts) 
+                         Float_t pos[3], const char** Materials,
+                         const char** Fields, const char** Cuts) 
 {
 // Concentric cones
 //
@@ -312,7 +319,7 @@ void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr,
            }
        }
     } else {
-       strcpy(nameCin,fDefaultVolume1);
+      fDefaultVolume1 = nameCin;
     }
     
     
@@ -346,7 +353,7 @@ void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr,
                        nameCou, pos[0], pos[1], r1[i]); 
            }
        } else {
-           strcpy(nameCou,fDefaultVolume1);
+         fDefaultVolume1 = nameCou;
        }
        
 // Volumes
@@ -360,15 +367,17 @@ void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr,
            fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
            fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
        }
-       if (hasInner) {
-           fprintf(fFile2,"+%5s-%5s+%5s-%5s\n", 
+       if (hasInner || isCylinder) {
+           if (!isCylinder) fprintf(fFile2,"+%5s-%5s+%5s-%5s\n", 
                    nameCou, nameCin, nameZou, nameZin);
+           if (isCylinder)  fprintf(fFile2,"+%5s+%5s-%5s\n",
+                   nameCou, nameZou, nameZin); 
        } else {
            fprintf(fFile2,"+%5s\n", nameCou);
            hasInner=kTRUE;
        }
        fprintf(fFile2,"\n");        
-       nameCin=nameCou;
+       strcpy(nameCin,nameCou);
     }
 }
 
@@ -376,7 +385,9 @@ void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr,
 void AliALIFE::PolyCone(Float_t* rmin, Float_t* rmax, Float_t* z, 
                        Int_t nz,
                        Float_t pos[3], 
-                       char* Material, char* Field, char* Cuts) 
+                       const char* Material,
+                       const char* Field,
+                       const char* Cuts) 
 {
 //
 // Equivalent to the Geant3 PCON
@@ -392,7 +403,8 @@ void AliALIFE::PolyCone(Float_t* rmin, Float_t* rmax, Float_t* z,
 void AliALIFE::OnionPolyCone(Float_t** r, Float_t* z,
                             Int_t nr, Int_t nz,
                             Float_t pos[3], 
-                            char** Materials, char** Fields=0, char** Cuts)
+                            const char** Materials,
+                            const char** Fields,const  char** Cuts)
 {
 //
 // Concentric PCONS
@@ -414,7 +426,7 @@ void AliALIFE::OnionPolyCone(Float_t** r, Float_t* z,
     }
 }
 
-void AliALIFE::Comment(char* Comment)
+void AliALIFE::Comment(const char* Comment)
 {
 // Insert comment line
     fprintf(fFile1,"*%s\n", Comment);        
@@ -422,7 +434,7 @@ void AliALIFE::Comment(char* Comment)
 }
 
 
-void AliALIFE::Finish()
+void AliALIFE::Finish(Bool_t iremove)
 {
 // Finish geometry definition
     char s[BUFSIZ];
@@ -435,8 +447,19 @@ void AliALIFE::Finish()
     
     fclose(fFile1);
     fclose(fFile2);    
+    if (iremove) {
+       remove(fVolumeFile);
+       remove(fBodyFile);
+    }
 }
 
+void AliALIFE::Copy(TObject&) const
+{
+    //
+    // Copy 
+    //
+    Fatal("Copy","Not implemented!\n");
+}