StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SandBox.C
1 class AgModule;
2 class Geometry;
3 //
4 Geometry *builder = 0;
5 
6 void SandBox(Bool_t closeGeo = true, Bool_t draw = true ) {
7  printf("\nIN SAND_BOX: closeGeo=%d draw=%d\n",closeGeo,draw);
8  gSystem -> Load (".$STAR_HOST_SYS/lib/libStarAgmlLib.so");
9  gSystem -> Load (".$STAR_HOST_SYS/lib/libStarGeometry.so");
10  gSystem -> Load (".$STAR_HOST_SYS/lib/libGeometry.so");
11 
12  // Setup code to create ROOT/TGeo geometry
13  AgBlock::SetStacker( new StarTGeoStacker() );
14 
15  // Create the geometry builder
16  builder = new Geometry();
17 
18  // Setup the sandbox environment
19  playground();
20 
21  // Create the SandBox geometry
22  builder -> ConstructGeometry("SandBox");
23 
24  // Add the FGT to the playground
25  ConstructFgtd();
26 
27  // Close the geometry in preparation to draw it
28  if(closeGeo) gGeoManager -> CloseGeometry();
29 
30  // Apply a different color scheme
31  ColorScheme();
32 
33  // Make different bits and pieces invisible
34  Invisibles();
35 
36  // And set the maximum visible depth
37  gGeoManager -> SetVisLevel(10);
38 
39  // And visualize with the OpenGL viewer
40  if (draw)
41  gGeoManager -> GetTopVolume() -> Draw("ogl");
42  //gGeoManager -> GetTopVolume() -> Draw();
43 
44  // export this geometry
45  // gGeoManager GetTopVolume() ->Write("myFgtGeom.C");
46  // I could use:
47 
48 
49 }
54 void playground()
55 {
56 
57  Geom_t geom;
58  geom.select = "SandBox"; {
59 
60  // on/off what I want to see
61  geom.sconFlag = "SCON13"; geom.sconStat = 0;
62  geom.tpceFlag = "TPCE04"; geom.tpceStat = 0;
63  geom.btofFlag = "BTOFc6"; geom.btofStat = 0;
64  geom.calbFlag = "CALB02"; geom.calbStat = 0;
65 
66  geom.vpddFlag = "VPDD07"; geom.vpddStat = 0;
67  geom.ftpcFlag = "FTPC01"; geom.ftpcStat = 0;
68  geom.svttFlag = "SVTTof"; geom.svttStat = 0;
69  geom.phmdFlag = "PHMDof"; geom.phmdStat = 0;
70 
71  geom.ftroFlag = "FTRO01"; geom.ftroStat = 0;
72  geom.mutdFlag = "MUTD03"; geom.mutdStat = 0;
73 
74  geom.sisdFlag = "SISDof"; geom.sisdStat = 0;
75  geom.ecalFlag = "ECALv6"; geom.ecalStat = 0;
76  geom.fpdmFlag = "FPDM03"; geom.fpdmStat = 0;
77 
78  geom.bbcmFlag = "BBCMon"; geom.bbcmStat = 0;
79  geom.caveFlag = "CAVE04"; geom.caveStat = 1;
80  geom.pipeFlag = "PIPE06"; geom.pipeStat = 1;
81  geom.fgtdFlag = "FGTDon"; geom.fgtdStat = 1;
82  geom.fgtdFlag = "FGMOon"; geom.fgtdStat = 0;
83  geom.magpFlag = "MAGPon"; geom.magpStat = 0;
84 
85  geom.closeGeometry = false;
86 
87  geom.SetTitle("STAR Geometry SanBox");
88  geom.fill();
89  }
90 
91 
92 }
97 Bool_t ConstructFgtd()
98 {
99 
100  // Prepare the interface to the structures defined
101  // within the FgtdGeo.xml
102  AgStructure::AgDetpNew( "FgtdGeo3", "Forward Gem Tracker Configuration" );
103 
104  // Here you can change the values assigned to the data structures
105  // inside of the geometry module. i.e. you can change the FGTG
106  // structure members with the following call...
107  AgStructure::AgDetpAdd( "Fgtg_t", "configjan", (float)2 );
108  // where the second arguement is the name of the member all in
109  // lower case and the third arguement is the value taken.
110  // Note that the compiler is picky, and you need to make sure
111  // that you pass in the right type for the third arguemnt.
112  //
113  // If you need to change an array, you would create an instance
114  // of Array_t... e.g.
115  //
116  // Array_t<float> a(2); a[0]=1; a[1]=2;
117  // AgDetpAdd("Fgtd_t", "array", a);
118 
119  builder -> CreateModule( "FgtdGeo3" );
120 
121 }
122 
124 //
125 // Integration with GeomBrowse.C
126 //
127 TDataSet *CreateTable()
128 {
129 
130  // We won't be drawing things ourself
131  draw = false;
132 
133  // Create the geometry
134  SandBox();
135 
136  TObjectSet *mygeom = 0;
137  if (gGeoManager) {
138  mygeom = new TObjectSet("Geometry",gGeoManager,kFALSE);
139  mygeom->SetTitle("Dyson");
140  }
141  return (TDataSet *) mygeom;
142 
143 }
144 
145 
150 void Invisibles()
151 {
152 
153  const Char_t *invisible[] =
154  {
155  "MAGP",
156  // "ZCAL",
157  // "UPST",
158  "TPSS",
159  "FSEN"
160  };
161 
162  TGeoVolume *volume = 0;
163  for ( UInt_t i=0;i<sizeof(invisible)/sizeof(Char_t *);i++ )
164  {
165  volume = gGeoManager->FindVolumeFast( invisible[i] );
166  if ( volume ) {
167  volume->InvisibleAll();
168  volume->SetVisDaughters(false);
169  }
170  }
171 }
172 
173 
174 void ColorScheme()
175 {
176  Int_t color_map[] = {kGray+2,1,42,kGreen+2,/*kBlue-9*/ 11,32,kBlue-9,22,8};
177  // loop over all volumes and remap the colors
178  TIter next( gGeoManager->GetListOfVolumes() );
179  while ((volume=(TGeoVolume*)next()))
180  {
181  Int_t color = volume->GetLineColor();
182  if ( color < 8 )
183  color = color_map[color];
184  volume->SetLineColor(color);
185  volume->SetFillColor(color);
186 
187  TString name=volume->GetName();
188  if ( name=="TPAD" || name=="TPA1" || name=="TPSS" )
189  {
190  volume->SetLineColor(47);
191  volume->SetFillColor(47);
192  }
193  }
194 }