Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EventInfoPage.cxx

Go to the documentation of this file.
00001 #include "EventInfoPage.h"
00002 #include "Midad/Base/PageProxy.h"
00003 #include "Midad/Gui/GuiBox.h"
00004 #include "Midad/Gui/GuiCanvas.h"
00005 #include "Midad/Gui/GuiMainWindow.h"
00006 #include "Midad/Gui/GuiTextView.h"
00007 #include "Midad/Base/Mint.h"
00008 
00009 #include "MinosObjectMap/MomNavigator.h"
00010 #include "DataUtil/DumpMom.h"
00011 #include "DataUtil/GetCandidate.h"
00012 #include "JobControl/JobC.h"
00013 #include "CandDigit/CandDigitListHandle.h"
00014 #include "SpillTiming/SpillTimeFinder.h"
00015 
00016 #include <TGWindow.h>
00017 #include <TGFileDialog.h>
00018 #include <TCanvas.h>
00019 #include <TLine.h>
00020 
00021 #include <sigc++/sigc++.h>
00022 
00023 #include <iostream>
00024 #include <cassert>
00025 #include <string>
00026 #include <sstream>
00027 
00028 // We don't use this here because we are just a base class.  But, any
00029 // subclass should have a version like it.
00030 static PageProxy<EventInfoPage> gsEventInfoPageProxy("EventInfoPage");
00031 
00032 EventInfoPage::EventInfoPage()
00033     : fMint(0),
00034       fPageDisplay(0),
00035       fTextView(0), 
00036       fMainWindow(0)
00037 {
00038 }
00039 
00040 EventInfoPage::~EventInfoPage()
00041 {
00042 }
00043 
00044 TObject* EventInfoPage::Init(Mint* mint, PageDisplay* pd, GuiBox& box)
00045 {
00046   fMint = mint;
00047   fPageDisplay = pd;
00048 
00049   fMainWindow = dynamic_cast<TGWindow*>(&box);
00050   assert(fMainWindow);
00051   
00052   fTextView = SigC::manage(new GuiTextView(*fMainWindow,500,300));
00053   box.Add(*fTextView);
00054   
00055   fTextView->AddLine("EventInfoPage");
00056   return fTextView;
00057 }
00058 
00059 void EventInfoPage::Print()
00060 {
00061   WriteInfo(std::cout);
00062 }
00063 
00064 void EventInfoPage::Update()
00065 {
00066    fTextView->Clear();
00067 
00068    stringstream oss; // A handy way to push stream data to a buffer.
00069    WriteInfo(oss);
00070    
00071    // Copy it out line-for-line into the text view.
00072    char line[1000];
00073    while(!oss.eof()) {
00074      oss.getline(line,sizeof(line));
00075      fTextView->AddLine(line);
00076    }
00077 }
00078 
00079 void EventInfoPage::WriteInfo(std::ostream& os) const
00080 {
00081   const MomNavigator* mom = &(fMint->GetJobC().Mom);
00082   const char* type = "CandDigitListHandle";
00083   const char* name = "canddigitlist";
00084 
00085   const CandDigitListHandle* cdlh =
00086     DataUtil::GetCandidate<CandDigitListHandle>(&(fMint->GetJobC().Mom),
00087                                                 type,name);
00088 
00089   if(cdlh) {
00090     VldContext cx = *(cdlh->GetVldContext());
00091     double digitListTime = cdlh->GetAbsTime();
00092     VldTimeStamp ts(cx.GetTimeStamp().GetSec(),0);
00093     ts.Add(digitListTime);
00094 
00095     VldContext digitCx(cx.GetDetector(),cx.GetSimFlag(),ts);
00096     
00097     os << "Digit list starts at time " << ts.AsString() << std::endl;
00098     
00099     VldTimeStamp prevSpill = SpillTimeFinder::Instance().GetTimeOfRecentSpill(digitCx);
00100     VldTimeStamp nextSpill = SpillTimeFinder::Instance().GetTimeOfNextSpill(digitCx);
00101     double prevDt = (ts-prevSpill).GetSec()*1.0 + (ts-prevSpill).GetNanoSec()*1e-9;
00102     double nextDt = (ts-nextSpill).GetSec()*1.0 + (ts-nextSpill).GetNanoSec()*1e-9;
00103     
00104     const char* prevDtStr = Form("%7.1lf s ",prevDt);
00105     if(prevDt<1.0) prevDtStr = Form("%7.1lf us",prevDt*1e6);
00106 
00107     const char* nextDtStr = Form("%7.1lf s ",nextDt);
00108     if(nextDt<1.0) nextDtStr = Form("%7.1lf us",nextDt*1e6);
00109 
00110 
00111     os << "Time relative to recent spill: " << prevDtStr << "\t" << prevSpill.AsString() << endl;
00112     os << "Time relative to next   spill: " << nextDtStr << "\t" << nextSpill.AsString() << endl;
00113     os << endl;
00114   }  
00115 
00116   // The the dump.
00117   DataUtil::dump_mom(mom,os);
00118   
00119 }
00120 
00121 
00122 GuiTextView& EventInfoPage::GetTextView() 
00123 {
00124   return *fTextView;
00125 }

Generated on Mon Feb 15 11:06:39 2010 for loon by  doxygen 1.3.9.1