]> git.uio.no Git - u/mrichter/AliRoot.git/blob - GEODB/AliGEODB.cxx
Streamlining of CodeAnalysis. .ii files are kept for reverse engineering
[u/mrichter/AliRoot.git] / GEODB / AliGEODB.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.2  1999/09/29 09:24:19  fca
19 Introduction of the Copyright and cvs Log
20
21 */
22
23 //////////////////////////////////////////////////////
24 //  C++ dummy interface to Geant3 basic routines    //
25 //////////////////////////////////////////////////////
26
27 #include <iostream.h>
28 #include <TBrowser.h>
29 #include <TCanvas.h>
30 #include "AliGEODB.h"
31 #include "AliGNode.h"
32 #include "AliGShape.h"
33 #include "AliGMaterial.h"
34 #include "AliGTransform.h"
35 #include "AliGTube.h"
36 #include "AliGBox.h"
37 #include "AliGTRD1.h"
38 #include "AliGPCone.h"
39 #include "AliGeometry.h"
40
41 //---------------------------------------------------------
42
43 #define MAXMAT 1000
44
45 struct Mater{
46     char*    fName;
47     Float_t  fA;
48     Float_t  fZ;
49     Float_t  fDens;
50     Float_t  fRadl;
51     Float_t  fAbsl;
52     Float_t* fBuf;
53     Int_t    fNwbuf;
54 };
55
56 Mater* AliMaterials[MAXMAT]; // Array of Mater structs containing the AliMaterial parameters.
57
58 struct Med{
59     char*    fName;
60     Int_t    fNmat;
61     Int_t    fIsvol;
62     Int_t    fIfield;
63     Float_t  fFieldm;
64     Float_t  fTmaxfd;
65     Float_t  fStemax;
66     Float_t  fDeemax;
67     Float_t  fEpsil;
68     Float_t  fStmin;
69     Float_t* fUbuf;
70     Int_t    fNbuf;
71 };
72
73 Med* AliMediums[MAXMAT]; // Array of Med structs containing the AliMedium parameters.
74
75 struct NodePosp{
76     char* name;
77     char* shape;
78     Int_t nmed;
79 };
80
81 NodePosp* Posp[MAXMAT];
82
83 AliGMaterial* Mat[MAXMAT]; // List of Pointers to my AliGMaterials created
84
85 Int_t  MateCount   = 0;
86 Int_t  MedCount    = 0;
87 Int_t  MatrCount   = 0;
88 Int_t  PospCount   = 0;
89 Int_t  Color       = 2;
90
91 TList* listNodes     = new TList(); // List of Nodes
92 TList* listTransf    = new TList();
93 TList* listShapes    = new TList();
94 TList* listMaterials = new TList();
95
96 AliGNode* TopNode    = NULL;
97
98 /***********************************************************************/
99
100 ClassImp(AliGEODB)
101
102 /***********************************************************************/
103
104 AliGEODB::AliGEODB(const char *title, Int_t) : AliMC("AliGEODB",title)
105 {
106     //cout << " AliGEODB" << endl;
107 }
108
109 /***********************************************************************/
110
111 void AliGEODB::DefaultRange() 
112 {
113     cout << " DefaultRange" << endl;
114 }
115  
116 //=======================functions from GBASE
117
118 /***********************************************************************/
119
120 void    AliGEODB::Gfile(const char*, const char*) 
121 {
122     cout << " Gfile" << endl;
123 }
124
125 /***********************************************************************/
126
127 void    AliGEODB::GeomIter() 
128 {
129     cout << " GeomIter" << endl;
130 }
131
132 /***********************************************************************/
133
134 Int_t   AliGEODB::CurrentMaterial(Float_t &, Float_t &, Float_t &, Float_t &, Float_t &) const 
135 {
136     cout << " CurrentMaterial" << endl;
137     return 0;
138 }
139
140 /***********************************************************************/
141
142 Int_t   AliGEODB::NextVolUp(Text_t*, Int_t&) 
143 {
144     cout << " NextVolUp" << endl;
145     return 0;
146 }
147
148 /***********************************************************************/
149
150 Int_t   AliGEODB::CurrentVol(Text_t*, Int_t&) const 
151 {
152     cout << " CurrentVol" << endl;
153     return 0;
154 }
155
156 /***********************************************************************/
157
158 Int_t   AliGEODB::NofVolumes() const 
159 {
160     cout << " NofVolumes" << endl;
161     return 0;
162 }
163
164 /***********************************************************************/
165
166 Int_t   AliGEODB::CurrentVolOff(Int_t, Text_t*, Int_t&) const 
167 {
168     cout << " CurrentVolOff" << endl;
169     return 0;
170 }
171
172 /***********************************************************************/
173
174 void    AliGEODB::TrackPosition(Float_t*) const 
175 {
176     cout << " TrackPosition" << endl;
177 }
178
179 /***********************************************************************/
180
181 void    AliGEODB::TrackMomentum(Float_t*) const 
182 {
183     cout << " TrackMomentum" << endl;
184 }
185
186 /***********************************************************************/
187
188 Int_t   AliGEODB::VolId( Text_t* name ) const 
189 {
190     cout << " VolId" << endl;
191     return 0;
192 }
193
194 /***********************************************************************/
195
196 const char* AliGEODB::VolName(Int_t ) const 
197 {
198     cout << " VolName" << endl;
199     return 0;
200 }
201
202 /***********************************************************************/
203     
204 Float_t AliGEODB::TrackCharge() const 
205 {
206     cout << " TrackCharge" << endl;
207     return 0;
208 }
209
210 /***********************************************************************/
211
212 Float_t AliGEODB::TrackMass() const 
213 {
214     cout << " TrackMass" << endl;
215     return 0;
216 }
217
218 /***********************************************************************/
219
220 Bool_t  AliGEODB::TrackInside() const 
221 {
222     cout << " TrackInside" << endl;
223     return 0;
224 }
225
226 /***********************************************************************/
227
228 Bool_t  AliGEODB::TrackEntering() const 
229 {
230     cout << " TrackEntering" << endl;
231     return 0;
232 }
233
234 /***********************************************************************/
235
236 Bool_t  AliGEODB::TrackExiting() const 
237 {
238     cout << " TrackExiting" << endl;
239     return 0;
240 }
241
242 /***********************************************************************/
243
244 Bool_t  AliGEODB::TrackOut() const 
245 {
246     cout << " TrackOut" << endl;
247     return 0;
248 }
249
250 /***********************************************************************/
251
252 Bool_t  AliGEODB::TrackDisappear() const 
253 {
254     cout << " TrackDisappear" << endl;
255     return 0;
256 }
257
258 /***********************************************************************/
259
260 Bool_t  AliGEODB::TrackStop() const 
261 {
262     cout << " TrackStop" << endl;
263     return 0;
264 }
265
266 /***********************************************************************/
267
268 Int_t   AliGEODB::NSecondaries() const 
269 {
270     cout << " NSecondaries" << endl;
271     return 0;
272 }
273
274 /***********************************************************************/
275
276 const char* AliGEODB::ProdProcess() const 
277 {
278     cout << " ProdProcess" << endl;
279     return 0;
280 }
281
282 /***********************************************************************/
283
284 void    AliGEODB::GetSecondary(Int_t, Int_t&, Float_t*, Float_t*)
285 {
286     cout << " GetSecondary" << endl;
287 }
288
289 /***********************************************************************/
290
291 Float_t AliGEODB::MaxStep() const 
292 {
293     cout << " MaxStep" << endl;
294     return 0;
295 }
296
297 /***********************************************************************/
298
299 void    AliGEODB::SetMaxStep(Float_t ) 
300 {
301     cout << " SetMaxStep" << endl;
302 }
303
304 /***********************************************************************/
305
306 void    AliGEODB::GetParticle(const Int_t, char*, Float_t&) const 
307 {
308     cout << " GetParticle" << endl;
309 }
310
311 /***********************************************************************/
312
313 Int_t   AliGEODB::CurrentEvent() const 
314 {
315     cout << " CurrentEvent" << endl;
316     return 0;
317 }
318
319 /***********************************************************************/
320
321 Int_t   AliGEODB::GetMedium() const 
322 {
323     cout << " GetMedium" << endl;
324     return 0;
325 }
326
327 /***********************************************************************/
328
329 Float_t AliGEODB::Edep() const 
330 {
331     cout << " Edep" << endl;
332     return 0;
333 }
334
335 /***********************************************************************/
336     
337 Float_t AliGEODB::Etot() const 
338 {
339     cout << " Etot" << endl;
340     return 0;
341 }
342
343 /***********************************************************************/
344
345 void    AliGEODB::Rndm(Float_t*, const Int_t) const 
346 {
347     cout << " Rndm" << endl;
348 }
349
350 /***********************************************************************/
351
352 Float_t AliGEODB::TrackStep() const 
353 {
354     cout << " TrackStep" << endl;
355     return 0;
356 }
357
358 /***********************************************************************/
359     
360 Float_t AliGEODB::TrackLength() const 
361 {
362     cout << " TrackLength" << endl;
363     return 0;
364 }
365
366 /***********************************************************************/
367
368 Float_t AliGEODB::TrackTime() const 
369 {
370     cout << " TrackTime" << endl;
371     return 0;
372 }
373
374 /***********************************************************************/
375
376 Int_t   AliGEODB::TrackPid() const 
377 {
378     cout << " TrackPid" << endl;
379     return 0;
380 }
381
382 /***********************************************************************/
383     
384 Bool_t  AliGEODB::TrackAlive() const 
385 {
386     cout << " TrackAlive" << endl;
387     return 0;
388 }
389
390 /***********************************************************************/
391
392 void    AliGEODB::StopTrack() 
393 {
394     cout << " StopTrack" << endl;
395 }
396
397 /***********************************************************************/
398
399 void    AliGEODB::StopEvent() 
400 {
401     cout << " StopEvent" << endl;
402 }
403
404 /***********************************************************************/
405
406 void    AliGEODB::SetMaxNStep(Int_t) 
407 {
408     cout << " SetMaxNStep" << endl;
409 }
410
411 /***********************************************************************/
412
413 void    AliGEODB::SetColors() 
414 {
415     cout << " SetColors" << endl;
416 }
417
418 /***********************************************************************/
419
420 Int_t   AliGEODB::GetMaxNStep() const 
421 {
422     cout << " GetMaxNStep" << endl;
423     return 0;
424 }
425
426 /***********************************************************************/
427
428 void AliGEODB::Material( Int_t& kmat, const char* name, Float_t a, Float_t z, Float_t dens, Float_t radl, Float_t absl,Float_t* buf, Int_t nwbuf )
429 {
430     if( MateCount >= MAXMAT ) {
431         printf( " ERROR: Material number: %d bigger that MAXMAT: %d => Out of array\n", MateCount, MAXMAT );
432         exit(0);
433     }
434
435     Mater*   AliMat = new Mater;
436     char*    fname  = new char[strlen(name)+1];
437     Float_t* fbuf   = new Float_t[nwbuf];
438
439     strcpy( fname, name );
440     fname[strlen(name)] = '\x0';
441
442     AliMat->fName  = fname;
443     AliMat->fA     = a;
444     AliMat->fZ     = z;
445     AliMat->fDens  = dens;
446     AliMat->fRadl  = radl;
447     AliMat->fAbsl  = absl;
448     AliMat->fNwbuf = nwbuf;
449
450     for( int i=0; i<nwbuf; i++ )
451         fbuf[i] = buf[i];
452
453     AliMat->fBuf = fbuf;
454     
455     AliMaterials[MateCount] = AliMat;
456
457     kmat = MateCount++;
458 }
459
460 /***********************************************************************/
461
462 void  AliGEODB::Mixture( Int_t& imat, const char* name, Float_t* a, Float_t* z, Float_t dens, Int_t nlmat, Float_t* wmat )
463 {
464     if( MateCount >= MAXMAT ) {
465         printf( " ERROR: Mixture number: %d bigger that MAXMAT: %d => Out of array\n", MateCount, MAXMAT );
466         exit(0);
467     }
468
469     Mater* AliMat   = new Mater;
470     char*    fname  = new char[strlen(name)+1];
471
472     strcpy( fname, name );
473     fname[strlen(name)] = '\x0';
474
475     AliMat->fName   = fname;
476     Float_t MidA    = 0.;
477     Float_t MidZ    = 0.;
478     Float_t SUMwmat = 0.;
479
480     for( int i=0; i<nlmat; i++ ) {
481         MidA    += wmat[i]*a[i];
482         MidZ    += wmat[i]*z[i];
483         SUMwmat += wmat[i];
484     }
485
486     MidA            = MidA/SUMwmat;
487     MidZ            = MidZ/SUMwmat;
488
489     AliMat->fA      = MidA;
490     AliMat->fZ      = MidZ;
491     AliMat->fDens   = dens;
492     AliMat->fRadl   = 0.;
493     AliMat->fAbsl   = 0.;
494     AliMat->fNwbuf  = 0;
495
496     AliMat->fBuf    = NULL;
497
498     AliMaterials[MateCount] = AliMat;
499
500     imat = MateCount++;
501 }
502
503 /***********************************************************************/
504
505 void  AliGEODB::Medium( Int_t& numed, const char* name, Int_t nmat, Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd, Float_t stemax, Float_t deemax, Float_t epsil, Float_t stmin, Float_t* ubuf, Int_t nbuf )
506 {
507     if( MedCount >= MAXMAT ) {
508         printf( " ERROR: Medium number: %d bigger that MAXMAT: %d => Out of array\n", MedCount, MAXMAT );
509         exit(0);
510     }
511
512     Med*     AliMed = new Med;
513     char*    fname  = new char[strlen(name)+1];
514     Float_t* fUbuf  = new Float_t[nbuf];
515
516     strcpy( fname, name );
517     fname[strlen(name)] = '\x0';
518     
519     AliMed->fName   = fname;
520     AliMed->fNmat   = nmat;
521     AliMed->fIsvol  = isvol;
522     AliMed->fIfield = ifield;
523     AliMed->fFieldm = fieldm;
524     AliMed->fTmaxfd = tmaxfd;
525     AliMed->fStemax = stemax;
526     AliMed->fDeemax = deemax;
527     AliMed->fEpsil  = epsil;
528     AliMed->fStmin  = stmin;
529     AliMed->fNbuf   = nbuf;
530     
531     for( int i=0; i<nbuf; i++ )
532         fUbuf[i] = ubuf[i];
533
534     AliMed->fUbuf = fUbuf;
535
536     AliMediums[MedCount] = AliMed;
537
538     numed = MedCount++;
539 }
540
541 /***********************************************************************/
542
543 void  AliGEODB::Matrix( Int_t &nmate , Float_t theta1, Float_t phi1, Float_t theta2, Float_t phi2, Float_t theta3, Float_t phi3 ) 
544 {
545     char* transname = new char[10];
546     sprintf(transname, "%s%d", "tra", MatrCount);
547
548     AliGTransform* tra = new AliGTransform( transname, transname, theta1, phi1, theta2, phi2, theta3, phi3 );
549
550     //printf( " Created new AliGTransform( %s, %s, %f, %f, %f, %f, %f, %f );\n", transname, transname, theta1, phi1, theta2, phi2, theta3, phi3 );
551
552     listTransf->AddAt( tra, MatrCount );
553
554     nmate = ++MatrCount;
555
556 }
557
558 /***********************************************************************/
559
560 void  AliGEODB::WriteEuclid(const char*, const char*, Int_t, Int_t) 
561 {
562     cout << " WriteEuclid" << endl;
563 }
564
565 /***********************************************************************/
566
567 void  AliGEODB::Gpcxyz() 
568 {
569     cout << " Gpcxyz " << endl;
570 }
571
572 /***********************************************************************/
573
574 void  AliGEODB::Ggclos() 
575 {
576
577     for( int i=0; i<listNodes->GetSize(); i++ ) {
578         AliGNode* node = (AliGNode*) listNodes->At(i);
579         char* name = new char[strlen(node->GetName())+1];
580         strcpy(name, node->GetName());
581         name[strlen(node->GetName())] = '\x0';
582         node->AddConfig(name, name,"detail",981201,991201);
583     }
584
585     printf( " Total number of nodes = %d\n", listNodes->GetSize() );
586
587     SetVisibility( "TPC_1",   1 );
588     SetVisibility( "TGAS_1",  1 );
589     SetVisibility( "TPSG_1",  1 );
590     SetVisibility( "TPHV_1",  1 );
591     SetVisibility( "TRCS_1",  1 );
592     SetVisibility( "TSGA_1",  1 );
593     SetVisibility( "TRCL_1",  1 );
594     SetVisibility( "TLGA_1",  1 );
595     SetVisibility( "TSST_1",  1 );
596     SetVisibility( "TSST_2",  1 );
597     SetVisibility( "TSST_3",  1 );
598     SetVisibility( "TSST_4",  1 );
599     SetVisibility( "TSST_5",  1 );
600     SetVisibility( "TSST_6",  1 );
601     SetVisibility( "TSST_7",  1 );
602     SetVisibility( "TSST_8",  1 );
603     SetVisibility( "TSST_9",  1 );
604     SetVisibility( "TSST_10", 1 );
605     SetVisibility( "TSST_11", 1 );
606     SetVisibility( "TSST_12", 1 );
607     SetVisibility( "TSST_13", 1 );
608     SetVisibility( "TSST_14", 1 );
609     SetVisibility( "TSST_15", 1 );
610     SetVisibility( "TSST_16", 1 );
611     SetVisibility( "TSST_17", 1 );
612     SetVisibility( "TSST_18", 1 );
613     SetVisibility( "TSST_19", 1 );
614     SetVisibility( "TSST_20", 1 );
615     SetVisibility( "TSST_21", 1 );
616     SetVisibility( "TSST_22", 1 );
617     SetVisibility( "TSST_23", 1 );
618     SetVisibility( "TLST_1",  1 );
619     SetVisibility( "TLST_2",  1 );
620     SetVisibility( "TLST_3",  1 );
621     SetVisibility( "TLST_4",  1 );
622     SetVisibility( "TLST_5",  1 );
623     SetVisibility( "TLST_6",  1 );
624     SetVisibility( "TLST_7",  1 );
625     SetVisibility( "TLST_8",  1 );
626     SetVisibility( "TLST_9",  1 );
627     SetVisibility( "TLST_10", 1 );
628     SetVisibility( "TLST_11", 1 );
629     SetVisibility( "TLST_12", 1 );
630     SetVisibility( "TLST_13", 1 );
631     SetVisibility( "TLST_14", 1 );
632     SetVisibility( "TLST_15", 1 );
633     SetVisibility( "TLST_16", 1 );
634     SetVisibility( "TLST_17", 1 );
635     SetVisibility( "TLST_18", 1 );
636     SetVisibility( "TLST_19", 1 );
637     SetVisibility( "TLST_20", 1 );
638     SetVisibility( "TLST_21", 1 );
639     SetVisibility( "TLST_22", 1 );
640     SetVisibility( "TLST_23", 1 );
641     SetVisibility( "TLST_24", 1 );
642     SetVisibility( "TLST_25", 1 );
643     SetVisibility( "TLST_26", 1 );
644     SetVisibility( "TLST_27", 1 );
645     SetVisibility( "TLST_28", 1 );
646     SetVisibility( "TLST_29", 1 );
647     SetVisibility( "TLST_30", 1 );
648     SetVisibility( "TLST_31", 1 );
649     SetVisibility( "TLST_32", 1 );
650     SetVisibility( "TLST_33", 1 );
651     SetVisibility( "TLST_34", 1 );
652     SetVisibility( "TLST_35", 1 );
653     SetVisibility( "TLST_36", 1 );
654     SetVisibility( "TLST_37", 1 );
655     SetVisibility( "TLST_38", 1 );
656     SetVisibility( "TLST_39", 1 );
657     SetVisibility( "TLST_40", 1 );
658     SetVisibility( "TLST_41", 1 );
659     SetVisibility( "TLST_42", 1 );
660     SetVisibility( "TLST_43", 1 );
661     SetVisibility( "TLST_44", 1 );
662     SetVisibility( "TLST_45", 1 );
663     SetVisibility( "TLST_46", 1 );
664     SetVisibility( "TLST_47", 1 );
665     SetVisibility( "TLST_48", 1 );
666     SetVisibility( "TLST_49", 1 );
667     SetVisibility( "TLST_50", 1 );
668     SetVisibility( "TLST_51", 1 );
669     SetVisibility( "TLST_52", 1 );
670     SetVisibility( "TSWS_1",  1 );
671     SetVisibility( "TSWS_2",  1 );
672     SetVisibility( "TSWS_3",  1 );
673     SetVisibility( "TPW1_1",  1 );
674     SetVisibility( "TPW2_1",  1 );
675     SetVisibility( "TPW3_1",  1 );
676     SetVisibility( "TPW4_1",  1 );
677     SetVisibility( "TSPI_1",  1 );
678     SetVisibility( "TSP1_1",  1 );
679     SetVisibility( "TSPO_1",  1 );
680     SetVisibility( "TSP2_1",  1 );
681     SetVisibility( "TSWH_1",  1 );
682     SetVisibility( "TSW1_1",  1 );
683     SetVisibility( "TCOV_1",  1 );
684     SetVisibility( "TPOI_1",  1 );
685     SetVisibility( "TSWS_4",  1 );
686     SetVisibility( "TSWS_5",  1 );
687     SetVisibility( "TSWS_6",  1 );
688     SetVisibility( "TSWS_7",  1 );
689     SetVisibility( "TSWS_8",  1 );
690     SetVisibility( "TSWS_9",  1 );
691     SetVisibility( "TSWS_10", 1 );
692     SetVisibility( "TSWS_11", 1 );
693     SetVisibility( "TSWS_12", 1 );
694     SetVisibility( "TSWS_13", 1 );
695     SetVisibility( "TPIV_1",  1 );
696     SetVisibility( "TPVD_1",  1 );
697
698     printf( " Visibilities activated \n" );
699
700     AliGeometry* Geom1 = new AliGeometry( "Geom1", "Geom1", TopNode, 0 );
701
702     TCanvas* c1 = new TCanvas( "TPC", "Geometry Shapes", 100, 100, 750, 750 );
703     c1->Range(0,0,1,1);
704     c1->SetFillColor(32); // Light Green
705     c1->SetBorderSize(3);
706     c1->SetBorderMode(0); // -1 (down) 0 (no) 1 (up)
707
708     TopNode->Draw("same");
709
710     TFile* file1 = new TFile( "GeoDB.root", "RECREATE" );
711     cout << endl << " Storing GeoDB.root file.  Please, be patient...    :-)" << endl;
712     TopNode->SaveAll(file1);
713
714     file1->cd();
715
716     if( Geom1 ) {
717         Geom1->Write();
718         cout << " Geometry saved in disk " << endl;
719     }
720
721     file1->Write();
722     file1->Close();
723
724     TFile* file2 = new TFile( "GeoDB.root", "READ" );
725     file2->cd();
726     AliGeometry* Geom2  = new AliGeometry( (AliGeometry*) file2->Get("Geom1") );
727
728     // Retrieve the memory tree structure from AliGeoDB.root and stores it in memory, being tree_root the top node
729     AliGNode* tree_root = new AliGNode( Geom2->FileToMemTree( file2 ) );
730     //AliGNode* tree_root = new AliGNode( Geom2->FileToMemTree( "GeoDB.root", "Geom1" ) );
731
732     TFile* file3 = new TFile( "GeoDB2.root", "RECREATE" );
733     cout << " Storing GeoDB2.root file. Please, be patient again...   :-)" << endl;
734     tree_root->SaveAll( file3 ); // Memory tree structure saved in disk (second time)
735
736     file3->cd();
737
738     if( Geom2 ) {
739         Geom2->Write();
740         cout << " Geometry saved in disk " << endl;
741     }
742
743     file3->Write();
744     file3->Close();
745
746     file2->Close();
747
748     cout << " The two databases are stored in disk." << endl;
749
750     TFile* file4 = new TFile( "GeoDB.root" , "READ" );
751     TFile* file5 = new TFile( "GeoDB2.root", "READ" );
752
753     TBrowser* a = new TBrowser();
754
755     //DrawTree( TopNode, 0 );
756 }
757
758 /***********************************************************************/
759
760 void AliGEODB::SetVisibility(Text_t* name, Int_t val)
761 {
762    AliGNode* node = (AliGNode*) listNodes->FindObject( name );
763
764    if( node )
765        node->SetVis(val);
766    else
767        printf( " ERROR!!! I couldn't find the node %s in the listNodes.\n", name );
768 }
769
770 /***********************************************************************/
771
772 void AliGEODB::DrawTree( AliGNode* topnode, Int_t tabs )
773 {
774
775     for( int i=0; topnode->GetNodeFromfNode(i); i++ ) {
776         for( int j=0; j<tabs; j++ )
777             cout << " ";
778         cout << topnode->GetNodeFromfNode(i)->GetName() << endl;
779         tabs+=5;
780         DrawTree( topnode->GetNodeFromfNode(i), tabs );
781         tabs-=5;
782     }
783
784 }
785
786 /***********************************************************************/
787
788 void  AliGEODB::Glast() 
789 {
790     cout << " Glast " << endl;
791 }
792
793 /***********************************************************************/
794
795 void  AliGEODB::Gprint(const char*) 
796 {
797     cout << " Gprint " << endl;
798 }
799
800 /***********************************************************************/
801
802 void  AliGEODB::Grun() 
803 {
804     cout << " Grun " << endl;
805 }
806
807 /***********************************************************************/
808
809 void  AliGEODB::Gtrig() 
810 {
811     cout << " Gtrig " << endl;
812 }
813
814 /***********************************************************************/
815
816 void  AliGEODB::Gtrigc() 
817 {
818     cout << " Gtrigc " << endl;
819 }
820
821 /***********************************************************************/
822
823 void  AliGEODB::Gtrigi() 
824 {
825     cout << " Gtrigi " << endl;
826 }
827
828 /***********************************************************************/
829
830 void  AliGEODB::Gwork(Int_t) 
831 {
832     cout << " Gwork " << endl;
833 }
834
835 /***********************************************************************/
836
837 void  AliGEODB::Gzinit() 
838 {
839     cout << " Gzinit " << endl;
840 }
841
842 //=======================functions from GCONS
843
844 /***********************************************************************/
845
846 void  AliGEODB::Gfmate(Int_t, char*, Float_t&, Float_t&, Float_t&, Float_t&, Float_t&, Float_t*, Int_t&)
847 {
848     cout << " Gfmate " << endl;
849 }
850
851 /***********************************************************************/
852
853 void  AliGEODB::Gfpart(Int_t, char*, Int_t&, Float_t&, Float_t&, Float_t&)
854 {
855     cout << " Gfpart " << endl;
856 }
857
858 /***********************************************************************/
859
860 void  AliGEODB::Gftmed(Int_t, char*, Int_t&, Int_t&, Int_t&, Float_t&, Float_t&,Float_t&, Float_t&, Float_t&, Float_t&, Float_t*, Int_t*)
861 {
862     cout << " Gftmed " << endl;
863 }
864
865 /***********************************************************************/
866
867 void  AliGEODB::Gmate() {
868     cout << " Gmate " << endl;
869 }
870
871 /***********************************************************************/
872
873 void  AliGEODB::Gpart() 
874 {
875     AliGTransform* Identity = new AliGTransform("Identity","Identity","rot 0. 0. 0.");
876     //printf( " Created new AliGTransform( Identity, Identity, rot 0. 0. 0. );\n" );
877
878     listTransf->AddAt( Identity, MatrCount );
879     MatrCount++;
880
881     AliGBox*  box  = new AliGBox("box","box", 400,400,400);
882     AliGNode* ALIC = new AliGNode( "ALIC", 1,"ALIC", box);
883     TopNode = ALIC;
884
885     listNodes->Add(ALIC);
886 }
887
888 /***********************************************************************/
889
890 void  AliGEODB::Gsdk(Int_t, Float_t*, Int_t*) {
891     cout << " Gsdk " << endl;
892 }
893
894 /***********************************************************************/
895
896 void  AliGEODB::Gsmate(Int_t, const char*, Float_t, Float_t, Float_t, Float_t, Float_t) {
897     cout << " Gsmate " << endl;
898 }
899
900 /***********************************************************************/
901
902 void  AliGEODB::Gsmixt(Int_t, const char*, Float_t*, Float_t*, Float_t, Int_t, Float_t*) {
903     cout << " Gsmixt " << endl;
904 }
905
906 /***********************************************************************/
907
908 void  AliGEODB::Gspart(Int_t, const char*, Int_t,   Float_t, Float_t, Float_t) {
909     cout << " Gspart " << endl;
910 }
911
912 /***********************************************************************/
913
914 void  AliGEODB::Gstmed(Int_t, const char*, Int_t, Int_t, Int_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t) {
915     cout << " Gstmed " << endl;
916 }
917
918 /***********************************************************************/
919
920 void  AliGEODB::Gstpar(Int_t, const char*, Float_t) 
921 {
922     //cout << " Gstpar " << endl;
923 }
924
925 /***********************************************************************/
926
927 void  AliGEODB::Gsckov(Int_t, Int_t, Float_t *, Float_t *, Float_t *, Float_t *) 
928 {
929     cout << " Gsclov " << endl;
930 }
931
932 /***********************************************************************/
933
934 //=======================functions from GKINE
935
936 void  AliGEODB::Gfkine(Int_t, Float_t*, Float_t*, Int_t&, Int_t&) 
937 {
938     cout << " Gfkine" << endl;
939 }
940
941 /***********************************************************************/
942
943 void  AliGEODB::Gfvert(Int_t, Float_t*, Int_t&, Int_t&, Float_t&) 
944 {
945     cout << " Gfvert" << endl;
946 }
947
948 /***********************************************************************/
949
950 Int_t AliGEODB::Gskine(Float_t*, Int_t, Int_t, Float_t*, Int_t)
951 {
952     cout << " Gskine" << endl;
953     return 0;
954 }
955
956 /***********************************************************************/
957
958 Int_t AliGEODB::Gsvert(Float_t*, Int_t, Int_t, Float_t*, Int_t)
959 {
960     cout << " Gsvert" << endl;
961     return 0;
962 }
963
964 /***********************************************************************/
965
966 //=======================functions from GPHYS
967
968 void  AliGEODB::Gphysi() 
969 {
970     cout << " Gphysi" << endl;
971 }
972
973 /***********************************************************************/
974
975 //=======================functions from GTRAK
976
977 void  AliGEODB::Gdebug() 
978 {
979     cout << " Gdebug" << endl;
980 }
981
982 /***********************************************************************/
983
984 void  AliGEODB::Gekbin() 
985 {
986     cout << " Gekbin" << endl;
987 }
988
989 /***********************************************************************/
990
991 void  AliGEODB::Gfinds() 
992 {
993     cout << " Gfinds" << endl;
994 }
995
996 /***********************************************************************/
997
998 void  AliGEODB::Gsking(Int_t) 
999 {
1000     cout << " Gsking" << endl;
1001 }
1002
1003 /***********************************************************************/
1004
1005 void  AliGEODB::Gskpho(Int_t) 
1006 {
1007     cout << " Gskpho" << endl;
1008 }
1009
1010 /***********************************************************************/
1011
1012 void  AliGEODB::Gsstak(Int_t) 
1013 {
1014     cout << " Gsstak" << endl;
1015 }
1016
1017 /***********************************************************************/
1018
1019 void  AliGEODB::Gsxyz() 
1020 {
1021     cout << " Gsxyz" << endl;
1022 }
1023
1024 /***********************************************************************/
1025
1026 void  AliGEODB::Gtrack() 
1027 {
1028     cout << " Gtrack" << endl;
1029 }
1030
1031 /***********************************************************************/
1032
1033 void  AliGEODB::Gtreve() 
1034 {
1035     cout << " Gtreve" << endl;
1036 }
1037
1038 /***********************************************************************/
1039
1040 void  AliGEODB::Grndm(Float_t*, const Int_t) const 
1041 {
1042     cout << " Grndm" << endl;
1043 }
1044
1045 /***********************************************************************/
1046
1047 void  AliGEODB::Grndmq(Int_t&, Int_t&, const Int_t, const Text_t*) 
1048 {
1049     cout << " Grndmq" << endl;
1050 }
1051
1052 /***********************************************************************/
1053
1054 //=======================functions from GDRAW
1055
1056 void  AliGEODB::Gdxyz(Int_t ) 
1057 {
1058     cout << " Gdxyz" << endl;
1059 }
1060
1061 /***********************************************************************/
1062
1063 void  AliGEODB::Gdcxyz() 
1064 {
1065     cout << " Gdcxyz" << endl;
1066 }
1067
1068 /***********************************************************************/
1069
1070 //=======================functions from GGEOM
1071
1072 void  AliGEODB::Gdtom(Float_t*, Float_t*, Int_t) 
1073 {
1074   printf( " Gdtom.\n" );
1075 }
1076
1077 /***********************************************************************/
1078
1079 void  AliGEODB::Glmoth(const char*, Int_t, Int_t&, Int_t*, Int_t*) 
1080 {
1081   printf( " Glmoth.\n" );
1082
1083 }
1084
1085 /***********************************************************************/
1086
1087 void  AliGEODB::Gmedia(Float_t*, Int_t&) 
1088 {
1089   printf( " Gmedia.\n" );
1090 }
1091
1092 /***********************************************************************/
1093
1094 void  AliGEODB::Gmtod(Float_t*, Float_t*, Int_t) 
1095 {
1096   printf( " Gmtod.\n" );
1097 }
1098
1099 /***********************************************************************/
1100
1101 void  AliGEODB::Gsdvn(const char* name, const char* parentname, Int_t ndiv, Int_t iaxis) 
1102 {
1103     cout << " Inside Gsdvn " << endl;
1104     /* Divides one node in Ndiv nodes in the iaxis direction*/
1105
1106     char* transfname = new char[10];
1107     char* nodename   = new char[10];
1108
1109     AliGNode* parent = (AliGNode*) listNodes->FindObject(parentname);
1110
1111     /* Find the shape that will result from the division*/
1112
1113     /* BOX */
1114     if( parent->GetShape()->ClassName() == "AliGBox" ) {
1115         AliGMaterial* material = new AliGMaterial(parent->GetMaterial());
1116
1117         Float_t Dx, Dy, Dz;
1118
1119         switch (iaxis) {
1120             case 1 : Dx = ((AliGBox*)(parent->GetShape()))->GetX() / ndiv;
1121                      Dy = ((AliGBox*)(parent->GetShape()))->GetY();
1122                      Dz = ((AliGBox*)(parent->GetShape()))->GetZ();
1123                      break;
1124                     
1125             case 2 : Dx = ((AliGBox*)(parent->GetShape()))->GetX() ;
1126                      Dy = ((AliGBox*)(parent->GetShape()))->GetY()/ ndiv;
1127                      Dz = ((AliGBox*)(parent->GetShape()))->GetZ();
1128                      break;
1129
1130             case 3 : Dx = ((AliGBox*)(parent->GetShape()))->GetX() ;
1131                      Dy = ((AliGBox*)(parent->GetShape()))->GetY();
1132                      Dz = ((AliGBox*)(parent->GetShape()))->GetZ()/ ndiv;
1133                      break;
1134                      
1135             default: Dx = Dy = Dz = 0.;
1136         };
1137
1138         AliGBox* box = new AliGBox("box","box", Dx, Dy, Dz);
1139
1140         /* Create the nodes son*/
1141
1142         Float_t x, y, z;
1143         Text_t* expression;
1144         
1145         for( int i=0; i<ndiv; i++ ) {
1146             //nodename = "Node";
1147             nodename[4] = '\x0';
1148             sprintf( nodename, "%s%d", nodename, i );
1149             transfname = "trans";
1150             transfname[5] = '\x0';
1151             sprintf( transfname, "%s%d", transfname, i );
1152
1153             switch (iaxis) {
1154                 case 'X' :
1155                 case 'x' : x = ndiv *i;
1156                            y = 0;
1157                            z = 0;
1158                            break;
1159                 case 'Y' :
1160                 case 'y' : x = 0;
1161                            y = ndiv *i;
1162                            z = 0;
1163                            break;
1164
1165                 case 'Z' :
1166                 case 'z' : x = 0;
1167                            y = 0;
1168                            z = ndiv *i;
1169                            break;
1170             };
1171
1172             /* Positioning the sons (only translations) and adding them to the parent*/
1173     
1174             sprintf( expression, "%s %f %f %f", "tra", x, y, z );
1175             AliGTransform* tran = new AliGTransform( transfname, transfname, expression );
1176
1177             char* nodname = new char[strlen(name)];
1178             strcpy( nodname, name );
1179             AliGNode* son = new AliGNode( nodname, i, nodname, box, material );
1180             if( nodname ) delete [] nodname;
1181             
1182             parent->Add( son, tran );
1183             parent->AddConfig("","");
1184             listNodes->AddLast(son);
1185         }
1186     }
1187 }
1188
1189 /***********************************************************************/
1190
1191 void  AliGEODB::Gsdvn2(const char*, const char*, Int_t, Int_t, Float_t, Int_t) 
1192 {
1193   printf( " Gsdvn2.\n" );
1194 }
1195
1196 /***********************************************************************/
1197
1198 void  AliGEODB::Gsdvs(const char*, const char*, Float_t, Int_t, Int_t) 
1199 {
1200   printf( " Gsdvs.\n" );
1201 }
1202
1203 /***********************************************************************/
1204
1205 void  AliGEODB::Gsdvs2(const char*, const char*, Float_t, Int_t, Float_t, Int_t) 
1206 {
1207   printf( " Gsdvs2.\n" );
1208 }
1209
1210 /***********************************************************************/
1211
1212 void  AliGEODB::Gsdvt(const char*, const char*, Float_t, Int_t, Int_t, Int_t) 
1213 {
1214   printf( " Gsdvt.\n" );
1215 }
1216
1217 /***********************************************************************/
1218
1219 void  AliGEODB::Gsdvt2(const char *, const char *, Float_t, Int_t, Float_t, Int_t, Int_t) 
1220 {
1221   printf( " Gsdvt2.\n" );
1222 }
1223
1224 /***********************************************************************/
1225
1226 void  AliGEODB::Gsord(const char*, Int_t) 
1227 {
1228   // Aqui entra pero dice Federico que Dummy.
1229 }
1230
1231 /***********************************************************************/
1232
1233 void  AliGEODB::Gspos( const char *name, Int_t nr, const char *mother, Float_t x, Float_t y, Float_t z, Int_t irot, const char* konly ) 
1234 {
1235
1236     if( !strcmp(mother, "ALIC") )
1237         mother = "ALIC_1";
1238
1239     AliGNode* son    = NULL;
1240     AliGNode* parent = NULL;
1241
1242     char* nodename   = new char[strlen(name)+1];
1243     strcpy( nodename, name );
1244     nodename[strlen(name)] = '\x0';
1245
1246     TObjLink *lnk = listNodes->FirstLink();
1247     int quit=0;
1248
1249     while( (lnk) && (!quit) ) {
1250         TObject *obj = lnk->GetObject();
1251
1252         if( obj->GetName() ) {
1253             char* NodeName = new char[strlen(obj->GetName())+1];
1254             strcpy( NodeName, obj->GetName() );
1255             NodeName[strlen(obj->GetName())] = '\x0';
1256
1257             int i;
1258             for( i=0; NodeName[i]!='_'; i++ );
1259
1260             if( !strncmp(nodename, NodeName, i) )
1261                 son = (AliGNode*) obj;
1262             else
1263                 if( !strncmp(mother, NodeName, i) )
1264                     parent = (AliGNode*) obj;
1265
1266             if( NodeName ) delete [] NodeName;
1267
1268             if( (son != NULL) && (parent != NULL) )
1269                 quit = 1;
1270         }
1271
1272         lnk = lnk->Next();
1273     }
1274
1275     if( son == NULL ) {
1276         cout << " ERROR in Gspos. Couldn't find node " << nodename << " inside listNodes." << endl;
1277         exit(1);
1278     }
1279     else
1280         if( parent == NULL) {
1281             cout << " ERROR in Gspos. Couldn't find node " << mother << " inside listNodes." << endl;
1282             exit(1);
1283         }
1284
1285     AliGTransform* tra = (AliGTransform*)listTransf->At(MatrCount - 1);
1286
1287     TVector* matrix = tra->GetMatrix();
1288     char* transname = new char[10];
1289     sprintf(transname, "%s%d", "tra", MatrCount );
1290
1291     TVector &mat = *matrix;
1292     AliGTransform* newtra = new AliGTransform(transname, transname, mat(0), mat(1),  mat(2), mat(4), mat(5), mat(6),mat(8), mat(9), mat(10), x, y, z);
1293
1294     //printf( "\n Created new AliGTransform( %s, %s, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f );\n", transname, transname, mat(0), mat(1), mat(2), mat(4), mat(5), mat(6), mat(8), mat(9), mat(10), x, y, z );
1295
1296     listTransf->AddAt(newtra, MatrCount);
1297     MatrCount++;
1298
1299     parent->Add(son, newtra);
1300     //printf( " %s->Add( %s, %s );\n", parent->GetName(), son->GetName(), newtra->GetName() );
1301 }
1302
1303 /***********************************************************************/
1304
1305 void  AliGEODB::Gsposp( const char* nodename, Int_t nr, const char* mother, Float_t x, Float_t y, Float_t z, Int_t irot, const char* konly, Float_t* upar, Int_t np ) 
1306 {
1307     //printf( "\n" );
1308
1309     Int_t i;
1310     
1311     for( i=0; i<PospCount; i++ )
1312         if( !strcmp(Posp[i]->name, nodename) )
1313             break;
1314
1315     char* shapename  = Posp[i]->shape;
1316     Int_t nmed       = Posp[i]->nmed;
1317
1318     char* fnodename  = new char[strlen(nodename)+1];
1319     strcpy(fnodename, nodename);
1320     fnodename[strlen(nodename)] = '\x0';
1321
1322     char* fmother    = new char[strlen(mother)+1];
1323     strcpy(fmother, mother);
1324     fmother[strlen(mother)] = '\x0';
1325     
1326     AliGNode* parent = NULL;
1327
1328     TObjLink *lnk = listNodes->FirstLink();
1329     int quit=0;
1330
1331     while( (lnk) && (!quit) ) {
1332         TObject *obj = lnk->GetObject();
1333
1334         if( obj->GetName() ) {
1335             char* NodeName = new char[strlen(obj->GetName())];
1336             strcpy( NodeName, obj->GetName() );
1337
1338             int i;
1339             for( i=0; NodeName[i]!='_'; i++ );
1340
1341             if( !strncmp(fmother, NodeName, i) )
1342                     parent = (AliGNode*) obj ;
1343  
1344             if( NodeName ) delete [] NodeName;
1345
1346             if( parent != NULL )
1347                 quit = 1;
1348         }
1349
1350         lnk = lnk->Next();
1351     }
1352
1353     if( parent == NULL) {
1354         cout << " ERROR in Gsposp. Couldn't find node " << mother << " inside listNodes." << endl;
1355         exit(1);
1356     }
1357
1358     Int_t nmat = AliMediums[nmed]->fNmat;
1359
1360     AliGMaterial* MyMaterial = NULL;
1361     
1362     for( int j=0; j<listMaterials->GetSize(); j++ )
1363         if( ((AliGMaterial*) listMaterials->At(j))->GetfImat() == nmat ) {
1364             MyMaterial = (AliGMaterial*) listMaterials->At(j);
1365             /*printf( " AliGMaterial( %d, %s, %s, %d, %d, %f, %f, %f, %f, %f, %f, *fUbuf, %d, %f, %f, %f, %f, %f, *fBuf, %d ); already existed.\n", nmat,AliMaterials[nmat]->fName, AliMaterials[nmat]->fName, AliMediums[nmed]->fIsvol, AliMediums[nmed]->fIfield, AliMediums[nmed]->fFieldm, AliMediums[nmed]->fTmaxfd, AliMediums[nmed]->fStemax, AliMediums[nmed]->fDeemax, AliMediums[nmed]->fEpsil, AliMediums[nmed]->fStmin, AliMediums[nmed]->fNbuf, AliMaterials[nmat]->fA, AliMaterials[nmat]->fZ, AliMaterials[nmat]->fDens, AliMaterials[nmat]->fRadl, AliMaterials[nmat]->fAbsl, AliMaterials[nmat]->fNwbuf );*/
1366             break;
1367         }
1368     
1369     if( MyMaterial == NULL ) {
1370         MyMaterial = new AliGMaterial( nmat, AliMaterials[nmat]->fName, AliMaterials[nmat]->fName, AliMediums[nmed]->fIsvol, AliMediums[nmed]->fIfield, AliMediums[nmed]->fFieldm, AliMediums[nmed]->fTmaxfd, AliMediums[nmed]->fStemax, AliMediums[nmed]->fDeemax, AliMediums[nmed]->fEpsil, AliMediums[nmed]->fStmin, AliMediums[nmed]->fUbuf, AliMediums[nmed]->fNbuf,  AliMaterials[nmat]->fA, AliMaterials[nmat]->fZ, AliMaterials[nmat]->fDens, AliMaterials[nmat]->fRadl, AliMaterials[nmat]->fAbsl, AliMaterials[nmat]
1371 ->fBuf, AliMaterials[nmat]->fNwbuf );
1372
1373         /*printf( " Created new AliGMaterial( %d, %s, %s, %d, %d, %f, %f, %f, %f, %f, %f, *fUbuf, %d, %f, %f, %f, %f, %f, *fBuf, %d );\n", nmat,AliMaterials[nmat]->fName, AliMaterials[nmat]->fName, AliMediums[nmed]->fIsvol, AliMediums[nmed]->fIfield, AliMediums[nmed]->fFieldm, AliMediums[nmed]->fTmaxfd, AliMediums[nmed]->fStemax, AliMediums[nmed]->fDeemax, AliMediums[nmed]->fEpsil, AliMediums[nmed]->fStmin, AliMediums[nmed]->fNbuf, AliMaterials[nmat]->fA, AliMaterials[nmat]->fZ, AliMaterials[nmat]->fDens, AliMaterials[nmat]->fRadl, AliMaterials[nmat]->fAbsl, AliMaterials[nmat]->fNwbuf );*/
1374
1375         listMaterials->Add( MyMaterial );
1376     }
1377
1378     AliGNode* son = NULL;
1379
1380     // Different constructor depending on the shape
1381     if( !strncmp(shapename, "TUBE", 4) ) {
1382
1383         AliGTube* Shape = NULL;
1384         
1385         for( int j=0; j<listShapes->GetSize(); j++ )
1386             if( ((AliGShape*) listShapes->At(j))->GetName() == shapename ) {
1387                 Shape = (AliGTube*) listShapes->At(j);
1388                 //printf( " AliGTube( %s, %s, %f, %f, %f ); already existed.\n", shapename, shapename, upar[0], upar[1], upar[2] );
1389                 break;
1390             }
1391
1392         if( Shape == NULL ) {
1393             Shape = new AliGTube( shapename, shapename, upar[0], upar[1], upar[2] );
1394             //printf( " Created new AliGTube( %s, %s, %f, %f, %f );\n", shapename, shapename, upar[0], upar[1], upar[2] );
1395             listShapes->Add(Shape);
1396         }
1397
1398         Shape->SetCol(Color);
1399         son = new AliGNode( fnodename, nr, fnodename, Shape, MyMaterial );
1400     }
1401     else
1402         if( !strncmp(shapename, "BOX", 3) ) {
1403
1404             AliGBox* Shape = NULL;
1405         
1406             for( int j=0; j<listShapes->GetSize(); j++ )
1407                 if( ((AliGShape*) listShapes->At(j))->GetName() == shapename ) {
1408                     Shape = (AliGBox*) listShapes->At(j);
1409                     //printf( " AliGBox( %s, %s, %f, %f, %f ); already existed.\n", shapename, shapename, upar[0], upar[1], upar[2] );
1410                     break;
1411                 }
1412
1413             if( Shape == NULL ) {
1414                 Shape = new AliGBox( shapename, shapename, upar[0], upar[1], upar[2] );
1415                 //printf( " Created new AliGBox( %s, %s, %f, %f, %f );\n", shapename, shapename, upar[0], upar[1], upar[2] );
1416                 listShapes->Add(Shape);
1417             }
1418             
1419             Shape->SetCol(Color);
1420             son = new AliGNode( fnodename, nr, fnodename, Shape, MyMaterial );
1421         }
1422         else
1423             if( !strncmp(shapename, "TRD1", 4) ) {
1424
1425                 AliGTRD1* Shape = NULL;
1426         
1427                 for( int j=0; j<listShapes->GetSize(); j++ )
1428                     if( ((AliGShape*) listShapes->At(j))->GetName() == shapename ) {
1429                         Shape = (AliGTRD1*) listShapes->At(j);
1430                         //printf( " AliGTRD1( %s, %s, %f, %f, %f, %f ); already existed.\n", shapename, shapename, upar[0], upar[1], upar[2], upar[3] );
1431                         break;
1432                     }
1433
1434                 if( Shape == NULL ) {
1435                     Shape = new AliGTRD1( shapename, shapename, upar[0], upar[1], upar[2], upar[3] );
1436                     //printf( " Created new AliGTRD1( %s, %s, %f, %f, %f, %f );\n", shapename, shapename, upar[0], upar[1], upar[2], upar[3] );
1437                     listShapes->Add(Shape);
1438                 }
1439
1440                 Shape->SetCol(Color);
1441                 son = new AliGNode( fnodename, nr, fnodename, Shape, MyMaterial );
1442             }
1443             else
1444                 if( !strncmp(shapename, "PCON", 4) ) {
1445
1446                     AliGPCone* Shape = NULL;
1447         
1448                     for( int j=0; j<listShapes->GetSize(); j++ )
1449                         if( ((AliGShape*) listShapes->At(j))->GetName() == shapename ) {
1450                             Shape = (AliGPCone*) listShapes->At(j);
1451                             //printf( " AliGPCone( %s, %s, %f, %f, %f ); already existed.\n", shapename, shapename, upar[0], upar[1], upar[2] );
1452                             break;
1453                         }
1454
1455                     if( Shape == NULL ) {
1456                         Shape = new AliGPCone( shapename, shapename, upar, np );
1457                         //printf( " Created new AliGPCone( %s, %s, %f, %f, %f );\n", shapename, shapename, upar[0], upar[1], upar[2] );
1458                         listShapes->Add(Shape);
1459                     }
1460
1461                     Shape->SetCol(Color);
1462                     son = new AliGNode( fnodename, nr, fnodename, Shape, MyMaterial );
1463                 }
1464
1465     Color++;
1466     if( Color == 50 )
1467         Color = 0;
1468
1469     AliGTransform* tra = (AliGTransform*) listTransf->At(0);
1470
1471     TVector* matrix = tra->GetMatrix();
1472
1473     char* transname = new char[10];
1474     sprintf( transname, "%s%d", "tra", MatrCount );
1475     
1476     TVector &mat = *matrix;
1477     AliGTransform* newtra = new AliGTransform(transname, transname, mat(0), mat(1),  mat(2), mat(4), mat(5), mat(6), mat(8), mat(9), mat(10), x, y, z);
1478
1479     //printf( " Created new AliGTransform( %s, %s, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f );\n", transname, transname, mat(0), mat(1), mat(2), mat(4), mat(5), mat(6), mat(8), mat(9), mat(10), x, y, z );
1480
1481     listTransf->AddAt(newtra, MatrCount);
1482     MatrCount++;
1483
1484     parent->Add(son, newtra);
1485
1486     //printf( " %s->Add( %s, %s );\n", parent->GetName(), son->GetName(), newtra->GetName() );
1487
1488     listNodes->Add(son);
1489 }
1490
1491 /***********************************************************************/
1492
1493 void  AliGEODB::Gsrotm(Int_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t) 
1494 {
1495   printf( " Gsrotm.\n" );
1496 }
1497
1498 /***********************************************************************/
1499
1500 void  AliGEODB::Gprotm(Int_t)
1501 {
1502   printf( " Gprotm.\n" );
1503 }
1504
1505 /***********************************************************************/
1506
1507 Int_t AliGEODB::Gsvolu(const char* vname, const char* shape, Int_t nmed, Float_t* upar, Int_t np)
1508 {
1509     Int_t lenvname = strlen(vname);
1510     
1511     char* nodename = new char[lenvname+1];
1512     strcpy( nodename, vname );
1513     nodename[lenvname] = '\x0';
1514
1515     int pos;
1516     for( pos=0; pos<lenvname; pos++ )
1517         if( (nodename[pos] == '\x0') || (nodename[pos] == ' ') )
1518             break;
1519
1520     if( pos < lenvname ) {
1521         if( nodename ) delete [] nodename;
1522         nodename = new char[pos+1];
1523         strncpy( nodename, vname, pos );
1524         nodename[pos] = '\x0';
1525     }
1526
1527     char* shapename = new char[strlen(shape)+1];
1528     strcpy( shapename, shape );
1529     shapename[strlen(shape)] = '\x0';
1530
1531     //printf( "\n Trying to build node: %s with shape: %s, nmed: %d, upar[0]: %f and np: %d\n", nodename, shapename, nmed, upar[0], np );
1532
1533     if( !np ) {
1534         /* if number of parameters is 0, stores the nodename, shapename and nmed to be used in GSPOSP */
1535         NodePosp* AliPosp = new NodePosp;
1536         AliPosp->name     = nodename;
1537         AliPosp->shape    = shapename;
1538         AliPosp->nmed     = nmed;
1539         Posp[PospCount]   = AliPosp;
1540         PospCount++;
1541         return 0;
1542     }
1543
1544     if( (listNodes) && (listNodes->FindObject(nodename)) ) { // Trying to find the node inside listNodes
1545         // The node existed in listNodes.
1546         printf( "\n ERROR!!! Node %s already existed in listNodes\n", nodename );
1547         exit(1);
1548     }
1549     else {
1550         // It's a new node.
1551         Int_t nmat = AliMediums[nmed]->fNmat;
1552
1553         AliGMaterial* MyMaterial = NULL;
1554     
1555         for( int j=0; j<listMaterials->GetSize(); j++ )
1556             if( ((AliGMaterial*) listMaterials->At(j))->GetfImat() == nmat ) {
1557                 MyMaterial = (AliGMaterial*) listMaterials->At(j);
1558                 /*printf( " AliGMaterial( %d, %s, %s, %d, %d, %f, %f, %f, %f, %f, %f, *fUbuf, %d, %f, %f, %f, %f, %f, *fBuf, %d ); already existed.\n", nmat,AliMaterials[nmat]->fName, AliMaterials[nmat]->fName, AliMediums[nmed]->fIsvol, AliMediums[nmed]->fIfield, AliMediums[nmed]->fFieldm, AliMediums[nmed]->fTmaxfd, AliMediums[nmed]->fStemax, AliMediums[nmed]->fDeemax, AliMediums[nmed]->fEpsil, AliMediums[nmed]->fStmin, AliMediums[nmed]->fNbuf, AliMaterials[nmat]->fA, AliMaterials[nmat]->fZ, AliMaterials[nmat]->fDens, AliMaterials[nmat]->fRadl, AliMaterials[nmat]->fAbsl, AliMaterials[nmat]->fNwbuf );*/
1559                 break;
1560             }
1561     
1562         if( MyMaterial == NULL ) {
1563             MyMaterial = new AliGMaterial( nmat, AliMaterials[nmat]->fName, AliMaterials[nmat]->fName, AliMediums[nmed]->fIsvol, AliMediums[nmed]->fIfield, AliMediums[nmed]->fFieldm, AliMediums[nmed]->fTmaxfd, AliMediums[nmed]->fStemax, AliMediums[nmed]->fDeemax, AliMediums[nmed]->fEpsil, AliMediums[nmed]->fStmin, AliMediums[nmed]->fUbuf, AliMediums[nmed]->fNbuf,  AliMaterials[nmat]->fA, AliMaterials[nmat]->fZ, AliMaterials[nmat]->fDens, AliMaterials[nmat]->fRadl, AliMaterials[nmat]->fAbsl, AliMaterials[nmat]->fBuf, AliMaterials[nmat]->fNwbuf );
1564
1565             listMaterials->Add( MyMaterial );
1566
1567             /*printf( " Created new AliGMaterial( %d, %s, %s, %d, %d, %f, %f, %f, %f, %f, %f, *fUbuf, %d, %f, %f, %f, %f, %f, *fBuf, %d );\n", nmat,AliMaterials[nmat]->fName, AliMaterials[nmat]->fName, AliMediums[nmed]->fIsvol, AliMediums[nmed]->fIfield, AliMediums[nmed]->fFieldm, AliMediums[nmed]->fTmaxfd, AliMediums[nmed]->fStemax, AliMediums[nmed]->fDeemax, AliMediums[nmed]->fEpsil, AliMediums[nmed]->fStmin, AliMediums[nmed]->fNbuf, AliMaterials[nmat]->fA, AliMaterials[nmat]->fZ, AliMaterials[nmat]->fDens, AliMaterials[nmat]->fRadl, AliMaterials[nmat]->fAbsl, AliMaterials[nmat]->fNwbuf );*/
1568         }
1569
1570         // Different constructor depending on the shape
1571         AliGNode* node = NULL;
1572
1573         if( !strncmp(shapename, "TUBE", 4) ) {
1574
1575             AliGTube* Shape = NULL;
1576         
1577             for( int j=0; j<listShapes->GetSize(); j++ )
1578                 if( ((AliGShape*) listShapes->At(j))->GetName() == shapename ) {
1579                     Shape = (AliGTube*) listShapes->At(j);
1580                     printf( " AliGTube( %s, %s, %f, %f, %f ); already existed.\n", shapename, shapename, upar[0], upar[1], upar[2] );
1581                     break;
1582                 }
1583
1584             if( Shape == NULL ) {
1585                 Shape = new AliGTube( shapename, shapename, upar[0], upar[1], upar[2] );
1586                 //printf( " Created new AliGTube( %s, %s, %f, %f, %f );\n", shapename, shapename, upar[0], upar[1], upar[2] );
1587                 listShapes->Add(Shape);
1588             }
1589
1590             Shape->SetCol(Color);
1591             node = new AliGNode( nodename, 1, nodename, Shape, MyMaterial );
1592         }
1593         else
1594             if( !strncmp(shapename, "BOX", 3) ) {
1595
1596                 AliGBox* Shape = NULL;
1597         
1598                 for( int j=0; j<listShapes->GetSize(); j++ )
1599                     if( ((AliGShape*) listShapes->At(j))->GetName() == shapename ) {
1600                         Shape = (AliGBox*) listShapes->At(j);
1601                         printf( " AliGBox( %s, %s, %f, %f, %f ); already existed.\n", shapename, shapename, upar[0], upar[1], upar[2] );
1602                         break;
1603                     }
1604
1605                 if( Shape == NULL ) {
1606                     Shape = new AliGBox( shapename, shapename, upar[0], upar[1], upar[2] );
1607                     //printf( " Created new AliGBox( %s, %s, %f, %f, %f );\n", shapename, shapename, upar[0], upar[1], upar[2] );
1608                     listShapes->Add(Shape);
1609                 }
1610
1611                 Shape->SetCol(Color);
1612                 node = new AliGNode( nodename, 1, nodename, Shape, MyMaterial );
1613             }
1614             else
1615                 if( !strncmp(shapename, "TRD1", 4) ) {
1616
1617                     AliGTRD1* Shape = NULL;
1618
1619                     for( int j=0; j<listShapes->GetSize(); j++ )
1620                         if( ((AliGShape*) listShapes->At(j))->GetName() == shapename ) {
1621                             Shape = (AliGTRD1*) listShapes->At(j);
1622
1623                             break;
1624                         }
1625
1626                     if( Shape == NULL ) {
1627                         Shape = new AliGTRD1( shapename, shapename, upar[0], upar[1], upar[2], upar[3] );
1628                         //printf( " Created new AliGTRD1( %s, %s, %f, %f, %f, %f );\n", shapename, shapename, upar[0], upar[1], upar[2], upar[3] );
1629                         listShapes->Add(Shape);
1630                     }
1631
1632                     Shape->SetCol(Color);
1633                     node = new AliGNode( nodename, 1, nodename, Shape, MyMaterial );
1634                 }
1635                 else
1636                     if( !strncmp(shapename, "PCON", 4) ) {
1637
1638                         AliGPCone* Shape = NULL;
1639
1640                         for( int j=0; j<listShapes->GetSize(); j++ )
1641                             if( ((AliGShape*) listShapes->At(j))->GetName() == shapename ) {
1642                                 Shape = (AliGPCone*) listShapes->At(j);
1643                                 break;
1644                             }
1645
1646                         if( Shape == NULL ) {
1647                             Shape = new AliGPCone( shapename, shapename, upar, np );
1648                             //printf( " Created new AliGPCone( %s, %s, %f, %f, %f );\n", shapename, shapename, upar[0], upar[1], upar[2] );
1649                             listShapes->Add(Shape);
1650                         }
1651
1652                         Shape->SetCol(Color);
1653                         node = new AliGNode( nodename, 1, nodename, Shape, MyMaterial );
1654                     }
1655
1656         //printf( " Created new AliGNode( %s, %d, %s, %s, %s );\n", nodename, 1+listNodes->GetSize(), nodename, shapename, MyMaterial->GetName() );
1657
1658         listNodes->Add(node);
1659
1660         //printf( " node->fShape->Color = %d\n", node->GetShape()->GetCol() );
1661
1662         Color++;
1663         if( Color == 50 )
1664             Color = 1;
1665     }
1666
1667     return 0;
1668 }
1669
1670 /***********************************************************************/
1671
1672 void  AliGEODB::Gsatt(const char*, const char*, Int_t) 
1673 {
1674   printf( " Gsatt.\n" );
1675 }
1676
1677 /***********************************************************************/
1678
1679 void  AliGEODB::Gfpara(const char*, Int_t, Int_t, Int_t&, Int_t&, Float_t*, Float_t*) 
1680 {
1681   printf( " Gfpara.\n" );
1682 }
1683
1684 /***********************************************************************/
1685
1686 void  AliGEODB::Gckpar(Int_t, Int_t, Float_t*) 
1687 {
1688   printf( " Gckpar.\n" );
1689 }
1690
1691 /***********************************************************************/
1692
1693 void  AliGEODB::Gckmat(Int_t, char*) 
1694 {
1695   printf( " Gckmat.\n" );
1696 }
1697
1698 /***********************************************************************/
1699
1700 //=======================DRAW functions
1701
1702 void  AliGEODB::InitHIGZ() 
1703 {
1704     printf( "InitHIGZ.\n" );
1705 }
1706
1707 /***********************************************************************/
1708
1709 void  AliGEODB::Gdopen(Int_t) 
1710 {
1711     printf( "Gdopen.\n" );
1712 }
1713
1714 /***********************************************************************/
1715
1716 void  AliGEODB::Gdclose() 
1717 {
1718     printf( "Gdclose.\n" );
1719 }
1720
1721 /***********************************************************************/
1722
1723 void  AliGEODB::Gdelete(Int_t) 
1724 {
1725     cout << " Gdelete" << endl;
1726 }
1727
1728 /***********************************************************************/
1729
1730 void  AliGEODB::Gdshow(Int_t) 
1731 {
1732     cout << " Gdshow" << endl;
1733 }
1734
1735 /***********************************************************************/
1736
1737 void  AliGEODB::Gdopt(const char *,const char *) 
1738 {
1739     cout << " Gdopt" << endl;
1740 }
1741
1742 /***********************************************************************/
1743
1744 void  AliGEODB::Gdraw(const char *,Float_t, Float_t, Float_t,Float_t,Float_t,Float_t,Float_t) 
1745 {
1746     cout << " Gdraw" << endl;
1747 }
1748
1749 /***********************************************************************/
1750
1751 void  AliGEODB::Gdrawc(const char *,Int_t, Float_t,Float_t,Float_t,Float_t,Float_t) 
1752 {
1753     cout << " Gdrawc" << endl;
1754 }
1755
1756 /***********************************************************************/
1757
1758 void  AliGEODB::Gdrawx(const char *,Float_t, Float_t, Float_t, Float_t, Float_t,Float_t,Float_t,Float_t,Float_t) 
1759 {
1760     cout << " Gdrawx" << endl;
1761 }
1762
1763 /***********************************************************************/
1764
1765 void  AliGEODB::Gdhead(Int_t, const char *, Float_t) 
1766 {
1767     cout << " Gdhead" << endl;
1768 }
1769
1770 /***********************************************************************/
1771
1772 void  AliGEODB::Gdman(Float_t, Float_t, const char *) 
1773 {
1774     cout << " Gdman" << endl;
1775 }
1776
1777 /***********************************************************************/
1778
1779 void  AliGEODB::Gdspec(const char *) 
1780 {
1781     cout << " Gdspec" << endl;
1782 }
1783
1784 /***********************************************************************/
1785
1786 void  AliGEODB::DrawOneSpec(const char *) 
1787 {
1788     cout << " DrawOneSpec" << endl;
1789 }
1790
1791 /***********************************************************************/
1792
1793 void  AliGEODB::Gdtree(const char *,Int_t,Int_t) 
1794 {
1795     cout << " Gdtree" << endl;
1796 }
1797
1798 /***********************************************************************/
1799
1800 void  AliGEODB::GdtreeParent(const char *,Int_t,Int_t) 
1801 {
1802     cout << " GdtreeParent" << endl;
1803 }
1804
1805 /***********************************************************************/
1806
1807 //=======================Set functions
1808
1809 void AliGEODB::SetABAN(Int_t)
1810 {
1811     cout << " SetABAN" << endl;
1812 }
1813
1814 /***********************************************************************/
1815
1816 void AliGEODB::SetANNI(Int_t)
1817 {
1818     cout << " SetANNI" << endl;
1819 }
1820
1821 /***********************************************************************/
1822
1823 void AliGEODB::SetAUTO(Int_t)
1824 {
1825     cout << " SetAUTO" << endl;
1826 }
1827
1828 /***********************************************************************/
1829
1830 void AliGEODB::SetBOMB(Float_t)
1831 {
1832     cout << " SetBOMB" << endl;
1833 }
1834
1835 /***********************************************************************/
1836
1837 void AliGEODB::SetBREM(Int_t)
1838 {
1839     cout << " SetBREM" << endl;
1840 }
1841
1842 /***********************************************************************/
1843
1844 void AliGEODB::SetCKOV(Int_t)
1845 {
1846     cout << " SetCKOV" << endl;
1847 }
1848
1849 /***********************************************************************/
1850
1851 void AliGEODB::SetClipBox(const char *,Float_t,Float_t, Float_t,Float_t,Float_t,Float_t) 
1852 {
1853     cout << " SetClipBox" << endl;
1854 }
1855
1856 /***********************************************************************/
1857
1858 void AliGEODB::SetCOMP(Int_t)
1859 {
1860     cout << " SetCOMP" << endl;
1861 }
1862
1863 /***********************************************************************/
1864
1865 void AliGEODB::SetCUTS( Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t )
1866 {
1867     cout << " SetCUTS" << endl;
1868 }
1869
1870 /***********************************************************************/
1871
1872 void AliGEODB::SetDCAY(Int_t)
1873 {
1874     cout << " SetDCAY" << endl;
1875 }
1876
1877 /***********************************************************************/
1878
1879 void AliGEODB::SetDEBU(Int_t, Int_t, Int_t)
1880 {
1881     cout << " SetDEBU" << endl;
1882 }
1883
1884 /***********************************************************************/
1885
1886 void AliGEODB::SetDRAY(Int_t)
1887 {
1888     cout << " SetDRAY" << endl;
1889 }
1890
1891 /***********************************************************************/
1892
1893 void AliGEODB::SetHADR(Int_t)
1894 {
1895     cout << " SetHADR" << endl;
1896 }
1897
1898 /***********************************************************************/
1899
1900 void AliGEODB::SetKINE(Int_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, Float_t,Float_t ) 
1901 {
1902     cout << " SetKINE" << endl;
1903 }
1904
1905 /***********************************************************************/
1906
1907 void AliGEODB::SetLOSS(Int_t)
1908 {
1909     cout << " SetLOSS" << endl;
1910 }
1911
1912 /***********************************************************************/
1913
1914 void AliGEODB::SetMULS(Int_t)
1915 {
1916     cout << " SetMULS" << endl;
1917 }
1918
1919 /***********************************************************************/
1920
1921 void AliGEODB::SetMUNU(Int_t)
1922 {
1923     cout << " SetMUNU" << endl;
1924 }
1925
1926 /***********************************************************************/
1927
1928 void AliGEODB::SetOPTI(Int_t)
1929 {
1930     cout << " SetOPTI" << endl;
1931 }
1932
1933 /***********************************************************************/
1934
1935 void AliGEODB::SetPAIR(Int_t)
1936 {
1937     cout << " SetPAIR" << endl;
1938 }
1939
1940 /***********************************************************************/
1941
1942 void AliGEODB::SetPFIS(Int_t)
1943 {
1944     cout << " SetPFIS" << endl;
1945 }
1946
1947 /***********************************************************************/
1948
1949 void AliGEODB::SetPHOT(Int_t)
1950 {
1951     cout << " SetPHOT" << endl;
1952 }
1953
1954 /***********************************************************************/
1955
1956 void AliGEODB::SetRAYL(Int_t)
1957 {
1958     cout << " SetRAYL" << endl;
1959 }
1960
1961 /***********************************************************************/
1962
1963 void AliGEODB::SetSWIT(Int_t , Int_t)
1964 {
1965     cout << " SetSWIT" << endl;
1966 }
1967
1968 /***********************************************************************/
1969
1970 void AliGEODB::SetTRIG(Int_t)
1971 {
1972     cout << " SetTRIG" << endl;
1973 }
1974
1975 /***********************************************************************/
1976
1977 void AliGEODB::Vname(const char *, char *) 
1978 {
1979     cout << " Vname" << endl;
1980 }
1981
1982 /***********************************************************************/
1983
1984 void AliGEODB::InitLego() 
1985 {
1986     cout << " InitLego" << endl;
1987 }
1988
1989 /***********************************************************************/
1990
1991 extern "C" void sxpart_(){}