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