]>
Commit | Line | Data |
---|---|---|
ef42d733 | 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 * | |
d9ae88d5 | 8 | * documentation strictlSy for non-commercial purposes is hereby granted * |
ef42d733 | 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 | $Log$ | |
490feb29 | 18 | Revision 1.3 2001/07/17 09:50:21 morsch |
19 | Index on media and material arrays corrected | |
20 | ||
b3aa5111 | 21 | Revision 1.2 2001/07/09 11:46:08 morsch |
22 | Conversion code moved to AliG3toRoot | |
23 | ||
d9ae88d5 | 24 | Revision 1.1 2000/07/13 16:19:10 fca |
25 | Mainly coding conventions + some small bug fixes | |
26 | ||
ef42d733 | 27 | Revision 1.8 2000/07/12 08:56:32 fca |
28 | Coding convention correction and warning removal | |
29 | ||
30 | Revision 1.7 2000/06/28 21:27:45 morsch | |
31 | Most coding rule violations corrected. | |
32 | Still to do: Split the file (on file per class) ? Avoid the global variables. | |
33 | Copy constructors and assignment operators (dummy ?) | |
34 | ||
35 | Revision 1.6 2000/04/14 11:07:46 morsch | |
36 | Correct volume to medium assignment in case several media are asigned to the | |
37 | same material. | |
38 | ||
39 | Revision 1.5 2000/03/20 15:11:03 fca | |
40 | Mods to make the code compile on HP | |
41 | ||
42 | Revision 1.4 2000/01/18 16:12:08 morsch | |
43 | Bug in calculation of number of volume divisions and number of positionings corrected | |
44 | Browser for Material and Media properties added | |
45 | ||
46 | Revision 1.3 1999/11/14 14:31:14 fca | |
47 | Correct small error and remove compilation warnings on HP | |
48 | ||
49 | Revision 1.2 1999/11/10 16:53:35 fca | |
50 | The new geometry viewer from A.Morsch | |
51 | ||
52 | */ | |
53 | ||
54 | /* | |
55 | * Version: 0 | |
56 | * Written by Andreas Morsch | |
57 | * | |
58 | * | |
59 | * | |
60 | * For questions critics and suggestions to this part of the code | |
61 | * contact andreas.morsch@cern.ch | |
62 | * | |
63 | **************************************************************************/ | |
64 | ||
65 | #include <stdlib.h> | |
d9ae88d5 | 66 | #include <TArrayF.h> |
67 | #include <TGMsgBox.h> | |
68 | #include <TGMenu.h> | |
69 | #include <TGTab.h> | |
70 | #include <TGFrame.h> | |
71 | #include <TGTextBuffer.h> | |
72 | #include <TGTextEntry.h> | |
73 | #include <TGLabel.h> | |
74 | #include <TGButton.h> | |
75 | #include <TGraph.h> | |
76 | #include <TCanvas.h> | |
77 | #include <TH1.h> | |
78 | #include <TApplication.h> | |
79 | #include <TGFileDialog.h> | |
80 | #include <TGListTree.h> | |
81 | #include <TGeant3.h> | |
82 | #include <TShape.h> | |
83 | #include <TGeometry.h> | |
84 | #include <TBRIK.h> | |
85 | #include <TGeometry.h> | |
86 | #include <TList.h> | |
87 | #include <TFile.h> | |
88 | #include <TFolder.h> | |
ef42d733 | 89 | |
90 | #include "AliGuiGeomMain.h" | |
ef42d733 | 91 | #include "AliGuiGeomDialog.h" |
d9ae88d5 | 92 | #include "AliG3Volume.h" |
93 | #include "AliG3Medium.h" | |
94 | #include "AliRun.h" | |
95 | #include "AliG3Material.h" | |
96 | #include "AliNode.h" | |
97 | ||
ef42d733 | 98 | |
99 | ClassImp(AliGuiGeomMain) | |
100 | ||
101 | static Int_t gCurrentParticle = 1; | |
102 | static Int_t gCurrentProcess = 1; | |
103 | ||
104 | const Text_t* kLabelTextP[19] = | |
105 | {"PAIR ", "COMP ", "PHOT ", "PFIS ", "DRAY ", "ANNI ", "BREM ", | |
106 | "HADR ", "MUNU ", "DCAY ", "LOSS ", "MULS ", "GHCOR1", "BIRK1 ", | |
107 | "BIRK2 ", "BIRK3 ", "LABS ", "SYNC ", "STRA "}; | |
108 | ||
109 | ||
110 | const Text_t* kLabelTextC[10] = | |
111 | {"CUTGAM", "CUTELE", "CUTNEU", "CUTHAD", "CUTMUO", "BCUTE", "BCUTM", | |
112 | "DCUTE ", "DCUTM ", "PPCUTM"}; | |
113 | ||
114 | const Text_t* kLabelTextPart[24] = | |
115 | {"Photon", "Positron", "Electron", "Neutrino", "Muon+", "Muon-", | |
116 | "Pi0", "Pi+", "Pi-", "Kaon_L", "Kaon+", "Kaon-", "Neutron", "Proton", | |
117 | "Anti Proton", "Kaon_S", "Eta", "Lambda", "Sigma+", "Sigma0", "Sigma-", | |
118 | "Xi0", "Xi-", "Omega-"}; | |
119 | ||
120 | const Text_t* kLabelTextMechanism[24] = | |
121 | {"HADF", "INEF", "ELAF", "FISF", "CAPF", | |
122 | "HADG", "INEG", "ELAG", "FISG", "CAPG", | |
123 | "LOSS", "PHOT", "ANNI", "COMP", "BREM", | |
124 | "PAIR", "DRAY", "PFIS", "RAYL", "HADG", | |
125 | "MUNU", "RANG", "STEP", "MUON"}; | |
126 | ||
127 | ||
128 | ||
129 | ||
130 | enum ETestCommandIdentifiers { | |
131 | kFileOpen, | |
132 | kFileSave, | |
133 | kFileSaveAs, | |
134 | kFileExit, | |
135 | ||
136 | kTestDlg, | |
137 | ||
138 | kHelpContents, | |
139 | kHelpSearch, | |
140 | kHelpAbout, | |
141 | ||
142 | ||
143 | kVId1, | |
144 | kHId1, | |
145 | kVId2, | |
146 | kHId2, | |
147 | ||
148 | kVSId1, | |
149 | kHSId1, | |
150 | kVSId2, | |
151 | kHSId2 | |
152 | }; | |
153 | ||
154 | ||
155 | Int_t mbButtonId[9] = { kMBYes, kMBNo, kMBOk, kMBApply, | |
156 | kMBRetry, kMBIgnore, kMBCancel, | |
157 | kMBClose, kMBDismiss }; | |
158 | ||
159 | EMsgBoxIcon mbIcon[4] = { kMBIconStop, kMBIconQuestion, | |
160 | kMBIconExclamation, kMBIconAsterisk }; | |
161 | ||
162 | const char *kFileTypes[] = { "All files", "*", | |
163 | "ROOT files", "*.root", | |
164 | "ROOT macros", "*.C", | |
165 | 0, 0 }; | |
166 | ||
167 | ||
168 | ||
169 | ||
170 | TGListTreeItem* AliGuiGeomMain:: | |
171 | AddItem(TObject * obj, TGListTreeItem *parent, const char* name, const TGPicture *open, const TGPicture *closed) | |
172 | { | |
173 | // Add item to the list tree | |
174 | return fLt->AddItem(parent, name, obj, open, closed); | |
175 | } | |
176 | ||
177 | AliGuiGeomMain::AliGuiGeomMain(const TGWindow *p, UInt_t w, UInt_t h) | |
178 | : TGMainFrame(p, w, h) | |
179 | { | |
180 | // Create test main frame. A TGMainFrame is a top level window. | |
181 | // Create menubar and popup menus. The hint objects are used to place | |
182 | // and group the different menu widgets with respect to eachother. | |
183 | ||
184 | fDialog=0; | |
185 | fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, | |
186 | 0, 0, 1, 1); | |
187 | fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0); | |
188 | fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight); | |
189 | ||
190 | fMenuFile = new TGPopupMenu(gClient->GetRoot()); | |
191 | fMenuFile->AddEntry("&Open...", kFileOpen); | |
192 | fMenuFile->AddEntry("&Save", kFileSave); | |
193 | fMenuFile->AddEntry("S&ave as...", kFileSaveAs); | |
194 | fMenuFile->AddEntry("&Close", -1); | |
195 | fMenuFile->AddSeparator(); | |
196 | fMenuFile->AddEntry("E&xit", kFileExit); | |
197 | ||
198 | fMenuFile->DisableEntry(kFileSaveAs); | |
199 | fMenuFile->DisableEntry(kFileOpen); | |
200 | fMenuFile->DisableEntry(kFileSave); | |
201 | ||
202 | ||
203 | ||
204 | fMenuTest = new TGPopupMenu(this); | |
205 | fMenuTest->AddLabel("Draw"); | |
206 | fMenuTest->AddSeparator(); | |
207 | fMenuTest->AddEntry("&Volume Draw Control", kTestDlg); | |
208 | fMenuTest->AddSeparator(); | |
209 | fMenuTest->Associate(this); | |
210 | ||
211 | ||
212 | fMenuHelp = new TGPopupMenu(gClient->GetRoot()); | |
213 | fMenuHelp->AddEntry("&Contents", kHelpContents); | |
214 | fMenuHelp->AddEntry("&Search...", kHelpSearch); | |
215 | fMenuHelp->AddSeparator(); | |
216 | fMenuHelp->AddEntry("&About", kHelpAbout); | |
217 | ||
218 | fMenuFile->DisableEntry(kHelpContents); | |
219 | fMenuFile->DisableEntry(kHelpSearch); | |
220 | fMenuFile->DisableEntry(kHelpAbout); | |
221 | // Menu button messages are handled by the main frame (i.e. "this") | |
222 | // ProcessMessage() method. | |
223 | fMenuFile->Associate(this); | |
224 | fMenuTest->Associate(this); | |
225 | fMenuHelp->Associate(this); | |
226 | ||
227 | fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame); | |
228 | fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout); | |
229 | fMenuBar->AddPopup("&Draw Control", fMenuTest, fMenuBarItemLayout); | |
230 | fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout); | |
231 | ||
232 | AddFrame(fMenuBar, fMenuBarLayout); | |
233 | ||
234 | // | |
235 | // Volumes | |
236 | // | |
237 | fTab = new TGTab(this, 400, 400); | |
238 | TGCompositeFrame *tf = fTab->AddTab("Volumes"); | |
239 | TGLayoutHints *lTab = new TGLayoutHints(kLHintsBottom | kLHintsExpandX | | |
240 | kLHintsExpandY, 2, 2, 5, 1); | |
241 | AddFrame(fTab, lTab); | |
242 | ||
243 | // Create TGCanvas and a canvas container which uses a tile layout manager | |
244 | fCanvasWindow = new TGCanvas(tf, 400, 240); | |
245 | // Create TreeList | |
246 | fLt = new TGListTree(fCanvasWindow->GetViewPort(), 10, 10, kHorizontalFrame, | |
247 | fgWhitePixel); | |
248 | fLt->Associate(this); | |
249 | fCanvasWindow->SetContainer(fLt); | |
250 | ||
251 | ||
252 | TGLayoutHints *lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY); | |
253 | tf->AddFrame(fCanvasWindow, lo); | |
254 | // | |
255 | // Materials | |
256 | // | |
257 | tf = fTab->AddTab("Materials"); | |
258 | fF2 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
259 | fL2 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5); | |
260 | // ComboBox for materials | |
261 | fMaterialCombo = new TGComboBox(fF2, 1); | |
262 | fF2->AddFrame(fMaterialCombo, fL2); | |
263 | // | |
264 | // text labels with material properties | |
265 | // | |
266 | Text_t* labelText[6] = | |
267 | {"Material Number ", | |
268 | "Atomic Weight ", | |
269 | "Atomic Number ", | |
270 | "Density ", | |
271 | "Radiation Length ", | |
272 | "Absorption Length"}; | |
273 | ||
274 | TGLayoutHints* bly = | |
275 | new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5); | |
276 | TGLayoutHints* bFly1 = | |
277 | new TGLayoutHints(kLHintsLeft | kLHintsExpandX ); | |
278 | fF21 = new TGCompositeFrame(fF2, 60, 20, kVerticalFrame); | |
279 | fF2->AddFrame(fF21,fL2); | |
280 | { //Begin local scope for i | |
281 | for (Int_t i=0; i<6; i++) { | |
282 | Int_t idT=i+1; | |
283 | fHframe[i] = new TGHorizontalFrame(fF21, 400, 100, kFixedWidth); | |
284 | fF21->AddFrame(fHframe[i], bly); | |
285 | fTbh[i] = new TGTextBuffer(10); | |
286 | fTeh[i] = new TGTextEntry(fHframe[i], fTbh[i],idT); | |
287 | fTeh[i]->Associate(this); | |
288 | fLabel[i] = new TGLabel(fHframe[i], labelText[i]); | |
289 | fHframe[i]->AddFrame(fLabel[i], bFly1); | |
290 | fHframe[i]->AddFrame(fTeh[i], bFly1); | |
291 | } | |
292 | } //End local scope for i | |
293 | tf->AddFrame(fF2, fL2); | |
294 | fMaterialCombo->Resize(200, 20); | |
295 | fMaterialCombo->Associate(this); | |
296 | ||
297 | ||
298 | // Media Combo | |
299 | // | |
300 | tf = fTab->AddTab("Media"); | |
301 | fF3 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
302 | // ComboBox for tracking media | |
303 | fMediaCombo = new TGComboBox(fF3, 2); | |
304 | fF3->AddFrame(fMediaCombo, fL2); | |
305 | // | |
306 | // text labels with material properties | |
307 | // | |
308 | Text_t* labelTextM[8] = | |
309 | {"Sensitivity Flag ", | |
310 | "Magnetic Field Flag ", | |
311 | "Maximum Field ", | |
312 | "Max. Ang. Deviation ", | |
313 | "Maximum Step ", | |
314 | "Max. Frac. Energy Loss", | |
315 | "Crossing Precission ", | |
316 | "Minimum Step Size "}; | |
317 | ||
318 | fF31 = new TGCompositeFrame(fF3, 60, 20, kVerticalFrame); | |
319 | fF3->AddFrame(fF31,fL2); | |
320 | { //Begin local scope for i | |
321 | for (Int_t i=0; i<8; i++) { | |
322 | Int_t idT=i+1; | |
323 | fHframeM[i] = new TGHorizontalFrame(fF31, 400, 100, kFixedWidth); | |
324 | fF31->AddFrame(fHframeM[i], bly); | |
325 | fTbhM[i] = new TGTextBuffer(10); | |
326 | fTehM[i] = new TGTextEntry(fHframeM[i], fTbhM[i],idT); | |
327 | fTehM[i]->Associate(this); | |
328 | fLabelM[i] = new TGLabel(fHframeM[i], labelTextM[i]); | |
329 | fHframeM[i]->AddFrame(fLabelM[i], bFly1); | |
330 | fHframeM[i]->AddFrame(fTehM[i], bFly1); | |
331 | } | |
332 | } //End local scope for i | |
333 | tf->AddFrame(fF3, fL2); | |
334 | fMediaCombo->Resize(200, 20); | |
335 | fMediaCombo->Associate(this); | |
336 | // | |
337 | // Processes | |
338 | tf = fTab->AddTab("Processes"); | |
339 | fF4 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
340 | fProcessLB = new TGListBox(fF4, 1); | |
341 | fF4->AddFrame(fProcessLB, fL2); | |
342 | tf->AddFrame(fF4, fL2); | |
343 | fProcessLB->Resize(150, 350); | |
344 | fProcessLB->Associate(this); | |
345 | ||
346 | // | |
347 | // Cuts | |
348 | tf = fTab->AddTab("Cuts"); | |
349 | fF5 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
350 | fCutsLB = new TGListBox(fF5, 1); | |
351 | fF5->AddFrame(fCutsLB, fL2); | |
352 | tf->AddFrame(fF5, fL2); | |
353 | fCutsLB->Resize(150, 350); | |
354 | ||
355 | // | |
356 | // de/dx and cross-sections | |
357 | tf = fTab->AddTab("DE/DX and X-Sections"); | |
358 | fF6 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame); | |
359 | ||
360 | // ComboBox for particles | |
361 | fF61 = new TGCompositeFrame(fF6, 60, 20, kVerticalFrame); | |
362 | fF6->AddFrame(fF61, fL2); | |
363 | fParticleCombo = new TGComboBox(fF61, 3); | |
364 | fF61->AddFrame(fParticleCombo, fL2); | |
365 | { //Begin local scope for i | |
366 | for (Int_t i = 0; i < 24; i++) { | |
367 | char tmp[20]; | |
368 | sprintf(tmp, "%s", kLabelTextPart[i]); | |
369 | fParticleCombo->AddEntry(tmp, i+1); | |
370 | } | |
371 | } //End local scope for i | |
372 | fParticleCombo->Select(1); | |
373 | fParticleCombo->Resize(100, 20); | |
374 | fParticleCombo->Associate(this); | |
375 | ||
376 | // ComboBox for mechanisms | |
377 | fF63 = new TGCompositeFrame(fF6, 60, 20, kVerticalFrame); | |
378 | fF6->AddFrame(fF63, fL2); | |
379 | fMechanismCombo = new TGComboBox(fF63, 4); | |
380 | fF63->AddFrame(fMechanismCombo, fL2); | |
381 | { //Begin local scope for i | |
382 | for (Int_t i = 0; i < 24; i++) { | |
383 | char tmp[20]; | |
384 | sprintf(tmp, "%s", kLabelTextMechanism[i]); | |
385 | fMechanismCombo->AddEntry(tmp, i+1); | |
386 | } | |
387 | } //End local scope for i | |
388 | fMechanismCombo->Select(1); | |
389 | fMechanismCombo->Resize(100, 20); | |
390 | fMechanismCombo->Associate(this); | |
391 | ||
392 | // | |
393 | // Energy Range | |
394 | // | |
395 | fTbh61 = new TGTextBuffer(10); | |
396 | fTeh61 = new TGTextEntry(fF61, fTbh61,10); | |
397 | fTbh61->AddText(0, " 100"); | |
398 | fTeh61->Associate(this); | |
399 | ||
400 | fTbh62 = new TGTextBuffer(10); | |
401 | fTeh62 = new TGTextEntry(fF61, fTbh62,11); | |
402 | fTbh62->AddText(0, "0.001"); | |
403 | fTeh62->Associate(this); | |
404 | ||
405 | fTbh63 = new TGTextBuffer(10); | |
406 | fTeh63 = new TGTextEntry(fF61, fTbh63,12); | |
407 | fTbh63->AddText(0, "10."); | |
408 | fTeh63->Associate(this); | |
409 | ||
410 | fEmin=0.001; | |
411 | fEmax=10.; | |
412 | fNbins=100; | |
413 | ||
414 | fSLabel61 = new TGLabel(fF61, "Nbins-Emin-Emax"); | |
415 | bFly1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX ); | |
416 | fF61->AddFrame(fSLabel61, bFly1); | |
417 | fF61->AddFrame(fTeh61, bFly1); | |
418 | fF61->AddFrame(fTeh62, bFly1); | |
419 | fF61->AddFrame(fTeh63, bFly1); | |
420 | // | |
421 | // Plot Button | |
422 | fF62 = new TGCompositeFrame(fF6, 60, 20, kHorizontalFrame); | |
423 | fF6->AddFrame(fF62, fL2); | |
424 | fPlotButton = new TGTextButton(fF62, "Plot", 1); | |
425 | fPlotButton -> Associate(this); | |
426 | fF62->AddFrame(fPlotButton); | |
427 | ||
428 | tf->AddFrame(fF6, fL2); | |
429 | // Window name and final mapping | |
430 | // | |
431 | SetWindowName("AliRoot Geometry Browser"); | |
432 | MapSubwindows(); | |
433 | // We need to use GetDefault...() to initialize the layout algorithm... | |
434 | Resize(GetDefaultSize()); | |
435 | MapWindow(); | |
436 | } | |
437 | ||
438 | AliGuiGeomMain::~AliGuiGeomMain() | |
439 | { | |
440 | // Delete all created widgets. | |
441 | ||
442 | delete fCanvasWindow; | |
443 | ||
444 | delete fMenuBarLayout; | |
445 | delete fMenuBarItemLayout; | |
446 | delete fMenuBarHelpLayout; | |
447 | ||
448 | delete fMenuFile; | |
449 | delete fMenuTest; | |
450 | delete fMenuHelp; | |
451 | } | |
452 | ||
453 | void AliGuiGeomMain::Streamer(TBuffer &) | |
454 | { | |
455 | // Dummy streamer | |
456 | ; | |
457 | } | |
458 | ||
459 | void AliGuiGeomMain::Plot() | |
460 | { | |
461 | // plot de/dx or cross-sections | |
462 | const Float_t kAvo=0.60221367; | |
463 | Float_t *tkin = new Float_t[fNbins]; | |
464 | Float_t *value = new Float_t[fNbins]; | |
465 | Float_t *pcut = new Float_t[fNbins]; | |
466 | Int_t ixst; | |
d9ae88d5 | 467 | Int_t imate = gCurrentMaterial->Id(); |
468 | Float_t z = gCurrentMaterial->GetZ(); | |
469 | Float_t a = gCurrentMaterial->GetA(); | |
470 | Float_t density = gCurrentMaterial->GetDensity(); | |
ef42d733 | 471 | |
472 | Int_t ipart=gCurrentParticle; | |
473 | const char *kChMeca= kLabelTextMechanism[gCurrentProcess-1]; | |
474 | char* tmp; | |
475 | tmp = new char[5]; | |
476 | strncpy(tmp, kChMeca, 4); | |
477 | tmp[4]='\0'; | |
478 | Int_t kdim=fNbins; | |
479 | Float_t de=(fEmax-fEmin)/fNbins; | |
480 | { //Begin local scope for i | |
481 | for (Int_t i=0; i<kdim; i++) { | |
482 | tkin[i]=fEmin+Float_t(i)*de; | |
483 | value[i]=0.; | |
484 | } | |
485 | } //End local scope for i | |
486 | if (kChMeca!="MUON") { | |
487 | ((TGeant3*) gMC)->Gftmat(imate, ipart, tmp, kdim, tkin, value, pcut, ixst); | |
488 | } else { | |
489 | for (Int_t i=0; i<kdim; i++) { | |
490 | Float_t ekin=tkin[i]; | |
491 | value[i]+=((TGeant3*) gMC)->Gbrelm(z,ekin,1.e10); | |
492 | value[i]+=((TGeant3*) gMC)->Gprelm(z,ekin,1.e10); | |
493 | value[i]*=1000.*kAvo*density/a; | |
494 | } | |
495 | } | |
d9ae88d5 | 496 | |
ef42d733 | 497 | if (ixst) { |
498 | TGraph *graph = new TGraph(kdim,tkin,value); | |
499 | TCanvas *c1 = new TCanvas("c1"," ",400,10,600,700); | |
500 | c1->Divide(1,1); | |
501 | c1->cd(1); | |
502 | ||
503 | graph->SetFillColor(42); | |
504 | graph->SetMarkerColor(4); | |
505 | graph->SetMarkerStyle(21); | |
506 | graph->Draw("AC"); | |
507 | graph->GetHistogram()->SetXTitle("Energy (GeV)"); | |
508 | if (kChMeca == "RANG" || kChMeca == "STEP") { | |
509 | graph->GetHistogram()->SetYTitle | |
510 | ("Distance (cm)"); | |
511 | } else if (kChMeca == "LOSS" || kChMeca == "MUON") { | |
512 | graph->GetHistogram()->SetYTitle("dE/dx (MeV/cm)"); | |
513 | } else { | |
514 | graph->GetHistogram()->SetYTitle | |
515 | ("Macroscopic X-Section (1/cm)"); | |
516 | } | |
517 | } | |
518 | ||
519 | delete tkin; | |
520 | delete value; | |
521 | delete pcut; | |
522 | ||
523 | ||
524 | } | |
525 | ||
526 | void AliGuiGeomMain::Update() | |
527 | { | |
528 | // Update widgets | |
529 | if (fDialog) { | |
530 | fDialog->Update(); | |
531 | } | |
532 | ||
533 | Int_t imat=gCurrentVolume->Material(); | |
d9ae88d5 | 534 | Int_t nmat=fComboMaterialEntries->GetEntriesFast(); |
ef42d733 | 535 | Int_t i=0; |
536 | for (i=0; i<nmat; i++) { | |
d9ae88d5 | 537 | gCurrentMaterial = (AliG3Material*) |
538 | (fComboMaterialEntries->UncheckedAt(i)); | |
539 | if ((gCurrentMaterial->Id())==imat) break; | |
ef42d733 | 540 | } |
541 | Int_t imed = gCurrentVolume->Medium(); | |
542 | Int_t nmed=fComboMediaEntries->GetEntriesFast(); | |
543 | for (i=0; i<nmed; i++) { | |
d9ae88d5 | 544 | gCurrentMedium = (AliG3Medium*) |
ef42d733 | 545 | (fComboMediaEntries->UncheckedAt(i)); |
546 | if (gCurrentMedium->Id()==imed) break; | |
547 | } | |
548 | ||
549 | UpdateCombo(); | |
550 | UpdateListBox(); | |
551 | ||
552 | } | |
553 | ||
554 | void AliGuiGeomMain::UpdateCombo() | |
555 | { | |
556 | // Update combos | |
557 | ||
558 | Int_t imat = gCurrentMaterial->Id(); | |
d9ae88d5 | 559 | Float_t a = gCurrentMaterial->GetA(); |
560 | Float_t z = gCurrentMaterial->GetZ(); | |
561 | Float_t dens = gCurrentMaterial->GetDensity(); | |
562 | Float_t radl = gCurrentMaterial->GetRadLength(); | |
563 | Float_t absl = gCurrentMaterial->GetInterLength(); | |
564 | Int_t entry = gCurrentMaterial->GetNumber(); | |
ef42d733 | 565 | // |
566 | // | |
567 | fMaterialCombo->Select(entry); | |
568 | fMediaCombo->Select(entry); | |
569 | char buf[10]; | |
570 | ||
571 | sprintf(buf, "%10i", imat); | |
572 | fTbh[0]->Clear(); | |
573 | fTbh[0]->AddText(0, buf); | |
574 | gClient->NeedRedraw(fTeh[0]); | |
575 | sprintf(buf, "%10.2e", a); | |
576 | fTbh[1]->Clear(); | |
577 | fTbh[1]->AddText(0, buf); | |
578 | gClient->NeedRedraw(fTeh[1]); | |
579 | ||
580 | sprintf(buf, "%10.2e", z); | |
581 | fTbh[2]->Clear(); | |
582 | fTbh[2]->AddText(0, buf); | |
583 | gClient->NeedRedraw(fTeh[2]); | |
584 | ||
585 | sprintf(buf, "%10.2e", dens); | |
586 | fTbh[3]->Clear(); | |
587 | fTbh[3]->AddText(0, buf); | |
588 | gClient->NeedRedraw(fTeh[3]); | |
589 | ||
590 | sprintf(buf, "%10.2e", radl); | |
591 | fTbh[4]->Clear(); | |
592 | fTbh[4]->AddText(0, buf); | |
593 | gClient->NeedRedraw(fTeh[4]); | |
594 | ||
595 | sprintf(buf, "%10.2e", absl); | |
596 | fTbh[5]->Clear(); | |
597 | fTbh[5]->AddText(0, buf); | |
598 | gClient->NeedRedraw(fTeh[5]); | |
599 | ||
600 | // Media Combo | |
601 | sprintf(buf, "%10i", gCurrentMedium->Isvol()); | |
602 | fTbhM[0]->Clear(); | |
603 | fTbhM[0]->AddText(0, buf); | |
604 | gClient->NeedRedraw(fTehM[0]); | |
605 | ||
606 | ||
607 | sprintf(buf, "%10i", gCurrentMedium->Ifield()); | |
608 | fTbhM[1]->Clear(); | |
609 | fTbhM[1]->AddText(0, buf); | |
610 | gClient->NeedRedraw(fTehM[1]); | |
611 | ||
612 | sprintf(buf, "%10.2e", gCurrentMedium->Fieldm()); | |
613 | fTbhM[2]->Clear(); | |
614 | fTbhM[2]->AddText(0, buf); | |
615 | gClient->NeedRedraw(fTehM[2]); | |
616 | ||
617 | sprintf(buf, "%10.2e", gCurrentMedium->Tmaxfd()); | |
618 | fTbhM[3]->Clear(); | |
619 | fTbhM[3]->AddText(0, buf); | |
620 | gClient->NeedRedraw(fTehM[3]); | |
621 | ||
622 | sprintf(buf, "%10.2e", gCurrentMedium->Stemax()); | |
623 | fTbhM[4]->Clear(); | |
624 | fTbhM[4]->AddText(0, buf); | |
625 | gClient->NeedRedraw(fTehM[4]); | |
626 | ||
627 | sprintf(buf, "%10.2e", gCurrentMedium->Deemax()); | |
628 | fTbhM[5]->Clear(); | |
629 | fTbhM[5]->AddText(0, buf); | |
630 | gClient->NeedRedraw(fTehM[5]); | |
631 | ||
632 | sprintf(buf, "%10.2e", gCurrentMedium->Epsil()); | |
633 | fTbhM[6]->Clear(); | |
634 | fTbhM[6]->AddText(0, buf); | |
635 | gClient->NeedRedraw(fTehM[6]); | |
636 | ||
637 | sprintf(buf, "%10.2e", gCurrentMedium->Stmin()); | |
638 | fTbhM[7]->Clear(); | |
639 | fTbhM[7]->AddText(0, buf); | |
640 | gClient->NeedRedraw(fTehM[7]); | |
641 | } | |
642 | ||
643 | void AliGuiGeomMain::UpdateListBox() | |
644 | { | |
645 | // Update the list box | |
646 | Int_t i; | |
647 | fProcessLB->RemoveEntries(1,19); | |
648 | for (i=11; i < 30; i++) { | |
649 | Float_t p=gCurrentMedium->GetPar(i); | |
650 | char tmp[20]; | |
651 | sprintf(tmp, "%6s%5d", kLabelTextP[i-11], Int_t(p)); | |
652 | fProcessLB->AddEntry(tmp, i-10); | |
653 | } | |
654 | fProcessLB->MapSubwindows(); | |
655 | fProcessLB->Layout(); | |
656 | ||
657 | fCutsLB->RemoveEntries(1,10); | |
658 | for (i=1; i < 11; i++) { | |
659 | Float_t p=gCurrentMedium->GetPar(i); | |
660 | char tmp[20]; | |
661 | sprintf(tmp, "%6s%10.3e", kLabelTextC[i-1], p); | |
662 | fCutsLB->AddEntry(tmp,i); | |
663 | } | |
664 | fCutsLB->MapSubwindows(); | |
665 | fCutsLB->Layout(); | |
666 | } | |
667 | ||
668 | ||
669 | void AliGuiGeomMain::CloseWindow() | |
670 | { | |
671 | // Got close message for this MainFrame. Calls parent CloseWindow() | |
672 | // (which destroys the window) and terminate the application. | |
673 | // The close message is generated by the window manager when its close | |
674 | // window menu item is selected. | |
675 | ||
676 | TGMainFrame::CloseWindow(); | |
677 | gApplication->Terminate(0); | |
678 | } | |
679 | ||
680 | Bool_t AliGuiGeomMain::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) | |
681 | { | |
682 | // Process messages to widgets | |
683 | switch (GET_MSG(msg)) { | |
684 | // | |
685 | // Text entries for binning of cross-section plots | |
686 | case kC_TEXTENTRY: | |
687 | switch (GET_SUBMSG(msg)) { | |
688 | case kTE_TEXTCHANGED: | |
689 | switch (parm1) { | |
690 | case 10: | |
691 | fNbins=(Int_t) atof(fTbh61->GetString()); | |
692 | break; | |
693 | case 11: | |
694 | fEmin= atof(fTbh62->GetString()); | |
695 | break; | |
696 | case 12: | |
697 | fEmax= atof(fTbh63->GetString()); | |
698 | break; | |
699 | } | |
ef42d733 | 700 | } |
701 | break; | |
702 | // | |
703 | // ListTree for volumes | |
704 | case kC_LISTTREE: | |
705 | switch (GET_SUBMSG(msg)) { | |
706 | // | |
707 | // Handle mouse click | |
708 | case kCT_ITEMCLICK: | |
709 | // | |
710 | // Button 1: Select volume | |
711 | if (parm1 == kButton1) { | |
712 | TGListTreeItem *item; | |
713 | if ((item = fLt->GetSelected())) | |
714 | { | |
d9ae88d5 | 715 | gCurrentVolume=((AliG3Volume *) item->GetUserData()); |
ef42d733 | 716 | Update(); |
717 | } | |
718 | } | |
719 | // | |
720 | // Button 2: Draw volume specifications | |
721 | ||
722 | if (parm1 == kButton2) { | |
723 | TGListTreeItem *item; | |
724 | if ((item = fLt->GetSelected())) | |
725 | { | |
726 | ||
d9ae88d5 | 727 | ((AliG3Volume *) item->GetUserData())->DrawSpec(); |
ef42d733 | 728 | |
d9ae88d5 | 729 | gCurrentVolume=((AliG3Volume *) item->GetUserData()); |
ef42d733 | 730 | Update(); |
731 | } | |
732 | } | |
733 | // | |
734 | // Button 3: Draw Volume | |
735 | if (parm1 == kButton3) { | |
736 | TGListTreeItem *item; | |
737 | if ((item = fLt->GetSelected())) | |
738 | { | |
d9ae88d5 | 739 | ((AliG3Volume *) item->GetUserData())->Draw(); |
740 | gCurrentVolume=((AliG3Volume *) item->GetUserData()); | |
ef42d733 | 741 | Update(); |
742 | } | |
743 | } | |
744 | ||
745 | ||
746 | break; | |
747 | case kCT_ITEMDBLCLICK: | |
748 | if (parm1 == kButton1) { | |
749 | if (fLt->GetSelected() != 0) { | |
750 | gClient->NeedRedraw(fLt); | |
751 | } | |
752 | } | |
753 | break; | |
754 | default: | |
755 | break; | |
756 | } | |
757 | break; | |
758 | case kC_COMMAND: | |
759 | switch (GET_SUBMSG(msg)) { | |
760 | case kCM_BUTTON: | |
761 | switch(parm1) { | |
762 | case 1: | |
763 | Plot(); | |
764 | break; | |
765 | } | |
766 | break; | |
767 | case kCM_COMBOBOX: | |
768 | // | |
769 | // Combo box bindings | |
770 | switch(parm1) { | |
771 | // | |
772 | // Material Combo | |
773 | case 1: | |
d9ae88d5 | 774 | gCurrentMaterial=(AliG3Material*) |
775 | (fComboMaterialEntries->UncheckedAt(Int_t(parm2-1))); | |
776 | gCurrentMedium=(AliG3Medium*) | |
ef42d733 | 777 | (fComboMediaEntries->UncheckedAt(Int_t(parm2-1))); |
778 | UpdateCombo(); | |
779 | UpdateListBox(); | |
780 | break; | |
781 | // | |
782 | // Media Combo | |
783 | case 2: | |
d9ae88d5 | 784 | gCurrentMedium=(AliG3Medium*) |
ef42d733 | 785 | (fComboMediaEntries->UncheckedAt(Int_t(parm2-1))); |
d9ae88d5 | 786 | gCurrentMaterial=(AliG3Material*) |
787 | (fComboMaterialEntries->UncheckedAt(Int_t(parm2-1))); | |
ef42d733 | 788 | UpdateCombo(); |
789 | UpdateListBox(); | |
790 | break; | |
791 | // | |
792 | // Particle Combo | |
793 | case 3: | |
794 | gCurrentParticle=Int_t(parm2); | |
795 | break; | |
796 | // | |
797 | // Mechanism Combo | |
798 | case 4: | |
799 | gCurrentProcess=Int_t(parm2); | |
ef42d733 | 800 | break; |
801 | } | |
802 | break; | |
803 | case kCM_MENUSELECT: | |
804 | break; | |
805 | ||
806 | case kCM_MENU: | |
807 | switch (parm1) { | |
ef42d733 | 808 | case kFileOpen: |
809 | { | |
490feb29 | 810 | printf("kFileOpen not yet implemented \n"); |
ef42d733 | 811 | } |
812 | break; | |
813 | ||
814 | case kTestDlg: | |
815 | fDialog = new AliGuiGeomDialog | |
816 | (gClient->GetRoot(), this, 400, 200); | |
817 | break; | |
818 | ||
819 | case kFileSave: | |
490feb29 | 820 | printf("kFileSave not yet implemented \n"); |
ef42d733 | 821 | break; |
822 | ||
823 | case kFileExit: | |
490feb29 | 824 | // printf("kFileExit not yet implemented \n"); |
ef42d733 | 825 | CloseWindow(); // this also terminates theApp |
826 | break; | |
827 | default: | |
828 | break; | |
829 | } | |
830 | default: | |
831 | break; | |
832 | } | |
833 | default: | |
834 | break; | |
835 | } | |
836 | return kTRUE; | |
837 | } | |
838 | ||
d9ae88d5 | 839 | void AliGuiGeomMain::AddMaterial(AliG3Material *Material, Int_t i) |
ef42d733 | 840 | { |
841 | // Add material to material combo | |
d9ae88d5 | 842 | const char* tmp; |
843 | tmp=Material->GetName(); | |
844 | char mName[21]; | |
845 | ||
846 | strncpy(mName, tmp, 20); | |
847 | mName[20]='\0'; | |
848 | ||
849 | // Material->SetItemId(i); | |
850 | fMaterialCombo->AddEntry(mName, i); | |
ef42d733 | 851 | fMaterialCombo->Select(i); |
852 | fMaterialCombo->Resize(200, 20); | |
853 | } | |
854 | ||
d9ae88d5 | 855 | void AliGuiGeomMain::AddMedium(AliG3Medium *Medium, Int_t i) |
ef42d733 | 856 | { |
857 | // Add medium to medium combo | |
d9ae88d5 | 858 | const char* tmp; |
859 | tmp=Medium->GetName(); | |
860 | char mName[21]; | |
861 | strncpy(mName, tmp, 20); | |
862 | mName[20]='\0'; | |
ef42d733 | 863 | Medium->SetItemId(i); |
d9ae88d5 | 864 | fMediaCombo->AddEntry(mName, i); |
ef42d733 | 865 | fMediaCombo->Select(i); |
866 | fMediaCombo->Resize(200, 20); | |
867 | } | |
868 | ||
d9ae88d5 | 869 | void AliGuiGeomMain::SetMaterialComboEntries(TClonesArray *entries) |
870 | { | |
871 | // Set the material combo entries | |
872 | // | |
873 | fComboMaterialEntries = entries; | |
874 | Int_t nent = fComboMaterialEntries->GetEntriesFast(); | |
875 | for (Int_t i=0; i < nent; i++) | |
876 | { | |
b3aa5111 | 877 | AddMaterial((AliG3Material*)fComboMaterialEntries->At(i), i); |
d9ae88d5 | 878 | gCurrentMaterial = (AliG3Material*)fComboMaterialEntries->At(i); |
879 | } | |
880 | } | |
881 | ||
882 | ||
883 | void AliGuiGeomMain::SetMediaComboEntries(TClonesArray *entries) | |
884 | { | |
885 | // Set the media combo entries | |
886 | // | |
887 | fComboMediaEntries = entries; | |
888 | Int_t nent = fComboMediaEntries->GetEntriesFast(); | |
889 | for (Int_t i=0; i < nent; i++) | |
890 | { | |
b3aa5111 | 891 | AddMedium((AliG3Medium*)fComboMediaEntries->At(i), i); |
d9ae88d5 | 892 | gCurrentMedium = (AliG3Medium*)fComboMediaEntries->At(i); |
893 | } | |
894 | } | |
895 | ||
896 | void AliGuiGeomMain::AddFoldersRecursively(TFolder* folder, TGListTreeItem* parent) | |
897 | { | |
898 | // Display geometry represented by TFolders in List Tree | |
899 | // | |
900 | const TGPicture* kFolder = gClient->GetPicture("folder_t.xpm"); | |
901 | const TGPicture* kOpenFolder = gClient->GetPicture("ofolder_t.xpm"); | |
902 | const TGPicture* kDocument = gClient->GetPicture("doc_t.xpm"); | |
903 | ||
904 | AliG3Volume* volume = ((AliG3Volume *) folder->FindObject(folder->GetName())); | |
905 | volume->SetItem(folder); | |
906 | ||
907 | TList* folders = (TList*) folder->GetListOfFolders(); | |
908 | TIter next(folders); | |
909 | TObject* obj; | |
910 | TGListTreeItem* nParent = 0; | |
911 | if (folders->GetSize() > 1) { | |
912 | nParent = fLt->AddItem(parent, folder->GetName(), volume, kOpenFolder, kFolder); | |
913 | } else { | |
914 | nParent = fLt->AddItem(parent, folder->GetName(), volume, kDocument, kDocument); | |
915 | } | |
916 | ||
917 | while ((obj = next())) | |
918 | { | |
919 | if ((AliG3Volume*) obj == volume) continue; | |
920 | TFolder* item = (TFolder*) obj; | |
921 | AddFoldersRecursively(item, nParent); | |
922 | } | |
923 | } | |
ef42d733 | 924 |