RivetYODA.cc
Go to the documentation of this file.
00001 #include "Rivet/Rivet.hh" 00002 #include "Rivet/Tools/RivetYODA.hh" 00003 #include "Rivet/Tools/RivetPaths.hh" 00004 #include "YODA/ReaderYODA.h" 00005 #include "YODA/ReaderAIDA.h" 00006 #include "boost/algorithm/string/split.hpp" 00007 00008 using namespace std; 00009 00010 namespace Rivet { 00011 00012 00013 string getDatafilePath(const string& papername) { 00014 /// Try to find YODA otherwise fall back to try AIDA 00015 const string path1 = findAnalysisRefFile(papername + ".yoda"); 00016 if (!path1.empty()) return path1; 00017 const string path2 = findAnalysisRefFile(papername + ".aida"); 00018 if (!path2.empty()) return path2; 00019 throw Rivet::Error("Couldn't find ref data file '" + papername + ".yoda/aida" + 00020 " in $RIVET_REF_PATH, '" + getRivetDataPath() + "', or '.'"); 00021 } 00022 00023 00024 std::map<std::string, Scatter2DPtr> getRefData(const string& papername) { 00025 const string datafile = getDatafilePath(papername); 00026 00027 // Make an appropriate data file reader and read the data objects 00028 YODA::Reader& reader = (datafile.find(".yoda") != string::npos) ? \ 00029 YODA::ReaderYODA::create() : YODA::ReaderAIDA::create(); 00030 vector<YODA::AnalysisObject *> aovec; 00031 reader.read(datafile, aovec); 00032 00033 // Return value, to be populated 00034 std::map<std::string, Scatter2DPtr> rtn; 00035 foreach ( YODA::AnalysisObject* ao, aovec ) { 00036 Scatter2DPtr refdata( dynamic_cast<Scatter2D *>(ao) ); 00037 if (!refdata) continue; 00038 string plotpath = refdata->path(); 00039 00040 // Split path at "/" and only return the last field, i.e. the histogram ID 00041 std::vector<string> pathvec; 00042 split( pathvec, plotpath, is_any_of("/"), token_compress_on ); 00043 plotpath = pathvec.back(); 00044 00045 rtn[plotpath] = refdata; 00046 } 00047 return rtn; 00048 } 00049 00050 00051 } Generated on Thu Feb 6 2014 17:38:46 for The Rivet MC analysis system by 1.7.6.1 |