]>
Commit | Line | Data |
---|---|---|
ab2f6604 | 1 | /**********************************************/ |
2 | /* */ | |
3 | /* FILE: geotest.C */ | |
4 | /* PURPOSE: To "experiment" with geometric's */ | |
5 | /* databases and ROOT. */ | |
6 | /* LANGUAGE: C++ */ | |
7 | /* COMPILER: CC for HP-UX 9.x and 10. */ | |
8 | /* AUTHOR: Joana && David */ | |
9 | /* DATE: December 2, 1998 */ | |
10 | /* ADDRESS: jesanto@cern.ch, dcollado@cern.ch */ | |
11 | /* */ | |
12 | /**********************************************/ | |
13 | ||
14 | geotest () { | |
15 | gSystem->Load("./libGEODB"); | |
16 | AliGBox* box1 = new AliGBox("box1", "box1", 0.2, 0.2, 0.2); | |
17 | AliGMaterial *mat1 = new AliGMaterial("mat1", "mat1", 2.3,4.5,6.7); | |
18 | AliGNode *node1 = new AliGNode("Node1", 1, "My first node", box1, mat1 ); | |
19 | ||
20 | AliGBox* box2 = new AliGBox("box2", "box2", 0.3,0.3,0.3); | |
21 | ||
22 | AliGTube* tube = new AliGTube("tube", "tube", 0.150,0.200,0.400); | |
23 | AliGMaterial *mat2 = new AliGMaterial("mat2", "mat2", 1.3,7.5,8.7); | |
24 | AliGNode *node2 = new AliGNode("Node2", 2, "My second node", /*tube*/ box2, mat2); | |
25 | ||
26 | //AliGBox* box3 = new AliGBox("box3", "box3", 3.0,2.0,4.0); | |
27 | AliGSphere* sphere = new AliGSphere("sphere", "sphere", 0.25); | |
28 | AliGMaterial *mat3 = new AliGMaterial("mat3", "mat3", 0.3,3.5,2.7); | |
29 | //AliGNode *node3 = new AliGNode("Node3", 3, "My third node", box3, mat3); | |
30 | AliGNode *node3 = new AliGNode("Node3", 3, "My third node", sphere, mat3); | |
31 | ||
32 | //AliGBox* box4 = new AliGBox("box4", "box4", 4.0,2.0,6.0); | |
33 | AliGCone* cone = new AliGCone("cone", "cone", 0.05,0.07,0.12,0.15,0.1); | |
34 | AliGMaterial *mat4 = new AliGMaterial("mat4", "mat4", 0.4,3.2,8.7); | |
35 | //AliGNode *node4 = new AliGNode("Node4", 4, "My fourth node", box4, mat4); | |
36 | AliGNode *node4 = new AliGNode("Node4", 4, "My fourth node", cone, mat4); | |
37 | ||
38 | AliGTransform *tran1 = new AliGTransform("tran1","tran1","tra 1. 0. 0."); | |
39 | AliGTransform *tran2 = new AliGTransform("tran2","tran2","tra 0.5 0. 0."); | |
40 | AliGTransform *tran3 = new AliGTransform("tran3","tran3","tra 0.25 0. 0."); | |
41 | ||
42 | node1->Add(node2,tran1); // TUBE | |
43 | node1->Add(node2,tran2);// | |
44 | node1->Add(node3,tran1);// | |
45 | node1->Add(node3,tran2); // SPHERE | |
46 | node2->Add(node4,tran1);// | |
47 | node2->Add(node4,tran2); // CONE | |
48 | node2->Add(node4,tran3);// | |
49 | ||
50 | node1->AddConfig("config1","config1","coarse",981201,991201); | |
51 | node2->AddConfig("config2","config2","detail",981201,991201); | |
52 | node3->AddConfig("config3","config3","",981201,991201); | |
53 | node4->AddConfig("config4","config4","",981201,991201); | |
54 | ||
55 | AliGeometry* geom1 = new AliGeometry( "geom1", "geom1", node1, 0 ); /* Build geometry in memory from Node1 */ | |
56 | ||
57 | TFile* file = new TFile( "AliGeoDB.root", "RECREATE","Alice Geometry Database"); | |
58 | ||
59 | node1->SaveAll( file ); /* Memory tree structure saved in disk */ | |
60 | ||
61 | ||
62 | file->Close(); | |
63 | ||
64 | TFile* file = new TFile( "AliGeoDB.root", "UPDATE" ); | |
65 | ||
66 | AliGeometry* geom1 = new AliGeometry( "geom1", "geom1", node1, 0 ); /* Build geometry in memory from Node1 */ | |
67 | ||
68 | geom1->Write(); /* Save geometry in disk */ | |
69 | file->Write(); | |
70 | ||
71 | file->Close(); /* Everything saved in disk */ | |
72 | file = new TFile("AliGeoDB.root","read"); | |
73 | a = TBrowser() ; | |
74 | printf( " The end of geotest.C \n" ); | |
75 | ||
76 | //if( geom1 ) delete geom1; | |
77 | //if( node4 ) delete node4; | |
78 | //if( node3 ) delete node3; | |
79 | //if( node2 ) delete node2; | |
80 | //if( node1 ) delete node1; | |
81 | ||
82 | ||
83 | ||
84 | //AliGeometry* geom3 = new AliGeometry(); | |
85 | ||
86 | /* Retrieve the memory tree structure from AliGeoDB.root and stores it in memory, being new_tree the top node */ | |
87 | //AliGNode* tree_root = new AliGNode(geom3->FileToMemTree( "AliGeoDB.root", "geom1" )); | |
88 | ||
89 | //TFile* file2 = new TFile( "AliGeoDB2.root", "RECREATE","Alice Geometry Database"); | |
90 | //tree_root->SaveAll( file2 ); /* Memory tree structure saved in disk (second time) */ | |
91 | ||
92 | ||
93 | //TFile* file = new TFile( "AliGeoDB.root", "READ" ); | |
94 | ||
95 | //AliGeometry* geom2 = new AliGeometry((AliGeometry*) file->Get("geom1")); | |
96 | //file->Close(); | |
97 | //file2->cd(); | |
98 | //geom2.Write(); | |
99 | //file2->Write(); | |
100 | //file2->Close(); | |
101 | ||
102 | //gROOT->Reset(); | |
103 | //file3 = new TFile( "AliGeoDB.root", "READ" ); | |
104 | //file4 = new TFile( "AliGeoDB2.root", "READ" ); | |
105 | //a = TBrowser(); | |
106 | ||
107 | //gPad->Update(); | |
108 | ||
109 | ||
110 | ||
111 | ||
112 | ||
113 | ||
114 | ||
115 | ||
116 | ||
117 | /* AliGNode *obj; | |
118 | ||
119 | TIter next(gPad->GetListOfPrimitives()); | |
120 | while (obj = (AliGNode*)next()) { | |
121 | if(obj.GetShape()->Is3D()) { | |
122 | obj.GetShape()->Sizeof3D(); | |
123 | printf("\n It is a 3D Object\n"); | |
124 | printf("Total size of x3d primitives:\n"); | |
125 | Size3D size = obj.GetShape()->GetSize3D(); | |
126 | printf(" gSize3D.numPoints=%d\n", size.numPoints); | |
127 | //printf(" gSize3D.numSegs =%d\n", gPad->gSize3D.numSegs); | |
128 | //printf(" gSize3D.numPolys =%d\n", gSize3D.numPolys); | |
129 | } | |
130 | else | |
131 | printf("\n It's not a 3D Object\n"); | |
132 | } | |
133 | ||
134 | gPad->x3d();*/ | |
135 | ||
136 | /* | |
137 | c1 = new TCanvas("c1","Common Shapes.",0,0,1202,846); | |
138 | c1->Range(0,0,1,1); | |
139 | c1->SetFillColor(32); // Light Green | |
140 | c1->SetBorderSize(3); | |
141 | c1->SetBorderMode(0); // -1 (down) 0 (no) 1 (up) | |
142 | ||
143 | // Create a TitleBar in Main Window | |
144 | title = new TPaveLabel(0.3,0.93,0.7,0.98,"View Of Different Shapes"); | |
145 | title->SetFillColor(34); // Grey | |
146 | title->Draw(); | |
147 | ||
148 | // Text for Pads | |
149 | TText *t = new TText(); | |
150 | t->SetTextFont(32); // Light Green | |
151 | t->SetTextColor(1); // Black | |
152 | t->SetTextSize(0.03); | |
153 | t->DrawText( 0.19, 0.89, "AliGBox" ); | |
154 | t->DrawText( 0.70, 0.89, "AliGSphere" ); | |
155 | t->DrawText( 0.19, 0.43, "AliGTube" ); | |
156 | t->DrawText( 0.70, 0.43, "AliGCone" ); | |
157 | ||
158 | // Define and Draw Pads of Main Window | |
159 | Pad1 = new TPad("Pad1","AliGBox Shape",0.05,0.48,0.45,0.88,28); | |
160 | Pad1->SetFillColor(34); // Grey | |
161 | Pad2 = new TPad("Pad2","AliGSphere Shape",0.55,0.48,0.95,0.88,28); | |
162 | Pad2->SetFillColor(34); // Grey | |
163 | Pad3 = new TPad("Pad3","AliGTube Shape",0.05,0.02,0.45,0.42,28); | |
164 | Pad3->SetFillColor(34); // Grey | |
165 | Pad4 = new TPad("Pad4","AliGCone Shape",0.55,0.02,0.95,0.42,28); | |
166 | Pad4->SetFillColor(34); // Grey | |
167 | Pad1->Draw(); | |
168 | Pad2->Draw(); | |
169 | Pad3->Draw(); | |
170 | Pad4->Draw(); | |
171 | ||
172 | // Define some volumes | |
173 | AliGTube* tube = new AliGTube("tube", "tube", 150,200,400); | |
174 | AliGCone* cone = new AliGCone("cone", "cone", 50,70,120,100,150); | |
175 | AliGSphere* sphere = new AliGSphere("sphere", "sphere", 75); | |
176 | AliGThorus* thorus = new AliGThorus("thorus", "thorus", 150,200,400); | |
177 | ||
178 | // Set shapes attributes | |
179 | box1->SetLineColor(2); // Red | |
180 | sphere->SetLineColor(4); // Blue | |
181 | tube->SetLineColor(3); // Bright Green | |
182 | cone->SetLineColor(5); // Yellow | |
183 | thorus->SetLineColor(2); // Red | |
184 | ||
185 | // Draw inside Pad1 | |
186 | Pad1->cd(); // Set current pad | |
187 | box1->Draw(); | |
188 | ||
189 | // Draw inside Pad2 | |
190 | Pad2->cd(); //Set current Pad | |
191 | sphere->Draw(); | |
192 | ||
193 | // Draw inside Pad3 | |
194 | Pad3->cd(); //Set current Pad | |
195 | tube->Draw(); | |
196 | ||
197 | // Draw inside Pad4 | |
198 | Pad4->cd(); //Set current Pad | |
199 | cone->Draw(); | |
200 | ||
201 | c1->cd(); | |
202 | c1->Update(); // Update Canvas | |
203 | */ | |
204 | } | |
205 | ||
206 | ||
207 |