1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 Revision 1.1 2000/07/26 15:10:57 morsch
19 Helper class to write geometry in ALIFE format in parallel with Geant geometry definition.
27 AliALIFE::AliALIFE(const char* file1, const char* file2)
32 fBodyFile = file1; // File for Fluka bodies
34 fFile1=fopen(fBodyFile,"w");
35 fFile2=fopen(fVolumeFile,"w");
38 fDefaultVolume1 = "DEFAU1";
39 fDefaultVolume2 = "DEFAU2";
44 // Default constructor
45 fBodyFile = "FlukaBody.inp";
46 fVolumeFile = "FlukaVolume.inp";
47 fFile1=fopen(fBodyFile,"w");
48 fFile2=fopen(fVolumeFile,"w");
53 void AliALIFE::BodyHeader()
55 // Write header for body definitions
56 fprintf(fFile1,"*\n");
57 fprintf(fFile1,"GEOBEGIN COMBINAT\n");
58 fprintf(fFile1," 0 0 AliRoot Generated\n");
59 fprintf(fFile1,"*\n");
60 fprintf(fFile1,"*== Body Definitions ================================================\n");
61 fprintf(fFile1,"*\n");
66 void AliALIFE::VolumeHeader()
68 // Write header for region (volume) definitions
69 fprintf(fFile2,"REGIONS\n");
70 fprintf(fFile2,"*\n");
71 fprintf(fFile2,"*== Region Definitions =================================================\n");
72 fprintf(fFile2,"*\n");
76 void AliALIFE:: Cylinder(Float_t rmin, Float_t rmax,
77 Float_t zmin, Float_t zmax,
79 char* Material, char* Field, char* Cuts)
85 char name1[5], name2[5], name3[5], name4[5];
88 sprintf(name1, "R%4.4d", fNBodies++);
89 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name1, pos[0], pos[1], rmax); // inner radius
90 sprintf(name2, "R%4.4d", fNBodies++);
91 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name2, pos[0], pos[1], rmin);
93 sprintf(name3, "Z%4.4d", fNBodies++);
94 fprintf(fFile1,"%5s XYP%10.3f\n",name3, zmax);
96 sprintf(name4, "Z%4.4d", fNBodies++);
97 fprintf(fFile1,"%5s XYP%10.3f\n",name4, zmin);
102 fprintf(fFile2,">%s:%s\n", Material, Field);
103 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
104 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
106 fprintf(fFile2,"+%s-%s+%s-%s\n", name1, name2, name3, name4);
108 fprintf(fFile2,"+%s+%s-%s\n", name1, name3, name4);
111 fprintf(fFile2,"\n");
114 void AliALIFE::OnionCylinder(Float_t* r, Int_t nr, Float_t zmin, Float_t zmax,
115 Float_t pos[3], char** Materials,
116 char** Fields, char** Cuts)
119 // Concentric cylinders
124 char nameRin[6], nameRou[6], nameZin[6], nameZou[6];
127 sprintf(nameZou, "Z%4.4d", fNBodies++);
130 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
132 sprintf(nameZin, "Z%4.4d", fNBodies++);
134 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
137 sprintf(nameRin, "R%4.4d", fNBodies++);
139 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",nameRin, pos[0], pos[1], r[0]);
142 for (i=1; i<nr; i++) {
144 sprintf(nameRou, "R%4.4d", fNBodies++);
146 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
147 nameRou, pos[0], pos[1], r[i]);
151 if (Fields && Cuts) {
152 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
153 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
154 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
156 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
157 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
158 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
161 fprintf(fFile2,"+%5s-%5s+%5s-%5s\n", nameZou, nameZin, nameRou, nameRin);
163 fprintf(fFile2,"+%5s-%5s+%5s\n", nameZou, nameZin, nameRou);
165 fprintf(fFile2,"\n");
166 strcpy(nameRin,nameRou);
171 void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
172 Float_t rmax1, Float_t rmax2,
173 Float_t zmin, Float_t zmax,
175 char* Material, char* Field, char* Cuts)
182 char nameCou[6], nameCin[6];
184 char nameZin[6], nameZou[6];
186 sprintf(nameZou, "Z%4.4d", fNBodies++);
187 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
189 sprintf(nameZin, "Z%4.4d", fNBodies++);
190 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
194 if (rmax1 >= 0. && rmax2 >= 0.) {
206 sprintf(nameCou, "C%4.4d", fNBodies++);
207 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
208 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
209 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
211 sprintf(nameCou, "C%4.4d", fNBodies++);
212 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
213 nameCou, pos[0], pos[1], rmax1);
216 strcpy(nameCou,fDefaultVolume1);
222 if (rmin1 >= 0. && rmin2 >= 0.) {
224 if (rmin1 != 0 && rmin2 !=0) {
236 sprintf(nameCin, "C%4.4d", fNBodies++);
237 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
238 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
239 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
242 sprintf(nameCin, "C%4.4d", fNBodies++);
243 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
244 nameCin, pos[0], pos[1], rmin1);
247 strcpy(nameCin,fDefaultVolume2);
255 fprintf(fFile2,">%s:%s\n", Material, Field);
256 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
257 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
258 if (rmin1 != 0 && rmin2 !=0) {
259 fprintf(fFile2,"+%s-%s+%s-%s\n", nameCou, nameCin, nameZou, nameZin);
261 fprintf(fFile2,"+%s+%s-%s\n", nameCou, nameZou, nameZin);
263 fprintf(fFile2,"\n");
266 void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr,
267 Float_t zmin, Float_t zmax,
268 Float_t pos[3], char** Materials, char** Fields,
273 char nameCin[6], nameCou[6], nameZin[6], nameZou[6];
277 Float_t ri1, ri2, ro1, ro2, d;
280 sprintf(nameZou, "Z%4.4d", fNBodies++);
281 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
283 sprintf(nameZin, "Z%4.4d", fNBodies++);
284 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
288 Bool_t hasInner=kFALSE;
289 Bool_t isCylinder=kFALSE;
290 if (r1[0]>=0 && r2[0]>=0) {
291 if (r1[0] != 0. && r2[0] !=0.) {
304 sprintf(nameCin, "C%4.4d", fNBodies++);
306 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
307 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
308 fprintf(fFile1," %10.3f%10.3f\n",ri1,ri2);
311 sprintf(nameCin, "C%4.4d", fNBodies++);
313 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
314 nameCin, pos[0], pos[1], r1[0]);
318 strcpy(nameCin,fDefaultVolume1);
325 for (i=1; i<nr; i++) {
326 if (r1[i] >= 0. && r2[i] >=0) {
339 sprintf(nameCou, "C%4.4d", fNBodies++);
341 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
342 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
343 fprintf(fFile1," %10.3f%10.3f\n",ro1,ro2);
346 sprintf(nameCou, "C%4.4d", fNBodies++);
348 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
349 nameCou, pos[0], pos[1], r1[i]);
352 strcpy(nameCou,fDefaultVolume1);
357 if (Fields && Cuts) {
358 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
359 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
360 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
362 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
363 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
364 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
367 fprintf(fFile2,"+%5s-%5s+%5s-%5s\n",
368 nameCou, nameCin, nameZou, nameZin);
370 fprintf(fFile2,"+%5s\n", nameCou);
373 fprintf(fFile2,"\n");
374 strcpy(nameCin,nameCou);
379 void AliALIFE::PolyCone(Float_t* rmin, Float_t* rmax, Float_t* z,
382 char* Material, char* Field, char* Cuts)
385 // Equivalent to the Geant3 PCON
387 for (i=0; i<nz-1; i++) {
388 // skip (z_i = z_i+1)
389 if (z[i] == z[i+1]) continue;
390 Cone(rmin[i], rmin[i+1], rmax[i], rmax[i+1], z[i], z[i+1], pos,
391 Material, Field, Cuts);
395 void AliALIFE::OnionPolyCone(Float_t** r, Float_t* z,
398 char** Materials, char** Fields, char** Cuts)
403 for (i=0; i<nz-1; i++) {
404 // skip (z_i = z_i+1)
405 if (z[i] == z[i+1]) continue;
406 for (j=0; j<nr-1; j++) {
407 if (Fields && Cuts) {
408 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
410 Materials[i], Fields[i], Cuts[i]);
412 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
420 void AliALIFE::Comment(char* Comment)
422 // Insert comment line
423 fprintf(fFile1,"*%s\n", Comment);
424 fprintf(fFile2,"*%s\n", Comment);
428 void AliALIFE::Finish()
430 // Finish geometry definition
432 fprintf(fFile1," END\n");
434 fFile2=fopen(fVolumeFile,"r");
435 while (fgets(s, BUFSIZ, fFile2)) {