|
[Rivet-svn] r2946 - in trunk: . include/Rivet include/Rivet/Tools src/Toolsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgMon Feb 21 10:22:28 GMT 2011
Author: buckley Date: Mon Feb 21 10:22:27 2011 New Revision: 2946 Log: Changing search path list construction behaviour to the agreed type of 'fallback' scheme (minus the current directory entry: I think it best to not be sensitive to the directory in which the script is run, cf. PATH for executables) and adding file-finding functions (which are also available in Python). Also some API cleaning of path-related function signatures and duplicate declarations. Modified: trunk/ChangeLog trunk/include/Rivet/RivetAIDA.hh trunk/include/Rivet/Tools/RivetPaths.hh trunk/include/Rivet/Tools/Utils.hh trunk/src/Tools/RivetAIDA.cc trunk/src/Tools/RivetPaths.cc Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Mon Feb 21 10:20:27 2011 (r2945) +++ trunk/ChangeLog Mon Feb 21 10:22:27 2011 (r2946) @@ -1,3 +1,21 @@ +2011-02-21 Andy Buckley <andy at insectnation.org> + + * Adding PDF documentation for path searching and .info/.plot + files, and tidying overfull lines. + + * Removing unneeded const declarations from various return by + value path and internal binning functions. Should not affect ABI + compatibility but will force recompilation of external packages + using the RivetPaths.hh and Utils.hh headers. + + * Adding findAnalysis*File(fname) functions, to be used by Rivet + scripts and external programs to find files known to Rivet + according to Rivet's (newly standard) lookup rule. + + * Changing search path function behaviour to always return *all* + search directories rather than overriding the built-in locations + if the environment variables are set. + 2011-02-20 Andy Buckley <andy at insectnation.org> * Adding the ATLAS 2011 transverse jet shapes analysis. @@ -11,7 +29,9 @@ * Added ATLAS prompt photon analysis ATLAS_2010_S8914702 2011-02-10 Hendrik Hoeth <hendrik.hoeth at cern.ch> + * Simple NOOP constructor for Thrust projection + * Add CMS event shape analysis. Data read off the plots. We will get the final numbers when the paper is accepted by the journal. Modified: trunk/include/Rivet/RivetAIDA.hh ============================================================================== --- trunk/include/Rivet/RivetAIDA.hh Mon Feb 21 10:20:27 2011 (r2945) +++ trunk/include/Rivet/RivetAIDA.hh Mon Feb 21 10:22:27 2011 (r2946) @@ -27,17 +27,16 @@ /// Function to get a map of all the bin edge vectors in a paper with the /// given @a papername. - const map<string, BinEdges> getBinEdges(string papername); + map<string, BinEdges> getBinEdges(string papername); - const map<string, BinEdges> - getBinEdges(const map<string, vector<DPSXPoint> >& xpoints); + map<string, BinEdges> getBinEdges(const map<string, vector<DPSXPoint> >& xpoints); - const map<string, vector<DPSXPoint> > getDPSXValsErrs(string papername); + map<string, vector<DPSXPoint> > getDPSXValsErrs(string papername); - const map<string, vector<DPSXYPoint> > getDPSXYValsErrs(string papername); + map<string, vector<DPSXYPoint> > getDPSXYValsErrs(string papername); /// Get the file system path to the AIDA reference file for this paper. - const string getDataPath(string papername); + string getDatafilePath(string papername); /// Return the integral over the histogram bins inline double integral(AIDA::IHistogram1D* histo) { @@ -49,7 +48,6 @@ return intg; } - using AIDA::IHistogram1D; using AIDA::IDataPointSet; using AIDA::IDataPoint; Modified: trunk/include/Rivet/Tools/RivetPaths.hh ============================================================================== --- trunk/include/Rivet/Tools/RivetPaths.hh Mon Feb 21 10:20:27 2011 (r2945) +++ trunk/include/Rivet/Tools/RivetPaths.hh Mon Feb 21 10:22:27 2011 (r2946) @@ -5,18 +5,26 @@ namespace Rivet { + /// @name Installation directory paths + //@{ + /// Get library install path - const std::string getLibPath(); + std::string getLibPath(); /// Get data install path - const std::string getDataPath(); + std::string getDataPath(); /// Get Rivet data install path - const std::string getRivetDataPath(); + std::string getRivetDataPath(); + + //@} + + /// @name Analysis library search paths + //@{ /// Get Rivet analysis plugin library search paths - const std::vector<std::string> getAnalysisLibPaths(); + std::vector<std::string> getAnalysisLibPaths(); /// Set the Rivet analysis plugin library search paths void setAnalysisLibPaths(const std::vector<std::string>& paths); @@ -24,14 +32,38 @@ /// Set the Rivet analysis plugin library search paths void addAnalysisLibPath(const std::string& extrapath); + /// @brief Find the first file of the given name in the analysis library search dirs + /// @note If none found, returns an empty string + std::string findAnalysisLibFile(const std::string& filename); + + //@} + + + /// @name Analysis data/metadata paths and search functions + //@{ + /// Get Rivet analysis reference data search paths - const std::vector<std::string> getAnalysisRefPaths(); + std::vector<std::string> getAnalysisRefPaths(); + + /// @brief Find the first file of the given name in the ref data file search dirs + /// @note If none found, returns an empty string + std::string findAnalysisRefFile(const std::string& filename); /// Get Rivet analysis info metadata search paths - const std::vector<std::string> getAnalysisInfoPaths(); + std::vector<std::string> getAnalysisInfoPaths(); + + /// @brief Find the first file of the given name in the analysis info file search dirs + /// @note If none found, returns an empty string + std::string findAnalysisInfoFile(const std::string& filename); /// Get Rivet analysis plot style search paths - const std::vector<std::string> getAnalysisPlotPaths(); + std::vector<std::string> getAnalysisPlotPaths(); + + /// @brief Find the first file of the given name in the analysis plot file search dirs + /// @note If none found, returns an empty string + std::string findAnalysisPlotFile(const std::string& filename); + + //@} } Modified: trunk/include/Rivet/Tools/Utils.hh ============================================================================== --- trunk/include/Rivet/Tools/Utils.hh Mon Feb 21 10:20:27 2011 (r2945) +++ trunk/include/Rivet/Tools/Utils.hh Mon Feb 21 10:22:27 2011 (r2946) @@ -93,16 +93,6 @@ } - /// Get library install path - const string getLibPath(); - - /// Get data install path - const string getDataPath(); - - /// Get Rivet data install path - const string getRivetDataPath(); - - } #endif Modified: trunk/src/Tools/RivetAIDA.cc ============================================================================== --- trunk/src/Tools/RivetAIDA.cc Mon Feb 21 10:20:27 2011 (r2945) +++ trunk/src/Tools/RivetAIDA.cc Mon Feb 21 10:22:27 2011 (r2946) @@ -2,6 +2,7 @@ #include "Rivet/Rivet.hh" #include "Rivet/RivetBoost.hh" #include "Rivet/Tools/Utils.hh" +#include "Rivet/Tools/RivetPaths.hh" #include "LWH/AnalysisFactory.h" #include "TinyXML/tinyxml.h" #include <sstream> @@ -17,26 +18,16 @@ } - // Forward declaration of generated function. - const string getRivetDataPath(); - - - const string getDatafilePath(string papername) { - const vector<string> searchpaths = getAnalysisRefPaths(); - foreach (const string& dir, searchpaths) { - std::ifstream in; - const string file = dir + "/" + papername + ".aida"; - if (access(file.c_str(), R_OK) == 0) { - return file; - } - } + string getDatafilePath(string papername) { + const string path = findAnalysisRefFile(papername + ".aida"); + if (!path.empty()) return path; throw Rivet::Error("Couldn't find ref data file '" + papername + ".aida" + " in $RIVET_REF_PATH, " + getRivetDataPath() + ", or ."); return ""; } - const map<string, vector<DPSXYPoint> > getDPSXYValsErrs(string papername) { + map<string, vector<DPSXYPoint> > getDPSXYValsErrs(string papername) { // Get filename const string xmlfile = getDatafilePath(papername); @@ -118,7 +109,7 @@ return rtn; } - const map<string, vector<DPSXPoint> > getDPSXValsErrs(string papername) { + map<string, vector<DPSXPoint> > getDPSXValsErrs(string papername) { // Get filename const string xmlfile = getDatafilePath(papername); @@ -193,16 +184,14 @@ - const map<string, BinEdges> - getBinEdges(string papername) { + map<string, BinEdges> getBinEdges(string papername) { const map<string, vector<DPSXPoint> > xpoints = getDPSXValsErrs(papername); return getBinEdges(xpoints); } - const map<string, BinEdges> - getBinEdges(const map<string, vector<DPSXPoint> >& xpoints) { + map<string, BinEdges> getBinEdges(const map<string, vector<DPSXPoint> >& xpoints) { map<string, BinEdges> rtn; for (map<string, vector<DPSXPoint> >::const_iterator dsit = xpoints.begin(); dsit != xpoints.end(); ++dsit) { Modified: trunk/src/Tools/RivetPaths.cc ============================================================================== --- trunk/src/Tools/RivetPaths.cc Mon Feb 21 10:20:27 2011 (r2945) +++ trunk/src/Tools/RivetPaths.cc Mon Feb 21 10:22:27 2011 (r2946) @@ -3,11 +3,25 @@ #include "Rivet/Tools/Utils.hh" #include "Rivet/RivetBoost.hh" #include "binreloc.h" +//#include <sys/stat.h> namespace Rivet { - const string getLibPath() { + inline string _findFile(const string& filename, const vector<string>& paths) { + //struct stat stFileInfo; + foreach (const string& dir, paths) { + const string path = dir + "/" + filename; + //if (stat(path.c_str(), &stFileInfo) == 0) { + if (access(path.c_str(), R_OK) == 0) { + return path; + } + } + return ""; + } + + + string getLibPath() { BrInitError error; br_init_lib(&error); char* temp = br_find_lib_dir(DEFAULTLIBDIR); @@ -16,7 +30,7 @@ return libdir; } - const string getDataPath() { + string getDataPath() { BrInitError error; br_init_lib(&error); char* temp = br_find_data_dir(DEFAULTDATADIR); @@ -25,12 +39,24 @@ return sharedir; } - const string getRivetDataPath() { + string getRivetDataPath() { return getDataPath() + "/Rivet"; } - const vector<string> getAnalysisLibPaths() { + + void setAnalysisLibPaths(const vector<string>& paths) { + const string pathstr = pathjoin(paths); + setenv("RIVET_ANALYSIS_PATH", pathstr.c_str(), 1); + } + + void addAnalysisLibPath(const string& extrapath) { + vector<string> paths = getAnalysisLibPaths(); + paths.push_back(extrapath); + setAnalysisLibPaths(paths); + } + + vector<string> getAnalysisLibPaths() { vector<string> dirs; char* env = 0; env = getenv("RIVET_ANALYSIS_PATH"); @@ -44,69 +70,69 @@ return dirs; } - - void setAnalysisLibPaths(const vector<string>& paths) { - const string pathstr = pathjoin(paths); - setenv("RIVET_ANALYSIS_PATH", pathstr.c_str(), 1); - } - - - void addAnalysisLibPath(const string& extrapath) { - vector<string> paths = getAnalysisLibPaths(); - paths.push_back(extrapath); - setAnalysisLibPaths(paths); + string findAnalysisLibFile(const string& filename) { + return _findFile(filename, getAnalysisLibPaths()); } - const vector<string> getAnalysisRefPaths() { + vector<string> getAnalysisRefPaths() { vector<string> dirs; char* env = 0; env = getenv("RIVET_REF_PATH"); if (env) { // Use the Rivet analysis path variable if set... dirs += pathsplit(env); - } else { - // ... otherwise fall back to the Rivet data install path - dirs += getRivetDataPath(); - // ... and also add any analysis plugin search dirs for convenience - dirs += getAnalysisLibPaths(); } + // Then fall back to the Rivet data install path... + dirs += getRivetDataPath(); + // ... and also add any analysis plugin search dirs for convenience + dirs += getAnalysisLibPaths(); return dirs; } + string findAnalysisRefFile(const string& filename) { + return _findFile(filename, getAnalysisRefPaths()); + } + - const vector<string> getAnalysisInfoPaths() { + vector<string> getAnalysisInfoPaths() { vector<string> dirs; char* env = 0; env = getenv("RIVET_INFO_PATH"); if (env) { // Use the Rivet analysis path variable if set... dirs += pathsplit(env); - } else { - // ... otherwise fall back to the Rivet data install path - dirs += getRivetDataPath(); - // ... and also add any analysis plugin search dirs for convenience - dirs += getAnalysisLibPaths(); } + // Then fall back to the Rivet data install path... + dirs += getRivetDataPath(); + // ... and also add any analysis plugin search dirs for convenience + dirs += getAnalysisLibPaths(); return dirs; } + string findAnalysisInfoFile(const string& filename) { + return _findFile(filename, getAnalysisInfoPaths()); + } - const vector<string> getAnalysisPlotPaths() { + + vector<string> getAnalysisPlotPaths() { vector<string> dirs; char* env = 0; env = getenv("RIVET_PLOT_PATH"); if (env) { // Use the Rivet analysis path variable if set... dirs += pathsplit(env); - } else { - // ... otherwise fall back to the Rivet data install path - dirs += getRivetDataPath(); - // ... and also add any analysis plugin search dirs for convenience - dirs += getAnalysisLibPaths(); } + // Then fall back to the Rivet data install path... + dirs += getRivetDataPath(); + // ... and also add any analysis plugin search dirs for convenience + dirs += getAnalysisLibPaths(); return dirs; } + string findAnalysisPlotFile(const string& filename) { + return _findFile(filename, getAnalysisPlotPaths()); + } + }
More information about the Rivet-svn mailing list |