StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StarFromWeb.C
1 //*-- Author : Valery Fine 26/03/99 (E-mail: fine@bnl.gov)
2 // $Id: StarFromWeb.C,v 1.6 2005/05/02 16:55:33 fine Exp $
3 // $Log: StarFromWeb.C,v $
4 // Revision 1.6 2005/05/02 16:55:33 fine
5 // fix T=Star Geometry test
6 //
7 // Revision 1.5 2005/04/29 21:37:35 fine
8 // fix the table library test
9 //
10 // Revision 1.4 2000/04/07 17:07:08 fine
11 // adjusted to the ROOT 2.24
12 //
13 // Revision 1.3 1999/05/21 15:33:53 kathy
14 // made sure Log & Id are in each file and also put in standard comment line with name of owner
15 //
16 // Revision 1.2 1999/03/29 19:17:54 fine
17 // x3d view has been activated. Some improvement as well
18 //
19 //=======================================================================
20 // owner: Valery fine
21 // what it does: Shows the various view of the STAR geometry
22 //=======================================================================
23 void StarFromWeb(const char *geomFile ="/afs/rhic.bnl.gov/star/users/fine/WWW/star_year_2a.root")
24 {
25  // To run this example one needs the access to Internet
26  // To start this example launch ROOT as follows:
27  //
28  //*-* root.exe StarFromWeb.C
29  //
30 
31  // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/WebStar.gif"> </P> End_Html //
32 
33  cout << " Loading share library" << endl;
34  Bool_t NT=kFALSE;
35  if (strcmp(gSystem->GetName(),"WinNT") == 0 ) NT=kTRUE;
36  if (NT) gSystem->Load("Table");
37  else gSystem->Load("libTable");
38  if (!gGeometry) new TGeometry;
39 
40  // Create canvas
41 
42  cout << " Creating an empty TCanvas object to draw in" << endl;
43  TCanvas &starCanvas = *(new TCanvas("STAR","Star",400,600));
44 
45  Int_t PadColumns = 2;
46  Int_t PadRows = 2;
47  starCanvas.Divide(PadColumns,PadRows);
48 
49  // Open remote Webfile
50  cout << " Open the remote Web file with STAR geometry database in ROOT format" << endl;
51  // TWebFile f("http://www.rhic.bnl.gov/~fine/star_year_2a.root");
52  TFile f(geomFile);
53  // read STAR geometry database remotely
54  cout << " Reading STAR geometry database (the full size of this database 28K bytes - ROOT-object" << endl;
55  TDataSetIter volume(HALL);
56  volume.Cd("HALL/CAVE");
57 
58  const Char_t *parts[] = {"TPCE"
59  ,"MAGP"
60  ,"CALB/RICH/SRIC"
61  ,"UPST" };
62  const Int_t numParts = sizeof(parts)/sizeof(void *);
63  cout << numParts << " different parts of the STAR detector will be built" << endl;
64 
65  for (Int_t i =0; i< numParts; i++) {
66  const Char_t *part = parts[i];
67  cout << "Drawing \"" << part << "\"" << endl;
68  TVolume *vol = (TVolume *)volume(part);
69  starCanvas.cd(i+1);
70  if (vol) vol->Draw();
71  else printf(" Volume \"%s\" was not found\n", part);
72  gPad->Update();
73  }
74 
75  Int_t ThreeDPart = 2;
76  cout << " Plot 3D view of the " << ThreeDPart << " part: " << parts[ThreeDPart-1] << endl <<
77  " Note: Under Windows NT OpenGL will be used by default instead x3d for UNIX" << endl <<
78  " ================================================================" << endl <<
79  " Select x3d windows and type \"m\" in there to get x3d HELP windows" << endl <<
80  " ================================================================" << endl <<
81  " DON NOT FORGET to type \"q\" letter to terminate x3d widget and" << endl <<
82  " to continue this session" << endl <<
83  " ================================================================" << endl;
84  starCanvas.cd(ThreeDPart);
85  gPad->x3d();
86 
87  cout << "Drawing ROOT TBrowser" << endl;
88  new TBrowser("STAR",HALL);
89  cout << "Now. Try yourself:" << endl <<
90  " 1. Select any STAR geometry TVolume object with \"double-left-mouse click\" on the TVolumePosition" << endl <<
91  " TVolume object has no \";<n>\" in its name." << endl <<
92  " The objects with trail \";<n>\" are TVolumePosition ones" << endl <<
93  " 2. Pop the context menu up with \"right-mouse click\" on the ROOT browser" << endl <<
94  " 3. Select \"Draw\" position" << endl <<
95  " 4. Click OK" << endl;
96  cout << " Get this macro form $(STAR)/StRoot/macro/StarFromWeb.C and customize it for fun" << endl;
97 
98 
99 
100 }
virtual TDataSet * Cd(const Char_t *dirname)
virtual void Draw(Option_t *depth="3")
Definition: TVolume.cxx:433