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