aemstat.cc File Reference

#include "AEMDBInterface.h"
#include "AEMPlots.h"
#include "TRint.h"
#include "TCanvas.h"
#include "TBrowser.h"
#include "TROOT.h"
#include "TStyle.h"
#include <string>
#include <iostream>
#include <ctime>
#include <sstream>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 
Id
aemstat.cc,v 1.10 2005/12/07 17:51:14 hmeyer Exp


Function Documentation

int main ( int  argc,
char **  argv 
)

Id
aemstat.cc,v 1.10 2005/12/07 17:51:14 hmeyer Exp

Program to cast run statistics from DB into Root Histograms

hmeyer@fnal.gov

Definition at line 21 of file aemstat.cc.

References AEMPlots::FillWeek(), AEMDBInterface::GetRunEntry(), and localtime().

00022 {
00023   std::ostringstream fDateStr;
00024   bool fArgHelp = false;
00025   std::string fHelp[] = {"-?", "-h", "--help"};
00026   std::string fArg;
00027   for (int i=1; i<argc; ++i) {
00028     fArg = argv[i];
00029     for (int j=1; j<3; ++j) {
00030       if (fArg == fHelp[j]) { fArgHelp = true;}
00031     }
00032     if (fArg.substr(0,2) == "-d") { fDateStr << fArg.substr(2,fArg.size());}
00033   }
00034   if (fArgHelp) {std::cout << "Usage: aemstat [-dDate]" << std::endl;}
00035   TRint AEMApp("App", &argc, argv);
00036 
00037   TStyle* fDefStyle = static_cast<TStyle*>(gROOT->GetListOfStyles()->FindObject("Default"));
00038   fDefStyle->SetOptStat(0);
00039 
00040   AEMDBInterface fDB("e907ana1.fnal.gov");
00041 
00042   std::cout << "Hello, Database!" << std::endl;
00043 
00044   if (fDateStr.str().empty()) {
00045     // now find the right week to plot, it was not in argv
00046     time_t fNow, fMonday;
00047     struct tm* fTm;
00048     time (&fNow);
00049     fTm = localtime(&fNow);
00050     fMonday = fNow - (fTm->tm_wday+6)*(24*3600); // get to monday
00051     if (fTm->tm_wday>1) fMonday += 7*24*3600;
00052     fTm = localtime(&fMonday);
00053     fDateStr << (1900+fTm->tm_year) << "-" << (fTm->tm_mon+1) << "-" << fTm->tm_mday;
00054   }
00055 
00056   std::cout << fDateStr.str() << std::endl;
00057 
00058   DBRunEntries fWeekRuns;
00059   long fEpochStart = fDB.GetRunEntry(fDateStr.str(), fWeekRuns);
00060 
00061   AEMPlots fPlots;
00062   fPlots.FillWeek(fEpochStart,fWeekRuns);
00063 
00064   TBrowser* b = new TBrowser;
00065   b->Show();
00066   AEMApp.Run();
00067 
00068   std::cout << "Bye-bye" << std::endl;
00069   return 0;
00070 }


Generated on Mon Nov 23 08:02:29 2009 for MIPP(E907) by  doxygen 1.4.7