RivetYODA.cc
Go to the documentation of this file.
00001 #include "Rivet/Config/RivetCommon.hh" 00002 #include "Rivet/Tools/RivetYODA.hh" 00003 #include "Rivet/Tools/RivetPaths.hh" 00004 #include "YODA/ReaderYODA.h" 00005 #include "YODA/ReaderAIDA.h" 00006 00007 using namespace std; 00008 00009 namespace Rivet { 00010 00011 00012 string getDatafilePath(const string& papername) { 00013 /// Try to find YODA otherwise fall back to try AIDA 00014 const string path1 = findAnalysisRefFile(papername + ".yoda"); 00015 if (!path1.empty()) return path1; 00016 const string path2 = findAnalysisRefFile(papername + ".aida"); 00017 if (!path2.empty()) return path2; 00018 throw Rivet::Error("Couldn't find ref data file '" + papername + ".yoda/aida" + 00019 " in $RIVET_REF_PATH, '" + getRivetDataPath() + "', or '.'"); 00020 } 00021 00022 00023 map<string, AnalysisObjectPtr> getRefData(const string& papername) { 00024 const string datafile = getDatafilePath(papername); 00025 00026 // Make an appropriate data file reader and read the data objects 00027 /// @todo Remove AIDA support some day... 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 map<string, AnalysisObjectPtr> rtn; 00035 foreach ( YODA::AnalysisObject* ao, aovec ) { 00036 AnalysisObjectPtr refdata(ao); 00037 if (!refdata) continue; 00038 const string plotpath = refdata->path(); 00039 // Split path at "/" and only return the last field, i.e. the histogram ID 00040 const size_t slashpos = plotpath.rfind("/"); 00041 const string plotname = (slashpos+1 < plotpath.size()) ? plotpath.substr(slashpos+1) : ""; 00042 rtn[plotname] = refdata; 00043 } 00044 return rtn; 00045 } 00046 00047 00048 } Generated on Tue Dec 13 2016 16:32:40 for The Rivet MC analysis system by ![]() |