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