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.3.6.1 2002/08/29 18:08:17 hristov
19 Replace strcpy by assignment operator
21 Revision 1.3 2001/10/31 15:56:54 morsch
22 Correction in OnionCone.
24 Revision 1.2 2000/10/10 06:40:25 hristov
27 Revision 1.1 2000/07/26 15:10:57 morsch
28 Helper class to write geometry in ALIFE format in parallel with Geant geometry definition.
36 AliALIFE::AliALIFE(const char* file1, const char* file2)
41 fBodyFile = file1; // File for Fluka bodies
43 fFile1=fopen(fBodyFile,"w");
44 fFile2=fopen(fVolumeFile,"w");
47 fDefaultVolume1 = "DEFAU1";
48 fDefaultVolume2 = "DEFAU2";
53 // Default constructor
54 fBodyFile = "FlukaBody.inp";
55 fVolumeFile = "FlukaVolume.inp";
56 fFile1=fopen(fBodyFile,"w");
57 fFile2=fopen(fVolumeFile,"w");
62 void AliALIFE::BodyHeader()
64 // Write header for body definitions
65 fprintf(fFile1,"*\n");
66 fprintf(fFile1,"GEOBEGIN COMBINAT\n");
67 fprintf(fFile1," 0 0 AliRoot Generated\n");
68 fprintf(fFile1,"*\n");
69 fprintf(fFile1,"*== Body Definitions ================================================\n");
70 fprintf(fFile1,"*\n");
75 void AliALIFE::VolumeHeader()
77 // Write header for region (volume) definitions
78 fprintf(fFile2,"REGIONS\n");
79 fprintf(fFile2,"*\n");
80 fprintf(fFile2,"*== Region Definitions =================================================\n");
81 fprintf(fFile2,"*\n");
85 void AliALIFE:: Cylinder(Float_t rmin, Float_t rmax,
86 Float_t zmin, Float_t zmax,
88 char* Material, char* Field, char* Cuts)
94 char name1[5], name2[5], name3[5], name4[5];
97 sprintf(name1, "R%4.4d", fNBodies++);
98 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name1, pos[0], pos[1], rmax); // inner radius
99 sprintf(name2, "R%4.4d", fNBodies++);
100 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name2, pos[0], pos[1], rmin);
102 sprintf(name3, "Z%4.4d", fNBodies++);
103 fprintf(fFile1,"%5s XYP%10.3f\n",name3, zmax);
105 sprintf(name4, "Z%4.4d", fNBodies++);
106 fprintf(fFile1,"%5s XYP%10.3f\n",name4, zmin);
111 fprintf(fFile2,">%s:%s\n", Material, Field);
112 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
113 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
115 fprintf(fFile2,"+%s-%s+%s-%s\n", name1, name2, name3, name4);
117 fprintf(fFile2,"+%s+%s-%s\n", name1, name3, name4);
120 fprintf(fFile2,"\n");
123 void AliALIFE::OnionCylinder(Float_t* r, Int_t nr, Float_t zmin, Float_t zmax,
124 Float_t pos[3], char** Materials,
125 char** Fields, char** Cuts)
128 // Concentric cylinders
133 char nameRin[6], nameRou[6], nameZin[6], nameZou[6];
136 sprintf(nameZou, "Z%4.4d", fNBodies++);
139 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
141 sprintf(nameZin, "Z%4.4d", fNBodies++);
143 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
146 sprintf(nameRin, "R%4.4d", fNBodies++);
148 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",nameRin, pos[0], pos[1], r[0]);
151 for (i=1; i<nr; i++) {
153 sprintf(nameRou, "R%4.4d", fNBodies++);
155 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
156 nameRou, pos[0], pos[1], r[i]);
160 if (Fields && Cuts) {
161 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
162 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
163 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
165 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
166 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
167 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
170 fprintf(fFile2,"+%5s-%5s+%5s-%5s\n", nameZou, nameZin, nameRou, nameRin);
172 fprintf(fFile2,"+%5s-%5s+%5s\n", nameZou, nameZin, nameRou);
174 fprintf(fFile2,"\n");
175 strcpy(nameRin,nameRou);
180 void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
181 Float_t rmax1, Float_t rmax2,
182 Float_t zmin, Float_t zmax,
184 char* Material, char* Field, char* Cuts)
191 char nameCou[6], nameCin[6];
193 char nameZin[6], nameZou[6];
195 sprintf(nameZou, "Z%4.4d", fNBodies++);
196 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
198 sprintf(nameZin, "Z%4.4d", fNBodies++);
199 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
203 if (rmax1 >= 0. && rmax2 >= 0.) {
215 sprintf(nameCou, "C%4.4d", fNBodies++);
216 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
217 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
218 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
220 sprintf(nameCou, "C%4.4d", fNBodies++);
221 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
222 nameCou, pos[0], pos[1], rmax1);
225 fDefaultVolume1 = nameCou;
231 if (rmin1 >= 0. && rmin2 >= 0.) {
233 if (rmin1 != 0 && rmin2 !=0) {
245 sprintf(nameCin, "C%4.4d", fNBodies++);
246 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
247 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
248 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
251 sprintf(nameCin, "C%4.4d", fNBodies++);
252 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
253 nameCin, pos[0], pos[1], rmin1);
256 fDefaultVolume2 = nameCin;
264 fprintf(fFile2,">%s:%s\n", Material, Field);
265 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
266 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
267 if (rmin1 != 0 && rmin2 !=0) {
268 fprintf(fFile2,"+%s-%s+%s-%s\n", nameCou, nameCin, nameZou, nameZin);
270 fprintf(fFile2,"+%s+%s-%s\n", nameCou, nameZou, nameZin);
272 fprintf(fFile2,"\n");
275 void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr,
276 Float_t zmin, Float_t zmax,
277 Float_t pos[3], char** Materials, char** Fields,
282 char nameCin[6], nameCou[6], nameZin[6], nameZou[6];
286 Float_t ri1, ri2, ro1, ro2, d;
289 sprintf(nameZou, "Z%4.4d", fNBodies++);
290 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
292 sprintf(nameZin, "Z%4.4d", fNBodies++);
293 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
297 Bool_t hasInner=kFALSE;
298 Bool_t isCylinder=kFALSE;
299 if (r1[0]>=0 && r2[0]>=0) {
300 if (r1[0] != 0. && r2[0] !=0.) {
313 sprintf(nameCin, "C%4.4d", fNBodies++);
315 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
316 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
317 fprintf(fFile1," %10.3f%10.3f\n",ri1,ri2);
320 sprintf(nameCin, "C%4.4d", fNBodies++);
322 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
323 nameCin, pos[0], pos[1], r1[0]);
327 fDefaultVolume1 = nameCin;
334 for (i=1; i<nr; i++) {
335 if (r1[i] >= 0. && r2[i] >=0) {
348 sprintf(nameCou, "C%4.4d", fNBodies++);
350 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
351 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
352 fprintf(fFile1," %10.3f%10.3f\n",ro1,ro2);
355 sprintf(nameCou, "C%4.4d", fNBodies++);
357 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
358 nameCou, pos[0], pos[1], r1[i]);
361 fDefaultVolume1 = nameCou;
366 if (Fields && Cuts) {
367 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
368 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
369 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
371 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
372 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
373 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
375 if (hasInner || isCylinder) {
376 if (!isCylinder) fprintf(fFile2,"+%5s-%5s+%5s-%5s\n",
377 nameCou, nameCin, nameZou, nameZin);
378 if (isCylinder) fprintf(fFile2,"+%5s+%5s-%5s\n",
379 nameCou, nameZou, nameZin);
381 fprintf(fFile2,"+%5s\n", nameCou);
384 fprintf(fFile2,"\n");
385 strcpy(nameCin,nameCou);
390 void AliALIFE::PolyCone(Float_t* rmin, Float_t* rmax, Float_t* z,
393 char* Material, char* Field, char* Cuts)
396 // Equivalent to the Geant3 PCON
398 for (i=0; i<nz-1; i++) {
399 // skip (z_i = z_i+1)
400 if (z[i] == z[i+1]) continue;
401 Cone(rmin[i], rmin[i+1], rmax[i], rmax[i+1], z[i], z[i+1], pos,
402 Material, Field, Cuts);
406 void AliALIFE::OnionPolyCone(Float_t** r, Float_t* z,
409 char** Materials, char** Fields, char** Cuts)
414 for (i=0; i<nz-1; i++) {
415 // skip (z_i = z_i+1)
416 if (z[i] == z[i+1]) continue;
417 for (j=0; j<nr-1; j++) {
418 if (Fields && Cuts) {
419 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
421 Materials[i], Fields[i], Cuts[i]);
423 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
431 void AliALIFE::Comment(char* Comment)
433 // Insert comment line
434 fprintf(fFile1,"*%s\n", Comment);
435 fprintf(fFile2,"*%s\n", Comment);
439 void AliALIFE::Finish()
441 // Finish geometry definition
443 fprintf(fFile1," END\n");
445 fFile2=fopen(fVolumeFile,"r");
446 while (fgets(s, BUFSIZ, fFile2)) {