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 **************************************************************************/
19 Revision 1.3 2001/10/31 15:56:54 morsch
20 Correction in OnionCone.
22 Revision 1.2 2000/10/10 06:40:25 hristov
25 Revision 1.1 2000/07/26 15:10:57 morsch
26 Helper class to write geometry in ALIFE format in parallel with Geant geometry definition.
34 AliALIFE::AliALIFE(const char* file1, const char* file2)
39 fBodyFile = file1; // File for Fluka bodies
41 fFile1=fopen(fBodyFile,"w");
42 fFile2=fopen(fVolumeFile,"w");
45 fDefaultVolume1 = "DEFAU1";
46 fDefaultVolume2 = "DEFAU2";
51 // Default constructor
52 fBodyFile = "FlukaBody.inp";
53 fVolumeFile = "FlukaVolume.inp";
54 fFile1=fopen(fBodyFile,"w");
55 fFile2=fopen(fVolumeFile,"w");
60 void AliALIFE::BodyHeader()
62 // Write header for body definitions
63 fprintf(fFile1,"*\n");
64 fprintf(fFile1,"GEOBEGIN COMBINAT\n");
65 fprintf(fFile1," 0 0 AliRoot Generated\n");
66 fprintf(fFile1,"*\n");
67 fprintf(fFile1,"*== Body Definitions ================================================\n");
68 fprintf(fFile1,"*\n");
73 void AliALIFE::VolumeHeader()
75 // Write header for region (volume) definitions
76 fprintf(fFile2,"REGIONS\n");
77 fprintf(fFile2,"*\n");
78 fprintf(fFile2,"*== Region Definitions =================================================\n");
79 fprintf(fFile2,"*\n");
83 void AliALIFE:: Cylinder(Float_t rmin, Float_t rmax,
84 Float_t zmin, Float_t zmax,
86 char* Material, char* Field, char* Cuts)
92 char name1[5], name2[5], name3[5], name4[5];
95 sprintf(name1, "R%4.4d", fNBodies++);
96 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name1, pos[0], pos[1], rmax); // inner radius
97 sprintf(name2, "R%4.4d", fNBodies++);
98 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name2, pos[0], pos[1], rmin);
100 sprintf(name3, "Z%4.4d", fNBodies++);
101 fprintf(fFile1,"%5s XYP%10.3f\n",name3, zmax);
103 sprintf(name4, "Z%4.4d", fNBodies++);
104 fprintf(fFile1,"%5s XYP%10.3f\n",name4, zmin);
109 fprintf(fFile2,">%s:%s\n", Material, Field);
110 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
111 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
113 fprintf(fFile2,"+%s-%s+%s-%s\n", name1, name2, name3, name4);
115 fprintf(fFile2,"+%s+%s-%s\n", name1, name3, name4);
118 fprintf(fFile2,"\n");
121 void AliALIFE::OnionCylinder(Float_t* r, Int_t nr, Float_t zmin, Float_t zmax,
122 Float_t pos[3], char** Materials,
123 char** Fields, char** Cuts)
126 // Concentric cylinders
131 char nameRin[6], nameRou[6], nameZin[6], nameZou[6];
134 sprintf(nameZou, "Z%4.4d", fNBodies++);
137 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
139 sprintf(nameZin, "Z%4.4d", fNBodies++);
141 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
144 sprintf(nameRin, "R%4.4d", fNBodies++);
146 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",nameRin, pos[0], pos[1], r[0]);
149 for (i=1; i<nr; i++) {
151 sprintf(nameRou, "R%4.4d", fNBodies++);
153 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
154 nameRou, pos[0], pos[1], r[i]);
158 if (Fields && Cuts) {
159 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
160 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
161 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
163 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
164 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
165 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
168 fprintf(fFile2,"+%5s-%5s+%5s-%5s\n", nameZou, nameZin, nameRou, nameRin);
170 fprintf(fFile2,"+%5s-%5s+%5s\n", nameZou, nameZin, nameRou);
172 fprintf(fFile2,"\n");
173 strcpy(nameRin,nameRou);
178 void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
179 Float_t rmax1, Float_t rmax2,
180 Float_t zmin, Float_t zmax,
182 char* Material, char* Field, char* Cuts)
189 char nameCou[6], nameCin[6];
191 char nameZin[6], nameZou[6];
193 sprintf(nameZou, "Z%4.4d", fNBodies++);
194 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
196 sprintf(nameZin, "Z%4.4d", fNBodies++);
197 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
201 if (rmax1 >= 0. && rmax2 >= 0.) {
213 sprintf(nameCou, "C%4.4d", fNBodies++);
214 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
215 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
216 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
218 sprintf(nameCou, "C%4.4d", fNBodies++);
219 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
220 nameCou, pos[0], pos[1], rmax1);
223 fDefaultVolume1 = nameCou;
229 if (rmin1 >= 0. && rmin2 >= 0.) {
231 if (rmin1 != 0 && rmin2 !=0) {
243 sprintf(nameCin, "C%4.4d", fNBodies++);
244 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
245 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
246 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
249 sprintf(nameCin, "C%4.4d", fNBodies++);
250 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
251 nameCin, pos[0], pos[1], rmin1);
254 fDefaultVolume2 = nameCin;
262 fprintf(fFile2,">%s:%s\n", Material, Field);
263 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
264 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
265 if (rmin1 != 0 && rmin2 !=0) {
266 fprintf(fFile2,"+%s-%s+%s-%s\n", nameCou, nameCin, nameZou, nameZin);
268 fprintf(fFile2,"+%s+%s-%s\n", nameCou, nameZou, nameZin);
270 fprintf(fFile2,"\n");
273 void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr,
274 Float_t zmin, Float_t zmax,
275 Float_t pos[3], char** Materials, char** Fields,
280 char nameCin[6], nameCou[6], nameZin[6], nameZou[6];
284 Float_t ri1, ri2, ro1, ro2, d;
287 sprintf(nameZou, "Z%4.4d", fNBodies++);
288 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
290 sprintf(nameZin, "Z%4.4d", fNBodies++);
291 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
295 Bool_t hasInner=kFALSE;
296 Bool_t isCylinder=kFALSE;
297 if (r1[0]>=0 && r2[0]>=0) {
298 if (r1[0] != 0. && r2[0] !=0.) {
311 sprintf(nameCin, "C%4.4d", fNBodies++);
313 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
314 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
315 fprintf(fFile1," %10.3f%10.3f\n",ri1,ri2);
318 sprintf(nameCin, "C%4.4d", fNBodies++);
320 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
321 nameCin, pos[0], pos[1], r1[0]);
325 fDefaultVolume1 = nameCin;
332 for (i=1; i<nr; i++) {
333 if (r1[i] >= 0. && r2[i] >=0) {
346 sprintf(nameCou, "C%4.4d", fNBodies++);
348 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
349 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
350 fprintf(fFile1," %10.3f%10.3f\n",ro1,ro2);
353 sprintf(nameCou, "C%4.4d", fNBodies++);
355 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
356 nameCou, pos[0], pos[1], r1[i]);
359 fDefaultVolume1 = nameCou;
364 if (Fields && Cuts) {
365 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
366 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
367 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
369 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
370 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
371 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
373 if (hasInner || isCylinder) {
374 if (!isCylinder) fprintf(fFile2,"+%5s-%5s+%5s-%5s\n",
375 nameCou, nameCin, nameZou, nameZin);
376 if (isCylinder) fprintf(fFile2,"+%5s+%5s-%5s\n",
377 nameCou, nameZou, nameZin);
379 fprintf(fFile2,"+%5s\n", nameCou);
382 fprintf(fFile2,"\n");
383 strcpy(nameCin,nameCou);
388 void AliALIFE::PolyCone(Float_t* rmin, Float_t* rmax, Float_t* z,
391 char* Material, char* Field, char* Cuts)
394 // Equivalent to the Geant3 PCON
396 for (i=0; i<nz-1; i++) {
397 // skip (z_i = z_i+1)
398 if (z[i] == z[i+1]) continue;
399 Cone(rmin[i], rmin[i+1], rmax[i], rmax[i+1], z[i], z[i+1], pos,
400 Material, Field, Cuts);
404 void AliALIFE::OnionPolyCone(Float_t** r, Float_t* z,
407 char** Materials, char** Fields, char** Cuts)
412 for (i=0; i<nz-1; i++) {
413 // skip (z_i = z_i+1)
414 if (z[i] == z[i+1]) continue;
415 for (j=0; j<nr-1; j++) {
416 if (Fields && Cuts) {
417 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
419 Materials[i], Fields[i], Cuts[i]);
421 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
429 void AliALIFE::Comment(char* Comment)
431 // Insert comment line
432 fprintf(fFile1,"*%s\n", Comment);
433 fprintf(fFile2,"*%s\n", Comment);
437 void AliALIFE::Finish()
439 // Finish geometry definition
441 fprintf(fFile1," END\n");
443 fFile2=fopen(fVolumeFile,"r");
444 while (fgets(s, BUFSIZ, fFile2)) {