| ////////////////////////////////////////////////////////////////////////////////
//                                                                            //
// MIDTBCTab                                                                  //
//                                                                            //
// Begin_Html <!--
/*-->
<!--*/
// --> End_Html
//                                                                            //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
/* Generated header file containing necessary includes                        */
#include "generated/MIDTBCTabGeneratedIncludes.h"
////////////////////////////////////////////////////////////////////////////////
/*  This header was generated by ROMEBuilder. Manual changes above the        *
 * following line will be lost next time ROMEBuilder is executed.             */
/////////////////////////////////////----///////////////////////////////////////
#include "generated/MIDWindow.h"
#include "generated/MIDAnalyzer.h"
#include "tabs/MIDTBCTab.h"
#include "tasks/MIDTFillHistogram.h"
#include "TAxis.h"
#include "TLatex.h"
#include <TGClient.h>
#include <TCanvas.h>
#include <TRandom.h>
#include <TGButton.h>
#include <TGFrame.h>
#include <TRootEmbeddedCanvas.h>
#include <RQ_OBJECT.h>
#include<TString.h>
#include<TDatime.h>
// uncomment if you want to include headers of all folders
//#include "MIDAllFolders.h"
ClassImp(MIDTBCTab)
using namespace std;
//______________________________________________________________________________
void MIDTBCTab::Init()
{
  // Create style for this tab                                                 
  TStyle *orgStyle = gStyle;
  fStyle = new TStyle(*orgStyle); // copy the original style                   
  fStyle->SetOptTitle(1);
  fStyle->SetTitleOffset(0.18, "y");
  fStyle->SetPadGridX(1);
  fStyle->SetPadGridY(1);
  fStyle->SetPadTickX(1);
  fStyle->SetPadTickY(1);
  fStyle->SetFrameBorderSize(0);
  fStyle->SetFrameBorderMode(0);
  fStyle->SetFrameFillStyle(0);
  fStyle->SetTitleSize(0.06, "t");
  fStyle->SetStatH(0.09);
  fStyle->SetStatW(0.09);
  fStyle->cd();
  // Create a vertical frame containing buttons and canvas                     
  fVert = new TGVerticalFrame(this, (UInt_t) (700 * gAnalyzer->GetWindow()->GetWindowScale()), (UInt_t) (700 *gAnalyzer->GetWindow()->GetWindowScale()));
  // Create an embedded canvas and add to the main frame, centered in x and y                                                
  //  TString canvasname = "Sample Canvas";
  
  // set data member 
  fCanvasName =  new TString ("Sample Canvas");
  
  
  fCanvas = new TRootEmbeddedCanvas(fCanvasName->Data(), fVert, (UInt_t) (600 * gAnalyzer->GetWindow()->GetWindowScale()), (UInt_t) (600 * gAnalyzer->GetWindow()->GetWindowScale()));
  fCanvas->GetCanvas()->Divide(1,1);
  TLatex title;
  title.SetTextFont(12);                                                        
  title.SetTextSize(0.03);                                                      
  title.SetNDC(); 
  //Create save button                                                                                                      
  ULong_t green;
  gClient->GetColorByName("Green",green);
  fSaveCanvas = new TGTextButton(fVert, "SaveCanvas");
  fSaveCanvas->ChangeBackground(green);
  fSaveCanvas->Associate(this);
  fVert->AddFrame(fSaveCanvas, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
                                               
                                                                                                               
                                  
                                                                                                                        /// Create "Update" button                                                    
  ULong_t yellow;
  gClient->GetColorByName("Yellow",yellow);                                            
  fBUpdate = new TGTextButton(fVert, "Update");
  fBUpdate->ChangeBackground(yellow);
  fBUpdate->Associate(this);
  //  fVert->AddFrame(fCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 4, 4, 4, 4));
  fVert->AddFrame(fBUpdate, new TGLayoutHints(kLHintsCenterX, 4, 4, 4, 4));
  // AddFrame(fVert, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 4, 4, 4, 4));
  //Create Exit button
  ULong_t red;
  gClient->GetColorByName("Red",red);                                    
  fExit = new TGTextButton(fVert,"&Exit", "gApplication->Terminate(0)");
  fExit->ChangeBackground(red);
  fExit->Associate(this);
  //  fVert->AddFrame(fCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 4, 4, 4, 4));
  
fVert->AddFrame(fExit, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
                                                                                    
   
 fVert->AddFrame(fCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 3,  4)); 
 AddFrame(fVert, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 4, 4, 4, 4)); 
  ConnectAll();
  orgStyle->cd();
}
//______________________________________________________________________________
void MIDTBCTab::EndInit()
{
}
//______________________________________________________________________________
void MIDTBCTab::EventHandler()
{
}
//______________________________________________________________________________
void MIDTBCTab::MenuClicked(TGPopupMenu * /* menu */, Long_t /* param */)
{
}
//______________________________________________________________________________
void MIDTBCTab::TabSelected()
{
}
//______________________________________________________________________________
void MIDTBCTab::TabUnSelected()
{
}
  // Save Canvas:
  // you'll need a function of the same signature in your .h -> also make sure that TString is included in your .h
  void MIDTBCTab::SaveCanvas() 
{
 
  TString * fileName = new TString (fCanvasName->Data());
    //replace all spaces in your canvas name 
    fileName->ReplaceAll(" ", "");
    
    //generate data and time stamp -> Recall you'll have to make sure TDatime is included 
    TDatime  dateTime; // time and date remain frozen when this function was called
    TString dateAsString = Form("%d", dateTime.GetDate());
    TString timeAsString = Form("%d", dateTime.GetTime());
    // append time date etc to canvas name
    (*fileName) += ".";
    (*fileName) += dateAsString;
    (*fileName) += ".";
    (*fileName) += timeAsString;
    (*fileName) += ".pdf"; // pdf for now maybe think about png and other options for user later ? 
    // debug
    //    cout << " This is the filename " << fileName->Data() << endl;
    // now print it and hope it works ....
    fCanvas->GetCanvas()->Print(fileName->Data());
    //cout << " Already attempted to print this file  " << fileName->Data() << endl;
}
void MIDTBCTab::Update()
{
  TLatex title;                                                                 
  title.SetTextFont(12);                                                        
  title.SetTextSize(0.03);                                                      
  title.SetNDC(); 
  TStyle *orgStyle = gStyle;
  fStyle->cd();
  TH2 *histo;
  for (Int_t i = 0; i < 1; i++) {
    fCanvas->GetCanvas()->cd(i + 1);
    histo = (TH2D *) gAnalyzer->GetFillHistogramTask()->Geth2_dt_tcpgotheaderAt(i);
    if (!histo) {
      cout << "Histo h2_dt_tcpgotheader not available." << endl;
    } else {
 
      histo->SetMarkerColor(1);
      histo->GetXaxis()->SetRangeUser(-20000,100000);
     
      histo->Draw("COLZ");
                                           
      title.SetTextColor(2);                                                        
                                                                                
                                      
                                                                                
                                                            
                                                                                
      title.SetTextColor(2); 
      title.DrawLatex(0.01,0.32,"tcp header #rightarrow");
      title.SetTextColor(3); 
                           
      title.DrawLatex(0.01,0.4,"tcp data  #rightarrow");                                 
      title.SetTextColor(4); 
      title.DrawLatex(0.01,0.48,"copy to GPU #rightarrow");                         
      title.SetTextColor(5); 
      title.DrawLatex(0.01,0.56,"GPU processing #rightarrow");                      
      title.SetTextColor(6); 
      title.DrawLatex(0.01,0.64,"MFE start #rightarrow");                           
      title.SetTextColor(7); 
      title.DrawLatex(0.01,0.72,"MFE stop #rightarrow");  
    }
  }
  fCanvas->GetCanvas()->cd(0);
  fCanvas->GetCanvas()->Modified();
  fCanvas->GetCanvas()->Update();
  orgStyle->cd();
  return;
}
//______________________________________________________________________________                                              
void MIDTBCTab::ConnectAll()
{
  fBUpdate->Connect("Pressed()", "MIDTBCTab", this, "Update()");
  fExit->Connect("Pressed()", "MIDTBCTab", this, "&Exit()");
  fSaveCanvas->Connect("Pressed()","MIDTBCTab", this, "SaveCanvas()");  
}
//______________________________________________________________________________                                         
void MIDTBCTab::DisconnectAll()
{
  if (fBUpdate) { fBUpdate->Disconnect(this); }
  if (fExit) { fExit->Disconnect(this); }
  if(fSaveCanvas) { fSaveCanvas->Disconnect(this);} 
}
 | 
| ////////////////////////////////////////////////////////////////////////////////
//                                                                            //
// MIDTRCTab                                                                  //
//                                                                            //
// Begin_Html <!--
/*-->
<!--*/
// --> End_Html
//                                                                            //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
/* Generated header file containing necessary includes                        */
#include "generated/MIDTRCTabGeneratedIncludes.h"
////////////////////////////////////////////////////////////////////////////////
/*  This header was generated by ROMEBuilder. Manual changes above the        *
 * following line will be lost next time ROMEBuilder is executed.             */
/////////////////////////////////////----///////////////////////////////////////
#include "generated/MIDWindow.h"
#include "generated/MIDAnalyzer.h"
#include "tabs/MIDTRCTab.h"
#include "tasks/MIDTFillHistogramraw.h"
#include "TAxis.h"
#include "TLatex.h"
#include <TGClient.h>
#include <TCanvas.h>
#include <TRandom.h>
#include <TGButton.h>
#include <TGFrame.h>
#include <TRootEmbeddedCanvas.h>
#include <RQ_OBJECT.h>
#include<TString.h>
#include<TDatime.h>
// uncomment if you want to include headers of all folders
#include "MIDAllFolders.h"
ClassImp(MIDTRCTab)
using namespace std;
//______________________________________________________________________________
void MIDTRCTab::Init()
{
  // Create style for this tab                                                                                                                                         
  TStyle *orgStyle = gStyle;
  fStyle = new TStyle(*orgStyle); // copy the original style                                                                                                           
  fStyle->SetOptTitle(1);
  fStyle->SetTitleOffset(0.38, "y");
  fStyle->SetPadGridX(1);
  fStyle->SetPadGridY(1);
  fStyle->SetPadTickX(1);
  fStyle->SetPadTickY(1);
  fStyle->SetFrameBorderSize(0);
  fStyle->SetFrameBorderMode(0);
  fStyle->SetFrameFillStyle(0);
  fStyle->SetTitleSize(0.06, "t");
  fStyle->SetStatH(0.30);
  fStyle->SetStatW(0.30);
  fStyle->cd();
  // Create a vertical frame containing buttons and canvas                                                                                                             
  fVert = new TGVerticalFrame(this, (UInt_t) (700 * gAnalyzer->GetWindow()->GetWindowScale()), (UInt_t) (700 * gAnalyzer->GetWindow()->GetWindowScale()));
  // Create an embedded canvas and add to the main frame, centered in x and y                                            
  // set data member                                                                                
  fCanvasName =  new TString ("Sample Canvas");
                                              
  fCanvas = new TRootEmbeddedCanvas("Sample Canvas", fVert, (UInt_t) (600 * gAnalyzer->GetWindow()->GetWindowScale()), (UInt_t) (600 * gAnalyzer->GetWindow()->GetWindowScale()));
  fCanvas->GetCanvas()->Divide(5, 11);
  // Create "Update" button                                                    
  ULong_t yellow;
  gClient->GetColorByName("Yellow",yellow);                                                     
  fBUpdate = new TGTextButton(fVert, "Update");
  fBUpdate->ChangeBackground(yellow);
  fBUpdate->Associate(this);
  //  fVert->AddFrame(fCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 4, 4, 4, 4));
  fVert->AddFrame(fBUpdate, new TGLayoutHints(kLHintsCenterX, 10, 10, 4, 4));
  AddFrame(fVert, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 10, 4, 4));
  //create Exit button
  ULong_t red;
  gClient->GetColorByName("Red",red);
  fExit = new TGTextButton(fVert, "&Exit", "gApplication->Terminate(0)");
  fExit->ChangeBackground(red);
  fExit->Associate(this);
  fVert->AddFrame(fExit, new TGLayoutHints(kLHintsCenterX, 10, 10, 4, 4));
  //create save button                                                                                                   
                                                                                                                         
  ULong_t green;
  gClient->GetColorByName("Green",green);
  fSaveCanvas = new TGTextButton(fVert, "SaveCanvas");
  fSaveCanvas->ChangeBackground(green);
  fSaveCanvas->Associate(this);
  fVert->AddFrame(fSaveCanvas, new TGLayoutHints(kLHintsCenterX, 10, 10, 4, 4));
  fVert->AddFrame(fCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 4, 4, 4, 4));
  //  AddFrame(fVert, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 4, 4, 4, 4));
  ConnectAll();
  orgStyle->cd();
}
//______________________________________________________________________________
void MIDTRCTab::EndInit()
{
}
//______________________________________________________________________________
void MIDTRCTab::EventHandler()
{
}
//______________________________________________________________________________
void MIDTRCTab::MenuClicked(TGPopupMenu * /* menu */, Long_t /* param */)
{
}
//______________________________________________________________________________
void MIDTRCTab::TabSelected()
{
}
//______________________________________________________________________________
void MIDTRCTab::TabUnSelected()
{
}
  // Save Canvas:                                                                                   
  // you'll need a function of the same signature in your .h -> also make sure that TString is included in your .h                                                                                      
  void MIDTRCTab::SaveCanvas()
{
  // if following doesn't work blame Sabato Leo                                                     
  TString * fileName = new TString (fCanvasName->Data());
  //replace all spaces in your canvas name                                                        
  fileName->ReplaceAll(" ", "");
  //generate data and time stamp -> Recall you'll have to make sure TDatime is included           
  TDatime  dateTime; // time and date remain frozen when this function was called                 
  TString dateAsString = Form("%d", dateTime.GetDate());
  TString timeAsString = Form("%d", dateTime.GetTime());
  // append time date etc to canvas name                                                          
  (*fileName) += ".";
  (*fileName) += dateAsString;
  (*fileName) += ".";
  (*fileName) += timeAsString;
  (*fileName) += ".pdf"; // pdf for now maybe think about png and other options for user later ? 
  // debug                                                                                        
  //cout << " This is the filename " << fileName->Data() << endl;
  // now print it and hope it works ....                                                          
  fCanvas->GetCanvas()->Print(fileName->Data());
  //  cout << " Already attempted to print this file  " << fileName->Data() << endl;
  }
void MIDTRCTab::Update()
{
  TStyle *orgStyle = gStyle;
  fStyle->cd();
  TH1 *histo;
  for (Int_t i = 0; i < 55; i++) { //loop over all 55 pads
    fCanvas->GetCanvas()->cd(i + 1);
    histo = (TH1F *) gAnalyzer->GetFillHistogramrawTask()->Geth1_wfAt(i);
    if (!histo) {
      cout << "Histo ADC not available." << endl;
    } else {
      histo->Draw();
    }
  }
  fCanvas->GetCanvas()->cd(0);
  fCanvas->GetCanvas()->Modified();
  fCanvas->GetCanvas()->Update();
  orgStyle->cd();
  return;
}
//_____________________________________________________________________________\
_                                                                               
void MIDTRCTab::ConnectAll()
{
  fBUpdate->Connect("Pressed()", "MIDTRCTab", this, "Update()");
  fExit->Connect("Pressed()", "MIDTRCTab", this, "&Exit()");
  fSaveCanvas->Connect("Pressed()","MIDTRCTab", this, "SaveCanvas()");
}
//_____________________________________________________________________________\
_                                                                               
void MIDTRCTab::DisconnectAll()
{
  if (fBUpdate) { fBUpdate->Disconnect(this); }
  if (fExit) { fExit->Disconnect(this); }
  if(fSaveCanvas) { fSaveCanvas->Disconnect(this);}
}
 |