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