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 **************************************************************************/
24 AliALIFE::AliALIFE(const char* file1, const char* file2)
29 fBodyFile = file1; // File for Fluka bodies
31 fFile1=fopen(fBodyFile,"w");
32 fFile2=fopen(fVolumeFile,"w");
35 fDefaultVolume1 = "DEFAU1";
36 fDefaultVolume2 = "DEFAU2";
41 // Default constructor
42 fBodyFile = "FlukaBody.inp";
43 fVolumeFile = "FlukaVolume.inp";
44 fFile1=fopen(fBodyFile,"w");
45 fFile2=fopen(fVolumeFile,"w");
50 void AliALIFE::BodyHeader()
52 // Write header for body definitions
53 fprintf(fFile1,"*\n");
54 fprintf(fFile1,"GEOBEGIN COMBINAT\n");
55 fprintf(fFile1," 0 0 AliRoot Generated\n");
56 fprintf(fFile1,"*\n");
57 fprintf(fFile1,"*== Body Definitions ================================================\n");
58 fprintf(fFile1,"*\n");
63 void AliALIFE::VolumeHeader()
65 // Write header for region (volume) definitions
66 fprintf(fFile2,"REGIONS\n");
67 fprintf(fFile2,"*\n");
68 fprintf(fFile2,"*== Region Definitions =================================================\n");
69 fprintf(fFile2,"*\n");
73 void AliALIFE:: Cylinder(Float_t rmin, Float_t rmax,
74 Float_t zmin, Float_t zmax,
76 char* Material, char* Field, char* Cuts)
82 char name1[5], name2[5], name3[5], name4[5];
85 sprintf(name1, "R%4.4d", fNBodies++);
86 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name1, pos[0], pos[1], rmax); // inner radius
87 sprintf(name2, "R%4.4d", fNBodies++);
88 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name2, pos[0], pos[1], rmin);
90 sprintf(name3, "Z%4.4d", fNBodies++);
91 fprintf(fFile1,"%5s XYP%10.3f\n",name3, zmax);
93 sprintf(name4, "Z%4.4d", fNBodies++);
94 fprintf(fFile1,"%5s XYP%10.3f\n",name4, zmin);
99 fprintf(fFile2,">%s:%s\n", Material, Field);
100 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
101 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
103 fprintf(fFile2,"+%s-%s+%s-%s\n", name1, name2, name3, name4);
105 fprintf(fFile2,"+%s+%s-%s\n", name1, name3, name4);
108 fprintf(fFile2,"\n");
111 void AliALIFE::OnionCylinder(Float_t* r, Int_t nr, Float_t zmin, Float_t zmax,
112 Float_t pos[3], char** Materials,
113 char** Fields, char** Cuts)
116 // Concentric cylinders
121 char nameRin[6], nameRou[6], nameZin[6], nameZou[6];
124 sprintf(nameZou, "Z%4.4d", fNBodies++);
127 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
129 sprintf(nameZin, "Z%4.4d", fNBodies++);
131 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
134 sprintf(nameRin, "R%4.4d", fNBodies++);
136 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",nameRin, pos[0], pos[1], r[0]);
139 for (i=1; i<nr; i++) {
141 sprintf(nameRou, "R%4.4d", fNBodies++);
143 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
144 nameRou, pos[0], pos[1], r[i]);
148 if (Fields && Cuts) {
149 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
150 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
151 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
153 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
154 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
155 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
158 fprintf(fFile2,"+%5s-%5s+%5s-%5s\n", nameZou, nameZin, nameRou, nameRin);
160 fprintf(fFile2,"+%5s-%5s+%5s\n", nameZou, nameZin, nameRou);
162 fprintf(fFile2,"\n");
168 void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
169 Float_t rmax1, Float_t rmax2,
170 Float_t zmin, Float_t zmax,
172 char* Material, char* Field, char* Cuts)
179 char nameCou[6], nameCin[6];
181 char nameZin[6], nameZou[6];
183 sprintf(nameZou, "Z%4.4d", fNBodies++);
184 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
186 sprintf(nameZin, "Z%4.4d", fNBodies++);
187 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
191 if (rmax1 >= 0. && rmax2 >= 0.) {
203 sprintf(nameCou, "C%4.4d", fNBodies++);
204 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
205 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
206 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
208 sprintf(nameCou, "C%4.4d", fNBodies++);
209 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
210 nameCou, pos[0], pos[1], rmax1);
213 strcpy(nameCou,fDefaultVolume1);
219 if (rmin1 >= 0. && rmin2 >= 0.) {
221 if (rmin1 != 0 && rmin2 !=0) {
233 sprintf(nameCin, "C%4.4d", fNBodies++);
234 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
235 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
236 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
239 sprintf(nameCin, "C%4.4d", fNBodies++);
240 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
241 nameCin, pos[0], pos[1], rmin1);
244 strcpy(nameCin,fDefaultVolume2);
252 fprintf(fFile2,">%s:%s\n", Material, Field);
253 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
254 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
255 if (rmin1 != 0 && rmin2 !=0) {
256 fprintf(fFile2,"+%s-%s+%s-%s\n", nameCou, nameCin, nameZou, nameZin);
258 fprintf(fFile2,"+%s+%s-%s\n", nameCou, nameZou, nameZin);
260 fprintf(fFile2,"\n");
263 void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr,
264 Float_t zmin, Float_t zmax,
265 Float_t pos[3], char** Materials, char** Fields,
270 char nameCin[6], nameCou[6], nameZin[6], nameZou[6];
274 Float_t ri1, ri2, ro1, ro2, d;
277 sprintf(nameZou, "Z%4.4d", fNBodies++);
278 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
280 sprintf(nameZin, "Z%4.4d", fNBodies++);
281 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
285 Bool_t hasInner=kFALSE;
286 Bool_t isCylinder=kFALSE;
287 if (r1[0]>=0 && r2[0]>=0) {
288 if (r1[0] != 0. && r2[0] !=0.) {
301 sprintf(nameCin, "C%4.4d", fNBodies++);
303 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
304 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
305 fprintf(fFile1," %10.3f%10.3f\n",ri1,ri2);
308 sprintf(nameCin, "C%4.4d", fNBodies++);
310 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
311 nameCin, pos[0], pos[1], r1[0]);
315 strcpy(nameCin,fDefaultVolume1);
322 for (i=1; i<nr; i++) {
323 if (r1[i] >= 0. && r2[i] >=0) {
336 sprintf(nameCou, "C%4.4d", fNBodies++);
338 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
339 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
340 fprintf(fFile1," %10.3f%10.3f\n",ro1,ro2);
343 sprintf(nameCou, "C%4.4d", fNBodies++);
345 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
346 nameCou, pos[0], pos[1], r1[i]);
349 strcpy(nameCou,fDefaultVolume1);
354 if (Fields && Cuts) {
355 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
356 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
357 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
359 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
360 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
361 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
364 fprintf(fFile2,"+%5s-%5s+%5s-%5s\n",
365 nameCou, nameCin, nameZou, nameZin);
367 fprintf(fFile2,"+%5s\n", nameCou);
370 fprintf(fFile2,"\n");
376 void AliALIFE::PolyCone(Float_t* rmin, Float_t* rmax, Float_t* z,
379 char* Material, char* Field, char* Cuts)
382 // Equivalent to the Geant3 PCON
384 for (i=0; i<nz-1; i++) {
385 // skip (z_i = z_i+1)
386 if (z[i] == z[i+1]) continue;
387 Cone(rmin[i], rmin[i+1], rmax[i], rmax[i+1], z[i], z[i+1], pos,
388 Material, Field, Cuts);
392 void AliALIFE::OnionPolyCone(Float_t** r, Float_t* z,
395 char** Materials, char** Fields=0, char** Cuts)
400 for (i=0; i<nz-1; i++) {
401 // skip (z_i = z_i+1)
402 if (z[i] == z[i+1]) continue;
403 for (j=0; j<nr-1; j++) {
404 if (Fields && Cuts) {
405 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
407 Materials[i], Fields[i], Cuts[i]);
409 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
417 void AliALIFE::Comment(char* Comment)
419 // Insert comment line
420 fprintf(fFile1,"*%s\n", Comment);
421 fprintf(fFile2,"*%s\n", Comment);
425 void AliALIFE::Finish()
427 // Finish geometry definition
429 fprintf(fFile1," END\n");
431 fFile2=fopen(fVolumeFile,"r");
432 while (fgets(s, BUFSIZ, fFile2)) {