StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SubDetectorView.C
1 //*-- Author : Valery Fine 26/03/99 (E-mail: fine@bnl.gov)
2 // $Id: SubDetectorView.C,v 1.6 2000/04/07 17:07:09 fine Exp $
3 // $Log: SubDetectorView.C,v $
4 // Revision 1.6 2000/04/07 17:07:09 fine
5 // adjusted to the ROOT 2.24
6 //
7 // Revision 1.5 1999/06/14 08:48:35 fine
8 // Some bug fixed
9 //
10 // Revision 1.4 1999/05/21 15:33:55 kathy
11 // made sure Log & Id are in each file and also put in standard comment line with name of owner
12 //
13 // Revision 1.3 1999/05/20 19:57:08 fine
14 // some clean up and protections
15 //
16 // Revision 1.2 1999/04/08 21:12:24 fine
17 // SubDetectorView macro has been introduced
18 //
19 // Revision 1.2 1999/03/29 19:17:54 fine
20 // x3d view has been activated. Some improvement as well
21 //=======================================================================
22 // owner: Valery Fine
23 // what it does: It shows how to select some particular portions of the
24 // STAR geometry to draw it out
25 //=======================================================================
26 
27 {
28  // example to show how to generate the STAR/GEANT geometry sub-structure
29  // To run this example one needs the access to Internet
30  // To start this example launch ROOT as follows:
31  //
32  //*-* root.exe SubDetectorView.C
33  //
34 
35  // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/StarBMTC.gif"> </P> End_Html //
36 
37  gROOT->Reset();
38  printf( " Loading share library\n");
39  gSystem->Load("libSTAR");
40  if (!gGeometry) new TGeometry;
41 
42  // Open remote GEANT geometry WebFile
43  // generated by begin_html <a href=".././St_geant_Maker.html##St_geant_Maker:Work">St_geant_Maker::Work()</a> method end_html
44 
45  TWebFile f("http://www.star.bnl.gov/~fine/star_year_2a.root");
46  // read STAR geometry database remotely
47  TVolume *hall = f.Get("HALL");
48  if (!hall) {
49  printf("Sorry, STAR hall was not found !\n");
50  return;
51  }
52 
53  hall->ls();
54  TDataSetIter volume(hall);
55  TVolume *nextNode = 0;
56  // Mark the pieces of the whole detector to create sub-structure
57 
58  volume("HALL")->Mark();
59  ((TVolume *)volume("HALL"))->SetVisibility(1);
60  volume.Cd("HALL/CAVE");
61 
62  nextNode = (TVolume *)volume("SVTT/SCON");
63  if (nextNode) {
64  nextNode->Mark();
65  nextNode->SetVisibility(1);
66  }
67 
68  nextNode = (TVolume *)volume("SVTT/SCON/STAC");
69  if (nextNode) {
70  nextNode->Mark();
71  nextNode->SetVisibility(1);
72  }
73 
74 
75  nextNode = (TVolume *)volume("SVTT/SCON/SHLA/SHMA/SHWA");
76  if (nextNode) {
77  nextNode->Mark();
78  nextNode->SetVisibility(1);
79  }
80 
81  nextNode = (TVolume *)volume("SVTT/SCON/SHLB/SHMB/SHWA");
82  if (nextNode) {
83  nextNode->Mark();
84  nextNode->SetVisibility(1);
85  }
86 
87  nextNode = (TVolume *)volume("MAGP/COIL/MCSE");
88  if (nextNode) {
89  nextNode->Mark();
90  nextNode->SetVisibility(1);
91  }
92  // Mark the whole structure excluding one node
93 
94  TDataSetIter bmtc(volume("BTOF/BTOH/BSEC/BTRA/BXTR/BMTC"));
95  TVolume *node =0;
96  while( node = (TVolume *) bmtc()) {
97  if( strcmp(node->GetName(),"BXSA")) node->Mark();
98  }
99 
100  // Create the "open" structure from the "closed" one
101  TVolumeView *fullView = new TVolumeView(*hall);
102  // Create the "open" sub-structure from the full one
103  TVolumeView *s = new TVolumeView(fullView);
104 
105  TDataSetIter rangeIter(s);
106  TVolumeView *bmtcNode = rangeIter.FindByName("TPAD");
107  Float_t min[3];
108  Float_t max[3];
109  if (bmtcNode) {
110  bmtcNode->GetLocalRange(min,max);
111  printf(" Range for %s node is x: %f-%f; y: %f-%f; z: %f-%f\n",
112  bmtcNode->GetName(), min[0],max[0],min[1],max[1],min[2],max[2]);
113 
114  bmtcNode->GetGlobalRange(s,min,max);
115  printf(" Range for %s node is x: %f-%f; y: %f-%f; z: %f-%f\n",
116  s->GetName(), min[0],max[0],min[1],max[1],min[2],max[2]);
117  }
118 
119  printf( " Creating an empty TCanvas object to draw in\n");
120 
121 
122  s->Draw();
123  gPad->Update();
124 #if 0
125  TVirtualPad *thisPad = gPad;
126  TView *view = thisPad->GetView();
127  view->SetRange(min,max);
128  thisPad->Modified();
129  thisPad->Update();
130 #endif
131 }
virtual TDataSet * Cd(const Char_t *dirname)
virtual void SetVisibility(ENodeSEEN vis=TVolume::kBothVisible)
Definition: TVolume.cxx:753
virtual void GetLocalRange(Float_t *min, Float_t *max)
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
virtual TDataSet * FindByName(const Char_t *name, const Char_t *path="", Option_t *opt="")
to be documented
virtual void Draw(Option_t *depth="3")
Draw Referenced node with current parameters.
virtual Int_t GetGlobalRange(const TVolumeView *rootNode, Float_t *min, Float_t *max)