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.2 2000/10/10 06:40:25 hristov
21 Revision 1.1 2000/07/26 15:10:57 morsch
22 Helper class to write geometry in ALIFE format in parallel with Geant geometry definition.
30 AliALIFE::AliALIFE(const char* file1, const char* file2)
35 fBodyFile = file1; // File for Fluka bodies
37 fFile1=fopen(fBodyFile,"w");
38 fFile2=fopen(fVolumeFile,"w");
41 fDefaultVolume1 = "DEFAU1";
42 fDefaultVolume2 = "DEFAU2";
47 // Default constructor
48 fBodyFile = "FlukaBody.inp";
49 fVolumeFile = "FlukaVolume.inp";
50 fFile1=fopen(fBodyFile,"w");
51 fFile2=fopen(fVolumeFile,"w");
56 void AliALIFE::BodyHeader()
58 // Write header for body definitions
59 fprintf(fFile1,"*\n");
60 fprintf(fFile1,"GEOBEGIN COMBINAT\n");
61 fprintf(fFile1," 0 0 AliRoot Generated\n");
62 fprintf(fFile1,"*\n");
63 fprintf(fFile1,"*== Body Definitions ================================================\n");
64 fprintf(fFile1,"*\n");
69 void AliALIFE::VolumeHeader()
71 // Write header for region (volume) definitions
72 fprintf(fFile2,"REGIONS\n");
73 fprintf(fFile2,"*\n");
74 fprintf(fFile2,"*== Region Definitions =================================================\n");
75 fprintf(fFile2,"*\n");
79 void AliALIFE:: Cylinder(Float_t rmin, Float_t rmax,
80 Float_t zmin, Float_t zmax,
82 char* Material, char* Field, char* Cuts)
88 char name1[5], name2[5], name3[5], name4[5];
91 sprintf(name1, "R%4.4d", fNBodies++);
92 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name1, pos[0], pos[1], rmax); // inner radius
93 sprintf(name2, "R%4.4d", fNBodies++);
94 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",name2, pos[0], pos[1], rmin);
96 sprintf(name3, "Z%4.4d", fNBodies++);
97 fprintf(fFile1,"%5s XYP%10.3f\n",name3, zmax);
99 sprintf(name4, "Z%4.4d", fNBodies++);
100 fprintf(fFile1,"%5s XYP%10.3f\n",name4, zmin);
105 fprintf(fFile2,">%s:%s\n", Material, Field);
106 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
107 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
109 fprintf(fFile2,"+%s-%s+%s-%s\n", name1, name2, name3, name4);
111 fprintf(fFile2,"+%s+%s-%s\n", name1, name3, name4);
114 fprintf(fFile2,"\n");
117 void AliALIFE::OnionCylinder(Float_t* r, Int_t nr, Float_t zmin, Float_t zmax,
118 Float_t pos[3], char** Materials,
119 char** Fields, char** Cuts)
122 // Concentric cylinders
127 char nameRin[6], nameRou[6], nameZin[6], nameZou[6];
130 sprintf(nameZou, "Z%4.4d", fNBodies++);
133 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
135 sprintf(nameZin, "Z%4.4d", fNBodies++);
137 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
140 sprintf(nameRin, "R%4.4d", fNBodies++);
142 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",nameRin, pos[0], pos[1], r[0]);
145 for (i=1; i<nr; i++) {
147 sprintf(nameRou, "R%4.4d", fNBodies++);
149 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
150 nameRou, pos[0], pos[1], r[i]);
154 if (Fields && Cuts) {
155 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
156 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
157 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
159 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
160 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
161 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
164 fprintf(fFile2,"+%5s-%5s+%5s-%5s\n", nameZou, nameZin, nameRou, nameRin);
166 fprintf(fFile2,"+%5s-%5s+%5s\n", nameZou, nameZin, nameRou);
168 fprintf(fFile2,"\n");
169 strcpy(nameRin,nameRou);
174 void AliALIFE::Cone(Float_t rmin1, Float_t rmin2,
175 Float_t rmax1, Float_t rmax2,
176 Float_t zmin, Float_t zmax,
178 char* Material, char* Field, char* Cuts)
185 char nameCou[6], nameCin[6];
187 char nameZin[6], nameZou[6];
189 sprintf(nameZou, "Z%4.4d", fNBodies++);
190 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
192 sprintf(nameZin, "Z%4.4d", fNBodies++);
193 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
197 if (rmax1 >= 0. && rmax2 >= 0.) {
209 sprintf(nameCou, "C%4.4d", fNBodies++);
210 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
211 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
212 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
214 sprintf(nameCou, "C%4.4d", fNBodies++);
215 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
216 nameCou, pos[0], pos[1], rmax1);
219 strcpy(nameCou,fDefaultVolume1);
225 if (rmin1 >= 0. && rmin2 >= 0.) {
227 if (rmin1 != 0 && rmin2 !=0) {
239 sprintf(nameCin, "C%4.4d", fNBodies++);
240 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
241 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
242 fprintf(fFile1," %10.3f%10.3f\n",r1,r2);
245 sprintf(nameCin, "C%4.4d", fNBodies++);
246 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
247 nameCin, pos[0], pos[1], rmin1);
250 strcpy(nameCin,fDefaultVolume2);
258 fprintf(fFile2,">%s:%s\n", Material, Field);
259 fprintf(fFile2,"EMFCUT=%s\n", Cuts);
260 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts);
261 if (rmin1 != 0 && rmin2 !=0) {
262 fprintf(fFile2,"+%s-%s+%s-%s\n", nameCou, nameCin, nameZou, nameZin);
264 fprintf(fFile2,"+%s+%s-%s\n", nameCou, nameZou, nameZin);
266 fprintf(fFile2,"\n");
269 void AliALIFE::OnionCone (Float_t* r1, Float_t* r2, Int_t nr,
270 Float_t zmin, Float_t zmax,
271 Float_t pos[3], char** Materials, char** Fields,
276 char nameCin[6], nameCou[6], nameZin[6], nameZou[6];
280 Float_t ri1, ri2, ro1, ro2, d;
283 sprintf(nameZou, "Z%4.4d", fNBodies++);
284 fprintf(fFile1,"%5s XYP%10.3f\n",nameZou, zmax);
286 sprintf(nameZin, "Z%4.4d", fNBodies++);
287 fprintf(fFile1,"%5s XYP%10.3f\n",nameZin, zmin);
291 Bool_t hasInner=kFALSE;
292 Bool_t isCylinder=kFALSE;
293 if (r1[0]>=0 && r2[0]>=0) {
294 if (r1[0] != 0. && r2[0] !=0.) {
307 sprintf(nameCin, "C%4.4d", fNBodies++);
309 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
310 nameCin, pos[0], pos[1], pos[2], 0., 0., d);
311 fprintf(fFile1," %10.3f%10.3f\n",ri1,ri2);
314 sprintf(nameCin, "C%4.4d", fNBodies++);
316 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
317 nameCin, pos[0], pos[1], r1[0]);
321 strcpy(nameCin,fDefaultVolume1);
328 for (i=1; i<nr; i++) {
329 if (r1[i] >= 0. && r2[i] >=0) {
342 sprintf(nameCou, "C%4.4d", fNBodies++);
344 fprintf(fFile1,"%5s TRC%10.3f%10.3f%10.3f%10.3f%10.3f%10.3f\n",
345 nameCou, pos[0], pos[1], pos[2], 0., 0., d);
346 fprintf(fFile1," %10.3f%10.3f\n",ro1,ro2);
349 sprintf(nameCou, "C%4.4d", fNBodies++);
351 fprintf(fFile1,"%5s ZCC%10.3f%10.3f%10.3f\n",
352 nameCou, pos[0], pos[1], r1[i]);
355 strcpy(nameCou,fDefaultVolume1);
360 if (Fields && Cuts) {
361 fprintf(fFile2,">%s:%s\n", Materials[i-1], Fields[i-1]);
362 fprintf(fFile2,"EMFCUT=%s\n", Cuts[i-1]);
363 fprintf(fFile2,"WW-FACTOR=%s\n", Cuts[i-1]);
365 fprintf(fFile2,">%s:%s\n", Materials[i-1], "MF");
366 fprintf(fFile2,"EMFCUT=%s\n", "$UNSHIELDED");
367 fprintf(fFile2,"WW-FACTOR=%s\n", "$UNSHIELDED");
369 if (hasInner || isCylinder) {
370 if (!isCylinder) fprintf(fFile2,"+%5s-%5s+%5s-%5s\n",
371 nameCou, nameCin, nameZou, nameZin);
372 if (isCylinder) fprintf(fFile2,"+%5s+%5s-%5s\n",
373 nameCou, nameZou, nameZin);
375 fprintf(fFile2,"+%5s\n", nameCou);
378 fprintf(fFile2,"\n");
379 strcpy(nameCin,nameCou);
384 void AliALIFE::PolyCone(Float_t* rmin, Float_t* rmax, Float_t* z,
387 char* Material, char* Field, char* Cuts)
390 // Equivalent to the Geant3 PCON
392 for (i=0; i<nz-1; i++) {
393 // skip (z_i = z_i+1)
394 if (z[i] == z[i+1]) continue;
395 Cone(rmin[i], rmin[i+1], rmax[i], rmax[i+1], z[i], z[i+1], pos,
396 Material, Field, Cuts);
400 void AliALIFE::OnionPolyCone(Float_t** r, Float_t* z,
403 char** Materials, char** Fields, char** Cuts)
408 for (i=0; i<nz-1; i++) {
409 // skip (z_i = z_i+1)
410 if (z[i] == z[i+1]) continue;
411 for (j=0; j<nr-1; j++) {
412 if (Fields && Cuts) {
413 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
415 Materials[i], Fields[i], Cuts[i]);
417 Cone(r[i][j], r[i+1][j], r[i][j+1], r[i+1][j+1],
425 void AliALIFE::Comment(char* Comment)
427 // Insert comment line
428 fprintf(fFile1,"*%s\n", Comment);
429 fprintf(fFile2,"*%s\n", Comment);
433 void AliALIFE::Finish()
435 // Finish geometry definition
437 fprintf(fFile1," END\n");
439 fFile2=fopen(fVolumeFile,"r");
440 while (fgets(s, BUFSIZ, fFile2)) {