]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
98490ea9 | 18 | Revision 1.19 2002/10/29 14:26:49 hristov |
19 | Code clean-up (F.Carminati) | |
20 | ||
e2afb3b6 | 21 | Revision 1.18 2001/12/19 14:46:26 morsch |
22 | Add possibility to disable StepManager() for each module separately. | |
23 | ||
3f754d83 | 24 | Revision 1.17 2001/08/29 14:28:33 morsch |
25 | Use visibility flags -1 and 3 instead of 0 and 1. | |
26 | ||
5bef1017 | 27 | Revision 1.16 2001/05/16 14:57:22 alibrary |
28 | New files for folders and Stack | |
29 | ||
9e1a0ddb | 30 | Revision 1.15 2001/03/20 06:36:28 alibrary |
31 | 100 parameters now allowed for geant shapes | |
32 | ||
d43b40e2 | 33 | Revision 1.14 2001/01/26 19:58:48 hristov |
34 | Major upgrade of AliRoot code | |
35 | ||
2ab0c725 | 36 | Revision 1.13 2000/11/30 07:12:49 alibrary |
37 | Introducing new Rndm and QA classes | |
38 | ||
65fb704d | 39 | Revision 1.12 2000/10/02 21:28:14 fca |
40 | Removal of useless dependecies via forward declarations | |
41 | ||
94de3818 | 42 | Revision 1.11 2000/07/12 08:56:25 fca |
43 | Coding convention correction and warning removal | |
44 | ||
8918e700 | 45 | Revision 1.10 2000/07/11 18:24:59 fca |
46 | Coding convention corrections + few minor bug fixes | |
47 | ||
aee8290b | 48 | Revision 1.9 2000/05/16 08:45:08 fca |
49 | Correct dtor, thanks to J.Belikov | |
50 | ||
bf9b027f | 51 | Revision 1.8 2000/02/23 16:25:22 fca |
52 | AliVMC and AliGeant3 classes introduced | |
53 | ReadEuclid moved from AliRun to AliModule | |
54 | ||
b13db077 | 55 | Revision 1.7 1999/09/29 09:24:29 fca |
56 | Introduction of the Copyright and cvs Log | |
57 | ||
4c039060 | 58 | */ |
59 | ||
8494b010 | 60 | /////////////////////////////////////////////////////////////////////////////// |
61 | // // | |
62 | // Base class for ALICE modules. Both sensitive modules (Modules) and // | |
63 | // non-sensitive ones are described by this base class. This class // | |
64 | // supports the hit and digit trees produced by the simulation and also // | |
65 | // the objects produced by the reconstruction. // | |
66 | // // | |
67 | // This class is also responsible for building the geometry of the // | |
68 | // Modules. // | |
69 | // // | |
70 | //Begin_Html | |
71 | /* | |
1439f98e | 72 | <img src="picts/AliModuleClass.gif"> |
8494b010 | 73 | */ |
74 | //End_Html | |
75 | // // | |
76 | /////////////////////////////////////////////////////////////////////////////// | |
94de3818 | 77 | #include <TNode.h> |
94de3818 | 78 | #include "TSystem.h" |
79 | ||
8494b010 | 80 | #include "AliModule.h" |
81 | #include "AliRun.h" | |
94de3818 | 82 | #include "AliMagF.h" |
9e1a0ddb | 83 | #include "AliConfig.h" |
8494b010 | 84 | |
85 | ClassImp(AliModule) | |
86 | ||
e2afb3b6 | 87 | //_______________________________________________________________________ |
88 | AliModule::AliModule(): | |
89 | fEuclidMaterial(""), | |
90 | fEuclidGeometry(""), | |
91 | fIdtmed(0), | |
92 | fIdmate(0), | |
93 | fLoMedium(0), | |
94 | fHiMedium(0), | |
95 | fActive(0), | |
96 | fHistograms(0), | |
97 | fNodes(0), | |
98 | fDebug(0), | |
99 | fEnable(1) | |
8494b010 | 100 | { |
101 | // | |
102 | // Default constructor for the AliModule class | |
103 | // | |
8494b010 | 104 | } |
105 | ||
e2afb3b6 | 106 | //_______________________________________________________________________ |
107 | AliModule::AliModule(const char* name,const char *title): | |
108 | TNamed(name,title), | |
109 | fEuclidMaterial(""), | |
110 | fEuclidGeometry(""), | |
111 | fIdtmed(new TArrayI(100)), | |
112 | fIdmate(new TArrayI(100)), | |
113 | fLoMedium(65536), | |
114 | fHiMedium(0), | |
115 | fActive(0), | |
116 | fHistograms(new TList()), | |
117 | fNodes(new TList()), | |
118 | fDebug(0), | |
119 | fEnable(1) | |
8494b010 | 120 | { |
121 | // | |
122 | // Normal constructor invoked by all Modules. | |
123 | // Create the list for Module specific histograms | |
124 | // Add this Module to the global list of Modules in Run. | |
125 | // | |
8494b010 | 126 | // Get the Module numeric ID |
127 | Int_t id = gAlice->GetModuleID(name); | |
02ca2762 | 128 | if (id>=0) { |
129 | // Module already added ! | |
130 | Warning("Ctor","Module: %s already present at %d\n",name,id); | |
8494b010 | 131 | return; |
132 | } | |
133 | // | |
134 | // Add this Module to the list of Modules | |
02ca2762 | 135 | gAlice->Modules()->Add(this); |
8494b010 | 136 | // |
137 | // | |
138 | SetMarkerColor(3); | |
139 | // | |
e2afb3b6 | 140 | // Clear space for tracking media and material indexes |
141 | ||
8494b010 | 142 | for(Int_t i=0;i<100;i++) (*fIdmate)[i]=(*fIdtmed)[i]=0; |
9e1a0ddb | 143 | |
144 | AliConfig::Instance()->Add(this); | |
145 | ||
65fb704d | 146 | SetDebug(gAlice->GetDebug()); |
8494b010 | 147 | } |
148 | ||
e2afb3b6 | 149 | //_______________________________________________________________________ |
150 | AliModule::AliModule(const AliModule &mod): | |
151 | TNamed(mod), | |
152 | TAttLine(mod), | |
153 | TAttMarker(mod), | |
154 | AliRndm(mod), | |
155 | fEuclidMaterial(""), | |
156 | fEuclidGeometry(""), | |
157 | fIdtmed(0), | |
158 | fIdmate(0), | |
159 | fLoMedium(0), | |
160 | fHiMedium(0), | |
161 | fActive(0), | |
162 | fHistograms(0), | |
163 | fNodes(0), | |
164 | fDebug(0), | |
165 | fEnable(0) | |
aee8290b | 166 | { |
167 | // | |
168 | // Copy constructor | |
169 | // | |
8918e700 | 170 | mod.Copy(*this); |
aee8290b | 171 | } |
172 | ||
e2afb3b6 | 173 | //_______________________________________________________________________ |
8494b010 | 174 | AliModule::~AliModule() |
175 | { | |
176 | // | |
177 | // Destructor | |
178 | // | |
e2afb3b6 | 179 | |
8494b010 | 180 | // Delete ROOT geometry |
bf9b027f | 181 | if(fNodes) { |
182 | fNodes->Clear(); | |
183 | delete fNodes; | |
184 | } | |
8494b010 | 185 | // |
186 | // Delete TArray objects | |
187 | delete fIdtmed; | |
188 | delete fIdmate; | |
189 | } | |
190 | ||
e2afb3b6 | 191 | //_______________________________________________________________________ |
8918e700 | 192 | void AliModule::Copy(AliModule & /* mod */) const |
aee8290b | 193 | { |
194 | // | |
195 | // Copy *this onto mod, not implemented for AliModule | |
196 | // | |
197 | Fatal("Copy","Not implemented!\n"); | |
198 | } | |
199 | ||
e2afb3b6 | 200 | //_______________________________________________________________________ |
8494b010 | 201 | void AliModule::Disable() |
202 | { | |
203 | // | |
204 | // Disable Module on viewer | |
205 | // | |
206 | fActive = kFALSE; | |
207 | TIter next(fNodes); | |
208 | TNode *node; | |
209 | // | |
210 | // Loop through geometry to disable all | |
211 | // nodes for this Module | |
e2afb3b6 | 212 | while((node = dynamic_cast<TNode*>(next()))) { |
5bef1017 | 213 | node->SetVisibility(-1); |
8494b010 | 214 | } |
215 | } | |
216 | ||
e2afb3b6 | 217 | //_______________________________________________________________________ |
8494b010 | 218 | Int_t AliModule::DistancetoPrimitive(Int_t, Int_t) |
219 | { | |
220 | // | |
221 | // Return distance from mouse pointer to object | |
222 | // Dummy routine for the moment | |
223 | // | |
224 | return 9999; | |
225 | } | |
226 | ||
e2afb3b6 | 227 | //_______________________________________________________________________ |
8494b010 | 228 | void AliModule::Enable() |
229 | { | |
230 | // | |
231 | // Enable Module on the viewver | |
232 | // | |
233 | fActive = kTRUE; | |
234 | TIter next(fNodes); | |
235 | TNode *node; | |
236 | // | |
237 | // Loop through geometry to enable all | |
238 | // nodes for this Module | |
e2afb3b6 | 239 | while((node = dynamic_cast<TNode*>(next()))) { |
5bef1017 | 240 | node->SetVisibility(3); |
8494b010 | 241 | } |
242 | } | |
243 | ||
e2afb3b6 | 244 | //_______________________________________________________________________ |
8494b010 | 245 | void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a, |
e2afb3b6 | 246 | Float_t z, Float_t dens, Float_t radl, |
247 | Float_t absl, Float_t *buf, Int_t nwbuf) const | |
8494b010 | 248 | { |
249 | // | |
250 | // Store the parameters for a material | |
251 | // | |
252 | // imat the material index will be stored in (*fIdmate)[imat] | |
253 | // name material name | |
254 | // a atomic mass | |
255 | // z atomic number | |
256 | // dens density | |
257 | // radl radiation length | |
258 | // absl absorbtion length | |
259 | // buf adress of an array user words | |
260 | // nwbuf number of user words | |
261 | // | |
262 | Int_t kmat; | |
cfce8870 | 263 | gMC->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf); |
8494b010 | 264 | (*fIdmate)[imat]=kmat; |
265 | } | |
266 | ||
e2afb3b6 | 267 | //_______________________________________________________________________ |
0afa509f | 268 | void AliModule::AliGetMaterial(Int_t imat, char* name, Float_t &a, |
e2afb3b6 | 269 | Float_t &z, Float_t &dens, Float_t &radl, |
270 | Float_t &absl) | |
0afa509f | 271 | { |
272 | // | |
273 | // Store the parameters for a material | |
274 | // | |
275 | // imat the material index will be stored in (*fIdmate)[imat] | |
276 | // name material name | |
277 | // a atomic mass | |
278 | // z atomic number | |
279 | // dens density | |
280 | // radl radiation length | |
281 | // absl absorbtion length | |
282 | // buf adress of an array user words | |
283 | // nwbuf number of user words | |
284 | // | |
285 | ||
286 | Float_t buf[10]; | |
287 | Int_t nwbuf, kmat; | |
288 | kmat=(*fIdmate)[imat]; | |
289 | gMC->Gfmate(kmat, name, a, z, dens, radl, absl, buf, nwbuf); | |
290 | } | |
291 | ||
8494b010 | 292 | |
e2afb3b6 | 293 | //_______________________________________________________________________ |
8494b010 | 294 | void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a, |
e2afb3b6 | 295 | Float_t *z, Float_t dens, Int_t nlmat, |
296 | Float_t *wmat) const | |
8494b010 | 297 | { |
298 | // | |
299 | // Defines mixture or compound imat as composed by | |
300 | // nlmat materials defined by arrays a, z and wmat | |
301 | // | |
302 | // If nlmat > 0 wmat contains the proportion by | |
303 | // weights of each basic material in the mixture | |
304 | // | |
305 | // If nlmat < 0 wmat contains the number of atoms | |
306 | // of eack kind in the molecule of the compound | |
307 | // In this case, wmat is changed on output to the relative weigths. | |
308 | // | |
309 | // imat the material index will be stored in (*fIdmate)[imat] | |
310 | // name material name | |
311 | // a array of atomic masses | |
312 | // z array of atomic numbers | |
313 | // dens density | |
314 | // nlmat number of components | |
315 | // wmat array of concentrations | |
316 | // | |
317 | Int_t kmat; | |
cfce8870 | 318 | gMC->Mixture(kmat, name, a, z, dens, nlmat, wmat); |
8494b010 | 319 | (*fIdmate)[imat]=kmat; |
320 | } | |
321 | ||
e2afb3b6 | 322 | //_______________________________________________________________________ |
8494b010 | 323 | void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat, |
e2afb3b6 | 324 | Int_t isvol, Int_t ifield, Float_t fieldm, |
325 | Float_t tmaxfd, Float_t stemax, Float_t deemax, | |
326 | Float_t epsil, Float_t stmin, Float_t *ubuf, | |
327 | Int_t nbuf) const | |
8494b010 | 328 | { |
329 | // | |
330 | // Store the parameters of a tracking medium | |
331 | // | |
b13db077 | 332 | // numed the medium number is stored into (*fIdtmed)[numed] |
8494b010 | 333 | // name medium name |
334 | // nmat the material number is stored into (*fIdmate)[nmat] | |
335 | // isvol sensitive volume if isvol!=0 | |
336 | // ifield magnetic field flag (see below) | |
337 | // fieldm maximum magnetic field | |
338 | // tmaxfd maximum deflection angle due to magnetic field | |
339 | // stemax maximum step allowed | |
340 | // deemax maximum fractional energy loss in one step | |
341 | // epsil tracking precision in cm | |
342 | // stmin minimum step due to continuous processes | |
343 | // | |
344 | // ifield = 0 no magnetic field | |
345 | // = -1 user decision in guswim | |
346 | // = 1 tracking performed with Runge Kutta | |
347 | // = 2 tracking performed with helix | |
348 | // = 3 constant magnetic field along z | |
349 | // | |
350 | Int_t kmed; | |
cfce8870 | 351 | gMC->Medium(kmed,name, (*fIdmate)[nmat], isvol, ifield, fieldm, |
8494b010 | 352 | tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); |
ad51aeb0 | 353 | (*fIdtmed)[numed]=kmed; |
8494b010 | 354 | } |
355 | ||
e2afb3b6 | 356 | //_______________________________________________________________________ |
8494b010 | 357 | void AliModule::AliMatrix(Int_t &nmat, Float_t theta1, Float_t phi1, |
e2afb3b6 | 358 | Float_t theta2, Float_t phi2, Float_t theta3, |
359 | Float_t phi3) const | |
8494b010 | 360 | { |
361 | // | |
362 | // Define a rotation matrix. Angles are in degrees. | |
363 | // | |
364 | // nmat on output contains the number assigned to the rotation matrix | |
365 | // theta1 polar angle for axis I | |
366 | // phi1 azimuthal angle for axis I | |
367 | // theta2 polar angle for axis II | |
368 | // phi2 azimuthal angle for axis II | |
369 | // theta3 polar angle for axis III | |
370 | // phi3 azimuthal angle for axis III | |
371 | // | |
cfce8870 | 372 | gMC->Matrix(nmat, theta1, phi1, theta2, phi2, theta3, phi3); |
8494b010 | 373 | } |
374 | ||
e2afb3b6 | 375 | //_______________________________________________________________________ |
65fb704d | 376 | Float_t AliModule::ZMin() const |
377 | { | |
378 | return -500; | |
379 | } | |
380 | ||
e2afb3b6 | 381 | //_______________________________________________________________________ |
65fb704d | 382 | Float_t AliModule::ZMax() const |
383 | { | |
384 | return 500; | |
385 | } | |
386 | ||
e2afb3b6 | 387 | //_______________________________________________________________________ |
8494b010 | 388 | void AliModule::SetEuclidFile(char* material, char* geometry) |
389 | { | |
390 | // | |
391 | // Sets the name of the Euclid file | |
392 | // | |
393 | fEuclidMaterial=material; | |
394 | if(geometry) { | |
395 | fEuclidGeometry=geometry; | |
396 | } else { | |
397 | char* name = new char[strlen(material)]; | |
398 | strcpy(name,material); | |
399 | strcpy(&name[strlen(name)-4],".euc"); | |
400 | fEuclidGeometry=name; | |
401 | delete [] name; | |
402 | } | |
403 | } | |
404 | ||
e2afb3b6 | 405 | //_______________________________________________________________________ |
b13db077 | 406 | void AliModule::ReadEuclid(const char* filnam, char* topvol) |
407 | { | |
408 | // | |
409 | // read in the geometry of the detector in euclid file format | |
410 | // | |
411 | // id_det : the detector identification (2=its,...) | |
412 | // topvol : return parameter describing the name of the top | |
413 | // volume of geometry. | |
414 | // | |
415 | // author : m. maire | |
416 | // | |
417 | // 28.07.98 | |
418 | // several changes have been made by miroslav helbich | |
419 | // subroutine is rewrited to follow the new established way of memory | |
420 | // booking for tracking medias and rotation matrices. | |
421 | // all used tracking media have to be defined first, for this you can use | |
422 | // subroutine greutmed. | |
423 | // top volume is searched as only volume not positioned into another | |
424 | // | |
425 | ||
426 | Int_t i, nvol, iret, itmed, irot, numed, npar, ndiv, iaxe; | |
427 | Int_t ndvmx, nr, flag; | |
428 | char key[5], card[77], natmed[21]; | |
429 | char name[5], mother[5], shape[5], konly[5], volst[7000][5]; | |
430 | char *filtmp; | |
d43b40e2 | 431 | Float_t par[100]; |
b13db077 | 432 | Float_t teta1, phi1, teta2, phi2, teta3, phi3, orig, step; |
433 | Float_t xo, yo, zo; | |
aee8290b | 434 | const Int_t kMaxRot=5000; |
435 | Int_t idrot[kMaxRot],istop[7000]; | |
b13db077 | 436 | FILE *lun; |
437 | // | |
438 | // *** The input filnam name will be with extension '.euc' | |
439 | filtmp=gSystem->ExpandPathName(filnam); | |
440 | lun=fopen(filtmp,"r"); | |
441 | delete [] filtmp; | |
442 | if(!lun) { | |
443 | Error("ReadEuclid","Could not open file %s\n",filnam); | |
444 | return; | |
445 | } | |
446 | //* --- definition of rotation matrix 0 --- | |
447 | TArrayI &idtmed = *fIdtmed; | |
aee8290b | 448 | for(i=1; i<kMaxRot; ++i) idrot[i]=-99; |
b13db077 | 449 | idrot[0]=0; |
450 | nvol=0; | |
451 | L10: | |
452 | for(i=0;i<77;i++) card[i]=0; | |
453 | iret=fscanf(lun,"%77[^\n]",card); | |
454 | if(iret<=0) goto L20; | |
455 | fscanf(lun,"%*c"); | |
456 | //* | |
457 | strncpy(key,card,4); | |
458 | key[4]='\0'; | |
459 | if (!strcmp(key,"TMED")) { | |
460 | sscanf(&card[5],"%d '%[^']'",&itmed,natmed); | |
461 | if( itmed<0 || itmed>=100 ) { | |
462 | Error("ReadEuclid","TMED illegal medium number %d for %s\n",itmed,natmed); | |
463 | exit(1); | |
464 | } | |
465 | //Pad the string with blanks | |
466 | i=-1; | |
467 | while(natmed[++i]); | |
468 | while(i<20) natmed[i++]=' '; | |
469 | natmed[i]='\0'; | |
470 | // | |
471 | if( idtmed[itmed]<=0 ) { | |
472 | Error("ReadEuclid","TMED undefined medium number %d for %s\n",itmed,natmed); | |
473 | exit(1); | |
474 | } | |
475 | gMC->Gckmat(idtmed[itmed],natmed); | |
476 | //* | |
477 | } else if (!strcmp(key,"ROTM")) { | |
478 | sscanf(&card[4],"%d %f %f %f %f %f %f",&irot,&teta1,&phi1,&teta2,&phi2,&teta3,&phi3); | |
aee8290b | 479 | if( irot<=0 || irot>=kMaxRot ) { |
b13db077 | 480 | Error("ReadEuclid","ROTM rotation matrix number %d illegal\n",irot); |
481 | exit(1); | |
482 | } | |
483 | AliMatrix(idrot[irot],teta1,phi1,teta2,phi2,teta3,phi3); | |
484 | //* | |
485 | } else if (!strcmp(key,"VOLU")) { | |
486 | sscanf(&card[5],"'%[^']' '%[^']' %d %d", name, shape, &numed, &npar); | |
487 | if (npar>0) { | |
488 | for(i=0;i<npar;i++) fscanf(lun,"%f",&par[i]); | |
489 | fscanf(lun,"%*c"); | |
490 | } | |
491 | gMC->Gsvolu( name, shape, idtmed[numed], par, npar); | |
492 | //* save the defined volumes | |
493 | strcpy(volst[++nvol],name); | |
494 | istop[nvol]=1; | |
495 | //* | |
496 | } else if (!strcmp(key,"DIVN")) { | |
497 | sscanf(&card[5],"'%[^']' '%[^']' %d %d", name, mother, &ndiv, &iaxe); | |
498 | gMC->Gsdvn ( name, mother, ndiv, iaxe ); | |
499 | //* | |
500 | } else if (!strcmp(key,"DVN2")) { | |
501 | sscanf(&card[5],"'%[^']' '%[^']' %d %d %f %d",name, mother, &ndiv, &iaxe, &orig, &numed); | |
502 | gMC->Gsdvn2( name, mother, ndiv, iaxe, orig,idtmed[numed]); | |
503 | //* | |
504 | } else if (!strcmp(key,"DIVT")) { | |
505 | sscanf(&card[5],"'%[^']' '%[^']' %f %d %d %d", name, mother, &step, &iaxe, &numed, &ndvmx); | |
506 | gMC->Gsdvt ( name, mother, step, iaxe, idtmed[numed], ndvmx); | |
507 | //* | |
508 | } else if (!strcmp(key,"DVT2")) { | |
509 | sscanf(&card[5],"'%[^']' '%[^']' %f %d %f %d %d", name, mother, &step, &iaxe, &orig, &numed, &ndvmx); | |
510 | gMC->Gsdvt2 ( name, mother, step, iaxe, orig, idtmed[numed], ndvmx ); | |
511 | //* | |
512 | } else if (!strcmp(key,"POSI")) { | |
513 | sscanf(&card[5],"'%[^']' %d '%[^']' %f %f %f %d '%[^']'", name, &nr, mother, &xo, &yo, &zo, &irot, konly); | |
aee8290b | 514 | if( irot<0 || irot>=kMaxRot ) { |
b13db077 | 515 | Error("ReadEuclid","POSI %s#%d rotation matrix number %d illegal\n",name,nr,irot); |
516 | exit(1); | |
517 | } | |
518 | if( idrot[irot] == -99) { | |
519 | Error("ReadEuclid","POSI %s#%d undefined matrix number %d\n",name,nr,irot); | |
520 | exit(1); | |
521 | } | |
522 | //*** volume name cannot be the top volume | |
523 | for(i=1;i<=nvol;i++) { | |
524 | if (!strcmp(volst[i],name)) istop[i]=0; | |
525 | } | |
526 | //* | |
527 | gMC->Gspos ( name, nr, mother, xo, yo, zo, idrot[irot], konly ); | |
528 | //* | |
529 | } else if (!strcmp(key,"POSP")) { | |
530 | sscanf(&card[5],"'%[^']' %d '%[^']' %f %f %f %d '%[^']' %d", name, &nr, mother, &xo, &yo, &zo, &irot, konly, &npar); | |
aee8290b | 531 | if( irot<0 || irot>=kMaxRot ) { |
b13db077 | 532 | Error("ReadEuclid","POSP %s#%d rotation matrix number %d illegal\n",name,nr,irot); |
533 | exit(1); | |
534 | } | |
535 | if( idrot[irot] == -99) { | |
536 | Error("ReadEuclid","POSP %s#%d undefined matrix number %d\n",name,nr,irot); | |
537 | exit(1); | |
538 | } | |
539 | if (npar > 0) { | |
540 | for(i=0;i<npar;i++) fscanf(lun,"%f",&par[i]); | |
541 | fscanf(lun,"%*c"); | |
542 | } | |
543 | //*** volume name cannot be the top volume | |
544 | for(i=1;i<=nvol;i++) { | |
545 | if (!strcmp(volst[i],name)) istop[i]=0; | |
546 | } | |
547 | //* | |
548 | gMC->Gsposp ( name, nr, mother, xo,yo,zo, idrot[irot], konly, par, npar); | |
549 | } | |
550 | //* | |
551 | if (strcmp(key,"END")) goto L10; | |
552 | //* find top volume in the geometry | |
553 | flag=0; | |
554 | for(i=1;i<=nvol;i++) { | |
555 | if (istop[i] && flag) { | |
556 | Warning("ReadEuclid"," %s is another possible top volume\n",volst[i]); | |
557 | } | |
558 | if (istop[i] && !flag) { | |
559 | strcpy(topvol,volst[i]); | |
9e1a0ddb | 560 | if(fDebug) printf("%s::ReadEuclid: volume %s taken as a top volume\n",ClassName(),topvol); |
b13db077 | 561 | flag=1; |
562 | } | |
563 | } | |
564 | if (!flag) { | |
565 | Warning("ReadEuclid","top volume not found\n"); | |
566 | } | |
567 | fclose (lun); | |
568 | //* | |
569 | //* commented out only for the not cernlib version | |
9e1a0ddb | 570 | if(fDebug) printf("%s::ReadEuclid: file: %s is now read in\n",ClassName(),filnam); |
b13db077 | 571 | // |
572 | return; | |
573 | //* | |
574 | L20: | |
575 | Error("ReadEuclid","reading error or premature end of file\n"); | |
576 | } | |
577 | ||
e2afb3b6 | 578 | //_______________________________________________________________________ |
b13db077 | 579 | void AliModule::ReadEuclidMedia(const char* filnam) |
580 | { | |
581 | // | |
582 | // read in the materials and tracking media for the detector | |
583 | // in euclid file format | |
584 | // | |
585 | // filnam: name of the input file | |
586 | // id_det: id_det is the detector identification (2=its,...) | |
587 | // | |
588 | // author : miroslav helbich | |
589 | // | |
590 | Float_t sxmgmx = gAlice->Field()->Max(); | |
591 | Int_t isxfld = gAlice->Field()->Integ(); | |
592 | Int_t end, i, iret, itmed; | |
593 | char key[5], card[130], natmed[21], namate[21]; | |
594 | Float_t ubuf[50]; | |
595 | char* filtmp; | |
596 | FILE *lun; | |
597 | Int_t imate; | |
598 | Int_t nwbuf, isvol, ifield, nmat; | |
599 | Float_t a, z, dens, radl, absl, fieldm, tmaxfd, stemax, deemax, epsil, stmin; | |
600 | // | |
601 | end=strlen(filnam); | |
602 | for(i=0;i<end;i++) if(filnam[i]=='.') { | |
603 | end=i; | |
604 | break; | |
605 | } | |
606 | // | |
607 | // *** The input filnam name will be with extension '.euc' | |
9e1a0ddb | 608 | if(fDebug) printf("%s::ReadEuclid: The file name is %s\n",ClassName(),filnam); //Debug |
b13db077 | 609 | filtmp=gSystem->ExpandPathName(filnam); |
610 | lun=fopen(filtmp,"r"); | |
611 | delete [] filtmp; | |
612 | if(!lun) { | |
613 | Warning("ReadEuclidMedia","Could not open file %s\n",filnam); | |
614 | return; | |
615 | } | |
616 | // | |
617 | // Retrieve Mag Field parameters | |
aee8290b | 618 | Int_t globField=gAlice->Field()->Integ(); |
619 | Float_t globMaxField=gAlice->Field()->Max(); | |
b13db077 | 620 | // TArrayI &idtmed = *fIdtmed; |
621 | // | |
622 | L10: | |
623 | for(i=0;i<130;i++) card[i]=0; | |
624 | iret=fscanf(lun,"%4s %[^\n]",key,card); | |
625 | if(iret<=0) goto L20; | |
626 | fscanf(lun,"%*c"); | |
627 | //* | |
628 | //* read material | |
629 | if (!strcmp(key,"MATE")) { | |
630 | sscanf(card,"%d '%[^']' %f %f %f %f %f %d",&imate,namate,&a,&z,&dens,&radl,&absl,&nwbuf); | |
631 | if (nwbuf>0) for(i=0;i<nwbuf;i++) fscanf(lun,"%f",&ubuf[i]); | |
632 | //Pad the string with blanks | |
633 | i=-1; | |
634 | while(namate[++i]); | |
635 | while(i<20) namate[i++]=' '; | |
636 | namate[i]='\0'; | |
637 | // | |
638 | AliMaterial(imate,namate,a,z,dens,radl,absl,ubuf,nwbuf); | |
639 | //* read tracking medium | |
640 | } else if (!strcmp(key,"TMED")) { | |
641 | sscanf(card,"%d '%[^']' %d %d %d %f %f %f %f %f %f %d", | |
642 | &itmed,natmed,&nmat,&isvol,&ifield,&fieldm,&tmaxfd, | |
643 | &stemax,&deemax,&epsil,&stmin,&nwbuf); | |
644 | if (nwbuf>0) for(i=0;i<nwbuf;i++) fscanf(lun,"%f",&ubuf[i]); | |
645 | if (ifield<0) ifield=isxfld; | |
646 | if (fieldm<0) fieldm=sxmgmx; | |
647 | //Pad the string with blanks | |
648 | i=-1; | |
649 | while(natmed[++i]); | |
650 | while(i<20) natmed[i++]=' '; | |
651 | natmed[i]='\0'; | |
652 | // | |
aee8290b | 653 | AliMedium(itmed,natmed,nmat,isvol,globField,globMaxField,tmaxfd, |
b13db077 | 654 | stemax,deemax,epsil,stmin,ubuf,nwbuf); |
655 | // (*fImedia)[idtmed[itmed]-1]=id_det; | |
656 | //* | |
657 | } | |
658 | //* | |
659 | if (strcmp(key,"END")) goto L10; | |
660 | fclose (lun); | |
661 | //* | |
662 | //* commented out only for the not cernlib version | |
9e1a0ddb | 663 | if(fDebug) printf("%s::ReadEuclidMedia: file %s is now read in\n", |
664 | ClassName(),filnam); | |
b13db077 | 665 | //* |
666 | return; | |
667 | //* | |
668 | L20: | |
669 | Warning("ReadEuclidMedia","reading error or premature end of file\n"); | |
670 | } | |
671 | ||
8494b010 | 672 |