ARA ROOT Test BEd Software

AraWebPlotter/AraTimeWebPlotter.cxx

00001 #include <cstdio>
00002 #include <stdlib.h>
00003 #include <fstream>
00004 #include <iostream>
00005 #include <zlib.h>
00006 #include <libgen.h>     
00007  
00008 //Root includes
00009 #include "TTree.h"
00010 #include "TChain.h"
00011 #include "TFile.h"
00012 #include "TSystem.h"
00013 #include "TROOT.h"
00014 #include "TApplication.h"
00015 
00016 #define HACK_FOR_ROOT
00017 
00018 //ARA includes
00019 #include "araIcrrStructures.h"
00020 #include "RawIcrrStationEvent.h"  
00021 #include "FullIcrrHkEvent.h"  
00022 #include "AraWebPlotterConfig.h"
00023 #include "AraHkPlotter.h"
00024 #include "AraEventPlotter.h"
00025 
00026 int openRootFiles(char *eventFileName, char *hkFileName);
00027 
00028 Int_t runNumber;
00029 TFile *theEventFile;
00030 TChain *eventTree;
00031 RawIcrrStationEvent *theEvent=0;
00032 
00033 
00034 TFile *theHkFile;
00035 TChain *hkTree;
00036 FullIcrrHkEvent *theHk=0;
00037 
00038 
00039 
00040 int main(int argc, char **argv) {
00041   //  theEvent = new RawIcrrStationEvent();
00042   //Step one is to read the config file.
00043    gROOT->SetBatch();
00044   AraWebPlotterConfig *araConfig = new AraWebPlotterConfig();
00045   std::cout << "Root File Dir: " << araConfig->getRootFileDir() << "\n";
00046   std::cout << "Plot Dir: " << araConfig->getPlotDir() << "\n";
00047   std::cout << "Make Event Plots " << araConfig->getEventPlotFlag() << "\n";
00048 
00049     
00050 
00051 
00052   //Step two is to make the plotter
00053   AraHkPlotter *hkPlotter = new AraHkPlotter(araConfig->getPlotDir(),araConfig->getRootFileDir());
00054   AraEventPlotter *eventPlotter = new AraEventPlotter(araConfig->getPlotDir(),araConfig->getRootFileDir());
00055   eventPlotter->setEventPlotFlag(araConfig->getEventPlotFlag());
00056 
00057  //Now we need to load the time hists
00058   hkPlotter->loadAllTimeHists();
00059   eventPlotter->loadAllTimeHists();
00060 
00061   //Step three is to make the time plots
00062   hkPlotter->makePlots();
00063   std::cout << "Done hkPlotter->makePlots()" << "\n";
00064   eventPlotter->makePlots();
00065   std::cout << "Done eventPlotter->makePlots()" << "\n";
00066 
00067   //A bit nasty but this gets us out of there quickly, probably does horrible things to the operating system
00068   //  abort();
00069   return 0;
00070 }
00071 
00072 Long64_t getLastEntry(char *fLastHkProcessedFile)
00073 {
00074   std::ifstream LastHk(fLastHkProcessedFile);
00075   if(LastHk) {
00076     Long64_t temp;
00077     LastHk >> temp;
00078     if(temp>0) return temp;
00079     LastHk.close();
00080   }
00081   return 0;
00082 }
00083 
00084 
00085 void setLastEntry(char *fLastHkProcessedFile, Long64_t lastHkEntry)
00086 {
00087   std::ofstream LastHk(fLastHkProcessedFile);
00088   if(LastHk) {
00089     LastHk << lastHkEntry << "\n";
00090     LastHk.close();
00091   }
00092   else {
00093     std::cerr << "Can't open " << fLastHkProcessedFile << "\n";
00094   }
00095 
00096 }
00097 
00098 
00099 
00100 
00101 int openRootFiles(char *eventInName, char *hkInName)
00102 {
00103   FileStat_t staty;
00104   if(eventInName) {
00105     theEvent=0;
00106     if(!eventTree)
00107       eventTree = new TChain("eventTree");
00108     if(gSystem->GetPathInfo(eventInName,staty)) {
00109       std::cout << "Can't find File: " << eventInName << std::endl;
00110       return -1;
00111     }
00112     else {
00113       //     theEventFile = new TFile(eventInName,"OLD");
00114       eventTree->Add(eventInName);
00115       if(eventTree->GetEntries()>0) {   
00116         eventTree->SetBranchAddress("run",&runNumber);
00117         eventTree->SetBranchAddress("event",&theEvent);
00118         
00119       }
00120       else { 
00121         std::cout << "Can't find eventTree\n";
00122         return -1;
00123       }
00124     }
00125   }
00126   
00127   if(hkInName) {
00128     theHk=0;
00129     hkTree = new TChain("hkTree");
00130     if(gSystem->GetPathInfo(hkInName,staty)) {
00131       std::cout << "Can't open File: " << hkInName << std::endl;
00132       return -1;
00133     }
00134     else {
00135       hkTree->Add(hkInName);
00136       if(hkTree->GetEntries()>0) {      
00137         hkTree->SetBranchAddress("fullhk",&theHk);
00138         hkTree->SetBranchAddress("run",&runNumber);
00139      }
00140       else {
00141         std::cout << "Can't find hkTree\n";
00142         return -1;
00143       }
00144     }
00145   }
00146   
00147   
00148   return 0;
00149 }

Generated on Wed Aug 8 16:20:07 2012 for ARA ROOT Test Bed Software by doxygen 1.4.7