• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/Users/jmonk/Physics/ForIA/src/D3PD/GoodRunsListsWrapper_enabled.cxx

Go to the documentation of this file.
00001 #include "ForIA/D3PD/GoodRunsListsWrapper.hh"
00002 
00003 #include "GoodRunsLists/TGoodRunsListReader.h"
00004 #include "GoodRunsLists/TGoodRunsList.h"
00005 
00006 #include "ForIA/binreloc.h"
00007 #include <errno.h>
00008 #include <sys/stat.h>
00009 
00010 namespace ForIA{
00011   GoodRunsListsWrapper::GoodRunsListsWrapper(const string &xmlFile): m_isEnabled(true){
00012     
00013     string path;
00014     
00015     struct stat buffer;
00016     int fileStatus;
00017     
00018     fileStatus = stat(xmlFile.c_str(), &buffer);
00019     
00020     // Try to use the file even if we don't have permission.  Failure to open 
00021     // the file in the latter case should alert the user, rather than continue 
00022     // to search other paths
00023     if(fileStatus == 0 || errno==EPERM){
00024       path = xmlFile;
00025     }else{
00026   
00027       char *envPath=0;
00028       envPath = getenv("FORIA_DATA_PATH");
00029       
00030       if(envPath){
00031         path = envPath;
00032       }else{
00033         BrInitError brError;
00034         br_init_lib(&brError);
00035         path = br_find_data_dir(DEFAULTDATADIR);
00036       }
00037       
00038       path = path + "/GRL/" + xmlFile;
00039     }
00040     
00041     m_reader = new Root::TGoodRunsListReader();
00042     std::cout<<"GoodRunsLists:  using file "<<path<<std::endl;
00043     m_reader->SetXMLFile(path.c_str());
00044     m_reader->Interpret();
00045     m_goodRunsList = new Root::TGoodRunsList((m_reader->GetMergedGoodRunsList()));
00046     m_goodRunsList->Summary(true);
00047   }
00048 
00049   bool GoodRunsListsWrapper::checkRun(const Event &evt) const{
00050     if(!m_isEnabled){
00051       throw std::runtime_error("GoodRunsLists are disabled - cannot check status of Event run number!");
00052     }
00053     return m_goodRunsList->HasRun(evt.runNumber());
00054   }
00055 
00056   bool GoodRunsListsWrapper::checkLBN(const Event &evt) const{
00057     if(!m_isEnabled){
00058       throw std::runtime_error("GoodRunsLists are disabled - cannot check status of Event Lumi Block!");
00059     }
00060     return m_goodRunsList->HasRunLumiBlock(evt.runNumber(), evt.lumiBlock());
00061   }
00062 }
00063 
00064 

Generated on Mon Jul 30 2012 16:56:35 for ForIA by  doxygen 1.7.2