MyTestLoop Class Reference

Inheritance diagram for MyTestLoop:
Inheritance graph
[legend]
Collaboration diagram for MyTestLoop:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MyTestLoop ()
void AddAllCanvases ()
 User must.
virtual ~MyTestLoop ()
void ResetHistograms ()
 This method can be implemented by users to plotting of current canvas.
void UpdateHistograms (TDataContainer &dataContainer)
 This method can be implemented by users to update user histograms.
void PlotCanvas (TDataContainer &dataContainer)
 This method can be implemented by users to plotting of current canvas.
 MyTestLoop ()
virtual ~MyTestLoop ()
void BeginRun (int transition, int run, int time)
void EndRun (int transition, int run, int time)
bool ProcessMidasEvent (TDataContainer &dataContainer)
void Usage (void)
bool CheckOption (std::string option)
 MyTestLoop ()
void AddAllCanvases ()
 User must.
virtual ~MyTestLoop ()
void ResetHistograms ()
 This method can be implemented by users to plotting of current canvas.
void UpdateHistograms (TDataContainer &dataContainer)
 This method can be implemented by users to update user histograms.
void PlotCanvas (TDataContainer &dataContainer)
 This method can be implemented by users to plotting of current canvas.
void AddSingleCanvas (std::string name, std::string subtab_name=std::string(""))
 Add a new canvas; user will interactively fill it.
void AddSingleCanvas (TCanvasHandleBase *handleClass, std::string subtab_name=std::string(""))
TMainDisplayWindowGetDisplayWindow ()
void NextButtonPushed ()
 Method for when next button is pushed (offline mode).
void EventSkipButtonPushed ()
 Method for when skip event button is pushed (online mode).
void Reset ()
void UpdatePlotsAction ()
void QuitButtonAction ()
 Method to call when 'quit' button is pressed.
void SetNumberSkipEvent (int number)
std::string GetDisplayName ()
 Get Display name.
void SetDisplayName (std::string name)
 Set Display name.
void Initialize ()
bool CheckOptionRAD (std::string option)
void UsageRAD ()
 Also a special version of usage for TRootanaDisplay. See CheckOptionRAD.
TDataContainerGetDataContainer ()
 Method to get the data container that event loop owns.
virtual void Finalize ()
virtual bool PreFilter (TDataContainer &dataContainer)
bool IsOnline () const
 Are we processing online data?
bool IsOffline () const
 Are we processing offline data?
int GetCurrentRunNumber () const
 Current Run Number.
void SetCurrentRunNumber (int run)
 Current Run Number.
int ExecuteLoop (int argc, char *argv[])
 Method to actually process the Midas information, either as file or online.
int ProcessMidasFile (TApplication *app, const char *fname)
void DisableAutoMainWindow ()
 Disable automatic creation of MainWindow.
void UseBatchMode ()
 Use a batch mode, where we don't check ROOT status.
VirtualOdbGetODB ()
 Get pointer to ODB variables.
void OpenRootFile (int run, std::string midasFilename=std::string(""))
 Open output ROOT file.
void CloseRootFile ()
 Cloe output ROOT file.
bool IsRootFileValid ()
 Check if output ROOT file is valid and open.
void DisableRootOutput (bool disable=true)
int IsRootOutputEnabled ()
void SetOutputFilename (std::string name)
virtual std::string SetFullOutputFileName (int run, std::string midasFilename)
void SetOnlineName (std::string name)
void ProcessThisEventID (int eventID)
bool CheckEventID (int eventId)
 Little helper method to check if EventID matchs requested EventID list.
void SuppressTimestampWarnings ()
bool GetSuppressTimestampWarnings ()
 Suppress timestamp warnings? true = suppress warnings.
void UseOnlyRecent (bool setting=true)
TDataContainerGetDataContainer ()
 Method to get the data container that event loop owns.
bool IsOnline () const
 Are we processing online data?
bool IsOffline () const
 Are we processing offline data?
int GetCurrentRunNumber () const
 Current Run Number.
void SetCurrentRunNumber (int run)
 Current Run Number.
int ExecuteLoop (int argc, char *argv[])
 Method to actually process the Midas information, either as file or online.
int ProcessMidasFile (TApplication *app, const char *fname)
void DisableAutoMainWindow ()
 Disable automatic creation of MainWindow.
void UseBatchMode ()
 Use a batch mode, where we don't check ROOT status.
VirtualOdbGetODB ()
 Get pointer to ODB variables.
void OpenRootFile (int run, std::string midasFilename=std::string(""))
 Open output ROOT file.
void CloseRootFile ()
 Cloe output ROOT file.
bool IsRootFileValid ()
 Check if output ROOT file is valid and open.
void DisableRootOutput (bool disable=true)
int IsRootOutputEnabled ()
void SetOutputFilename (std::string name)
void SetOnlineName (std::string name)
void ProcessThisEventID (int eventID)
bool CheckEventID (int eventId)
 Little helper method to check if EventID matchs requested EventID list.
void SuppressTimestampWarnings ()
bool GetSuppressTimestampWarnings ()
 Suppress timestamp warnings? true = suppress warnings.
void UseOnlyRecent (bool setting=true)

Static Public Member Functions

static TRootanaEventLoopGet (void)
template<typename T >
static void CreateSingleton ()
static TRootanaEventLoopGet (void)
template<typename T >
static void CreateSingleton ()

Public Attributes

TAnaManageranaManager

Protected Member Functions

bool CreateOutputFile (std::string name, std::string options="RECREATE")
bool CreateOutputFile (std::string name, std::string options="RECREATE")

Protected Attributes

TDirectoryfOnlineHistDir
 TDirectory for online histograms.
TDirectoryfOnlineHistDir
 TDirectory for online histograms.

Static Protected Attributes

static TRootanaEventLoopfTRootanaEventLoop = NULL
 The static pointer to the singleton instance.
static TRootanaEventLoopfTRootanaEventLoop = NULL
 The static pointer to the singleton instance.

Private Attributes

int nnn
TH1F * sizeBankFR10

Detailed Description

This is an example of the a user defined event display. The user then needs to define how they what to update and plot histograms. The updating of histograms happens for each event. In online mode, the plotting of histograms only happens for each XX events; for offline mode the plotting happens for each event.

There are two ways that users can decide to update and plot histograms:

1) They can create histograms in their event display class and then fill the methods UpdateHistograms(TMidasEvent*) and PlotCanvas(TMidasEvent*). This histograms can then file in the canvases that are added using AddSingleCanvas(std::string name).

In this example this method is used for the histogram sizeBankFR10, which is just a histogram of the size of the bank called "FR10".

2) They can create classes that are derived from TCanvasHandleBase. The derived classes are then added using the method AddSingleCanvas(TCanvasHandleBase* handleClass). In this example there are two classes derived from TCanvasHandleBase: a) TSimpleExampleCanvas: this class just creates a tab/canvas with a histogram of the size of the bank called "FR11". a) TComplicatedExampleCanvas: this class creates a set of four different canvases/histograms which the user can select using a ROOT number widget.

The actual ROOT GUI is encapsulated in a separate class TMainDisplayWindow. The TRootanaDisplay has an instance of this TMainDisplayWindow class. Users will be need to access the TMainDisplayWindow by calling

TRootanaDisplay::GetDisplayWindow()

in order to grab the particular canvas that we want plot on.

Definition at line 14 of file anaDisplay.cxx.


Constructor & Destructor Documentation

MyTestLoop::MyTestLoop (  )  [inline]

Definition at line 22 of file anaDisplay.cxx.

References anaManager, TRootanaEventLoop::DisableRootOutput(), and TRootanaEventLoop::SetOutputFilename().

00022                {
00023     SetOutputFilename("example_output");
00024     DisableRootOutput(false);
00025 
00026                 anaManager = new TAnaManager();
00027                 
00028   }

Here is the call graph for this function:

virtual MyTestLoop::~MyTestLoop (  )  [inline, virtual]

Definition at line 65 of file anaDisplay.cxx.

00065 {};

MyTestLoop::MyTestLoop (  )  [inline]

Definition at line 19 of file analyzer_example.cxx.

References nnn.

00019                {
00020     nnn = 0;
00021   };

virtual MyTestLoop::~MyTestLoop (  )  [inline, virtual]

Definition at line 23 of file analyzer_example.cxx.

00023 {};

MyTestLoop::MyTestLoop (  )  [inline]

Definition at line 48 of file display_example.cxx.

References sizeBankFR10.

00048                {
00049     
00050     // Initialize histograms.
00051     sizeBankFR10 = new TH1F("sizeBankFR10","Size of FR10 bank",2000,0,10000);
00052   }

virtual MyTestLoop::~MyTestLoop (  )  [inline, virtual]

Definition at line 63 of file display_example.cxx.

00063 {};


Member Function Documentation

void MyTestLoop::AddAllCanvases (  )  [inline, virtual]

User must.

Implements TRootanaDisplay.

Definition at line 54 of file display_example.cxx.

References TRootanaDisplay::AddSingleCanvas(), TRootanaDisplay::SetDisplayName(), and TRootanaDisplay::SetNumberSkipEvent().

00054                        {
00055     // Set up tabbed canvases
00056     AddSingleCanvas(new TSimpleExampleCanvas());
00057     AddSingleCanvas(new TComplicatedExampleCanvas());
00058     AddSingleCanvas("FR10"); 
00059     SetNumberSkipEvent(20);
00060     SetDisplayName("Example Display");
00061   };

Here is the call graph for this function:

void MyTestLoop::AddAllCanvases (  )  [inline, virtual]

User must.

Implements TRootanaDisplay.

Definition at line 30 of file anaDisplay.cxx.

References TRootanaDisplay::AddSingleCanvas(), anaManager, TAnaManager::GetAgilentistograms(), TAnaManager::GetDT724Histograms(), TAnaManager::GetL2249Histograms(), TAnaManager::GetV1190Histograms(), TAnaManager::GetV1720Histograms(), TAnaManager::GetV1730DPPistograms(), TAnaManager::GetV1730Rawistograms(), TAnaManager::GetV792Histograms(), TAnaManager::HaveAgilentistograms(), TAnaManager::HaveDT724Histograms(), TAnaManager::HaveL2249Histograms(), TAnaManager::HaveV1190Histograms(), TAnaManager::HaveV1720Histograms(), TAnaManager::HaveV1730DPPistograms(), TAnaManager::HaveV1730Rawistograms(), TAnaManager::HaveV792Histograms(), TRootanaDisplay::SetDisplayName(), and TRootanaDisplay::SetNumberSkipEvent().

00030                        {
00031 
00032     // Number of events to skip before plotting one.
00033     SetNumberSkipEvent(10);
00034 
00035     // Set up tabbed canvases
00036     
00037     
00038     if(anaManager->HaveV792Histograms()) 
00039       AddSingleCanvas(new TFancyHistogramCanvas(anaManager->GetV792Histograms(),"V792"));
00040     
00041     if(anaManager->HaveV1190Histograms()) 
00042       AddSingleCanvas(new TFancyHistogramCanvas(anaManager->GetV1190Histograms(),"V1190"));
00043     
00044     if(anaManager->HaveL2249Histograms()) 
00045       AddSingleCanvas(new TFancyHistogramCanvas(anaManager->GetL2249Histograms(),"L2249"));
00046     
00047     if(anaManager->HaveAgilentistograms()) 
00048       AddSingleCanvas(new TFancyHistogramCanvas(anaManager->GetAgilentistograms(),"AGILENT"));
00049     
00050     if(anaManager->HaveV1720Histograms()) 
00051       AddSingleCanvas(new TFancyHistogramCanvas(anaManager->GetV1720Histograms(),"V1720 Waveforms"));
00052     
00053     if(anaManager->HaveV1730DPPistograms()) 
00054       AddSingleCanvas(new TFancyHistogramCanvas(anaManager->GetV1730DPPistograms(),"V1730 Waveforms"));
00055     
00056     if(anaManager->HaveV1730Rawistograms()) 
00057       AddSingleCanvas(new TFancyHistogramCanvas(anaManager->GetV1730Rawistograms(),"V1730 Waveforms"));
00058     
00059     if(anaManager->HaveDT724Histograms()) 
00060       AddSingleCanvas(new TFancyHistogramCanvas(anaManager->GetDT724Histograms(),"DT724 Waveforms"));
00061     
00062     SetDisplayName("Example Display");
00063   };

Here is the call graph for this function:

void TRootanaDisplay::AddSingleCanvas ( TCanvasHandleBase handleClass,
std::string  subtab_name = std::string("") 
) [inherited]

Add a new canvas, using a TCanvasHandleBase class. TRootanaDisplay will take ownership of pointer and delete memory it points to.

Definition at line 74 of file TRootanaDisplay.cxx.

References TMainDisplayWindow::AddCanvas(), TRootanaDisplay::fCanvasHandlers, TMainDisplayWindow::GetCompositeFrame(), TRootanaDisplay::GetDisplayWindow(), TMainDisplayWindow::GetSubTab(), TCanvasHandleBase::GetTabName(), and TCanvasHandleBase::SetUpCompositeFrame().

00074                                                                                           {
00075   
00076   std::pair<int,int> index = GetDisplayWindow()->AddCanvas(handleClass->GetTabName(),subtab_name);
00077 
00078   std::pair< std::pair<int,int>, TCanvasHandleBase*> tmp(index,handleClass);
00079   
00080   fCanvasHandlers.push_back(tmp);
00081   // Now set up the embedded canvas, if user so desires.
00082   TGCompositeFrame* embed = GetDisplayWindow()->GetCompositeFrame(index);//ssGetTab()->GetTabContainer(tab_index);
00083   handleClass->SetUpCompositeFrame(embed,this);
00084 
00085   // If we just created a new sub-tab, grab the tab and add
00086   // call-back to UpdatePlot
00087   if(index.second == 0){
00088     TGTab* tab = GetDisplayWindow()->GetSubTab(index.first);
00089     tab->Connect("Selected(Int_t)", "TRootanaDisplay", this, "UpdatePlotsAction()");
00090   }
00091 
00092 
00093 }

Here is the call graph for this function:

void TRootanaDisplay::AddSingleCanvas ( std::string  name,
std::string  subtab_name = std::string("") 
) [inline, inherited]

Add a new canvas; user will interactively fill it.

Definition at line 70 of file TRootanaDisplay.hxx.

References TMainDisplayWindow::AddCanvas(), and TRootanaDisplay::fMainWindow.

Referenced by AddAllCanvases().

00070                                                                              {
00071     fMainWindow->AddCanvas(name,subtab_name);
00072   }

Here is the call graph for this function:

Here is the caller graph for this function:

void MyTestLoop::BeginRun ( int  transition,
int  run,
int  time 
) [inline, virtual]

Called before the first event of a file is read, but you should prefer Initialize() for general initialization. This method will be called once for each input file.

Reimplemented from TRootanaEventLoop.

Definition at line 25 of file analyzer_example.cxx.

00025                                                 {
00026     std::cout << "Custom: begin run " << run << std::endl;
00027   }

bool TRootanaEventLoop::CheckEventID ( int  eventId  )  [inherited]

Little helper method to check if EventID matchs requested EventID list.

Definition at line 135 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::fProcessEventIDs.

Referenced by TRootanaEventLoop::ProcessMidasFile().

00135                                                {
00136 
00137   // If we didn't specify list of accepted IDs, then accept all.
00138   if(fProcessEventIDs.size()==0) return true;
00139 
00140   // Otherwise check event ID against list
00141   for(unsigned int i = 0; i < fProcessEventIDs.size(); i++){
00142     if(fProcessEventIDs[i] == (eventId & 0xFFFF))
00143       return true;
00144   }
00145   
00146   return false;
00147 }

Here is the caller graph for this function:

bool TRootanaEventLoop::CheckEventID ( int  eventId  )  [inherited]

Little helper method to check if EventID matchs requested EventID list.

Definition at line 135 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::fProcessEventIDs.

Referenced by TRootanaEventLoop::ProcessMidasFile().

00135                                                {
00136 
00137   // If we didn't specify list of accepted IDs, then accept all.
00138   if(fProcessEventIDs.size()==0) return true;
00139 
00140   // Otherwise check event ID against list
00141   for(unsigned int i = 0; i < fProcessEventIDs.size(); i++){
00142     if(fProcessEventIDs[i] == (eventId & 0xFFFF))
00143       return true;
00144   }
00145   
00146   return false;
00147 }

Here is the caller graph for this function:

bool MyTestLoop::CheckOption ( std::string  option  )  [inline, virtual]

Check an option and return true if it is valid. The return value is used to flag errors during option handling. If the options are valid, then CheckOption should return true to indicate success. If there is a problem processing the options, then CheckOption should return false. If this returns false, then the event loop will print the Usage message and exit with a non zero value (i.e. indicate failure).

Reimplemented from TRootanaEventLoop.

Definition at line 89 of file analyzer_example.cxx.

00089                                     {
00090     const char* arg = option.c_str();
00091     if (strncmp(arg,"-D",2)==0){
00092       std::cout << arg+2 << std::endl;
00093       std::cout << "I'm happy with this flag!" << std::endl;
00094       return true;
00095     }
00096 
00097     return false;
00098   }

bool TRootanaDisplay::CheckOptionRAD ( std::string  option  )  [inline, virtual, inherited]

This is a special version of CheckOption that is only used by TRootanaDisplay. This is just so that users still have the ability to set options for executables derived from TRootanaDisplay.

Reimplemented from TRootanaEventLoop.

Definition at line 131 of file TRootanaDisplay.hxx.

References TRootanaDisplay::fNumberSkipEventsOffline.

00131                                        {
00132     if(option.find("-s") != std::string::npos){
00133       std::string sub = option.substr(2);
00134       fNumberSkipEventsOffline = atoi(sub.c_str());
00135       printf("Will process %i events before plotting first event.\n",fNumberSkipEventsOffline);
00136       return true;
00137     }
00138     return false;
00139   }

void TRootanaEventLoop::CloseRootFile (  )  [inherited]

Cloe output ROOT file.

Definition at line 456 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::fOutputFile.

Referenced by TRootanaEventLoop::ProcessMidasFile(), TRootanaDisplay::QuitButtonAction(), and TRootanaEventLoop::~TRootanaEventLoop().

00456                                      {
00457 
00458   if(fOutputFile) {
00459                 std::cout << "Closing ROOT file " << std::endl;
00460     fOutputFile->Write();
00461     fOutputFile->Close();
00462     fOutputFile=0;
00463   } 
00464 
00465 }

Here is the caller graph for this function:

void TRootanaEventLoop::CloseRootFile (  )  [inherited]

Cloe output ROOT file.

Definition at line 456 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::fOutputFile.

Referenced by TRootanaEventLoop::ProcessMidasFile(), TRootanaDisplay::QuitButtonAction(), and TRootanaEventLoop::~TRootanaEventLoop().

00456                                      {
00457 
00458   if(fOutputFile) {
00459                 std::cout << "Closing ROOT file " << std::endl;
00460     fOutputFile->Write();
00461     fOutputFile->Close();
00462     fOutputFile=0;
00463   } 
00464 
00465 }

Here is the caller graph for this function:

bool TRootanaEventLoop::CreateOutputFile ( std::string  name,
std::string  options = "RECREATE" 
) [inline, protected, inherited]

Definition at line 198 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fOutputFile.

00198                                                                        {
00199     
00200     fOutputFile = new TFile(name.c_str(),options.c_str());
00201     
00202     return true;
00203   }

bool TRootanaEventLoop::CreateOutputFile ( std::string  name,
std::string  options = "RECREATE" 
) [inline, protected, inherited]

Definition at line 198 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fOutputFile.

00198                                                                        {
00199     
00200     fOutputFile = new TFile(name.c_str(),options.c_str());
00201     
00202     return true;
00203   }

template<typename T >
static void TRootanaEventLoop::CreateSingleton (  )  [inline, static, inherited]

This static templated function will make it a little easier for users to create the singleton instance.

Definition at line 125 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fTRootanaEventLoop.

00126   {
00127     if(fTRootanaEventLoop)
00128       std::cout << "Singleton has already been created" << std::endl;
00129     else
00130       fTRootanaEventLoop = new T();
00131   } 

template<typename T >
static void TRootanaEventLoop::CreateSingleton (  )  [inline, static, inherited]

This static templated function will make it a little easier for users to create the singleton instance.

Definition at line 125 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fTRootanaEventLoop.

00126   {
00127     if(fTRootanaEventLoop)
00128       std::cout << "Singleton has already been created" << std::endl;
00129     else
00130       fTRootanaEventLoop = new T();
00131   } 

void TRootanaEventLoop::DisableAutoMainWindow (  )  [inline, inherited]

Disable automatic creation of MainWindow.

Definition at line 135 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fCreateMainWindow.

00135 {  fCreateMainWindow = false;}

void TRootanaEventLoop::DisableAutoMainWindow (  )  [inline, inherited]

Disable automatic creation of MainWindow.

Definition at line 135 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fCreateMainWindow.

00135 {  fCreateMainWindow = false;}

void TRootanaEventLoop::DisableRootOutput ( bool  disable = true  )  [inline, inherited]

Definition at line 157 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fDisableRootOutput.

Referenced by MyTestLoop().

00157 {fDisableRootOutput = disable;};

Here is the caller graph for this function:

void TRootanaEventLoop::DisableRootOutput ( bool  disable = true  )  [inline, inherited]

Definition at line 157 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fDisableRootOutput.

Referenced by MyTestLoop().

00157 {fDisableRootOutput = disable;};

Here is the caller graph for this function:

void MyTestLoop::EndRun ( int  transition,
int  run,
int  time 
) [inline, virtual]

Called after the last event of a file is read, but you should prefer Finalize() for general finalization. This method will be called once for each input file.

Reimplemented from TRootanaEventLoop.

Definition at line 29 of file analyzer_example.cxx.

00029                                               {
00030     std::cout << "Custom end run " << run <<std::endl;
00031   }

void TRootanaDisplay::EventSkipButtonPushed (  )  [inline, inherited]

Method for when skip event button is pushed (online mode).

Definition at line 98 of file TRootanaDisplay.hxx.

References TRootanaDisplay::fMainWindow, TRootanaDisplay::fNumberSkipEventsOnline, and TMainDisplayWindow::GetSkipEventButton().

00098                               {
00099     fNumberSkipEventsOnline = fMainWindow->GetSkipEventButton()->GetNumberEntry()->GetIntNumber();
00100   }

Here is the call graph for this function:

int TRootanaEventLoop::ExecuteLoop ( int  argc,
char *  argv[] 
) [inherited]

Method to actually process the Midas information, either as file or online.

Definition at line 177 of file TRootanaEventLoop.cxx.

References TDirectory::cd(), TRootanaEventLoop::CheckOption(), TRootanaEventLoop::CheckOptionRAD(), TRootanaEventLoop::fApp, TRootanaEventLoop::fBufferName, TRootanaEventLoop::fCreateMainWindow, TRootanaEventLoop::Finalize(), TRootanaEventLoop::fIsOffline, TRootanaEventLoop::fMaxEvents, TRootanaEventLoop::fOnlineHistDir, TRootanaEventLoop::fUseBatchMode, TRootanaEventLoop::Initialize(), TRootanaEventLoop::PrintHelp(), TRootanaEventLoop::ProcessMidasFile(), and StartNetDirectoryServer().

Referenced by main().

00177                                                         {
00178   
00179   setbuf(stdout,NULL);
00180   setbuf(stderr,NULL);
00181   
00182   signal(SIGILL,  SIG_DFL);
00183   signal(SIGBUS,  SIG_DFL);
00184   signal(SIGSEGV, SIG_DFL);
00185 
00186   std::vector<std::string> args;
00187   for (int i=0; i<argc; i++)
00188     {
00189       if (strcmp(argv[i],"-h")==0)
00190         PrintHelp(); // does not return
00191       args.push_back(argv[i]);
00192     }
00193   
00194   
00195   if(fUseBatchMode){ // Disable creating extra window if batch mode requested.
00196     fCreateMainWindow = false;
00197   }
00198     
00199   if(gROOT->IsBatch() && !fUseBatchMode) {
00200     printf("Cannot run in batch mode\n");
00201     return 1;
00202   }
00203 
00204   bool forceEnableGraphics = false;
00205   bool testMode = false;
00206   int  tcpPort = 0;
00207   int  rhttpdPort = 0; // ROOT THttpServer port
00208   const char* hostname = NULL;
00209   const char* exptname = NULL;
00210   
00211   for (unsigned int i=1; i<args.size(); i++) // loop over the commandline options
00212     {
00213       const char* arg = args[i].c_str();
00214       //printf("argv[%d] is %s\n",i,arg);
00215       
00216       if (strncmp(arg,"-e",2)==0)  // Event cutoff flag (only applicable in offline mode)
00217         fMaxEvents = atoi(arg+2);
00218       else if (strncmp(arg,"-m",2)==0) // Enable memory debugging
00219         ;//      gEnableShowMem = true;
00220       else if (strncmp(arg,"-P",2)==0) // Set the histogram server port
00221         tcpPort = atoi(arg+2);
00222 #ifdef HAVE_THTTP_SERVER
00223       else if (strncmp(arg,"-r",2)==0) // Set the THttpdServer port
00224         rhttpdPort = atoi(arg+2);
00225 #endif
00226       else if (strcmp(arg,"-T")==0)
00227         testMode = true;
00228       else if (strcmp(arg,"-g")==0)
00229         forceEnableGraphics = true;
00230       else if (strncmp(arg,"-H",2)==0)
00231         hostname = strdup(arg+2);
00232       else if (strncmp(arg,"-E",2)==0)
00233         exptname = strdup(arg+2);
00234       else if (strncmp(arg,"-b",2)==0){
00235         fBufferName = std::string(arg+2);        
00236       }else if (strcmp(arg,"-h")==0)
00237         PrintHelp(); // does not return
00238       else if(arg[0] == '-')// Check if a TRootanaDisplay or user-defined options
00239         if(!CheckOptionRAD(args[i]))
00240           if(!CheckOption(args[i]))
00241             PrintHelp(); // does not return
00242     }
00243     
00244   // Do quick check if we are processing online or offline.
00245   // Want to know before we initialize.
00246   fIsOffline = false;  
00247   for (unsigned int i=1; i<args.size(); i++){
00248     const char* arg = args[i].c_str();
00249     if (arg[0] != '-')  
00250       {  
00251         fIsOffline = true;
00252       }
00253   }
00254 
00255 
00256   MainWindow *mainWindow=0;
00257   if(fCreateMainWindow){
00258     std::cout << "Create main window! " << std::endl;
00259     mainWindow = new MainWindow(gClient->GetRoot(), 200, 300);
00260   }
00261 
00262    gROOT->cd();
00263    fOnlineHistDir = new TDirectory("rootana", "rootana online plots");
00264 
00265 #ifdef HAVE_LIBNETDIRECTORY
00266    if (tcpPort)
00267      StartNetDirectoryServer(tcpPort, fOnlineHistDir);
00268 #else
00269    if (tcpPort)
00270      fprintf(stderr,"ERROR: No support for the TNetDirectory server!\n");
00271 #endif
00272 
00273 #ifdef HAVE_THTTP_SERVER
00274 
00275    THttpServer *root_http_serv; // = new THttpServer("http:8080");
00276    if(rhttpdPort){
00277      char address[100];
00278      sprintf(address,"http:%i",rhttpdPort);
00279      root_http_serv = new THttpServer(address);
00280    }
00281 #endif
00282   
00283    // Initialize the event loop with user initialization.
00284    Initialize();
00285 
00286    for (unsigned int i=1; i<args.size(); i++){
00287      const char* arg = args[i].c_str();
00288      if (arg[0] != '-')  
00289        {  
00290            ProcessMidasFile(fApp,arg);
00291        }
00292    }
00293 
00294    if (testMode){
00295      std::cout << "Entering test mode." << std::endl;
00296      fOnlineHistDir->cd();
00297      TH1D* hh = new TH1D("test", "test", 100, 0, 100);
00298      hh->Fill(1);
00299      hh->Fill(10);
00300      hh->Fill(50);
00301      
00302      fApp->Run(kTRUE);
00303      if(fCreateMainWindow) delete mainWindow;
00304      return 0;
00305    }
00306 
00307    // if we processed some data files,
00308    // do not go into online mode.
00309    if (fIsOffline){
00310      if(fCreateMainWindow) delete mainWindow;
00311      return 0;
00312    }
00313  
00314 #ifdef HAVE_MIDAS
00315    ProcessMidasOnline(fApp, hostname, exptname);;
00316 #endif
00317    
00318    if(fCreateMainWindow) delete mainWindow;
00319    
00320    Finalize();
00321    
00322    return 0;
00323   
00324 }

Here is the call graph for this function:

Here is the caller graph for this function:

int TRootanaEventLoop::ExecuteLoop ( int  argc,
char *  argv[] 
) [inherited]

Method to actually process the Midas information, either as file or online.

Definition at line 177 of file TRootanaEventLoop.cxx.

References TDirectory::cd(), TRootanaEventLoop::CheckOption(), TRootanaEventLoop::CheckOptionRAD(), TRootanaEventLoop::fApp, TRootanaEventLoop::fBufferName, TRootanaEventLoop::fCreateMainWindow, TRootanaEventLoop::Finalize(), TRootanaEventLoop::fIsOffline, TRootanaEventLoop::fMaxEvents, TRootanaEventLoop::fOnlineHistDir, TRootanaEventLoop::fUseBatchMode, TRootanaEventLoop::Initialize(), TRootanaEventLoop::PrintHelp(), TRootanaEventLoop::ProcessMidasFile(), and StartNetDirectoryServer().

Referenced by main().

00177                                                         {
00178   
00179   setbuf(stdout,NULL);
00180   setbuf(stderr,NULL);
00181   
00182   signal(SIGILL,  SIG_DFL);
00183   signal(SIGBUS,  SIG_DFL);
00184   signal(SIGSEGV, SIG_DFL);
00185 
00186   std::vector<std::string> args;
00187   for (int i=0; i<argc; i++)
00188     {
00189       if (strcmp(argv[i],"-h")==0)
00190         PrintHelp(); // does not return
00191       args.push_back(argv[i]);
00192     }
00193   
00194   
00195   if(fUseBatchMode){ // Disable creating extra window if batch mode requested.
00196     fCreateMainWindow = false;
00197   }
00198     
00199   if(gROOT->IsBatch() && !fUseBatchMode) {
00200     printf("Cannot run in batch mode\n");
00201     return 1;
00202   }
00203 
00204   bool forceEnableGraphics = false;
00205   bool testMode = false;
00206   int  tcpPort = 0;
00207   int  rhttpdPort = 0; // ROOT THttpServer port
00208   const char* hostname = NULL;
00209   const char* exptname = NULL;
00210   
00211   for (unsigned int i=1; i<args.size(); i++) // loop over the commandline options
00212     {
00213       const char* arg = args[i].c_str();
00214       //printf("argv[%d] is %s\n",i,arg);
00215       
00216       if (strncmp(arg,"-e",2)==0)  // Event cutoff flag (only applicable in offline mode)
00217         fMaxEvents = atoi(arg+2);
00218       else if (strncmp(arg,"-m",2)==0) // Enable memory debugging
00219         ;//      gEnableShowMem = true;
00220       else if (strncmp(arg,"-P",2)==0) // Set the histogram server port
00221         tcpPort = atoi(arg+2);
00222 #ifdef HAVE_THTTP_SERVER
00223       else if (strncmp(arg,"-r",2)==0) // Set the THttpdServer port
00224         rhttpdPort = atoi(arg+2);
00225 #endif
00226       else if (strcmp(arg,"-T")==0)
00227         testMode = true;
00228       else if (strcmp(arg,"-g")==0)
00229         forceEnableGraphics = true;
00230       else if (strncmp(arg,"-H",2)==0)
00231         hostname = strdup(arg+2);
00232       else if (strncmp(arg,"-E",2)==0)
00233         exptname = strdup(arg+2);
00234       else if (strncmp(arg,"-b",2)==0){
00235         fBufferName = std::string(arg+2);        
00236       }else if (strcmp(arg,"-h")==0)
00237         PrintHelp(); // does not return
00238       else if(arg[0] == '-')// Check if a TRootanaDisplay or user-defined options
00239         if(!CheckOptionRAD(args[i]))
00240           if(!CheckOption(args[i]))
00241             PrintHelp(); // does not return
00242     }
00243     
00244   // Do quick check if we are processing online or offline.
00245   // Want to know before we initialize.
00246   fIsOffline = false;  
00247   for (unsigned int i=1; i<args.size(); i++){
00248     const char* arg = args[i].c_str();
00249     if (arg[0] != '-')  
00250       {  
00251         fIsOffline = true;
00252       }
00253   }
00254 
00255 
00256   MainWindow *mainWindow=0;
00257   if(fCreateMainWindow){
00258     std::cout << "Create main window! " << std::endl;
00259     mainWindow = new MainWindow(gClient->GetRoot(), 200, 300);
00260   }
00261 
00262    gROOT->cd();
00263    fOnlineHistDir = new TDirectory("rootana", "rootana online plots");
00264 
00265 #ifdef HAVE_LIBNETDIRECTORY
00266    if (tcpPort)
00267      StartNetDirectoryServer(tcpPort, fOnlineHistDir);
00268 #else
00269    if (tcpPort)
00270      fprintf(stderr,"ERROR: No support for the TNetDirectory server!\n");
00271 #endif
00272 
00273 #ifdef HAVE_THTTP_SERVER
00274 
00275    THttpServer *root_http_serv; // = new THttpServer("http:8080");
00276    if(rhttpdPort){
00277      char address[100];
00278      sprintf(address,"http:%i",rhttpdPort);
00279      root_http_serv = new THttpServer(address);
00280    }
00281 #endif
00282   
00283    // Initialize the event loop with user initialization.
00284    Initialize();
00285 
00286    for (unsigned int i=1; i<args.size(); i++){
00287      const char* arg = args[i].c_str();
00288      if (arg[0] != '-')  
00289        {  
00290            ProcessMidasFile(fApp,arg);
00291        }
00292    }
00293 
00294    if (testMode){
00295      std::cout << "Entering test mode." << std::endl;
00296      fOnlineHistDir->cd();
00297      TH1D* hh = new TH1D("test", "test", 100, 0, 100);
00298      hh->Fill(1);
00299      hh->Fill(10);
00300      hh->Fill(50);
00301      
00302      fApp->Run(kTRUE);
00303      if(fCreateMainWindow) delete mainWindow;
00304      return 0;
00305    }
00306 
00307    // if we processed some data files,
00308    // do not go into online mode.
00309    if (fIsOffline){
00310      if(fCreateMainWindow) delete mainWindow;
00311      return 0;
00312    }
00313  
00314 #ifdef HAVE_MIDAS
00315    ProcessMidasOnline(fApp, hostname, exptname);;
00316 #endif
00317    
00318    if(fCreateMainWindow) delete mainWindow;
00319    
00320    Finalize();
00321    
00322    return 0;
00323   
00324 }

Here is the call graph for this function:

Here is the caller graph for this function:

void TRootanaEventLoop::Finalize (  )  [virtual, inherited]

Called after the last event has been processed, but before any open output files are closed.

Definition at line 125 of file TRootanaEventLoop.cxx.

Referenced by TRootanaEventLoop::ExecuteLoop().

00125 {};

Here is the caller graph for this function:

TRootanaEventLoop & TRootanaEventLoop::Get ( void   )  [static, inherited]

Definition at line 72 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::fTRootanaEventLoop.

Referenced by main().

00072                                               {
00073   
00074   if(!fTRootanaEventLoop){
00075     std::cerr << "Singleton Not Instantiated! " 
00076               << " Need to call something like SomeClass::CreateSingleton<SomeClass>(); Exiting!"
00077               <<std::endl; exit(0);
00078   }
00079   return *fTRootanaEventLoop;
00080 }

Here is the caller graph for this function:

TRootanaEventLoop & TRootanaEventLoop::Get ( void   )  [static, inherited]

Definition at line 72 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::fTRootanaEventLoop.

Referenced by main().

00072                                               {
00073   
00074   if(!fTRootanaEventLoop){
00075     std::cerr << "Singleton Not Instantiated! " 
00076               << " Need to call something like SomeClass::CreateSingleton<SomeClass>(); Exiting!"
00077               <<std::endl; exit(0);
00078   }
00079   return *fTRootanaEventLoop;
00080 }

Here is the caller graph for this function:

int TRootanaEventLoop::GetCurrentRunNumber (  )  const [inline, inherited]

Current Run Number.

Definition at line 107 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fCurrentRunNumber.

Referenced by ProcessMidasEvent(), TRootanaDisplay::QuitButtonAction(), and TRootanaDisplay::UpdatePlotsAction().

00107 {return fCurrentRunNumber;};

Here is the caller graph for this function:

int TRootanaEventLoop::GetCurrentRunNumber (  )  const [inline, inherited]

Current Run Number.

Definition at line 107 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fCurrentRunNumber.

Referenced by ProcessMidasEvent(), TRootanaDisplay::QuitButtonAction(), and TRootanaDisplay::UpdatePlotsAction().

00107 {return fCurrentRunNumber;};

Here is the caller graph for this function:

TDataContainer* TRootanaEventLoop::GetDataContainer (  )  [inline, inherited]

Method to get the data container that event loop owns.

Definition at line 49 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fDataContainer.

00049 {return fDataContainer;};

TDataContainer* TRootanaEventLoop::GetDataContainer (  )  [inline, inherited]

Method to get the data container that event loop owns.

Definition at line 49 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fDataContainer.

00049 {return fDataContainer;};

std::string TRootanaDisplay::GetDisplayName (  )  [inline, inherited]

Get Display name.

Definition at line 123 of file TRootanaDisplay.hxx.

References TRootanaDisplay::fDisplayName.

Referenced by TRootanaDisplay::UpdatePlotsAction().

00123 {return fDisplayName;}

Here is the caller graph for this function:

TMainDisplayWindow* TRootanaDisplay::GetDisplayWindow (  )  [inline, inherited]

Retrieve the main display window, so that users can do things like grab the canvases and update them.

Definition at line 82 of file TRootanaDisplay.hxx.

References TRootanaDisplay::fMainWindow.

Referenced by TRootanaDisplay::AddSingleCanvas(), TRootanaDisplay::InitializeMainWindow(), PlotCanvas(), and TRootanaDisplay::UpdatePlotsAction().

00082 { return fMainWindow;}

Here is the caller graph for this function:

VirtualOdb* TRootanaEventLoop::GetODB (  )  [inline, inherited]

Get pointer to ODB variables.

Definition at line 141 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fODB.

00141 {return fODB;}

VirtualOdb* TRootanaEventLoop::GetODB (  )  [inline, inherited]

Get pointer to ODB variables.

Definition at line 141 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fODB.

00141 {return fODB;}

bool TRootanaEventLoop::GetSuppressTimestampWarnings (  )  [inline, inherited]

Suppress timestamp warnings? true = suppress warnings.

Definition at line 189 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fSuppressTimestampWarnings.

00189 { return fSuppressTimestampWarnings;};

bool TRootanaEventLoop::GetSuppressTimestampWarnings (  )  [inline, inherited]

Suppress timestamp warnings? true = suppress warnings.

Definition at line 189 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fSuppressTimestampWarnings.

00189 { return fSuppressTimestampWarnings;};

void TRootanaDisplay::Initialize ( void   )  [inline, virtual, inherited]

Called after the arguments are processes but before reading the first event is read

Reimplemented from TRootanaEventLoop.

Definition at line 127 of file TRootanaDisplay.hxx.

References TRootanaDisplay::InitializeMainWindow().

00127                    {
00128     InitializeMainWindow();
00129   }

Here is the call graph for this function:

bool TRootanaEventLoop::IsOffline (  )  const [inline, inherited]

Are we processing offline data?

Definition at line 104 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fIsOffline.

Referenced by TRootanaDisplay::InitializeMainWindow().

00104 {return fIsOffline;};

Here is the caller graph for this function:

bool TRootanaEventLoop::IsOffline (  )  const [inline, inherited]

Are we processing offline data?

Definition at line 104 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fIsOffline.

Referenced by TRootanaDisplay::InitializeMainWindow().

00104 {return fIsOffline;};

Here is the caller graph for this function:

bool TRootanaEventLoop::IsOnline (  )  const [inline, inherited]

Are we processing online data?

Definition at line 101 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fIsOffline.

Referenced by TRootanaDisplay::InitializeMainWindow(), TRootanaDisplay::ProcessMidasEvent(), TRootanaDisplay::QuitButtonAction(), and TRootanaDisplay::UpdatePlotsAction().

00101 {return !fIsOffline;};

Here is the caller graph for this function:

bool TRootanaEventLoop::IsOnline (  )  const [inline, inherited]

Are we processing online data?

Definition at line 101 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fIsOffline.

Referenced by TRootanaDisplay::InitializeMainWindow(), TRootanaDisplay::ProcessMidasEvent(), TRootanaDisplay::QuitButtonAction(), and TRootanaDisplay::UpdatePlotsAction().

00101 {return !fIsOffline;};

Here is the caller graph for this function:

bool TRootanaEventLoop::IsRootFileValid (  )  [inline, inherited]

Check if output ROOT file is valid and open.

Definition at line 151 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fOutputFile.

00151                         {    
00152     if(fOutputFile) return true;
00153     return false;
00154   }

bool TRootanaEventLoop::IsRootFileValid (  )  [inline, inherited]

Check if output ROOT file is valid and open.

Definition at line 151 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fOutputFile.

00151                         {    
00152     if(fOutputFile) return true;
00153     return false;
00154   }

int TRootanaEventLoop::IsRootOutputEnabled (  )  [inline, inherited]

Definition at line 159 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fDisableRootOutput.

00159 {return !fDisableRootOutput;};

int TRootanaEventLoop::IsRootOutputEnabled (  )  [inline, inherited]

Definition at line 159 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fDisableRootOutput.

00159 {return !fDisableRootOutput;};

void TRootanaDisplay::NextButtonPushed (  )  [inline, inherited]

Method for when next button is pushed (offline mode).

Definition at line 94 of file TRootanaDisplay.hxx.

References TRootanaDisplay::waitingForNextButton.

00094                          {
00095     waitingForNextButton = false;
00096   }

void TRootanaEventLoop::OpenRootFile ( int  run,
std::string  midasFilename = std::string("") 
) [inherited]

Open output ROOT file.

Definition at line 422 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::fDisableRootOutput, TRootanaEventLoop::fOutputFile, TRootanaEventLoop::fOutputFilename, NetDirectoryExport(), and TRootanaEventLoop::SetFullOutputFileName().

Referenced by TRootanaEventLoop::ProcessMidasFile().

00422                                                                     {
00423 
00424   if(fDisableRootOutput) return;
00425 
00426   if(fOutputFile) {
00427     fOutputFile->Write();
00428     fOutputFile->Close();
00429     fOutputFile=0;
00430   }  
00431 
00432   char filename[1024];
00433         // This is the default filename, using fOutputFilename
00434         sprintf(filename, "%s%08d.root",fOutputFilename.c_str(), run);
00435 
00436         // See if user has implemented a function where they specify 
00437         // the root file name using the midas file name...
00438         // Only works offline, because we need midas file name
00439         if(midasFilename.compare("") != 0){
00440                 std::string fullname = SetFullOutputFileName(run,midasFilename);
00441                 if(fullname.compare("") != 0){
00442                         sprintf(filename, "%s",fullname.c_str());
00443                 }
00444         }
00445         
00446   fOutputFile = new TFile(filename,"RECREATE");
00447   std::cout << "Opened output file with name : " << filename << std::endl;
00448 
00449 
00450 #ifdef HAVE_LIBNETDIRECTORY
00451   NetDirectoryExport(fOutputFile, "outputFile");
00452 #endif
00453 }

Here is the call graph for this function:

Here is the caller graph for this function:

void TRootanaEventLoop::OpenRootFile ( int  run,
std::string  midasFilename = std::string("") 
) [inherited]

Open output ROOT file.

Definition at line 422 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::fDisableRootOutput, TRootanaEventLoop::fOutputFile, TRootanaEventLoop::fOutputFilename, NetDirectoryExport(), and TRootanaEventLoop::SetFullOutputFileName().

Referenced by TRootanaEventLoop::ProcessMidasFile().

00422                                                                     {
00423 
00424   if(fDisableRootOutput) return;
00425 
00426   if(fOutputFile) {
00427     fOutputFile->Write();
00428     fOutputFile->Close();
00429     fOutputFile=0;
00430   }  
00431 
00432   char filename[1024];
00433         // This is the default filename, using fOutputFilename
00434         sprintf(filename, "%s%08d.root",fOutputFilename.c_str(), run);
00435 
00436         // See if user has implemented a function where they specify 
00437         // the root file name using the midas file name...
00438         // Only works offline, because we need midas file name
00439         if(midasFilename.compare("") != 0){
00440                 std::string fullname = SetFullOutputFileName(run,midasFilename);
00441                 if(fullname.compare("") != 0){
00442                         sprintf(filename, "%s",fullname.c_str());
00443                 }
00444         }
00445         
00446   fOutputFile = new TFile(filename,"RECREATE");
00447   std::cout << "Opened output file with name : " << filename << std::endl;
00448 
00449 
00450 #ifdef HAVE_LIBNETDIRECTORY
00451   NetDirectoryExport(fOutputFile, "outputFile");
00452 #endif
00453 }

Here is the call graph for this function:

Here is the caller graph for this function:

void MyTestLoop::PlotCanvas ( TDataContainer dataContainer  )  [inline, virtual]

This method can be implemented by users to plotting of current canvas.

Reimplemented from TRootanaDisplay.

Definition at line 78 of file display_example.cxx.

References TMainDisplayWindow::GetCanvas(), TRootanaDisplay::GetDisplayWindow(), and sizeBankFR10.

00078                                                 {
00079 
00080     if(GetDisplayWindow()->GetCurrentTabName().compare("FR10") == 0){       
00081       TCanvas* c1 = GetDisplayWindow()->GetCanvas("FR10");
00082       c1->Clear();
00083       sizeBankFR10->Draw();
00084       c1->Modified();
00085       c1->Update();
00086     }
00087     
00088   }

Here is the call graph for this function:

void MyTestLoop::PlotCanvas ( TDataContainer dataContainer  )  [inline, virtual]

This method can be implemented by users to plotting of current canvas.

Reimplemented from TRootanaDisplay.

Definition at line 74 of file anaDisplay.cxx.

00074 {}

virtual bool TRootanaEventLoop::PreFilter ( TDataContainer dataContainer  )  [inline, virtual, inherited]

The PreFilter method allows user to specify whether to ignore a particular event. Specifically, if PreFilter returns

true -> then ProcessMidasEvent will be called or false -> then ProcessMidasEvent will not be called

This is particularly useful for the RootanaDisplay, where you might want to only process and plot certain events.

Definition at line 98 of file TRootanaEventLoop.hxx.

Referenced by TRootanaEventLoop::ProcessMidasFile().

00098 {return true;}

Here is the caller graph for this function:

bool MyTestLoop::ProcessMidasEvent ( TDataContainer dataContainer  )  [inline, virtual]

The main method, called for each event. Users must implement this function!

Implements TRootanaEventLoop.

Definition at line 33 of file analyzer_example.cxx.

References TDirectory::cd(), TRootanaEventLoop::fOnlineHistDir, TDirectory::Get(), TDCMeasurement::GetChannel(), TRootanaEventLoop::GetCurrentRunNumber(), TDataContainer::GetEventData(), TDCMeasurement::GetMeasurement(), TV1190Data::GetMeasurements(), TDataContainer::GetMidasData(), TDCMeasurement::GetTDCNumber(), TMidasEvent::LocateBank(), nnn, and TV792Data::Print().

00033                                                        {
00034 
00035 
00036     void *ptr;
00037     int size = dataContainer.GetMidasData().LocateBank(NULL, "FR10", &ptr);
00038     if (ptr){
00039       nnn++;
00040       if(nnn%100 == 0){
00041         std::cout << "Current run :  " << GetCurrentRunNumber() << std::endl;
00042         std::cout << "Trying to handle this event... " << size << " " << nnn << std::endl;
00043       }
00044 
00045       fOnlineHistDir->cd();
00046       char sname[256];
00047       sprintf(sname, "size%d", 0);
00048       TH1D* hsize = (TH1D*)fOnlineHistDir->Get(sname);
00049       if (!hsize){
00050         printf("Create [%s]\n", sname);
00051         hsize = new TH1D(sname, sname, 600, 0, 6000);
00052       }      
00053       hsize->Fill(size);
00054     }
00055 
00056 
00057     TV1190Data *v1190 = dataContainer.GetEventData<TV1190Data>("TDC0");
00058     if(v1190){ 
00059 
00060       std::cout << "TDC measurements for V1190" << std::endl;
00061       std::vector<TDCMeasurement>& measurements = v1190->GetMeasurements();
00062       for(unsigned int i = 0; i < measurements.size(); i++){
00063         TDCMeasurement tdcmeas = measurements[i];
00064         
00065         std::cout << "Measurement: " <<    tdcmeas.GetMeasurement() << " for tdc/chan "  <<
00066           tdcmeas.GetTDCNumber() << "/"<< tdcmeas.GetChannel() << std::endl;
00067 
00068       }   
00069       
00070     }
00071 
00072     TV792Data *v792 = dataContainer.GetEventData<TV792Data>("ADC0");
00073     if(v792 ){ 
00074  
00075       v792->Print();
00076       
00077     }
00078  
00079     return true;
00080   }

Here is the call graph for this function:

int TRootanaEventLoop::ProcessMidasFile ( TApplication *  app,
const char *  fname 
) [inherited]

Treat the begin run and end run events differently.

Definition at line 328 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::BeginRun(), TRootanaEventLoop::CheckEventID(), TDataContainer::CleanupEvent(), TMidasFile::Close(), TRootanaEventLoop::CloseRootFile(), TRootanaEventLoop::EndRun(), TRootanaEventLoop::fCurrentRunNumber, TRootanaEventLoop::fDataContainer, TRootanaEventLoop::fMaxEvents, TRootanaEventLoop::fODB, TMidasEvent::GetData(), TMidasEvent::GetSerialNumber(), gUseOnlyRecent, TMidasFile::Open(), TRootanaEventLoop::OpenRootFile(), TRootanaEventLoop::PreFilter(), PrintCurrentStats(), TRootanaEventLoop::ProcessMidasEvent(), raTotalEventsProcessed, raTotalEventsSkippedForAge, TMidasFile::Read(), and TDataContainer::SetMidasEventPointer().

Referenced by TRootanaEventLoop::ExecuteLoop().

00329 {
00330   TMidasFile f;
00331   bool tryOpen = f.Open(fname);
00332 
00333   if (!tryOpen){
00334     printf("Cannot open input file \"%s\"\n",fname);
00335     return -1;
00336   }
00337 
00338   // This parameter is irrelevant for offline processing.
00339   gUseOnlyRecent = false;
00340 
00341   int i=0;
00342   while (1)
00343     {
00344       TMidasEvent event;
00345       if (!f.Read(&event))
00346         break;
00347       
00348       /// Treat the begin run and end run events differently.
00349       int eventId = event.GetEventId();
00350 
00351       
00352 
00353       if ((eventId & 0xFFFF) == 0x8000){// begin run event
00354         
00355         event.Print();
00356         
00357         // Load ODB contents from the ODB XML file
00358         if (fODB) delete fODB;
00359         fODB = new XmlOdb(event.GetData(),event.GetDataSize());
00360         
00361         fCurrentRunNumber = event.GetSerialNumber();
00362         OpenRootFile(fCurrentRunNumber,fname);
00363         BeginRun(0,event.GetSerialNumber(),0);
00364         raTotalEventsProcessed = 0;
00365         raTotalEventsSkippedForAge = 0;
00366         
00367       } else if ((eventId & 0xFFFF) == 0x8001){// end run event
00368           
00369                                 event.Print();
00370         //EndRun(0,fCurrentRunNumber,0);
00371         
00372 
00373       } else if ((eventId & 0xFFFF) == 0x8002){
00374 
00375         event.Print(); 
00376         printf("Log message: %s\n", event.GetData()); 
00377 
00378       }else if(CheckEventID(eventId)){ // all other events; check that this event ID should be processed.
00379 
00380         // Set the bank list for midas event.
00381         event.SetBankList();
00382         
00383         // Set the midas event pointer in the physics event.
00384         fDataContainer->SetMidasEventPointer(event);
00385         
00386         //ProcessEvent if prefilter is satisfied...
00387                                 if(PreFilter(*fDataContainer))
00388                                          ProcessMidasEvent(*fDataContainer);
00389         
00390         // Cleanup the information for this event.
00391         fDataContainer->CleanupEvent();
00392         
00393       }
00394  
00395       PrintCurrentStats();
00396 
00397       // Check if we have processed desired number of events.
00398       i++;
00399       if ((fMaxEvents!=0)&&(i>=fMaxEvents)){
00400         printf("Reached event %d, exiting loop.\n",i);
00401         break;
00402       }
00403     }
00404   
00405   f.Close(); 
00406 
00407   EndRun(0,fCurrentRunNumber,0);
00408   CloseRootFile();  
00409 
00410   // start the ROOT GUI event loop
00411   //  app->Run(kTRUE);
00412 
00413   return 0;
00414 }

Here is the call graph for this function:

Here is the caller graph for this function:

int TRootanaEventLoop::ProcessMidasFile ( TApplication *  app,
const char *  fname 
) [inherited]

Treat the begin run and end run events differently.

Definition at line 328 of file TRootanaEventLoop.cxx.

References TRootanaEventLoop::BeginRun(), TRootanaEventLoop::CheckEventID(), TDataContainer::CleanupEvent(), TMidasFile::Close(), TRootanaEventLoop::CloseRootFile(), TRootanaEventLoop::EndRun(), TRootanaEventLoop::fCurrentRunNumber, TRootanaEventLoop::fDataContainer, TRootanaEventLoop::fMaxEvents, TRootanaEventLoop::fODB, TMidasEvent::GetData(), TMidasEvent::GetSerialNumber(), gUseOnlyRecent, TMidasFile::Open(), TRootanaEventLoop::OpenRootFile(), TRootanaEventLoop::PreFilter(), PrintCurrentStats(), TRootanaEventLoop::ProcessMidasEvent(), raTotalEventsProcessed, raTotalEventsSkippedForAge, TMidasFile::Read(), and TDataContainer::SetMidasEventPointer().

Referenced by TRootanaEventLoop::ExecuteLoop().

00329 {
00330   TMidasFile f;
00331   bool tryOpen = f.Open(fname);
00332 
00333   if (!tryOpen){
00334     printf("Cannot open input file \"%s\"\n",fname);
00335     return -1;
00336   }
00337 
00338   // This parameter is irrelevant for offline processing.
00339   gUseOnlyRecent = false;
00340 
00341   int i=0;
00342   while (1)
00343     {
00344       TMidasEvent event;
00345       if (!f.Read(&event))
00346         break;
00347       
00348       /// Treat the begin run and end run events differently.
00349       int eventId = event.GetEventId();
00350 
00351       
00352 
00353       if ((eventId & 0xFFFF) == 0x8000){// begin run event
00354         
00355         event.Print();
00356         
00357         // Load ODB contents from the ODB XML file
00358         if (fODB) delete fODB;
00359         fODB = new XmlOdb(event.GetData(),event.GetDataSize());
00360         
00361         fCurrentRunNumber = event.GetSerialNumber();
00362         OpenRootFile(fCurrentRunNumber,fname);
00363         BeginRun(0,event.GetSerialNumber(),0);
00364         raTotalEventsProcessed = 0;
00365         raTotalEventsSkippedForAge = 0;
00366         
00367       } else if ((eventId & 0xFFFF) == 0x8001){// end run event
00368           
00369                                 event.Print();
00370         //EndRun(0,fCurrentRunNumber,0);
00371         
00372 
00373       } else if ((eventId & 0xFFFF) == 0x8002){
00374 
00375         event.Print(); 
00376         printf("Log message: %s\n", event.GetData()); 
00377 
00378       }else if(CheckEventID(eventId)){ // all other events; check that this event ID should be processed.
00379 
00380         // Set the bank list for midas event.
00381         event.SetBankList();
00382         
00383         // Set the midas event pointer in the physics event.
00384         fDataContainer->SetMidasEventPointer(event);
00385         
00386         //ProcessEvent if prefilter is satisfied...
00387                                 if(PreFilter(*fDataContainer))
00388                                          ProcessMidasEvent(*fDataContainer);
00389         
00390         // Cleanup the information for this event.
00391         fDataContainer->CleanupEvent();
00392         
00393       }
00394  
00395       PrintCurrentStats();
00396 
00397       // Check if we have processed desired number of events.
00398       i++;
00399       if ((fMaxEvents!=0)&&(i>=fMaxEvents)){
00400         printf("Reached event %d, exiting loop.\n",i);
00401         break;
00402       }
00403     }
00404   
00405   f.Close(); 
00406 
00407   EndRun(0,fCurrentRunNumber,0);
00408   CloseRootFile();  
00409 
00410   // start the ROOT GUI event loop
00411   //  app->Run(kTRUE);
00412 
00413   return 0;
00414 }

Here is the call graph for this function:

Here is the caller graph for this function:

void TRootanaEventLoop::ProcessThisEventID ( int  eventID  )  [inline, inherited]

Provide a way to force program to only process certain event IDs. This method can be called repeatedly to specify several different event IDs to accept. If the method is not called then all eventIDs are accepted.

Definition at line 177 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fProcessEventIDs.

00177                                       {
00178     fProcessEventIDs.push_back(eventID);
00179   };

void TRootanaEventLoop::ProcessThisEventID ( int  eventID  )  [inline, inherited]

Provide a way to force program to only process certain event IDs. This method can be called repeatedly to specify several different event IDs to accept. If the method is not called then all eventIDs are accepted.

Definition at line 177 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fProcessEventIDs.

00177                                       {
00178     fProcessEventIDs.push_back(eventID);
00179   };

void TRootanaDisplay::QuitButtonAction (  )  [inherited]

Method to call when 'quit' button is pressed.

Definition at line 234 of file TRootanaDisplay.cxx.

References TRootanaEventLoop::CloseRootFile(), TRootanaDisplay::EndRun(), TRootanaDisplay::fQuitPushed, TRootanaEventLoop::GetCurrentRunNumber(), and TRootanaEventLoop::IsOnline().

00235 {
00236   // If we are offline, then we close the ROOT file here.
00237   // If we are online then the control will return to TRootanaEventLoop::ProcessMidasOnline
00238   // which will take care of closing the file.
00239 
00240   if(!IsOnline()){
00241     EndRun(0,GetCurrentRunNumber(),0);
00242     CloseRootFile();  
00243   }
00244 
00245         // Set a flag so that we can breakout of loop if 
00246         // we are ONLINE and PAUSED.
00247         // It is odd that gApplication->Terminate(0) doesn't 
00248         // finish, but somehow it seems to wait for the the 
00249         // RootanaDisplay::ProcessMidasEvent() to finish.
00250         fQuitPushed = true;
00251   gApplication->Terminate(0);   
00252 }

Here is the call graph for this function:

void TRootanaDisplay::Reset (  )  [inherited]

This method calls a couple other methods for resets the histograms. This method is attached using the ROOT signal/input system to the reset button on the canvas.

Definition at line 224 of file TRootanaDisplay.cxx.

References TRootanaDisplay::fCanvasHandlers, TRootanaDisplay::ResetHistograms(), and TRootanaDisplay::UpdatePlotsAction().

00224                            {
00225   // Call the reset functions defined in user event loop.
00226   ResetHistograms();
00227   // Call the user defined canvas classes.
00228   for(unsigned int i = 0; i < fCanvasHandlers.size(); i++)
00229       fCanvasHandlers[i].second->ResetCanvasHistograms();
00230   UpdatePlotsAction();
00231 }

Here is the call graph for this function:

void MyTestLoop::ResetHistograms (  )  [inline, virtual]

This method can be implemented by users to plotting of current canvas.

Reimplemented from TRootanaDisplay.

Definition at line 65 of file display_example.cxx.

References sizeBankFR10.

00065                         {
00066     sizeBankFR10->Reset();
00067   }

void MyTestLoop::ResetHistograms (  )  [inline, virtual]

This method can be implemented by users to plotting of current canvas.

Reimplemented from TRootanaDisplay.

Definition at line 67 of file anaDisplay.cxx.

00067 {}

void TRootanaEventLoop::SetCurrentRunNumber ( int  run  )  [inline, inherited]

Current Run Number.

Definition at line 110 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fCurrentRunNumber.

00110 {fCurrentRunNumber = run;};

void TRootanaEventLoop::SetCurrentRunNumber ( int  run  )  [inline, inherited]

Current Run Number.

Definition at line 110 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fCurrentRunNumber.

00110 {fCurrentRunNumber = run;};

void TRootanaDisplay::SetDisplayName ( std::string  name  )  [inline, inherited]

Set Display name.

Definition at line 125 of file TRootanaDisplay.hxx.

References TRootanaDisplay::fDisplayName.

Referenced by AddAllCanvases().

00125 {fDisplayName = name;}

Here is the caller graph for this function:

virtual std::string TRootanaEventLoop::SetFullOutputFileName ( int  run,
std::string  midasFilename 
) [inline, virtual, inherited]

This is an alternative, more complicated way of setting the output ROOT filename. In this case the user is given the run number and the midas file name and, from that information, constructs the output ROOT filename themselves.

Reimplemented in Analyzer.

Definition at line 168 of file TRootanaEventLoop.hxx.

Referenced by TRootanaEventLoop::OpenRootFile().

00168                                                                                  {
00169                 return std::string("");
00170         }

Here is the caller graph for this function:

void TRootanaDisplay::SetNumberSkipEvent ( int  number  )  [inline, inherited]

Function so that user can specify at outset how many events to skip before refreshing display (in online mode).

Definition at line 116 of file TRootanaDisplay.hxx.

References TRootanaDisplay::fMainWindow, TRootanaDisplay::fNumberSkipEventsOnline, and TMainDisplayWindow::GetSkipEventButton().

Referenced by AddAllCanvases().

00116                                      {
00117     fNumberSkipEventsOnline = number;
00118     if(fMainWindow->GetSkipEventButton())
00119       fMainWindow->GetSkipEventButton()->GetNumberEntry()->SetIntNumber(number);
00120   }

Here is the call graph for this function:

Here is the caller graph for this function:

void TRootanaEventLoop::SetOnlineName ( std::string  name  )  [inline, inherited]

Definition at line 172 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fOnlineName.

00172 {fOnlineName = name;};

void TRootanaEventLoop::SetOnlineName ( std::string  name  )  [inline, inherited]

Definition at line 172 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fOnlineName.

00172 {fOnlineName = name;};

void TRootanaEventLoop::SetOutputFilename ( std::string  name  )  [inline, inherited]

Set the output filename. File name will be XXX.root, where XXX is run number

Definition at line 163 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fOutputFilename.

Referenced by MyTestLoop().

00163 {fOutputFilename = name;};

Here is the caller graph for this function:

void TRootanaEventLoop::SetOutputFilename ( std::string  name  )  [inline, inherited]

Set the output filename. File name will be XXX.root, where XXX is run number

Definition at line 163 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fOutputFilename.

Referenced by MyTestLoop().

00163 {fOutputFilename = name;};

Here is the caller graph for this function:

void TRootanaEventLoop::SuppressTimestampWarnings (  )  [inline, inherited]

Suppress the warning methods regarding old timestamp events for online ie warnings about analyzer falling behind data taking.

Definition at line 186 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fSuppressTimestampWarnings.

00186 { fSuppressTimestampWarnings = true;};

void TRootanaEventLoop::SuppressTimestampWarnings (  )  [inline, inherited]

Suppress the warning methods regarding old timestamp events for online ie warnings about analyzer falling behind data taking.

Definition at line 186 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fSuppressTimestampWarnings.

00186 { fSuppressTimestampWarnings = true;};

void MyTestLoop::UpdateHistograms ( TDataContainer dataContainer  )  [inline, virtual]

This method can be implemented by users to update user histograms.

Reimplemented from TRootanaDisplay.

Definition at line 69 of file display_example.cxx.

References TDataContainer::GetMidasData(), TMidasEvent::LocateBank(), and sizeBankFR10.

00069                                                       {
00070     void *ptr;
00071     // Update histograms
00072     int size = dataContainer.GetMidasData().LocateBank(NULL, "FR10", &ptr);
00073     sizeBankFR10->Fill(size);
00074 
00075   }

Here is the call graph for this function:

void MyTestLoop::UpdateHistograms ( TDataContainer dataContainer  )  [inline, virtual]

This method can be implemented by users to update user histograms.

Reimplemented from TRootanaDisplay.

Definition at line 69 of file anaDisplay.cxx.

References anaManager, and TAnaManager::ProcessMidasEvent().

00069                                                       {
00070     
00071     anaManager->ProcessMidasEvent(dataContainer);
00072   }

Here is the call graph for this function:

void TRootanaDisplay::UpdatePlotsAction (  )  [inherited]

This is a generic action to call when some button gets pushed. Also called in regular event handling loop

Definition at line 182 of file TRootanaDisplay.cxx.

References TRootanaDisplay::fCachedDataContainer, TRootanaDisplay::fCanvasHandlers, TRootanaDisplay::fMainWindow, TMainDisplayWindow::GetCurrentEmbeddedCanvas(), TRootanaEventLoop::GetCurrentRunNumber(), TMainDisplayWindow::GetCurrentTabIndex(), TRootanaDisplay::GetDisplayName(), TRootanaDisplay::GetDisplayWindow(), TMainDisplayWindow::GetMain(), TDataContainer::GetMidasData(), TMidasEvent::GetSerialNumber(), TRootanaEventLoop::IsOnline(), TRootanaDisplay::PlotCanvas(), and TMainDisplayWindow::ResetSize().

Referenced by TRootanaDisplay::BeginRun(), TRootanaDisplay::EndRun(), TRootanaDisplay::ProcessMidasEvent(), and TRootanaDisplay::Reset().

00182                                        {
00183 
00184   if(!fCachedDataContainer){
00185     char displayTitle[200];
00186     sprintf(displayTitle,"%s (): run %i (no events yet)",
00187             GetDisplayName().c_str(),GetCurrentRunNumber());
00188     GetDisplayWindow()->GetMain()->SetWindowName(displayTitle);
00189     return;
00190   }
00191     
00192   // Execute the plotting actions from user event loop.
00193   PlotCanvas(*fCachedDataContainer);
00194   
00195   // See if we find a user class that describes this tab.
00196   std::pair<int,int> tabdex = GetDisplayWindow()->GetCurrentTabIndex();
00197   for(unsigned int i = 0; i < fCanvasHandlers.size(); i++){
00198     if(tabdex == fCanvasHandlers[i].first){
00199       TRootEmbeddedCanvas* embed = GetDisplayWindow()->GetCurrentEmbeddedCanvas();
00200       fCanvasHandlers[i].second->PlotCanvas(*fCachedDataContainer,embed);
00201     }
00202   }
00203     
00204   
00205   // Set the display title
00206   char displayTitle[200];
00207   if(IsOnline())
00208     sprintf(displayTitle,"%s (online): run %i event %i",
00209             GetDisplayName().c_str(),GetCurrentRunNumber(),
00210             fCachedDataContainer->GetMidasData().GetSerialNumber());
00211   else
00212     sprintf(displayTitle,"%s (offline): run %i event %i",
00213             GetDisplayName().c_str(),GetCurrentRunNumber(),
00214             fCachedDataContainer->GetMidasData().GetSerialNumber());
00215     
00216   GetDisplayWindow()->GetMain()->SetWindowName(displayTitle);
00217 
00218 
00219   // Update canvas and window sizes    
00220   fMainWindow->ResetSize();
00221   
00222 }

Here is the call graph for this function:

Here is the caller graph for this function:

void MyTestLoop::Usage ( void   )  [inline, virtual]

Called when there is a usage error. This code should print a usage message and then return.

Reimplemented from TRootanaEventLoop.

Definition at line 84 of file analyzer_example.cxx.

00084                   {
00085     std::cout << "\t-D option: this is a fun new option " << std::endl;
00086   }

void TRootanaDisplay::UsageRAD ( void   )  [inline, virtual, inherited]

Also a special version of usage for TRootanaDisplay. See CheckOptionRAD.

Reimplemented from TRootanaEventLoop.

Definition at line 140 of file TRootanaDisplay.hxx.

00140                  {
00141     printf("\t-s: will process specified number of events before displaying (for display programs)\n");
00142   }

void TRootanaEventLoop::UseBatchMode (  )  [inline, inherited]

Use a batch mode, where we don't check ROOT status.

Definition at line 138 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fUseBatchMode.

00138 {  fUseBatchMode = true;}

void TRootanaEventLoop::UseBatchMode (  )  [inline, inherited]

Use a batch mode, where we don't check ROOT status.

Definition at line 138 of file TRootanaEventLoop.hxx.

References TRootanaEventLoop::fUseBatchMode.

00138 {  fUseBatchMode = true;}

void TRootanaEventLoop::UseOnlyRecent ( bool  setting = true  )  [inherited]

Method to set whether analyzer should operate in GET_RECENT mode, where we only process data that is less than 1 second old (this is not default). Setting true will use this option.

Definition at line 416 of file TRootanaEventLoop.cxx.

References gUseOnlyRecent.

00416                                                  { 
00417 
00418   gUseOnlyRecent = setting;
00419 };

void TRootanaEventLoop::UseOnlyRecent ( bool  setting = true  )  [inherited]

Method to set whether analyzer should operate in GET_RECENT mode, where we only process data that is less than 1 second old (this is not default). Setting true will use this option.

Definition at line 416 of file TRootanaEventLoop.cxx.

References gUseOnlyRecent.

00416                                                  { 
00417 
00418   gUseOnlyRecent = setting;
00419 };


Member Data Documentation

Definition at line 20 of file anaDisplay.cxx.

Referenced by AddAllCanvases(), MyTestLoop(), and UpdateHistograms().

TRootanaEventLoop * TRootanaEventLoop::fTRootanaEventLoop = NULL [static, protected, inherited]

The static pointer to the singleton instance.

Definition at line 209 of file TRootanaEventLoop.hxx.

Referenced by TRootanaEventLoop::CreateSingleton(), and TRootanaEventLoop::Get().

TRootanaEventLoop * TRootanaEventLoop::fTRootanaEventLoop = NULL [static, protected, inherited]

The static pointer to the singleton instance.

Definition at line 209 of file TRootanaEventLoop.hxx.

Referenced by TRootanaEventLoop::CreateSingleton(), and TRootanaEventLoop::Get().

int MyTestLoop::nnn [private]

Definition at line 15 of file analyzer_example.cxx.

Referenced by MyTestLoop(), and ProcessMidasEvent().

TH1F* MyTestLoop::sizeBankFR10 [private]

Definition at line 45 of file display_example.cxx.

Referenced by MyTestLoop(), PlotCanvas(), ResetHistograms(), and UpdateHistograms().


The documentation for this class was generated from the following files:

Generated on 12 Feb 2016 for ROOT Analyzer by  doxygen 1.6.1