]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/DisplayITSv11.cxx
Start of a TTask to replace Displayv11.C
[u/mrichter/AliRoot.git] / ITS / DisplayITSv11.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 $Id$
18 */
19 #include <TSystem.h>
20 #include <TROOT.h>
21 #include <TGeoManager.h>
22 #include <TGeoNode.h>
23 #include <TGeoVolume.h>
24 #include <TGeoShape.h>
25 #include <TGeoTube.h>
26 #include <TGeoMaterial.h>
27 #include <TGeoMedium.h>
28 #include <TCanvas.h>
29 #include <TControlBar.h>
30 #include <TArrow.h>
31 #include <TPad.h>
32 #include <TView.h>
33
34 #include "AliITS.h"
35 #include "AliITSv11.h"
36 #include "DisplayITSv11.h"
37
38 ClassImp(DisplayITSv11)
39 //______________________________________________________________________
40 DisplayITSv11::DisplayITSv11(){
41     // Default Constructor.
42     // Inputs:
43     //    none.
44     // Outputs:
45     //    none.
46     // Return:
47     //    A Default constructed DispalyITSv11 class/task.
48
49     fmgr         = 0;
50     fits         = 0;
51     fALICE       = 0;
52     fITS         = 0;
53     fClip        = 0;
54     fITSdebug    = 0;
55     fNsegments   = 80;
56     fCut         = 0;
57     fAxis        = 1;
58     fPerspective = 0;
59     fSolid       = 0;
60     fPhimincut   = 0.0;
61     fPhimaxcut   = 180.0;
62     fRmin[0] = fRmin[1] = fRmin[2] = fRmax[0] = fRmax[1] = fRmax[2] = 0.0;
63     fLongitude   = 90.0;
64     fLatitude    = 0.0;
65     fPsi         = 0.0;
66 }
67 //______________________________________________________________________
68 DisplayITSv11::~DisplayITSv11(){
69     // Destructor.
70     // Inputs:
71     //    none.
72     // Outputs:
73     //    none.
74     // Return:
75     //    none..
76
77     if(fits) delete fits;
78     if(fClip) delete fClip;
79     fITS   = 0;
80     fALICE = 0;
81     fmgr   = 0;
82 }
83 //______________________________________________________________________
84 void DisplayITSv11::Exec(Option_t* opt){
85     // Main display routine
86     // Inputs:
87     //      Option_t * opt   Not presently used.
88     // Outputs:
89     //      none.
90     // Return:
91     //      none.
92     Int_t i;
93
94     gSystem->Load("libGeom");
95     //
96     if(gGeoManager) delete gGeoManager;
97     fmgr = gGeoManager = new TGeoManager("ITSGeometry",
98                                          " ITS Simulation Geometry Manager");
99     //
100     TGeoMaterial *vacmat = new TGeoMaterial("Vacume",0,0,0);
101     TGeoMedium   *vacmed = new TGeoMedium("Vacume_med",1,vacmat);
102     fRmax[0] = 100.;
103     fRmax[1] = 100.;
104     fRmax[2] = 200.;
105     for(i=0;i<3;i++) fRmin[i] = -fRmax[i];
106     fALICE = fmgr->MakeBox("ALIC",vacmed,fRmax[0],fRmax[1],fRmax[2]);
107     fmgr->SetTopVolume(fALICE);
108     //
109     AliITSv11 *fits = new AliITSv11();
110     fits->SetDebug(GetDebugITS());
111     fits->CreateMaterials();
112     fits->CreateGeometry();
113     //
114     fmgr->CloseGeometry();
115     fITS = fALICE->FindNode("ITSV_1")->GetVolume();
116     //
117     TControlBar *bar=new TControlBar("vertical","ITS Geometry Display",10,10);
118     bar->AddButton("Set ITS Debug level 1","SetITSdebugOn()","Debug on");
119     bar->AddButton("Set ITS Debug level 0","SetITSdebugOff()","Debug off");
120     bar->AddButton("Set ITS Theta,Phi cut on","SetCylindericalClipVolume()",
121                    "Cut on");
122     bar->AddButton("Set ITS Theta,Phi cut off","SetCylindericalCutOff()",
123                    "Cut off");
124     bar->AddButton("Set axis on","SetAxisOn()","Show Axis on");
125     bar->AddButton("Set axis off","SetAxisOff()","Show Axis off");
126     bar->AddButton("Set perspective on","SetPerspectiveOn()",
127                    "Perspective on");
128     bar->AddButton("Set perspective off","SetPerspectiveOff()",
129                    "Perspective off");
130     bar->AddButton("Draw volumes as Solid","SetSolid()","Solid Volumes");
131     bar->AddButton("Draw volumes as wire","SetWire()","Wire Volumes");
132     bar->AddButton("Set circle/80","SetCircleSegments(80)",
133                    "circles ~ by 80 lines");
134     bar->AddButton("Check Overlaps","fmgr->CheckOverlaps()",
135                    "Check for overlaps");
136     bar->AddButton("Display Geometry","Displayit()","Run Displayit");
137     bar->AddButton("Display SPD Thermal Sheald","EngineeringSPDThS()",
138                    "Run EngineeringSPDThS");
139     bar->AddButton("Display SDD Cone","EngineeringSDDCone()",
140                    "Run EngineeringSDDCone");
141     bar->AddButton("Display SDD Centeral Cylinder","EngineeringSDDCylinder()",
142                    "Run EngineeringSDDCylinder");
143     bar->AddButton("Display SUP RB24 side","EngineeringSupRB24()",
144                    "Run EngineeringSDDCylinder");
145     bar->AddButton("Display SUP RB26 side","EngineeringSupRB26()",
146                    "Run EngineeringSupRB26");
147     bar->AddButton("Quit/Exit",".q","Exit");
148     bar->Show();
149     gROOT->SaveContext();
150          //Displayit();
151 }
152 //______________________________________________________________________
153 void DisplayITSv11::Displaying(TGeoVolume *v,TCanvas *c,Int_t ipad){
154     // Display Volume according to existing values
155     // Inputs:
156     //    TGeoVolume *v volume to be drawn.
157     //    TCanvas    *p Pad where drawing is to be done
158     //    Int_t      ipad subpad to draw on
159     // Outputs:
160     //    none.
161     // Return:
162     //    none.
163     Int_t irr;
164     TVirtualPad *p = 0;
165     TView *view=0;
166
167     c->cd(ipad);
168     p = c->GetPad(ipad);
169     if(!p) return;
170     view = p->GetView();
171     if(!view){view = new TView(fRmin,fRmax,1);p->SetView(view);}
172     view->SetRange(fRmin,fRmax);
173     view->SetView(fLongitude,fLatitude,fPsi,irr);
174     if(fPerspective) view->SetPerspective();
175     else view->SetParralel();
176     if(fAxis) view->ShowAxis();
177     //
178     if(fClip) fmgr->SetClippingShape(fClip);
179     v->Draw();
180     if(fSolid) v->Raytrace();
181     p->Modified(1);
182     p->Update();
183 }
184 //----------------------------------------------------------------------
185 void DisplayITSv11::DisplayITS(){
186     // Display AliITSv11 Geometry
187     // Inputs:
188     //    const char* filename output file with the display in it
189     // Outputs:
190     //    none.
191     // Retrurn:
192     //    none.
193     Double_t lon,lat,psi;
194     //
195     TCanvas *c1;
196     if(!(c1 = (TCanvas*)gROOT->FindObject("C1")))
197         c1 = new TCanvas("C1","ITS Simulation Geometry",900,900);
198     c1->Divide(2,2);
199     //
200     fmgr->SetNsegments(fNsegments);
201     //
202     fmgr->SetVisLevel(6);
203     fmgr->SetVisOption(0);
204     // Perspective
205     Displaying(fALICE,c1,2);
206     lon = fLongitude;
207     lat = fLatitude;
208     psi = fPsi;
209     fLongitude = 270.0; // Front
210     fLatitude  =  90.0;
211     fPsi       =   0.0;
212     Displaying(fALICE,c1,1);
213     fLongitude = 270.0; // Top
214     fLatitude  =   0.0;
215     fPsi       =   0.0;
216     Displaying(fALICE,c1,3);
217     fLongitude =   0.0; // Side
218     fLatitude  =  90.0;
219     fPsi       =   0.0;
220     Displaying(fALICE,c1,4);
221     fLongitude = lon;
222     fLatitude  = lat;
223     fPsi       = psi;
224     //
225 }
226 //----------------------------------------------------------------------
227 void DisplayITSv11::EngineeringSPDThS(){
228     // Display SPD Thermal Sheald Geometry
229     // Inputs:
230     //    none.
231     // Outputs:
232     //    none.
233     // Retrurn:
234     //    none.
235     Double_t lon,lat,psi;
236     //
237     TCanvas *c4;
238     TGeoNode *node;
239     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
240         c4 = new TCanvas("C4","ITS SDD Cylinder Geometry",900,450);
241     c4->Divide(2,1);
242     TGeoVolume *SPDThS=0;
243          //TArrow *arrow=new TArrow();
244     //
245     node = fITS->FindNode("ITSspdThermalSheald_1");
246     SPDThS = node->GetVolume();
247     //
248     fmgr->SetNsegments(fNsegments);
249     //
250     fmgr->SetVisLevel(6);
251     fmgr->SetVisOption(0);
252     //
253     lon = fLongitude;
254     lat = fLatitude;
255     psi = fPsi;
256     fLongitude = 270.0; // Front
257     fLatitude  =  90.0;
258     fPsi       =   0.0;
259     Displaying(SPDThS,c4,1);
260     //
261     fLongitude = 270.0; // Top
262     fLatitude  =   0.0;
263     fPsi       =   0.0;
264     Displaying(SPDThS,c4,2);
265     //
266     fLongitude = lon;
267     fLatitude  = lat;
268     fPsi       = psi;
269 }
270 //----------------------------------------------------------------------
271 void DisplayITSv11::EngineeringSDDCone(){
272     // Display SDD Cone Geometry
273     // Inputs:
274     //    none.
275     // Outputs:
276     //    none.
277     // Retrurn:
278     //    none.
279     Double_t lon,lat,psi;
280     //
281     TCanvas *c2;
282     if(!(c2 = (TCanvas*)gROOT->FindObject("C2")))
283         c2 = new TCanvas("C2","ITS SDD Cone Geometry",900,450);
284     c2->Divide(2,1);
285     TGeoVolume *SDD=0;
286     TGeoNode *node;
287     //
288     node = fITS->FindNode("ITSsddConeL_1");
289     SDD = node->GetVolume();
290     //
291     fmgr->SetNsegments(fNsegments);
292     //
293     fmgr->SetVisLevel(6);
294     fmgr->SetVisOption(0);
295     //
296     lon = fLongitude;
297     lat = fLatitude;
298     psi = fPsi;
299     fLongitude = 270.0; // Front
300     fLatitude  =  90.0;
301     fPsi       =   0.0;
302     Displaying(SDD,c2,1);
303     //
304     fLongitude = 270.0; // Top
305     fLatitude  =   0.0;
306     fPsi       =   0.0;
307     Displaying(SDD,c2,2);
308     //
309     fLongitude = lon;
310     fLatitude  = lat;
311     fPsi       = psi;
312 }
313 //----------------------------------------------------------------------
314 void DisplayITSv11::EngineeringSDDCylinder(){
315     // Display SDD Cylinder Geometry
316     // Inputs:
317     //    none.
318     // Outputs:
319     //    none.
320     // Retrurn:
321     //    none.
322     Double_t lon,lat,psi;
323     //
324     TCanvas *c3;
325     if(!(c3 = (TCanvas*)gROOT->FindObject("C3")))
326         c3 = new TCanvas("C3","ITS SDD Cylinder Geometry",900,450);
327     c3->Divide(2,1);
328     TGeoVolume *SDD=0;
329     TGeoNode *node;
330     TArrow *arrow=new TArrow();
331     //
332     node = fITS->FindNode("ITSsddCentCylCF_1");
333     SDD = node->GetVolume();
334     Double_t Rmin = ((TGeoTube*)(SDD->GetShape()))->GetRmin();
335     Double_t Rmax = ((TGeoTube*)(SDD->GetShape()))->GetRmax();
336     Double_t Dz   = ((TGeoTube*)(SDD->GetShape()))->GetDz();
337     //
338     fmgr->SetNsegments(fNsegments);
339     //
340     fmgr->SetVisLevel(6);
341     fmgr->SetVisOption(0);
342     //
343     lon = fLongitude;
344     lat = fLatitude;
345     psi = fPsi;
346     fLongitude = 270.0; // Front
347     fLatitude  =  90.0;
348     fPsi       =   0.0;
349     Displaying(SDD,c3,1);
350     arrow->DrawArrow(1.01*Rmax,-Dz,1.01*Rmax,+Dz);
351     //
352     fLongitude = 270.0; // Top
353     fLatitude  =   0.0;
354     fPsi       =   0.0;
355     Displaying(SDD,c3,2);
356     arrow->DrawArrow(Rmax,0.0,Rmax,0.0);
357     Double_t s = TMath::Sin(0.7),c = TMath::Cos(0.7);
358     arrow->DrawArrow(-Rmin*c,-Rmin*s,Rmin*c,Rmin*s);
359     //
360     fLongitude = lon;
361     fLatitude  = lat;
362     fPsi       = psi;
363 }
364 //----------------------------------------------------------------------
365 void DisplayITSv11::EngineeringSupRB24(){
366     // Display SDD Cylinder Geometry
367     // Inputs:
368     //    none.
369     // Outputs:
370     //    none.
371     // Retrurn:
372     //    none.
373     Double_t lon,lat,psi;
374     //
375     TCanvas *c4;
376     if(!(c4 = (TCanvas*)gROOT->FindObject("C4")))
377         c4 = new TCanvas("C4","ITS SDD Cylinder Geometry",900,450);
378     c4->Divide(2,1);
379     TGeoVolume *SUPRB24=0;
380     TGeoNode *node;
381          //TArrow *arrow=new TArrow();
382     //
383     node = fITS->FindNode("ITSsupFrameM24_1");
384     SUPRB24 = node->GetVolume();
385     //
386     fmgr->SetNsegments(fNsegments);
387     //
388     fmgr->SetVisLevel(6);
389     fmgr->SetVisOption(0);
390     //
391     lon = fLongitude;
392     lat = fLatitude;
393     psi = fPsi;
394     fLongitude = 270.0; // Front
395     fLatitude  =  90.0;
396     fPsi       =   0.0;
397     Displaying(SUPRB24,c4,1);
398     //
399     fLongitude = 270.0; // Top
400     fLatitude  =   0.0;
401     fPsi       =   0.0;
402     Displaying(SUPRB24,c4,2);
403     //
404     fLongitude = lon;
405     fLatitude  = lat;
406     fPsi       = psi;
407 }
408
409 //----------------------------------------------------------------------
410 void DisplayITSv11::EngineeringSupRB26(){
411     // Display SDD Cylinder Geometry
412     // Inputs:
413     //    none.
414     // Outputs:
415     //    none.
416     // Retrurn:
417     //    none.
418     Double_t lon,lat,psi;
419     //
420     TCanvas *c5;
421     if(!(c5 = (TCanvas*)gROOT->FindObject("C5")))
422         c5 = new TCanvas("C5","ITS SDD Cylinder Geometry",900,450);
423     c5->Divide(2,1);
424     TGeoVolume *SUPRB26=0;
425     TGeoNode *node;
426          //TArrow *arrow=new TArrow();
427     //
428     node = fITS->FindNode("ITSsupFrameM26_1");
429     SUPRB26 = node->GetVolume();
430     //
431     fmgr->SetNsegments(fNsegments);
432     //
433     fmgr->SetVisLevel(6);
434     fmgr->SetVisOption(0);
435     //
436     lon = fLongitude;
437     lat = fLatitude;
438     psi = fPsi;
439     fLongitude = 270.0; // Front
440     fLatitude  =  90.0;
441     fPsi       =   0.0;
442     Displaying(SUPRB26,c5,1);
443     //
444     fLongitude = 270.0; // Top
445     fLatitude  =   0.0;
446     fPsi       =   0.0;
447     Displaying(SUPRB26,c5,2);
448     //
449     fLongitude = lon;
450     fLatitude  = lat;
451     fPsi       = psi;
452 }