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