]>
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 | ||
acd84897 | 16 | /* $Id$ */ |
4c039060 | 17 | |
8494b010 | 18 | /////////////////////////////////////////////////////////////////////////////// |
19 | // // | |
20 | // Base class for ALICE modules. Both sensitive modules (Modules) and // | |
21 | // non-sensitive ones are described by this base class. This class // | |
22 | // supports the hit and digit trees produced by the simulation and also // | |
23 | // the objects produced by the reconstruction. // | |
24 | // // | |
25 | // This class is also responsible for building the geometry of the // | |
26 | // Modules. // | |
27 | // // | |
28 | //Begin_Html | |
29 | /* | |
1439f98e | 30 | <img src="picts/AliModuleClass.gif"> |
8494b010 | 31 | */ |
32 | //End_Html | |
33 | // // | |
34 | /////////////////////////////////////////////////////////////////////////////// | |
94de3818 | 35 | #include <TNode.h> |
116cbefd | 36 | #include <TObjArray.h> |
2cad796f | 37 | #include <TClonesArray.h> |
38 | #include <TTree.h> | |
116cbefd | 39 | #include <TSystem.h> |
2cad796f | 40 | #include <TDirectory.h> |
94de3818 | 41 | |
8494b010 | 42 | #include "AliModule.h" |
43 | #include "AliRun.h" | |
94de3818 | 44 | #include "AliMagF.h" |
9e1a0ddb | 45 | #include "AliConfig.h" |
2cad796f | 46 | #include "AliTrackReference.h" |
8494b010 | 47 | |
48 | ClassImp(AliModule) | |
49 | ||
e2afb3b6 | 50 | //_______________________________________________________________________ |
51 | AliModule::AliModule(): | |
52 | fEuclidMaterial(""), | |
53 | fEuclidGeometry(""), | |
54 | fIdtmed(0), | |
55 | fIdmate(0), | |
56 | fLoMedium(0), | |
57 | fHiMedium(0), | |
58 | fActive(0), | |
59 | fHistograms(0), | |
60 | fNodes(0), | |
61 | fDebug(0), | |
2cad796f | 62 | fEnable(1), |
63 | fTrackReferences(0), | |
64 | fMaxIterTrackRef(0), | |
65 | fCurrentIterTrackRef(0) | |
8494b010 | 66 | { |
67 | // | |
68 | // Default constructor for the AliModule class | |
69 | // | |
8494b010 | 70 | } |
71 | ||
e2afb3b6 | 72 | //_______________________________________________________________________ |
73 | AliModule::AliModule(const char* name,const char *title): | |
74 | TNamed(name,title), | |
75 | fEuclidMaterial(""), | |
76 | fEuclidGeometry(""), | |
77 | fIdtmed(new TArrayI(100)), | |
78 | fIdmate(new TArrayI(100)), | |
79 | fLoMedium(65536), | |
80 | fHiMedium(0), | |
81 | fActive(0), | |
82 | fHistograms(new TList()), | |
83 | fNodes(new TList()), | |
84 | fDebug(0), | |
2cad796f | 85 | fEnable(1), |
86 | fTrackReferences(new TClonesArray("AliTrackReference", 100)), | |
87 | fMaxIterTrackRef(0), | |
88 | fCurrentIterTrackRef(0) | |
8494b010 | 89 | { |
90 | // | |
91 | // Normal constructor invoked by all Modules. | |
92 | // Create the list for Module specific histograms | |
93 | // Add this Module to the global list of Modules in Run. | |
94 | // | |
8494b010 | 95 | // Get the Module numeric ID |
96 | Int_t id = gAlice->GetModuleID(name); | |
02ca2762 | 97 | if (id>=0) { |
98 | // Module already added ! | |
99 | Warning("Ctor","Module: %s already present at %d\n",name,id); | |
8494b010 | 100 | return; |
101 | } | |
102 | // | |
103 | // Add this Module to the list of Modules | |
02ca2762 | 104 | gAlice->Modules()->Add(this); |
8494b010 | 105 | // |
106 | // | |
107 | SetMarkerColor(3); | |
108 | // | |
e2afb3b6 | 109 | // Clear space for tracking media and material indexes |
110 | ||
8494b010 | 111 | for(Int_t i=0;i<100;i++) (*fIdmate)[i]=(*fIdtmed)[i]=0; |
9e1a0ddb | 112 | |
113 | AliConfig::Instance()->Add(this); | |
114 | ||
65fb704d | 115 | SetDebug(gAlice->GetDebug()); |
8494b010 | 116 | } |
117 | ||
e2afb3b6 | 118 | //_______________________________________________________________________ |
119 | AliModule::AliModule(const AliModule &mod): | |
120 | TNamed(mod), | |
121 | TAttLine(mod), | |
122 | TAttMarker(mod), | |
123 | AliRndm(mod), | |
124 | fEuclidMaterial(""), | |
125 | fEuclidGeometry(""), | |
126 | fIdtmed(0), | |
127 | fIdmate(0), | |
128 | fLoMedium(0), | |
129 | fHiMedium(0), | |
130 | fActive(0), | |
131 | fHistograms(0), | |
132 | fNodes(0), | |
133 | fDebug(0), | |
2cad796f | 134 | fEnable(0), |
135 | fTrackReferences(0), | |
136 | fMaxIterTrackRef(0), | |
137 | fCurrentIterTrackRef(0) | |
aee8290b | 138 | { |
139 | // | |
140 | // Copy constructor | |
141 | // | |
8918e700 | 142 | mod.Copy(*this); |
aee8290b | 143 | } |
144 | ||
e2afb3b6 | 145 | //_______________________________________________________________________ |
8494b010 | 146 | AliModule::~AliModule() |
147 | { | |
148 | // | |
149 | // Destructor | |
150 | // | |
e2afb3b6 | 151 | |
bbcea4df | 152 | // Remove this Module from the list of Modules |
a9cc22a2 | 153 | if (gAlice) { |
154 | TObjArray * modules = gAlice->Modules(); | |
155 | if (modules) modules->Remove(this); | |
156 | } | |
8494b010 | 157 | // Delete ROOT geometry |
bf9b027f | 158 | if(fNodes) { |
159 | fNodes->Clear(); | |
160 | delete fNodes; | |
004a2444 | 161 | fNodes = 0; |
bf9b027f | 162 | } |
a1629660 | 163 | // Delete histograms |
164 | if(fHistograms) { | |
165 | fHistograms->Clear(); | |
166 | delete fHistograms; | |
004a2444 | 167 | fHistograms = 0; |
168 | } | |
169 | // Delete track references | |
170 | if (fTrackReferences) { | |
171 | fTrackReferences->Delete(); | |
172 | delete fTrackReferences; | |
173 | fTrackReferences = 0; | |
a1629660 | 174 | } |
8494b010 | 175 | // Delete TArray objects |
176 | delete fIdtmed; | |
177 | delete fIdmate; | |
178 | } | |
179 | ||
e2afb3b6 | 180 | //_______________________________________________________________________ |
8918e700 | 181 | void AliModule::Copy(AliModule & /* mod */) const |
aee8290b | 182 | { |
183 | // | |
184 | // Copy *this onto mod, not implemented for AliModule | |
185 | // | |
186 | Fatal("Copy","Not implemented!\n"); | |
187 | } | |
188 | ||
e2afb3b6 | 189 | //_______________________________________________________________________ |
8494b010 | 190 | void AliModule::Disable() |
191 | { | |
192 | // | |
193 | // Disable Module on viewer | |
194 | // | |
195 | fActive = kFALSE; | |
196 | TIter next(fNodes); | |
197 | TNode *node; | |
198 | // | |
199 | // Loop through geometry to disable all | |
200 | // nodes for this Module | |
e2afb3b6 | 201 | while((node = dynamic_cast<TNode*>(next()))) { |
5bef1017 | 202 | node->SetVisibility(-1); |
8494b010 | 203 | } |
204 | } | |
205 | ||
e2afb3b6 | 206 | //_______________________________________________________________________ |
116cbefd | 207 | Int_t AliModule::DistancetoPrimitive(Int_t, Int_t) const |
8494b010 | 208 | { |
209 | // | |
210 | // Return distance from mouse pointer to object | |
211 | // Dummy routine for the moment | |
212 | // | |
213 | return 9999; | |
214 | } | |
215 | ||
e2afb3b6 | 216 | //_______________________________________________________________________ |
8494b010 | 217 | void AliModule::Enable() |
218 | { | |
219 | // | |
220 | // Enable Module on the viewver | |
221 | // | |
222 | fActive = kTRUE; | |
223 | TIter next(fNodes); | |
224 | TNode *node; | |
225 | // | |
226 | // Loop through geometry to enable all | |
227 | // nodes for this Module | |
e2afb3b6 | 228 | while((node = dynamic_cast<TNode*>(next()))) { |
5bef1017 | 229 | node->SetVisibility(3); |
8494b010 | 230 | } |
231 | } | |
232 | ||
e2afb3b6 | 233 | //_______________________________________________________________________ |
8494b010 | 234 | void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a, |
e2afb3b6 | 235 | Float_t z, Float_t dens, Float_t radl, |
236 | Float_t absl, Float_t *buf, Int_t nwbuf) const | |
8494b010 | 237 | { |
238 | // | |
239 | // Store the parameters for a material | |
240 | // | |
241 | // imat the material index will be stored in (*fIdmate)[imat] | |
242 | // name material name | |
243 | // a atomic mass | |
244 | // z atomic number | |
245 | // dens density | |
246 | // radl radiation length | |
247 | // absl absorbtion length | |
248 | // buf adress of an array user words | |
249 | // nwbuf number of user words | |
250 | // | |
251 | Int_t kmat; | |
cfce8870 | 252 | gMC->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf); |
8494b010 | 253 | (*fIdmate)[imat]=kmat; |
254 | } | |
255 | ||
e2afb3b6 | 256 | //_______________________________________________________________________ |
0afa509f | 257 | void AliModule::AliGetMaterial(Int_t imat, char* name, Float_t &a, |
e2afb3b6 | 258 | Float_t &z, Float_t &dens, Float_t &radl, |
116cbefd | 259 | Float_t &absl) const |
0afa509f | 260 | { |
261 | // | |
262 | // Store the parameters for a material | |
263 | // | |
264 | // imat the material index will be stored in (*fIdmate)[imat] | |
265 | // name material name | |
266 | // a atomic mass | |
267 | // z atomic number | |
268 | // dens density | |
269 | // radl radiation length | |
270 | // absl absorbtion length | |
271 | // buf adress of an array user words | |
272 | // nwbuf number of user words | |
273 | // | |
274 | ||
275 | Float_t buf[10]; | |
276 | Int_t nwbuf, kmat; | |
277 | kmat=(*fIdmate)[imat]; | |
278 | gMC->Gfmate(kmat, name, a, z, dens, radl, absl, buf, nwbuf); | |
279 | } | |
280 | ||
8494b010 | 281 | |
e2afb3b6 | 282 | //_______________________________________________________________________ |
8494b010 | 283 | void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a, |
e2afb3b6 | 284 | Float_t *z, Float_t dens, Int_t nlmat, |
285 | Float_t *wmat) const | |
8494b010 | 286 | { |
287 | // | |
288 | // Defines mixture or compound imat as composed by | |
289 | // nlmat materials defined by arrays a, z and wmat | |
290 | // | |
291 | // If nlmat > 0 wmat contains the proportion by | |
292 | // weights of each basic material in the mixture | |
293 | // | |
294 | // If nlmat < 0 wmat contains the number of atoms | |
295 | // of eack kind in the molecule of the compound | |
296 | // In this case, wmat is changed on output to the relative weigths. | |
297 | // | |
298 | // imat the material index will be stored in (*fIdmate)[imat] | |
299 | // name material name | |
300 | // a array of atomic masses | |
301 | // z array of atomic numbers | |
302 | // dens density | |
303 | // nlmat number of components | |
304 | // wmat array of concentrations | |
305 | // | |
306 | Int_t kmat; | |
cfce8870 | 307 | gMC->Mixture(kmat, name, a, z, dens, nlmat, wmat); |
8494b010 | 308 | (*fIdmate)[imat]=kmat; |
309 | } | |
310 | ||
e2afb3b6 | 311 | //_______________________________________________________________________ |
8494b010 | 312 | void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat, |
e2afb3b6 | 313 | Int_t isvol, Int_t ifield, Float_t fieldm, |
314 | Float_t tmaxfd, Float_t stemax, Float_t deemax, | |
315 | Float_t epsil, Float_t stmin, Float_t *ubuf, | |
316 | Int_t nbuf) const | |
8494b010 | 317 | { |
318 | // | |
319 | // Store the parameters of a tracking medium | |
320 | // | |
b13db077 | 321 | // numed the medium number is stored into (*fIdtmed)[numed] |
8494b010 | 322 | // name medium name |
323 | // nmat the material number is stored into (*fIdmate)[nmat] | |
324 | // isvol sensitive volume if isvol!=0 | |
325 | // ifield magnetic field flag (see below) | |
326 | // fieldm maximum magnetic field | |
327 | // tmaxfd maximum deflection angle due to magnetic field | |
328 | // stemax maximum step allowed | |
329 | // deemax maximum fractional energy loss in one step | |
330 | // epsil tracking precision in cm | |
331 | // stmin minimum step due to continuous processes | |
332 | // | |
333 | // ifield = 0 no magnetic field | |
334 | // = -1 user decision in guswim | |
335 | // = 1 tracking performed with Runge Kutta | |
336 | // = 2 tracking performed with helix | |
337 | // = 3 constant magnetic field along z | |
338 | // | |
339 | Int_t kmed; | |
cfce8870 | 340 | gMC->Medium(kmed,name, (*fIdmate)[nmat], isvol, ifield, fieldm, |
8494b010 | 341 | tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); |
ad51aeb0 | 342 | (*fIdtmed)[numed]=kmed; |
8494b010 | 343 | } |
344 | ||
e2afb3b6 | 345 | //_______________________________________________________________________ |
8494b010 | 346 | void AliModule::AliMatrix(Int_t &nmat, Float_t theta1, Float_t phi1, |
e2afb3b6 | 347 | Float_t theta2, Float_t phi2, Float_t theta3, |
348 | Float_t phi3) const | |
8494b010 | 349 | { |
350 | // | |
351 | // Define a rotation matrix. Angles are in degrees. | |
352 | // | |
353 | // nmat on output contains the number assigned to the rotation matrix | |
354 | // theta1 polar angle for axis I | |
355 | // phi1 azimuthal angle for axis I | |
356 | // theta2 polar angle for axis II | |
357 | // phi2 azimuthal angle for axis II | |
358 | // theta3 polar angle for axis III | |
359 | // phi3 azimuthal angle for axis III | |
360 | // | |
cfce8870 | 361 | gMC->Matrix(nmat, theta1, phi1, theta2, phi2, theta3, phi3); |
8494b010 | 362 | } |
363 | ||
e2afb3b6 | 364 | //_______________________________________________________________________ |
65fb704d | 365 | Float_t AliModule::ZMin() const |
366 | { | |
367 | return -500; | |
368 | } | |
369 | ||
e2afb3b6 | 370 | //_______________________________________________________________________ |
65fb704d | 371 | Float_t AliModule::ZMax() const |
372 | { | |
373 | return 500; | |
374 | } | |
375 | ||
e2afb3b6 | 376 | //_______________________________________________________________________ |
8494b010 | 377 | void AliModule::SetEuclidFile(char* material, char* geometry) |
378 | { | |
379 | // | |
380 | // Sets the name of the Euclid file | |
381 | // | |
382 | fEuclidMaterial=material; | |
383 | if(geometry) { | |
384 | fEuclidGeometry=geometry; | |
385 | } else { | |
386 | char* name = new char[strlen(material)]; | |
387 | strcpy(name,material); | |
388 | strcpy(&name[strlen(name)-4],".euc"); | |
389 | fEuclidGeometry=name; | |
390 | delete [] name; | |
391 | } | |
392 | } | |
393 | ||
e2afb3b6 | 394 | //_______________________________________________________________________ |
b13db077 | 395 | void AliModule::ReadEuclid(const char* filnam, char* topvol) |
396 | { | |
397 | // | |
398 | // read in the geometry of the detector in euclid file format | |
399 | // | |
400 | // id_det : the detector identification (2=its,...) | |
401 | // topvol : return parameter describing the name of the top | |
402 | // volume of geometry. | |
403 | // | |
404 | // author : m. maire | |
405 | // | |
406 | // 28.07.98 | |
407 | // several changes have been made by miroslav helbich | |
408 | // subroutine is rewrited to follow the new established way of memory | |
409 | // booking for tracking medias and rotation matrices. | |
410 | // all used tracking media have to be defined first, for this you can use | |
411 | // subroutine greutmed. | |
412 | // top volume is searched as only volume not positioned into another | |
413 | // | |
414 | ||
415 | Int_t i, nvol, iret, itmed, irot, numed, npar, ndiv, iaxe; | |
416 | Int_t ndvmx, nr, flag; | |
417 | char key[5], card[77], natmed[21]; | |
418 | char name[5], mother[5], shape[5], konly[5], volst[7000][5]; | |
419 | char *filtmp; | |
d43b40e2 | 420 | Float_t par[100]; |
b13db077 | 421 | Float_t teta1, phi1, teta2, phi2, teta3, phi3, orig, step; |
422 | Float_t xo, yo, zo; | |
aee8290b | 423 | const Int_t kMaxRot=5000; |
424 | Int_t idrot[kMaxRot],istop[7000]; | |
b13db077 | 425 | FILE *lun; |
426 | // | |
427 | // *** The input filnam name will be with extension '.euc' | |
428 | filtmp=gSystem->ExpandPathName(filnam); | |
429 | lun=fopen(filtmp,"r"); | |
430 | delete [] filtmp; | |
431 | if(!lun) { | |
432 | Error("ReadEuclid","Could not open file %s\n",filnam); | |
433 | return; | |
434 | } | |
435 | //* --- definition of rotation matrix 0 --- | |
436 | TArrayI &idtmed = *fIdtmed; | |
aee8290b | 437 | for(i=1; i<kMaxRot; ++i) idrot[i]=-99; |
b13db077 | 438 | idrot[0]=0; |
439 | nvol=0; | |
440 | L10: | |
441 | for(i=0;i<77;i++) card[i]=0; | |
442 | iret=fscanf(lun,"%77[^\n]",card); | |
443 | if(iret<=0) goto L20; | |
444 | fscanf(lun,"%*c"); | |
445 | //* | |
446 | strncpy(key,card,4); | |
447 | key[4]='\0'; | |
448 | if (!strcmp(key,"TMED")) { | |
449 | sscanf(&card[5],"%d '%[^']'",&itmed,natmed); | |
450 | if( itmed<0 || itmed>=100 ) { | |
451 | Error("ReadEuclid","TMED illegal medium number %d for %s\n",itmed,natmed); | |
452 | exit(1); | |
453 | } | |
454 | //Pad the string with blanks | |
455 | i=-1; | |
456 | while(natmed[++i]); | |
457 | while(i<20) natmed[i++]=' '; | |
458 | natmed[i]='\0'; | |
459 | // | |
460 | if( idtmed[itmed]<=0 ) { | |
461 | Error("ReadEuclid","TMED undefined medium number %d for %s\n",itmed,natmed); | |
462 | exit(1); | |
463 | } | |
464 | gMC->Gckmat(idtmed[itmed],natmed); | |
465 | //* | |
466 | } else if (!strcmp(key,"ROTM")) { | |
467 | sscanf(&card[4],"%d %f %f %f %f %f %f",&irot,&teta1,&phi1,&teta2,&phi2,&teta3,&phi3); | |
aee8290b | 468 | if( irot<=0 || irot>=kMaxRot ) { |
b13db077 | 469 | Error("ReadEuclid","ROTM rotation matrix number %d illegal\n",irot); |
470 | exit(1); | |
471 | } | |
472 | AliMatrix(idrot[irot],teta1,phi1,teta2,phi2,teta3,phi3); | |
473 | //* | |
474 | } else if (!strcmp(key,"VOLU")) { | |
475 | sscanf(&card[5],"'%[^']' '%[^']' %d %d", name, shape, &numed, &npar); | |
476 | if (npar>0) { | |
477 | for(i=0;i<npar;i++) fscanf(lun,"%f",&par[i]); | |
478 | fscanf(lun,"%*c"); | |
479 | } | |
480 | gMC->Gsvolu( name, shape, idtmed[numed], par, npar); | |
481 | //* save the defined volumes | |
482 | strcpy(volst[++nvol],name); | |
483 | istop[nvol]=1; | |
484 | //* | |
485 | } else if (!strcmp(key,"DIVN")) { | |
486 | sscanf(&card[5],"'%[^']' '%[^']' %d %d", name, mother, &ndiv, &iaxe); | |
487 | gMC->Gsdvn ( name, mother, ndiv, iaxe ); | |
488 | //* | |
489 | } else if (!strcmp(key,"DVN2")) { | |
490 | sscanf(&card[5],"'%[^']' '%[^']' %d %d %f %d",name, mother, &ndiv, &iaxe, &orig, &numed); | |
491 | gMC->Gsdvn2( name, mother, ndiv, iaxe, orig,idtmed[numed]); | |
492 | //* | |
493 | } else if (!strcmp(key,"DIVT")) { | |
494 | sscanf(&card[5],"'%[^']' '%[^']' %f %d %d %d", name, mother, &step, &iaxe, &numed, &ndvmx); | |
495 | gMC->Gsdvt ( name, mother, step, iaxe, idtmed[numed], ndvmx); | |
496 | //* | |
497 | } else if (!strcmp(key,"DVT2")) { | |
498 | sscanf(&card[5],"'%[^']' '%[^']' %f %d %f %d %d", name, mother, &step, &iaxe, &orig, &numed, &ndvmx); | |
499 | gMC->Gsdvt2 ( name, mother, step, iaxe, orig, idtmed[numed], ndvmx ); | |
500 | //* | |
501 | } else if (!strcmp(key,"POSI")) { | |
502 | sscanf(&card[5],"'%[^']' %d '%[^']' %f %f %f %d '%[^']'", name, &nr, mother, &xo, &yo, &zo, &irot, konly); | |
aee8290b | 503 | if( irot<0 || irot>=kMaxRot ) { |
b13db077 | 504 | Error("ReadEuclid","POSI %s#%d rotation matrix number %d illegal\n",name,nr,irot); |
505 | exit(1); | |
506 | } | |
507 | if( idrot[irot] == -99) { | |
508 | Error("ReadEuclid","POSI %s#%d undefined matrix number %d\n",name,nr,irot); | |
509 | exit(1); | |
510 | } | |
511 | //*** volume name cannot be the top volume | |
512 | for(i=1;i<=nvol;i++) { | |
513 | if (!strcmp(volst[i],name)) istop[i]=0; | |
514 | } | |
515 | //* | |
516 | gMC->Gspos ( name, nr, mother, xo, yo, zo, idrot[irot], konly ); | |
517 | //* | |
518 | } else if (!strcmp(key,"POSP")) { | |
519 | sscanf(&card[5],"'%[^']' %d '%[^']' %f %f %f %d '%[^']' %d", name, &nr, mother, &xo, &yo, &zo, &irot, konly, &npar); | |
aee8290b | 520 | if( irot<0 || irot>=kMaxRot ) { |
b13db077 | 521 | Error("ReadEuclid","POSP %s#%d rotation matrix number %d illegal\n",name,nr,irot); |
522 | exit(1); | |
523 | } | |
524 | if( idrot[irot] == -99) { | |
525 | Error("ReadEuclid","POSP %s#%d undefined matrix number %d\n",name,nr,irot); | |
526 | exit(1); | |
527 | } | |
528 | if (npar > 0) { | |
529 | for(i=0;i<npar;i++) fscanf(lun,"%f",&par[i]); | |
530 | fscanf(lun,"%*c"); | |
531 | } | |
532 | //*** volume name cannot be the top volume | |
533 | for(i=1;i<=nvol;i++) { | |
534 | if (!strcmp(volst[i],name)) istop[i]=0; | |
535 | } | |
536 | //* | |
537 | gMC->Gsposp ( name, nr, mother, xo,yo,zo, idrot[irot], konly, par, npar); | |
538 | } | |
539 | //* | |
540 | if (strcmp(key,"END")) goto L10; | |
541 | //* find top volume in the geometry | |
542 | flag=0; | |
543 | for(i=1;i<=nvol;i++) { | |
544 | if (istop[i] && flag) { | |
545 | Warning("ReadEuclid"," %s is another possible top volume\n",volst[i]); | |
546 | } | |
547 | if (istop[i] && !flag) { | |
548 | strcpy(topvol,volst[i]); | |
9e1a0ddb | 549 | if(fDebug) printf("%s::ReadEuclid: volume %s taken as a top volume\n",ClassName(),topvol); |
b13db077 | 550 | flag=1; |
551 | } | |
552 | } | |
553 | if (!flag) { | |
554 | Warning("ReadEuclid","top volume not found\n"); | |
555 | } | |
556 | fclose (lun); | |
557 | //* | |
558 | //* commented out only for the not cernlib version | |
9e1a0ddb | 559 | if(fDebug) printf("%s::ReadEuclid: file: %s is now read in\n",ClassName(),filnam); |
b13db077 | 560 | // |
561 | return; | |
562 | //* | |
563 | L20: | |
564 | Error("ReadEuclid","reading error or premature end of file\n"); | |
565 | } | |
566 | ||
e2afb3b6 | 567 | //_______________________________________________________________________ |
b13db077 | 568 | void AliModule::ReadEuclidMedia(const char* filnam) |
569 | { | |
570 | // | |
571 | // read in the materials and tracking media for the detector | |
572 | // in euclid file format | |
573 | // | |
574 | // filnam: name of the input file | |
575 | // id_det: id_det is the detector identification (2=its,...) | |
576 | // | |
577 | // author : miroslav helbich | |
578 | // | |
579 | Float_t sxmgmx = gAlice->Field()->Max(); | |
580 | Int_t isxfld = gAlice->Field()->Integ(); | |
581 | Int_t end, i, iret, itmed; | |
582 | char key[5], card[130], natmed[21], namate[21]; | |
583 | Float_t ubuf[50]; | |
584 | char* filtmp; | |
585 | FILE *lun; | |
586 | Int_t imate; | |
587 | Int_t nwbuf, isvol, ifield, nmat; | |
588 | Float_t a, z, dens, radl, absl, fieldm, tmaxfd, stemax, deemax, epsil, stmin; | |
589 | // | |
590 | end=strlen(filnam); | |
591 | for(i=0;i<end;i++) if(filnam[i]=='.') { | |
592 | end=i; | |
593 | break; | |
594 | } | |
595 | // | |
596 | // *** The input filnam name will be with extension '.euc' | |
9e1a0ddb | 597 | if(fDebug) printf("%s::ReadEuclid: The file name is %s\n",ClassName(),filnam); //Debug |
b13db077 | 598 | filtmp=gSystem->ExpandPathName(filnam); |
599 | lun=fopen(filtmp,"r"); | |
600 | delete [] filtmp; | |
601 | if(!lun) { | |
602 | Warning("ReadEuclidMedia","Could not open file %s\n",filnam); | |
603 | return; | |
604 | } | |
605 | // | |
606 | // Retrieve Mag Field parameters | |
aee8290b | 607 | Int_t globField=gAlice->Field()->Integ(); |
608 | Float_t globMaxField=gAlice->Field()->Max(); | |
b13db077 | 609 | // TArrayI &idtmed = *fIdtmed; |
610 | // | |
611 | L10: | |
612 | for(i=0;i<130;i++) card[i]=0; | |
613 | iret=fscanf(lun,"%4s %[^\n]",key,card); | |
614 | if(iret<=0) goto L20; | |
615 | fscanf(lun,"%*c"); | |
616 | //* | |
617 | //* read material | |
618 | if (!strcmp(key,"MATE")) { | |
619 | sscanf(card,"%d '%[^']' %f %f %f %f %f %d",&imate,namate,&a,&z,&dens,&radl,&absl,&nwbuf); | |
620 | if (nwbuf>0) for(i=0;i<nwbuf;i++) fscanf(lun,"%f",&ubuf[i]); | |
621 | //Pad the string with blanks | |
622 | i=-1; | |
623 | while(namate[++i]); | |
624 | while(i<20) namate[i++]=' '; | |
625 | namate[i]='\0'; | |
626 | // | |
627 | AliMaterial(imate,namate,a,z,dens,radl,absl,ubuf,nwbuf); | |
628 | //* read tracking medium | |
629 | } else if (!strcmp(key,"TMED")) { | |
630 | sscanf(card,"%d '%[^']' %d %d %d %f %f %f %f %f %f %d", | |
631 | &itmed,natmed,&nmat,&isvol,&ifield,&fieldm,&tmaxfd, | |
632 | &stemax,&deemax,&epsil,&stmin,&nwbuf); | |
633 | if (nwbuf>0) for(i=0;i<nwbuf;i++) fscanf(lun,"%f",&ubuf[i]); | |
634 | if (ifield<0) ifield=isxfld; | |
635 | if (fieldm<0) fieldm=sxmgmx; | |
636 | //Pad the string with blanks | |
637 | i=-1; | |
638 | while(natmed[++i]); | |
639 | while(i<20) natmed[i++]=' '; | |
640 | natmed[i]='\0'; | |
641 | // | |
aee8290b | 642 | AliMedium(itmed,natmed,nmat,isvol,globField,globMaxField,tmaxfd, |
b13db077 | 643 | stemax,deemax,epsil,stmin,ubuf,nwbuf); |
644 | // (*fImedia)[idtmed[itmed]-1]=id_det; | |
645 | //* | |
646 | } | |
647 | //* | |
648 | if (strcmp(key,"END")) goto L10; | |
649 | fclose (lun); | |
650 | //* | |
651 | //* commented out only for the not cernlib version | |
9e1a0ddb | 652 | if(fDebug) printf("%s::ReadEuclidMedia: file %s is now read in\n", |
653 | ClassName(),filnam); | |
b13db077 | 654 | //* |
655 | return; | |
656 | //* | |
657 | L20: | |
658 | Warning("ReadEuclidMedia","reading error or premature end of file\n"); | |
659 | } | |
2cad796f | 660 | |
661 | //_______________________________________________________________________ | |
662 | void AliModule::RemapTrackReferencesIDs(Int_t *map) | |
663 | { | |
664 | // | |
665 | // Remapping track reference | |
666 | // Called at finish primary | |
667 | // | |
668 | if (!fTrackReferences) return; | |
669 | for (Int_t i=0;i<fTrackReferences->GetEntries();i++){ | |
670 | AliTrackReference * ref = dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(i)); | |
671 | if (ref) { | |
672 | Int_t newID = map[ref->GetTrack()]; | |
673 | if (newID>=0) ref->SetTrack(newID); | |
674 | else ref->SetTrack(-1); | |
675 | ||
676 | } | |
677 | } | |
678 | } | |
679 | ||
680 | ||
681 | //_______________________________________________________________________ | |
682 | AliTrackReference* AliModule::FirstTrackReference(Int_t track) | |
683 | { | |
684 | // | |
685 | // Initialise the hit iterator | |
686 | // Return the address of the first hit for track | |
687 | // If track>=0 the track is read from disk | |
688 | // while if track<0 the first hit of the current | |
689 | // track is returned | |
690 | // | |
691 | if(track>=0) { | |
692 | gAlice->ResetTrackReferences(); | |
693 | gAlice->TreeTR()->GetEvent(track); | |
694 | } | |
695 | // | |
696 | fMaxIterTrackRef = fTrackReferences->GetEntriesFast(); | |
697 | fCurrentIterTrackRef = 0; | |
698 | if(fMaxIterTrackRef) return dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(0)); | |
699 | else return 0; | |
700 | } | |
701 | ||
702 | //_______________________________________________________________________ | |
703 | AliTrackReference* AliModule::NextTrackReference() | |
704 | { | |
705 | // | |
706 | // Return the next hit for the current track | |
707 | // | |
708 | if(fMaxIterTrackRef) { | |
709 | if(++fCurrentIterTrackRef<fMaxIterTrackRef) | |
710 | return dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(fCurrentIterTrackRef)); | |
711 | else | |
712 | return 0; | |
713 | } else { | |
714 | printf("* AliDetector::NextTrackReference * TrackReference Iterator called without calling FistTrackReference before\n"); | |
715 | return 0; | |
716 | } | |
717 | } | |
718 | ||
719 | ||
720 | //_______________________________________________________________________ | |
721 | void AliModule::ResetTrackReferences() | |
722 | { | |
723 | // | |
724 | // Reset number of hits and the hits array | |
725 | // | |
726 | fMaxIterTrackRef = 0; | |
727 | if (fTrackReferences) fTrackReferences->Clear(); | |
728 | } | |
b13db077 | 729 | |
8494b010 | 730 | |
2cad796f | 731 | |
732 | void AliModule::SetTreeAddress() | |
733 | { | |
734 | // | |
735 | // Set branch address for the Hits and Digits Trees | |
736 | // | |
737 | TBranch *branch; | |
738 | char branchname[20]; | |
739 | sprintf(branchname,"%s",GetName()); | |
740 | // Branch address for track reference tree | |
741 | TTree *treeTR = gAlice->TreeTR(); | |
742 | if (treeTR && fTrackReferences) { | |
743 | branch = treeTR->GetBranch(branchname); | |
744 | if (branch) branch->SetAddress(&fTrackReferences); | |
745 | } | |
746 | } | |
747 | ||
748 | void AliModule::AddTrackReference(Int_t label){ | |
749 | // | |
750 | // add a trackrefernce to the list | |
751 | if (!fTrackReferences) { | |
752 | cerr<<"Container trackrefernce not active\n"; | |
753 | return; | |
754 | } | |
755 | Int_t nref = fTrackReferences->GetEntriesFast(); | |
756 | TClonesArray &lref = *fTrackReferences; | |
757 | new(lref[nref]) AliTrackReference(label); | |
758 | } | |
759 | ||
760 | ||
761 | void AliModule::MakeBranchTR(Option_t *option, const char *file) | |
762 | { | |
763 | // | |
764 | // Makes branch in treeTR | |
765 | // | |
766 | char name[10]; | |
767 | sprintf(name,"%s",GetName()); | |
768 | ||
769 | if (GetDebug()>1) | |
770 | printf("* MakeBranch * Making Branch %s \n",name); | |
771 | ||
772 | TDirectory *cwd = gDirectory; | |
773 | TBranch *branch = 0; | |
774 | TTree* tree = gAlice->TreeTR(); | |
775 | if (tree) { | |
776 | branch = tree->Branch(name, &fTrackReferences, 1600); | |
777 | if (file) { | |
778 | char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2]; | |
779 | sprintf(outFile,"%s/%s",gAlice->GetBaseFile(),file); | |
780 | branch->SetFile(outFile); | |
781 | TIter next( branch->GetListOfBranches()); | |
782 | while ((branch=dynamic_cast<TBranch*>(next()))) { | |
783 | branch->SetFile(outFile); | |
784 | } | |
785 | delete outFile; | |
786 | ||
787 | cwd->cd(); | |
788 | ||
789 | if (GetDebug()>1) | |
790 | printf("* MakeBranch * Diverting Branch %s to file %s\n",name,file); | |
791 | } | |
792 | } | |
793 | } |