NtpEventViewer Class Reference

#include <NtpEventViewer.h>

List of all members.

Public Member Functions

 NtpEventViewer ()
virtual ~NtpEventViewer ()
void Initialize ()
void AddList (const char *file)
void controlStart ()
void controlNext ()
void controlPrevious ()
void controlGoTo ()
void controlPrint ()
void SetDisplayName (const char *displayname)

Private Member Functions

Bool_t PassFail ()
Bool_t Find (Int_t run, Int_t snarl, Int_t event)
void Display ()

Private Attributes

TCanvas * fControlCanvas
TButton * buttonStart
TButton * buttonNext
TButton * buttonPrevious
TButton * buttonGoTo
TButton * buttonPrint
TButton * buttonFree1
TButton * buttonFree2
TButton * buttonQuit
NtpEventDisplayfDisplay
TString fDisplayName
Int_t fRecordCounter
Int_t fEventCounter
Int_t fRun
Int_t fSnarl
Int_t fEvent
Int_t fFoundEventList
Int_t fEventListCounter
Int_t fEventListLast
std::vector< Int_t > fRunList
std::vector< Int_t > fSnarlList
std::vector< Int_t > fEventList
NtpStRecordfNtpRecord

Detailed Description

Definition at line 15 of file NtpEventViewer.h.


Constructor & Destructor Documentation

NtpEventViewer::NtpEventViewer (  ) 

Definition at line 18 of file NtpEventViewer.cxx.

References Initialize().

00018                                :
00019   fControlCanvas(0),
00020   buttonStart(0),
00021   buttonNext(0),
00022   buttonPrevious(0),
00023   buttonGoTo(0),
00024   buttonPrint(0),
00025   buttonFree1(0),
00026   buttonFree2(0),
00027   buttonQuit(0),
00028   fDisplay(0),
00029   fDisplayName("default"),
00030   fRecordCounter(-1),
00031   fEventCounter(-1),
00032   fRun(-1),
00033   fSnarl(-1),
00034   fEvent(-1),
00035   fFoundEventList(0),
00036   fEventListCounter(-1),
00037   fEventListLast(0),
00038   fNtpRecord(0)
00039 {
00040   this->Initialize();
00041 }
  

NtpEventViewer::~NtpEventViewer (  )  [virtual]

Definition at line 43 of file NtpEventViewer.cxx.

References buttonFree1, buttonFree2, buttonGoTo, buttonNext, buttonPrevious, buttonPrint, buttonQuit, buttonStart, fControlCanvas, and fDisplay.

00044 {
00045   if(fControlCanvas) delete fControlCanvas;
00046   if(buttonStart) delete buttonStart;
00047   if(buttonNext) delete buttonNext;
00048   if(buttonPrevious) delete buttonPrevious;
00049   if(buttonGoTo) delete buttonGoTo;
00050   if(buttonPrint) delete buttonPrint;
00051   if(buttonFree1) delete buttonFree1;
00052   if(buttonFree2) delete buttonFree2;
00053   if(buttonQuit) delete buttonQuit;
00054   if(fDisplay) delete fDisplay;
00055 }


Member Function Documentation

void NtpEventViewer::AddList ( const char *  file  ) 

Definition at line 125 of file NtpEventViewer.cxx.

References fEventList, fEventListLast, fFoundEventList, fRunList, fSnarlList, and run().

00126 {
00127   Int_t run   = -1;
00128   Int_t snarl = -1;
00129   Int_t event = -1;
00130 
00131   std::cout << " reading in events from: " << file << std::endl;
00132 
00133   std::ifstream input(file);
00134   if(input){
00135     while( !input.eof() ){
00136       run = -1; snarl = -1; event = -1;
00137       input >> run >> snarl >> event;
00138       if( run>=0 && snarl>=0 && event>=0 ){
00139         std::cout << " (" << fEventListLast << ") run/snarl = " << run << "/" << snarl << "/" << event << std::endl;
00140         fRunList.push_back(run);
00141         fSnarlList.push_back(snarl);
00142         fEventList.push_back(event);
00143         fEventListLast++;
00144         fFoundEventList = 1;
00145       }
00146     }
00147   }
00148   input.close();
00149 
00150   return;
00151 }

void NtpEventViewer::controlGoTo (  ) 

Definition at line 259 of file NtpEventViewer.cxx.

References Display(), fDisplay, fFoundEventList, Find(), PassFail(), and run().

00260 {
00261   if( fDisplay && !fFoundEventList ){
00262     Int_t run = -1;
00263     Int_t snarl = -1;
00264     Int_t event = -1;
00265 
00266     std::cout << " Enter Run :";   std::cin >> run;   std::cout << std::endl;
00267     std::cout << " Enter Snarl :"; std::cin >> snarl; std::cout << std::endl;
00268     std::cout << " Enter Event :"; std::cin >> event; std::cout << std::endl;
00269     std::cout << "   Searching... " << std::endl;
00270     
00271     if( this->Find(run, snarl, event) ){
00272       if( this->PassFail() ){
00273         this->Display();
00274       }
00275     }
00276   }
00277 
00278   return;
00279 }

void NtpEventViewer::controlNext (  ) 

Definition at line 166 of file NtpEventViewer.cxx.

References Display(), fDisplay, fEventCounter, fEventList, fEventListCounter, fEventListLast, fFoundEventList, Find(), fNtpRecord, fRecordCounter, fRunList, fSnarlList, NtpInterface::GetNumEvents(), NtpInterface::GetNumRecords(), and PassFail().

Referenced by controlStart().

00167 {
00168   Bool_t display = 0;
00169 
00170   if( fDisplay ){
00171     if( fFoundEventList ){
00172       if( fEventListCounter<fEventListLast-1 ){
00173         fEventListCounter++;
00174         display = this->Find(fRunList[fEventListCounter],
00175                              fSnarlList[fEventListCounter],
00176                              fEventList[fEventListCounter]);
00177       }
00178     }
00179     else{
00180       if( fNtpRecord==0 ){
00181         fRecordCounter = 0;
00182         fEventCounter = 0;
00183         display = 1;
00184       }
00185       else if( fEventCounter>=NtpInterface::GetNumEvents(fNtpRecord)-1 ){
00186         if( fRecordCounter<NtpInterface::GetNumRecords()-1 ){
00187           fRecordCounter++;
00188           fEventCounter = 0;
00189           display = 1;
00190         }
00191       }
00192       else{
00193         fEventCounter++;
00194         display = 1;
00195       }
00196     }
00197     if( display ){
00198       if( this->PassFail() ){
00199         this->Display();      
00200       }
00201       else{
00202         this->controlNext();
00203       }
00204     }
00205     else{
00206       std::cout << " --- end of file --- " << std::endl;
00207     }
00208   }
00209 
00210   return;
00211 }

void NtpEventViewer::controlPrevious (  ) 

Definition at line 213 of file NtpEventViewer.cxx.

References Display(), fDisplay, fEventCounter, fEventList, fEventListCounter, fFoundEventList, Find(), fNtpRecord, fRecordCounter, fRunList, fSnarlList, and PassFail().

00214 {
00215   Bool_t display = 0;
00216 
00217   if( fDisplay ){
00218     if( fFoundEventList ){
00219       if( fEventListCounter>0 ){
00220         fEventListCounter--;
00221         display = this->Find(fRunList[fEventListCounter],
00222                              fSnarlList[fEventListCounter],
00223                              fEventList[fEventListCounter]);
00224       }
00225     }
00226     else{
00227       if( fNtpRecord==0 ){
00228         fRecordCounter = 0;
00229         fEventCounter = 0;
00230       }
00231       else if( fEventCounter<=0 ){
00232         if( fRecordCounter>0 ){
00233           fRecordCounter--;
00234           fEventCounter = 0;
00235           display = 1;
00236         }
00237       }
00238       else{
00239         fEventCounter--;
00240         display = 1;
00241       }
00242     }
00243     if( display ){
00244       if( this->PassFail() ){
00245         this->Display();
00246       }
00247       else{
00248         this->controlPrevious();
00249       }
00250     }
00251     else{
00252       std::cout << " --- beginning of file --- " << std::endl;
00253     }
00254   }
00255 
00256   return;
00257 }

void NtpEventViewer::controlPrint (  ) 

Definition at line 281 of file NtpEventViewer.cxx.

References fDisplay, and NtpEventDisplay::PrintPicture().

00282 {
00283   if( fDisplay ){
00284     std::cout << " saving image of event display " << std::endl;
00285     fDisplay->PrintPicture();
00286   }
00287 
00288   return;
00289 }

void NtpEventViewer::controlStart (  ) 

Definition at line 155 of file NtpEventViewer.cxx.

References controlNext(), fDisplay, fDisplayName, NtpEventDisplayFactory::Instance(), and NtpEventDisplayFactory::MakeEventDisplay().

00156 {
00157   if( !fDisplay ){
00158     std::cout << " starting event display " << std::endl;
00159     fDisplay = NtpEventDisplayFactory::Instance()->MakeEventDisplay(fDisplayName.Data());
00160     if( fDisplay ) this->controlNext();
00161   }
00162 
00163   return;
00164 }

void NtpEventViewer::Display (  )  [private]

Definition at line 338 of file NtpEventViewer.cxx.

References fDisplay, fEventCounter, fNtpRecord, fRecordCounter, fRun, fSnarl, RecRecordImp< T >::GetHeader(), NtpInterface::GetNumRecords(), NtpInterface::GetRecord(), RecDataHeader::GetRun(), RecPhysicsHeader::GetSnarl(), NtpEventDisplay::MakePicture(), and NtpInterface::TouchData().

Referenced by controlGoTo(), controlNext(), and controlPrevious().

00339 {
00340   if( NtpInterface::TouchData() ){
00341     if( fRecordCounter>=0 && fRecordCounter<NtpInterface::GetNumRecords() ){
00342       fNtpRecord = NtpInterface::GetRecord(fRecordCounter);
00343       if( fNtpRecord ){
00344         fDisplay->MakePicture(fNtpRecord,fEventCounter);
00345 
00346         fRun = fNtpRecord->GetHeader().GetRun();
00347         fSnarl = fNtpRecord->GetHeader().GetSnarl();
00348         std::cout << " Displaying Event " << fRecordCounter << "/" << fEventCounter  
00349                   << ": run/snarl/event = " << fRun << "/" << fSnarl << "/" << fEventCounter << std::endl;
00350       }
00351     }
00352   }
00353 
00354   return;
00355 }

Bool_t NtpEventViewer::Find ( Int_t  run,
Int_t  snarl,
Int_t  event 
) [private]

Definition at line 305 of file NtpEventViewer.cxx.

References fEventCounter, fNtpRecord, fRecordCounter, RecRecordImp< T >::GetHeader(), NtpInterface::GetNumEvents(), NtpInterface::GetNumRecords(), NtpInterface::GetRecord(), RecDataHeader::GetRun(), and RecPhysicsHeader::GetSnarl().

Referenced by controlGoTo(), controlNext(), and controlPrevious().

00306 {
00307   // search forwards
00308   for( Int_t record=fRecordCounter; record<NtpInterface::GetNumRecords(); record++ ){
00309     fNtpRecord = NtpInterface::GetRecord(record);
00310     if( fNtpRecord->GetHeader().GetRun()==run
00311      && fNtpRecord->GetHeader().GetSnarl()==snarl ){
00312       if( event>=0 && event<NtpInterface::GetNumEvents(fNtpRecord) ){
00313         fRecordCounter = record;
00314         fEventCounter  = event;
00315         return 1;
00316       }
00317     }
00318   }
00319 
00320   // search backwards
00321   for( Int_t record=fRecordCounter; record>=0; record-- ){
00322     fNtpRecord = NtpInterface::GetRecord(record);
00323     if( fNtpRecord->GetHeader().GetRun()==run
00324      && fNtpRecord->GetHeader().GetSnarl()==snarl ){
00325       if( event>=0 && event<NtpInterface::GetNumEvents(fNtpRecord) ){
00326         fRecordCounter = record;
00327         fEventCounter  = event;
00328         return 1;
00329       }
00330     }
00331   }
00332 
00333   std::cout << " failed to find: " << run << "/" << snarl << "/" << event << std::endl;
00334 
00335   return 0;
00336 }

void NtpEventViewer::Initialize (  ) 

Definition at line 57 of file NtpEventViewer.cxx.

References buttonGoTo, buttonNext, buttonPrevious, buttonPrint, buttonQuit, buttonStart, and fControlCanvas.

00058 {
00059 
00060   std::cout << " initializing... " << std::endl;
00061 
00062   // initializing control canvas
00063   if( !fControlCanvas ){
00064     fControlCanvas = new TCanvas("ControlCanvas",
00065                                  "ControlCanvas",0,0,150,600);
00066     fControlCanvas->cd();
00067     
00068     Int_t butNumber = 6;
00069     Double_t butLowerY,butUpperY,butSpaceY;
00070 
00071     butSpaceY = 1.0/((double)(butNumber));
00072     
00073     butUpperY = 1.0;
00074     butLowerY = butUpperY-butSpaceY;
00075     buttonStart = new TButton("Start","viewer->controlStart()",0.0,butLowerY,1.0,butUpperY);
00076     buttonStart->SetTextSize(0.33);
00077     buttonStart->SetTextColor(1);
00078     buttonStart->SetFillColor(9);
00079     buttonStart->Draw();
00080 
00081     butUpperY = butLowerY;
00082     butLowerY = butUpperY-butSpaceY;
00083     buttonNext = new TButton("Next","viewer->controlNext()",0.0,butLowerY,1.0,butUpperY);
00084     buttonNext->SetTextSize(0.33);
00085     buttonNext->SetTextColor(1);
00086     buttonNext->SetFillColor(9);
00087     buttonNext->Draw();
00088 
00089     butUpperY = butLowerY;
00090     butLowerY = butUpperY-butSpaceY;
00091     buttonPrevious = new TButton("Previous","viewer->controlPrevious()",0.0,butLowerY,1.0,butUpperY);
00092     buttonPrevious->SetTextSize(0.33);
00093     buttonPrevious->SetTextColor(1);
00094     buttonPrevious->SetFillColor(9);
00095     buttonPrevious->Draw();
00096 
00097     butUpperY = butLowerY;
00098     butLowerY = butUpperY-butSpaceY;
00099     buttonGoTo = new TButton("GoTo","viewer->controlGoTo()",0.0,butLowerY,1.0,butUpperY);
00100     buttonGoTo->SetTextSize(0.33);
00101     buttonGoTo->SetTextColor(1);
00102     buttonGoTo->SetFillColor(9);
00103     buttonGoTo->Draw();
00104 
00105     butUpperY = butLowerY;
00106     butLowerY = butUpperY-butSpaceY;
00107     buttonPrint = new TButton("Print","viewer->controlPrint()",0.0,butLowerY,1.0,butUpperY);
00108     buttonPrint->SetTextSize(0.33);
00109     buttonPrint->SetTextColor(1);
00110     buttonPrint->SetFillColor(9);
00111     buttonPrint->Draw();
00112 
00113     butUpperY = butLowerY;
00114     butLowerY = butUpperY-butSpaceY;
00115     buttonQuit = new TButton("Quit",".q",0.0,butLowerY,1.0,butUpperY);
00116     buttonQuit->SetTextSize(0.33);
00117     buttonQuit->SetTextColor(1);
00118     buttonQuit->SetFillColor(9);
00119     buttonQuit->Draw();
00120   }
00121 
00122   return;
00123 }

Bool_t NtpEventViewer::PassFail (  )  [private]
void NtpEventViewer::SetDisplayName ( const char *  displayname  )  [inline]

Definition at line 32 of file NtpEventViewer.h.

References fDisplayName.

00032 { fDisplayName = displayname; }


Member Data Documentation

TButton* NtpEventViewer::buttonFree1 [private]

Definition at line 47 of file NtpEventViewer.h.

Referenced by ~NtpEventViewer().

TButton* NtpEventViewer::buttonFree2 [private]

Definition at line 48 of file NtpEventViewer.h.

Referenced by ~NtpEventViewer().

TButton* NtpEventViewer::buttonGoTo [private]

Definition at line 45 of file NtpEventViewer.h.

Referenced by Initialize(), and ~NtpEventViewer().

TButton* NtpEventViewer::buttonNext [private]

Definition at line 43 of file NtpEventViewer.h.

Referenced by Initialize(), and ~NtpEventViewer().

TButton* NtpEventViewer::buttonPrevious [private]

Definition at line 44 of file NtpEventViewer.h.

Referenced by Initialize(), and ~NtpEventViewer().

TButton* NtpEventViewer::buttonPrint [private]

Definition at line 46 of file NtpEventViewer.h.

Referenced by Initialize(), and ~NtpEventViewer().

TButton* NtpEventViewer::buttonQuit [private]

Definition at line 49 of file NtpEventViewer.h.

Referenced by Initialize(), and ~NtpEventViewer().

TButton* NtpEventViewer::buttonStart [private]

Definition at line 42 of file NtpEventViewer.h.

Referenced by Initialize(), and ~NtpEventViewer().

TCanvas* NtpEventViewer::fControlCanvas [private]

Definition at line 41 of file NtpEventViewer.h.

Referenced by Initialize(), and ~NtpEventViewer().

TString NtpEventViewer::fDisplayName [private]

Definition at line 53 of file NtpEventViewer.h.

Referenced by controlStart(), and SetDisplayName().

Int_t NtpEventViewer::fEvent [private]

Definition at line 60 of file NtpEventViewer.h.

Definition at line 56 of file NtpEventViewer.h.

Referenced by controlNext(), controlPrevious(), Display(), Find(), and PassFail().

std::vector<Int_t> NtpEventViewer::fEventList [private]

Definition at line 68 of file NtpEventViewer.h.

Referenced by AddList(), controlNext(), and controlPrevious().

Definition at line 63 of file NtpEventViewer.h.

Referenced by controlNext(), and controlPrevious().

Definition at line 64 of file NtpEventViewer.h.

Referenced by AddList(), and controlNext().

Definition at line 62 of file NtpEventViewer.h.

Referenced by AddList(), controlGoTo(), controlNext(), and controlPrevious().

Definition at line 70 of file NtpEventViewer.h.

Referenced by controlNext(), controlPrevious(), Display(), Find(), and PassFail().

Definition at line 55 of file NtpEventViewer.h.

Referenced by controlNext(), controlPrevious(), Display(), Find(), and PassFail().

Int_t NtpEventViewer::fRun [private]

Definition at line 58 of file NtpEventViewer.h.

Referenced by Display().

std::vector<Int_t> NtpEventViewer::fRunList [private]

Definition at line 66 of file NtpEventViewer.h.

Referenced by AddList(), controlNext(), and controlPrevious().

Int_t NtpEventViewer::fSnarl [private]

Definition at line 59 of file NtpEventViewer.h.

Referenced by Display().

std::vector<Int_t> NtpEventViewer::fSnarlList [private]

Definition at line 67 of file NtpEventViewer.h.

Referenced by AddList(), controlNext(), and controlPrevious().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1