rivet is hosted by Hepforge, IPPP Durham
RivetYODA.cc
Go to the documentation of this file.
00001 #include "Rivet/RivetYODA.hh"
00002 #include "Rivet/Rivet.hh"
00003 #include "Rivet/Tools/RivetPaths.hh"
00004 #include "boost/algorithm/string/split.hpp"
00005 
00006 using namespace std;
00007 
00008 namespace Rivet {
00009 
00010 
00011   string getDatafilePath(const string& papername) {
00012     const string path =  findAnalysisRefFile(papername + ".aida");
00013     if (!path.empty()) return path;
00014     throw Rivet::Error("Couldn't find ref data file '" + papername + ".aida" +
00015                        " in $RIVET_REF_PATH, " + getRivetDataPath() + ", or .");
00016     return "";
00017   }
00018 
00019 
00020   RefDataMap getRefData(const string& papername) {
00021     // Get filename
00022     const string xmlfile = getDatafilePath(papername);
00023 
00024     YODA::Reader & reader =  ReaderAIDA::create();
00025     vector<YODA::AnalysisObject *> aovec;
00026     reader.read(xmlfile, aovec);
00027 
00028     // Return value, to be populated
00029     RefDataMap rtn;
00030     foreach ( YODA::AnalysisObject * ao, aovec ) {
00031       Scatter2DPtr refdata( dynamic_cast<Scatter2D *>(ao) );
00032       if (!refdata) continue;
00033       string plotpath = refdata->path();
00034 
00035       // split path at "/" and only return the last field, i.e. the histogram ID
00036       std::vector<string> pathvec;
00037       split( pathvec, plotpath, is_any_of("/"), token_compress_on );
00038       plotpath = pathvec.back();
00039 
00040       rtn[plotpath] = refdata;
00041     }
00042     return rtn;
00043   }
00044 
00045 
00046 }