//#define STANDALONE /* Welcome to RANGER, the Root Accessing Navigation GUI for Exploring Root, version 1.0 KNOWN BUGS -illegal axis coordinates range error if user zooms a histogram to a range with no data points -zoom text box does not immediately update (requires DoDraw() to be called) -logy option does not retain user range on 2D histograms */ //This is a GUI used to sort and display histogram files #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include TGFileInfo fi; //contains open file data TGFileInfo fi2; //stores a copy of file data so if the user cancels the file open dialog box, the program can continue to function TGFileInfo sfi; //contains save file data enum CommandIdentifiers { M_FILE_OPEN, M_FILE_SAVE, M_FILE_EXIT, sID1, //identifies fHSlider1 (s, slider) sID2, //identifies fHSlider2, not yet implemented sID3, //identifies fHSlider3, not yet implemented tsID1, //identifies fSTextEntry1 tsID2, //identifies fSTextEntry2, not yet implemented tsID3, //identifies fSTextEntry3, not yet implemented tnID1, //identifies fNTextEntry1 (n, normalization) tzID1, //identifies fZTextEntry1 (z, zoom) tzID2, //identifies fZTextEntry2 tzID3, //identifies fZTextEntry3 tzID4 //identifies fZTextEntry4 }; const char *filetypes[] = { "ROOT files", "*.root", //defines what filetypeswill be visible in the Open dialog box "ROOT macros", "*.C", 0, 0 }; const char *sfiletypes[] = { "GIF", "*.gif", //defines what filetypeswill be visible in the Save dialog box "PS", "*.ps", "EPS", "*.eps", 0, 0 }; class MainFrame { RQ_OBJECT("MainFrame") private: TGMainFrame *fMain; //the MainWindow TGMenuBar *fMenuBar; TGPopupMenu *fMenuFile; TGLayoutHints *fMenuBarLayout; TGLayoutHints *fMenuBarItemLayout; TGLayoutHints *fMenuBarHelpLayout; TGHorizontalFrame *fHorizontalSetup; //fills all of fMain TGVerticalFrame *fVerticalLeft, *fVerticalRight; //the left side contains the canvas, the right side contains the buttons TGVerticalFrame *fVLast; //even more right than fVerticalRight TGCompositeFrame *fStatusFrame; //cMakeStatusFrame is commented out, so this is not used TGTextEntry *fTestText; //cMakeStatusFrame is commented out, so this is not used TRootEmbeddedCanvas *fEcanvas; //this canvas is the drawing board for the histograms TCanvas *c1; //the pad in the canvas TGComboBox *fCombo; //this Combo box lets users change the units when normalizing a flux graph TGTextEntry *fNTextEntry1; //input for flux TGTextBuffer *fNTextBuffer1; //buffer for fNTextEntry1 TGHorizontalFrame *fHNorm; //holds fCombo and fNTextEntry1 TGVerticalFrame *fSFrame1, *fSFrame2, *fSFrame3; //hold the sliders TGLabel *fSRangeL, *fSRangeM, *fSRangeR; //contain values of min, middle, and max slider positions TGHorizontalFrame *fSRange; //holds the labels that show the range of the slider TGTextEntry *fSTextEntry1; TGTextEntry *fSTextEntry2; TGTextEntry *fSTextEntry3; //input for slider positions TGTextBuffer *fSTextBuffer1; TGTextBuffer *fSTextBuffer2; TGTextBuffer *fSTextBuffer3; //buffers for corresponding textboxes TGLabel *fSliderUnits; //says "cm" for slider position TGHorizontalFrame *fSUnits; //holds the textbox and unit label for the slider position output TGHSlider *fHSlider1, *fHSlider2; //sliders--fHSlider2 not used at the moment TGVSlider *fVSlider3; //fVSlider3--not used yet TGTextEntry *fZTextEntry1, *fZTextEntry2; TGTextEntry *fZTextEntry3, *fZTextEntry4; //input for zoom TGTextBuffer *fZTextBuffer1, *fZTextBuffer2; TGTextBuffer *fZTextBuffer3, *fZTextBuffer4; //buffers for corresponding textboxes TGLabel *fZoomTitle0, *fZoomTitle1; TGLabel *fZoomTitle2; //zoom input labels TGHorizontalFrame *fZoomFrame1, *fZoomFrame2; //holds zoom textboxes TGHorizontalFrame *fOrganizerFrame; //contains fInfoFrameHolder, fPushButtonFrame TGHorizontalFrame *fInfoFrameHolder; //holds the fInfoFrames1, 2, and 3 TGVerticalFrame *fInfoFrame1; TGVerticalFrame *fInfoFrame2; TGVerticalFrame *fInfoFrame3; //hold the labels for names, values, and units TGLabel *fInfoLabels[10]; TGLabel *fInfoEntries[10]; TGLabel *fInfoUnits[10]; //hold the entries for the names, values, and units TGVerticalFrame *fPushButtonFrame; //this frame holds text buttons TGVerticalFrame *fOrganizeCheckBoxes; //contains checkboxes and normalization options TGVerticalFrame *fPrimaryButtonFrame; //holds the check and radio buttons TGRadioButton *fR[100]; //an array of radio buttons TGCheckButton *fC[100]; //an array of checkbox buttons TGCompositeFrame *fHistoPickerFrame; //contains listbox and labels for multiplotting TGHorizontalFrame *fAddRemoveClearFrame; //contains add, remove, clear buttons TGTextButton *fAddHisto; TGTextButton *fRemoveHisto; TGTextButton *fClearHisto; //add, remove, clear buttons TGListBox *fHistoList; //listbox of histograms TGLabel *fMultiplotTitle; //label for listbox TGVertical3DLine *fV1, *fV2, *fC1, *fV5; //lines for seperating interface components TGHorizontal3DLine *fH1, *fH2, *fH3; //lines for seperating interface components int fCount; //distinguishes the code run when opening a file char fNumPrinter[100]; //used to get numbers into TGLabels char *fRootFileName; //the name of the root file char fHSave[100]; //this array holds the name a file will be saved as char fHName[100]; //the histogram file name (eg "hxxxxx") gets written into this array vector fHNamesMulti; //contains an fHName entry, since plot_rflux takes a vector int fCurrSlider1; //keeps track of the current fHSlider1 position int fCurrSlider2; //keeps track of the current fHSlider2 position int fCurrParticle; //keeps track of the selected particle type int fCurrType; //keeps track of the whether the user is looking at distributions or detector data int fCurrHisto; //keeps track of the selected histogram type int fSOutput; //converts between slider movements and the appropriate new textbox readout int fHistoNum; //the number added to fHName after the letter h TFile *fFile; //the opened file TTree *fTree; //the tree for loading simulation input parameters float fVar[10]; //array of simulation input values retrieved by Load_Tree() and placed in ffVar[] char ffVar[10][100]; //array of values from fVar that is now in a string, put into fInfoEntries[] char fbName[10][100]; //array of strings retrived by Load_Tree(), put into fInfoLabels[] TTree *fTree2; //the loaded ntuple of histogram information float fCat1, fCat2, fCat3, fCat4; //histogram information float fCat5, fCat6, fCat7, fCat8; //histogram information int fNEntries; //number of ntuple entries int fiEntry; //current ntuple entry int fZedElements; //number of unique zed positions bool fActivate; //used to temporarily disable checkboxes when they are reset bool fColorbox; //whether the color box is checked or not bool fLogzbox; //whether the LogZ box is checked or not bool fLogybox; //whether the LogY box is checked or not bool fProybox; //whether the ProjectionY box is checked or not bool fProxbox; //whether the ProjectionX box is checked or not bool fProyboxLast; //if multiplotting projections, and both Prox/Proy are off, graphs the most recently selected projection bool fProxboxLast; //see fProyboxLast description bool fNormbox; //whether the Normalization box is checked or not int fMeasure; //keeps track of whether the user is looking at distribution, flux, or multiplots float fScale; //Amp normalization scale float fmScale; //mAmp normalization scale int fUnitsSelection; //keeps track of the selected normalization units char fFluxTitle[100]; //contains new flux graph titles float fSliderMin; //minimum slider position float fSliderMax; //maximum slider position int fScaler; //(fSliderMax-fSliderMin)/(fZedElements - 1), used for slider int CurrHisto; // TH1 *gr; TH2F *fHisto; //the histogram to be drawn //TMultiGraph *fMg; //used in the flux functions for drawing graphs TH2F *fEventsGetter; //gets number of events for flux calculations float fNEvents; //used in the flux functions, but now called only when a file is loaded--repeated callings were causing a crash char fHistoListEntry[100]; //name displayed in multiplots list box vector fHistoListEntries; //keeps track of fHNames of multiplotted histograms vector fHistoListIds; //keeps track of fHistoNums of multiplotted histograms float fPadxMin1, fPadxMax1, fPadyMin1, fPadyMax1; //keep track of the pad dimensions for a histogram type float fPadxMin2, fPadxMax2, fPadyMin2, fPadyMax2; //keep track of the pad dimensions for a histogram type float fPadxMin3, fPadxMax3, fPadyMin3, fPadyMax3; //keep track of the pad dimensions for a histogram type float fPadxMin4, fPadxMax4, fPadyMin4, fPadyMax4; //keep track of the pad dimensions for a histogram type float fPadxMin5, fPadxMax5, fPadyMin5, fPadyMax5; //keep track of the pad dimensions for a histogram type float fPadxMin6, fPadxMax6, fPadyMin6, fPadyMax6; //keep track of the pad dimensions for a histogram type float fPadxMin7, fPadxMax7, fPadyMin7, fPadyMax7; //keep track of the pad dimensions for a histogram type float fPadxMin5b, fPadxMax5b; //keep track of pad dimensions if ProjectionY is selected float fPadxMin6b, fPadxMax6b; //keep track of pad dimensions if ProjectionY is selected float fPadxMin7b, fPadxMax7b; //keep track of pad dimensions if ProjectionY is selected float fZoomNum1, fZoomNum2, fZoomNum3, fZoomNum4; //input parameters for zoom char public: MainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MainFrame(); // slots void CloseWindow(); //kills the program void HandleMenu(Int_t id = -1); //gives the menu functionality void DoSlider(Int_t pos); //gives the slider functionality void DoSliderText(Int_t pos); //handles slider text box output void DoText(const char *text); //handles slider text box input void DoDraw(); //this function gets called every time a histogram needs to be redrawn--whether loaded or the options changed void AlterState(); //draws a histogram, called by DoDraw() or directly (for checkboxes) void FindHisto(); //loads a new fHisto void GetCoords(); //saves the current user zoom settings void DoDrawMulti(); //handles the multiplot case void DoZoomText(); //updates zoom boxes/histogram void cActivator(); //enables/disables buttons for different histogram types void FillInfoFrames(); //this function fills in the input parameters of the simulation and defines the starting positions of the radio buttons void HandleButtons(Int_t id = -1); //gives all the radio, check buttons functionality void Load_Tree(); //loads in fVar[] and fbName[] void Load_Tree2(); //loads histogram information void SetDefaultZoom(); //resets zoom to default void CheckBoxes(); //calls CheckCheckBoxes() and CheckMeasureBoxes() void CheckCheckBoxes(); //enables/disables checkboxes void CheckMeasureBoxes(); //enables/disables radio buttons //our "Create" functions void cMakeMenu(); //creates a title bar with menus void cMakeCanvas(); //creates the canvas void cMakeButtons(); //creates all the buttons void cMakeInfoFrames(); //creates the infoframes void cMakeSlider1(); //creates the first slider and its textbox and textbuffer void cMakeSlider2(); //creates the second slider and its textbox and textbuffer void cMakeSlider3(); //creates the third slider and its textbox and textbuffer void cMakeStatusFrame(); //makes a status frame, not currently used void cRemoveInfoFrames(); //removes info frames before a new file is opened void cInitializer(); //calls cInitializeFile() and cInitializeSettings() void cInitializeFile(); //collection of other functions which display a file void cInitializeSettings(); //resets the starting histogram void cOpenFile(); //opens a file void cShowWindow(); //redraws everything, note that if you try to hide a frame and use this function, it will be revealed void cResetGraphSettings(); //sets the graph back to the default settings void cMakeHistoPicker(); //creates the multiplot listbox void cRemoveHistoPickerFrame(); //removes the multiplot listbox void cZoomUser(); //creates the zoom interface void cAllRestore(); //resets everything to default, ie reopens the file void cButtonDefault(); //resets buttons to defaults //plot functions, for creating flux graphs int Plot_xyFlux(string hname, string title, string cname); //handles the x/y case int Plot_phirFlux(string hname, string title, string cname); //handles the phi/r case int Plot_rFlux(vector< string > hnames, string title, string cname); //handles the radial case }; MainFrame::MainFrame(const TGWindow *p, UInt_t w, UInt_t h) { fCount = 1; //first run through the program fMain = new TGMainFrame(p, w, h); fMain->Connect("CloseWindow()", "MainFrame", this, "CloseWindow()"); fMain->SetWMSizeHints(30, 20,1600,1200,1,1); //minimum is 30x20 to insure not crashing if shrunk to zero, and allows File menu to always be seen cMakeMenu(); fHorizontalSetup = new TGHorizontalFrame(fMain, 100,100); fMain->SetWindowName("File->Open... to choose a ROOT file"); fMain->AddFrame(fHorizontalSetup, new TGLayoutHints (kLHintsExpandX |kLHintsExpandY)); cShowWindow(); fMain->Resize(400, 100); //otherwise the initial window will be quite small, only showing the File menu, and not revealing the cool window name which tells you what to do } MainFrame::~MainFrame() { delete fMenuBarLayout; delete fMenuBarItemLayout; delete fMenuBarHelpLayout; delete fMenuBar; delete fMenuFile; delete fMain; } void MainFrame::CloseWindow() { gApplication->Terminate(0); } void MainFrame::HandleMenu(Int_t id) { switch (id) { case M_FILE_OPEN: //cout << "Case Open " << endl; if(fCount == 1) { cOpenFile(); if(!fi.fFilename){ //this code will prevent a crash if the user selects cancel break; } fMenuFile->EnableEntry(M_FILE_SAVE); //this shows the save menu option which is hidden until the user opens a file cInitializer(); cMakeCanvas(); cMakeSlider1(); // cMakeSlider2(); // New slider to browse root? cMakeButtons(); FillInfoFrames(); cButtonDefault(); fNEvents = fEventsGetter->GetBinContent(1); //gets number of events, used for flux calculations } else { //ie, if count>1...this code is executed if the user tries to open another file fi2 = fi; //stores the file information in case the user hits cancel cOpenFile(); if(!fi.fFilename){ //breaks if the user hits cancel fi=fi2; break; } cInitializer(); cRemoveInfoFrames(); cRemoveHistoPickerFrame(); cMakeHistoPicker(); cMakeInfoFrames(); cResetGraphSettings(); FillInfoFrames(); cButtonDefault(); DoDraw(); } cShowWindow(); fCount += 1; break; case M_FILE_SAVE: //cout << "Case Save " << endl; static TString sdir("."); sfi.fFileTypes = sfiletypes; sfi.fIniDir = StrDup(sdir.Data()); new TGFileDialog(gClient->GetRoot(), fMain, kFDSave, &sfi); if(!sfi.fFilename) //breaks if the user hits cancel break; printf("Save file: %s (dir: %s)\n %s", sfi.fFilename, sfi.fIniDir, sfi.fFileTypes[2]); sdir = sfi.fIniDir; c1->SaveAs(sfi.fFilename); //this line is what actually saves the file break; case M_FILE_EXIT: //cout << "Case Exit " << endl; CloseWindow(); break; default: break; } } void ranger() { //cout << "ranger() " << endl; new MainFrame(gClient->GetRoot(), 400, 100); } void MainFrame::DoZoomText() { //cout << "This is DoZoomText() " << endl; char buf1[32]; char buf2[32]; char buf3[32]; char buf4[32]; fZoomNum1 = gPad->GetUxmin(); sprintf(buf1, "%.1f", fZoomNum1); fZTextBuffer1->Clear(); fZTextBuffer1->AddText(0,buf1); fZoomNum2 = gPad->GetUxmax(); sprintf(buf2, "%.1f", fZoomNum2); fZTextBuffer2->Clear(); fZTextBuffer2->AddText(0,buf2); if(!fLogybox){ fZoomNum3 = gPad->GetUymin(); sprintf(buf3, "%.1f", fZoomNum3); fZTextBuffer3->Clear(); fZTextBuffer3->AddText(0,buf3); fZoomNum4 = gPad->GetUymax(); sprintf(buf4, "%.1f", fZoomNum4); fZTextBuffer4->Clear(); fZTextBuffer4->AddText(0,buf4); } else { fZoomNum3 = gPad->GetUymin(); sprintf(buf3, "%.1f", pow(10,fZoomNum3)); fZTextBuffer3->Clear(); fZTextBuffer3->AddText(0,buf3); fZoomNum4 = gPad->GetUymax(); sprintf(buf4, "%.1f", pow(10,fZoomNum4)); fZTextBuffer4->Clear(); fZTextBuffer4->AddText(0,buf4); } gClient->NeedRedraw(fZTextEntry1); gClient->NeedRedraw(fZTextEntry2); gClient->NeedRedraw(fZTextEntry3); gClient->NeedRedraw(fZTextEntry4); } void MainFrame::DoSliderText(Int_t pos) { //cout << "This is DoSliderText() " <GetPosition(); fSOutput *= fScaler; //scales for textbox output sprintf(buf, "%i", fSOutput); fSTextBuffer1->Clear(); fSTextBuffer1->AddText(0, buf); gClient->NeedRedraw(fSTextEntry1); } void MainFrame::DoSlider(Int_t pos) { //cout << "This is DoSlider() " << endl; Int_t id; TGFrame *frm = (TGFrame *) gTQSender; if (frm->IsA()->InheritsFrom(TGSlider::Class())) { TGSlider *sl = (TGSlider*) frm; id = sl->WidgetId(); } else { TGDoubleSlider *sd = (TGDoubleSlider *) frm; id = sd->WidgetId(); } pos=fHSlider1->GetPosition(); fCurrSlider1 = pos; switch (id){ case sID1: //cout << "Case sID1 " << endl; fCurrType = 2; GetCoords(); DoDraw(); break; case sID2: //cout << "Case sID2 " << endl; break; case sID3: //cout << "Case sID3 " << endl; break; default: break; } } void MainFrame::DoText(const char *text) { //cout << "This is DoText() " << endl; // Handle text entry widgets. TGTextEntry *te = (TGTextEntry *) gTQSender; Int_t id = te->WidgetId(); TCanvas *c = (TCanvas*) gTQSender; switch (id){ case tsID1: //cout << "Case tsID1 " << endl; fHSlider1->SetPosition(atoi(fSTextBuffer1->GetString())/fScaler); fCurrSlider1 = fHSlider1->GetPosition(); DoDraw(); break; case tsID2: //cout << "Case tsID2 " << endl; break; case tsID3: //cout << "Case tsID3 " << endl; break; case tnID1: //cout << "Case tnID1 " << endl; if(fNTextBuffer1->GetString()<=0) break; if(fCombo->GetSelected()==1){ fScale=atof(fNTextBuffer1->GetString())*1000; fmScale=1; //sets other scale to 1 if(fMeasure == 2 && fCurrHisto != 2 && fCurrHisto !=3 && fCurrHisto !=4 && fCurrHisto !=5){ if(fCurrHisto==1){ fHNamesMulti.push_back(fHName); Plot_rFlux(fHNamesMulti,fHName, fHName); fHNamesMulti.pop_back(); } if(fCurrHisto==6){ Plot_xyFlux(fHName, fHName, fHName); } if(fCurrHisto==7){ Plot_phirFlux(fHName, fHName, fHName); } } } if(fCombo->GetSelected()==2){ fmScale=atof(fNTextBuffer1->GetString()); fScale=1; //sets other scale to 1 if(fMeasure == 2 && fCurrHisto != 2 && fCurrHisto !=3 && fCurrHisto !=4 && fCurrHisto !=5){ if(fCurrHisto==1){ fHNamesMulti.push_back(fHName); Plot_rFlux(fHNamesMulti,fHName, fHName); fHNamesMulti.pop_back(); } if(fCurrHisto==6){ Plot_xyFlux(fHName, fHName, fHName); } if(fCurrHisto==7){ Plot_phirFlux(fHName, fHName, fHName); } } } break; case tzID1: //cout << "This is case tzID1" << endl; if(fCurrHisto==1) fPadxMin1 = atoi(fZTextBuffer1->GetString()); else if(fCurrHisto==2) fPadxMin2 = atoi(fZTextBuffer1->GetString()); else if(fCurrHisto==3) fPadxMin3 = atoi(fZTextBuffer1->GetString()); else if(fCurrHisto==4) fPadxMin4 = atoi(fZTextBuffer1->GetString()); else if(fCurrHisto==5) if(fProybox) fPadxMin5b = atoi(fZTextBuffer1->GetString()); else fPadxMin5 = atoi(fZTextBuffer1->GetString()); else if(fCurrHisto==6) if(fProybox) fPadxMin6b = atoi(fZTextBuffer1->GetString()); else fPadxMin6 = atoi(fZTextBuffer1->GetString()); else if(fCurrHisto==7) if(fProybox) fPadxMin7b = atoi(fZTextBuffer1->GetString()); else fPadxMin7 = atoi(fZTextBuffer1->GetString()); AlterState(); break; case tzID2: //cout << "This is case tzID2" << endl; if(fCurrHisto==1) fPadxMax1 = atoi(fZTextBuffer2->GetString()); else if(fCurrHisto==2) fPadxMax2 = atoi(fZTextBuffer2->GetString()); else if(fCurrHisto==3) fPadxMax3 = atoi(fZTextBuffer2->GetString()); else if(fCurrHisto==4) fPadxMax4 = atoi(fZTextBuffer2->GetString()); else if(fCurrHisto==5) if(fProybox) fPadxMax5b = atoi(fZTextBuffer2->GetString()); else fPadxMax5 = atoi(fZTextBuffer2->GetString()); else if(fCurrHisto==6) if(fProybox) fPadxMax6b = atoi(fZTextBuffer2->GetString()); else fPadxMax6 = atoi(fZTextBuffer2->GetString()); else if(fCurrHisto==7) if(fProybox) fPadxMax7b = atoi(fZTextBuffer2->GetString()); else fPadxMax7 = atoi(fZTextBuffer2->GetString()); AlterState(); break; case tzID3: //cout << "This is case tzID3" << endl; if(fCurrHisto==1) fPadyMin1 = atoi(fZTextBuffer3->GetString()); else if(fCurrHisto==2) fPadyMin2 = atoi(fZTextBuffer3->GetString()); else if(fCurrHisto==3) fPadyMin3 = atoi(fZTextBuffer3->GetString()); else if(fCurrHisto==4) fPadyMin4 = atoi(fZTextBuffer3->GetString()); else if(fCurrHisto==5) fPadyMin5 = atoi(fZTextBuffer3->GetString()); else if(fCurrHisto==6) fPadyMin6 = atoi(fZTextBuffer3->GetString()); else if(fCurrHisto==7) fPadyMin7 = atoi(fZTextBuffer3->GetString()); AlterState(); break; case tzID4: //cout << "This is case tzID4" << endl; if(fCurrHisto==1) fPadyMax1 = atoi(fZTextBuffer4->GetString()); else if(fCurrHisto==2) fPadyMax2 = atoi(fZTextBuffer4->GetString()); else if(fCurrHisto==3) fPadyMax3 = atoi(fZTextBuffer4->GetString()); else if(fCurrHisto==4) fPadyMax4 = atoi(fZTextBuffer4->GetString()); else if(fCurrHisto==5) fPadyMax5 = atoi(fZTextBuffer4->GetString()); else if(fCurrHisto==6) fPadyMax6 = atoi(fZTextBuffer4->GetString()); else if(fCurrHisto==7) fPadyMax7 = atoi(fZTextBuffer4->GetString()); AlterState(); break; default: break; } } void MainFrame::HandleButtons(Int_t id) { //cout << "This is HandleButtons() " << endl; if (id == -1) { TGButton *btn = (TGButton *) gTQSender; id = btn->WidgetId(); } int entry; int trial; switch (id) { //cases 0, 1 are for the "Particle Type" radiobuttons case 0: //cout << "Case 0 " << endl; fCurrParticle = 2; DoDraw(); break; case 1: //cout << "Case 1 " << endl; fCurrParticle = 1; if (fCount != 1) //prevents multiple DoDraw() calls when a file is opened DoDraw(); break; //cases 11, 12 are for the "Options" checkbuttons case 11: //cout << "Case 11 " << endl; if(fActivate){ if(fColorbox) fColorbox = false; else fColorbox = true; GetCoords(); AlterState(); } break; case 12: //cout << "Case 12 " << endl; if(fActivate) { if(fLogzbox) fLogzbox = false; else fLogzbox = true; GetCoords(); AlterState(); } break; case 13: //no get coords in Logy, the log scale will quickly mess with the max/min y values //cout << "Case 13 " << endl; if(fActivate){ if(fLogybox) fLogybox = false; else{ GetCoords(); fLogybox = true; } AlterState(); } break; case 14: //cout<< "Case 14" <SetState(kButtonDisabled); fActivate=false; fZTextEntry3->SetEnabled(true); fZTextEntry4->SetEnabled(true); if(fColorbox) fC[0]->SetState(kButtonDown); else fC[0]->SetState(kButtonUp); if(fLogzbox) fC[2]->SetState(kButtonDown); else fC[2]->SetState(kButtonUp); } else{ GetCoords(); fProybox = true; fProxbox = false; fAddHisto->SetState(kButtonUp); fActivate=false; fZTextEntry3->SetEnabled(false); fZTextEntry4->SetEnabled(false); fC[0]->SetState(kButtonDisabled); fC[2]->SetState(kButtonDisabled); fC[4]->SetState(kButtonUp); } fActivate=true; AlterState(); } break; case 15: //cout<< "Case 15" <SetState(kButtonDisabled); fActivate=false; fZTextEntry3->SetEnabled(true); fZTextEntry4->SetEnabled(true); if(fColorbox) fC[0]->SetState(kButtonDown); else fC[0]->SetState(kButtonUp); if(fLogzbox) fC[2]->SetState(kButtonDown); else fC[2]->SetState(kButtonUp); } else { GetCoords(); fProxbox = true; fProybox = false; fAddHisto->SetState(kButtonUp); fActivate=false; fZTextEntry3->SetEnabled(false); fZTextEntry4->SetEnabled(false); fC[0]->SetState(kButtonDisabled); fC[2]->SetState(kButtonDisabled); fC[3]->SetState(kButtonUp); } fActivate=true; AlterState(); } break; case 16: //cout<<"Case 16"<SetEnabled(false); if(fCombo->GetSelected()==1){ fUnitsSelection=1; fCombo->RemoveEntry(2); } else if(fCombo->GetSelected()==2){ fUnitsSelection=2; fCombo->RemoveEntry(1); } else{ fUnitsSelection=2; fCombo->RemoveEntry(1); } } else { fNormbox=true; fNTextEntry1->SetEnabled(true); if(fUnitsSelection==2){ fCombo->AddEntry("A", 1); } else{ fCombo->AddEntry("mA", 2); } fCombo->Select(fUnitsSelection); } if(fNormbox) { fNTextEntry1->ReturnPressed(); //to use whatever number is in the normalization box when you click the checkbox break; } else { //to redraw the flux plot with the default normalization when you uncheck if(fCurrHisto==1){ fHNamesMulti.push_back(fHName); Plot_rFlux(fHNamesMulti,fHName, fHName); fHNamesMulti.pop_back(); } if(fCurrHisto==6){ Plot_xyFlux(fHName, fHName, fHName); } if(fCurrHisto==7){ Plot_phirFlux(fHName, fHName, fHName); } } } break; //cases 21, 22 are for the "Measuring" radiobuttons case 21: //cout << "Case 21 " << endl; if(fActivate){ if(fMeasure!=3) GetCoords(); if(fMeasure==2 && fCurrHisto==1 &&fPadxMin1!=0) fPadxMin1=fPadxMin1+1; fMeasure=1; if (fCount !=1) //to prevent multiple DoDraw() calls when a file is loaded DoDraw(); if(fCurrHisto !=5 && fCurrHisto !=6 && fCurrHisto !=7) fAddHisto->SetState(kButtonUp); else fAddHisto->SetState(kButtonDisabled); if(fProybox) fAddHisto->SetState(kButtonUp); if(fProxbox) fAddHisto->SetState(kButtonUp); if(fCurrHisto != 1 && fCurrHisto!=6 &&fCurrHisto!=7) fR[3]->SetState(kButtonDisabled); if(fHistoListEntries.size()==0) fR[11]->SetState(kButtonDisabled); if(fCombo->GetSelected()==1){ fUnitsSelection=1; fCombo->RemoveEntry(2); } else if(fCombo->GetSelected()==2) { fUnitsSelection=2; fCombo->RemoveEntry(1); } else{ fUnitsSelection=2; fCombo->RemoveEntry(1); } fNTextEntry1->SetEnabled(false); fActivate=false; fC[5]->SetState(kButtonDisabled); fActivate=true; } break; case 22: //cout << "Case 22 " << endl; if(fActivate){ if(fMeasure==1) GetCoords(); fAddHisto->SetState(kButtonDisabled); fActivate=false; if(fNormbox){ fUnitsSelection=fCombo->GetSelected(); fC[5]->SetState(kButtonUp); fC[5]->SetState(kButtonDown); if(fUnitsSelection==2 && fMeasure!=2) fCombo->AddEntry("A", 1); else if(fMeasure!=2) fCombo->AddEntry("mA", 2); fCombo->Select(fUnitsSelection); fNTextEntry1->SetEnabled(true); } else { fC[5]->SetState(kButtonDown); fC[5]->SetState(kButtonUp); } fMeasure=2; fActivate=true; if(fCurrHisto==1) { fHNamesMulti.push_back(fHName); Plot_rFlux(fHNamesMulti,fHName, fHName); fHNamesMulti.pop_back(); } if(fCurrHisto==6) Plot_xyFlux(fHName, fHName, fHName); if(fCurrHisto==7) Plot_phirFlux(fHName, fHName, fHName); if(fHistoListEntries.size()==0) fR[11]->SetState(kButtonDisabled); } break; case 23: if(fActivate) { //cout << "Case 23 " << endl; fActivate=false; fC[5]->SetState(kButtonDisabled); fActivate=true; fUnitsSelection=fCombo->GetSelected(); if(fCombo->GetSelected()==1){ fUnitsSelection=1; fCombo->RemoveEntry(2); } else if(fCombo->GetSelected()==2){ fUnitsSelection=2; fCombo->RemoveEntry(1); } else{ fUnitsSelection=2; fCombo->RemoveEntry(1); } fNTextEntry1->SetEnabled(false); fAddHisto->SetState(kButtonUp); if(fHistoListEntries.size()>=1){ GetCoords(); fMeasure=3; if(fCurrHisto != 1 && fCurrHisto!=6 &&fCurrHisto!=7) fR[3]->SetState(kButtonDisabled); DoDrawMulti(); break; } if(fMeasure==2){ fActivate=false; fR[3]->SetState(kButtonDown); fActivate=true; } if(fMeasure==1){ fActivate=false; fR[2]->SetState(kButtonDown); fActivate=true; } } break; //cases 31-37 are for the "Histogram Type" radiobuttons case 31: //cout << "Case 31 " << endl; GetCoords(); fCurrHisto=1; CurrHisto = 11; cActivator(); break; case 32: //cout << "Case 32 " << endl; GetCoords(); fCurrHisto=2; CurrHisto = 12; cActivator(); break; case 33: //cout << "Case 33 " << endl; GetCoords(); fCurrHisto=3; CurrHisto = 13; cActivator(); break; case 34: //cout << "Case 34 " << endl; GetCoords(); CurrHisto = 14; fCurrHisto=4; cActivator(); break; case 35: //cout << "Case 35 " << endl; GetCoords(); fCurrHisto=5; CurrHisto = 15; cActivator(); break; case 36: //cout << "Case 36 " << endl; GetCoords(); fCurrHisto=6; CurrHisto = 16; cActivator(); break; case 37: //cout << "Case 37 " << endl; GetCoords(); fCurrHisto=7; CurrHisto = 17; cActivator(); break; //cases 41,42 are for the add/remove histogram buttons case 41: //cout << "Case 41 " << endl; if(fCurrHisto==5 || fCurrHisto==6 || fCurrHisto == 7) { trial = 0; fTree2->GetEntry(0); while( trial < fNEntries ) { fTree2->SetBranchAddress("ptype",&fCat2); fTree2->SetBranchAddress("flag",&fCat3); fTree2->SetBranchAddress("z",&fCat6); fTree2->GetEntry(trial); if(fCat2 == fCurrParticle && fCat6 == fCurrSlider1*fScaler && fCat3 != 20 && fCat3 == CurrHisto) { //cout << "The correct ID is: " << fCat1 << endl; fHistoNum = fCat1; break; } //cout << " DoDraw::: " << fCat1 << " " << fCat2 << " " << fCat3 << " " << fCat4 << " " << fCat5 << " " << fCat6 << " " << fCat7 << " " << "Trial: " << trial << endl; trial++; } sprintf(fHName, "h%i", fHistoNum); char part[2]; char flux[2]; char type[3]; if(fCurrParticle==1){ sprintf(part, "E"); } else sprintf(part, "P"); if(fCurrHisto==5) sprintf(type, "RvE"); if(fCurrHisto==6) sprintf(type, "X/Y"); if(fCurrHisto==7) sprintf(type, "Phi/R"); sprintf(fHistoListEntry, "%s Proj (%s %s) %i cm", fHName, part, type, fCurrSlider1*fScaler); fHistoList->AddEntry(fHistoListEntry, fHistoNum ); fHistoList->MapSubwindows(); fHistoList->Layout(); fHistoListEntries.push_back(fHName); fHistoListIds.push_back(fHistoNum); if(fMeasure==3) DoDrawMulti(); if(fMeasure != 3) fR[11]->SetState(kButtonUp); fRemoveHisto->SetState(kButtonUp); fClearHisto->SetState(kButtonUp); break; } char part[2]; char flux[2]; char type[3]; if(fCurrParticle==1) sprintf(part, "E"); else sprintf(part, "P"); if(fCurrHisto==1) sprintf(type, "RD"); if(fCurrHisto==2) sprintf(type, "AD"); if(fCurrHisto==3) sprintf(type, "ED"); if(fCurrHisto==4) sprintf(type, "RED"); trial = 0; fTree2->GetEntry(0); while( trial < fNEntries ) { fTree2->SetBranchAddress("ptype",&fCat2); fTree2->SetBranchAddress("flag",&fCat3); fTree2->SetBranchAddress("z",&fCat6); fTree2->GetEntry(trial); if(fCat2 == fCurrParticle && fCat6 == fCurrSlider1*fScaler && fCat3 != 20 && fCat3 == CurrHisto) { //cout << "The correct ID is: " << fCat1 << endl; fHistoNum = fCat1; break; } //cout << " DoDraw::: " << fCat1 << " " << fCat2 << " " << fCat3 << " " << fCat4 << " " << fCat5 << " " << fCat6 << " " << fCat7 << " " << "Trial: " << trial << endl; trial++; } sprintf(fHName, "h%i", fHistoNum); sprintf(fHistoListEntry, "%s (%s %s) %i cm", fHName, part, type, fCurrSlider1*fScaler); fHistoList->AddEntry(fHistoListEntry, fHistoNum ); fHistoList->MapSubwindows(); fHistoList->Layout(); fHistoListEntries.push_back(fHName); fHistoListIds.push_back(fHistoNum); if(fMeasure==3){ DoDrawMulti(); fR[11]->SetState(kButtonDown); } else fR[11]->SetState(kButtonUp); fRemoveHisto->SetState(kButtonUp); fClearHisto->SetState(kButtonUp); break; case 42: //cout << "Case 42 " << endl; entry = fHistoList->GetSelected(); fHistoList->RemoveEntry(entry); fHistoList->Layout(); char buf[100]; sprintf(buf, "h%i",entry); for(vector :: iterator i=fHistoListEntries.begin(); iSetState(kButtonUp); fR[2]->SetState(kButtonDown); } fActivate=false; fR[11]->SetState(kButtonDisabled); fRemoveHisto->SetState(kButtonDisabled); fClearHisto->SetState(kButtonDisabled); fActivate=true; } break; case 43: //cout << "Case 43 " << endl; for(int j=0; jRemoveEntry(fHistoListIds[j]); } fHistoListEntries.clear(); fR[11]->SetState(kButtonDisabled); if(fMeasure ==3) fR[2]->SetState(kButtonDown); fRemoveHisto->SetState(kButtonDisabled); fClearHisto->SetState(kButtonDisabled); break; //cases 51-53 are for the save as buttons case 51: //cout << "Case 51 " << endl; if(fMeasure==1) sprintf(fHSave, "Saved_Canvas_%s.gif", fHName); if(fMeasure==2 && fCurrHisto!=2 && fCurrHisto!=3 && fCurrHisto!=4 &&fCurrHisto!=5){ sprintf(fHSave, "Saved_Flux_%s.gif", fHName); } else if ( fMeasure == 2){ sprintf(fHSave, "Saved_Canvas_%s.gif", fHName); } if(fMeasure==3) sprintf(fHSave, "Saved_Multi_%s.gif", fHName); c1->SaveAs(fHSave); break; case 52: //cout << "Case 52 " << endl; if(fMeasure==1) sprintf(fHSave, "Saved_Canvas_%s.ps", fHName); if(fMeasure==2 && fCurrHisto!=2 && fCurrHisto!=3 && fCurrHisto!=4 &&fCurrHisto!=5){ sprintf(fHSave, "Saved_Flux_%s.ps", fHName); } else if ( fMeasure == 2){ sprintf(fHSave, "Saved_Canvas_%s.ps", fHName); } if(fMeasure==3) sprintf(fHSave, "Saved_Multi_%s.ps", fHName); c1->SaveAs(fHSave); break; case 53: //cout << "Case 53 " << endl; if(fMeasure==1){ sprintf(fHSave, "Saved_Canvas_%s.eps", fHName); } if(fMeasure==2 && fCurrHisto!=2 && fCurrHisto!=3 && fCurrHisto!=4 &&fCurrHisto!=5){ sprintf(fHSave, "Saved_Flux_%s.eps", fHName); } else if ( fMeasure == 2){ sprintf(fHSave, "Saved_Canvas_%s.eps", fHName); } if(fMeasure==3){ sprintf(fHSave, "Saved_Multi_%s.eps", fHName); } c1->SaveAs(fHSave); break; case 54: //cout <<"Case 54 " << endl; cAllRestore(); break; case 55: //cout <<"Case 55 " << endl; SetDefaultZoom(); break; default: break; } } //---- Main program ------------------------------------------------------------ #ifdef STANDALONE TROOT root("GUI", "GUI test environement"); int main(int argc, char **argv) { TApplication theApp("App", &argc, argv); if (gROOT->IsBatch()) { fprintf(stderr, "%s: cannot run in batch mode\n", argv[0]); return 1; } ranger(); theApp.Run(); return 0; } #endif const char *units[] = { //defines units for simulation input parameters "MeV", "cm", "cm", "cm", "mRads", "degrees", "cm", " ", " ", " " }; void MainFrame::FillInfoFrames() { //cout << "This is FillInfoFrames " << endl; for(int zlabel=0; zlabel<8; zlabel++) { //replace 8 with 10 to show the rndm1 and rndm2 fInfoUnits[zlabel] = new TGLabel(fInfoFrame3, units[zlabel]); fInfoLabels[zlabel] = new TGLabel(fInfoFrame1, fbName[zlabel]); sprintf(ffVar[zlabel], "%8.3f", fVar[zlabel]); if(zlabel==0){ //changes units from GeV to MeV fVar[0] *= 1000; sprintf(ffVar[0], "%8.3f", fVar[0]); } if(zlabel==4){ //changes units from Rad to mRad fVar[4] *= 1000; sprintf(ffVar[4], "%8.3f", fVar[4]); } if(zlabel==5){ //changes units from Rad to degrees fVar[5] *= (180/3.14159); sprintf(ffVar[5], "%8.3f", fVar[5]); } fInfoEntries[zlabel] = new TGLabel(fInfoFrame2, ffVar[zlabel]); fInfoFrame1->AddFrame(fInfoLabels[zlabel], new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2)); fInfoFrame2->AddFrame(fInfoEntries[zlabel], new TGLayoutHints(kLHintsRight, 2, 2, 2, 2)); fInfoFrame3->AddFrame(fInfoUnits[zlabel], new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2)); } } void MainFrame::AlterState() { //cout << "This is AlterState() " << endl; gPad->SetRightMargin(.10); if(fMeasure==3) DoDrawMulti(); else if(fMeasure==2 && fCurrHisto != 2 && fCurrHisto != 3 && fCurrHisto != 4 && fCurrHisto!=5) { fR[3]->SetState(kButtonUp); fR[3]->SetState(kButtonDown); } else { if(fLogybox) c1->SetLogy(); else c1->SetLogy(0); if(fCurrHisto==1){ fHisto->GetXaxis()->SetRangeUser(fPadxMin1, fPadxMax1-1); //subtractions correct for zoom 'drift' } else if(fCurrHisto==2) { fHisto->GetXaxis()->SetRangeUser(fPadxMin2, fPadxMax2-1); } else if(fCurrHisto==3) { fHisto->GetXaxis()->SetRangeUser(fPadxMin3, fPadxMax3-.5); } else if(fCurrHisto==4) { fHisto->GetXaxis()->SetRangeUser(fPadxMin4, fPadxMax4-1); } else if(fCurrHisto==5) { fHisto->GetXaxis()->SetRangeUser(fPadxMin5, fPadxMax5-1); fHisto->GetYaxis()->SetRangeUser(fPadyMin5, fPadyMax5-.5); } else if(fCurrHisto==6) { fHisto->GetXaxis()->SetRangeUser(fPadxMin6, fPadxMax6-1); fHisto->GetYaxis()->SetRangeUser(fPadyMin6, fPadyMax6-1); } else if(fCurrHisto==7) { fHisto->GetXaxis()->SetRangeUser(fPadxMin7, fPadxMax7-1); fHisto->GetYaxis()->SetRangeUser(fPadyMin7, fPadyMax7 -.5); } if(fLogzbox) c1->SetLogz(); else c1->SetLogz(0); if(fProybox && fCurrHisto != 1 && fCurrHisto != 2 && fCurrHisto != 3 && fCurrHisto != 4) { TH1D *la; la = fHisto->ProjectionY("_py", -1, -1, "d"); if (fCurrHisto==5) la->GetXaxis()->SetRangeUser(fPadxMin5b, fPadxMax5b -.5); if (fCurrHisto==6) la->GetXaxis()->SetRangeUser(fPadxMin6b, fPadxMax6b -.5); if (fCurrHisto==7) la->GetXaxis()->SetRangeUser(fPadxMin7b, fPadxMax7b -.5); la->SetLineColor(1); } else if (fProxbox && fCurrHisto != 1 && fCurrHisto != 2 && fCurrHisto != 3 && fCurrHisto != 4) { TH1D *la; la = fHisto->ProjectionX("_px", -1, -1, "d"); if(fCurrHisto==5) la->GetXaxis()->SetRangeUser(fPadxMin5, fPadxMax5-1); if (fCurrHisto==6) la->GetXaxis()->SetRangeUser(fPadxMin6, fPadxMax6-1); if (fCurrHisto==7) la->GetXaxis()->SetRangeUser(fPadxMin7, fPadxMax7-1); la->SetLineColor(1); } else if(fColorbox && fCurrHisto != 1 && fCurrHisto != 2 && fCurrHisto != 3 && fCurrHisto != 4 ) { fHisto->Draw("COL"); } else fHisto->Draw(); c1->Modified(); c1->Update(); } DoZoomText(); fFile->Flush(); } void MainFrame::SetDefaultZoom() { fHisto = 0; DoDraw(); } void MainFrame::GetCoords() { //cout<<"This is GetCoords()"<GetUxmin(); fPadxMax1=gPad->GetUxmax(); } else if(fCurrHisto==2) { fPadxMin2=gPad->GetUxmin(); fPadxMax2=gPad->GetUxmax(); } else if(fCurrHisto==3) { fPadxMin3=gPad->GetUxmin(); fPadxMax3=gPad->GetUxmax(); } else if(fCurrHisto==4) { fPadxMin4=gPad->GetUxmin(); fPadxMax4=gPad->GetUxmax(); } else if(fCurrHisto==5) { if(!fProybox){ fPadxMin5=gPad->GetUxmin(); fPadxMax5=gPad->GetUxmax(); } else{ fPadxMin5b=gPad->GetUxmin(); fPadxMax5b=gPad->GetUxmax(); } if(!fProxbox &&!fProybox&&!fLogybox){ fPadyMin5=gPad->GetUymin(); fPadyMax5=gPad->GetUymax(); } } else if(fCurrHisto==6) { if(!fProybox){ fPadxMin6=gPad->GetUxmin(); fPadxMax6=gPad->GetUxmax(); } else{ fPadxMin6b=gPad->GetUxmin(); fPadxMax6b=gPad->GetUxmax(); } if(!fProxbox&&!fProybox&&!fLogybox){ fPadyMin6=gPad->GetUymin(); fPadyMax6=gPad->GetUymax(); } } else if(fCurrHisto==7) { if(!fProybox){ fPadxMin7=gPad->GetUxmin(); fPadxMax7=gPad->GetUxmax(); } else{ fPadxMin7b=gPad->GetUxmin(); fPadxMax7b=gPad->GetUxmax(); } if(!fProxbox&&!fProybox&&!fLogybox){ fPadyMin7=gPad->GetUymin(); fPadyMax7=gPad->GetUymax(); } } } } void MainFrame::DoDraw() { //cout<< "DoDraw() has been called" <SetRightMargin(.10); FindHisto(); AlterState(); } void MainFrame::Load_Tree() { //cout << "This is Load_Tree() " << endl; fTree = (TTree*)gDirectory->Get("h1"); TIter next(fTree->GetListOfLeaves()); TLeaf *leaf; int n = 0; while ((leaf = (TLeaf*)next())) { float var; TBranch *branch = leaf->GetBranch(); fTree->SetBranchAddress(branch->GetName(),&var); branch->GetEntry(0); fVar[n] = var; sprintf(fbName[n],"%s",branch->GetName()); n++; } } void MainFrame::Load_Tree2() { //cout << "This is Load_Tree2() " << endl; fTree2 = (TTree*)gDirectory->Get("h2"); TIter next(fTree2->GetListOfLeaves()); TLeaf *leaf2; int n = 0; fiEntry = 0; fZedElements = 0; fNEntries = fTree2->GetEntries(); //cout << "fNEntries is: " << fNEntries << endl; while( fiEntry < fNEntries ) { fTree2->SetBranchAddress("id",&fCat1); fTree2->SetBranchAddress("ptype",&fCat2); fTree2->SetBranchAddress("flag",&fCat3); fTree2->SetBranchAddress("x",&fCat4); fTree2->SetBranchAddress("y",&fCat5); fTree2->SetBranchAddress("z",&fCat6); fTree2->SetBranchAddress("phi",&fCat7); fTree2->SetBranchAddress("r",&fCat8); fTree2->GetEntry(fiEntry); if(fCat3!=20) { if(fZedElements==0){ //finds min, max zed values for non-detector histograms fSliderMin=fCat6; fSliderMax=fCat6; } if(fCat6>fSliderMax) fSliderMax=fCat6; if(fCat6GetRoot()); fH2 = new TGHorizontal3DLine(fMain); fMenuFile->AddEntry("&Open...", M_FILE_OPEN); fMenuFile->AddEntry("&Save", M_FILE_SAVE); fMenuFile->HideEntry(M_FILE_SAVE); //entry is revealed when a file is opened fMenuFile->AddSeparator(); fMenuFile->AddEntry("E&xit", M_FILE_EXIT); fMenuFile->Connect("Activated(Int_t)", "MainFrame", this, "HandleMenu(Int_t)"); fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame); fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout); fMain->AddFrame(fMenuBar, fMenuBarLayout); fMain->AddFrame(fH2, new TGLayoutHints(kLHintsExpandX | kLHintsTop, 0,0,0,0)); } void MainFrame::cMakeCanvas() { //cout << "This is cMakeCanvas() " << endl; fVerticalLeft = new TGVerticalFrame(fHorizontalSetup,500,500); fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fVerticalLeft,500,500); c1 = fEcanvas->GetCanvas(); fVerticalLeft->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,10,10,10,1)); fHorizontalSetup->AddFrame(fVerticalLeft, new TGLayoutHints(kLHintsLeft)); // cMakeSlider3(); //Vertical Slider to browse angles or different files? fV5 = new TGVertical3DLine(fHorizontalSetup); fHorizontalSetup->AddFrame(fV5, new TGLayoutHints(kLHintsExpandY)); } void MainFrame::cMakeButtons() { //cout << "This is cMakeButtons " << endl; fVLast = new TGVerticalFrame(fHorizontalSetup,100,100); fVerticalRight = new TGVerticalFrame(fHorizontalSetup,500,700); fOrganizerFrame = new TGHorizontalFrame(fVerticalRight,500,500); fPrimaryButtonFrame = new TGVerticalFrame(fVerticalRight,500,200); fPushButtonFrame = new TGVerticalFrame(fVLast,200,50); fOrganizeCheckBoxes = new TGVerticalFrame(fPrimaryButtonFrame,200, 200); //Create buttons for fPushButtonFrame and connect TGTextButton *savegif = new TGTextButton(fPushButtonFrame,"Save as .gif", 51); savegif->Connect("Clicked()","MainFrame",this,"HandleButtons()"); TGTextButton *exit = new TGTextButton(fPushButtonFrame,"&Exit", "gApplication->Terminate(0)"); TGTextButton *saveps = new TGTextButton(fPushButtonFrame,"Save as .ps", 52); saveps->Connect("Clicked()","MainFrame",this,"HandleButtons()"); TGTextButton *saveeps = new TGTextButton(fPushButtonFrame,"Save as .eps", 53); saveeps->Connect("Clicked()","MainFrame",this,"HandleButtons()"); TGTextButton *restoreall = new TGTextButton(fPushButtonFrame, "Restore All Defaults", 54); restoreall->Connect("Clicked()","MainFrame",this,"HandleButtons()"); TGTextButton *restorezoom = new TGTextButton(fPushButtonFrame, "Default Zoom", 55); restorezoom->Connect("Clicked()","MainFrame",this,"HandleButtons()"); //Add check boxes TGButtonGroup *checkboxes = new TGButtonGroup(fOrganizeCheckBoxes); TGLabel *checktitle = new TGLabel(checkboxes, "Options"); fC[0] = new TGCheckButton(checkboxes, new TGHotString("&Colors"),11); fC[1] = new TGCheckButton(checkboxes, new TGHotString("&LogY Scale"), 13); fC[2] = new TGCheckButton(checkboxes, new TGHotString("&LogZ Scale"), 12); fC[3] = new TGCheckButton(checkboxes, new TGHotString("&ProjectionY"), 14); fC[4] = new TGCheckButton(checkboxes, new TGHotString("&ProjectionX"), 15); fC[5] = new TGCheckButton(checkboxes, new TGHotString("Normalization..."), 16); //Add the Normalization checkboxes fHNorm = new TGHorizontalFrame(fOrganizeCheckBoxes,100,50); fCombo = new TGComboBox(fHNorm, 88); fCombo->AddEntry("mA", 2); fUnitsSelection=2; fCombo->Select(2); fCombo->Resize(45, 20); fNTextEntry1 = new TGTextEntry(fHNorm, fNTextBuffer1 = new TGTextBuffer(10), tnID1); fNTextEntry1->SetToolTipText("Set scaling factor while looking at Flux, choose units, and hit enter. Best viewed in color..."); fNTextEntry1->SetEnabled(false); fNTextBuffer1->AddText(0, "1"); fNTextEntry1->Connect("ReturnPressed()", "MainFrame", this, "DoText(char*)"); fNTextEntry1->Resize(50, fSTextEntry1->GetDefaultHeight()); fHNorm->AddFrame(fNTextEntry1, new TGLayoutHints(kLHintsTop | kLHintsLeft, 16,0,0,0)); fHNorm->AddFrame(fCombo, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0,0,0,0)); //Add radio buttons TGButtonGroup *particle = new TGButtonGroup (fPrimaryButtonFrame); TGLabel *particletitle = new TGLabel(particle, "Particle Type"); fR[0] = new TGRadioButton (particle,new TGHotString("&Electrons (E)"), 1); fR[1] = new TGRadioButton (particle,new TGHotString("&Photons (P)"), 0); TGVButtonGroup *look = new TGVButtonGroup (fPrimaryButtonFrame); TGLabel *looktitle = new TGLabel(look, "Looking at..."); TGLabel *singleplottitle = new TGLabel(look, "-Single Graphs Options-"); look->AddFrame(singleplottitle); fR[2] = new TGRadioButton (look,new TGHotString("&Distribution"), 21); fR[3] = new TGRadioButton (look,new TGHotString("&Flux"), 22); TGLabel *multiplottitle = new TGLabel(look, "-Multiple Graphs Option-"); look->AddFrame(multiplottitle); fR[11] = new TGRadioButton (look,new TGHotString("&Multiplots"), 23); TGVButtonGroup *histo = new TGVButtonGroup (fPrimaryButtonFrame); TGLabel *histotitle = new TGLabel(histo, "Histogram Type"); fR[4] = new TGRadioButton (histo, new TGHotString("&Radial Distribution (RD)"), 31); fR[5] = new TGRadioButton (histo, new TGHotString("&Azimuthal Distribution (AD)"), 32); fR[6] = new TGRadioButton (histo, new TGHotString("&Energy Distribution (ED)"), 33); fR[7] = new TGRadioButton (histo, new TGHotString("&Radial Energy Distribution (RED)"), 34); fR[8] = new TGRadioButton (histo, new TGHotString("&Radius vs. Energy (RvE)"), 35); fR[9] = new TGRadioButton (histo, new TGHotString("&X/Y Shower Profile (X/Y)"), 36); fR[10] = new TGRadioButton (histo, new TGHotString("&Phi/R Shower Profile (Phi/R)") ,37); fC[0]->Connect("Clicked()", "MainFrame", this, "HandleButtons()"); fC[1]->Connect("Clicked()", "MainFrame", this, "HandleButtons()"); fC[2]->Connect("Clicked()", "MainFrame", this, "HandleButtons()"); fC[3]->Connect("Clicked()", "MainFrame", this, "HandleButtons()"); fC[4]->Connect("Clicked()", "MainFrame", this, "HandleButtons()"); fC[5]->Connect("Clicked()", "MainFrame", this, "HandleButtons()"); fR[0]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[1]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[2]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[3]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[11]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[4]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[5]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[6]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[7]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[8]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[9]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fR[10]->Connect("Pressed()", "MainFrame", this, "HandleButtons()"); fH1 = new TGHorizontal3DLine(fPushButtonFrame); fH3 = new TGHorizontal3DLine(fPushButtonFrame); //Add push buttons to fPushButtonFrame fPushButtonFrame->AddFrame(restorezoom, new TGLayoutHints(kLHintsLeft,5,5,3,50)); fPushButtonFrame->AddFrame(restoreall, new TGLayoutHints(kLHintsLeft,5,5,3,4)); fPushButtonFrame->AddFrame(fH3, new TGLayoutHints(kLHintsExpandX,0,0,0,0)); fPushButtonFrame->AddFrame(savegif, new TGLayoutHints(kLHintsLeft,5,5,3,4)); fPushButtonFrame->AddFrame(saveps, new TGLayoutHints(kLHintsLeft,5,5,3,4)); fPushButtonFrame->AddFrame(saveeps, new TGLayoutHints(kLHintsLeft,5,5,3,4)); fPushButtonFrame->AddFrame(fH1, new TGLayoutHints(kLHintsExpandX,0,0,0,0)); fPushButtonFrame->AddFrame(exit, new TGLayoutHints(kLHintsLeft,5,5,3,4)); //Add check buttons to the organizer frame fOrganizeCheckBoxes->AddFrame(checkboxes, new TGLayoutHints(kLHintsLeft, 0,0,0,0)); fOrganizeCheckBoxes->AddFrame(fHNorm, new TGLayoutHints(kLHintsLeft, 0,0,0,0)); //Add radio buttons and check buttons to fPrimaryButtonFrame fPrimaryButtonFrame->AddFrame(fOrganizeCheckBoxes, new TGLayoutHints(kLHintsLeft,0,0,0,0)); fPrimaryButtonFrame->AddFrame(particle, new TGLayoutHints(kLHintsLeft,0,0,19,0)); fPrimaryButtonFrame->AddFrame(histo, new TGLayoutHints(kLHintsLeft,0,0,0,0)); fPrimaryButtonFrame->AddFrame(look, new TGLayoutHints(kLHintsLeft,0,0,0,0)); cMakeHistoPicker(); cMakeInfoFrames(); //Add child frames to fOrganizerFrame fVLast->AddFrame(fPushButtonFrame, new TGLayoutHints(kLHintsBottom|kLHintsRight,5,2,2,2)); cZoomUser(); //Add child frames to fmain fVerticalRight->AddFrame(fPrimaryButtonFrame, new TGLayoutHints(kLHintsLeft,2,2,2,2)); fVerticalRight->AddFrame(fOrganizerFrame, new TGLayoutHints(kLHintsExpandX,2,2,2,2)); fHorizontalSetup->AddFrame(fVerticalRight, new TGLayoutHints(kLHintsLeft)); fHorizontalSetup->AddFrame(fVLast,new TGLayoutHints(kLHintsExpandY)); } void MainFrame::cMakeSlider1() { //cout << "This is cMakeSlider1() " << endl; fSFrame1 = new TGVerticalFrame(fVerticalLeft, 500, 75); fSRange = new TGHorizontalFrame(fSFrame1, 500, 20); fSUnits = new TGHorizontalFrame(fSFrame1, 500, 20); if(fSliderMin>=0) sprintf(fNumPrinter, "%5.0f cm", fSliderMin); if(fSliderMin<0) sprintf(fNumPrinter, "%4.0f cm", fSliderMin); //if negative, uses less spaces, otherwise numbers don't align correctly fSRangeL = new TGLabel(fSRange, fNumPrinter); if((fSliderMax+fSliderMin)/2>=0) sprintf(fNumPrinter, " %.0f ", (fSliderMax+fSliderMin)/2); else sprintf(fNumPrinter, " %.0f ", (fSliderMax+fSliderMin)/2); fSRangeM = new TGLabel(fSRange, fNumPrinter); if(fSliderMax>=0) sprintf(fNumPrinter, "%5.0f cm", fSliderMax); else sprintf(fNumPrinter, "%4.0f cm", fSliderMax); fSRangeR = new TGLabel(fSRange, fNumPrinter); fSRange->AddFrame(fSRangeL, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); fSRange->AddFrame(fSRangeM, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0)); fSRange->AddFrame(fSRangeR, new TGLayoutHints(kLHintsRight, 0, 0, 0, 0)); fSFrame1->AddFrame(fSRange, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); //Connect Slider to Textbuffer fSTextEntry1 = new TGTextEntry(fSUnits, fSTextBuffer1 = new TGTextBuffer(10), tsID1); fSTextEntry1->SetToolTipText("Enter zed position and hit enter, or move slider to desired position"); fSliderUnits = new TGLabel(fSUnits, "cm"); sprintf(fNumPrinter, "%.0f", (fSliderMax+fSliderMin)/2); fSTextBuffer1->AddText(0, fNumPrinter); fSTextEntry1->Connect("ReturnPressed()", "MainFrame", this, "DoText(char*)"); fSTextEntry1->Resize(50, fSTextEntry1->GetDefaultHeight()); //Add slider fHSlider1 = new TGHSlider (fSFrame1, 40, kSlider2 | kScaleNo, sID1); fHSlider1->Connect("Released()","MainFrame", this, "DoSlider(Int_t)"); fHSlider1->Connect("PositionChanged(Int_t)", "MainFrame", this, "DoSliderText(Int_t)"); fHSlider1->SetRange((int)(fSliderMin/fScaler),(int)(fSliderMax/fScaler)); fHSlider1->SetPosition((fSliderMax+fSliderMin)/2/fScaler); TGLayoutHints *fBly = new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0,0,0,0); fC1 = new TGVertical3DLine(fSFrame1); //Add the sliders to fSFrame1 fSFrame1->AddFrame(fHSlider1, fBly); fSFrame1->AddFrame(fC1, new TGLayoutHints(kLHintsTop | kLHintsCenterX |kLHintsExpandY, 0,0,0,0)); fSUnits->AddFrame(fSTextEntry1, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,0,0,0)); fSUnits->AddFrame(fSliderUnits, new TGLayoutHints(kLHintsTop | kLHintsLeft, 1,0,5,0)); fSFrame1->AddFrame(fSUnits, fBly); //Add child frames to fMain fVerticalLeft->AddFrame(fSFrame1, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2)); } void MainFrame::cMakeSlider2() { //cout << "This is cMakeSlider2() " << endl; fSFrame2 = new TGVerticalFrame(fVerticalLeft, 500, 75); fSTextEntry2 = new TGTextEntry(fSFrame2, fSTextBuffer2 = new TGTextBuffer(10), tsID2); fSTextBuffer2->AddText(0, "1"); fSTextEntry2->Connect("TextChanged(char*)", "MainFrame", this, "DoText(char*)"); fHSlider2 = new TGHSlider (fSFrame2, 400, kSlider1 | kScaleDownRight, sID2); fHSlider2->Connect("PositionChanged(Int_t)","MainFrame", this, "DoSlider(Int_t)"); fHSlider2->SetRange(1, 9); fHSlider2->SetPosition(1); TGLayoutHints *fBly2 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0,0,3,0); fSFrame2->AddFrame(fHSlider2, fBly2); fSFrame2->AddFrame(fSTextEntry2, fBly2); fVerticalLeft->AddFrame(fSFrame2, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2)); } void MainFrame::cMakeSlider3() { //cout << "This is cMakeSlider3() " << endl; fSFrame3 = new TGVerticalFrame(fHorizontalSetup, 500, 75); fSTextEntry3 = new TGTextEntry(fSFrame3, fSTextBuffer3 = new TGTextBuffer(10), tsID3); fSTextBuffer3->AddText(0, "1"); fSTextEntry3->Connect("TextChanged(char*)", "MainFrame", this, "DoText(char*)"); fVSlider3 = new TGVSlider (fSFrame3, 400, kSlider1 | kScaleDownRight, sID2); fVSlider3->Connect("PositionChanged(Int_t)","MainFrame", this, "DoSlider(Int_t)"); fVSlider3->SetRange(1, 9); fVSlider3->SetPosition(1); TGLayoutHints *fBly3 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0,0,3,0); fSFrame3->AddFrame(fVSlider3, fBly3); fSFrame3->AddFrame(fSTextEntry3, fBly3); fHorizontalSetup->AddFrame(fSFrame3, new TGLayoutHints(kLHintsExpandY, 2, 2, 2, 2)); } void MainFrame::cMakeStatusFrame(){ //cout << "This is cMakeStatusFrame() " << endl; fStatusFrame = new TGCompositeFrame(fMain, 60, 20, kHorizontalFrame | kSunkenFrame); fTestText = new TGTextEntry(fStatusFrame, new TGTextBuffer(100)); fTestText->SetToolTipText("Got James?"); fTestText->Resize(300, fTestText->GetDefaultHeight()); fStatusFrame->AddFrame(fTestText, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 2, 2, 2)); Pixel_t yellow; gClient->GetColorByName("yellow", yellow); fMain->AddFrame(fStatusFrame, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 0, 0, 1, 0)); } void MainFrame::cRemoveInfoFrames() { //cout << "This is cRemoveInfoFrames() " << endl; fInfoFrameHolder->RemoveFrame(fInfoFrame1); fInfoFrameHolder->RemoveFrame(fInfoFrame2); fInfoFrameHolder->RemoveFrame(fInfoFrame3); fVLast->RemoveFrame(fInfoFrameHolder); delete fInfoFrame1; delete fInfoFrame2; delete fInfoFrame3; delete fInfoFrameHolder; } void MainFrame::cRemoveHistoPickerFrame() { fHistoList->Resize(1,1); //otherwise fHistoList leaves a white remnant :( fHistoPickerFrame->RemoveFrame(fMultiplotTitle); fHistoPickerFrame->RemoveFrame(fHistoList); fOrganizerFrame->RemoveFrame(fHistoPickerFrame); delete fHistoList; fHistoPickerFrame->RemoveFrame(fAddRemoveClearFrame); delete fAddHisto; delete fRemoveHisto; delete fClearHisto; delete fMultiplotTitle; delete fAddRemoveClearFrame; delete fHistoPickerFrame; } void MainFrame::cInitializer() { cInitializeFile(); cInitializeSettings(); } void MainFrame::cInitializeFile() { //cout << "This is cInitializeFile() " << endl; fRootFileName = fi.fFilename; fMain->SetWindowName(fRootFileName); delete fFile; fFile= new TFile(fRootFileName); fEventsGetter = (TH2F*)gDirectory->Get("h10001"); Load_Tree(); Load_Tree2(); delete fHisto; } void MainFrame::cInitializeSettings() { //cout << "This is cInitializeSettings() " << endl; fCount = 1; fScale=1; fmScale=1; fMeasure=1; fCurrSlider1 = (fSliderMax+fSliderMin)/2/fScaler; fCurrSlider2 = 1; fCurrParticle = 1; fCurrType = 2; fCurrHisto = 6; } void MainFrame::cOpenFile() { //cout << "This is cOpenFile()" << endl; static TString dir("."); fi.fFileTypes = filetypes; fi.fIniDir = StrDup(dir.Data()); new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen, &fi); if(!fi.fFilename) return; printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); dir = fi.fIniDir; } void MainFrame::cShowWindow() { //cout << "This is cShowWindow() " << endl; fMain->MapSubwindows(); fMain->Resize(); fMain->MapWindow(); } void MainFrame::cMakeInfoFrames() { //cout << "This is cMakeInfoFrames " << endl; fInfoFrameHolder = new TGHorizontalFrame(fVLast, 300, 200); fInfoFrame1 = new TGVerticalFrame(fInfoFrameHolder, 200, 5); fInfoFrame2 = new TGVerticalFrame(fInfoFrameHolder, 200, 5); fInfoFrame3 = new TGVerticalFrame(fInfoFrameHolder, 200, 5); fV1 = new TGVertical3DLine(fInfoFrameHolder); fV2 = new TGVertical3DLine(fInfoFrameHolder); fInfoFrameHolder->AddFrame(fInfoFrame1, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2)); fInfoFrameHolder->AddFrame(fV1, new TGLayoutHints(kLHintsTop | kLHintsExpandY)); fInfoFrameHolder->AddFrame(fInfoFrame2, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2)); fInfoFrameHolder->AddFrame(fV2, new TGLayoutHints(kLHintsTop | kLHintsExpandY)); fInfoFrameHolder->AddFrame(fInfoFrame3, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2)); fVLast->AddFrame(fInfoFrameHolder, new TGLayoutHints(kLHintsTop|kLHintsLeft, 5, 2, 2, 2)); } void MainFrame::cResetGraphSettings() { //cout << "This is cResetGraphSettings " << endl; fActivate=false; fC[0]->SetState(kButtonUp); fC[1]->SetState(kButtonUp); fC[2]->SetState(kButtonUp); fC[3]->SetState(kButtonUp); fC[4]->SetState(kButtonUp); fC[5]->SetState(kButtonUp); fActivate=true; fHistoListEntries.clear(); fColorbox = false; fLogybox = false; fLogzbox = false; fProybox = false; fProxbox = false; fNormbox = false; fNTextEntry1->SetEnabled(false); fHSlider1->SetRange(fSliderMin/fScaler,fSliderMax/fScaler); fHSlider1->SetPosition((fSliderMax+fSliderMin)/2/fScaler); fSTextBuffer1->Clear(); sprintf(fNumPrinter, "%.0f", (fSliderMax+fSliderMin)/2); fSTextBuffer1->AddText(0, fNumPrinter); fSRange->RemoveFrame(fSRangeL); fSRange->RemoveFrame(fSRangeM); fSRange->RemoveFrame(fSRangeR); delete fSRangeL; delete fSRangeM; delete fSRangeR; if(fSliderMin>=0) sprintf(fNumPrinter, "%5.0f cm", fSliderMin); if(fSliderMin<0) sprintf(fNumPrinter, "%4.0f cm", fSliderMin); fSRangeL = new TGLabel(fSRange, fNumPrinter); if((fSliderMax+fSliderMin)/2>=0) sprintf(fNumPrinter, " %.0f ", (fSliderMax+fSliderMin)/2); else sprintf(fNumPrinter, " %.0f ", (fSliderMax+fSliderMin)/2); fSRangeM = new TGLabel(fSRange, fNumPrinter); if(fSliderMax>=0) sprintf(fNumPrinter, "%5.0f cm", fSliderMax); else sprintf(fNumPrinter, "%4.0f cm", fSliderMax); fSRangeR = new TGLabel(fSRange, fNumPrinter); fSRange->AddFrame(fSRangeL, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); fSRange->AddFrame(fSRangeM, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0)); fSRange->AddFrame(fSRangeR, new TGLayoutHints(kLHintsRight, 0, 0, 0, 0)); gClient->NeedRedraw(fSTextEntry1); fNTextBuffer1->Clear(); fNTextBuffer1->AddText(0, "1"); gClient->NeedRedraw(fNTextEntry1); fCombo->RemoveEntry(1); fCombo->Select(2); if(fCombo->GetSelected()!=2){ fCombo->AddEntry("mA", 2); fCombo->Select(2); } } void MainFrame::cMakeHistoPicker(){ //cout << "This is cMakeHistoPicker() " << endl; fHistoPickerFrame = new TGCompositeFrame(fOrganizerFrame, 60, 20, kVerticalFrame); fMultiplotTitle = new TGLabel(fHistoPickerFrame, "Histograms to Multiplot"); fAddRemoveClearFrame = new TGHorizontalFrame(fHistoPickerFrame, 60, 20); fAddRemoveClearFrame->AddFrame(fAddHisto = new TGTextButton(fAddRemoveClearFrame, "Add", 41), new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2)); fAddRemoveClearFrame->AddFrame(fRemoveHisto = new TGTextButton(fAddRemoveClearFrame, "Remove", 42), new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2)); fAddRemoveClearFrame->AddFrame(fClearHisto = new TGTextButton(fAddRemoveClearFrame, "Clear", 43), new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2)); fAddHisto->Connect("Clicked()", "MainFrame", this, "HandleButtons()"); fRemoveHisto->Connect("Clicked()", "MainFrame", this, "HandleButtons()"); fClearHisto->Connect("Clicked()", "MainFrame", this, "HandleButtons()"); fHistoPickerFrame->AddFrame(fMultiplotTitle, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2)); fHistoPickerFrame->AddFrame(fAddRemoveClearFrame, new TGLayoutHints(kLHintsLeft, 17, 2, 2, 2)); fHistoList = new TGListBox(fHistoPickerFrame, 89); fHistoPickerFrame->AddFrame(fHistoList, new TGLayoutHints(kLHintsLeft, 19, 2, 2, 2)); fHistoList->Resize(175, 115); fOrganizerFrame->AddFrame(fHistoPickerFrame, new TGLayoutHints (kLHintsExpandX|kLHintsLeft, 2, 2, 0, 2)); } int MainFrame::Plot_xyFlux(string hname, string title, string cname) { //cout << "This is Plot_xyFlux() " << endl; TH2F *hist = (TH2F*)gDirectory->Get(hname.c_str()); if( !(hist->IsA()->InheritsFrom( "TH2" )) ) { cout << "ERROR: Not a 2-D Histogram" << endl; return 0; } string cnamea = cname + "_colz"; TH2F *xynhist1 = (TH2F*)hist->Clone(); if(fLogzbox) gPad->SetLogz(); else gPad->SetLogz(0); if(fLogybox) gPad->SetLogy(); else gPad->SetLogy(0); float area = xynhist1->GetXaxis()->GetBinWidth(1)*xynhist1->GetYaxis()->GetBinWidth(1); xynhist1->Scale(6.25E15 * fmScale*fScale/(fNEvents*area)); xynhist1->SetMinimum(xynhist1->GetMinimum(0.1)); xynhist1->SetContour(50); xynhist1->GetXaxis()->SetRangeUser(fPadxMin6, fPadxMax6-1); if(!fProxbox && !fProybox) xynhist1->GetYaxis()->SetRangeUser(fPadyMin6, fPadyMax6-1); if(fProybox) { TH1D *la2; la2=xynhist1->ProjectionY("_py", -1, -1, "d"); la2->GetXaxis()->SetRangeUser(fPadxMin6b, fPadxMax6b-1); la2->SetLineColor(1); } else if(fProxbox) { TH1D *la2; la2=xynhist1->ProjectionX("_px", -1, -1, "d"); la2->GetXaxis()->SetRangeUser(fPadxMin6, fPadxMax6-1); la2->SetLineColor(1); } else if(fColorbox){ gPad->SetRightMargin(.18); xynhist1->Draw("COLZ"); } else{ xynhist1->Draw(); } xynhist1->SetDirectory(0); xynhist1->SetTitleOffset(1.2,"Y"); xynhist1->SetTitleOffset(1.4, "Z"); xynhist1->SetStats(0); xynhist1->GetXaxis()->SetTitle("X (cm)"); xynhist1->GetYaxis()->SetTitle("Y (cm)"); if(fCombo->GetSelected()==1 && fNormbox){ if(fScale/1000 == 1) sprintf(fFluxTitle, "Flux (1/cm^{2}s) per Amp Beam Loss", fScale/1000); else sprintf(fFluxTitle, "Flux (1/cm^{2}s) per %.2f Amps Beam Loss", fScale/1000); xynhist1->GetZaxis()->SetTitle(fFluxTitle); } else{ if(fmScale == 1) sprintf(fFluxTitle, "Flux (1/cm^{2}s) per mA Beam Loss"); else sprintf(fFluxTitle, "Flux (1/cm^{2}s) per %.2f mAs Beam Loss", fmScale); xynhist1->GetZaxis()->SetTitle(fFluxTitle); } xynhist1->SetTitle(fHisto->GetTitle()); c1->Update(); return 0; } int MainFrame::Plot_phirFlux(string hname, string title, string cname) { //cout << "This is Plot_phirFlux() " << endl; TH2F *hist = (TH2F*)gDirectory->Get(hname.c_str()); if( !(hist->IsA()->InheritsFrom( "TH2" )) ) { cout << "ERROR: Not a 2-D Histogram" << endl; return 0; } TH2F *nhist = (TH2F*)hist->Clone(); for(int i = 1; i <= nhist->GetNbinsY(); i++) { float r1 = nhist->GetYaxis()->GetBinLowEdge(i); float r2 = nhist->GetYaxis()->GetBinLowEdge(i+1); float rarea = 3.14159*(r2*r2-r1*r1); for(int j = 1; j <= nhist->GetNbinsX(); j++) { float a1 = nhist->GetXaxis()->GetBinLowEdge(j); float a2 = nhist->GetXaxis()->GetBinLowEdge(j+1); float area = rarea*(a2-a1)/360; float flux = nhist->GetBinContent(j,i)*fScale*fmScale*6.25E15/(fNEvents*area); nhist->SetBinContent(j,i,flux); } } string cnamea = cname + "_colz"; string cnameb = cname + "_surf"; if(fLogzbox){ gPad->SetLogz(); } else{ gPad->SetLogz(0); } if(fLogybox){ gPad->SetLogy(); } else{ gPad->SetLogy(0); } nhist->SetMinimum(nhist->GetMinimum(0.1)); nhist->SetContour(50); nhist->GetXaxis()->SetRangeUser(fPadxMin7, fPadxMax7-.5); if(!fProxbox && !fProybox) nhist->GetYaxis()->SetRangeUser(fPadyMin7, fPadyMax7-.5); if(fProybox) { TH1D *la3; la3=nhist->ProjectionY("_py", -1, -1, "d"); la3->GetXaxis()->SetRangeUser(fPadxMin7b, fPadxMax7b-.5); la3->SetLineColor(1); } else if(fProxbox) { TH1D *la3; la3=nhist->ProjectionX("_px", -1, -1, "d"); la3->GetXaxis()->SetRangeUser(fPadxMin7, fPadxMax7-1); la3->SetLineColor(1); } else if(fColorbox){ gPad->SetRightMargin(.18); nhist->Draw("COLZ"); } else{nhist->Draw(); } nhist->SetDirectory(0); nhist->SetTitleOffset(1.2,"Y"); nhist->SetTitleOffset(1.4, "Z"); nhist->SetStats(0); nhist->GetXaxis()->SetTitle("#phi (degrees)"); nhist->GetYaxis()->SetTitle("R (cm)"); if(fCombo->GetSelected()==1 && fNormbox){ if(fScale/1000 == 1) sprintf(fFluxTitle, "Flux (1/cm^{2}s) per Amp Beam Loss", fScale/1000); else sprintf(fFluxTitle, "Flux (1/cm^{2}s) per %.2f Amps Beam Loss", fScale/1000); nhist->GetZaxis()->SetTitle(fFluxTitle); } else{ if(fmScale == 1) sprintf(fFluxTitle, "Flux (1/cm^{2}s) per mA Beam Loss", fmScale); else sprintf(fFluxTitle, "Flux (1/cm^{2}s) per %.2f mAs Beam Loss", fmScale); nhist->GetZaxis()->SetTitle(fFluxTitle); } nhist->SetTitle(fHisto->GetTitle()); c1->Update(); } int MainFrame::Plot_rFlux(vector< string > hnames, string title, string cname) { //cout << "This is Plot_rFlux() " << endl; if(hnames.size()==0) return 0; vector< TH1* > hvec; vector< TGraph* > grvec; for(int i = 0; i < hnames.size(); i++) { TH1F *hist = (TH1F*)gDirectory->Get(hnames[i].c_str()); TH1F *nhist = (TH1F*)hist->Clone(); nhist->SetDirectory(0); hvec.push_back(nhist); } for(int i = 0; i < hvec.size(); i++) { TGraph *gr = new TGraph(); for(int j = 1; j <= hvec[0]->GetNbinsX();j++) { if(hvec[i]->GetBinContent(j-1)>0) { float r1 = hvec[i]->GetBinLowEdge(j); float r2 = hvec[i]->GetBinLowEdge(j+1); float area = 3.1415*(r2*r2 - r1*r1); float x = hvec[i]->GetBinCenter(j); float flux = hvec[i]->GetBinContent(j)*fScale*fmScale*6.25E15/(fNEvents*area); gr->SetPoint(gr->GetN(),x,flux); } } //grvec.push_back(gr); } /* delete fMg; fMg = new TMultiGraph(); for(int i = 0; i < grvec.size(); i++) { grvec[i]->SetLineColor(i+1); grvec[i]->SetLineStyle(i+1); fMg->Add(grvec[i]); } */ c1->Clear(); //fixes issue with graph merely covering a histogram that's still visible behind it if(fLogybox) gPad->SetLogy(); else gPad->SetLogy(0); if(fLogzbox) gPad->SetLogz(); else gPad->SetLogz(0); gr->Draw("AC"); gr->GetXaxis()->SetRangeUser(fPadxMin1, fPadxMax1-1); gr->SetTitle(fHisto->GetTitle()); gr->GetXaxis()->SetTitle("R (cm)"); if(fCombo->GetSelected()==1 && fNormbox){ if(fScale/1000 == 1) sprintf(fFluxTitle, "Flux (1/cm^{2}s) per Amp Beam Loss", fScale/1000); else sprintf(fFluxTitle, "Flux (1/cm^{2}s) per %.2f Amps Beam Loss", fScale/1000); gr->GetYaxis()->SetTitle(fFluxTitle); } else { if(fmScale == 1) sprintf(fFluxTitle, "Flux (1/cm^{2}s) per mA Beam Loss", fmScale); else sprintf(fFluxTitle, "Flux (1/cm^{2}s) per %.2f mAs Beam Loss", fmScale); gr->GetYaxis()->SetTitle(fFluxTitle); } gr->GetYaxis()->SetTitleOffset(1.2); c1->Update(); return 0; } void MainFrame::DoDrawMulti() { //cout << "This is DoDrawMulti() " << endl; if(fLogzbox) c1->SetLogz(); else c1->SetLogz(0); if(fLogybox) c1->SetLogy(); else c1->SetLogy(0); THStack *th = new THStack; TLegend *legend = new TLegend(0.55, 0.65, 0.76, 0.82); for(int i = 0; i<(fHistoListEntries.size()); i++){ TH2F *fHistob = (TH2F*)gDirectory->Get(fHistoListEntries[i].c_str()); fHistob->SetDirectory(0); if(fHistob->GetDimension()==2){ TH1D * output; if(fProybox) output=fHistob->ProjectionY("_py", -1, -1, " "); else if(fProxbox) output=fHistob->ProjectionX("_px", -1, -1, " "); else if(fProyboxLast) output=fHistob->ProjectionY("_py", -1, -1, " "); else if(fProxboxLast) output=fHistob->ProjectionX("_px", -1, -1, " "); legend->AddEntry(output, fHistoListEntries[i].c_str() , "f"); output->SetLineColor(i+2); output->GetXaxis()->SetRangeUser(-1000,1000); th->Add(output); } else { legend->AddEntry(fHisto, fHistoListEntries[i].c_str(), "f"); fHistob->SetLineColor(i+2); th->Add(fHistob); } } th->Draw("nostack"); legend->Draw(); c1->Update(); } void MainFrame::cActivator() { //cout << "This is cActivator() " << endl; fActivate=false; CheckBoxes(); fActivate=true; DoDraw(); } void MainFrame::CheckBoxes() { CheckCheckBoxes(); CheckMeasureBoxes(); } void MainFrame::CheckCheckBoxes() { //cout<<"This is CheckCheckBoxes()"<SetEnabled(false); fZTextEntry4->SetEnabled(false); fAddHisto->SetState(kButtonUp); fC[0]->SetState(kButtonDisabled); fC[2]->SetState(kButtonDisabled); fC[4]->SetState(kButtonUp); fC[3]->SetState(kButtonDown); } else if (fProxbox){ fZTextEntry3->SetEnabled(false); fZTextEntry4->SetEnabled(false); fAddHisto->SetState(kButtonUp); fC[0]->SetState(kButtonDisabled); fC[2]->SetState(kButtonDisabled); fC[3]->SetState(kButtonUp); fC[4]->SetState(kButtonDown); } else { fAddHisto->SetState(kButtonDisabled); fZTextEntry3->SetEnabled(true); fZTextEntry4->SetEnabled(true); if(fColorbox) fC[0]->SetState(kButtonDown); else fC[0]->SetState(kButtonUp); if(fLogzbox) fC[2]->SetState(kButtonDown); else fC[2]->SetState(kButtonUp); fC[3]->SetState(kButtonUp); fC[4]->SetState(kButtonUp); } if(fLogybox) fC[1]->SetState(kButtonDown); else fC[1]->SetState(kButtonUp); } else { fZTextEntry3->SetEnabled(false); fZTextEntry4->SetEnabled(false); fAddHisto->SetState(kButtonUp); fC[0]->SetState(kButtonDisabled); if(fLogybox) fC[1]->SetState(kButtonDown); else fC[1]->SetState(kButtonUp); fC[2]->SetState(kButtonDisabled); fC[3]->SetState(kButtonDisabled); fC[4]->SetState(kButtonDisabled); } } void MainFrame::CheckMeasureBoxes() { //cout<<"This is CheckMeasureBoxes()"<SetEnabled(false); fC[5]->SetState(kButtonDisabled); if(fCombo->GetSelected()==1){ fUnitsSelection=1; fCombo->RemoveEntry(2); } else if(fCombo->GetSelected()==2){ fUnitsSelection=2; fCombo->RemoveEntry(1); } else{ fUnitsSelection=2; fCombo->RemoveEntry(1); } if(fMeasure==1||fMeasure==2) fR[2]->SetState(kButtonDown); fR[3]->SetState(kButtonDisabled); if(fMeasure==3) fR[11]->SetState(kButtonDown); if(fHistoListEntries.size()==0) fR[11]->SetState(kButtonDisabled); } else { if(fNormbox && fMeasure==2){ fUnitsSelection=fCombo->GetSelected(); fCombo->Select(1); if(fCombo->GetSelected()!=1) fCombo->AddEntry("A", 1); fCombo->Select(2); if(fCombo->GetSelected()!=2) fCombo->AddEntry("mA", 2); fCombo->Select(fUnitsSelection); } if(fMeasure==1) fR[2]->SetState(kButtonDown); fR[3]->SetState(kButtonEngaged); if(fMeasure==2) fR[3]->SetState(kButtonDown); if(fMeasure==3) fR[11]->SetState(kButtonDown); if(fHistoListEntries.size()==0) fR[11]->SetState(kButtonDisabled); } } void MainFrame::FindHisto() { //cout << "This is FindHisto() " << endl; int trial2 = fNEntries; fTree2->GetEntry(0); while( trial2 >= 0 ) { fTree2->SetBranchAddress("ptype",&fCat2); fTree2->SetBranchAddress("flag",&fCat3); fTree2->SetBranchAddress("z",&fCat6); fTree2->GetEntry(trial2); if(fCat2 == fCurrParticle && fCat6 == fCurrSlider1*fScaler && fCat3 != 20 && fCat3 == CurrHisto) { //cout << "The correct ID is: " << fCat1 << endl; fHistoNum = fCat1; break; } //cout << " FindHisto::: " << fCat1 << " " << fCat2 << " " << fCat3 << " " << fCat4 << " " << fCat5 << " " << fCat6 << " " << fCat7 << " " << "Trial2: " << trial2 << endl; trial2--; } sprintf(fHName, "h%i", fHistoNum); if(fHisto){ //GetCoords(); } else { fPadxMin1 = 0; fPadxMax1 = 100; fPadyMin1 = 0; fPadxMin2 = 0; fPadxMax2 = 360; fPadyMin2 = 0; fPadxMin3 = 0; fPadxMax3 = fVar[0]*1000; fPadyMin3 = 0; fPadxMin4 = 0; fPadxMax4 = 100; fPadyMin4 = 0; fPadxMin5 = 0; fPadxMax5 = 100; fPadyMin5 = 0; fPadyMax5 = fVar[0]*1000; fPadxMin6 = -100; fPadxMax6 = 100; fPadyMin6 = -100; fPadyMax6 = 100; fPadxMin7 = 0; fPadxMax7 = 360; fPadyMin7 = 0; fPadyMax7 = 100; fPadxMin5b=0; fPadxMax5b=fVar[0]*1000; fPadxMin6b=-100; fPadxMax6b=100; fPadxMin7b=0; fPadxMax7b=100; } delete fHisto; fHisto = (TH2F*)gDirectory->Get(fHName); if(!fHisto) return; fHisto->SetMinimum(fHisto->GetMinimum(0.1)); //affects 2D histograms, makes background white fHisto->SetDirectory(0); //makes it so the user can do graph functions on the displayed histogram without it "whiting out" } void MainFrame::cZoomUser() { //cout << "This is cZoomUser() " << endl; fZoomFrame1 = new TGHorizontalFrame(fVLast, 50, 50); fZoomFrame2 = new TGHorizontalFrame(fVLast, 50, 50); fZTextEntry1 = new TGTextEntry(fZoomFrame1, fZTextBuffer1 = new TGTextBuffer(10), tzID1); fZTextEntry1->SetToolTipText("Enter minimum value for x-axis"); fZTextBuffer1->AddText(0, "%fPadxMin6"); fZTextEntry1->Connect("ReturnPressed()", "MainFrame", this, "DoText(char*)"); fZTextEntry1->Resize(52, fSTextEntry1->GetDefaultHeight()); fZTextEntry2 = new TGTextEntry(fZoomFrame1, fZTextBuffer2 = new TGTextBuffer(10), tzID2); fZTextEntry2->SetToolTipText("Enter maximum value for x-axis"); fZTextBuffer2->AddText(0, "%fPadxMax6"); fZTextEntry2->Connect("ReturnPressed()", "MainFrame", this, "DoText(char*)"); fZTextEntry2->Resize(52, fSTextEntry1->GetDefaultHeight()); fZTextEntry3 = new TGTextEntry(fZoomFrame2, fZTextBuffer3 = new TGTextBuffer(10), tzID3); fZTextEntry3->SetToolTipText("Enter minimum value for y-axis"); fZTextBuffer3->AddText(0, "%fPadyMin6"); fZTextEntry3->Connect("ReturnPressed()", "MainFrame", this, "DoText(char*)"); fZTextEntry3->Resize(52, fSTextEntry1->GetDefaultHeight()); fZTextEntry4 = new TGTextEntry(fZoomFrame2, fZTextBuffer4 = new TGTextBuffer(10), tzID4); fZTextEntry4->SetToolTipText("Enter maximum value for y-axis"); fZTextBuffer4->AddText(0, "%fPadyMax6"); fZTextEntry4->Connect("ReturnPressed()", "MainFrame", this, "DoText(char*)"); fZTextEntry4->Resize(52, fSTextEntry1->GetDefaultHeight()); fZoomTitle0 = new TGLabel(fVLast, "Zooming Parameters"); fZoomTitle1 = new TGLabel(fVLast, "Minimum/Maximum X/Phi-Value"); fZoomTitle2 = new TGLabel(fVLast, "Minimum/Maximum Y-value"); fZoomFrame1->AddFrame(fZTextEntry1); fZoomFrame1->AddFrame(fZTextEntry2); fZoomFrame2->AddFrame(fZTextEntry3); fZoomFrame2->AddFrame(fZTextEntry4); fVLast->AddFrame(fZoomFrame2, new TGLayoutHints(kLHintsBottom,0,5,5,5)); fVLast->AddFrame(fZoomTitle2, new TGLayoutHints(kLHintsBottom,0,5,0,3)); fVLast->AddFrame(fZoomFrame1, new TGLayoutHints(kLHintsBottom,0,5,0,5)); fVLast->AddFrame(fZoomTitle1, new TGLayoutHints(kLHintsBottom,0,5,0,3)); fVLast->AddFrame(fZoomTitle0, new TGLayoutHints(kLHintsBottom,0,5,0,10)); } void MainFrame::cAllRestore() { fHisto = 0; cInitializer(); cRemoveHistoPickerFrame(); cMakeHistoPicker(); cResetGraphSettings(); cButtonDefault(); DoDraw(); cShowWindow(); fCount++; } void MainFrame::cButtonDefault() { fR[0]->SetState(kButtonUp); fR[0]->SetState(kButtonDown); fR[2]->SetState(kButtonUp); fR[2]->SetState(kButtonDown); fR[9]->SetState(kButtonUp); fR[9]->SetState(kButtonDown); fR[11]->SetState(kButtonDisabled); fAddHisto->SetState(kButtonDisabled); fRemoveHisto->SetState(kButtonDisabled); fClearHisto->SetState(kButtonDisabled); fActivate = false; fC[5]->SetState(kButtonDisabled); fActivate=true; }