#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //Global Viariables vector myFiles; TGCompositeFrame *fFleft; TGCompositeFrame *fFright; int i0=0; int i1=0; int i2=0; int tabcheck=0; //__________________________________________________________ class MyMainFrame : public TGMainFrame { private:    TGListBox           *fListBox;    TGCheckButton       *fCheckMulti;    TList               *fSelected;    TGTextViewostream   *fTRun, *fTgas, *fTdaq, *fTG4, *fTrd, *fTproc;    TGTextEntry         *fCommand;    TGLayoutHints       *fL;    TGCompositeFrame    *fF, *fFproc, *fFG4, *fFrun;    TGTab               *fTab;    TGCompositeFrame    *tf; public:    MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);    virtual ~MyMainFrame();    void     DoSave();    void     CloseWindow();    void     PrintSelected();    void     CreateTabs();    void     DoTab(Int_t id);    void     DoProcesses();    void     DeleteTabs();    ClassDef(MyMainFrame, 0) }; //_________________________________________________________________________ MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :   TGMainFrame(p, w, h) {    // Create vertical splitter    TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 50, 50);    TGVerticalFrame *fV1 = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);    TGVerticalFrame *fV2 = new TGVerticalFrame(fHf, 10, 10);    fFleft = new TGCompositeFrame(fV1, 10, 10, kSunkenFrame);    fFright = new TGCompositeFrame(fV2, 10, 10, kSunkenFrame);       //Add listBox on the left side    fListBox = new TGListBox(this, 89);    fSelected = new TList;    char tmp[20];    myFiles= listFiles(tmp);    for (unsigned int i = 0; i < myFiles.size(); i++) {       fListBox->AddEntry(myFiles[i], i);          }    fFleft->AddFrame(fListBox, new TGLayoutHints(kLHintsExpandX |kLHintsExpandY,                                           0, 0, 5, 10));        //Select with a Single Click    fListBox->Connect("Selected(Int_t)","MyMainFrame",this,"CreateTabs()");                 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    fV1->AddFrame(fFleft, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,                                            0, 0, 5, 10));    fV2->AddFrame(fFright, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,                                             0, 0, 5, 10));    fV1->Resize(fFleft->GetDefaultWidth()+20, fV1->GetDefaultHeight());    fV2->Resize(fFright->GetDefaultWidth(), fV1->GetDefaultHeight());    fHf->AddFrame(fV1, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));    TGVSplitter *splitter = new TGVSplitter(fHf,2,2);    splitter->SetFrame(fV1, kTRUE);    fHf->AddFrame(splitter, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));    fHf->AddFrame(fV2, new TGLayoutHints(kLHintsRight | kLHintsExpandX |                                         kLHintsExpandY));    AddFrame(fHf, new TGLayoutHints(kLHintsRight | kLHintsExpandX |                                    kLHintsExpandY));    // button frame    TGVerticalFrame *vframe = new TGVerticalFrame(this, 10, 10);    TGCompositeFrame *cframe2 = new TGCompositeFrame(vframe, 170, 20,                                              kHorizontalFrame | kFixedWidth);    TGTextButton *exit = new TGTextButton(cframe2, "&Exit ","gApplication->Terminate(0)");    cframe2->AddFrame(exit, new TGLayoutHints(kLHintsTop | kLHintsExpandX,                                              2, 0, 2, 2));    vframe->AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));    AddFrame(vframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));         // What to clean up in destructor    SetCleanup(kDeepCleanup);    // Set a name to the main frame    SetWindowName("RunBrowser");    SetWMSizeHints(350, 200, 600, 400, 0, 0);    MapSubwindows();    Resize(GetDefaultSize());    MapWindow(); } //______________________________________________________________________________ MyMainFrame::~MyMainFrame() {    // Clean up all widgets, frames and layouthints that were used    Cleanup(); } //______________________________________________________________________________ void MyMainFrame::CloseWindow() {    // Called when window is closed via the window manager.    delete this; } //______________________________________________________________________________ void MyMainFrame::CreateTabs() {        if (tabcheck>0)    {       DeleteTabs();    }    /* if (tabcheck>0) {     Cleanup();     fTab->Delete();     delete fTab;  } */    //Find input File    TRestRun *run = new TRestRun();    run->OpenInputFile( myFiles[fListBox->GetSelected()] );       //Create tabs on the right side     fTab = new TGTab (fFright, 500, 300);    fL= new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5);    fFright->AddFrame(fTab, fL); //insert tab            //Tab_Run    tf= fTab->AddTab("Run");    fFrun= new TGCompositeFrame(tf, 200, 200, kVerticalFrame);    tf->AddFrame (fFrun, fL);      //Add TextBox    fTRun = new TGTextViewostream (fFrun, 500, 300);    fFrun->AddFrame(fTRun, new TGLayoutHints(kLHintsExpandX |                 kLHintsExpandY, 0, 0, 0, 0));                     //Load data from PrintInfo()-before it was GetMetadataString()    TRestRun *run = new TRestRun();    run->OpenInputFile(myFiles[fListBox->GetSelected()]);    TString runInfo = run->PrintInfo();             //Print data    fTRun->Clear();    cout<ShowBottom();                       //Tabs of Metadata-daq,gas and HistoricMetadata-restG4,readout    for(unsigned int j = 0; j < run->GetNumberOfMetadata(); j++ )           {            TString nameOfMetadata = run->GetMetadata( j )->GetName();            //Tabi                       if (nameOfMetadata=="daq")               {                 tf= fTab->AddTab(nameOfMetadata.Data());                 fF= new TGCompositeFrame(tf, 200, 200, kVerticalFrame);                 tf->AddFrame (fF, fL);                 //Add TextBox                 fTdaq = new TGTextViewostream (fF, 500, 300);                 fF->AddFrame(fTdaq, new TGLayoutHints(kLHintsExpandX |                      kLHintsExpandY, 0, 0, 0, 0));               }            if (nameOfMetadata=="gas")               {                 tf= fTab->AddTab(nameOfMetadata.Data());                 fF= new TGCompositeFrame(tf, 200, 200, kVerticalFrame);                 tf->AddFrame (fF, fL);                 //Add TextBox                 fTgas = new TGTextViewostream (fF, 500, 300);                 fF->AddFrame(fTgas, new TGLayoutHints(kLHintsExpandX |                      kLHintsExpandY, 0, 0, 0, 0));               }            }    for(unsigned int k = 0; k < run->GetNumberOfHistoricMetadata(); k++ )           {            TString nameOfMetadata = run->GetHistoricMetadata( k )->GetName();            //Tabi            if (nameOfMetadata=="restG4")               {                 tf= fTab->AddTab(nameOfMetadata.Data());                 fFG4= new TGCompositeFrame(tf, 200, 200, kVerticalFrame);                 tf->AddFrame (fFG4, fL);                 //Add TextBox                 fTG4 = new TGTextViewostream (fFG4, 500, 300);                 fFG4->AddFrame(fTG4, new TGLayoutHints(kLHintsExpandX |                      kLHintsExpandY, 0, 0, 0, 0));               }            if (nameOfMetadata=="readout")               {                 tf= fTab->AddTab(nameOfMetadata.Data());                 fF= new TGCompositeFrame(tf, 200, 200, kVerticalFrame);                 tf->AddFrame (fF, fL);                 //Add TextBox                 fTrd = new TGTextViewostream (fF, 500, 300);                 fF->AddFrame(fTrd, new TGLayoutHints(kLHintsExpandX |                      kLHintsExpandY, 0, 0, 0, 0));               }            }    cout<AddTab("Processes");    fFproc= new TGCompositeFrame(tf, 200, 200, kVerticalFrame);    tf->AddFrame (fFproc, fL);          //Update Window    fTab->Layout();    fFright->MapSubwindows();    fFright->Resize(GetDefaultSize());       tabcheck++;       //Select a tab    fTab->Connect("Selected(Int_t)", "MyMainFrame", this, "DoTab(Int_t)");    } //______________________________________________________________________________ void MyMainFrame::DoTab(Int_t id) {  cout<<"Tab id =" <GetTabTab(id)->GetString();    cout<OpenInputFile(myFiles[fListBox->GetSelected()]);        TString runInfo = run->PrintInfo();                 //Print data        fTRun->Clear();        cout<ShowBottom();           }        else if (s=="Processes")      {        DoProcesses();      }           else      {        //Open selected file        TRestRun *run = new TRestRun();        run->OpenInputFile(myFiles[fListBox->GetSelected()]);        //Add TextBox of Metadata        if (s=="gas")        {        TRestMetadata *md=run->GetMetadata(s);        TString print=md->PrintMetadata();        cout<Clear();        *fTgas <ShowBottom();        }        if (s=="daq")        {        TRestMetadata *md=run->GetMetadata(s);        TString print=md->PrintMetadata();        cout<Clear();        *fTdaq <ShowBottom();        }        if (s=="restG4")        {          TRestMetadata *md=run->GetMetadata(s);        TString print=md->PrintMetadata();        cout<Clear();        *fTG4 <ShowBottom();        }        if (s=="readout")        {        TRestMetadata *md=run->GetMetadata(s);        TString print=md->PrintMetadata();        cout<Clear();        *fTrd <ShowBottom();        }                    }    //Update Window    fFright->MapSubwindows();    fFright->Resize(GetDefaultSize()); } //______________________________________________________________________________ void MyMainFrame::DoProcesses() {          for(unsigned int i = 0; i < run->GetNumberOfProcesses(); i++ )           {cout<<"Process"<< endl;            TString nameOfProcess = run->GetProcess( i )->GetName();            TString titleOfProcess = run->GetProcess( i )->GetName();            cout << "Process name : " << nameOfProcess << " title : " << titleOfProcess << endl;           }     for(unsigned int i = 0; i < run->GetNumberOfHistoricProcesses(); i++ )           {cout<<"Historic Process"<< endl;            TString nameOfProcess = run->GetHistoricProcess( i )->GetName();            TString titleOfProcess = run->GetHistoricProcess( i )->GetName();            cout << "Historic Process name : " << nameOfProcess << " title : " << titleOfProcess << endl;           }    //Print metadata of one process-general, raw, signal, analysis    //TRestMetadata *md=run->GetProcessMetadata();    //TString print=md->PrintMetadata();    //cout<GetRoot(), 350, 200); }