00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024 #include <iostream>
00025 using namespace std;
00026
00027 #include <TMultiGraph.h>
00028 #include <TClonesArray.h>
00029 #include <TGTab.h>
00030 #include <TGCanvas.h>
00031 #include <TApplication.h>
00032 #include <TGComboBox.h>
00033 #include <TGTextEntry.h>
00034 #include <TGTextBuffer.h>
00035 #include <TGButton.h>
00036 #include <TGLabel.h>
00037 #include <TGListBox.h>
00038 #include <TGraph.h>
00039 #include <TCanvas.h>
00040 #include <TGMenu.h>
00041 #include <TGFileDialog.h>
00042 #include <TFile.h>
00043 #include <TGeoManager.h>
00044 #include <TLegend.h>
00045 #include <TH1F.h>
00046
00047 #include "MessageService/MsgService.h"
00048 #include "G3PTSim/TGeant3/TGeant3.h"
00049 #include "ParticleTransportSim/Gui/PTGui.h"
00050 #include "ParticleTransportSim/Gui/PTGuiMainFrame.h"
00051 #include "ParticleTransportSim/Gui/PTGuiMaterial.h"
00052 #include "ParticleTransportSim/Gui/PTGuiMedium.h"
00053 #include "ParticleTransportSim/Gui/PTGuiRollGMinos.h"
00054 #include "ParticleTransportSim/Gui/PTGuiRollG3.h"
00055
00056 ClassImp(PTGuiMainFrame)
00057
00058 CVSID("$Id: PTGuiMainFrame.cxx,v 1.7 2007/08/28 23:37:37 schubert Exp $");
00059
00060 static const char *gOpenTypes[] = { "ROOT files", "*.root",
00061 "All files", "*",
00062 0, 0 };
00063
00064
00065
00066
00067
00068 PTGuiMainFrame::PTGuiMainFrame(const TGWindow* p, UInt_t w, UInt_t n) :
00069 TGMainFrame(p,w,n), fL10KENbin(1000), fL10KEmin(-5.),
00070 fL10KEmax(1.),fCurrentPTParticle(0),
00071 fCurrentPTMechanism(0),fMediumFrame(0),fMediumCombo(0),
00072 fMaterialFrame(0),fProcessFrame(0),fCutFrame(0),
00073 fParticleCombo(0),fMechanismCombo(0),fPlotButton(0),
00074 fMultiGraph(0),fPTGuiRollG3(0),fPTGuiRollGMinos(0) {
00075
00076
00077
00078
00079 for ( Int_t igeo = 0; igeo < 2; igeo++ ) {
00080 fCurrentPTGuiMedium[igeo] = 0;
00081 fProcessLB[igeo] = 0;
00082 fCutLB[igeo] = 0;
00083 for ( int ie = 0; ie < 6; ie++ ) fMaterialTextE[ie][igeo] = 0;
00084 for ( int ie = 0; ie < 9; ie++ ) fMediumTextE[ie][igeo] = 0;
00085 }
00086 for ( Int_t ib = 0; ib < 3; ib++ ) fL10KETextB[ib] = 0;
00087
00088
00089
00090 TGMenuBar* menuBar = new TGMenuBar(this,1,1,kHorizontalFrame);
00091
00092
00093 AddFrame(menuBar,
00094 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1));
00095
00096
00097 TGPopupMenu* menuFile = new TGPopupMenu(gClient->GetRoot());
00098 menuFile -> AddEntry("&Open...",kFileOpen);
00099 menuFile -> AddEntry("&Close Browser",kFileCloseBrowser);
00100 menuFile -> AddEntry("&QuitRoot",kFileQuit);
00101 menuFile -> Associate(this);
00102 menuBar -> AddPopup("File",menuFile,
00103 new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
00104
00105
00106
00107
00108 TGTab* tabmgr = new TGTab(this,400,400);
00109 AddFrame(tabmgr,
00110 new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY,
00111 2, 2, 5, 1));
00112
00113
00114 BuildMediumFrame(tabmgr);
00115 BuildMaterialFrame(tabmgr);
00116 BuildProcessFrame(tabmgr);
00117 BuildCutFrame(tabmgr);
00118 BuildXSecFrame(tabmgr);
00119
00120
00121 SetWindowName("PT Browser");
00122
00123 MapSubwindows();
00124
00125 Resize(GetDefaultSize());
00126
00127 MapWindow();
00128
00129
00130 fPTGuiRollG3 = new PTGuiRollG3();
00131 AddComboMedia();
00132 Update();
00133
00134 }
00135
00136
00137 PTGuiMainFrame::~PTGuiMainFrame() {
00138
00139
00140
00141
00142
00143
00144 }
00145
00146
00147 void PTGuiMainFrame::Plot() {
00148
00149
00150 if ( fCurrentPTMechanism < 0 || fCurrentPTMechanism > PTGui::kNMechanism )
00151 return;
00152 if ( fCurrentPTParticle < 0 || fCurrentPTParticle > PTGui::kNParticle )
00153 return;
00154
00155
00156 Int_t imate = fCurrentPTGuiMedium[0]->IdMat();
00157 if ( imate < 0 ) return;
00158
00159
00160 Float_t* L10tkin = new Float_t[fL10KENbin];
00161 Float_t* tkin = new Float_t[fL10KENbin];
00162 Float_t* value = new Float_t[fL10KENbin];
00163 Float_t* pcut = new Float_t[fL10KENbin];
00164 Float_t de = (fL10KEmax-fL10KEmin)/fL10KENbin;
00165 for ( UInt_t ie = 0; ie < fL10KENbin; ie++ ) {
00166 L10tkin[ie] = fL10KEmin + Float_t(ie)*de;
00167 tkin[ie] = pow((Float_t) 10.,L10tkin[ie]);
00168 value[ie] = 0.;
00169 pcut[ie] = 0.;
00170 }
00171
00172
00173 TGTextLBEntry* textE = dynamic_cast<TGTextLBEntry*>
00174 (fMechanismCombo->GetListBox()->GetEntry(fCurrentPTMechanism));
00175 std::string mechname = textE->GetText()->GetString();
00176
00177 UInt_t imech = textE->GetUniqueID();
00178 std::string descname = PTGui::kDescMechanism[imech];
00179
00180 Int_t ipart = fCurrentPTParticle + 1;
00181 std::string graphname = PTGui::kLabelParticle[ipart-1] + " "
00182 + mechname + " (" + descname + ") "
00183 + std::string(fCurrentPTGuiMedium[0]->GetName());
00184
00185 if ( fMultiGraph ) {
00186
00187 delete fMultiGraph; fMultiGraph = 0;
00188 }
00189
00190 TCanvas* c1 = new TCanvas("c1"," ",400,10,1000,700);
00191 TLegend* lgd = new TLegend(0.7,0.8,0.89,0.89);
00192
00193 fMultiGraph = new TMultiGraph();
00194 fMultiGraph -> SetTitle(graphname.c_str());
00195
00196 if ( mechname != "ALL XSEC" ) {
00197 Int_t ixst = 0;
00198 char* mechch = const_cast<char*>(mechname.c_str());
00199 ((TGeant3*) gMC) -> Gftmat(imate,ipart,mechch,
00200 (Int_t)fL10KENbin,tkin, value, pcut, ixst);
00201
00202 if ( ixst ) {
00203
00204
00205 TGraph* graph = new TGraph(fL10KENbin,L10tkin,value);
00206
00207 graph->SetFillColor(42);
00208 graph->SetMarkerColor(4);
00209 graph->SetMarkerStyle(21);
00210 graph->SetMarkerSize(0.4);
00211 fMultiGraph->Add(graph);
00212 lgd -> AddEntry(graph,"PTSim","PL");
00213
00214
00215 if ( fCurrentPTGuiMedium[1] ) {
00216
00217 Int_t igminosmate = fCurrentPTGuiMedium[1]->IdMat();
00218 TGraph* gminosgraph
00219 = fPTGuiRollGMinos->GetGraph(igminosmate,ipart,imech+1);
00220 if ( gminosgraph ) {
00221 gminosgraph->SetMarkerStyle(21);
00222 gminosgraph->SetMarkerSize(0.3);
00223 fMultiGraph -> Add(gminosgraph);
00224 lgd -> AddEntry(gminosgraph,"GMinos","PL");
00225
00226 }
00227 }
00228
00229 fMultiGraph->Draw("AP");
00230 lgd->Draw();
00231 fMultiGraph->GetHistogram()->GetXaxis()
00232 ->SetTitle("Log10(Kinetic Energy (GeV))");
00233
00234 if ( mechname == "RANG" || mechname == "STEP") {
00235 fMultiGraph -> GetHistogram() -> SetYTitle("Distance (cm)");
00236 }
00237 else if ( mechname == "LOSS" ) {
00238 fMultiGraph -> GetHistogram() -> SetYTitle("dE/dX (MeV/cm)");
00239 }
00240 else {
00241 fMultiGraph -> GetHistogram() -> GetYaxis()
00242 -> SetTitle("Macroscopic X-Section (1/cm)");
00243 }
00244
00245 Double_t minimum = pow(10,log10(graph->GetHistogram()->GetMaximum())-4.);
00246 minimum = TMath::Min(minimum,1.e-4);
00247 fMultiGraph -> GetHistogram() -> SetMinimum(minimum);
00248 fMultiGraph -> GetHistogram()->SetAxisRange(fL10KEmin,fL10KEmax,"X");
00249
00250 if ( mechname != "LOSS" ) c1->SetLogy();
00251 c1->Update();
00252 c1->Modified();
00253
00254 }
00255
00256 }
00257 else {
00258
00259
00260
00261 Int_t nent = fMechanismCombo->GetNumberOfEntries();
00262
00263 TLegend* lgd = new TLegend(0.6,0.7,0.89,0.89);
00264 Int_t nmech = 0;
00265 for ( Int_t ient = 0; ient < nent; ient++ ) {
00266 TGTextLBEntry* combotextE = dynamic_cast<TGTextLBEntry*>
00267 (fMechanismCombo->GetListBox()->GetEntry(ient));
00268 std::string combomechname = combotextE->GetText()->GetString();
00269 UInt_t icombomech = combotextE -> GetUniqueID();
00270 std::string combodescname = PTGui::kDescMechanism[icombomech];
00271 if ( combomechname == "RANG" || combomechname == "STEP" ||
00272 combomechname == "LOSS" || combomechname == "ALL XSEC" ) continue;
00273 Int_t ipart = fCurrentPTParticle + 1;
00274
00275 Int_t imate = fCurrentPTGuiMedium[0]->IdMat();
00276 char* combomechch = const_cast<char*>(combomechname.c_str());
00277 Int_t ixst = 0;
00278 ((TGeant3*) gMC) -> Gftmat(imate,ipart,combomechch,
00279 (Int_t)fL10KENbin,tkin, value, pcut, ixst);
00280 nmech++;
00281
00282 TGraph* combograph = new TGraph(fL10KENbin,L10tkin,value);
00283 combograph->SetFillColor(42);
00284 Int_t icolor = 1+nmech;
00285 if ( icolor >= 10 ) icolor++;
00286 combograph->SetMarkerColor(icolor);
00287 combograph->SetLineColor(icolor);
00288 combograph->SetMarkerStyle(21);
00289 combograph->SetMarkerSize(0.4);
00290 fMultiGraph -> Add(combograph);
00291
00292
00293 if ( fCurrentPTGuiMedium[1] ) {
00294 Int_t igminosmate = fCurrentPTGuiMedium[1]->IdMat();
00295 TGraph* gminosgraph
00296 = fPTGuiRollGMinos->GetGraph(igminosmate,ipart,icombomech+1);
00297 if ( gminosgraph ) {
00298 gminosgraph->SetMarkerStyle(21);
00299 gminosgraph->SetMarkerSize(0.3);
00300 fMultiGraph -> Add(gminosgraph);
00301 }
00302 }
00303 std::string combographname = combomechname + " (" + combodescname + ")";
00304 lgd -> AddEntry(combograph,combographname.c_str(),"PL");
00305 }
00306 fMultiGraph -> Draw("AP");
00307 lgd -> Draw();
00308 fMultiGraph -> GetHistogram()->GetYaxis()
00309 -> SetTitle("Macroscopic X-Section (1/cm)");
00310 fMultiGraph -> GetHistogram()->GetXaxis()
00311 -> SetTitle("Log10(Kinetic Energy (GeV))");
00312 Double_t minimum
00313 = pow(10,log10(fMultiGraph->GetHistogram()->GetMaximum())-4.);
00314 minimum = TMath::Min(minimum,1.e-4);
00315 fMultiGraph -> GetHistogram()->SetMinimum(minimum);
00316 fMultiGraph -> GetHistogram()->SetAxisRange(fL10KEmin,fL10KEmax,"X");
00317 c1 -> Update();
00318 c1 -> Modified();
00319 c1 -> SetLogy();
00320 }
00321
00322
00323
00324 delete [] L10tkin;
00325 delete [] tkin;
00326 delete [] value;
00327 delete [] pcut;
00328
00329 }
00330
00331
00332 Bool_t PTGuiMainFrame::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) {
00333
00334
00335 switch ( GET_MSG(msg) ) {
00336
00337 case kC_TEXTENTRY:
00338
00339 switch ( GET_SUBMSG(msg) ) {
00340 case kTE_TEXTCHANGED:
00341 switch (parm1) {
00342 case kTextL10KENbin:
00343 fL10KENbin = (Int_t)atof(fL10KETextB[0]->GetString());
00344 break;
00345 case kTextL10KEmin:
00346 fL10KEmin = atof(fL10KETextB[1]->GetString());
00347 break;
00348 case kTextL10KEmax:
00349 fL10KEmax = atof(fL10KETextB[2]->GetString());
00350 break;
00351 }
00352 }
00353 break;
00354
00355 case kC_COMMAND:
00356 switch ( GET_SUBMSG(msg) ) {
00357 case kCM_BUTTON:
00358 switch(parm1) {
00359 case 1:
00360 Plot();
00361 break;
00362
00363 default:
00364 break;
00365 }
00366 break;
00367
00368 case kCM_COMBOBOX:
00369 switch(parm1) {
00370
00371 case kComboMedium:
00372
00373 fCurrentPTGuiMedium[0]=(PTGuiMedium*)
00374 (fPTGuiRollG3->GetMedia()->UncheckedAt(Int_t(parm2)));
00375 Update();
00376 break;
00377
00378 case kComboParticle:
00379
00380 fCurrentPTParticle = Int_t(parm2);
00381 UpdateMechanismCombo();
00382 break;
00383
00384 case kComboMechanism:
00385
00386 fCurrentPTMechanism = Int_t(parm2);
00387 break;
00388
00389 default:
00390 break;
00391
00392 }
00393 break;
00394
00395 case kCM_MENU:
00396 switch(parm1) {
00397
00398 case kFileOpen:
00399
00400 OpenGMinosFile();
00401 break;
00402
00403 case kFileCloseBrowser:
00404
00405 CloseWindow();
00406
00407 break;
00408
00409 case kFileQuit:
00410
00411 gApplication->Terminate(0);
00412 break;
00413
00414 default:
00415 break;
00416
00417 }
00418 break;
00419
00420 default:
00421 break;
00422
00423 }
00424
00425 default:
00426 break;
00427
00428 }
00429
00430 return kTRUE;
00431
00432 }
00433
00434
00435 void PTGuiMainFrame::Update() {
00436
00437
00438 if ( !fCurrentPTGuiMedium[0] ) {
00439 Int_t nmed = fPTGuiRollG3 -> GetMedia() -> GetEntriesFast();
00440 if ( nmed > 0 ) fCurrentPTGuiMedium[0] = dynamic_cast<PTGuiMedium*>
00441 (fPTGuiRollG3 -> GetMedia() -> At(0));
00442 }
00443 if ( fPTGuiRollGMinos) fCurrentPTGuiMedium[1]=
00444 (fPTGuiRollGMinos->GetMedium(fCurrentPTGuiMedium[0]->GetName()));
00445
00446 UpdateList();
00447 UpdateCombo();
00448
00449 }
00450
00451
00452 void PTGuiMainFrame::UpdateCombo() {
00453
00454
00455 UpdateMechanismCombo();
00456
00457 }
00458
00459
00460 void PTGuiMainFrame::UpdateList() {
00461
00462
00463 for ( int igeo = 0; igeo < 2; igeo++ ) {
00464 UpdateMediumList(igeo);
00465 UpdateMaterialList(igeo);
00466 UpdateProcessList(igeo);
00467 UpdateCutList(igeo);
00468 }
00469
00470 }
00471
00472
00473 void PTGuiMainFrame::OpenGMinosFile() {
00474
00475
00476
00477 static TString dir(".");
00478 TGFileInfo fi;
00479 fi.fFileTypes = gOpenTypes;
00480 fi.fIniDir = StrDup(dir);
00481 new TGFileDialog(fClient->GetDefaultRoot(),this,kFDOpen,&fi);
00482 if (!fi.fFilename) return;
00483 dir = fi.fIniDir;
00484 if ( fPTGuiRollGMinos ) {
00485
00486 MSG("PTGui",Msg::kInfo) << "Closing existing gminos file " << endl;
00487 delete fPTGuiRollGMinos; fPTGuiRollGMinos = 0;
00488 }
00489
00490 TFile* file = new TFile(fi.fFilename,"update");
00491 if ( !(file -> IsOpen()) || (file -> IsZombie()) ) {
00492 MSG("PTGui",Msg::kWarning) << "Unable to open file "
00493 << file->GetName() << endl;
00494 delete file; file = 0;
00495 return;
00496 }
00497
00498
00499 fPTGuiRollGMinos = new PTGuiRollGMinos(file);
00500 BuildMediumCombo(1);
00501 BuildMaterialList(1);
00502 BuildCutList(1);
00503 BuildProcessList(1);
00504 MapSubwindows();
00505 Resize(GetDefaultSize());
00506 MapWindow();
00507
00508 Update();
00509
00510 }
00511
00512
00513
00514 void PTGuiMainFrame::UpdateProcessList(Int_t igeo) {
00515
00516
00517 if ( !fProcessLB[igeo] || !fCurrentPTGuiMedium[igeo] ) return;
00518
00519 fProcessLB[igeo] -> RemoveEntries(0,PTGui::kNProcess-1);
00520 for ( Int_t ip = 0; ip < PTGui::kNProcess; ip++ ) {
00521 Float_t pflag = fCurrentPTGuiMedium[igeo]->Process(ip);
00522 char tmp[20];
00523 sprintf(tmp,"%6s%5d",(PTGui::kLabelProcess[ip]).c_str(),(Int_t)pflag);
00524 fProcessLB[igeo]->AddEntry(tmp,ip);
00525 }
00526
00527 fProcessLB[igeo]->MapSubwindows();
00528 fProcessLB[igeo]->Layout();
00529
00530 }
00531
00532
00533 void PTGuiMainFrame::UpdateCutList(Int_t igeo) {
00534
00535
00536 if ( !fCutLB[igeo] || !fCurrentPTGuiMedium[igeo] ) return;
00537
00538 fCutLB[igeo] -> RemoveEntries(0,PTGui::kNCut-1);
00539 for ( Int_t ic = 0; ic < PTGui::kNCut; ic++ ) {
00540 Float_t cut = fCurrentPTGuiMedium[igeo]->Cut(ic);
00541 char tmp[20];
00542 sprintf(tmp,"%6s%10.3e",(PTGui::kLabelCut[ic]).c_str(),cut);
00543 fCutLB[igeo]->AddEntry(tmp,ic);
00544 }
00545
00546 fCutLB[igeo]->MapSubwindows();
00547 fCutLB[igeo]->Layout();
00548
00549 }
00550
00551
00552 void PTGuiMainFrame::UpdateMaterialList(Int_t igeo) {
00553
00554
00555 PTGuiMedium* med = fCurrentPTGuiMedium[igeo];
00556 if ( !med ) return;
00557
00558 Int_t imat = med->IdMat();
00559 std::string matname = "<null>";
00560 Float_t a = -1;
00561 Float_t z = -1;
00562 Float_t dens = -1;
00563 Float_t radl = -1;
00564 Float_t absl = -1;
00565 if ( imat >= 0 ) {
00566 PTGuiMaterial* ptmat = 0;
00567 if ( igeo == 0 ) ptmat = dynamic_cast<PTGuiMaterial*>
00568 (fPTGuiRollG3->GetMaterials()->At(imat-1));
00569 else ptmat = dynamic_cast<PTGuiMaterial*>
00570 (fPTGuiRollGMinos->GetMaterials()->At(imat-1));
00571
00572 matname = ptmat->GetName();
00573 a = ptmat->A();
00574 z = ptmat->Z();
00575 dens = ptmat->Density();
00576 radl = ptmat->RadLen();
00577 absl = ptmat->IntLen();
00578 }
00579
00580 char buf[20];
00581
00582 sprintf(buf, "%20s", matname.c_str());
00583 fMaterialTextE[0][igeo]->GetBuffer()->Clear();
00584 fMaterialTextE[0][igeo]->GetBuffer()->AddText(0, buf);
00585 gClient->NeedRedraw(fMaterialTextE[0][igeo]);
00586
00587 sprintf(buf, "%20.3e", a);
00588 fMaterialTextE[1][igeo]->GetBuffer()->Clear();
00589 fMaterialTextE[1][igeo]->GetBuffer()->AddText(0, buf);
00590 gClient->NeedRedraw(fMaterialTextE[1][igeo]);
00591
00592 sprintf(buf, "%20.3e", z);
00593 fMaterialTextE[2][igeo]->GetBuffer()->Clear();
00594 fMaterialTextE[2][igeo]->GetBuffer()->AddText(0, buf);
00595 gClient->NeedRedraw(fMaterialTextE[2][igeo]);
00596
00597 sprintf(buf, "%20.3e", dens);
00598 fMaterialTextE[3][igeo]->GetBuffer()->Clear();
00599 fMaterialTextE[3][igeo]->GetBuffer()->AddText(0, buf);
00600 gClient->NeedRedraw(fMaterialTextE[3][igeo]);
00601
00602 sprintf(buf, "%20.3e", radl);
00603 fMaterialTextE[4][igeo]->GetBuffer()->Clear();
00604 fMaterialTextE[4][igeo]->GetBuffer()->AddText(0, buf);
00605 gClient->NeedRedraw(fMaterialTextE[4][igeo]);
00606
00607 sprintf(buf, "%20.3e", absl);
00608 fMaterialTextE[5][igeo]->GetBuffer()->Clear();
00609 fMaterialTextE[5][igeo]->GetBuffer()->AddText(0, buf);
00610 gClient->NeedRedraw(fMaterialTextE[5][igeo]);
00611
00612
00613 }
00614
00615
00616 void PTGuiMainFrame::UpdateMediumList(Int_t igeo) {
00617
00618
00619 if ( !fCurrentPTGuiMedium[igeo] ) return;
00620
00621 std::string medName = fCurrentPTGuiMedium[igeo]->GetName();
00622 Int_t imed = fCurrentPTGuiMedium[igeo]->Id();
00623 Int_t isvol = fCurrentPTGuiMedium[igeo]->Isvol();
00624 Int_t ifield = fCurrentPTGuiMedium[igeo]->Ifield();
00625 Float_t fieldm = fCurrentPTGuiMedium[igeo]->Fieldm();
00626 Float_t tmaxfd = fCurrentPTGuiMedium[igeo]->Tmaxfd();
00627 Float_t stemax = fCurrentPTGuiMedium[igeo]->Stemax();
00628 Float_t deemax = fCurrentPTGuiMedium[igeo]->Deemax();
00629 Float_t epsil = fCurrentPTGuiMedium[igeo]->Epsil();
00630 Float_t stmin = fCurrentPTGuiMedium[igeo]->Stmin();
00631
00632 if ( igeo == 0 )fMediumCombo->Select(imed-1);
00633 char buf[20];
00634
00635 int itxt = 0;
00636 sprintf(buf,"%20s",medName.c_str());
00637 fMediumTextE[itxt][igeo]->GetBuffer()->Clear();
00638 fMediumTextE[itxt][igeo]->GetBuffer()->AddText(0,buf);
00639 gClient->NeedRedraw(fMediumTextE[itxt][igeo]);
00640
00641 itxt++;
00642 sprintf(buf, "%20i", isvol);
00643 fMediumTextE[itxt][igeo]->GetBuffer()->Clear();
00644 fMediumTextE[itxt][igeo]->GetBuffer()->AddText(0, buf);
00645 gClient->NeedRedraw(fMediumTextE[itxt][igeo]);
00646
00647 itxt++;
00648 sprintf(buf, "%20i", ifield);
00649 fMediumTextE[itxt][igeo]->GetBuffer()->Clear();
00650 fMediumTextE[itxt][igeo]->GetBuffer()->AddText(0, buf);
00651 gClient->NeedRedraw(fMediumTextE[itxt][igeo]);
00652
00653 itxt++;
00654 sprintf(buf, "%20.3e", fieldm);
00655 fMediumTextE[itxt][igeo]->GetBuffer()->Clear();
00656 fMediumTextE[itxt][igeo]->GetBuffer()->AddText(0, buf);
00657 gClient->NeedRedraw(fMediumTextE[itxt][igeo]);
00658
00659 itxt++;
00660 sprintf(buf, "%20.3e", tmaxfd);
00661 fMediumTextE[itxt][igeo]->GetBuffer()->Clear();
00662 fMediumTextE[itxt][igeo]->GetBuffer()->AddText(0, buf);
00663 gClient->NeedRedraw(fMediumTextE[itxt][igeo]);
00664
00665 itxt++;
00666 sprintf(buf, "%20.3e", stemax);
00667 fMediumTextE[itxt][igeo]->GetBuffer()->Clear();
00668 fMediumTextE[itxt][igeo]->GetBuffer()->AddText(0, buf);
00669 gClient->NeedRedraw(fMediumTextE[itxt][igeo]);
00670
00671 itxt++;
00672 sprintf(buf, "%20.3e", deemax);
00673 fMediumTextE[itxt][igeo]->GetBuffer()->Clear();
00674 fMediumTextE[itxt][igeo]->GetBuffer()->AddText(0, buf);
00675 gClient->NeedRedraw(fMediumTextE[itxt][igeo]);
00676
00677 itxt++;
00678 sprintf(buf, "%20.3e", epsil);
00679 fMediumTextE[itxt][igeo]->GetBuffer()->Clear();
00680 fMediumTextE[itxt][igeo]->GetBuffer()->AddText(0, buf);
00681 gClient->NeedRedraw(fMediumTextE[itxt][igeo]);
00682
00683 itxt++;
00684 sprintf(buf, "%20.3e", stmin);
00685 fMediumTextE[itxt][igeo]->GetBuffer()->Clear();
00686 fMediumTextE[itxt][igeo]->GetBuffer()->AddText(0, buf);
00687 gClient->NeedRedraw(fMediumTextE[itxt][igeo]);
00688
00689
00690 }
00691
00692
00693
00694 void PTGuiMainFrame::UpdateMechanismCombo() {
00695
00696
00697
00698 if ( !fCurrentPTGuiMedium[0] ) return;
00699
00700 fMechanismCombo->RemoveAll();
00701
00702
00703
00704
00705 Float_t tkin[1] = {1.};
00706 Float_t value[1] = {0};
00707 Float_t pcut[1] = {0};
00708
00709 Int_t nmech = 0;
00710 for ( Int_t imech = 0; imech < PTGui::kNMechanism-1; imech++ ) {
00711 Int_t ipart = fCurrentPTParticle + 1;
00712
00713
00714 Int_t imate = fCurrentPTGuiMedium[0]->IdMat();
00715 std::string mechname = PTGui::kLabelMechanism[imech];
00716 char* mechstr = const_cast<char*>(mechname.c_str());
00717
00718 Int_t ixst = 0;
00719 ((TGeant3*) gMC) -> Gftmat(imate,ipart,mechstr,1,tkin, value, pcut, ixst);
00720
00721 if ( ixst > 0 ) {
00722 fMechanismCombo->AddEntry((PTGui::kLabelMechanism[imech]).c_str(),nmech);
00723 TGTextLBEntry* textE = dynamic_cast<TGTextLBEntry*>
00724 (fMechanismCombo->GetListBox()->GetEntry(nmech));
00725 textE->SetUniqueID(imech);
00726 nmech++;
00727 }
00728
00729 }
00730
00731 fCurrentPTMechanism = -1;
00732 if ( nmech > 0 ) {
00733
00734 fMechanismCombo->AddEntry(
00735 (PTGui::kLabelMechanism[PTGui::kNMechanism-1]).c_str(),nmech);
00736 TGTextLBEntry* textE = dynamic_cast<TGTextLBEntry*>
00737 (fMechanismCombo->GetListBox()->GetEntry(nmech));
00738 textE->SetUniqueID(PTGui::kNMechanism-1);
00739 fMechanismCombo->Select(0);
00740 fCurrentPTMechanism = 0;
00741 }
00742
00743
00744 }
00745
00746
00747 void PTGuiMainFrame::AddComboMedia() {
00748
00749
00750 TClonesArray* medArray = fPTGuiRollG3->GetMedia();
00751 Int_t nent = medArray->GetEntriesFast();
00752
00753 for ( Int_t ient = 0; ient < nent; ient++ ) {
00754 PTGuiMedium* medium = dynamic_cast<PTGuiMedium*>(medArray->At(ient));
00755 fMediumCombo->AddEntry(medium->GetName(),ient);
00756 fMediumCombo->Select(ient);
00757 fMediumCombo->Resize(200,20);
00758 }
00759
00760 }
00761
00762
00763 void PTGuiMainFrame::BuildMaterialFrame(TGTab* tabmgr) {
00764
00765
00766 TGCompositeFrame* tabF = tabmgr->AddTab("Material");
00767
00768
00769 fMaterialFrame = new TGCompositeFrame(tabF,60,20,kHorizontalFrame);
00770
00771 tabF -> AddFrame(fMaterialFrame,
00772 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
00773
00774 BuildMaterialList();
00775
00776 }
00777
00778
00779 void PTGuiMainFrame::BuildMaterialList(Int_t igeo) {
00780
00781
00782
00783 TGCompositeFrame *vF
00784 = new TGCompositeFrame(fMaterialFrame,60,20,kVerticalFrame);
00785 fMaterialFrame -> AddFrame(vF,
00786 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
00787
00788 TGLayoutHints* textL1 = new TGLayoutHints(kLHintsTop | kLHintsExpandY,
00789 5, 5, 5, 5);
00790 TGLayoutHints* textL2 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX);
00791
00792 const Int_t npar = 6;
00793 std::string labelText[npar] = {
00794 "Material Name ",
00795 "Atomic Weight ",
00796 "Atomic Number ",
00797 "Density ",
00798 "Radiation Length ",
00799 "Absorption Length"
00800 };
00801 for ( Int_t ipar=0; ipar < npar; ipar++ ) {
00802 TGHorizontalFrame* textF
00803 = new TGHorizontalFrame(vF,400,100,kFixedWidth);
00804 vF -> AddFrame(textF,textL1);
00805 fMaterialTextE[ipar][igeo]
00806 = new TGTextEntry(textF,new TGTextBuffer(20),ipar);
00807 fMaterialTextE[ipar][igeo] -> Associate(this);
00808 textF->AddFrame(new TGLabel(textF,(labelText[ipar]).c_str()),
00809 textL2);
00810 textF->AddFrame(fMaterialTextE[ipar][igeo],textL2);
00811 }
00812
00813 }
00814
00815
00816 void PTGuiMainFrame::BuildMediumFrame(TGTab* tabmgr) {
00817
00818
00819
00820 TGCompositeFrame *tabF = tabmgr->AddTab("Media");
00821
00822
00823
00824
00825
00826 fMediumFrame = new TGCompositeFrame(tabF,60,20,kHorizontalFrame);
00827
00828 tabF -> AddFrame(fMediumFrame,
00829 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
00830
00831
00832 fMediumCombo = new TGComboBox(fMediumFrame,kComboMedium);
00833 fMediumFrame -> AddFrame(fMediumCombo,
00834 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
00835
00836 BuildMediumCombo();
00837
00838 }
00839
00840
00841 void PTGuiMainFrame::BuildMediumCombo(Int_t igeo) {
00842
00843
00844
00845
00846
00847 TGCompositeFrame *vF
00848 = new TGCompositeFrame(fMediumFrame,60,20,kVerticalFrame);
00849 fMediumFrame -> AddFrame(vF,
00850 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
00851
00852 TGLayoutHints* textL1 = new TGLayoutHints(kLHintsTop | kLHintsExpandY,
00853 5, 5, 5, 5);
00854 TGLayoutHints* textL2 = new TGLayoutHints(kLHintsLeft | kLHintsExpandX);
00855
00856 const Int_t npar = 9;
00857 std::string labelText[npar] = {
00858 "Medium Name ",
00859 "Sensitivity Flag ",
00860 "Magnetic Field Flag ",
00861 "Maximum Field ",
00862 "Max. Ang. Deviation ",
00863 "Maximum Step ",
00864 "Max. Frac. Energy Loss",
00865 "Crossing Precision ",
00866 "Minimum Step Size "
00867 };
00868
00869 for ( Int_t ipar=0; ipar < npar; ipar++ ) {
00870 TGHorizontalFrame* textF
00871 = new TGHorizontalFrame(vF,400,100,kFixedWidth);
00872 vF -> AddFrame(textF,textL1);
00873 fMediumTextE[ipar][igeo] = new TGTextEntry(textF,new TGTextBuffer(20),ipar);
00874 fMediumTextE[ipar][igeo] -> Associate(this);
00875 textF->AddFrame(new TGLabel(textF,(labelText[ipar]).c_str()),
00876 textL2);
00877 textF->AddFrame(fMediumTextE[ipar][igeo],textL2);
00878 }
00879
00880 fMediumCombo -> Resize(200,20);
00881 fMediumCombo -> Associate(this);
00882
00883
00884 }
00885
00886
00887 void PTGuiMainFrame::BuildProcessFrame(TGTab* tabmgr) {
00888
00889
00890 TGCompositeFrame *tabF = tabmgr->AddTab("Processes");
00891
00892
00893
00894
00895
00896 fProcessFrame = new TGCompositeFrame(tabF,60,20,kHorizontalFrame);
00897
00898 TGLayoutHints *mainL=new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
00899 tabF -> AddFrame(fProcessFrame,mainL);
00900
00901 BuildProcessList();
00902
00903 }
00904
00905
00906 void PTGuiMainFrame::BuildProcessList(Int_t igeo) {
00907
00908
00909 fProcessLB[igeo] = new TGListBox(fProcessFrame,1);
00910 fProcessFrame -> AddFrame(fProcessLB[igeo],
00911 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
00912
00913 fProcessLB[igeo] -> Resize(150,350);
00914 fProcessLB[igeo] -> Associate(this);
00915
00916 }
00917
00918
00919 void PTGuiMainFrame::BuildCutFrame(TGTab* tabmgr) {
00920
00921
00922 TGCompositeFrame *tabF = tabmgr->AddTab("Cuts");
00923
00924
00925 fCutFrame = new TGCompositeFrame(tabF,60,20,kHorizontalFrame);
00926
00927 TGLayoutHints *mainL=new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
00928 tabF -> AddFrame(fCutFrame,mainL);
00929
00930 BuildCutList();
00931
00932 }
00933
00934
00935 void PTGuiMainFrame::BuildCutList(Int_t igeo) {
00936
00937
00938 fCutLB[igeo] = new TGListBox(fCutFrame,1);
00939 fCutFrame -> AddFrame(fCutLB[igeo],
00940 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
00941
00942 fCutLB[igeo] -> Resize(150,350);
00943 fCutLB[igeo] -> Associate(this);
00944
00945 }
00946
00947
00948 void PTGuiMainFrame::BuildXSecFrame(TGTab* tabmgr) {
00949
00950
00951 TGCompositeFrame *tabF = tabmgr->AddTab("dE/dX and X-Sections");
00952
00953
00954 TGCompositeFrame* mainF = new TGCompositeFrame(tabF,60,20,kHorizontalFrame);
00955 TGLayoutHints *mainL=new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
00956 tabF -> AddFrame(mainF,mainL);
00957
00958
00959
00960 TGCompositeFrame* partF = new TGCompositeFrame(mainF,60,20,kVerticalFrame);
00961 mainF -> AddFrame(partF,mainL);
00962
00963
00964 fParticleCombo = new TGComboBox(partF,kComboParticle);
00965 partF -> AddFrame(fParticleCombo,mainL);
00966 for ( Int_t ipart = 0; ipart < PTGui::kNParticle; ipart++ ) {
00967 fParticleCombo->AddEntry((PTGui::kLabelParticle[ipart]).c_str(),ipart);
00968 }
00969
00970 fParticleCombo->Select(0);
00971 fParticleCombo->Resize(100,20);
00972 fParticleCombo->Associate(this);
00973 fCurrentPTParticle = 0;
00974
00975
00976 TGCompositeFrame* mechF = new TGCompositeFrame(mainF,60,20,kVerticalFrame);
00977 mainF -> AddFrame(mechF,mainL);
00978
00979
00980 fMechanismCombo = new TGComboBox(mechF,kComboMechanism);
00981 mechF -> AddFrame(fMechanismCombo,mainL);
00982
00983
00984 for ( Int_t imech = 0; imech < PTGui::kNMechanism; imech++ ) {
00985 fMechanismCombo->AddEntry((PTGui::kLabelMechanism[imech]).c_str(),imech);
00986 }
00987
00988 fMechanismCombo->Select(0);
00989 fMechanismCombo->Resize(100,20);
00990 fMechanismCombo->Associate(this);
00991
00992
00993 fL10KETextB[0] = new TGTextBuffer(10);
00994 TGTextEntry* keTextE0=new TGTextEntry(partF,fL10KETextB[0],
00995 kTextL10KENbin);
00996 fL10KETextB[0] -> AddText(0,"1000");
00997 keTextE0 -> Associate(this);
00998
00999 fL10KETextB[1] = new TGTextBuffer(10);
01000 TGTextEntry* keTextE1=new TGTextEntry(partF,fL10KETextB[1],
01001 kTextL10KEmin);
01002 fL10KETextB[1] -> AddText(0,"-5");
01003 keTextE1 -> Associate(this);
01004
01005 fL10KETextB[2] = new TGTextBuffer(10);
01006 TGTextEntry* keTextE=new TGTextEntry(partF,fL10KETextB[2],
01007 kTextL10KEmax);
01008 fL10KETextB[2] -> AddText(0,"1");
01009 keTextE -> Associate(this);
01010
01011 TGLabel* keLabel
01012 = new TGLabel(partF,"Nbins,L10(KEmin),L10(KEmax) (GeV)");
01013 TGLayoutHints* keL = new TGLayoutHints(kLHintsLeft | kLHintsExpandX);
01014 partF->AddFrame(keLabel,keL);
01015 partF->AddFrame(keTextE0,keL);
01016 partF->AddFrame(keTextE1,keL);
01017 partF->AddFrame(keTextE,keL);
01018
01019
01020 TGCompositeFrame* plotF = new TGCompositeFrame(mainF,60,20,kHorizontalFrame);
01021 mainF -> AddFrame(plotF,mainL);
01022 fPlotButton = new TGTextButton(plotF,"Plot",1);
01023 fPlotButton -> Associate(this);
01024 plotF -> AddFrame(fPlotButton);
01025
01026 }
01027
01028
01029 void PTGuiMainFrame::CloseWindow() {
01030
01031
01032
01033
01034
01035 TGMainFrame::CloseWindow();
01036
01037 }
01038