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