AnalysisInfo Class Reference

#include <AnalysisInfo.hh>

Collaboration diagram for AnalysisInfo:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 11 of file AnalysisInfo.hh.


Public Member Functions

bool needsCrossSection () const
 Return true if this analysis needs to know the process cross-section.
Standard constructors and destructors.
 AnalysisInfo ()
 The default constructor.
 ~AnalysisInfo ()
 The destructor.
Metadata
Metadata is used for querying from the command line and also for building web pages and the analysis pages in the Rivet manual.

std::string name () const
const std::string & spiresId () const
 Get a description of the analysis.
const std::vector< std::string > & authors () const
 Names & emails of paper/analysis authors. Names and email of authors in 'NAME <EMAIL>' format. The first name in the list should be the primary contact person.
const std::string & summary () const
 Get a short description of the analysis. Short (one sentence) description used as an index entry. Use description() to provide full descriptive paragraphs of analysis details.
const std::string & description () const
 Get a full description of the analysis. Full textual description of this analysis, what it is useful for, what experimental techniques are applied, etc. Should be treated as a chunk of restructuredText (http://docutils.sourceforge.net/rst.html), with equations to be rendered as LaTeX with amsmath operators.
const std::string & runInfo () const
 Information about the events needed as input for this analysis. Event types, energies, kinematic cuts, particles to be considered stable, etc. etc. Should be treated as a restructuredText bullet list (http://docutils.sourceforge.net/rst.html).
const std::pair< ParticleName,
ParticleName > & 
beams () const
 Beam particle types.
const std::vector< std::pair
< double, double > > & 
energies () const
 Sets of valid beam energy pairs.
const std::string & experiment () const
 Experiment which performed and published this analysis.
const std::string & collider () const
 Collider on which the experiment ran.
const std::string & year () const
 Incoming beams required by this analysis.
const std::vector< std::string > & references () const
 Journal, and preprint references.
const std::string & status () const
 Whether this analysis is trusted (in any way!).

Static Public Member Functions

static AnalysisInfomake (const std::string &name)
 Static factory method: returns null pointer if no metadata found.

Private Attributes

std::string _name
std::string _spiresId
std::vector< std::string > _authors
std::string _summary
std::string _description
std::string _runInfo
std::string _experiment
std::string _collider
std::pair< ParticleName,
ParticleName
_beams
std::vector< std::pair< double,
double > > 
_energies
std::string _year
std::vector< std::string > _references
std::string _status
bool _needsCrossSection

Friends

class Analysis

Constructor & Destructor Documentation

AnalysisInfo (  )  [inline]

The default constructor.

Definition at line 24 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::make().

00024 { }

~AnalysisInfo (  )  [inline]

The destructor.

Definition at line 27 of file AnalysisInfo.hh.

00027 { }


Member Function Documentation

AnalysisInfo * make ( const std::string &  ananame  )  [static]

Static factory method: returns null pointer if no metadata found.

Static factory method.

Ideas: search RIVET_INFO_PATH etc. for <name>.info.yaml how to determine the name? only populate pointer on Analysis when requested use smart pointer: deletes automatically when Analysis goes out of scope

Todo:
Use system-independent separator (e.g. Boost.File)

If no ana data file found, return null AI

Definition at line 23 of file AnalysisInfo.cc.

References AnalysisInfo::_authors, AnalysisInfo::_beams, AnalysisInfo::_collider, AnalysisInfo::_description, AnalysisInfo::_energies, AnalysisInfo::_experiment, AnalysisInfo::_name, AnalysisInfo::_references, AnalysisInfo::_runInfo, AnalysisInfo::_spiresId, AnalysisInfo::_status, AnalysisInfo::_summary, AnalysisInfo::_year, AnalysisInfo::AnalysisInfo(), Rivet::ANY, AnalysisInfo::authors(), AnalysisInfo::beams(), Log::DEBUG, AnalysisInfo::energies(), Log::ERROR, Log::getLog(), Rivet::getParticleNameEnum(), Rivet::getRivetDataPath(), Rivet::split(), Log::TRACE, and Log::WARN.

00023                                                            {
00024     // Build the list of directories to search
00025     vector<string> dirs;
00026     char* env = 0;
00027     // First try to use the Rivet data path variable
00028     env = getenv("RIVET_INFO_PATH");
00029     if (env) dirs += split(env);
00030     // Then try to use the Rivet data install path
00031     dirs += getRivetDataPath();
00032     // And the current dir
00033     dirs += ".";
00034 
00035     bool found = false;
00036     string datapath = "";
00037     foreach (const string& d, dirs) {
00038       if (d.empty()) continue;
00039       /// @todo Use system-independent separator (e.g. Boost.File)
00040       datapath = d + "/" + ananame + ".info";
00041       Log::getLog("Rivet.AnalysisInfo")
00042         << Log::TRACE << "Looking for analysis data file '" << datapath << "'" << endl;
00043       if (access(datapath.c_str(), R_OK) == 0) {
00044         found = true;
00045         break;
00046       }
00047     }
00048 
00049     // Returned AI, in semi-null state
00050     AnalysisInfo* ai = new AnalysisInfo();
00051     ai->_beams = make_pair(ANY,ANY);
00052     ai->_name = ananame;
00053 
00054     /// If no ana data file found, return null AI
00055     if (!found) return ai;
00056 
00057     // Read data from YAML document
00058     Log::getLog("Rivet.AnalysisInfo")
00059       << Log::DEBUG << "Reading analysis data from " << datapath << endl;
00060     std::ifstream io(datapath.c_str());
00061     YAML::Parser parser(io);
00062     YAML::Node doc;
00063     try {
00064       parser.GetNextDocument(doc);
00065       //cout << doc << endl;
00066     } catch (const YAML::ParserException& ex) {
00067       Log::getLog("Rivet.AnalysisInfo")
00068         << Log::ERROR << "Parse error when reading analysis data from "
00069         << datapath << endl;
00070       return ai;
00071     }
00072 
00073     for (YAML::Iterator it = doc.begin(); it != doc.end(); ++it) {
00074       string key;
00075       it.first() >> key;
00076       stringstream sec;
00077       sec << it.second();
00078       const string secstr = sec.str().substr(0, sec.str().length()-1);
00079       Log::getLog("Rivet.AnalysisInfo")
00080         << Log::TRACE << key << ": " << secstr << endl;
00081       try {
00082         if (key == "Name") {
00083           it.second() >> ai->_name;
00084         } else if (key == "Summary") {
00085           it.second() >> ai->_summary;
00086         } else if (key == "Experiment") {
00087           it.second() >> ai->_experiment;
00088         } else if (key == "Beams") {
00089           const YAML::Node& beams = it.second();
00090           vector<ParticleName> beampair;
00091           for (YAML::Iterator b = beams.begin(); b != beams.end(); ++b) {
00092             string bstr;
00093             *b >> bstr;
00094             ParticleName beamname = getParticleNameEnum(bstr);
00095             beampair += beamname;
00096           }
00097           assert(beampair.size() == 2);
00098           ai->_beams = make_pair<ParticleName,ParticleName>(beampair[0], beampair[1]);
00099         // } else if (key == "NeedCrossSection") {
00100         //   // it.second() >> ai->_needsCrossSection;
00101         } else if (key == "Energies") {
00102           const YAML::Node& energies = it.second();
00103           vector<pair<double,double> > beam_energy_pairs;
00104           for (YAML::Iterator be = energies.begin(); be != energies.end(); ++be) {
00105             if (be->GetType() == YAML::CT_SCALAR) {
00106               // If beam energy is a scalar, then assume symmetric beams each with half that energy
00107               double sqrts;
00108               *be >> sqrts;
00109               beam_energy_pairs += make_pair(sqrts/2.0, sqrts/2.0);
00110             } else if (be->GetType() == YAML::CT_SEQUENCE) {
00111               const YAML::Node& beamenergy_strs = be.second();
00112               vector<double> beamenergies;
00113               for (YAML::Iterator e = beamenergy_strs.begin(); e != beamenergy_strs.end(); ++e) {
00114                 double beamenergy;
00115                 *e >> beamenergy;
00116                 beamenergies += beamenergy;
00117               }
00118               assert(beamenergies.size() == 2);
00119               beam_energy_pairs += make_pair(beamenergies[0], beamenergies[1]);
00120             } else {
00121               assert(0 && "Beam energies have to be a list of either numbers or pairs of numbers");
00122             }
00123           }
00124           ai->_energies = beam_energy_pairs;
00125         } else if (key == "Collider") {
00126           it.second() >> ai->_collider;
00127         } else if (key == "SpiresID") {
00128           it.second() >> ai->_spiresId;
00129         } else if (key == "Status") {
00130           it.second() >> ai->_status;
00131         } else if (key == "RunInfo") {
00132           it.second() >> ai->_runInfo;
00133         } else if (key == "Description") {
00134           it.second() >> ai->_description;
00135         } else if (key == "Year") {
00136           it.second() >> ai->_year;
00137         } else if (key == "Authors") {
00138           const YAML::Node& authors = it.second();
00139           for (YAML::Iterator a = authors.begin(); a != authors.end(); ++a) {
00140             string astr;
00141             *a >> astr;
00142             ai->_authors += astr;
00143           }
00144         } else if (key == "References") {
00145           const YAML::Node& refs = it.second();
00146           for (YAML::Iterator r = refs.begin(); r != refs.end(); ++r) {
00147             string rstr;
00148             *r >> rstr;
00149             ai->_references += rstr;
00150           }
00151         }
00152       } catch (const YAML::RepresentationException& ex) {
00153         Log::getLog("Rivet.Analysis")
00154           << Log::WARN << "Type error when reading analysis data '"
00155           << key << "' from " << datapath << endl;
00156       }
00157     }
00158     Log::getLog("Rivet.AnalysisInfo") << Log::DEBUG << ai << endl;
00159     return ai;
00160   }

std::string name (  )  const [inline]

Get the name of the analysis. By default this is computed by combining the results of the experiment, year and Spires ID metadata methods and you should only override it if there's a good reason why those won't work.

Definition at line 42 of file AnalysisInfo.hh.

References AnalysisInfo::_name, AnalysisInfo::experiment(), AnalysisInfo::spiresId(), and AnalysisInfo::year().

Referenced by Rivet::toString().

00042                            {
00043       if (!_name.empty()) return _name;
00044       if (!experiment().empty() && !year().empty() && !spiresId().empty()) {
00045         return experiment() + "_" + year() + "_S" + spiresId();
00046       }
00047       return "";
00048     }

const std::string& spiresId (  )  const [inline]

Get a description of the analysis.

Definition at line 51 of file AnalysisInfo.hh.

References AnalysisInfo::_spiresId.

Referenced by AnalysisInfo::name().

00051 { return _spiresId; }

const std::vector<std::string>& authors (  )  const [inline]

Names & emails of paper/analysis authors. Names and email of authors in 'NAME <EMAIL>' format. The first name in the list should be the primary contact person.

Definition at line 56 of file AnalysisInfo.hh.

References AnalysisInfo::_authors.

Referenced by AnalysisInfo::make().

00056 { return _authors; }

const std::string& summary (  )  const [inline]

Get a short description of the analysis. Short (one sentence) description used as an index entry. Use description() to provide full descriptive paragraphs of analysis details.

Definition at line 62 of file AnalysisInfo.hh.

References AnalysisInfo::_summary.

Referenced by Rivet::toString().

00062 { return _summary; }

const std::string& description (  )  const [inline]

Get a full description of the analysis. Full textual description of this analysis, what it is useful for, what experimental techniques are applied, etc. Should be treated as a chunk of restructuredText (http://docutils.sourceforge.net/rst.html), with equations to be rendered as LaTeX with amsmath operators.

Definition at line 69 of file AnalysisInfo.hh.

References AnalysisInfo::_description.

00069 { return _description; }

const std::string& runInfo (  )  const [inline]

Information about the events needed as input for this analysis. Event types, energies, kinematic cuts, particles to be considered stable, etc. etc. Should be treated as a restructuredText bullet list (http://docutils.sourceforge.net/rst.html).

Definition at line 75 of file AnalysisInfo.hh.

References AnalysisInfo::_runInfo.

00075 { return _runInfo; }

const std::pair<ParticleName,ParticleName>& beams (  )  const [inline]

Beam particle types.

Definition at line 78 of file AnalysisInfo.hh.

References AnalysisInfo::_beams.

Referenced by AnalysisInfo::make().

00078 { return _beams; }

const std::vector<std::pair<double,double> >& energies (  )  const [inline]

Sets of valid beam energy pairs.

Definition at line 81 of file AnalysisInfo.hh.

References AnalysisInfo::_energies.

Referenced by Analysis::energies(), and AnalysisInfo::make().

00081 { return _energies; }

const std::string& experiment (  )  const [inline]

Experiment which performed and published this analysis.

Definition at line 84 of file AnalysisInfo.hh.

References AnalysisInfo::_experiment.

Referenced by AnalysisInfo::name().

00084 { return _experiment; }

const std::string& collider (  )  const [inline]

Collider on which the experiment ran.

Definition at line 87 of file AnalysisInfo.hh.

References AnalysisInfo::_collider.

00087 { return _collider; }

const std::string& year (  )  const [inline]

Incoming beams required by this analysis.

When the original experimental analysis was published. When the refereed paper on which this is based was published, according to SPIRES.

Definition at line 95 of file AnalysisInfo.hh.

References AnalysisInfo::_year.

Referenced by AnalysisInfo::name().

00095 { return _year; }

const std::vector<std::string>& references (  )  const [inline]

Journal, and preprint references.

Definition at line 98 of file AnalysisInfo.hh.

References AnalysisInfo::_references.

00098 { return _references; }

const std::string& status (  )  const [inline]

Whether this analysis is trusted (in any way!).

Definition at line 101 of file AnalysisInfo.hh.

References AnalysisInfo::_status.

Referenced by Rivet::toString().

00101 { return _status; }

bool needsCrossSection (  )  const [inline]

Return true if this analysis needs to know the process cross-section.

Definition at line 105 of file AnalysisInfo.hh.

References AnalysisInfo::_needsCrossSection.

00105 { return _needsCrossSection; }


Friends And Related Function Documentation

friend class Analysis [friend]

Todo:
Remove this when all metadata taken from YAML

Definition at line 13 of file AnalysisInfo.hh.


Member Data Documentation

std::string _name [private]

Definition at line 109 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::make(), and AnalysisInfo::name().

std::string _spiresId [private]

Definition at line 110 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::make(), and AnalysisInfo::spiresId().

std::vector<std::string> _authors [private]

Definition at line 111 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::authors(), and AnalysisInfo::make().

std::string _summary [private]

Definition at line 112 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::make(), and AnalysisInfo::summary().

std::string _description [private]

Definition at line 113 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::description(), and AnalysisInfo::make().

std::string _runInfo [private]

Definition at line 114 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::make(), and AnalysisInfo::runInfo().

std::string _experiment [private]

Definition at line 115 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::experiment(), and AnalysisInfo::make().

std::string _collider [private]

Definition at line 116 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::collider(), and AnalysisInfo::make().

std::pair<ParticleName, ParticleName> _beams [private]

Definition at line 117 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::beams(), and AnalysisInfo::make().

std::vector<std::pair<double, double> > _energies [private]

Definition at line 118 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::energies(), and AnalysisInfo::make().

std::string _year [private]

Definition at line 119 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::make(), and AnalysisInfo::year().

std::vector<std::string> _references [private]

Definition at line 120 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::make(), and AnalysisInfo::references().

std::string _status [private]

Definition at line 121 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::make(), and AnalysisInfo::status().

bool _needsCrossSection [private]

Definition at line 122 of file AnalysisInfo.hh.

Referenced by AnalysisInfo::needsCrossSection().


The documentation for this class was generated from the following files: