]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STRUCT/AliALIFE.cxx
bugfix, added missing header file
[u/mrichter/AliRoot.git] / STRUCT / AliALIFE.cxx
index b8361ea1522d43dc982fc37a005a014eff512613..37dad7f74e2a76cec96f86233bda38bf30a60acd 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
+/* $Id$ */
 
-Revision 1.3  2001/10/31 15:56:54  morsch
-Correction in OnionCone.
-
-Revision 1.2  2000/10/10 06:40:25  hristov
-Bug fixes
-
-Revision 1.1  2000/07/26 15:10:57  morsch
-Helper class to write geometry in ALIFE format in parallel with Geant geometry definition.
-
-*/
+//----------------------------------------------------------------------
+// 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):
+    fNBodies(0), 
+    fNVolumes(0), 
+    fBodyFile(file1),
+    fVolumeFile(file2),
+    fFile1(fopen(fBodyFile,"w")),
+    fFile2(fopen(fVolumeFile,"w")),
+    fDefaultVolume1("DEFAU1"),
+    fDefaultVolume2("DEFAU2")    
 {  
 // Constructor
-    fNBodies = 0; 
-    fNVolumes= 0; 
-    fBodyFile   = file1;   // File for Fluka bodies
-    fVolumeFile = file2;
-    fFile1=fopen(fBodyFile,"w");
-    fFile2=fopen(fVolumeFile,"w");
     BodyHeader();
     VolumeHeader();
-    fDefaultVolume1 = "DEFAU1";
-    fDefaultVolume2 = "DEFAU2";    
 }
 
-    AliALIFE::AliALIFE()
+AliALIFE::AliALIFE():
+    fNBodies(0), 
+    fNVolumes(0), 
+    fBodyFile("FlukaBody.inp"),
+    fVolumeFile("FlukaVolume.inp"),
+    fFile1(fopen(fBodyFile,"w")),
+    fFile2(fopen(fVolumeFile,"w")),
+    fDefaultVolume1("DEFAU1"),
+    fDefaultVolume2("DEFAU2")    
 {
 // Default constructor
-    fBodyFile   = "FlukaBody.inp";  
-    fVolumeFile = "FlukaVolume.inp";
-    fFile1=fopen(fBodyFile,"w");
-    fFile2=fopen(fVolumeFile,"w");
     BodyHeader();
     VolumeHeader();
 }
 
+
+AliALIFE::AliALIFE(const AliALIFE &rhs): 
+    TObject(rhs),
+    fNBodies(0), 
+    fNVolumes(0), 
+    fBodyFile(0),
+    fVolumeFile(0),
+    fFile1(0),
+    fFile2(0),
+    fDefaultVolume1(0),
+    fDefaultVolume2(0)   
+{
+    // Copy Constructor
+    rhs.Copy(*this);
+}
+
 void AliALIFE::BodyHeader()
 {
 // Write header for body definitions
@@ -83,13 +97,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++);
@@ -119,8 +135,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
@@ -179,7 +195,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 
 
@@ -198,6 +216,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) {
@@ -210,12 +229,10 @@ 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); 
        } 
@@ -226,6 +243,7 @@ void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
     
     
 // inner radius
+    sprintf(nameCin, "C%4.4d", fNBodies++);
     if (rmin1 >= 0. && rmin2 >= 0.) {
        if (rmin1!=rmin2) {
            if (rmin1 != 0 && rmin2 !=0) {
@@ -240,13 +258,11 @@ 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); 
        } 
@@ -272,8 +288,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
 //
@@ -388,7 +404,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
@@ -404,7 +422,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, char** Cuts)
+                            const char** Materials,
+                            const char** Fields,const  char** Cuts)
 {
 //
 // Concentric PCONS
@@ -426,7 +445,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);        
@@ -434,7 +453,7 @@ void AliALIFE::Comment(char* Comment)
 }
 
 
-void AliALIFE::Finish()
+void AliALIFE::Finish(Bool_t iremove)
 {
 // Finish geometry definition
     char s[BUFSIZ];
@@ -447,8 +466,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");
+}