#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "scaner.h" using namespace std; MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) { // Create a main frame fMain = new TGMainFrame(p,w,h); // Create canvas widget fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,900,600); fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX| kLHintsExpandY, 10,10,10,1)); // Create a horizontal frame widget with buttons TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,900,40); FileLabel = new TGLabel(hframe,"..................................................................."); FileLabel->SetTitle("................................................................................................"); FileLabel->Set3DStyle(2); ULong_t yellow; gClient->GetColorByName("yellow", yellow); FileLabel->ChangeBackground(yellow); hframe->AddFrame(FileLabel, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // Radio Buttons for selecting Geometry TGVButtonGroup *GrpGeom = new TGVButtonGroup(hframe, "Geometry"); TGRadioButton *RadioBGeom = new TGRadioButton(GrpGeom, "Normal: Cu cooling"); new TGRadioButton(GrpGeom, "FDC 20cm Upstream"); new TGRadioButton(GrpGeom, "Normal: Al cooling"); new TGRadioButton(GrpGeom, "Old Geometry"); GrpGeom->Connect("Clicked(Int_t)", "MyMainFrame", this, "setGeomTag(Int_t)"); hframe->AddFrame(GrpGeom, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // Radio Buttons for selecting target vertex position TGVButtonGroup *sGrpFile = new TGVButtonGroup(hframe, "Target Position"); TGRadioButton *RadioBFile = new TGRadioButton(sGrpFile, "Center"); new TGRadioButton(sGrpFile, "+10cm"); new TGRadioButton(sGrpFile, "-10cm"); new TGRadioButton(sGrpFile, "-10cm cable ds"); new TGRadioButton(sGrpFile, "Center cable ds"); new TGRadioButton(sGrpFile, "+10cm cable ds"); sGrpFile->Connect("Clicked(Int_t)", "MyMainFrame", this, "openFile(Int_t)"); hframe->AddFrame(sGrpFile, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); TGVButtonGroup *selectGrp = new TGVButtonGroup(hframe, "Bining In"); TGRadioButton *RadioB = new TGRadioButton(selectGrp, "Angle"); new TGRadioButton(selectGrp, "Energy"); selectGrp->Connect("Clicked(Int_t)", "MyMainFrame", this, "HandleRadioButtons(Int_t)"); hframe->AddFrame(selectGrp, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); TGVerticalFrame *hframeInput = new TGVerticalFrame(hframe,70,40); // Angle is default at startup set it to 7 degree. InputBin[0] = new TGNumberEntry(hframeInput, 7.00, 8, -1, TGNumberFormat::kNESRealTwo ); hframeInput->AddFrame(InputBin[0], new TGLayoutHints(kLHintsCenterX,5,5,3,4)); UnitLabel = new TGLabel(hframeInput, "[deg] or [GeV]"); hframeInput->AddFrame(UnitLabel, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); hframe->AddFrame(hframeInput, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); TGTextButton *draw = new TGTextButton(hframe,"&Draw"); draw->Connect("Clicked()","MyMainFrame",this,"DoDraw()"); hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); TGTextButton *exit = new TGTextButton(hframe,"&Exit", "gApplication->Terminate(0)"); hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2)); // Set a name to the main frame fMain->SetWindowName("Scanning Photons in Angle and Energy over Gap Region"); // Map all subwindows of main frame fMain->MapSubwindows(); // Initialize the layout algorithm fMain->Resize(fMain->GetDefaultSize()); // Map main frame fMain->MapWindow(); // Set Angle bin select default RadioB->SetState((EButtonState)1,kTRUE); RadioBGeom->SetState((EButtonState)1,kTRUE); RadioBFile->SetState((EButtonState)1,kTRUE); // openFile(1); BinValueInput(); } Int_t MyMainFrame::DoDraw() { // Draws function graphics in randomly choosen interval BinValueInput(); if (RadioId==1){ if (hBcal){ hBcal->Draw(); } if (hFcal && hBcal){ hFcal->Draw("same"); } else if (hFcal && (!hBcal)){ hFcal->Draw(); } } else if (RadioId==2){ if ((hFcal)&&(!hBcal)){ hFcal->Draw(); } else if ((!hFcal)&&(hBcal)){ hBcal->Draw(); } else if (hFcal && hBcal){ hBcal->Draw(); hFcal->Draw("same"); } } gPad->SetGrid(); TCanvas *fCanvas = fEcanvas->GetCanvas(); fCanvas->cd(); fCanvas->Update(); return 0; } MyMainFrame::~MyMainFrame() { // Clean up used widgets: frames, buttons, layouthints fMain->Cleanup(); delete fMain; } Int_t MyMainFrame::HandleRadioButtons(Int_t but){ RadioId = but; if (RadioId==1){ sprintf(hnameF,"ratioAFcal"); sprintf(hnameB,"ratioABcal"); InputBin[0]->SetNumber(7.00); ULong_t yellow; gClient->GetColorByName("yellow", yellow); UnitLabel->ChangeBackground(yellow); UnitLabel->SetTitle("[deg]"); } else if (RadioId==2){ sprintf(hnameF,"ratioEFcal"); sprintf(hnameB,"ratioEBcal"); InputBin[0]->SetNumber(1.0); ULong_t magenta; gClient->GetColorByName("magenta", magenta); UnitLabel->ChangeBackground(magenta); UnitLabel->SetTitle("[GeV]"); } //cout<<"RadioID: "<Close(); } INF = new TFile(fname,"READ"); if (INF->IsOpen()){ //cout<<"root file opened!"<GetColorByName("yellow", yellow); FileLabel->ChangeBackground(yellow); } else { //cout<<"Error open root file "<< fname <<" !" <GetColorByName("red", red); FileLabel->ChangeBackground(red); } FileLabel->SetText(FileName); FileLabel->SetTextJustify(kTextLeft||kTextCenterY); return 0; } Int_t MyMainFrame::BinValueInput(){ //cout<GetNumber(); //cout<<"Value = "<22.) val = 22; Bin = (Int_t)((val-5.0)/20.*240.); ULong_t yellow; gClient->GetColorByName("yellow", yellow); UnitLabel->ChangeBackground(yellow); UnitLabel->SetTitle("[deg]"); } else if (RadioId==2){ if (val>3.2) val = 3.2; Bin = (Int_t)(val/3.2*64.); ULong_t magenta; gClient->GetColorByName("magenta", magenta); UnitLabel->ChangeBackground(magenta); UnitLabel->SetTitle("[GeV]"); } if (Bin<0) Bin=0; hFcal = NULL; hBcal = NULL; char str1[128]; sprintf(str1,"%s%d",hnameF,Bin); //cout<<"Histo 1 name is "<Get(str1); //hFcal = (TH1D*)INF->Get(str1); sprintf(str1,"%s%d",hnameB,Bin); //cout<<"Histo 2 name is "<Get(str1); if (hFcal){ hFcal->SetLineColor(2); hFcal->GetYaxis()->SetRangeUser(0.,1.5); } if (hBcal){ hBcal->GetYaxis()->SetRangeUser(0.,1.5); } return 0; } Int_t main(Int_t argc, char **argv) { TApplication theApp("App",&argc,argv); // Popup the GUI... new MyMainFrame(gClient->GetRoot(),200,200); theApp.Run(); return 0; }