00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "AEMDBInterface.h"
00010 #include "AEMPlots.h"
00011 #include "TRint.h"
00012 #include "TCanvas.h"
00013 #include "TBrowser.h"
00014 #include "TROOT.h"
00015 #include "TStyle.h"
00016 #include <string>
00017 #include <iostream>
00018 #include <ctime>
00019 #include <sstream>
00020
00021 int main(int argc, char** argv)
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
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);
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 }