]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant3/TGeant3GUI.cxx
New detailed and corrected version from Galina Chabratova
[u/mrichter/AliRoot.git] / TGeant3 / TGeant3GUI.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.5  2000/03/20 15:11:03  fca
19 Mods to make the code compile on HP
20
21 Revision 1.4  2000/01/18 16:12:08  morsch
22 Bug in calculation of number of volume divisions and number of positionings corrected
23 Browser for Material and Media properties added
24
25 Revision 1.3  1999/11/14 14:31:14  fca
26 Correct small error and remove compilation warnings on HP
27
28 Revision 1.2  1999/11/10 16:53:35  fca
29 The new geometry viewer from A.Morsch
30
31 */
32
33 /* 
34  *  Version: 0
35  *  Written by Andreas Morsch
36  *  
37  * 
38  *
39  * For questions critics and suggestions to this part of the code
40  * contact andreas.morsch@cern.ch
41  * 
42  **************************************************************************/
43 #include <stdlib.h>
44 #include <TROOT.h>
45 #include <AliRun.h>
46 #include <AliMC.h>
47 #include <TGeant3.h>
48 #include <THIGZ.h>
49 #include <TApplication.h>
50 #include <TVirtualX.h>
51 #include <TGListBox.h>
52 #include <TGListTree.h>
53 #include <TGClient.h>
54 #include <TGFrame.h>
55 #include <TGIcon.h>
56 #include <TGLabel.h>
57 #include <TGButton.h>
58 #include <TGTextEntry.h>
59 #include <TGMsgBox.h>
60 #include <TGMenu.h>
61 #include <TGCanvas.h>
62 #include <TGComboBox.h>
63 #include <TGTab.h>
64 #include <TGSlider.h>
65 #include <TGDoubleSlider.h>
66 #include <TGFileDialog.h>
67 #include <TRootEmbeddedCanvas.h>
68 #include <TCanvas.h>
69 #include <TH1.h>
70 #include <TH2.h>
71 #include <TRandom.h>
72 #include <TSystem.h>
73 #include <TEnv.h>
74 #include <TGPicture.h>
75 #include <TGraph.h>
76
77 #include "TGeant3GUI.h"
78
79 static AliDrawVolume  *gCurrentVolume   = new AliDrawVolume("NULL");
80 static AliGUIMaterial *gCurrentMaterial = new AliGUIMaterial();
81 static AliGUIMedium   *gCurrentMedium   = new AliGUIMedium();
82 static Int_t           gCurrentParticle = 1;
83 static Int_t           gCurrentProcess  = 1;
84
85 ClassImp(AliGeant3GeometryGUI)
86
87     AliGeant3GeometryGUI::AliGeant3GeometryGUI()
88 {
89     fPanel  =   new AliGuiGeomMain(gClient->GetRoot(), 500, 500);
90     fNstack = 0;
91     fVolumes =   new TClonesArray("AliDrawVolume",1000);
92     fMaterials = new TClonesArray("AliGUIMaterial",1000);
93     fMedia =     new TClonesArray("AliGUIMedium",1000);
94 //  Store local copy of zebra bank entries
95     TGeant3 *geant3 = (TGeant3*) gMC;
96     if (geant3) {
97         fZlq=geant3->Lq();
98         fZq=geant3->Q();
99         fZiq=geant3->Iq();
100         fGclink=geant3->Gclink();
101         fGcnum=geant3->Gcnum();
102 //
103         ReadGeometryTree();
104         ReadMaterials();
105     }
106 }
107 void AliGeant3GeometryGUI::Streamer(TBuffer &)
108 {
109 ;
110 }
111
112
113 void AliGeant3GeometryGUI::ReadGeometryTree()
114 {
115 //
116 // Copy zebra volume tree into ROOT LisTree
117 //
118     char *vname;
119     char /* *namec, */ *tmp;
120     char namec[30];
121 //  Icons for 
122 //  Closed folder (=volume containing children)
123     const TGPicture* Folder     = gClient->GetPicture("folder_t.xpm");
124 //  Open folder   (=volume containing children)
125     const TGPicture* OpenFolder = gClient->GetPicture("ofolder_t.xpm");
126 //  Empty object
127     const TGPicture* Document   = gClient->GetPicture("doc_t.xpm");
128
129     AliDrawVolume  *volume;
130
131     Int_t nst=0;
132     Int_t nlevel=1;
133     Int_t newlevel=nlevel;
134
135     volume = new AliDrawVolume("ALIC");
136     volume->SetIdVolume(((TGeant3*)gMC)->VolId("ALIC"));
137     volume->SetIdCopy(0);
138     volume->SetItem(NULL);
139     (*fVolumes)[0]=volume;
140 //
141 //  Loop over volumes for which information has been collected
142     while(nlevel>nst) {
143         for (Int_t i=nst; i<nlevel; i++) 
144         {
145             TGListTreeItem *itemi, *item2;
146 // GEANT3 volume number
147             Int_t ivol=TMath::Abs(Volume(i)->GetIdVolume());
148 // Copy number
149 // icopy=1 normal positioning
150 // icopy>1 positioning with parposp
151 // icopy<0 division
152             Int_t icopy = Volume(i)->GetIdCopy();
153 // Medium and material number, handle special case of divisions
154             Int_t imat, imed;
155             
156             if (icopy <0) {
157                 imed=Medium(-ivol);
158                 imat=Material(-ivol);
159             } else {
160                 imed=Medium(ivol);
161                 imat=Material(ivol);
162             }
163 //
164 // Number of children
165             Int_t nch = NChildren(ivol);
166             strcpy(namec,((TGeant3*)gMC)->VolName(ivol));
167             if (nch >= 0) {
168                 printf("\n %s has %d children  \n ", namec,  nch);
169             } else {
170                 printf("\n %s has  divisions \n ", namec);
171             }
172 //
173 // Name to be used in ListTree
174             vname = new char[5];
175             strncpy(vname,namec, 4);
176             vname[4]='\0';
177
178             if (icopy >1) {
179                 sprintf(namec,"%s*%3dPos",namec,icopy);
180             } else if (icopy <0) {
181                 sprintf(namec,"%s*%3dDiv",namec,-icopy);
182             }
183             if (i>0) {
184                 itemi=Volume(i)->GetItem();
185             } else {
186                 itemi=NULL;
187             }
188             
189 //
190 // Add volume to list tree
191             
192             if (nch!=0) {
193                 item2 = fPanel->AddItem(new AliDrawVolume(vname), 
194                                     itemi, namec, OpenFolder, Folder);
195             } else {
196                 item2 = fPanel->AddItem(new AliDrawVolume(vname), 
197                                     itemi, namec, Document, Document);
198             }
199 //
200 // Add medium information to list tree item
201             ((AliDrawVolume *) item2->GetUserData())->SetIdVolume(ivol);
202             ((AliDrawVolume *) item2->GetUserData())->SetIdMaterial(imat);
203             ((AliDrawVolume *) item2->GetUserData())->SetIdMedium(imed);
204 //
205 // Set current volume to first list tree entry
206             if (!i) gCurrentVolume= ((AliDrawVolume *) item2->GetUserData());
207             
208 //
209 // Collect children information
210 //
211 // nch < 0: Children by division            
212             if (nch < 0) {
213 //
214 // Geant volume number
215                 Int_t icvol=Child(ivol,1);
216 // Name
217                 strcpy(namec,((TGeant3*)gMC)->VolName(-icvol));
218                 tmp = new char[4];
219                 strncpy(tmp,(char *) &namec, 4);
220                 volume = new AliDrawVolume(namec);
221                 volume->SetIdVolume(-icvol);
222 // Number of divisions
223                 Int_t jvo  = fZlq[fGclink->jvolum-ivol];
224                 Int_t jdiv = fZlq[jvo-1];
225                 Int_t ndiv = Int_t (fZq[jdiv+3]);
226                 volume->SetIdCopy(-ndiv);
227 // Link to mother
228                 volume->SetItem(item2);
229                 (*fVolumes)[newlevel]=volume;
230                 printf("\n volume %s %d %d %d", namec, icvol, nch, ndiv);
231                 newlevel++;
232 //
233 // Children by positioning
234             } else {
235                 Int_t nnew=0;
236 // Loop over children 
237                 for (Int_t j=0; j<nch; j++) 
238                 {
239 //
240 // Find out if this volume was already positioned and count copies 
241                     Int_t icvol=Child(ivol,j+1);
242                     icvol = TMath::Abs(icvol);
243                     Bool_t inList=kFALSE;
244                     for (Int_t k=0; k<nnew; k++) {
245                         if (icvol==
246                             Volume(newlevel-k-1)->GetIdVolume()) 
247                         {
248                             Volume(newlevel-k-1)->AddCopy();
249                             inList=kTRUE;
250                         }
251                     }
252 //
253 // New child
254                     if (!inList) {
255 //
256 // Name
257                         strcpy(namec,((TGeant3*)gMC)->VolName(icvol));
258                         tmp = new char[4];
259                         strncpy(tmp,(char *) &namec, 4);
260                         volume = new AliDrawVolume(namec);
261                         volume->SetIdVolume(icvol);
262                         volume->SetIdCopy(1);
263 // Link to mother
264                         volume->SetItem(item2);
265                         (*fVolumes)[newlevel]=volume;
266                         printf("\n volume %s %d %d", namec, icvol, nch);
267                         newlevel++;
268                         nnew++;
269                     }
270                 }
271             }
272         }
273 // Move one level deaper
274         nst=nlevel;
275         nlevel=newlevel;
276     }
277 }
278
279 void AliGeant3GeometryGUI::ReadMaterials()
280 {
281 //
282 // Puts media and material names into ComboBox and 
283 // collects material information
284 // 
285     Float_t a, z, dens, radl, absl;
286     a=z=dens=radl=absl=-1;
287     Int_t npar=0;
288     Int_t imat, isvol, ifield;
289     Float_t fieldm, tmaxfd, stemax, deemax, epsil, stmin;
290     Float_t par[50];
291     Float_t ubuf[50];
292     Int_t nwbuf;
293     
294     char natmed[21], namate[21];
295 //
296 // Loop over media
297     Int_t NEntries=0;
298     
299     for(Int_t itm=1;itm<=fGcnum->ntmed;itm++) {
300         Int_t jtm  = fZlq[fGclink->jtmed-itm];
301         if (jtm > 0) {
302             NEntries++;
303 // 
304 // Get medium parameters
305             ((TGeant3*)(gMC))->Gftmed(itm, natmed, imat, isvol, ifield, fieldm, 
306                                       tmaxfd, stemax, deemax, epsil, stmin, ubuf, &nwbuf);
307             strncpy(natmed,(char*)&fZiq[jtm+1],20);
308             natmed[20]='\0';
309 //
310 // Create new medium object 
311             AliGUIMedium * medium = 
312                 new AliGUIMedium(itm, imat, natmed, isvol, ifield, fieldm, 
313                                       tmaxfd, stemax, deemax, epsil, stmin);
314             (*fMedia)[NEntries-1]=medium;
315         { //Begin local scope for j
316           for (Int_t j=1; j<=22; j++) {
317             medium->SetPar(j,Cut(itm,j));
318           }
319         } //End local scope for j
320         { //Begin local scope for j
321           for (Int_t j=23; j<=26; j++) {
322             medium->SetPar(j,Cut(itm,j+3));
323           }
324         } //End local scope for j
325         { //Begin local scope for j
326           for (Int_t j=27; j<=29; j++) {
327             medium->SetPar(j,Cut(itm,j+4));
328           }
329         } //End local scope for j
330 //
331 // Add to ComboBox
332             fPanel->AddMedium(medium, NEntries);
333 //
334 // Associated material
335             imat =  Int_t (fZq[jtm+6]);
336             Int_t jma  =  Int_t (fZlq[fGclink->jmate-imat]);
337 //
338 // Get material parameters
339             ((TGeant3*)(gMC))->Gfmate (imat,namate,a,z,dens,radl,absl,par,npar);
340             strncpy(namate,(char *)&fZiq[jma+1],20);
341             namate[20]='\0';
342 //
343 // Create new material object
344             AliGUIMaterial * material = 
345                 new AliGUIMaterial(imat,namate,a,z,dens,radl,absl);
346             (*fMaterials)[NEntries-1]=material;
347             material->Dump();
348 //
349 // Add to combo box
350             fPanel->AddMaterial(material, NEntries);
351             gCurrentMaterial=material;
352         }
353     }
354     fPanel->SetComboEntries(fMaterials);
355     fPanel->SetMediaComboEntries(fMedia);
356     fPanel->Update();
357 }
358
359 Int_t AliGeant3GeometryGUI::NChildren(Int_t idvol)
360 {
361 //
362 // Return number of children for volume idvol
363     Int_t jvo = fZlq[fGclink->jvolum-idvol];
364     Int_t nin = Int_t(fZq[jvo+3]);
365     return nin;
366 }
367
368 Int_t AliGeant3GeometryGUI::Child(Int_t idvol, Int_t idc)
369 {
370 //
371 // Return GEANT id of child number idc of volume idvol
372     Int_t jvo = fZlq[fGclink->jvolum-idvol];
373     Int_t nin=idc;
374     Int_t jin = fZlq[jvo-nin];
375     Int_t numb =  Int_t (fZq[jin +3]);
376     if (numb > 1) {
377         return -Int_t(fZq[jin+2]);
378     } else {
379         return Int_t(fZq[jin+2]);
380     }
381 }
382
383 Int_t AliGeant3GeometryGUI::Medium(Int_t idvol)
384 {
385 //
386 // Return medium number for volume idvol.
387 // If idvol is negative the volume results from a division.
388     Int_t imed;
389     if (idvol > 0) {
390         Int_t jvo = fZlq[fGclink->jvolum-idvol];
391         imed = Int_t(fZq[jvo+4]);
392     } else {
393         idvol=-idvol;
394         Int_t jdiv = fZlq[fGclink->jvolum-idvol];
395         Int_t ivin = Int_t ( fZq[jdiv+2]);
396         Int_t jvin = fZlq[fGclink->jvolum-ivin];
397         imed = Int_t (fZq[jvin+4]);
398     }
399     return imed;
400 }
401
402 Int_t AliGeant3GeometryGUI::Material(Int_t idvol)
403 {
404 // Return material number for volume idvol.
405 // If idvol is negative the volume results from a division.
406
407     Int_t imed=Medium(idvol);
408     Int_t jtm  = fZlq[fGclink->jtmed-imed];
409     return Int_t (fZq[jtm+6]);
410 }
411
412
413 Float_t AliGeant3GeometryGUI::Cut(Int_t imed, Int_t icut)
414 {
415 // Return cuts icut for medium idmed 
416 // 
417     Int_t jtm  = fZlq[fGclink->jtmed-imed];
418 //
419 //  Have the defaults been modified ??
420     Int_t jtmn = fZlq[jtm];
421     if (jtmn >0) {
422         jtm=jtmn;
423         
424     } else {
425         jtm=fGclink->jtmed;
426     }
427     
428     return Float_t (fZq[jtm+icut]);
429 }
430
431 ClassImp(AliDrawVolume)
432 //
433 // Drawing parameter tags
434 enum AliDrawParamId {
435    P_Theta,
436    P_Phi,
437    P_Psi,
438    P_U,
439    P_V,
440    P_Uscale,
441    P_Vscale,
442    P_Shadow,
443    P_Hide,
444    P_Fill,
445    P_Seen,
446    P_Clip,
447    P_ClipXmin,
448    P_ClipXmax,
449    P_ClipYmin,
450    P_ClipYmax,
451    P_ClipZmin,
452    P_ClipZmax
453 };
454
455
456 AliDrawVolume::AliDrawVolume(char* name)
457 {
458     fName   = name;
459     fTheta  = 30;
460     fPhi    = 30;
461     fPsi    = 0;
462     fU      = 10;
463     fV      = 10;
464     fUscale = 0.01;
465     fVscale = 0.01;
466     fHide=0;
467     fShadow=0;
468     fFill=1;
469     fSeen=1;
470     fClip=0;
471     fClipXmin=0.;
472     fClipXmax=2000.;
473     fClipYmin=0.;
474     fClipYmax=2000.;
475     fClipZmin=0.;
476     fClipZmax=2000.;
477 }
478
479 char* AliDrawVolume::Name()
480 {
481 //
482 // Return volume name
483     return fName;
484 }
485
486     
487 void AliDrawVolume::Streamer(TBuffer &)
488 {
489 ;
490 }
491
492
493
494 void AliDrawVolume::Draw(Option_t *)
495 {
496     gMC->Gsatt(fName,"seen", fSeen);
497     
498     if (fHide) {
499         gMC->Gdopt("hide", "on");
500     } else {
501         gMC->Gdopt("hide", "off");
502     }
503
504     if (fShadow) {
505         gMC->Gdopt("shad", "on");
506         gMC->Gsatt("*", "fill", fFill);
507     } else {
508         gMC->Gdopt("shad", "off");
509     }
510
511         gMC->SetClipBox(".");
512     if (fClip) {
513         gMC->SetClipBox("*", fClipXmin, fClipXmax, 
514                         fClipYmin, fClipYmax, fClipZmin, fClipZmax);
515     } else {
516         gMC->SetClipBox(".");
517     }
518     
519
520     gMC->Gdraw(fName, fTheta, fPhi, fPsi, fU, fV, fUscale, fVscale);
521     THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
522     if (higz) higz->Update();
523 }
524
525 void AliDrawVolume::DrawSpec()
526 {
527     gMC->Gsatt(fName,"seen", fSeen);
528     
529     if (fHide) {
530         gMC->Gdopt("hide", "on");
531     } else {
532         gMC->Gdopt("hide", "off");
533     }
534
535     if (fShadow) {
536         gMC->Gdopt("shad", "on");
537         gMC->Gsatt("*", "fill", fFill);
538     } else {
539         gMC->Gdopt("shad", "off");
540     }
541
542     gMC->SetClipBox(".");
543     if (fClip) {
544         gMC->SetClipBox("*", fClipXmin, fClipXmax, fClipYmin, fClipYmax, fClipZmin, fClipZmax);
545     } else {
546         gMC->SetClipBox(".");
547     }
548     
549
550     ((TGeant3*) gMC)->DrawOneSpec(fName);
551     THIGZ *higz = (THIGZ*)gROOT->GetListOfCanvases()->FindObject("higz");
552     if (higz) higz->Update();
553 }
554
555 void AliDrawVolume::SetParam(Int_t ip, Float_t param)
556 {
557     switch (ip) {
558     case P_Theta:
559         fTheta=param;
560         break;
561     case P_Phi:
562         fPhi=param;
563         break;
564     case P_Psi:
565         fPsi=param;
566         break;
567     case P_U:
568         fU=param;
569         break;
570     case P_V:
571         fV=param;
572         break;
573     case P_Uscale:
574         fUscale=param;
575         break;
576     case P_Vscale:
577         fVscale=param;
578         break;
579     case P_Hide:
580         fHide=Int_t(param);
581         break;
582     case P_Shadow:
583         fShadow=Int_t(param);
584         break;
585     case P_Fill:
586         fFill=Int_t(param);
587         break;
588     case P_Seen:
589         fSeen=Int_t(param);
590         break;
591     case P_Clip:
592         fClip=Int_t(param);
593         break;
594     case P_ClipXmin:
595         fClipXmin=param;
596         break;
597     case P_ClipXmax:
598         fClipXmax=param;
599         break;
600     case P_ClipYmin:
601         fClipYmin=param;
602         break;
603     case P_ClipYmax:
604         fClipYmax=param;
605         break;
606     case P_ClipZmin:
607         fClipZmin=param;
608         break;
609     case P_ClipZmax:
610         fClipZmax=param;
611         break;
612     }
613 }
614
615 Float_t  AliDrawVolume::GetParam(Int_t ip)
616 {
617     switch (ip) {
618     case P_Theta:
619         return fTheta;
620     case P_Phi:
621         return fPhi;
622     case P_Psi:
623         return fPsi;
624     case P_U:
625         return fU;
626     case P_V:
627         return fV;
628     case P_Uscale:
629         return fUscale;
630     case P_Vscale:
631         return fVscale;
632     case P_Hide:
633         return Float_t(fHide);
634     case P_Shadow:
635         return Float_t(fShadow);
636     case P_Fill:
637         return Float_t(fFill);
638     case P_Seen:
639         return Float_t(fSeen);
640     case P_Clip:
641         return Float_t(fClip);
642     case P_ClipXmin:
643         return fClipXmin;
644     case P_ClipXmax:
645         return fClipXmax;
646     case P_ClipYmin:
647         return fClipYmin;
648     case P_ClipYmax:
649         return fClipYmax;
650     case P_ClipZmin:
651         return fClipZmin;
652     case P_ClipZmax:
653         return fClipZmax;
654     default:
655         return 0.;
656     }
657     return 0.;
658 }
659
660
661 ClassImp(AliGuiGeomMain)
662
663  const Text_t* LabelTextP[19]  = 
664 {"PAIR  ", "COMP  ", "PHOT  ", "PFIS  ", "DRAY  ", "ANNI  ", "BREM  ", 
665  "HADR  ", "MUNU  ", "DCAY  ", "LOSS  ", "MULS  ", "GHCOR1", "BIRK1 ", 
666  "BIRK2 ", "BIRK3 ", "LABS  ", "SYNC  ", "STRA  "};
667
668
669  const Text_t* LabelTextC[10]  = 
670  {"CUTGAM", "CUTELE", "CUTNEU", "CUTHAD", "CUTMUO", "BCUTE", "BCUTM",
671   "DCUTE ", "DCUTM ", "PPCUTM"};
672
673 const Text_t* LabelTextPart[24]  = 
674 {"Photon", "Positron", "Electron", "Neutrino", "Muon+", "Muon-", 
675  "Pi0", "Pi+", "Pi-", "Kaon_L", "Kaon+", "Kaon-", "Neutron", "Proton", 
676  "Anti Proton", "Kaon_S", "Eta", "Lambda", "Sigma+", "Sigma0", "Sigma-",
677  "Xi0", "Xi-", "Omega-"};
678
679 const Text_t* LabelTextMechanism[24]  = 
680 {"HADF", "INEF", "ELAF", "FISF", "CAPF",
681  "HADG", "INEG", "ELAG", "FISG", "CAPG",
682  "LOSS", "PHOT", "ANNI", "COMP", "BREM",
683  "PAIR", "DRAY", "PFIS", "RAYL", "HADG",
684  "MUNU", "RANG", "STEP", "MUON"};
685
686
687
688
689 enum ETestCommandIdentifiers {
690    M_FILE_OPEN,
691    M_FILE_SAVE,
692    M_FILE_SAVEAS,
693    M_FILE_EXIT,
694
695    M_TEST_DLG,
696
697    M_HELP_CONTENTS,
698    M_HELP_SEARCH,
699    M_HELP_ABOUT,
700
701
702    VId1,
703    HId1,
704    VId2,
705    HId2,
706
707    VSId1,
708    HSId1,
709    VSId2,
710    HSId2
711 };
712
713
714 Int_t mb_button_id[9] = { kMBYes, kMBNo, kMBOk, kMBApply,
715                           kMBRetry, kMBIgnore, kMBCancel,
716                           kMBClose, kMBDismiss };
717
718 EMsgBoxIcon mb_icon[4] = { kMBIconStop, kMBIconQuestion,
719                            kMBIconExclamation, kMBIconAsterisk };
720
721 const char *filetypes[] = { "All files",     "*",
722                             "ROOT files",    "*.root",
723                             "ROOT macros",   "*.C",
724                             0,               0 };
725
726
727
728
729 TGListTreeItem*  AliGuiGeomMain::
730 AddItem(TObject * obj, TGListTreeItem *parent, const char* name, const TGPicture *open, const TGPicture *closed)
731 {
732     return fLt->AddItem(parent, name, obj, open, closed);
733 }
734
735 AliGuiGeomMain::AliGuiGeomMain(const TGWindow *p, UInt_t w, UInt_t h)
736       : TGMainFrame(p, w, h)
737 {
738     fDialog=0;
739    // Create test main frame. A TGMainFrame is a top level window.
740    // Create menubar and popup menus. The hint objects are used to place
741    // and group the different menu widgets with respect to eachother.
742    fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
743                                       0, 0, 1, 1);
744    fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
745    fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
746
747    fMenuFile = new TGPopupMenu(gClient->GetRoot());
748    fMenuFile->AddEntry("&Open...", M_FILE_OPEN);
749    fMenuFile->AddEntry("&Save", M_FILE_SAVE);
750    fMenuFile->AddEntry("S&ave as...", M_FILE_SAVEAS);
751    fMenuFile->AddEntry("&Close", -1);
752    fMenuFile->AddSeparator();
753    fMenuFile->AddEntry("E&xit", M_FILE_EXIT);
754
755    fMenuFile->DisableEntry(M_FILE_SAVEAS);
756    fMenuFile->DisableEntry(M_FILE_OPEN);
757    fMenuFile->DisableEntry(M_FILE_SAVE);
758
759
760
761    fMenuTest = new TGPopupMenu(this);
762    fMenuTest->AddLabel("Draw");
763    fMenuTest->AddSeparator();
764    fMenuTest->AddEntry("&Volume Draw Control", M_TEST_DLG);
765    fMenuTest->AddSeparator();
766    fMenuTest->Associate(this);
767    
768    
769    fMenuHelp = new TGPopupMenu(gClient->GetRoot());
770    fMenuHelp->AddEntry("&Contents", M_HELP_CONTENTS);
771    fMenuHelp->AddEntry("&Search...", M_HELP_SEARCH);
772    fMenuHelp->AddSeparator();
773    fMenuHelp->AddEntry("&About", M_HELP_ABOUT);
774
775    fMenuFile->DisableEntry(M_HELP_CONTENTS);
776    fMenuFile->DisableEntry(M_HELP_SEARCH);
777    fMenuFile->DisableEntry(M_HELP_ABOUT);
778    // Menu button messages are handled by the main frame (i.e. "this")
779    // ProcessMessage() method.
780    fMenuFile->Associate(this);
781    fMenuTest->Associate(this);
782    fMenuHelp->Associate(this);
783
784    fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
785    fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout);
786    fMenuBar->AddPopup("&Draw Control", fMenuTest, fMenuBarItemLayout);
787    fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout);
788
789    AddFrame(fMenuBar, fMenuBarLayout);
790
791 // 
792 // Volumes
793 //
794    fTab = new TGTab(this, 400, 400);
795    TGCompositeFrame *tf = fTab->AddTab("Volumes");
796    TGLayoutHints *fLTab = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
797                                           kLHintsExpandY, 2, 2, 5, 1);
798    AddFrame(fTab, fLTab);
799
800 // Create TGCanvas and a canvas container which uses a tile layout manager
801    fCanvasWindow = new TGCanvas(tf, 400, 240);
802 // Create TreeList
803    fLt = new TGListTree(fCanvasWindow->GetViewPort(), 10, 10, kHorizontalFrame,
804                         fgWhitePixel);
805    fLt->Associate(this);
806    fCanvasWindow->SetContainer(fLt);
807
808     
809    TGLayoutHints *lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
810    tf->AddFrame(fCanvasWindow, lo);
811 //
812 // Materials
813 //
814    tf = fTab->AddTab("Materials");
815    fF2 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame);
816    fL2 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
817 // ComboBox for materials
818    fMaterialCombo = new TGComboBox(fF2, 1);
819    fF2->AddFrame(fMaterialCombo, fL2);
820 // 
821 // text labels with material properties 
822 //
823    Text_t* LabelText[6]  = 
824    {"Material Number  ", 
825     "Atomic Weight    ",
826     "Atomic Number    ", 
827     "Density          ",
828     "Radiation Length ", 
829     "Absorption Length"};
830
831    TGLayoutHints* Bly   = 
832        new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
833    TGLayoutHints* Bfly1 = 
834        new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
835    fF21 = new TGCompositeFrame(fF2, 60, 20, kVerticalFrame);
836    fF2->AddFrame(fF21,fL2);
837    for (Int_t i=0; i<6; i++) {
838        Int_t idT=i+1;       
839        fHframe[i] = new TGHorizontalFrame(fF21, 400, 100, kFixedWidth);
840        fF21->AddFrame(fHframe[i], Bly);
841        fTbh[i] = new TGTextBuffer(10);
842        fTeh[i] = new TGTextEntry(fHframe[i], fTbh[i],idT);
843        fTeh[i]->Associate(this);
844        fLabel[i] = new TGLabel(fHframe[i], LabelText[i]);
845        fHframe[i]->AddFrame(fLabel[i], Bfly1);
846        fHframe[i]->AddFrame(fTeh[i], Bfly1);
847    }
848   tf->AddFrame(fF2, fL2);
849   fMaterialCombo->Resize(200, 20);
850   fMaterialCombo->Associate(this);
851
852
853 // Media Combo
854 //   
855    tf = fTab->AddTab("Media");
856    fF3 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame);
857 // ComboBox for tracking media
858    fMediaCombo = new TGComboBox(fF3, 2);
859    fF3->AddFrame(fMediaCombo, fL2);
860 // 
861 // text labels with material properties 
862 //
863    Text_t* LabelTextM[8]  = 
864    {"Sensitivity Flag      ", 
865     "Magnetic Field Flag   ",
866     "Maximum Field         ", 
867     "Max. Ang. Deviation   ",
868     "Maximum Step          ", 
869     "Max. Frac. Energy Loss",
870     "Crossing Precission   ",
871     "Minimum Step Size     "};
872
873    fF31 = new TGCompositeFrame(fF3, 60, 20, kVerticalFrame);
874    fF3->AddFrame(fF31,fL2);
875    { //Begin local scope for i
876      for (Int_t i=0; i<8; i++) {
877        Int_t idT=i+1;       
878        fHframeM[i] = new TGHorizontalFrame(fF31, 400, 100, kFixedWidth);
879        fF31->AddFrame(fHframeM[i], Bly);
880        fTbhM[i] = new TGTextBuffer(10);
881        fTehM[i] = new TGTextEntry(fHframeM[i], fTbhM[i],idT);
882        fTehM[i]->Associate(this);
883        fLabelM[i] = new TGLabel(fHframeM[i], LabelTextM[i]);
884        fHframeM[i]->AddFrame(fLabelM[i], Bfly1);
885        fHframeM[i]->AddFrame(fTehM[i], Bfly1);
886      }
887    } //End local scope for i
888   tf->AddFrame(fF3, fL2);
889   fMediaCombo->Resize(200, 20);
890   fMediaCombo->Associate(this);
891 //
892 // Processes
893    tf = fTab->AddTab("Processes");
894    fF4 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame);
895    fProcessLB = new TGListBox(fF4, 1);
896    fF4->AddFrame(fProcessLB, fL2);
897    tf->AddFrame(fF4, fL2);
898    fProcessLB->Resize(150, 350);
899    fProcessLB->Associate(this);
900    
901 //
902 // Cuts
903    tf = fTab->AddTab("Cuts");
904    fF5 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame);
905    fCutsLB = new TGListBox(fF5, 1);
906    fF5->AddFrame(fCutsLB, fL2);
907    tf->AddFrame(fF5, fL2);
908    fCutsLB->Resize(150, 350);
909
910 //
911 // de/dx and cross-sections
912    tf = fTab->AddTab("DE/DX and X-Sections");
913    fF6 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame);
914
915 // ComboBox for particles
916    fF61 = new TGCompositeFrame(fF6, 60, 20, kVerticalFrame);
917    fF6->AddFrame(fF61, fL2);
918    fParticleCombo = new TGComboBox(fF61, 3);
919    fF61->AddFrame(fParticleCombo, fL2);
920    { //Begin local scope for i
921      for (Int_t i = 0; i < 24; i++) {
922        char tmp[20];
923        sprintf(tmp, "%s", LabelTextPart[i]);
924        fParticleCombo->AddEntry(tmp, i+1);
925      }
926    } //End local scope for i
927    fParticleCombo->Select(1);
928    fParticleCombo->Resize(100, 20);
929    fParticleCombo->Associate(this);
930
931 // ComboBox for mechanisms
932    fF63 = new TGCompositeFrame(fF6, 60, 20, kVerticalFrame);
933    fF6->AddFrame(fF63, fL2);
934    fMechanismCombo = new TGComboBox(fF63, 4);
935    fF63->AddFrame(fMechanismCombo, fL2);
936    { //Begin local scope for i
937      for (Int_t i = 0; i < 24; i++) {
938        char tmp[20];
939        sprintf(tmp, "%s", LabelTextMechanism[i]);
940        fMechanismCombo->AddEntry(tmp, i+1);
941      }
942    } //End local scope for i
943    fMechanismCombo->Select(1);
944    fMechanismCombo->Resize(100, 20);
945    fMechanismCombo->Associate(this);
946
947 //
948 // Energy Range
949 //
950    fTbh61 = new TGTextBuffer(10);
951    fTeh61 = new TGTextEntry(fF61, fTbh61,10);
952    fTbh61->AddText(0, "  100");
953    fTeh61->Associate(this);
954
955    fTbh62 = new TGTextBuffer(10);
956    fTeh62 = new TGTextEntry(fF61, fTbh62,11);
957    fTbh62->AddText(0, "0.001");
958    fTeh62->Associate(this);
959     
960    fTbh63 = new TGTextBuffer(10);
961    fTeh63 = new TGTextEntry(fF61, fTbh63,12);
962    fTbh63->AddText(0, "10.");
963    fTeh63->Associate(this);
964
965    fEmin=0.001;
966    fEmax=10.;
967    fNbins=100;
968    
969    fSLabel61 = new TGLabel(fF61, "Nbins-Emin-Emax");
970    Bfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
971    fF61->AddFrame(fSLabel61, Bfly1);
972    fF61->AddFrame(fTeh61, Bfly1);
973    fF61->AddFrame(fTeh62, Bfly1);
974    fF61->AddFrame(fTeh63, Bfly1);
975 //
976 // Plot Button
977    fF62 = new TGCompositeFrame(fF6, 60, 20, kHorizontalFrame);
978    fF6->AddFrame(fF62, fL2);
979    fPlotButton = new TGTextButton(fF62, "Plot", 1);
980    fPlotButton -> Associate(this);
981    fF62->AddFrame(fPlotButton);
982
983    tf->AddFrame(fF6, fL2);
984 // Window name and final mapping
985 //
986    SetWindowName("AliRoot Geometry Browser");
987    MapSubwindows();
988    // We need to use GetDefault...() to initialize the layout algorithm...
989    Resize(GetDefaultSize());
990    MapWindow();
991 }
992
993 AliGuiGeomMain::~AliGuiGeomMain()
994 {
995    // Delete all created widgets.
996
997    delete fContainer;
998    delete fCanvasWindow;
999
1000    delete fMenuBarLayout;
1001    delete fMenuBarItemLayout;
1002    delete fMenuBarHelpLayout;
1003
1004    delete fMenuFile;
1005    delete fMenuTest;
1006    delete fMenuHelp;
1007 }
1008
1009 void AliGuiGeomMain::Streamer(TBuffer &)
1010 {
1011 ;
1012 }
1013
1014 void AliGuiGeomMain::Plot()
1015 {
1016     const Float_t avo=0.60221367;
1017     Float_t *tkin  = new Float_t[fNbins];
1018     Float_t *value = new Float_t[fNbins];
1019     Float_t *pcut  = new Float_t[fNbins];
1020     Int_t ixst;
1021     Int_t imate=gCurrentMaterial->Id();
1022     Float_t z=gCurrentMaterial->Z();
1023     Float_t a=gCurrentMaterial->A();
1024     Float_t density=gCurrentMaterial->Density();
1025     
1026     Int_t ipart=gCurrentParticle;
1027     const char *chmeca= LabelTextMechanism[gCurrentProcess-1];
1028     char* tmp;
1029     tmp = new char[5];
1030     strncpy(tmp, chmeca, 4);
1031     tmp[4]='\0';
1032     Int_t kdim=fNbins;
1033     Float_t de=(fEmax-fEmin)/fNbins;
1034     for (Int_t i=0; i<kdim; i++) {
1035         tkin[i]=fEmin+Float_t(i)*de;
1036         value[i]=0.;
1037     }
1038     if (chmeca!="MUON") {
1039         ((TGeant3*) gMC)->Gftmat(imate, ipart, tmp, kdim, tkin, value, pcut, ixst);
1040     } else {
1041         for (Int_t i=0; i<kdim; i++) {
1042             Float_t ekin=tkin[i];
1043             value[i]+=((TGeant3*) gMC)->Gbrelm(z,ekin,1.e10);
1044             value[i]+=((TGeant3*) gMC)->Gprelm(z,ekin,1.e10);
1045             value[i]*=1000.*avo*density/a;
1046         }
1047     }
1048     
1049     
1050     printf("\n %d %d %s %d \n",imate, ipart, chmeca, kdim);
1051     if (ixst) {
1052         TGraph *graph = new TGraph(kdim,tkin,value);
1053         TCanvas *c1 = new TCanvas("c1"," ",400,10,600,700);
1054         c1->Divide(1,1);
1055         c1->cd(1);
1056         
1057         graph->SetFillColor(42);
1058         graph->SetMarkerColor(4);
1059         graph->SetMarkerStyle(21);
1060         graph->Draw("AC");
1061         graph->GetHistogram()->SetXTitle("Energy (GeV)");
1062         if (chmeca == "RANG" || chmeca == "STEP") {
1063             graph->GetHistogram()->SetYTitle
1064                 ("Distance (cm)");   
1065         } else if (chmeca == "LOSS" || chmeca == "MUON") {
1066             graph->GetHistogram()->SetYTitle("dE/dx (MeV/cm)");   
1067         } else {
1068             graph->GetHistogram()->SetYTitle
1069                 ("Macroscopic X-Section (1/cm)"); 
1070         }
1071     }
1072     
1073     delete tkin;
1074     delete value;
1075     delete pcut;
1076     
1077     
1078 }
1079
1080 void AliGuiGeomMain::Update()
1081 {
1082     if (fDialog) {
1083         fDialog->Update();
1084     }
1085
1086     Int_t imat=gCurrentVolume->Material();
1087     Int_t nmat=fComboEntries->GetEntriesFast();
1088     Int_t i=0;
1089     for (i=0; i<nmat; i++) {
1090         gCurrentMaterial = (AliGUIMaterial*) 
1091             (fComboEntries->UncheckedAt(i));
1092         if (gCurrentMaterial->Id()==imat) break;
1093     }
1094     Int_t imed = gCurrentVolume->Medium();
1095     Int_t nmed=fComboMediaEntries->GetEntriesFast();
1096     for (i=0; i<nmed; i++) {
1097         gCurrentMedium = (AliGUIMedium*) 
1098             (fComboMediaEntries->UncheckedAt(i));
1099         if (gCurrentMedium->Id()==imed) break;
1100     }
1101
1102     UpdateCombo();
1103     UpdateListBox();
1104     
1105 }
1106
1107 void AliGuiGeomMain::UpdateCombo()
1108 {
1109
1110     Int_t   imat = gCurrentMaterial->Id();
1111     Float_t    a = gCurrentMaterial->A();
1112     Float_t    z = gCurrentMaterial->Z();    
1113     Float_t dens = gCurrentMaterial->Density();
1114     Float_t radl = gCurrentMaterial->RadiationLength();
1115     Float_t absl = gCurrentMaterial->AbsorptionLength();
1116     Int_t entry=gCurrentMaterial->ItemId();
1117 //    
1118 //
1119     fMaterialCombo->Select(entry);
1120     fMediaCombo->Select(entry);    
1121     char buf[10];
1122      
1123     sprintf(buf, "%10i", imat);
1124     fTbh[0]->Clear();
1125     fTbh[0]->AddText(0, buf);
1126     gClient->NeedRedraw(fTeh[0]);
1127     sprintf(buf, "%10.2e", a);
1128     fTbh[1]->Clear();
1129     fTbh[1]->AddText(0, buf);
1130     gClient->NeedRedraw(fTeh[1]);
1131
1132     sprintf(buf, "%10.2e", z);
1133     fTbh[2]->Clear();
1134     fTbh[2]->AddText(0, buf);
1135     gClient->NeedRedraw(fTeh[2]);
1136
1137     sprintf(buf, "%10.2e", dens);
1138     fTbh[3]->Clear();
1139     fTbh[3]->AddText(0, buf);
1140     gClient->NeedRedraw(fTeh[3]);
1141
1142     sprintf(buf, "%10.2e", radl);
1143     fTbh[4]->Clear();
1144     fTbh[4]->AddText(0, buf);
1145     gClient->NeedRedraw(fTeh[4]);
1146
1147     sprintf(buf, "%10.2e", absl);
1148     fTbh[5]->Clear();
1149     fTbh[5]->AddText(0, buf);
1150     gClient->NeedRedraw(fTeh[5]);
1151
1152 //  Media Combo
1153     sprintf(buf, "%10i", gCurrentMedium->Isvol());
1154     fTbhM[0]->Clear();
1155     fTbhM[0]->AddText(0, buf);
1156     gClient->NeedRedraw(fTehM[0]);
1157
1158
1159     sprintf(buf, "%10i", gCurrentMedium->Ifield());
1160     fTbhM[1]->Clear();
1161     fTbhM[1]->AddText(0, buf);
1162     gClient->NeedRedraw(fTehM[1]);
1163
1164     sprintf(buf, "%10.2e", gCurrentMedium->Fieldm());
1165     fTbhM[2]->Clear();
1166     fTbhM[2]->AddText(0, buf);
1167     gClient->NeedRedraw(fTehM[2]);
1168
1169     sprintf(buf, "%10.2e", gCurrentMedium->Tmaxfd());
1170     fTbhM[3]->Clear();
1171     fTbhM[3]->AddText(0, buf);
1172     gClient->NeedRedraw(fTehM[3]);
1173
1174     sprintf(buf, "%10.2e", gCurrentMedium->Stemax());
1175     fTbhM[4]->Clear();
1176     fTbhM[4]->AddText(0, buf);
1177     gClient->NeedRedraw(fTehM[4]);
1178
1179     sprintf(buf, "%10.2e", gCurrentMedium->Deemax());
1180     fTbhM[5]->Clear();
1181     fTbhM[5]->AddText(0, buf);
1182     gClient->NeedRedraw(fTehM[5]);
1183
1184     sprintf(buf, "%10.2e", gCurrentMedium->Epsil());
1185     fTbhM[6]->Clear();
1186     fTbhM[6]->AddText(0, buf);
1187     gClient->NeedRedraw(fTehM[6]);
1188
1189     sprintf(buf, "%10.2e", gCurrentMedium->Stmin());
1190     fTbhM[7]->Clear();
1191     fTbhM[7]->AddText(0, buf);
1192     gClient->NeedRedraw(fTehM[7]);
1193 }
1194
1195 void AliGuiGeomMain::UpdateListBox()
1196 {
1197     Int_t i;
1198     fProcessLB->RemoveEntries(1,19);
1199     for (i=11; i < 30; i++) {
1200         Float_t p=gCurrentMedium->GetPar(i);
1201         char tmp[20];
1202         sprintf(tmp, "%6s%5d", LabelTextP[i-11], Int_t(p));
1203         fProcessLB->AddEntry(tmp, i-10);
1204     }
1205     fProcessLB->MapSubwindows();
1206     fProcessLB->Layout();
1207
1208     fCutsLB->RemoveEntries(1,10);
1209     for (i=1; i < 11; i++) {
1210         Float_t p=gCurrentMedium->GetPar(i);
1211         char tmp[20];
1212         sprintf(tmp, "%6s%10.3e", LabelTextC[i-1], p);
1213         fCutsLB->AddEntry(tmp,i);
1214     }
1215     fCutsLB->MapSubwindows();
1216     fCutsLB->Layout();
1217 }
1218
1219
1220 void AliGuiGeomMain::CloseWindow()
1221 {
1222    // Got close message for this MainFrame. Calls parent CloseWindow()
1223    // (which destroys the window) and terminate the application.
1224    // The close message is generated by the window manager when its close
1225    // window menu item is selected.
1226
1227    TGMainFrame::CloseWindow();
1228    gApplication->Terminate(0);
1229 }
1230
1231 Bool_t AliGuiGeomMain::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
1232 {
1233     switch (GET_MSG(msg)) {
1234 //
1235 //  Text entries for binning of cross-section plots
1236     case kC_TEXTENTRY:
1237         switch (GET_SUBMSG(msg)) {
1238         case kTE_TEXTCHANGED:
1239             switch (parm1) {
1240             case 10:
1241                 fNbins=(Int_t) atof(fTbh61->GetString());
1242                 break;
1243             case 11:
1244                 fEmin= atof(fTbh62->GetString());
1245                 break;
1246             case 12:
1247                 fEmax= atof(fTbh63->GetString());
1248                 break;
1249             }
1250             printf("\n %d %f %f binning", fNbins, fEmin, fEmax);
1251         }
1252         break;
1253 //
1254 // ListTree for volumes
1255     case kC_LISTTREE:
1256         switch (GET_SUBMSG(msg)) {
1257 //
1258 // Handle mouse click 
1259         case kCT_ITEMCLICK:
1260             TGListTreeItem *item;
1261 //
1262 // Button 1: Select volume
1263             if (parm1 == kButton1) {
1264                 if ((item = fLt->GetSelected())) 
1265                 {
1266                     gCurrentVolume=((AliDrawVolume *) item->GetUserData());
1267                     Update();
1268                 }
1269             }
1270 //
1271 // Button 2: Draw volume specifications
1272
1273             if (parm1 == kButton2) {
1274                 TGListTreeItem *item;
1275                 if ((item = fLt->GetSelected())) 
1276                 {
1277
1278                     ((AliDrawVolume *) item->GetUserData())->DrawSpec();
1279
1280                     gCurrentVolume=((AliDrawVolume *) item->GetUserData());
1281                     Update();
1282                 }
1283             }
1284 //
1285 // Button 3: Draw Volume
1286             if (parm1 == kButton3) {
1287                 TGListTreeItem *item;
1288                 if ((item = fLt->GetSelected())) 
1289                 {
1290                     ((AliDrawVolume *) item->GetUserData())->Draw();
1291                     gCurrentVolume=((AliDrawVolume *) item->GetUserData());
1292                     Update();
1293                 }
1294             }
1295             
1296             
1297             break;
1298         case kCT_ITEMDBLCLICK:
1299             if (parm1 == kButton1) {
1300                 if (fLt->GetSelected() != 0) {
1301                     gClient->NeedRedraw(fLt);
1302                 }
1303             }
1304             break;
1305         default:
1306             break;
1307         }
1308         break;
1309     case kC_COMMAND:
1310         switch (GET_SUBMSG(msg)) {
1311         case kCM_BUTTON:
1312             switch(parm1) {
1313             case 1:
1314                 Plot();
1315                 break;
1316             }
1317             break;
1318         case kCM_COMBOBOX:
1319 //
1320 // Combo box bindings
1321             switch(parm1) {
1322 //
1323 // Material Combo
1324             case 1:
1325                 gCurrentMaterial=(AliGUIMaterial*) 
1326                     (fComboEntries->UncheckedAt(Int_t(parm2-1)));
1327                 gCurrentMedium=(AliGUIMedium*) 
1328                     (fComboMediaEntries->UncheckedAt(Int_t(parm2-1)));
1329                 UpdateCombo();
1330                 UpdateListBox();
1331                 break;
1332 //
1333 // Media Combo
1334             case 2:
1335                 gCurrentMedium=(AliGUIMedium*) 
1336                     (fComboMediaEntries->UncheckedAt(Int_t(parm2-1)));
1337                 gCurrentMaterial=(AliGUIMaterial*) 
1338                     (fComboEntries->UncheckedAt(Int_t(parm2-1)));
1339                 UpdateCombo();
1340                 UpdateListBox();
1341                 break;
1342 //
1343 // Particle Combo
1344             case 3:
1345                 gCurrentParticle=Int_t(parm2);
1346                 break;
1347 //
1348 // Mechanism Combo
1349             case 4:
1350                 gCurrentProcess=Int_t(parm2);
1351                 printf("\n Process %d", gCurrentProcess);
1352                 break;
1353             }
1354             break;
1355         case kCM_MENUSELECT:
1356             break;
1357             
1358         case kCM_MENU:
1359             switch (parm1) {
1360                 
1361             case M_FILE_OPEN:
1362             {
1363                 TGFileInfo fi;
1364                 fi.fFileTypes = (char **)filetypes;
1365                 new TGFileDialog(gClient->GetRoot(), this, kFDOpen,&fi);
1366             }
1367             break;
1368             
1369             case M_TEST_DLG:
1370                 fDialog = new AliGuiGeomDialog
1371                     (gClient->GetRoot(), this, 400, 200);
1372                 break;
1373                 
1374             case M_FILE_SAVE:
1375                 printf("M_FILE_SAVE\n");
1376                 break;
1377                 
1378             case M_FILE_EXIT:
1379                 CloseWindow();   // this also terminates theApp
1380                 break;
1381             default:
1382                 break;
1383             }
1384         default:
1385             break;
1386         }
1387     default:
1388         break;
1389     }
1390     return kTRUE;
1391 }
1392
1393 void AliGuiGeomMain::AddMaterial(AliGUIMaterial *Material, Int_t i)
1394 {
1395     char* tmp;
1396     tmp=Material->Name();
1397     Material->SetItemId(i);
1398     fMaterialCombo->AddEntry(tmp, i);
1399     fMaterialCombo->Select(i);
1400     fMaterialCombo->Resize(200, 20);
1401 }
1402
1403 void AliGuiGeomMain::AddMedium(AliGUIMedium *Medium, Int_t i)
1404 {
1405     char* tmp;
1406     tmp=Medium->Name();
1407     Medium->SetItemId(i);
1408     
1409     fMediaCombo->AddEntry(tmp, i);
1410     fMediaCombo->Select(i);
1411     fMediaCombo->Resize(200, 20);
1412 }
1413
1414
1415 AliGuiGeomDialog::AliGuiGeomDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
1416                        UInt_t h, UInt_t options)
1417     : TGTransientFrame(p, main, w, h, options)
1418 {
1419    // Create a dialog window. A dialog window pops up with respect to its
1420    // "main" window.
1421
1422    fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
1423
1424    fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
1425    fOkButton->Associate(this);
1426    fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
1427    fCancelButton->Associate(this);
1428
1429    fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
1430                            2, 2, 2, 2);
1431    fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
1432
1433    fFrame1->AddFrame(fOkButton, fL1);
1434    fFrame1->AddFrame(fCancelButton, fL1); 
1435
1436    fFrame1->Resize(150, fOkButton->GetDefaultHeight());
1437    AddFrame(fFrame1, fL2);
1438
1439    //--------- create Tab widget and some composite frames for Tab testing
1440
1441    fTab = new TGTab(this, 300, 300);
1442    fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
1443 //
1444 // Tab1: Sliders
1445 //
1446    TGCompositeFrame *tf = fTab->AddTab("Draw");
1447    fF1 = new AliGUISliders(tf, this, 60, 20);
1448    tf->AddFrame(fF1,fL3);
1449    
1450 // 
1451 // Tab2: Drawing Options
1452 //
1453    tf = fTab->AddTab("Options");
1454    fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
1455                            200, 2, 2, 2);
1456    fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
1457
1458    fF2->AddFrame(fChk1 = new TGCheckButton(fF2, "Shadow", 86), fL3);
1459    fF2->AddFrame(fChk2 = new TGCheckButton(fF2, "Hide  ", 87), fL3);
1460    fF2->AddFrame(fChk3 = new TGCheckButton(fF2, "Clip  ", 88), fL3);
1461
1462    fF2->AddFrame(fLabel1 = new TGLabel(fF2, "Fill"),fL3);
1463    
1464    fCombo = new TGComboBox(fF2, 89);
1465    fF2->AddFrame(fCombo, fL3);
1466
1467    tf->AddFrame(fF2, fL3);
1468
1469    int i;
1470    for (i = 0; i < 8; i++) {
1471       char tmp[20];
1472
1473       sprintf(tmp, "%i", i+1);
1474       fCombo->AddEntry(tmp, i+1);
1475    }
1476    fCombo->Select(1);
1477    fCombo->Resize(50, 20);
1478    fCombo->Associate(this);
1479
1480    fChk1->Associate(this);
1481    fChk2->Associate(this);
1482    fChk3->Associate(this);
1483 // 
1484 // Tab3: Seen Option
1485 //
1486    tf = fTab->AddTab("Seen");
1487    fF3 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
1488    fF3->AddFrame(fLabel2 = new TGLabel(fF3, "Seen"),fL3);
1489    fCombo2 = new TGComboBox(fF3, 90);
1490    fF3->AddFrame(fCombo2, fL3);
1491    tf->AddFrame(fF3, fL3);
1492
1493    for (i = 0; i < 4; i++) {
1494       char tmp[20];
1495
1496       sprintf(tmp, "%i", i-2);
1497       fCombo2->AddEntry(tmp, i+1);
1498    }
1499    fCombo2->Select(4);
1500    fCombo2->Resize(50, 20);
1501    fCombo2->Associate(this);
1502 // 
1503 // Tab4: Clip Box
1504 //
1505    tf = fTab->AddTab("ClipBox");
1506    //--- layout for buttons: top align, equally expand horizontally
1507    fBly = new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
1508
1509    //--- layout for the frame: place at bottom, right aligned
1510    fBfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
1511 //
1512 //  Frames
1513 //
1514 //  Slider1
1515    fF4 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
1516        
1517    fHSframe1 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
1518
1519    fTbh11 = new TGTextBuffer(10);
1520    fTeh11 = new TGTextEntry(fHSframe1, fTbh11,1);
1521    fTbh11->AddText(0, "   0");
1522    fTeh11->Associate(this);
1523
1524    fTbh12 = new TGTextBuffer(10);
1525    fTeh12 = new TGTextEntry(fHSframe1, fTbh12,1);
1526    fTbh12->AddText(0, "2000");
1527    fTeh12->Associate(this);
1528     
1529    fDslider1 = new TGDoubleHSlider(fHSframe1, 400, kSlider1 | kScaleBoth, 1);
1530    fDslider1->Associate(this);
1531    fDslider1->SetRange(-2000, 2000);
1532    fDslider1->SetPosition(0, 2000);
1533    
1534    fSLabel1 = new TGLabel(fHSframe1, "xmin-xmax");
1535
1536    fHSframe1->AddFrame(fSLabel1, fBfly1);
1537    fHSframe1->AddFrame(fTeh11, fBfly1);
1538    fHSframe1->AddFrame(fTeh12, fBfly1);
1539    fHSframe1->AddFrame(fDslider1, fBfly1);
1540    
1541    fF4->AddFrame(fHSframe1, fBly);
1542
1543 //
1544    fHSframe2 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
1545
1546    fTbh21 = new TGTextBuffer(10);
1547    fTeh21 = new TGTextEntry(fHSframe2, fTbh21,1);
1548    fTbh21->AddText(0, "   0");
1549    fTeh21->Associate(this);
1550
1551    fTbh22 = new TGTextBuffer(10);
1552    fTeh22 = new TGTextEntry(fHSframe2, fTbh22,1);
1553    fTbh22->AddText(0, "2000");
1554    fTeh22->Associate(this);
1555
1556    fDslider2 = new TGDoubleHSlider(fHSframe2, 400, kSlider1 | kScaleBoth, 2);
1557    fDslider2->Associate(this);
1558    fDslider2->SetRange(-2000, 2000);
1559    fDslider2->SetPosition(0, 2000);
1560    
1561    fSLabel2 = new TGLabel(fHSframe2, "ymin-ymax");
1562
1563    fHSframe2->AddFrame(fSLabel2, fBfly1);
1564    fHSframe2->AddFrame(fTeh21, fBfly1);
1565    fHSframe2->AddFrame(fTeh22, fBfly1);
1566    fHSframe2->AddFrame(fDslider2, fBfly1);
1567    
1568    fF4->AddFrame(fHSframe2, fBly);
1569
1570 //
1571    fHSframe3 = new TGHorizontalFrame(fF4, 400, 100, kFixedWidth);
1572
1573    fTbh31 = new TGTextBuffer(10);
1574    fTeh31 = new TGTextEntry(fHSframe3, fTbh31,1);
1575    fTbh31->AddText(0, "   0");
1576    fTeh31->Associate(this);
1577
1578    fTbh32 = new TGTextBuffer(10);
1579    fTeh32 = new TGTextEntry(fHSframe3, fTbh32,1);
1580    fTbh32->AddText(0, "2000");
1581    fTeh32->Associate(this);
1582
1583    fDslider3 = new TGDoubleHSlider(fHSframe3, 400, kSlider1 | kScaleBoth, 3);
1584    fDslider3->Associate(this);
1585    fDslider3->SetRange(-2000, 2000);
1586    fDslider3->SetPosition(0, 2000);
1587    
1588    fSLabel3 = new TGLabel(fHSframe3, "zmin-zmax");
1589
1590    fHSframe3->AddFrame(fSLabel3, fBfly1);
1591    fHSframe3->AddFrame(fTeh31, fBfly1);
1592    fHSframe3->AddFrame(fTeh32, fBfly1);
1593    fHSframe3->AddFrame(fDslider3, fBfly1);
1594    
1595    fF4->AddFrame(fHSframe3, fBly);
1596    tf->AddFrame(fF4, fL3);
1597 //
1598 //
1599    TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
1600                                           kLHintsExpandY, 2, 2, 5, 1);
1601    AddFrame(fTab, fL5);
1602
1603    MapSubwindows();
1604    Resize(GetDefaultSize());
1605
1606    // position relative to the parent's window
1607    Window_t wdum;
1608    int ax, ay;
1609    gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
1610                           (((TGFrame *) main)->GetWidth() - fWidth) >> 1,
1611                           (((TGFrame *) main)->GetHeight() - fHeight) >> 1,
1612                           ax, ay, wdum);
1613    Move(ax, ay);
1614
1615    SetWindowName("Dialog");
1616
1617    MapWindow();
1618    //gClient->WaitFor(this);    // otherwise canvas contextmenu does not work
1619 }
1620
1621 AliGuiGeomDialog::~AliGuiGeomDialog()
1622 {
1623    // Delete test dialog widgets.
1624
1625    delete fOkButton;
1626    delete fCancelButton;
1627    delete fFrame1;
1628    delete fChk1; delete fChk2;
1629    delete fF1; delete fF2; delete fF3; delete fF4;
1630    delete fCombo;
1631    delete fTab;
1632    delete fL3; delete fL4;
1633    delete fL1; delete fL2;
1634    delete fBly; delete fBfly1;
1635    delete fTbh11; delete fTbh12; delete fTbh21; delete fTbh22; 
1636    delete fTbh31; delete fTbh32; delete fTeh11; delete fTeh12; 
1637    delete fTeh21; delete fTeh22; delete fTeh31; delete fTeh32;
1638    delete fDslider1; delete fDslider2; delete fDslider3;
1639    delete fSLabel1;  delete fSLabel2;  delete fSLabel3;
1640 }
1641
1642 void AliGuiGeomDialog::Update()
1643 {
1644     
1645     Float_t param;
1646 //  Update Sliders
1647     if (fF1) {
1648         fF1->Update();
1649     }
1650 //  Seen
1651     if (fCombo2) {
1652         param=gCurrentVolume->GetParam(P_Seen);
1653         fCombo2->Select(Int_t(param)+3);
1654     }
1655 //  Hide, Shadow, Clip
1656     if (fChk1) {
1657         if (Int_t(gCurrentVolume->GetParam(P_Shadow))) {
1658             fChk1->SetState(kButtonDown);
1659         } else {
1660             fChk1->SetState(kButtonUp);
1661         }
1662     }
1663
1664     if (fChk2) {
1665         if (Int_t(gCurrentVolume->GetParam(P_Hide))) {
1666             fChk2->SetState(kButtonDown);
1667         } else {
1668             fChk2->SetState(kButtonUp);
1669         }
1670     }
1671
1672     if (fChk3) {
1673         if (Int_t(gCurrentVolume->GetParam(P_Clip))) {
1674             fChk3->SetState(kButtonDown);
1675         } else {
1676             fChk3->SetState(kButtonUp);
1677         }
1678     }
1679     
1680 }
1681
1682 void AliGuiGeomDialog::CloseWindow()
1683 {
1684    // Called when window is closed via the window manager.
1685    delete this;
1686 }
1687
1688 Bool_t AliGuiGeomDialog::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
1689 {
1690    // Process messages coming from widgets associated with the dialog.
1691     char buf[10];
1692     Float_t min,max;
1693     switch (GET_MSG(msg)) {
1694     case kC_HSLIDER:
1695         switch (GET_SUBMSG(msg)) {
1696         case kSL_POS:
1697             switch (Int_t(parm1)) {
1698             case 1:
1699                 min=fDslider1->GetMinPosition();
1700                 max=fDslider1->GetMaxPosition();
1701                 sprintf(buf, "%6.2f", min);
1702                 fTbh11->Clear();
1703                 fTbh11->AddText(0, buf);
1704                 sprintf(buf, "%6.2f", max);
1705                 fTbh12->Clear();
1706                 fTbh12->AddText(0, buf);
1707                 gClient->NeedRedraw(fTeh11);
1708                 gClient->NeedRedraw(fTeh12);
1709                 gCurrentVolume->SetParam(P_ClipXmin,min);
1710                 gCurrentVolume->SetParam(P_ClipXmax,max);
1711                 break;
1712             case 2:
1713                 min=fDslider2->GetMinPosition();
1714                 max=fDslider2->GetMaxPosition();
1715                 sprintf(buf, "%6.2f", min);
1716                 fTbh21->Clear();
1717                 fTbh21->AddText(0, buf);
1718                 sprintf(buf, "%6.2f", max);
1719                 fTbh22->Clear();
1720                 fTbh22->AddText(0, buf);
1721                 gClient->NeedRedraw(fTeh21);
1722                 gClient->NeedRedraw(fTeh22);
1723                 gCurrentVolume->SetParam(P_ClipYmin,min);
1724                 gCurrentVolume->SetParam(P_ClipYmax,max);
1725                 break;
1726             case 3:
1727                 min=fDslider3->GetMinPosition();
1728                 max=fDslider3->GetMaxPosition();
1729                 sprintf(buf, "%6.2f", min);
1730                 fTbh31->Clear();
1731                 fTbh31->AddText(0, buf);
1732                 sprintf(buf, "%6.2f", max);
1733                 fTbh32->Clear();
1734                 fTbh32->AddText(0, buf);
1735                 gClient->NeedRedraw(fTeh31);
1736                 gClient->NeedRedraw(fTeh32);
1737                 gCurrentVolume->SetParam(P_ClipZmin,min);
1738                 gCurrentVolume->SetParam(P_ClipZmax,max);
1739                 break;
1740             default:
1741                 break;
1742             }
1743         }
1744         break;
1745     case kC_COMMAND:
1746         switch (GET_SUBMSG(msg)) {
1747         case kCM_BUTTON:
1748             switch(parm1) {
1749             case 1:
1750             case 2:
1751                 printf("\nTerminating dialog: %s pressed\n",
1752                        (parm1 == 1) ? "OK" : "Cancel");
1753                 CloseWindow();
1754                 break;
1755             }
1756             break;
1757         case kCM_COMBOBOX:
1758             switch(parm1) {
1759             case 89:
1760                 gCurrentVolume->SetParam(P_Fill, Float_t(parm2));
1761                 gCurrentVolume->Draw();
1762                 break;
1763             case 90:
1764                 gCurrentVolume->SetParam(P_Seen, Float_t(parm2-3));
1765                 gCurrentVolume->Draw();
1766                 break;
1767             }
1768             break;
1769         case kCM_CHECKBUTTON:
1770             switch (parm1) {
1771             case 86:
1772                 if (Int_t(gCurrentVolume->GetParam(P_Shadow))) {
1773                     gCurrentVolume->SetParam(P_Shadow, 0.);
1774                 } else {
1775                     gCurrentVolume->SetParam(P_Shadow, 1.);
1776                 }
1777                 gCurrentVolume->Draw();
1778                 break;
1779             case 87:
1780                 if (Int_t(gCurrentVolume->GetParam(P_Hide))) {
1781                     gCurrentVolume->SetParam(P_Hide, 0.);
1782                 } else {
1783                     gCurrentVolume->SetParam(P_Hide, 1.);
1784                 }
1785                 gCurrentVolume->Draw();
1786                 break;
1787             case 88:
1788                 if (Int_t(gCurrentVolume->GetParam(P_Clip))) {
1789                     gCurrentVolume->SetParam(P_Clip, 0.);
1790                 } else {
1791                     gCurrentVolume->SetParam(P_Clip, 1.);
1792                 }
1793                 gCurrentVolume->Draw();
1794                 break;
1795
1796             default:
1797                 break;
1798             }
1799             break;
1800         case kCM_TAB:
1801             break;
1802         default:
1803             break;
1804         }
1805         break;
1806     default:
1807         break;
1808     }
1809     return kTRUE;
1810 }
1811
1812 static Text_t* LabelText[7]  = 
1813 {"Theta  ", "Phi    ", "Psi    ", "U      ", "V      ", "UScale", "VScale"};
1814 static Int_t   IRangeMin[7]  = {    0,     0,     0,    0,    0,   0,   0};
1815 static Int_t   IRangeMax[7]  = {36000, 36000, 36000, 2000, 2000, 10, 10};
1816 static Int_t   DefaultPos[7] = { 3000,  4000,     0, 1000, 1000,   1,   1};
1817
1818 AliGUISliders::AliGUISliders(const TGWindow *p, const TGWindow *,
1819                          UInt_t w, UInt_t h) :
1820     TGCompositeFrame(p, w, h,kVerticalFrame)
1821 {
1822     ChangeOptions((GetOptions() & ~kHorizontalFrame) | kVerticalFrame);
1823    //--- layout for buttons: top align, equally expand horizontally
1824     fBly = new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
1825
1826    //--- layout for the frame: place at bottom, right aligned
1827     fBfly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
1828 //
1829 // Frames
1830
1831    for (Int_t i=0; i<7; i++) {
1832        Int_t idT=i+1;
1833        Int_t idS=i+8;       
1834        fHframe[i] = new TGHorizontalFrame(this, 400, 100, kFixedWidth);
1835        fTbh[i] = new TGTextBuffer(10);
1836        fTeh[i] = new TGTextEntry(fHframe[i], fTbh[i],idT);
1837        char buf[10];
1838        sprintf(buf, "%6.2f", Float_t(DefaultPos[i])/100);
1839        fTbh[i]->AddText(0, buf);
1840        fTeh[i]->Associate(this);
1841        
1842        fHslider[i] = new TGHSlider(fHframe[i], 400, kSlider1 | kScaleBoth, idS);
1843        fHslider[i]->Associate(this);
1844        fHslider[i]->SetRange(IRangeMin[i], IRangeMax[i]);
1845        fHslider[i]->SetPosition(DefaultPos[i]);
1846
1847        fLabel[i] = new TGLabel(fHframe[i], LabelText[i]);
1848        
1849        
1850        fHframe[i]->AddFrame(fLabel[i], fBfly1);
1851        fHframe[i]->AddFrame(fTeh[i], fBfly1);
1852        fHframe[i]->AddFrame(fHslider[i], fBfly1);
1853        AddFrame(fHframe[i], fBly);
1854    }
1855 }
1856
1857 AliGUISliders::~AliGUISliders()
1858 {
1859     delete fBfly1; delete fBly;
1860    // Delete dialog.
1861     for (Int_t i=1; i<7; i++) {
1862         delete fHframe[i];
1863         delete fHslider[i];
1864         delete fTeh[i];
1865         delete fTbh[i]; 
1866     }
1867 }
1868
1869 void AliGUISliders::Update()
1870 {
1871     char buf[10];
1872     
1873     for (Int_t i=0; i<7; i++) {
1874         Float_t param = gCurrentVolume->GetParam(i);
1875 //
1876         fHslider[i]->SetPosition(Int_t(param*100.));
1877         gClient->NeedRedraw(fHslider[i]);
1878 //
1879         sprintf(buf, "%6.2f", param);
1880         fTbh[i]->Clear();
1881         fTbh[i]->AddText(0, buf);
1882         gClient->NeedRedraw(fTeh[i]);
1883 //
1884     }
1885
1886     
1887 }
1888
1889 void AliGUISliders::CloseWindow()
1890 {
1891    // Called when window is closed via the window manager.
1892
1893    delete this;
1894 }
1895
1896 Bool_t AliGUISliders::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
1897 {
1898    // Process slider messages.
1899
1900    char buf[10];
1901
1902    switch (GET_MSG(msg)) {
1903    case kC_TEXTENTRY:
1904        switch (GET_SUBMSG(msg)) {
1905        case kTE_TEXTCHANGED:
1906            Int_t idT=Int_t(parm1)-1;
1907            fHslider[idT]->SetPosition((Int_t)atof(fTbh[idT]->GetString())*100);
1908            gClient->NeedRedraw(fHslider[idT]);
1909            gCurrentVolume->SetParam(idT,atof(fTbh[idT]->GetString()));
1910            gCurrentVolume->Draw();
1911        }
1912        break;
1913    case kC_HSLIDER:
1914        switch (GET_SUBMSG(msg)) {
1915        case kSL_POS:
1916            sprintf(buf, "%6.2f", Float_t(parm2)/100);
1917            Int_t idS=Int_t(parm1)-8;
1918            fTbh[idS]->Clear();
1919            fTbh[idS]->AddText(0, buf);
1920            gClient->NeedRedraw(fTeh[idS]);
1921            gCurrentVolume->SetParam(idS, Float_t(parm2)/100.);
1922            gCurrentVolume->Draw();
1923        }
1924        break;
1925    }
1926    return kTRUE;
1927 }
1928
1929 ClassImp(AliGUIMaterial)
1930
1931 AliGUIMaterial::AliGUIMaterial()
1932
1933     fId=-1;
1934     fName = 0; 
1935     fA=-1; 
1936     fZ=-1; 
1937     fDensity=-1;
1938     fRadl=-1;   
1939     fAbsl=-1;    
1940 }
1941
1942 AliGUIMaterial::AliGUIMaterial(Int_t imat, char* name, Float_t a, Float_t z,
1943                    Float_t dens, Float_t radl, Float_t absl)
1944
1945     fId=imat;
1946     fName=name;
1947     fA=a; 
1948     fZ=z; 
1949     fDensity=dens;
1950     fRadl=radl;   
1951     fAbsl=absl;    
1952 }
1953 void AliGUIMaterial::Dump()
1954 {
1955     printf("\n *****************************************");
1956     printf("\n Material Number:   %10d", fId);
1957     printf("\n %s", fName);
1958     printf("\n Mass   Number:     %10.2f", fA);    
1959     printf("\n Charge Number:     %10.2f", fZ);
1960     printf("\n Density:           %10.2f", fDensity);
1961     printf("\n Radiation  Length: %10.2f", fRadl);
1962     printf("\n Absorption Length: %10.2f", fAbsl);              
1963 }
1964
1965 Int_t AliGUIMaterial::Id()
1966 {
1967     return fId;
1968 }
1969
1970 char*  AliGUIMaterial::Name()
1971 {
1972     return fName;
1973 }
1974
1975 Float_t  AliGUIMaterial::A()
1976 {
1977     return fA;
1978 }
1979
1980 Float_t  AliGUIMaterial::Z()
1981 {
1982     return fZ;
1983 }
1984
1985 Float_t  AliGUIMaterial::Density()
1986 {
1987     return fDensity;
1988 }
1989
1990 Float_t  AliGUIMaterial::RadiationLength()
1991 {
1992     return fRadl;
1993 }
1994
1995 Float_t  AliGUIMaterial::AbsorptionLength()
1996 {
1997     return fAbsl;
1998 }
1999
2000
2001 void AliGUIMaterial::Plot()
2002 {
2003     ;
2004 }
2005
2006 void AliGUIMaterial::Streamer(TBuffer &)
2007 {
2008 ;
2009 }
2010
2011 ClassImp(AliGUIMedium)
2012
2013 AliGUIMedium::AliGUIMedium()
2014
2015     fId=-1;
2016     fName = 0; 
2017 }
2018
2019 AliGUIMedium::AliGUIMedium(Int_t imed, Int_t imat, char* name, Int_t isvol, 
2020                            Int_t ifield,
2021                            Float_t fieldm, Float_t tmaxfd, Float_t stemax, Float_t deemax,
2022                            Float_t epsil, Float_t stmin)
2023 {
2024     fId=imed;
2025     fIdMat=imat;
2026     fName=name;
2027     fIsvol=isvol;
2028     fIfield=ifield;
2029     fFieldm=fieldm;
2030     fTmaxfd=tmaxfd;
2031     fStemax=stemax;
2032     fDeemax=deemax;
2033     fEpsil=epsil;
2034     fStmin=stmin;
2035 }
2036
2037 void AliGUIMedium::Dump()
2038 {
2039     ;
2040 }
2041
2042 Int_t AliGUIMedium::Id()
2043 {
2044     return fId;
2045 }
2046
2047 char*  AliGUIMedium::Name()
2048 {
2049     return fName;
2050 }
2051
2052 Float_t AliGUIMedium::GetPar(Int_t ipar)
2053
2054     Float_t p;
2055     if (ipar < 23) {
2056         p= fPars[ipar-1];   
2057     } else if(ipar >=23 && ipar <27) {
2058         p= fPars[ipar-1+3];   
2059     } else {
2060         p= fPars[ipar-1+4];   
2061     }
2062     
2063     return p;
2064 }
2065  
2066 void AliGUIMedium::Streamer(TBuffer &)
2067 {
2068 ;
2069 }
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084