X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STRUCT%2FAliALIFE.cxx;h=37dad7f74e2a76cec96f86233bda38bf30a60acd;hb=c9d0ec1fcefa5f2c374637f228d48443c85f55c0;hp=79822f0e2903495f76f31148c98a3609834bfb1f;hpb=886e839a5bad0f34222eeaca98164c11d3d4e893;p=u%2Fmrichter%2FAliRoot.git diff --git a/STRUCT/AliALIFE.cxx b/STRUCT/AliALIFE.cxx index 79822f0e290..37dad7f74e2 100644 --- a/STRUCT/AliALIFE.cxx +++ b/STRUCT/AliALIFE.cxx @@ -13,43 +13,64 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* -$Log$ -Revision 1.1 2000/07/26 15:10:57 morsch -Helper class to write geometry in ALIFE format in parallel with Geant geometry definition. +/* $Id$ */ -*/ +//---------------------------------------------------------------------- +// Helper class to write geometry in ALIFE format +// in parallel with Geant geometry definition. +// Author: A.Morsch +//---------------------------------------------------------------------- #include 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 @@ -76,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++); @@ -112,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 @@ -172,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 @@ -191,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) { @@ -203,22 +229,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) { @@ -233,18 +258,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; } @@ -265,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 // @@ -315,7 +338,7 @@ void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr, } } } else { - strcpy(nameCin,fDefaultVolume1); + fDefaultVolume1 = nameCin; } @@ -349,7 +372,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 @@ -363,9 +386,11 @@ 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; @@ -379,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 @@ -395,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 @@ -417,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); @@ -425,7 +453,7 @@ void AliALIFE::Comment(char* Comment) } -void AliALIFE::Finish() +void AliALIFE::Finish(Bool_t iremove) { // Finish geometry definition char s[BUFSIZ]; @@ -438,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"); +}