fixed the tainted variables
[u/mrichter/AliRoot.git] / ITS / Displayv11.C
1 //----------------------------------------------------------------------
2
3 #if !defined(__CINT__) || defined(__MAKECINT__)
4 #include <TROOT.h>
5 #include <TSystem.h>
6 #include <TPolyLine.h>
7 #include <TGeoVolume.h>
8 #include <TGeoMedium.h>
9 #include <TGeoManager.h>
10 #include <TArrayD.h>
11 #include <TArrow.h>
12 #include <TControlBar.h>
13 #include <TGeoTube.h>
14 #include <TCanvas.h>
15 #include <TPad.h>
16 #include <TVirtualPad.h>
17 #include <TView.h>
18 #include "AliITSgeom.h"
19 #include "AliITSInitGeometry.h"
20 #include "AliITSv11GeometrySPD.h"
21 #include "AliITSv11GeometrySDD.h"
22 #include "AliITSv11GeometrySSD.h"
23 #include "AliITSv11GeometrySupport.h"
24 #endif
25
26
27 static AliITSv11GeometrySPD *gspd;
28 static AliITSv11GeometrySDD *gsdd;
29 static AliITSv11GeometrySSD *gssd;
30 static AliITSv11GeometrySupport *gsupp;
31 static AliITSgeom *geom;
32
33 void CreateMaterialsITS();
34
35 void AliMaterial(Int_t imat, const char* name, Float_t a, 
36                  Float_t z, Float_t dens, Float_t radl,
37                  Float_t absl);
38 void AliMedium(Int_t numed, const char *name, Int_t nmat,
39                Int_t isvol, Int_t ifield, Float_t fieldm,
40                Float_t tmaxfd, Float_t stemax, Float_t deemax,
41                Float_t epsil, Float_t stmin);
42 void AliMixture(Int_t kmat, const char* name, Float_t* a, Float_t* z,
43                 Double_t dens, Int_t nlmat=0, Float_t* wmat=0);
44 void Mixture(Int_t& kmat, const char* name, Double_t* a, Double_t* z,
45              Double_t dens, Int_t nlmat, Double_t* wmat);
46 Double_t* CreateDoubleArray(Float_t* array, Int_t size);
47
48 Bool_t Make2DCrossSections(TPolyLine &a0,TPolyLine &a1,
49                            TPolyLine &b0,TPolyLine &b1,TPolyMarker &p);
50
51 //
52 //----------------------------------------------------------------------
53 void Displayv11(){
54     // Display AliITSv11 Geometry
55     // Inputs:
56     //    const char* filename output file with the display in it
57     // Outputs:
58     //    none.
59     // Retrurn:
60     //    none.
61
62     gSystem->Load("libGeom");
63     //
64     if(gGeoManager) delete gGeoManager;
65     gGeoManager = new TGeoManager("ITSGeometry",
66                                   " ITS Simulation Geometry Manager");
67     TGeoManager *mgr2 = gGeoManager;
68     //
69     const AliITSVersion_t kv11=(AliITSVersion_t)110;
70     const Char_t *cvsDate="$Date$";
71     const Char_t *cvsRevision="$Revision$";
72     const Int_t kLength=100;
73     Char_t vstrng[kLength];
74     AliITSInitGeometry initgeom(kv11,1);
75     //
76     TGeoMaterial *vacmat = new TGeoMaterial("Vacume",0,0,0);
77     TGeoMedium   *vacmed = new TGeoMedium("Vacume_med",1,vacmat);
78     TGeoVolume *ALIC = mgr2->MakeBox("ALIC",vacmed,1000.,1000.,2000.);
79     mgr2->SetTopVolume(ALIC);
80     TGeoVolume *ITS = mgr2->MakeBox("ITSV",vacmed,990.,990.,1990.);
81     if(initgeom.WriteVersionString(vstrng,kLength,kv11,1,cvsDate,cvsRevision))
82         ITS->SetTitle(vstrng);
83     //TGeoVolumeAssembly *ITSSPD = new TGeoVolumeAssembly("ITSSPD");
84     //ITS->AddNode(ITSSPD,1);
85     ALIC->AddNode(ITS,1);
86     //
87     /*
88     AliITSv11 *its = new AliITSv11(0,3);
89     its->SetDebug(ISetits(0,-1));
90     its->GetSPDGeometry()->SetDebug(ISetits(0,-1));
91     its->GetSupGeometry()->SetDebug(ISetits(0,-1));
92     its->CreateMaterials();
93     its->CreateGeometry();
94     */
95     gspd  = new AliITSv11GeometrySPD(0);
96     gsdd  = new AliITSv11GeometrySDD();
97     gsupp = new AliITSv11GeometrySupport(0);
98     gssd  = new AliITSv11GeometrySSD();
99     //
100     CreateMaterialsITS();
101     gspd->SPDSector(ITS,mgr2);
102     gsupp->SPDCone(ITS,mgr2);
103     gsupp->SetDebug(0);
104     gsupp->SDDCone(ITS,mgr2);
105     gsdd->Layer3(ITS);
106     gsdd->Layer4(ITS);
107     gsdd->ForwardLayer3(ITS);// in Hybrid its in IS02
108     gsdd->ForwardLayer4(ITS);// in Hybrid its in IS02
109     gssd->Layer5(ITS);
110     gssd->Layer6(ITS);
111     gssd->LadderSupportLayer5(ITS);
112     gssd->LadderSupportLayer6(ITS);
113     gssd->EndCapSupportSystemLayer6(ITS);
114     gssd->EndCapSupportSystemLayer5(ITS);
115     gsupp->SSDCone(ITS,mgr2);
116     gsupp->ServicesCableSupport(ITS);
117     //
118     mgr2->CloseGeometry();
119     //
120     geom = new AliITSgeom();
121     initgeom.InitAliITSgeom(geom);
122     geom->WriteNewFile("ITSgeomV11.det");
123     //
124     TControlBar *bar=new TControlBar("vertical","ITS Geometry Display",10,10);
125     bar->AddButton("Set Clipping on","ISetits(2,1)","Clipping on");
126     bar->AddButton("Set Cllipping off","ISetits(2,0)","Clipping off");
127     bar->AddButton("Set axis on","ISetits(3,1)","Show Axis on");
128     bar->AddButton("Set axis off","ISetits(3,0)","Show Axis off");
129     bar->AddButton("Set perspective on","ISetits(4,1)","Perspective on");
130     bar->AddButton("Set perspective off","ISetits(4,0)","Perspective off");
131     bar->AddButton("Set RayTrace on","ISetits(5,1)","Perspective on");
132     bar->AddButton("Set RayTrace off","ISetits(5,0)","Perspective off");
133     bar->AddButton("Set circle/80","ISetits(1,80)","circles ~ by 80 lines");
134     bar->AddButton("Display Geometry","Displayit()","Run Displayit");
135     bar->AddButton("Display SPD Sector Volume","EngineeringSPDSector()",
136                    "Run EngineeringSPDSector");
137     bar->AddButton("Print SPD Sector Volume data xfig","PrintSPDSectorData()",
138                    "Run PrintSPDSectorData");
139     bar->AddButton("Display SPD General Volume","EngineeringSPDCenter()",
140                    "Run EngineeringSPDCenter");
141     bar->AddButton("Display SPD Thermal Shield","EngineeringSPDThS()",
142                    "Run EngineeringSPDThS");
143     bar->AddButton("Display SPD Sector Cross Sections","EngineeringSPDSCS()",
144                    "Run EngineeringSPDSCS");
145     bar->AddButton("Display SDD Layer 3","EngineeringSDDLayer3()",
146                    "Run EngineeringSDDLayer3");
147     bar->AddButton("Display SDD Layer 4","EngineeringSDDLayer4()",
148                    "Run EngineeringSDDLayer4");
149     bar->AddButton("Display SDD Cone","EngineeringSDDCone()",
150                    "Run EngineeringSDDCone");
151     bar->AddButton("Display SDD Central Cylinder","EngineeringSDDCylinder()",
152                    "Run EngineeringSDDCylinder");
153     bar->AddButton("Display SSD Layer 5","EngineeringSSDLayer5()",
154                    "Run EngineeringSSDLayer5");
155     bar->AddButton("Display SSD Layer 6","EngineeringSSDLayer6()",
156                    "Run EngineeringSSDLayer6");
157     bar->AddButton("Display SSD Cone","EngineeringSSDCone()",
158                    "Run EngineeringSSDCone");
159     bar->AddButton("Display SSD Central Cylinder","EngineeringSSDCylinder()",
160                    "Run EngineeringSSDCylinder");
161 //    bar->AddButton("Display SUP RB24 side","EngineeringSupRB24()",
162 //                   "Run EngineeringSupRB24");
163 //    bar->AddButton("Display Cable Trays RB24 side","EngineeringSupTrayRB24()",
164 //                   "Run EngineeringSupTrayRB24");
165 //    bar->AddButton("Display SUP RB26 side","EngineeringSupRB26()",
166 //                   "Run EngineeringSupRB26");
167     bar->AddButton("Save Geometry to File","ExportToFile()",
168                    "Run ExportToFile");
169     bar->AddButton("Quit/Exit",".q","Exit");
170     bar->Show();
171     gROOT->SaveContext();
172          //Displayit();
173 }
174 //----------------------------------------------------------------------
175 void ExportToFile(){
176     // Quirry file name and write geometry to a root file.
177     // Inputs:
178     //    const char* filename output file with the display in it
179     // Outputs:
180     //    none.
181     // Retrurn:
182     //    none.
183     Char_t filename[100];
184
185     printf("Enter File name:");
186     scanf("%s",filename);
187
188     gGeoManager->Export(filename);
189 }
190 //----------------------------------------------------------------------
191 Int_t ISetits(Int_t t,Int_t v){
192     static Int_t itsdebug=1,nsegments=80,cut=0,axis=1,perspective=0,ray=0;
193
194     switch (t) {
195     case 0:
196         if(v<0) return itsdebug;
197         itsdebug = v;
198         break;
199     case 1:
200         if(v<0) return nsegments;
201         nsegments= v;
202         break;
203     case 2:
204         if(v<0) return cut;
205         cut = v;
206         break;
207     case 3:
208         if(v<0) return axis;
209         axis = v;
210         break;
211     case 4:
212         if(v<0) return perspective;
213         perspective = v;
214         break;
215     case 5:
216         if(v<0) return ray;
217         ray = v;
218         break;
219     }// end switch
220     return 0;
221 }
222 //----------------------------------------------------------------------
223 Double_t DSetits(Int_t t,Double_t v){
224     static Double_t phimincut=0.0,phimaxcut=180.0;
225     static Double_t longitude=90.0,latitude=0.0;
226
227     switch (t) {
228     case 0:
229         if(v<0.) return phimincut;
230         phimincut = v;
231         break;
232     case 1:
233         if(v<0.) return phimaxcut;
234         phimaxcut = v;
235         break;
236     case 2:
237         if(v<0.) return longitude;
238         longitude = v;
239         break;
240     case 3:
241         if(v<0.) return latitude;
242         latitude = v;
243         break;
244     case 4:
245         if(v<0.) return latitude;
246         latitude = v;
247         break;
248     }// end switch
249     return 0;
250 }
251 //----------------------------------------------------------------------
252 void Displayit(){
253     // Display AliITSv11 Geometry
254     // Inputs:
255     //    const char* filename output file with the display in it
256     // Outputs:
257     //    none.
258     // Retrurn:
259     //    none.
260     Int_t irr;
261     //
262     TGeoManager *mgr2 = gGeoManager;
263     TGeoVolume *ALIC = mgr2->GetTopVolume();
264     TCanvas *c1;
265     if(!(c1 = (TCanvas*)gROOT->FindObject("C1")))
266         c1 = new TCanvas("C1","ITS Simulation Geometry",900,900);
267     //c1->Divide(2,2);
268     //
269     mgr2->SetNsegments(ISetits(1,-1));
270     //
271     mgr2->SetVisLevel(6);
272     mgr2->SetVisOption(0);
273     //mgr2->CheckOverlaps(0.01);
274     //mgr2->PrintOverlaps();
275     if(ISetits(2,-1)==1){
276         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
277         mgr2->SetClippingShape(clip);
278     } // end if
279     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
280     //
281     c1->cd(1);
282     ALIC->Draw();
283     TPad *p1 = (TPad*)c1->GetPad(1);
284     TView *view1 = p1->GetView();
285     if(view1){
286         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
287         if(irr) cout <<"error="<<irr<<endl;
288         if(ISetits(4,-1)==0) view1->SetParallel();
289         else  view1->SetPerspective();
290         view1->Front();
291         if(ISetits(3,-1)!=0) view1->ShowAxis();
292     } // end if view1
293     if(ISetits(5,-1)==1) ALIC->Raytrace();
294     /*c1->cd(2);
295     ALIC->Draw();
296     TPad *p2 = c1->GetPad(2);
297     TView *view2 = p2->GetView();
298     if(view2){
299         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
300         if(irr) cout <<"error="<<irr<<endl;
301         if(ISetits(4,-1)==0) view2->SetParallel();
302         else  view2->SetPerspective();
303         view2->RotateView(60.,30.);
304         if(ISetits(3,-1)!=0) view2->ShowAxis();
305     } // end if view2
306     if(ISetits(5,-1)==1) ALIC->Raytrace();
307     c1->cd(3);
308     ALIC->Draw();
309     c1->SetPhi(90.0); c1->SetTheta(90.0);
310     TPad *p3 = c1->GetPad(3);
311     TView *view3 = p3->GetView();
312     if(view3){
313         view3->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
314         if(irr) cout <<"error="<<irr<<endl;
315         if(ISetits(4,-1)==0) view3->SetParallel();
316         else  view3->SetPerspective();
317         view3->Top();
318         if(ISetits(3,-1)!=0) view3->ShowAxis();
319     } // end if view3
320     if(ISetits(5,-1)==1) ALIC->Raytrace();
321     c1->cd(4);
322     ALIC->Draw();
323     TPad *p4 = c1->GetPad(4);
324     TView *view4 = p4->GetView();
325     if(view4){
326         view4->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
327         if(irr) cout <<"error="<<irr<<endl;
328         if(ISetits(4,-1)==0) view4->SetParallel();
329         else  view4->SetPerspective();
330         view4->Side();
331         if(ISetits(3,-1)!=0) view4->ShowAxis();
332     } // end if view4
333     if(ISetits(5,-1)==1) ALIC->Raytrace();
334     *///
335 }
336 //----------------------------------------------------------------------
337 void EngineeringSPDSCS(){
338     // Display SPD Carbon Fiber Sector Cross sections A and B
339     // Inputs:
340     //    none.
341     // Outputs:
342     //    none.
343     // Return:
344     //    none.
345     TPolyLine *a0,*a1,*b0,*b1;
346     TPolyMarker *p;
347     TCanvas *cSPDSCS=0;
348     Int_t i;
349     Double_t max=0.0;
350
351     a0 = new TPolyLine();
352     a1 = new TPolyLine();
353     b0 = new TPolyLine();
354     b1 = new TPolyLine();
355     p = new TPolyMarker();
356     a0->SetLineColor(1);
357     a1->SetLineColor(4);
358     b0->SetLineColor(3);
359     b0->SetLineStyle(2); // dashed
360     b1->SetLineColor(6);
361     b1->SetLineStyle(2); // dashed
362     p->SetMarkerColor(2);
363     p->SetMarkerStyle(5);
364     if(gspd==0||Make2DCrossSections(*a0,*a1,*b0,*b1,*p)==kFALSE)return;
365     for(i=0;i<a0->GetN();i++) {
366       if(TMath::Abs(a0->GetX()[i])>max) max = TMath::Abs(a0->GetX()[i]);
367       if(TMath::Abs(a0->GetY()[i])>max) max = TMath::Abs(a0->GetY()[i]);
368     } // end for i
369     for(i=0;i<a1->GetN();i++) {
370       if(TMath::Abs(a1->GetX()[i])>max) max = TMath::Abs(a0->GetX()[i]);
371       if(TMath::Abs(a1->GetY()[i])>max) max = TMath::Abs(a1->GetY()[i]);
372     } // end for i
373     for(i=0;i<b0->GetN();i++) {
374       if(TMath::Abs(b0->GetX()[i])>max) max = TMath::Abs(b0->GetX()[i]);
375       if(TMath::Abs(b0->GetY()[i])>max) max = TMath::Abs(b0->GetY()[i]);
376     } // end for i
377     for(i=0;i<b1->GetN();i++) {
378       if(TMath::Abs(b1->GetX()[i])>max) max = TMath::Abs(b1->GetX()[i]);
379       if(TMath::Abs(b1->GetY()[i])>max) max = TMath::Abs(b1->GetY()[i]);
380     } // end for i
381     max *= 1.05;
382     cSPDSCS = (TCanvas*)gROOT->FindObject("cSPDSCS");
383     if(cSPDSCS==0) delete cSPDSCS;
384     cSPDSCS = new TCanvas("cSPDSCS","SPD Carbon Fiber Sector Cross sections",2);
385     cSPDSCS->Range(-max,-max,max,max);
386     //cSPDSCS->RangeAxis();
387     cSPDSCS->SetFixedAspectRatio(kTRUE);
388     //
389     a0->Draw("");
390     a1->Draw("same");
391     p->Draw("same");
392     b0->Draw("same");
393     b1->Draw("same");
394     cSPDSCS->Update();
395     return;
396 }
397 //----------------------------------------------------------------------
398 void EngineeringSPDSector(){
399     // Display SPD Sector Geometry
400     // Inputs:
401     //    none.
402     // Outputs:
403     //    none.
404     // Retrurn:
405     //    none.
406     Int_t irr;
407     //
408     TGeoManager *mgr2 = gGeoManager;
409     TGeoVolume *ALIC = mgr2->GetTopVolume();
410     TCanvas *c4=0, *c5=0;
411     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
412         c4 = new TCanvas("C4","ITS SPD Layer Geometry Side View",500,500);
413     TGeoVolume *ITS=0,*ITSSPD=0,*SPDLay=0;
414     TGeoNode *node=0;
415     //
416     node = ALIC->FindNode("ITSV_1");
417     ITS = node->GetVolume();
418     node = ITS->FindNode("ITSSPD_1");
419     ITSSPD = node->GetVolume();
420     node = ITSSPD->FindNode("ITSSPDCarbonFiberSectorV_1");
421     if(node==0)Error("EngineeringSPDSector","could not find node %s",
422                      "ITSSPDCarbonFiberSectorV_1");
423     SPDLay = node->GetVolume();
424     if(SPDLay==0)Error("EngineeringSPDSector","could not find volume SPDLay");
425     //
426     mgr2->SetNsegments(ISetits(1,-1));
427     //
428     mgr2->SetVisLevel(6);
429     mgr2->SetVisOption(0);
430     //mgr2->CheckOverlaps(0.01);
431     //mgr2->PrintOverlaps();
432     if(ISetits(2,-1)==1){
433         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
434         mgr2->SetClippingShape(clip);
435     } // end if
436     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
437     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
438     //
439     SPDLay->Draw();
440     TView *view1 = c4->GetView();
441     if(view1){
442         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
443         if(irr) cout <<"error="<<irr<<endl;
444         if(ISetits(4,-1)==0) view1->SetParallel();
445         else  view1->SetPerspective();
446         view1->Front();
447         if(ISetits(3,-1)!=0) view1->ShowAxis();
448     } // end if view1
449     if(ISetits(5,-1)==1) SPDLay->Raytrace();
450     //
451     if(!(c5 = (TCanvas*)gROOT->FindObject("C5")))
452         c5 = new TCanvas("C5","ITS SPD Sector Geometry End View",500,500);
453     SPDLay->Draw();
454     TView *view2 = c5->GetView();
455     if(view2){
456         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
457         if(irr) cout <<"error="<<irr<<endl;
458         if(ISetits(4,-1)==0) view2->SetParallel();
459         else  view2->SetPerspective();
460         view2->Top();
461         if(ISetits(3,-1)!=0) view2->ShowAxis();
462     } // end if view2
463     if(ISetits(5,-1)==1) SPDLay->Raytrace();
464     //
465 }
466 //----------------------------------------------------------------------
467 void PrintSPDSectorData(){
468     // Print SPD Sector Data
469     // Inputs:
470     //    none.
471     // Outputs:
472     //    none.
473     // Retrurn:
474     //    none.
475     Int_t irr,i;
476     //
477     TGeoManager *mgr2 = gGeoManager;
478     TGeoXtru * sA0;
479     TGeoVolume *vA0=0;
480
481     //mgr2->PushPath();
482     //mgr2->cd("ITSSPDCarbonFiberSupportSectorA0_1");
483     vA0 = mgr2->FindVolumeFast("ITSSPDCarbonFiberSupportSectorA0");
484     sA0 = (TGeoXtru*) vA0->GetShape();
485     irr = sA0->GetNvert();
486     Double_t x,y;
487     cout <<endl;
488     cout <<"2 3 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 "<<irr;
489     for(i=0;i<irr;i++){
490         x = sA0->GetX(i)+2.5;
491         y = sA0->GetY(i)+2.5;
492         if(!(i%6)) { cout << endl; cout <<"        ";}
493         cout<<" "<<TMath::Nint(x*450.)<<" "<<TMath::Nint(y*450);
494         //cout<<" "<<x<<" "<<y;
495     } // end for i
496     x = sA0->GetX(0)+2.5;
497     y = sA0->GetY(0)+2.5;
498     if(!(i%6)) { cout << endl; cout <<"        ";}
499     cout<<" "<<TMath::Nint(x*450.)<<" "<<TMath::Nint(y*450);
500     //cout<<" "<<x<<" "<<y;
501     cout << endl;
502     //
503 }
504 //----------------------------------------------------------------------
505 void EngineeringSPDCenter(){
506     // Display SPD Centeral Geometry
507     // Inputs:
508     //    none.
509     // Outputs:
510     //    none.
511     // Retrurn:
512     //    none.
513     Int_t irr;
514     //
515     TGeoManager *mgr2 = gGeoManager;
516     TGeoVolume *ALIC = mgr2->GetTopVolume();
517     TCanvas *c4=0, *c5=0;
518     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
519         c4 = new TCanvas("C4","ITS SPD Layer Geometry Side View",500,500);
520     TGeoVolume *ITS,*ITSSPD,*SPDLay=0;
521     TGeoNode *node;
522     //
523     node = ALIC->FindNode("ITSV_1");
524     ITS = node->GetVolume();
525     node = ITS->FindNode("ITSSPD_1");
526     ITSSPD = node->GetVolume();
527     //
528     mgr2->SetNsegments(ISetits(1,-1));
529     //
530     mgr2->SetVisLevel(6);
531     mgr2->SetVisOption(0);
532     //mgr2->CheckOverlaps(0.01);
533     //mgr2->PrintOverlaps();
534     if(ISetits(2,-1)==1){
535         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
536         mgr2->SetClippingShape(clip);
537     } // end if
538     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
539     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
540     //
541     ITSSPD->Draw();
542     TView *view1 = c4->GetView();
543     if(view1){
544         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
545         if(irr) cout <<"error="<<irr<<endl;
546         if(ISetits(4,-1)==0) view1->SetParallel();
547         else  view1->SetPerspective();
548         view1->Front();
549         if(ISetits(3,-1)!=0) view1->ShowAxis();
550     } // end if view1
551     if(ISetits(5,-1)==1) SPDLay->Raytrace();
552     //
553     if(!(c5 = (TCanvas*)gROOT->FindObject("C5")))
554         c5 = new TCanvas("C5","ITS SPD Centeral Geometry End View",500,500);
555     ITSSPD->Draw();
556     TView *view2 = c5->GetView();
557     if(view2){
558         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
559         if(irr) cout <<"error="<<irr<<endl;
560         if(ISetits(4,-1)==0) view2->SetParallel();
561         else  view2->SetPerspective();
562         view2->Top();
563         if(ISetits(3,-1)!=0) view2->ShowAxis();
564     } // end if view2
565     if(ISetits(5,-1)==1) ITSSPD->Raytrace();
566     //
567 }
568 //----------------------------------------------------------------------
569 void EngineeringSPDThS(){
570     // Display SPD Thermal Shield Geometry
571     // Inputs:
572     //    none.
573     // Outputs:
574     //    none.
575     // Retrurn:
576     //    none.
577     Int_t irr;
578     //
579     TGeoManager *mgr2 = gGeoManager;
580     TGeoVolume *ALIC = mgr2->GetTopVolume();
581     TCanvas *c4;
582     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
583         c4 = new TCanvas("C4","ITS SDD Cylinder Geometry",900,450);
584     c4->Divide(2,1);
585     TGeoVolume *ITS,*SPDThS=0;
586     TGeoNode *node;
587     //
588     node = ALIC->FindNode("ITSV_1");
589     ITS = node->GetVolume();
590     node = ITS->FindNode("ITSspdThermalShield_1");
591     SPDThS = node->GetVolume();
592     //
593     mgr2->SetNsegments(ISetits(1,-1));
594     //
595     mgr2->SetVisLevel(6);
596     mgr2->SetVisOption(0);
597     //mgr2->CheckOverlaps(0.01);
598     //mgr2->PrintOverlaps();
599     if(ISetits(2,-1)==1){
600         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
601         mgr2->SetClippingShape(clip);
602     } // end if
603     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
604     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
605     //
606     c4->cd(1);
607     SPDThS->Draw();
608     TPad *p1 = (TPad*)c4->GetPad(1);
609     TView *view1 = p1->GetView();
610     if(view1){
611         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
612         if(irr) cout <<"error="<<irr<<endl;
613         if(ISetits(4,-1)==0) view1->SetParallel();
614         else  view1->SetPerspective();
615         view1->Front();
616         if(ISetits(3,-1)!=0) view1->ShowAxis();
617     } // end if view1
618     if(ISetits(5,-1)==1) SPDThS->Raytrace();
619     //
620     c4->cd(2);
621     SPDThS->Draw();
622     TPad *p2 = (TPad*)c4->GetPad(2);
623     TView *view2 = p2->GetView();
624     if(view2){
625         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
626         if(irr) cout <<"error="<<irr<<endl;
627         if(ISetits(4,-1)==0) view2->SetParallel();
628         else  view2->SetPerspective();
629         view2->Top();
630         if(ISetits(3,-1)!=0) view2->ShowAxis();
631     } // end if view2
632     if(ISetits(5,-1)==1) SPDThS->Raytrace();
633     //
634 }
635 //----------------------------------------------------------------------
636 void EngineeringSDDLayer3(){
637     // Display SDD Layer 3 Geometry
638     // Inputs:
639     //    none.
640     // Outputs:
641     //    none.
642     // Retrurn:
643     //    none.
644     Int_t irr;
645     //
646     TGeoManager *mgr2 = gGeoManager;
647     TGeoVolume *ALIC = mgr2->GetTopVolume();
648     TCanvas *c4=0, *c5=0;
649     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
650         c4 = new TCanvas("C4","ITS SDD Layer 3 Geometry Side View",500,500);
651     TGeoVolume *ITS,*SDDLay3=0;
652     TGeoNode *node;
653     //
654     node = ALIC->FindNode("ITSV_1");
655     ITS = node->GetVolume();
656     node = ITS->FindNode("ITSsddLayer3_1");
657     SDDLay3 = node->GetVolume();
658     //
659     mgr2->SetNsegments(ISetits(1,-1));
660     //
661     mgr2->SetVisLevel(6);
662     mgr2->SetVisOption(0);
663     //mgr2->CheckOverlaps(0.01);
664     //mgr2->PrintOverlaps();
665     if(ISetits(2,-1)==1){
666         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
667         mgr2->SetClippingShape(clip);
668     } // end if
669     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
670     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
671     //
672     SDDLay3->Draw();
673     TView *view1 = c4->GetView();
674     if(view1){
675         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
676         if(irr) cout <<"error="<<irr<<endl;
677         if(ISetits(4,-1)==0) view1->SetParallel();
678         else  view1->SetPerspective();
679         view1->Front();
680         if(ISetits(3,-1)!=0) view1->ShowAxis();
681     } // end if view1
682     if(ISetits(5,-1)==1) SDDLay3->Raytrace();
683     //
684     if(!(c5 = (TCanvas*)gROOT->FindObject("C5")))
685         c5 = new TCanvas("C5","ITS SDD Layer 3 Geometry End View",500,500);
686     SDDLay3->Draw();
687     TView *view2 = c5->GetView();
688     if(view2){
689         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
690         if(irr) cout <<"error="<<irr<<endl;
691         if(ISetits(4,-1)==0) view2->SetParallel();
692         else  view2->SetPerspective();
693         view2->Top();
694         if(ISetits(3,-1)!=0) view2->ShowAxis();
695     } // end if view2
696     if(ISetits(5,-1)==1) SDDLay3->Raytrace();
697     //
698 }
699 //----------------------------------------------------------------------
700 void EngineeringSDDLayer4(){
701     // Display SDD Layer 4 Geometry
702     // Inputs:
703     //    none.
704     // Outputs:
705     //    none.
706     // Retrurn:
707     //    none.
708     Int_t irr;
709     //
710     TGeoManager *mgr2 = gGeoManager;
711     TGeoVolume *ALIC = mgr2->GetTopVolume();
712     TCanvas *c4=0, *c5=0;
713     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
714         c4 = new TCanvas("C4","ITS SDD Layer 4 Geometry Side View",500,500);
715     TGeoVolume *ITS,*SDDLay4=0;
716     TGeoNode *node;
717     //
718     node = ALIC->FindNode("ITSV_1");
719     ITS = node->GetVolume();
720     node = ITS->FindNode("ITSsddLayer4_1");
721     SDDLay4 = node->GetVolume();
722     //
723     mgr2->SetNsegments(ISetits(1,-1));
724     //
725     mgr2->SetVisLevel(6);
726     mgr2->SetVisOption(0);
727     //mgr2->CheckOverlaps(0.01);
728     //mgr2->PrintOverlaps();
729     if(ISetits(2,-1)==1){
730         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
731         mgr2->SetClippingShape(clip);
732     } // end if
733     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
734     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
735     //
736     SDDLay4->Draw();
737     TView *view1 = c4->GetView();
738     if(view1){
739         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
740         if(irr) cout <<"error="<<irr<<endl;
741         if(ISetits(4,-1)==0) view1->SetParallel();
742         else  view1->SetPerspective();
743         view1->Front();
744         if(ISetits(3,-1)!=0) view1->ShowAxis();
745     } // end if view1
746     if(ISetits(5,-1)==1) SDDLay4->Raytrace();
747     //
748     if(!(c5 = (TCanvas*)gROOT->FindObject("C5")))
749         c5 = new TCanvas("C5","ITS SDD Layer 4 Geometry End View",500,500);
750     SDDLay4->Draw();
751     TView *view2 = c5->GetView();
752     if(view2){
753         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
754         if(irr) cout <<"error="<<irr<<endl;
755         if(ISetits(4,-1)==0) view2->SetParallel();
756         else  view2->SetPerspective();
757         view2->Top();
758         if(ISetits(3,-1)!=0) view2->ShowAxis();
759     } // end if view2
760     if(ISetits(5,-1)==1) SDDLay4->Raytrace();
761     //
762 }
763 //----------------------------------------------------------------------
764 void EngineeringSDDCone(){
765     // Display SDD Cone Geometry
766     // Inputs:
767     //    none.
768     // Outputs:
769     //    none.
770     // Retrurn:
771     //    none.
772     Int_t irr;
773     //
774     TGeoManager *mgr2 = gGeoManager;
775     TGeoVolume *ALIC = mgr2->GetTopVolume();
776     TCanvas *c2=0;
777     if(!(c2 = (TCanvas*)gROOT->FindObject("C2")))
778         c2 = new TCanvas("C2","ITS SDD Cone Geometry",900,450);
779     c2->Divide(2,1);
780     TGeoVolume *ITS,*SDD=0;
781     TGeoNode *node;
782     //
783     node = ALIC->FindNode("ITSV_1");
784     ITS = node->GetVolume();
785     node = ITS->FindNode("SDDCarbonFiberCone_1");
786     SDD = node->GetVolume();
787     //
788     mgr2->SetNsegments(ISetits(1,-1));
789     //
790     mgr2->SetVisLevel(6);
791     mgr2->SetVisOption(0);
792     //mgr2->CheckOverlaps(0.01);
793     //mgr2->PrintOverlaps();
794     if(ISetits(2,-1)==1){
795         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
796         mgr2->SetClippingShape(clip);
797     } // end if
798     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
799     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
800     //
801     c2->cd(1);
802     SDD->Draw();
803     TPad *p1 = (TPad*)c2->GetPad(1);
804     TView *view1 = p1->GetView();
805     if(view1){
806         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
807         if(irr) cout <<"error="<<irr<<endl;
808         if(ISetits(4,-1)==0) view1->SetParallel();
809         else  view1->SetPerspective();
810         view1->Front();
811         if(ISetits(3,-1)!=0) view1->ShowAxis();
812     } // end if view1
813     if(ISetits(5,-1)==1) SDD->Raytrace();
814     //
815     c2->cd(2);
816     SDD->Draw();
817     TPad *p2 = (TPad*)c2->GetPad(2);
818     TView *view2 = p2->GetView();
819     if(view2){
820         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
821         if(irr) cout <<"error="<<irr<<endl;
822         if(ISetits(4,-1)==0) view2->SetParallel();
823         else  view2->SetPerspective();
824         view2->Top();
825         if(ISetits(3,-1)!=0) view2->ShowAxis();
826     } // end if view1
827     if(ISetits(5,-1)==1) SDD->Raytrace();
828     //
829 }
830 //----------------------------------------------------------------------
831 void EngineeringSDDCylinder(){
832     // Display SDD Cylinder Geometry
833     // Inputs:
834     //    none.
835     // Outputs:
836     //    none.
837     // Retrurn:
838     //    none.
839     Int_t irr;
840     //
841     TGeoManager *mgr2 = gGeoManager;
842     TGeoVolume *ALIC = mgr2->GetTopVolume();
843     TCanvas *c3=0;
844     if(!(c3 = (TCanvas*)gROOT->FindObject("C3")))
845         c3 = new TCanvas("C3","ITS SDD Cylinder Geometry",900,450);
846     c3->Divide(2,1);
847     TGeoVolume *ITS,*SDD=0;
848     TGeoNode *node;
849 //    TArrow *arrow=new TArrow();
850     //
851     node = ALIC->FindNode("ITSV_1");
852     ITS = node->GetVolume();
853     node = ITS->FindNode("SDDCarbonFiberCylinder_1");
854     SDD = node->GetVolume();
855 //    Double_t Rmin = ((TGeoTube*)(SDD->GetShape()))->GetRmin();
856 //    Double_t Rmax = ((TGeoTube*)(SDD->GetShape()))->GetRmax();
857 //    Double_t Dz   = ((TGeoTube*)(SDD->GetShape()))->GetDz();
858     //
859     mgr2->SetNsegments(ISetits(1,-1));
860     //
861     mgr2->SetVisLevel(6);
862     mgr2->SetVisOption(0);
863     //mgr2->CheckOverlaps(0.01);
864     //mgr2->PrintOverlaps();
865     if(ISetits(2,-1)==1){
866         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
867         mgr2->SetClippingShape(clip);
868     } // end if
869     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
870     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
871     //
872     c3->cd(1);
873     SDD->Draw();
874     TPad *p1 = (TPad*)c3->GetPad(1);
875     TView *view1 = p1->GetView();
876     if(view1){
877         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
878         if(irr) cout <<"error="<<irr<<endl;
879         if(ISetits(4,-1)==0) view1->SetParallel();
880         else  view1->SetPerspective();
881         view1->Front();
882         if(ISetits(3,-1)!=0) view1->ShowAxis();
883     } // end if view1
884     if(ISetits(5,-1)==1) SDD->Raytrace();
885     //arrow->DrawArrow(1.01*Rmax,-Dz,1.01*Rmax,+Dz);
886     //
887     c3->cd(2);
888     SDD->Draw();
889     TPad *p2 = (TPad*)c3->GetPad(2);
890     TView *view2 = p2->GetView();
891     if(view2){
892         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
893         if(irr) cout <<"error="<<irr<<endl;
894         if(ISetits(4,-1)==0) view2->SetParallel();
895         else  view2->SetPerspective();
896         view2->Top();
897         if(ISetits(3,-1)!=0) view2->ShowAxis();
898     } // end if view2
899     if(ISetits(5,-1)==1) SDD->Raytrace();
900     //arrow->DrawArrow(Rmax,0.0,Rmax,0.0);
901     //Double_t s = TMath::Sin(0.7),c = TMath::Cos(0.7);
902     //arrow->DrawArrow(-Rmin*c,-Rmin*s,Rmin*c,Rmin*s);
903     //
904 }
905 //----------------------------------------------------------------------
906 void EngineeringSSDLayer5(){
907     // Display SSD Layer 5 Geometry
908     // Inputs:
909     //    none.
910     // Outputs:
911     //    none.
912     // Retrurn:
913     //    none.
914     Int_t irr;
915     //
916     TGeoManager *mgr2 = gGeoManager;
917     TGeoVolume *ALIC = mgr2->GetTopVolume();
918     TCanvas *c4=0, *c5=0;
919     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
920         c4 = new TCanvas("C4","ITS SDD Layer 5 Geometry Side View",500,500);
921     TGeoVolume *ITS,*SDDLay5=0;
922     TGeoNode *node;
923     //
924     node = ALIC->FindNode("ITSV_1");
925     ITS = node->GetVolume();
926     node = ITS->FindNode("ITSssdLayer5_1");
927     SDDLay5 = node->GetVolume();
928     //
929     mgr2->SetNsegments(ISetits(1,-1));
930     //
931     mgr2->SetVisLevel(6);
932     mgr2->SetVisOption(0);
933     //mgr2->CheckOverlaps(0.01);
934     //mgr2->PrintOverlaps();
935     if(ISetits(2,-1)==1){
936         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
937         mgr2->SetClippingShape(clip);
938     } // end if
939     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
940     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
941     //
942     SDDLay5->Draw();
943     TView *view1 = c4->GetView();
944     if(view1){
945         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
946         if(irr) cout <<"error="<<irr<<endl;
947         if(ISetits(4,-1)==0) view1->SetParallel();
948         else  view1->SetPerspective();
949         view1->Front();
950         if(ISetits(3,-1)!=0) view1->ShowAxis();
951     } // end if view1
952     if(ISetits(5,-1)==1) SDDLay5->Raytrace();
953     //
954     if(!(c5 = (TCanvas*)gROOT->FindObject("C5")))
955         c5 = new TCanvas("C5","ITS SDD Layer 5 Geometry End View",500,500);
956     SDDLay5->Draw();
957     TView *view2 = c5->GetView();
958     if(view2){
959         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
960         if(irr) cout <<"error="<<irr<<endl;
961         if(ISetits(4,-1)==0) view2->SetParallel();
962         else  view2->SetPerspective();
963         view2->Top();
964         if(ISetits(3,-1)!=0) view2->ShowAxis();
965     } // end if view2
966     if(ISetits(5,-1)==1) SDDLay5->Raytrace();
967     //
968 }
969 //----------------------------------------------------------------------
970 void EngineeringSSDLayer6(){
971     // Display SSD Layer 6 Geometry
972     // Inputs:
973     //    none.
974     // Outputs:
975     //    none.
976     // Retrurn:
977     //    none.
978     Int_t irr;
979     //
980     TGeoManager *mgr2 = gGeoManager;
981     TGeoVolume *ALIC = mgr2->GetTopVolume();
982     TCanvas *c4=0, *c5=0;
983     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
984         c4 = new TCanvas("C4","ITS SDD Layer 6 Geometry Side View",500,500);
985     TGeoVolume *ITS,*SDDLay6=0;
986     TGeoNode *node;
987     //
988     node = ALIC->FindNode("ITSV_1");
989     ITS = node->GetVolume();
990     node = ITS->FindNode("ITSssdLayer6_1");
991     SDDLay6 = node->GetVolume();
992     //
993     mgr2->SetNsegments(ISetits(1,-1));
994     //
995     mgr2->SetVisLevel(6);
996     mgr2->SetVisOption(0);
997     //mgr2->CheckOverlaps(0.01);
998     //mgr2->PrintOverlaps();
999     if(ISetits(2,-1)==1){
1000         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
1001         mgr2->SetClippingShape(clip);
1002     } // end if
1003     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1004     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1005     //
1006     SDDLay6->Draw();
1007     TView *view1 = c4->GetView();
1008     if(view1){
1009         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1010         if(irr) cout <<"error="<<irr<<endl;
1011         if(ISetits(4,-1)==0) view1->SetParallel();
1012         else  view1->SetPerspective();
1013         view1->Front();
1014         if(ISetits(3,-1)!=0) view1->ShowAxis();
1015     } // end if view1
1016     if(ISetits(5,-1)==1) SDDLay6->Raytrace();
1017     //
1018     if(!(c5 = (TCanvas*)gROOT->FindObject("C5")))
1019         c5 = new TCanvas("C5","ITS SDD Layer 6 Geometry End View",500,500);
1020     SDDLay6->Draw();
1021     TView *view2 = c5->GetView();
1022     if(view2){
1023         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1024         if(irr) cout <<"error="<<irr<<endl;
1025         if(ISetits(4,-1)==0) view2->SetParallel();
1026         else  view2->SetPerspective();
1027         view2->Top();
1028         if(ISetits(3,-1)!=0) view2->ShowAxis();
1029     } // end if view2
1030     if(ISetits(5,-1)==1) SDDLay6->Raytrace();
1031     //
1032 }
1033 //----------------------------------------------------------------------
1034 void EngineeringSSDCone(){
1035     // Display SSD Cone Geometry
1036     // Inputs:
1037     //    none.
1038     // Outputs:
1039     //    none.
1040     // Retrurn:
1041     //    none.
1042     Int_t irr;
1043     //
1044     TGeoManager *mgr2 = gGeoManager;
1045     TGeoVolume *ALIC = mgr2->GetTopVolume();
1046     TCanvas *c2=0;
1047     if(!(c2 = (TCanvas*)gROOT->FindObject("C2")))
1048         c2 = new TCanvas("C2","ITS SSD Cone Geometry",900,450);
1049     c2->Divide(2,1);
1050     TGeoVolume *ITS,*SSD=0;
1051     TGeoNode *node;
1052     //
1053     node = ALIC->FindNode("ITSV_1");
1054     ITS = node->GetVolume();
1055     node = ITS->FindNode("ITSssdCone_1");
1056     SSD = node->GetVolume();
1057     //
1058     mgr2->SetNsegments(ISetits(1,-1));
1059     //
1060     mgr2->SetVisLevel(6);
1061     mgr2->SetVisOption(0);
1062     //mgr2->CheckOverlaps(0.01);
1063     //mgr2->PrintOverlaps();
1064     if(ISetits(2,-1)==1){
1065         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
1066         mgr2->SetClippingShape(clip);
1067     } // end if
1068     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1069     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1070     //
1071     c2->cd(1);
1072     SSD->Draw();
1073     TPad *p1 = (TPad*)c2->GetPad(1);
1074     TView *view1 = p1->GetView();
1075     if(view1){
1076         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1077         if(irr) cout <<"error="<<irr<<endl;
1078         if(ISetits(4,-1)==0) view1->SetParallel();
1079         else  view1->SetPerspective();
1080         view1->Top();
1081         if(ISetits(3,-1)!=0) view1->ShowAxis();
1082     } // end if view1
1083     if(ISetits(5,-1)==1) SSD->Raytrace();
1084     //
1085     c2->cd(2);
1086     SSD->Draw();
1087     TPad *p2 = (TPad*)c2->GetPad(2);
1088     TView *view2 = p2->GetView();
1089     if(view2){
1090         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1091         if(irr) cout <<"error="<<irr<<endl;
1092         if(ISetits(4,-1)==0) view2->SetParallel();
1093         else  view2->SetPerspective();
1094         view2->Front();
1095         if(ISetits(3,-1)!=0) view2->ShowAxis();
1096     } // end if view1
1097     if(ISetits(5,-1)==1) SSD->Raytrace();
1098     //
1099 }
1100 //----------------------------------------------------------------------
1101 void EngineeringSSDCylinder(){
1102     // Display SSD Cylinder Geometry
1103     // Inputs:
1104     //    none.
1105     // Outputs:
1106     //    none.
1107     // Retrurn:
1108     //    none.
1109     Int_t irr;
1110     //
1111     TGeoManager *mgr2 = gGeoManager;
1112     TGeoVolume *ALIC = mgr2->GetTopVolume();
1113     TCanvas *c3=0;
1114     if(!(c3 = (TCanvas*)gROOT->FindObject("C3")))
1115         c3 = new TCanvas("C3","ITS SSD Cylinder Geometry",900,450);
1116     c3->Divide(2,1);
1117     TGeoVolume *ITS,*SSD=0;
1118     TGeoNode *node;
1119 //    TArrow *arrow=new TArrow();
1120     //
1121     node = ALIC->FindNode("ITSV_1");
1122     ITS = node->GetVolume();
1123     node = ITS->FindNode("SSDexternalcylinder_1");
1124     SSD = node->GetVolume();
1125     //Double_t Rmin = ((TGeoPcon*)(SSD->GetShape()))->GetRmin();
1126     //Double_t Rmax = ((TGeoPcon*)(SSD->GetShape()))->GetRmax();
1127     //Double_t Dz   = ((TGeoPcon*)(SSD->GetShape()))->GetDz();
1128     //
1129     mgr2->SetNsegments(ISetits(1,-1));
1130     //
1131     mgr2->SetVisLevel(6);
1132     mgr2->SetVisOption(0);
1133     //mgr2->CheckOverlaps(0.01);
1134     //mgr2->PrintOverlaps();
1135     if(ISetits(2,-1)==1){
1136         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
1137         mgr2->SetClippingShape(clip);
1138     } // end if
1139     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1140     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1141     //
1142     c3->cd(1);
1143     SSD->Draw();
1144     TPad *p1 = (TPad*)c3->GetPad(1);
1145     TView *view1 = p1->GetView();
1146     if(view1){
1147         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1148         if(irr) cout <<"error="<<irr<<endl;
1149         if(ISetits(4,-1)==0) view1->SetParallel();
1150         else  view1->SetPerspective();
1151         view1->Front();
1152         if(ISetits(3,-1)!=0) view1->ShowAxis();
1153     } // end if view1
1154     if(ISetits(5,-1)==1) SSD->Raytrace();
1155     //arrow->DrawArrow(1.01*Rmax,-Dz,1.01*Rmax,+Dz);
1156     //
1157     c3->cd(2);
1158     SSD->Draw();
1159     TPad *p2 = (TPad*)c3->GetPad(2);
1160     TView *view2 = p2->GetView();
1161     if(view2){
1162         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1163         if(irr) cout <<"error="<<irr<<endl;
1164         if(ISetits(4,-1)==0) view2->SetParallel();
1165         else  view2->SetPerspective();
1166         view2->Top();
1167         if(ISetits(3,-1)!=0) view2->ShowAxis();
1168     } // end if view2
1169     if(ISetits(5,-1)==1) SSD->Raytrace();
1170     //arrow->DrawArrow(Rmax,0.0,Rmax,0.0);
1171     //Double_t s = TMath::Sin(0.7),c = TMath::Cos(0.7);
1172     //arrow->DrawArrow(-Rmin*c,-Rmin*s,Rmin*c,Rmin*s);
1173     //
1174 }
1175 //----------------------------------------------------------------------
1176 void EngineeringSupRB24(){
1177     // Display  RB 24 side cable tray support structure Geometry
1178     // Inputs:
1179     //    none.
1180     // Outputs:
1181     //    none.
1182     // Retrurn:
1183     //    none.
1184     Int_t irr;
1185     //
1186     TGeoManager *mgr2 = gGeoManager;
1187     TGeoVolume *ALIC = mgr2->GetTopVolume();
1188     TCanvas *c4=0;
1189     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
1190         c4 = new TCanvas("C4","ITS SDD Cylinder Geometry",900,450);
1191     c4->Divide(2,1);
1192     TGeoVolume *ITS,*SUPRB24=0;
1193     TGeoNode *node;
1194     //
1195     node = ALIC->FindNode("ITSV_1");
1196     ITS = node->GetVolume();
1197     node = ITS->FindNode("ITSsupFrameM24_1");
1198     SUPRB24 = node->GetVolume();
1199     //
1200     mgr2->SetNsegments(ISetits(1,-1));
1201     //
1202     mgr2->SetVisLevel(6);
1203     mgr2->SetVisOption(0);
1204     //mgr2->CheckOverlaps(0.01);
1205     //mgr2->PrintOverlaps();
1206     if(ISetits(2,-1)==1){
1207         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
1208         mgr2->SetClippingShape(clip);
1209     } // end if
1210     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1211     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1212     //
1213     c4->cd(1);
1214     SUPRB24->Draw();
1215     TPad *p1 = (TPad*)c4->GetPad(1);
1216     TView *view1 = p1->GetView();
1217     if(view1){
1218         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1219         if(irr) cout <<"error="<<irr<<endl;
1220         if(ISetits(4,-1)==0) view1->SetParallel();
1221         else  view1->SetPerspective();
1222         view1->Front();
1223         if(ISetits(3,-1)!=0) view1->ShowAxis();
1224     } // end if view1
1225     if(ISetits(5,-1)==1) SUPRB24->Raytrace();
1226     //
1227     c4->cd(2);
1228     SUPRB24->Draw();
1229     TPad *p2 = (TPad*)c4->GetPad(2);
1230     TView *view2 = p2->GetView();
1231     if(view2){
1232         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1233         if(irr) cout <<"error="<<irr<<endl;
1234         if(ISetits(4,-1)==0) view2->SetParallel();
1235         else  view2->SetPerspective();
1236         view2->Top();
1237         if(ISetits(3,-1)!=0) view2->ShowAxis();
1238     } // end if view2
1239     if(ISetits(5,-1)==1) SUPRB24->Raytrace();
1240     //
1241 }
1242 //----------------------------------------------------------------------
1243 void EngineeringSupTrayRB24(){
1244     // Display  RB 24 side cable tray support structure Geometry
1245     // Inputs:
1246     //    none.
1247     // Outputs:
1248     //    none.
1249     // Retrurn:
1250     //    none.
1251     Int_t irr;
1252     //
1253     TGeoManager *mgr2 = gGeoManager;
1254     TGeoVolume *ALIC = mgr2->GetTopVolume();
1255     TCanvas *c4=0,*c5=0;
1256     //if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
1257         c4 = new TCanvas("C4","ITS RB24 Cable Trays and Patch Pannels",500,500);
1258     //c4->Divide(2,1);
1259     TGeoVolume *ITS,*SUPRB24=0;
1260     TGeoNode *node;
1261     //
1262     node = ALIC->FindNode("ITSV_1");
1263     ITS = node->GetVolume();
1264     node = ITS->FindNode("ITSsupCableTrayMotherMT24_1");
1265     SUPRB24 = node->GetVolume();
1266     //
1267     mgr2->SetNsegments(ISetits(1,-1));
1268     //
1269     mgr2->SetVisLevel(6);
1270     mgr2->SetVisOption(0);
1271     //mgr2->CheckOverlaps(0.01);
1272     //mgr2->PrintOverlaps();
1273     if(ISetits(2,-1)==1){
1274         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
1275         mgr2->SetClippingShape(clip);
1276     } // end if
1277     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1278     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1279     //
1280     c4->cd(1);
1281     SUPRB24->Draw();
1282     //TPad *p1 = c4->GetPad(1);
1283     //TView *view1 = p1->GetView();
1284     TView *view1 = c4->GetView();
1285     if(view1){
1286         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1287         if(irr) cout <<"error="<<irr<<endl;
1288         if(ISetits(4,-1)==0) view1->SetParallel();
1289         else  view1->SetPerspective();
1290         view1->Front();
1291         if(ISetits(3,-1)!=0) view1->ShowAxis();
1292     } // end if view1
1293     if(ISetits(5,-1)==1) SUPRB24->Raytrace();
1294     //
1295     //c4->cd(2);
1296         c5 = new TCanvas("C5","ITS RB24 Cable Trays and Patch Pannels",500,500);
1297     c5->cd(1);
1298     SUPRB24->Draw();
1299     //TPad *p2 = c5->GetPad(1);
1300     //TView *view2 = p2->GetView();
1301     TView *view2 = c5->GetView();
1302     if(view2){
1303         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1304         if(irr) cout <<"error="<<irr<<endl;
1305         if(ISetits(4,-1)==0) view2->SetParallel();
1306         else  view2->SetPerspective();
1307         view2->Top();
1308         if(ISetits(3,-1)!=0) view2->ShowAxis();
1309     } // end if view2
1310     if(ISetits(5,-1)==1) SUPRB24->Raytrace();
1311     //
1312 }
1313 //----------------------------------------------------------------------
1314 void EngineeringSupRB26(){
1315     // Display RB 26 side cable tray support structure
1316     // Inputs:
1317     //    none.
1318     // Outputs:
1319     //    none.
1320     // Retrurn:
1321     //    none.
1322     Int_t irr;
1323     //
1324     TGeoManager *mgr2 = gGeoManager;
1325     TGeoVolume *ALIC = mgr2->GetTopVolume();
1326     TCanvas *c5=0;
1327     if(!(c5 = (TCanvas*)gROOT->FindObject("C5")))
1328         c5 = new TCanvas("C5","ITS SDD Cylinder Geometry",900,450);
1329     c5->Divide(2,1);
1330     TGeoVolume *ITS,*SUPRB26=0;
1331     TGeoNode *node;
1332     //
1333     node = ALIC->FindNode("ITSV_1");
1334     ITS = node->GetVolume();
1335     node = ITS->FindNode("ITSsupFrameM26_1");
1336     SUPRB26 = node->GetVolume();
1337     //
1338     mgr2->SetNsegments(ISetits(1,-1));
1339     //
1340     mgr2->SetVisLevel(6);
1341     mgr2->SetVisOption(0);
1342     //mgr2->CheckOverlaps(0.01);
1343     //mgr2->PrintOverlaps();
1344     if(ISetits(2,-1)==1){
1345         TGeoShape *clip = new TGeoTubeSeg(0, 1000, 2000, 45, 90);
1346         mgr2->SetClippingShape(clip);
1347     } // end if
1348     mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1349     if(ISetits(2,-1)!=0) mgr2->SetPhiRange(DSetits(1,-1.),DSetits(0,-1.));
1350     //
1351     c5->cd(1);
1352     SUPRB26->Draw();
1353     TPad *p1 = (TPad*)c5->GetPad(1);
1354     TView *view1 = p1->GetView();
1355     if(view1){
1356         view1->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1357         if(irr) cout <<"error="<<irr<<endl;
1358         if(ISetits(4,-1)==0) view1->SetParallel();
1359         else  view1->SetPerspective();
1360         view1->Front();
1361         if(ISetits(3,-1)!=0) view1->ShowAxis();
1362     } // end if view1
1363     if(ISetits(5,-1)==1) SUPRB26->Raytrace();
1364     //
1365     c5->cd(2);
1366     SUPRB26->Draw();
1367     TPad *p2 = (TPad*)c5->GetPad(2);
1368     TView *view2 = p2->GetView();
1369     if(view2){
1370         view2->SetView(DSetits(2,-1.),DSetits(3,-1.),DSetits(4,-1.),irr);
1371         if(irr) cout <<"error="<<irr<<endl;
1372         if(ISetits(4,-1)==0) view2->SetParallel();
1373         else  view2->SetPerspective();
1374         view2->Top();
1375         if(ISetits(3,-1)!=0) view2->ShowAxis();
1376     } // end if view2
1377     if(ISetits(5,-1)==1) SUPRB26->Raytrace();
1378     //
1379 }
1380
1381 // Local functions to replace "regular" ones not available
1382 // in the environment where the macro runs
1383
1384 //______________________________________________________________________
1385 void CreateMaterialsITS(){
1386     // Create ITS materials
1387     //     This function defines the default materials used in the Geant
1388     // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
1389     // AliITSv11Hybrid.
1390     // In general it is automatically replaced by
1391     // the CreateMaterials routine defined in AliITSv?. Should the function
1392     // CreateMaterials not exist for the geometry version you are using this
1393     // one is used. See the definition found in AliITSv5 or the other routine
1394     // for a complete definition.
1395     // Inputs:
1396     //   none.
1397     // Outputs:
1398     //   none.
1399     // Return:
1400     //   none.
1401
1402     Bool_t fByThick=kTRUE;    // Flag to use services materials by thickness
1403                               // ture, or mass false.
1404
1405 //    Int_t   ifield = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
1406 //    Float_t fieldm = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
1407     Int_t   ifield = 2;
1408     Float_t fieldm = 10.;
1409
1410     Float_t tmaxfd = 0.1; // 1.0; // Degree
1411     Float_t stemax = 1.0; // cm
1412     Float_t deemax = 0.1; // 30.0; // Fraction of particle's energy 0<deemax<=1
1413     Float_t epsil  = 1.0E-4; // 1.0; // cm
1414     Float_t stmin  = 0.0; // cm "Default value used"
1415
1416     Float_t tmaxfdSi = 0.1; // .10000E+01; // Degree
1417     Float_t stemaxSi = 0.0075; //  .10000E+01; // cm
1418     Float_t deemaxSi = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
1419     Float_t epsilSi  = 1.0E-4;// .10000E+01;
1420     Float_t stminSi  = 0.0; // cm "Default value used"
1421
1422     Float_t tmaxfdAir = 0.1; // .10000E+01; // Degree
1423     Float_t stemaxAir = .10000E+01; // cm
1424     Float_t deemaxAir = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
1425     Float_t epsilAir  = 1.0E-4;// .10000E+01;
1426     Float_t stminAir  = 0.0; // cm "Default value used"
1427
1428     Float_t tmaxfdServ = 1.0; // 10.0; // Degree
1429     Float_t stemaxServ = 1.0; // 0.01; // cm
1430     Float_t deemaxServ = 0.5; // 0.1; // Fraction of particle's energy 0<deemax<=1
1431     Float_t epsilServ  = 1.0E-3; // 0.003; // cm
1432     Float_t stminServ  = 0.0; //0.003; // cm "Default value used"
1433
1434     // Freon PerFluorobuthane C4F10 see 
1435     // http://st-support-cooling-electronics.web.cern.ch/
1436     //        st-support-cooling-electronics/default.htm
1437     Float_t afre[2]  = { 12.011,18.9984032 };
1438     Float_t zfre[2]  = { 6., 9. };
1439     Float_t wfre[2]  = { 4.,10. };
1440     Float_t densfre  = 1.52;
1441
1442
1443     //CM55J
1444
1445     Float_t aCM55J[4]={12.0107,14.0067,15.9994,1.00794};
1446     Float_t zCM55J[4]={6.,7.,8.,1.};
1447     Float_t wCM55J[4]={0.908508078,0.010387573,0.055957585,0.025146765};
1448     Float_t dCM55J = 1.8;
1449
1450     //ALCM55J
1451
1452     Float_t aALCM55J[5]={12.0107,14.0067,15.9994,1.00794,26.981538};
1453     Float_t zALCM55J[5]={6.,7.,8.,1.,13.};
1454     Float_t wALCM55J[5]={0.817657902,0.0093488157,0.0503618265,0.0226320885,0.1};
1455     Float_t dALCM55J = 1.9866;
1456
1457     //Si Chips
1458
1459     Float_t aSICHIP[6]={12.0107,14.0067,15.9994,1.00794,28.0855,107.8682};
1460     Float_t zSICHIP[6]={6.,7.,8.,1.,14., 47.};
1461     Float_t wSICHIP[6]={0.039730642,0.001396798,0.01169634,0.004367771,0.844665,0.09814344903};
1462     Float_t dSICHIP = 2.36436;
1463
1464     //Inox
1465     
1466     Float_t aINOX[9]={12.0107,54.9380, 28.0855,30.9738,32.066,58.6928,51.9961,95.94,55.845};
1467     Float_t zINOX[9]={6.,25.,14.,15.,16., 28.,24.,42.,26.};
1468     Float_t wINOX[9]={0.0003,0.02,0.01,0.00045,0.0003,0.12,0.17,0.025,0.654};
1469     Float_t dINOX = 8.03;
1470
1471     //SDD HV microcable
1472
1473     Float_t aHVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
1474     Float_t zHVm[5]={6.,1.,7.,8.,13.};
1475     Float_t wHVm[5]={0.520088819984,0.01983871336,0.0551367996,0.157399667056, 0.247536};
1476     Float_t dHVm = 1.6087;
1477
1478     //SDD LV+signal cable
1479
1480     Float_t aLVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
1481     Float_t zLVm[5]={6.,1.,7.,8.,13.};
1482     Float_t wLVm[5]={0.21722436468,0.0082859922,0.023028867,0.06574077612, 0.68572};
1483     Float_t dLVm = 2.1035;
1484
1485     //SDD hybrid microcab
1486
1487     Float_t aHLVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
1488     Float_t zHLVm[5]={6.,1.,7.,8.,13.};
1489     Float_t wHLVm[5]={0.24281879711,0.00926228815,0.02574224025,0.07348667449, 0.64869};
1490     Float_t dHLVm = 2.0502;
1491
1492     //SDD anode microcab
1493
1494     Float_t aALVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
1495     Float_t zALVm[5]={6.,1.,7.,8.,13.};
1496     Float_t wALVm[5]={0.392653705471,0.0128595919215,0.041626868025,0.118832707289, 0.431909};
1497     Float_t dALVm = 2.0502;
1498
1499     //X7R capacitors
1500
1501     Float_t aX7R[7]={137.327,47.867,15.9994,58.6928,63.5460,118.710,207.2};
1502     Float_t zX7R[7]={56.,22.,8.,28.,29.,50.,82.};
1503     Float_t wX7R[7]={0.251639432,0.084755042,0.085975822,0.038244751,0.009471271,0.321736471,0.2081768};
1504     Float_t dX7R = 7.14567;
1505
1506     // AIR
1507
1508     Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
1509     Float_t zAir[4]={6.,7.,8.,18.};
1510     Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
1511     Float_t dAir = 1.20479E-3;
1512
1513     // Water
1514
1515     Float_t aWater[2]={1.00794,15.9994};
1516     Float_t zWater[2]={1.,8.};
1517     Float_t wWater[2]={0.111894,0.888106};
1518     Float_t dWater   = 1.0;
1519
1520     // CERAMICS
1521   //     94.4% Al2O3 , 2.8% SiO2 , 2.3% MnO , 0.5% Cr2O3
1522     Float_t acer[5]  = { 26.981539,15.9994,28.0855,54.93805,51.9961 };
1523     Float_t zcer[5]  = {       13.,     8.,    14.,     25.,    24. };
1524     Float_t wcer[5]  = {.4443408,.5213375,.0130872,.0178135,.003421};
1525     Float_t denscer  = 3.6;
1526
1527     //G10FR4
1528
1529     Float_t zG10FR4[14] = {14.00,       20.00,  13.00,  12.00,  5.00,   22.00,  11.00,  19.00,  26.00,  9.00,   8.00,   6.00,   7.00,   1.00};
1530     Float_t aG10FR4[14] = {28.0855000,40.0780000,26.9815380,24.3050000,10.8110000,47.8670000,22.9897700,39.0983000,55.8450000,18.9984000,15.9994000,12.0107000,14.0067000,1.0079400};
1531     Float_t wG10FR4[14] = {0.15144894,0.08147477,0.04128158,0.00904554,0.01397570,0.00287685,0.00445114,0.00498089,0.00209828,0.00420000,0.36043788,0.27529426,0.01415852,0.03427566};
1532     Float_t densG10FR4= 1.8;
1533     
1534      //--- EPOXY  --- C18 H19 O3
1535       Float_t aEpoxy[3] = {15.9994, 1.00794, 12.0107} ; 
1536       Float_t zEpoxy[3] = {     8.,      1.,      6.} ; 
1537       Float_t wEpoxy[3] = {     3.,     19.,     18.} ; 
1538       Float_t dEpoxy = 1.8 ;
1539
1540       // rohacell: C9 H13 N1 O2
1541     Float_t arohac[4] = {12.01,  1.01, 14.010, 16.};
1542     Float_t zrohac[4] = { 6.,    1.,    7.,     8.};
1543     Float_t wrohac[4] = { 14.,   10.,    2.,     6.};
1544     Float_t drohac    = 0.052;
1545
1546     // If he/she means stainless steel (inox) + Aluminium and Zeff=15.3383 then
1547 //
1548 // %Al=81.6164 %inox=100-%Al
1549
1550     Float_t aInAl[5] = {27., 55.847,51.9961,58.6934,28.0855 };
1551     Float_t zInAl[5] = {13., 26.,24.,28.,14. };
1552     Float_t wInAl[5] = {.816164, .131443,.0330906,.0183836,.000919182};
1553     Float_t dInAl    = 3.075;
1554
1555     // Kapton
1556
1557     Float_t aKapton[4]={1.00794,12.0107, 14.010,15.9994};
1558     Float_t zKapton[4]={1.,6.,7.,8.};
1559     Float_t wKapton[4]={0.026362,0.69113,0.07327,0.209235};
1560     Float_t dKapton   = 1.42;
1561     
1562     // Kapton + Cu (for Pixel Bus)
1563
1564     Float_t aKaptonCu[5]={1.00794, 12.0107, 14.010, 15.9994, 63.5460};
1565     Float_t zKaptonCu[5]={1., 6., 7., 8., 29.};
1566     Float_t wKaptonCuBus[5];
1567     
1568     // Kapton + Cu (for Pixel MCM)
1569
1570     Float_t wKaptonCuMCM[5];
1571     
1572     // Kapton + Cu (mix of two above)
1573
1574     Float_t wKaptonCuMix[5];
1575
1576     //SDD ruby sph.
1577     Float_t aAlOxide[2]  = { 26.981539,15.9994};
1578     Float_t zAlOxide[2]  = {       13.,     8.};
1579     Float_t wAlOxide[2]  = {0.4707, 0.5293};
1580     Float_t dAlOxide     = 3.97;
1581
1582     // Silica for optical fibers: Si O2
1583     Float_t aoptfib[2] = { 28.0855, 15.9994};
1584     Float_t zoptfib[2] = { 14.,      8.    };
1585     Float_t woptfib[2] = {  1.,      2.    };
1586     Float_t doptfib    = 2.55;
1587
1588     // Tetrafluorethylene-Perfluorpropylene (FEP) - 08 Mar 10
1589     Float_t aFEP[2] = { 12.0107, 18.9984};
1590     Float_t zFEP[2] = {  6.    ,  9.    };
1591     Float_t wFEP[2] = {  1.    ,  2.    };
1592     Float_t dFEP    = 2.15;
1593
1594     // PVC (C2H3Cl)n - 08 Jul 10
1595     Float_t aPVC[3] = { 12.0107, 1.00794, 35.4527};
1596     Float_t zPVC[3] = {  6.    , 1.     , 35.   };
1597     Float_t wPVC[3] = {  2.    , 3.     ,  1.   };
1598     Float_t dPVC    = 1.3;
1599
1600     //SSD NiSn capacitor ends
1601     Float_t aNiSn[2]  = { 56.6934,118.710};
1602     Float_t zNiSn[2]  = {     28.,     50.};
1603     Float_t wNiSn[2]  = {0.33, 0.67};
1604     Float_t dNiSn     = wNiSn[0]*8.908 + wNiSn[1]*7.310;
1605
1606     AliMaterial(1,"SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
1607     AliMedium(1,"SI$",1,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
1608
1609     AliMaterial(2,"SPD SI CHIP$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
1610     AliMedium(2,"SPD SI CHIP$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
1611
1612     AliMaterial(3,"SPD SI BUS$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
1613     AliMedium(3,"SPD SI BUS$",3,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
1614
1615     AliMixture(4,"C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
1616     AliMedium(4,"C (M55J)$",4,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1617
1618     AliMixture(5,"AIR$",aAir,zAir,dAir,4,wAir);
1619     AliMedium(5,"AIR$",5,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
1620
1621     AliMixture(6,"GEN AIR$",aAir,zAir,dAir,4,wAir);
1622     AliMedium(6,"GEN AIR$",6,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
1623
1624     AliMixture(7,"SDD SI CHIP$",aSICHIP,zSICHIP,dSICHIP,6,wSICHIP);
1625     AliMedium(7,"SDD SI CHIP$",7,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
1626
1627     AliMixture(9,"SDD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
1628     AliMedium(9,"SDD C (M55J)$",9,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1629
1630     AliMixture(10,"SDD AIR$",aAir,zAir,dAir,4,wAir);
1631     AliMedium(10,"SDD AIR$",10,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
1632
1633     AliMaterial(11,"AL$",0.26982E+02,0.13000E+02,0.26989E+01,0.89000E+01,0.99900E+03);
1634     AliMedium(11,"AL$",11,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1635
1636     AliMixture(12, "Water$",aWater,zWater,dWater,2,wWater);
1637     AliMedium(12,"WATER$",12,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1638
1639     AliMixture(13,"Freon$",afre,zfre,densfre,-2,wfre);
1640     AliMedium(13,"Freon$",13,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1641
1642     AliMaterial(14,"COPPER$",0.63546E+02,0.29000E+02,0.89600E+01,0.14300E+01,0.99900E+03);
1643     AliMedium(14,"COPPER$",14,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1644     AliMixture(15,"CERAMICS$",acer,zcer,denscer,5,wcer);
1645     AliMedium(15,"CERAMICS$",15,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1646
1647     AliMixture(20,"SSD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
1648     AliMedium(20,"SSD C (M55J)$",20,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1649
1650     AliMixture(21,"SSD AIR$",aAir,zAir,dAir,4,wAir);
1651     AliMedium(21,"SSD AIR$",21,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
1652
1653     AliMixture(25,"G10FR4$",aG10FR4,zG10FR4,densG10FR4,14,wG10FR4);
1654     AliMedium(25,"G10FR4$",25,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1655
1656      AliMixture(26,"GEN C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
1657     AliMedium(26,"GEN C (M55J)$",26,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1658
1659     AliMixture(27,"GEN Air$",aAir,zAir,dAir,4,wAir);
1660     AliMedium(27,"GEN Air$",27,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
1661
1662     AliMixture(47,"PVC$",aPVC,zPVC,dPVC,-3,wPVC);
1663     AliMedium(47,"PVC$",47,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1664
1665     Double_t cuFrac = 0.56;
1666     Double_t kFrac  = 1.0 - cuFrac;
1667     Double_t cuDens = 8.96;
1668     Float_t dKaptonCuBus   = cuFrac * cuDens + kFrac * dKapton;
1669     for (Int_t j=0; j<4; j++)
1670       wKaptonCuBus[j] = wKapton[j]*kFrac;
1671     wKaptonCuBus[4] = cuFrac;
1672     AliMixture(48, "SPD-BUS CU KAPTON", aKaptonCu, zKaptonCu, dKaptonCuBus, 5, wKaptonCuBus);
1673     AliMedium(48,"SPD-BUS CU KAPTON$",48,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1674     
1675     cuFrac = 0.5;
1676     kFrac  = 1.0 - cuFrac;
1677     Float_t dKaptonCuMCM   = cuFrac * cuDens + kFrac * dKapton;
1678     for (Int_t j=0; j<4; j++)
1679       wKaptonCuMCM[j] = wKapton[j]*kFrac;
1680     wKaptonCuMCM[4] = cuFrac;
1681     AliMixture(49, "SPD-MCM CU KAPTON", aKaptonCu, zKaptonCu, dKaptonCuMCM, 5, wKaptonCuMCM);
1682     AliMedium(49,"SPD-MCM CU KAPTON$",49,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1683     
1684     cuFrac = (0.56 + 0.5) / 2.0;
1685     kFrac  = 1.0 - cuFrac;
1686     Float_t dKaptonCuMix   = cuFrac * cuDens + kFrac * dKapton;
1687     for (Int_t j=0; j<4; j++)
1688       wKaptonCuMix[j] = wKapton[j]*kFrac;
1689     wKaptonCuMix[4] = cuFrac;
1690     AliMixture(50, "SPD-MIX CU KAPTON", aKaptonCu, zKaptonCu, dKaptonCuMix, 5, wKaptonCuMix);
1691     AliMedium(50,"SPD-MIX CU KAPTON$",50,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1692
1693     AliMaterial(51,"SPD SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
1694     AliMedium(51,"SPD SI$",51,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
1695
1696     AliMaterial(52,"SPD SI CHIP$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
1697     AliMedium(52,"SPD SI CHIP$",52,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
1698
1699     AliMaterial(53,"SPD SI BUS$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
1700     AliMedium(53,"SPD SI BUS$",53,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
1701
1702     AliMixture(54,"SPD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
1703     AliMedium(54,"SPD C (M55J)$",54,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1704
1705     AliMixture(55,"SPD AIR$",aAir,zAir,dAir,4,wAir);
1706     AliMedium(55,"SPD AIR$",55,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
1707
1708     AliMixture(56, "SPD KAPTON(POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
1709     AliMedium(56,"SPD KAPTON(POLYCH2)$",56,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1710
1711     // Gaseous Freon has same chemical composition but air density at 1.7 atm
1712     AliMixture(59,"GASEOUS FREON$",afre,zfre,1.7*dAir,-2,wfre);
1713     AliMedium(59,"GASEOUS FREON$",59,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1714
1715     AliMixture(61,"EPOXY$",aEpoxy,zEpoxy,dEpoxy,-3,wEpoxy);
1716     AliMedium(61,"EPOXY$",61,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1717
1718     AliMaterial(62,"SILICON$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
1719     AliMedium(62,"SILICON$",62,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
1720
1721     AliMixture(63, "KAPTONH(POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
1722     AliMedium(63,"KAPTONH(POLYCH2)$",63,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1723
1724     AliMaterial(64,"ALUMINUM$",0.26982E+02,0.13000E+02,0.26989E+01,0.89000E+01,0.99900E+03);
1725     AliMedium(64,"ALUMINUM$",64,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1726
1727     AliMixture(65,"INOX$",aINOX,zINOX,dINOX,9,wINOX);
1728     AliMedium(65,"INOX$",65,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1729
1730     AliMixture(66,"NiSn$",aNiSn,zNiSn,dNiSn,2,wNiSn);
1731     AliMedium(66,"NiSn$",66,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1732
1733     AliMaterial(67,"Sn$", 118.710, 50., 7.310, 1.206, 999.);
1734     AliMedium(67,"Sn$",67,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1735
1736     AliMixture(68,"ROHACELL$",arohac,zrohac,drohac,-4,wrohac);
1737     AliMedium(68,"ROHACELL$",68,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1738
1739      AliMixture(69,"SDD C AL (M55J)$",aALCM55J,zALCM55J,dALCM55J,5,wALCM55J);
1740     AliMedium(69,"SDD C AL (M55J)$",69,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1741   
1742     AliMixture(70, "SDDKAPTON (POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
1743     AliMedium(70,"SDDKAPTON (POLYCH2)$",70,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1744
1745      AliMaterial(71,"ITS SANDW A$",0.12011E+02,0.60000E+01,0.2115E+00,0.17479E+03,0.99900E+03);
1746     AliMedium(71,"ITS SANDW A$",71,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1747
1748     AliMaterial(72,"ITS SANDW B$",0.12011E+02,0.60000E+01,0.27000E+00,0.18956E+03,0.99900E+03);
1749     AliMedium(72,"ITS SANDW B$",72,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1750
1751     AliMaterial(73,"ITS SANDW C$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
1752     AliMedium(73,"ITS SANDW C$",73,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1753
1754     AliMaterial(74,"HEAT COND GLUE$",0.12011E+02,0.60000E+01,0.1930E+01,0.22100E+02,0.99900E+03);
1755     AliMedium(74,"HEAT COND GLUE$",74,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1756
1757     AliMaterial(75,"ELASTO SIL$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
1758     AliMedium(75,"ELASTO SIL$",75,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1759
1760     // SPD bus (data from Petra Riedler)
1761     Float_t aSPDbus[5] = {1.00794,12.0107,14.01,15.9994,26.982 };
1762     Float_t zSPDbus[5] = {1.,6.,7.,8.,13.};
1763     Float_t wSPDbus[5] = {0.023523,0.318053,0.009776,0.078057,0.570591};
1764     Float_t dSPDbus    = 2.128505;
1765
1766     //   AliMaterial(76,"SPDBUS(AL+KPT+EPOX)$",0.19509E+02,0.96502E+01,0.19060E+01,0.15413E+02,0.99900E+03);
1767     AliMixture(76,"SPDBUS(AL+KPT+EPOX)$",aSPDbus,zSPDbus,dSPDbus,5,wSPDbus);
1768     AliMedium(76,"SPDBUS(AL+KPT+EPOX)$",76,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1769                
1770     AliMixture(77,"SDD X7R capacitors$",aX7R,zX7R,dX7R,7,wX7R);
1771     AliMedium(77,"SDD X7R capacitors$",77,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1772
1773     AliMixture(78,"SDD ruby sph. Al2O3$",aAlOxide,zAlOxide,dAlOxide,2,wAlOxide);
1774     AliMedium(78,"SDD ruby sph. Al2O3$",78,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1775
1776     AliMaterial(79,"SDD SI insensitive$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
1777     AliMedium(79,"SDD SI insensitive$",79,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1778
1779     AliMixture(80,"SDD HV microcable$",aHVm,zHVm,dHVm,5,wHVm);
1780     AliMedium(80,"SDD HV microcable$",80,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1781
1782     AliMixture(81,"SDD LV+signal cable$",aLVm,zLVm,dLVm,5,wLVm);
1783     AliMedium(81,"SDD LV+signal cable$",81,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1784
1785     AliMixture(82,"SDD hybrid microcab$",aHLVm, zHLVm,dHLVm,5,wHLVm);
1786     AliMedium(82,"SDD hybrid microcab$",82,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1787
1788     AliMixture(83,"SDD anode microcab$",aALVm,zALVm,dALVm,5,wALVm);
1789     AliMedium(83,"SDD anode microcab$",83,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1790     Float_t aDSring[4]={12.0107,      1.00794,     14.0067,      15.9994};
1791     Float_t zDSring[4]={ 6.,          1.,           7.,           8.};
1792     Float_t wDSring[4]={ 0.854323888, 0.026408778,  0.023050265,  0.096217069};
1793     Float_t dDSring = 0.2875;
1794     AliMixture(84,"SDD/SSD rings$",aDSring,zDSring,dDSring,4,wDSring);
1795     AliMedium(84,"SDD/SSD rings$",84,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1796
1797     AliMixture(85,"inox/alum$",aInAl,zInAl,dInAl,5,wInAl);
1798     AliMedium(85,"inox/alum$",85,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1799
1800     // special media to take into account services in the SDD and SSD 
1801     // cones for the FMD
1802     //Begin_Html
1803     /*
1804       <A HREF="http://www.Physics.ohio-state.edu/~nilsen/ITS/ITS_MatBudget_4B.xls">
1805       </pre>
1806       <br clear=left>
1807       <font size=+2 color=blue>
1808       <p> The Exel spread sheet from which these density number come from.
1809       </font></A>
1810     */
1811     //End_Html
1812
1813     //  AliMaterial(86,"AIRFMDSDD$",0.14610E+02,0.73000E+01,0.12050E-02,0.30423E+05,0.99900E+03);
1814     Float_t aA[13],zZ[13],wW[13],den;
1815     // From Pierluigi Barberis calculations of 2SPD+1SDD October 2 2002.
1816     zZ[0] = 1.0; aA[0] = 1.00794; // Hydrogen
1817     zZ[1] = 6.0; aA[1] = 12.011; // Carbon
1818     zZ[2] = 7.0; aA[2] = 14.00674; // Nitrogen
1819     zZ[3] = 8.0; aA[3] = 15.9994; // Oxigen
1820     zZ[4] = 14.0; aA[4] = 28.0855; // Silicon
1821     zZ[5] = 24.0; aA[5] = 51.9961; //Cromium
1822     zZ[6] = 25.0; aA[6] = 54.938049; // Manganese
1823     zZ[7] = 26.0; aA[7] = 55.845; // Iron
1824     zZ[8] = 28.0; aA[8] = 58.6934; // Nickle
1825     zZ[9] = 29.0; aA[9] = 63.546; // Copper
1826     zZ[10] = 13.0; aA[10] = 26.981539; // Alulminum
1827     zZ[11] = 47.0; aA[11] = 107.8682; // Silver
1828     zZ[12] = 27.0; aA[12] = 58.9332; // Cobolt
1829     wW[0] = 0.019965;
1830     wW[1] = 0.340961;
1831     wW[2] = 0.041225;
1832     wW[3] = 0.200352;
1833     wW[4] = 0.000386;
1834     wW[5] = 0.001467;
1835     wW[6] = 0.000155;
1836     wW[7] = 0.005113;
1837     wW[8] = 0.000993;
1838     wW[9] = 0.381262;
1839     wW[10] = 0.008121;
1840     wW[11] = 0.000000;
1841     wW[12] = 0.000000;
1842     if(fByThick){// New values seeITS_MatBudget_4B.xls
1843         den = 1.5253276; // g/cm^3  Cell O370
1844     }else{
1845         den = 2.58423412; // g/cm^3 Cell L370
1846     } // end if fByThick
1847     //den = 6161.7/(3671.58978);//g/cm^3 Volume does not exclude holes
1848     AliMixture(86,"AIRFMDSDD$",aA,zZ,den,+11,wW);
1849     AliMedium(86,"AIRFMDSDD$",86,0,ifield,fieldm,tmaxfdAir,stemaxAir,
1850               deemaxAir,epsilAir,stminAir);
1851
1852     //AliMaterial(87,"AIRFMDSSD$",0.14610E+02,0.73000E+01,0.12050E-02,0.30423E+05,0.99900E+03);
1853     // From Pierluigi Barberis calculations of SSD October 2 2002.
1854     wW[0] = 0.019777;
1855     wW[1] = 0.325901;
1856     wW[2] = 0.031848;
1857     wW[3] = 0.147668;
1858     wW[4] = 0.030609;
1859     wW[5] = 0.013993;
1860     wW[6] = 0.001479;
1861     wW[7] = 0.048792;
1862     wW[8] = 0.009477;
1863     wW[9] = 0.350697;
1864     wW[10] = 0.014546;
1865     wW[11] = 0.005213;
1866     wW[12] = 0.000000;
1867     if(fByThick){// New values seeITS_MatBudget_4B.xls
1868         den = 1.2464275; // g/cm^3   Cell O403
1869     }else{
1870         den = 1.28134409; // g/cm^3  Cell L403
1871     } // end if fByThick
1872     //den = 7666.3/(9753.553259); // volume does not exclude holes
1873     AliMixture(87,"AIRFMDSSD$",aA,zZ,den,+12,wW); 
1874     AliMedium(87,"AIRFMDSSD$",87,0,ifield,fieldm,tmaxfdAir,stemaxAir,
1875               deemaxAir,epsilAir,stminAir);
1876
1877     //AliMaterial(88,"ITS SANDW CFMDSDD$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
1878     // From Pierluigi Barberis calculations of 1SDD+Carbon fiber October 2 2002
1879     wW[0] = 0.016302;
1880     wW[1] = 0.461870;
1881     wW[2] = 0.033662;
1882     wW[3] = 0.163595;
1883     wW[4] = 0.000315;
1884     wW[5] = 0.001197;
1885     wW[6] = 0.000127;
1886     wW[7] = 0.004175;
1887     wW[8] = 0.000811;
1888     wW[9] = 0.311315;
1889     wW[10] = 0.006631;
1890     wW[11] = 0.000000;
1891     wW[12] = 0.000000;
1892     if(fByThick){// New values seeITS_MatBudget_4B.xls
1893         den = 1.9353276; // g/cm^3  Cell N370
1894     }else{
1895         den = 3.2788626; // g/cm^3 Cell F370
1896     } // end if fByThick
1897     //den = 7667.1/(3671.58978); // Volume does not excludeholes
1898     AliMixture(88,"ITS SANDW CFMDSDD$",aA,zZ,den,+11,wW); 
1899     AliMedium(88,"ITS SANDW CFMDSDD$",88,0,ifield,fieldm,tmaxfd,stemax,
1900               deemax,epsil,stmin);
1901
1902     //AliMaterial(89,"ITS SANDW CFMDSSD$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
1903     // From Pierluigi Barberis calculations of SSD+Carbon fiber October 2 2002.
1904     wW[0] = 0.014065;
1905     wW[1] = 0.520598;
1906     wW[2] = 0.022650;
1907     wW[3] = 0.105018;
1908     wW[4] = 0.021768;
1909     wW[5] = 0.009952;
1910     wW[6] = 0.001051;
1911     wW[7] = 0.034700;
1912     wW[8] = 0.006740;
1913     wW[9] = 0.249406;
1914     wW[10] = 0.010345;
1915     wW[11] = 0.0003707;
1916     wW[12] = 0.000000;
1917     if(fByThick){// New values seeITS_MatBudget_4B.xls
1918         den = 1.6564275; // g/cm^3  Cell N304
1919     }else{
1920         den = 1.7028296; // g/cm^3  Cell F304
1921     } // end if fByThick
1922     //den = 1166.5/(3671.58978); // Volume does not exclude holes
1923     AliMixture(89,"ITS SANDW CFMDSSD$",aA,zZ,den,+12,wW); 
1924     AliMedium(89,"ITS SANDW CFMDSSD$",89,0,ifield,fieldm,tmaxfd,stemax,
1925               deemax,epsil,stmin);
1926
1927     //AliMaterial(97,"SPD SERVICES$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
1928     // From Pierluigi Barberis calculations of 1SPD October 2 2002.
1929     wW[0] = 0.005970;
1930     wW[1] = 0.304704;
1931     wW[2] = 0.042510;
1932     wW[3] = 0.121715;
1933     wW[4] = 0.001118;
1934     wW[5] = 0.030948;
1935     wW[6] = 0.003270;
1936     wW[7] = 0.107910;
1937     wW[8] = 0.020960;
1938     wW[9] = 0.360895;
1939     wW[10] = 0.000000;
1940     wW[11] = 0.000000;
1941     wW[12] = 0.000000;
1942     if(fByThick){// New values seeITS_MatBudget_4B.xls
1943         den = 80.31136576; // g/cm^3 Cell H329
1944     }else{
1945         den = 87.13062; // g/cm^3  Cell G329
1946     } // end if fByThick
1947     //den = 1251.3/(0.05*2.0*TMath::Pi()*(7.75*7.75 - 3.7*3.7)); // g/cm^3
1948     AliMixture(97,"SPD SERVICES$",aA,zZ,den,+10,wW); 
1949     AliMedium(97,"SPD SERVICES$",97,0,ifield,fieldm,tmaxfd,stemax,
1950               deemax,epsil,stmin);
1951
1952
1953     // Special media
1954
1955     AliMaterial(90,"SPD shield$", 12.011, 6., 1.93 , 22.36, 999);
1956     AliMedium(90,"SPD shield$",90,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1957
1958     // SPD End Ladder (data from Petra Riedler)
1959     Float_t aSPDel[5] = {1.00794,12.0107,14.01,15.9994,63.54 };
1960     Float_t zSPDel[5] = {1.,6.,7.,8.,29.};
1961     Float_t wSPDel[5] = {0.004092,0.107274,0.011438,0.032476,0.844719};
1962     Float_t dSPDel    = 3.903403;
1963
1964     //   AliMaterial(91, "SPD End ladder$", 47.0447, 21.7963, 3.6374, 4.4711, 999); 
1965     AliMixture(91,"SPD End ladder$",aSPDel,zSPDel,dSPDel,5,wSPDel);
1966     AliMedium(91,"SPD End ladder$",91,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1967
1968     AliMaterial(92, "SPD cone$",28.0855, 14., 2.33, 9.36, 999);    
1969     AliMedium(92,"SPD cone$",92,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1970     /*  Material with fractional Z not actually used
1971     AliMaterial(93, "SDD End ladder$", 69.9298, 29.8246, 0.3824, 36.5103, 999);
1972     AliMedium(93,"SDD End ladder$",93,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1973     */
1974     AliMaterial(94, "SDD cone$",63.546, 29., 1.15, 1.265, 999);
1975     AliMedium(94,"SDD cone$",94,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1976     /* Material with fractional Z not actually used
1977     AliMaterial(95, "SSD End ladder$", 32.0988, 15.4021, 0.68, 35.3238, 999); 
1978     AliMedium(95,"SSD End ladder$",95,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1979     */
1980     AliMaterial(96, "SSD cone$",63.546, 29., 1.15, 1.265, 999);
1981     AliMedium(96,"SSD cone$",96,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1982
1983     AliMixture(98,"SDD OPTICFIB$",aoptfib,zoptfib,doptfib,-2,woptfib);
1984     AliMedium(98,"SDD OPTICFIB$",98,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1985
1986     AliMixture(95,"SSD FEP$",aFEP,zFEP,dFEP,-2,wFEP);
1987     AliMedium(95,"SSD FEP$",95,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1988
1989     // Mean material for low-voltage cables on SPD trays Side A
1990     // (Copper + PolyEthylene (C2-H4)) (D.Elia for cable number and
1991     // cross-section area, M.Sitta for elemental computation) - 26 Feb 10
1992     wW[0] = 0.323024;//H
1993     wW[2] = 0.515464;//Cu
1994     wW[1] = 0.161512;//C
1995     wW[3] = 0.000000;//O
1996     wW[4] = 0.000000;//S
1997     wW[5] = 0.000000;//F
1998     wW[6] = 0.000000;//Sn
1999     wW[7] = 0.000000;//Pb
2000     wW[8] = 0.000000;//Cr
2001     wW[9] = 0.000000;//Si
2002     wW[10] = 0.000000;//Ni
2003     wW[11] = 0.000000;//Ca
2004
2005     den = 5.078866;
2006     AliMixture(60,"SPD_LOWCABLES$",aA,zZ,den,+3,wW);
2007     AliMedium(60,"SPD_LOWCABLES$",60,0,ifield,fieldm,tmaxfd,stemax,
2008               deemax,epsil,stmin);
2009
2010     // Mean material for high-voltage cables on SPD trays Side A & C
2011     // (Copper + HD PolyEthylene (C2-H2)) (D.Elia for cable number and
2012     // cross-section area, M.Sitta for elemental computation) - 10 Jun 10
2013     wW[0] = 0.083766;//H
2014     wW[2] = 0.417136;//Cu
2015     wW[1] = 0.499098;//C
2016     wW[3] = 0.000000;//O
2017     wW[4] = 0.000000;//S
2018     wW[5] = 0.000000;//F
2019     wW[6] = 0.000000;//Sn
2020     wW[7] = 0.000000;//Pb
2021     wW[8] = 0.000000;//Cr
2022     wW[9] = 0.000000;//Si
2023     wW[10] = 0.000000;//Ni
2024     wW[11] = 0.000000;//Ca
2025
2026     den = 1.514930;
2027     AliMixture(58,"SPD_HICABLES$",aA,zZ,den,+3,wW);
2028     AliMedium(58,"SPD_HICABLES$",58,0,ifield,fieldm,tmaxfd,stemax,
2029               deemax,epsil,stmin);
2030
2031     // PolyUrethane [C25-H42-N2-O6] - 07 Mar 10
2032     zZ[2] =  7.0; aA[2] =  14.0067; // Nitrogen - From Root TGeoElementTable
2033
2034     wW[0] = 0.090724;//H
2035     wW[2] = 0.060035;//N
2036     wW[1] = 0.643513;//C
2037     wW[3] = 0.205728;//O
2038     wW[4] = 0.000000;//S
2039     wW[5] = 0.000000;//F
2040     wW[6] = 0.000000;//Sn
2041     wW[7] = 0.000000;//Pb
2042     wW[8] = 0.000000;//Cr
2043     wW[9] = 0.000000;//Si
2044     wW[10] = 0.000000;//Ni
2045     wW[11] = 0.000000;//Ca
2046
2047     den = 1.158910;
2048     AliMixture(67,"POLYURETHANE$",aA,zZ,den,+4,wW);
2049     AliMedium(67,"POLYURETHANE$",67,0,ifield,fieldm,tmaxfd,stemax,
2050               deemax,epsil,stmin);
2051
2052     //  POM (Polyoxymethylene = (CH2O)n ) - 02 May 10
2053     zZ[2] =  8.0; aA[2] =  15.9994; // Oxigen
2054
2055     wW[0] = 0.067137;//H
2056     wW[1] = 0.400016;//C
2057     wW[2] = 0.532847;//O
2058     wW[3] = 0.000000;//O
2059     wW[4] = 0.000000;//S
2060     wW[5] = 0.000000;//F
2061     wW[6] = 0.000000;//Sn
2062     wW[7] = 0.000000;//Pb
2063     wW[8] = 0.000000;//Cr
2064     wW[9] = 0.000000;//Si
2065     wW[10] = 0.000000;//Ni
2066     wW[11] = 0.000000;//Ca
2067
2068     den = 1.4200;
2069     AliMixture(57,"POLYOXYMETHYLENE$",aA,zZ,den,+3,wW);
2070     AliMedium(57,"POLYOXYMETHYLENE$",57,0,ifield,fieldm,tmaxfd,stemax,
2071               deemax,epsil,stmin);
2072
2073
2074     // Anticorodal: Aliminum alloy for tray ring support on Side A
2075     den = 2.710301;
2076     AliMaterial(93,"ANTICORODAL$",0.26982E+02,0.13000E+02,den,0.89000E+01,0.99900E+03);
2077     AliMedium(93,"ANTICORODAL$",93,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
2078     
2079 }
2080
2081 //_____________________________________________________________________________
2082 void AliMaterial(Int_t imat, const char* name, Float_t a, 
2083                  Float_t z, Float_t dens, Float_t radl,
2084                  Float_t absl) {
2085
2086   TString uniquename = "ITS";
2087   uniquename.Append("_");
2088   uniquename.Append(name);
2089
2090   gGeoManager->Material(uniquename.Data(), a, z, dens, imat, radl, absl);
2091
2092 }
2093
2094 //_____________________________________________________________________________
2095 void AliMedium(Int_t numed, const char *name, Int_t nmat,
2096                Int_t isvol, Int_t ifield, Float_t fieldm,
2097                Float_t tmaxfd, Float_t stemax, Float_t deemax,
2098                Float_t epsil, Float_t stmin){
2099
2100   TString uniquename = "ITS";
2101   uniquename.Append("_");
2102   uniquename.Append(name);
2103
2104   gGeoManager->Medium(uniquename.Data(),numed,nmat, isvol, ifield, fieldm, 
2105                       tmaxfd, stemax,deemax, epsil, stmin);
2106
2107 }
2108
2109 //_____________________________________________________________________________
2110 void AliMixture(Int_t kmat, const char* name, Float_t* a, Float_t* z,
2111                     Double_t dens, Int_t nlmat, Float_t* wmat)
2112 {
2113   //
2114   // Defines mixture OR COMPOUND IMAT as composed by
2115   // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
2116   //
2117   // If NLMAT > 0 then wmat contains the proportion by
2118   // weights of each basic material in the mixture.
2119   //
2120   // If nlmat < 0 then WMAT contains the number of atoms
2121   // of a given kind into the molecule of the COMPOUND
2122   // In this case, WMAT in output is changed to relative
2123   // weigths.
2124   //
2125
2126   TString uniquename = "ITS";
2127   uniquename.Append("_");
2128   uniquename.Append(name);
2129
2130
2131    Double_t* da = CreateDoubleArray(a, TMath::Abs(nlmat));
2132    Double_t* dz = CreateDoubleArray(z, TMath::Abs(nlmat));
2133    Double_t* dwmat = CreateDoubleArray(wmat, TMath::Abs(nlmat));
2134
2135    Mixture(kmat, uniquename.Data(), da, dz, dens, nlmat, dwmat);
2136    for (Int_t i=0; i<nlmat; i++) {
2137       a[i] = da[i]; z[i] = dz[i]; wmat[i] = dwmat[i];
2138    }
2139
2140    delete [] da;
2141    delete [] dz;
2142    delete [] dwmat;
2143 }
2144
2145 //_____________________________________________________________________________
2146 void Mixture(Int_t& kmat, const char* name, Double_t* a, Double_t* z,
2147              Double_t dens, Int_t nlmat, Double_t* wmat)
2148 {
2149   //
2150   // Defines mixture OR COMPOUND IMAT as composed by
2151   // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
2152   //
2153   // If NLMAT > 0 then wmat contains the proportion by
2154   // weights of each basic material in the mixture.
2155   //
2156   // If nlmat < 0 then WMAT contains the number of atoms
2157   // of a given kind into the molecule of the COMPOUND
2158   // In this case, WMAT in output is changed to relative
2159   // weigths.
2160   //
2161
2162    if (nlmat < 0) {
2163       nlmat = - nlmat;
2164       Double_t amol = 0;
2165       Int_t i;
2166       for (i=0;i<nlmat;i++) {
2167          amol += a[i]*wmat[i];
2168       }
2169       for (i=0;i<nlmat;i++) {
2170          wmat[i] *= a[i]/amol;
2171       }
2172    }
2173    gGeoManager->Mixture(name, a, z, dens, nlmat, wmat, kmat);
2174 }
2175
2176 //_____________________________________________________________________________
2177 Double_t* CreateDoubleArray(Float_t* array, Int_t size)
2178 {
2179 // Converts Float_t* array to Double_t*,
2180 // !! The new array has to be deleted by user.
2181 // ---
2182
2183    Double_t* doubleArray;
2184    if (size>0) {
2185       doubleArray = new Double_t[size];
2186       for (Int_t i=0; i<size; i++) doubleArray[i] = array[i];
2187    } else {
2188       //doubleArray = 0;
2189       doubleArray = new Double_t[1];
2190    }
2191    return doubleArray;
2192 }
2193
2194 //______________________________________________________________________
2195 Bool_t Make2DCrossSections(TPolyLine &a0,TPolyLine &a1,
2196                            TPolyLine &b0,TPolyLine &b1,TPolyMarker &p)
2197 {
2198     //
2199     // Fill the objects with the points representing
2200     // a0 the outer carbon fiber SPD sector shape Cross Section A
2201     // a1 the inner carbon fiber SPD sector shape Cross Section A
2202     // b0 the outer carbon fiber SPD sector shape Cross Section B
2203     // b1 the inner carbon fiber SPD sector shape Cross Section B
2204     //
2205     // Inputs:
2206     //   TPolyLine &a0   The outer carbon fiber SPD sector shape
2207     //   TPolyLine &a1   The Inner carbon fiber SPD sector shape
2208     //   TPolyLine &b0   The outer carbon fiber SPD sector shape
2209     //   TPolyLine &b1   The Inner carbon fiber SPD sector shape
2210     //   TPolyMarker &p  The points where the ladders are to be placed
2211     // Outputs:
2212     //   TPolyLine &a0   The shape filled with the points
2213     //   TPolyLine &a1   The shape filled with the points
2214     //   TPolyLine &b0   The shape filled with the points
2215     //   TPolyLine &b1   The shape filled with the points
2216     //   TPolyMarker &p  The filled array of points
2217     // Return:
2218     //     An error flag.
2219     //
2220     Int_t n0,n1,i;
2221     Double_t x,y;
2222     TGeoVolume *a0V,*a1V,*b0V,*b1V;
2223     TGeoXtru *a0S,*a1S,*b0S,*b1S;
2224     TGeoManager *mgr = gGeoManager;
2225
2226     a0V = mgr->GetVolume("ITSSPDCarbonFiberSupportSectorA0");
2227     a0S = dynamic_cast<TGeoXtru*>(a0V->GetShape());
2228     n0 = a0S->GetNvert();
2229     a0.SetPolyLine(n0+1);
2230     //for(i=0;i<fSPDsectorPoints0.GetSize();i++)
2231     //  printf("%d %d %d\n",i,fSPDsectorPoints0[i],fSPDsectorPoints1[i]);
2232     for(i=0;i<n0;i++){
2233         x = a0S->GetX(i);
2234           y = a0S->GetY(i);
2235           //printf("%d %g %g\n",i,x,y);
2236         a0.SetPoint(i,x,y);
2237           if(i==0) a0.SetPoint(n0,x,y);
2238     } // end for i
2239     a1V = mgr->GetVolume("ITSSPDCarbonFiberSupportSectorAirA1");
2240     a1S = dynamic_cast<TGeoXtru*>(a1V->GetShape());
2241     n1 = a1S->GetNvert();
2242     a1.SetPolyLine(n1+1);
2243     for(i=0;i<n1;i++){
2244         x = a1S->GetX(i);
2245           y = a1S->GetY(i);
2246         a1.SetPoint(i,x,y);
2247           if(i==0) a1.SetPoint(n1,x,y);
2248     } // end for i
2249     // Cross Section B
2250     b0V = mgr->GetVolume("ITSSPDCarbonFiberSupportSectorEndB0");
2251     b0S = dynamic_cast<TGeoXtru*>(b0V->GetShape());
2252     n0 = b0S->GetNvert();
2253     b0.SetPolyLine(n0+1);
2254     for(i=0;i<n0;i++){
2255         x = b0S->GetX(i);
2256           y = b0S->GetY(i);
2257         b0.SetPoint(i,x,y);
2258           if(i==0) b0.SetPoint(n0,x,y);
2259     } // end for i
2260     b1V = mgr->GetVolume("ITSSPDCarbonFiberSupportSectorEndAirB1");
2261     b1S = dynamic_cast<TGeoXtru*>(b1V->GetShape());
2262     n1 = b1S->GetNvert();
2263     b1.SetPolyLine(n1+1);
2264     for(i=0;i<n1;i++){
2265         x = b1S->GetX(i);
2266           y = b1S->GetY(i);
2267         b1.SetPoint(i,x,y);
2268           if(i==0) b1.SetPoint(n1,x,y);
2269     } // end for i
2270     //
2271     Double_t x0,y0,x1,y1;
2272     p.SetPolyMarker(2*gspd->GetSPDsectorX0Size());
2273     for(i=0;i<gspd->GetSPDsectorX0Size();i++){
2274           gspd->GetSectorMountingPoints(i,x0,y0,x1,y1);
2275           p.SetPoint(2*i,x0,y0);
2276           p.SetPoint(2*i+1,x1,y1);
2277     } // end for i
2278     return kTRUE;
2279 }