AnalysisInfo Class Reference

#include <AnalysisInfo.hh>

Collaboration diagram for AnalysisInfo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

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
void setName (const std::string &name)
 Set the name of the analysis.
const std::string & spiresId () const
 Get the SPIRES ID code for this analysis.
void setSpiresId (const std::string &spiresId)
 Set the SPIRES ID code for this 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.
void setAuthors (const std::vector< std::string > &authors)
 Set the author list.
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.
void setSummary (const std::string &summary)
 Set the short description for this analysis.
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.
void setDescription (const std::string &description)
 Set the full description for this analysis.
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).
void setRunInfo (const std::string &runInfo)
 Set the full description for this analysis.
const std::vector< PdgIdPair > & beams () const
 Beam particle types.
void setBeams (const std::vector< PdgIdPair > &beams)
 Set beam particle types.
const std::vector< std::pair
< double, double > > & 
energies () const
 Sets of valid beam energies.
void setEnergies (const std::vector< std::pair< double, double > > &energies)
 Set the valid beam energies.
const std::string & experiment () const
 Experiment which performed and published this analysis.
void setExperiment (const std::string &experiment)
 Set the experiment which performed and published this analysis.
const std::string & collider () const
 Collider on which the experiment ran.
void setCollider (const std::string &collider)
 Set the collider on which the experiment ran.
const std::string & year () const
 When the original experimental analysis was published. When the refereed paper on which this is based was published, according to SPIRES.
void setYear (const std::string &year)
 Set the year in which the original experimental analysis was published.
const std::vector< std::string > & references () const
 Journal and preprint references.
void setReferences (const std::vector< std::string > &references)
 Set the journal and preprint reference list.
const std::string & bibKey () const
 BibTeX citation key for this article.
void setBibKey (const std::string &bibKey)
 Set the BibTeX citation key for this article.
const std::string & bibTeX () const
 BibTeX citation entry for this article.
void setBibTeX (const std::string &bibTeX)
 Set the BibTeX citation entry for this article.
const std::string & status () const
 Whether this analysis is trusted (in any way!).
void setStatus (const std::string &status)
 Set the analysis code status.
const std::vector< std::string > & todos () const
 Any work to be done on this analysis.
void setTodos (const std::vector< std::string > &todos)
 Set the to-do list.
bool needsCrossSection () const
 Return true if this analysis needs to know the process cross-section.
void setNeedsCrossSection (bool needXsec)
 Return true if this analysis needs to know the process cross-section.

Static Public Member Functions

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

Private Member Functions

void clear ()

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::vector< std::pair< PdgId,
PdgId > > 
_beams
std::vector< std::pair< double,
double > > 
_energies
std::string _year
std::vector< std::string > _references
std::string _bibKey
std::string _bibTeX
std::string _status
std::vector< std::string > _todos
bool _needsCrossSection

Friends

class Analysis

Detailed Description

Definition at line 11 of file AnalysisInfo.hh.


Constructor & Destructor Documentation

AnalysisInfo (  )  [inline]

The default constructor.

Definition at line 25 of file AnalysisInfo.hh.

References AnalysisInfo::clear().

Referenced by AnalysisInfo::make().

00025 { clear(); }

~AnalysisInfo (  )  [inline]

The destructor.

Definition at line 28 of file AnalysisInfo.hh.

00028 { }


Member Function Documentation

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 66 of file AnalysisInfo.hh.

References AnalysisInfo::_authors.

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

00066 { return _authors; }

const std::vector<PdgIdPair>& beams (  )  const [inline]

Beam particle types.

Definition at line 104 of file AnalysisInfo.hh.

References AnalysisInfo::_beams.

Referenced by Analysis::requiredBeams().

00104 { return _beams; }

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

BibTeX citation key for this article.

Definition at line 148 of file AnalysisInfo.hh.

References AnalysisInfo::_bibKey.

Referenced by Analysis::bibKey().

00148 { return _bibKey;}

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

BibTeX citation entry for this article.

Definition at line 155 of file AnalysisInfo.hh.

References AnalysisInfo::_bibTeX.

Referenced by Analysis::bibTeX().

00155 { return _bibTeX; }

void clear (  )  [inline, private]
const std::string& collider (  )  const [inline]

Collider on which the experiment ran.

Definition at line 125 of file AnalysisInfo.hh.

References AnalysisInfo::_collider.

Referenced by Analysis::collider().

00125 { return _collider; }

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 87 of file AnalysisInfo.hh.

References AnalysisInfo::_description.

Referenced by Analysis::description().

00087 { return _description; }

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

Sets of valid beam energies.

Definition at line 111 of file AnalysisInfo.hh.

References AnalysisInfo::_energies.

Referenced by AnalysisInfo::make(), Analysis::requiredEnergies(), and AnalysisInfo::setEnergies().

00111 { return _energies; }

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

Experiment which performed and published this analysis.

Definition at line 118 of file AnalysisInfo.hh.

References AnalysisInfo::_experiment.

Referenced by Analysis::experiment(), and AnalysisInfo::name().

00118 { return _experiment; }

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

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

Static factory method.

If no ana data file found, return null AI

Definition at line 23 of file AnalysisInfo.cc.

References AnalysisInfo::_authors, AnalysisInfo::_beams, AnalysisInfo::_bibKey, AnalysisInfo::_bibTeX, AnalysisInfo::_collider, AnalysisInfo::_description, AnalysisInfo::_energies, AnalysisInfo::_experiment, AnalysisInfo::_name, AnalysisInfo::_needsCrossSection, AnalysisInfo::_references, AnalysisInfo::_runInfo, AnalysisInfo::_spiresId, AnalysisInfo::_status, AnalysisInfo::_summary, AnalysisInfo::_todos, AnalysisInfo::_year, AnalysisInfo::AnalysisInfo(), Rivet::ANY, AnalysisInfo::authors(), AnalysisInfo::energies(), Rivet::findAnalysisInfoFile(), Log::getLog(), Rivet::make_pdgid_pair(), MSG_DEBUG, MSG_ERROR, MSG_TRACE, Rivet::s, AnalysisInfo::todos(), and Log::WARN.

Referenced by Analysis::Analysis().

00023                                                            {
00024     // Returned AI, in semi-null state
00025     AnalysisInfo* ai = new AnalysisInfo();
00026     ai->_beams += make_pair(ANY, ANY);
00027     ai->_name = ananame;
00028 
00029     /// If no ana data file found, return null AI
00030     const string datapath = findAnalysisInfoFile(ananame + ".info");
00031     if (datapath.empty()) {
00032       MSG_DEBUG("No datafile " << ananame + ".info found");
00033       return ai;
00034     }
00035 
00036     // Read data from YAML document
00037     MSG_DEBUG("Reading analysis data from " << datapath);
00038     std::ifstream io(datapath.c_str());
00039     YAML::Parser parser(io);
00040     YAML::Node doc;
00041     try {
00042       parser.GetNextDocument(doc);
00043       //cout << doc << endl;
00044     } catch (const YAML::ParserException& ex) {
00045       MSG_ERROR("Parse error when reading analysis data from " << datapath);
00046       return ai;
00047     }
00048 
00049     for (YAML::Iterator it = doc.begin(); it != doc.end(); ++it) {
00050       string key;
00051       it.first() >> key;
00052       stringstream sec;
00053       // sec << it.second();
00054       // const string secstr = sec.str().substr(0, sec.str().length()-1);
00055       // MSG_TRACE(key << ": " << secstr);
00056       try {
00057         if (key == "Name") {
00058           it.second() >> ai->_name;
00059         } else if (key == "Summary") {
00060           it.second() >> ai->_summary;
00061         } else if (key == "Experiment") {
00062           it.second() >> ai->_experiment;
00063         } else if (key == "Beams") {
00064           const YAML::Node& beampairs = it.second();
00065           vector<PdgIdPair> beam_pairs;
00066           if (beampairs.size() == 2 &&
00067               beampairs[0].GetType() == YAML::CT_SCALAR &&
00068               beampairs[1].GetType() == YAML::CT_SCALAR) {
00069             string bstr0, bstr1;
00070             beampairs[0] >> bstr0;
00071             beampairs[1] >> bstr1;
00072             beam_pairs += make_pdgid_pair(bstr0, bstr1);
00073           } else {
00074             for (YAML::Iterator bpi = beampairs.begin(); bpi != beampairs.end(); ++bpi) {
00075               const YAML::Node& bp = *bpi;
00076               if (bp.size() == 2 &&
00077                   bp[0].GetType() == YAML::CT_SCALAR &&
00078                   bp[1].GetType() == YAML::CT_SCALAR) {
00079                 string bstr0, bstr1;
00080                 bp[0] >> bstr0;
00081                 bp[1] >> bstr1;
00082                 beam_pairs += make_pdgid_pair(bstr0, bstr1);
00083               } else {
00084                 assert(0 && "Beam ID pairs have to be either a 2-tuple or a list of 2-tuples of particle names");
00085               }
00086             }
00087           }
00088           ai->_beams = beam_pairs;
00089         }
00090         else if (key == "Energies") {
00091           const YAML::Node& energies = it.second();
00092           vector<pair<double,double> > beam_energy_pairs;
00093           for (YAML::Iterator be = energies.begin(); be != energies.end(); ++be) {
00094             if (be->GetType() == YAML::CT_SCALAR) {
00095               // If beam energy is a scalar, then assume symmetric beams each with half that energy
00096               double sqrts;
00097               *be >> sqrts;
00098               beam_energy_pairs += make_pair(sqrts/2.0, sqrts/2.0);
00099             } else if (be->GetType() == YAML::CT_SEQUENCE) {
00100               const YAML::Node& beseq = *be;
00101               // If the sub-sequence is of length 1, then it's another scalar sqrt(s)!
00102               if (beseq.size() == 1) {
00103                 double sqrts;
00104                 (*be)[0] >> sqrts;
00105                 beam_energy_pairs += make_pair(sqrts/2.0, sqrts/2.0);
00106               } else if (beseq.size() == 2) {
00107                 vector<double> beamenergies;
00108                 double beamenergy0, beamenergy1;
00109                 beseq[0] >> beamenergy0;
00110                 beseq[1] >> beamenergy1;
00111                 beam_energy_pairs += make_pair(beamenergy0, beamenergy1);
00112               } else {
00113                 assert(0 && "Beam energies have to be a list of either numbers or pairs of numbers");
00114               }
00115             } else {
00116               assert(0 && "Beam energies have to be a list of either numbers or pairs of numbers");
00117             }
00118           }
00119           ai->_energies = beam_energy_pairs;
00120         } else if (key == "Collider") {
00121           it.second() >> ai->_collider;
00122         } else if (key == "SpiresID") {
00123           it.second() >> ai->_spiresId;
00124         } else if (key == "BibKey") {
00125           it.second() >> ai->_bibKey;
00126         } else if (key == "BibTeX") {
00127           it.second() >> ai->_bibTeX;//Body;
00128         } else if (key == "Status") {
00129           it.second() >> ai->_status;
00130         } else if (key == "ToDo") {
00131           const YAML::Node& todos = it.second();
00132           for (YAML::Iterator todo = todos.begin(); todo != todos.end(); ++todo) {
00133             string s;
00134             *todo >> s;
00135             ai->_todos += s;
00136           }
00137         } else if (key == "NeedCrossSection") {
00138           it.second() >> ai->_needsCrossSection;
00139         } else if (key == "RunInfo") {
00140           it.second() >> ai->_runInfo;
00141         } else if (key == "Description") {
00142           it.second() >> ai->_description;
00143         } else if (key == "Year") {
00144           it.second() >> ai->_year;
00145         } else if (key == "Authors") {
00146           const YAML::Node& authors = it.second();
00147           for (YAML::Iterator a = authors.begin(); a != authors.end(); ++a) {
00148             string astr;
00149             *a >> astr;
00150             ai->_authors += astr;
00151           }
00152         } else if (key == "References") {
00153           const YAML::Node& refs = it.second();
00154           for (YAML::Iterator r = refs.begin(); r != refs.end(); ++r) {
00155             string rstr;
00156             *r >> rstr;
00157             ai->_references += rstr;
00158           }
00159         }
00160       } catch (const YAML::RepresentationException& ex) {
00161         Log::getLog("Rivet.Analysis")
00162           << Log::WARN << "Type error when reading analysis data '"
00163           << key << "' from " << datapath << endl;
00164       }
00165     }
00166     MSG_TRACE("AnalysisInfo pointer = " << ai);
00167     return ai;
00168   }

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 44 of file AnalysisInfo.hh.

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

Referenced by Analysis::name(), and Rivet::toString().

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

bool needsCrossSection (  )  const [inline]

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

Definition at line 176 of file AnalysisInfo.hh.

References AnalysisInfo::_needsCrossSection.

Referenced by Analysis::needsCrossSection().

00176 { return _needsCrossSection; }

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

Journal and preprint references.

Definition at line 141 of file AnalysisInfo.hh.

References AnalysisInfo::_references.

Referenced by Analysis::references().

00141 { return _references; }

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 97 of file AnalysisInfo.hh.

References AnalysisInfo::_runInfo.

Referenced by Analysis::runInfo().

00097 { return _runInfo; }

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

Set the author list.

Definition at line 69 of file AnalysisInfo.hh.

References AnalysisInfo::_authors.

00069 { _authors = authors; }

void setBeams ( const std::vector< PdgIdPair > &  beams  )  [inline]

Set beam particle types.

Definition at line 107 of file AnalysisInfo.hh.

References AnalysisInfo::_beams.

Referenced by Analysis::setRequiredBeams().

00107 { _beams = beams; }

void setBibKey ( const std::string &  bibKey  )  [inline]

Set the BibTeX citation key for this article.

Definition at line 151 of file AnalysisInfo.hh.

References AnalysisInfo::_bibKey.

00151 { _bibKey = bibKey; }

void setBibTeX ( const std::string &  bibTeX  )  [inline]

Set the BibTeX citation entry for this article.

Definition at line 158 of file AnalysisInfo.hh.

References AnalysisInfo::_bibTeX.

00158 { _bibTeX = bibTeX; }

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

Set the collider on which the experiment ran.

Definition at line 128 of file AnalysisInfo.hh.

References AnalysisInfo::_collider.

00128 { _collider = collider; }

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

Set the full description for this analysis.

Definition at line 90 of file AnalysisInfo.hh.

References AnalysisInfo::_description.

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

Set the valid beam energies.

Definition at line 114 of file AnalysisInfo.hh.

References AnalysisInfo::_energies, and AnalysisInfo::energies().

Referenced by Analysis::setRequiredEnergies().

00114 { _energies = energies; }

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

Set the experiment which performed and published this analysis.

Definition at line 121 of file AnalysisInfo.hh.

References AnalysisInfo::_experiment.

00121 { _experiment = experiment; }

void setName ( const std::string &  name  )  [inline]

Set the name of the analysis.

Definition at line 53 of file AnalysisInfo.hh.

References AnalysisInfo::_name.

00053 { _name = name; }

void setNeedsCrossSection ( bool  needXsec  )  [inline]

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

Definition at line 179 of file AnalysisInfo.hh.

References AnalysisInfo::_needsCrossSection.

Referenced by Analysis::setNeedsCrossSection().

00179 { _needsCrossSection = needXsec; }

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

Set the journal and preprint reference list.

Definition at line 144 of file AnalysisInfo.hh.

References AnalysisInfo::_references.

00144 { _references = references; }

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

Set the full description for this analysis.

Definition at line 100 of file AnalysisInfo.hh.

References AnalysisInfo::_runInfo.

00100 { _runInfo = runInfo; }

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

Set the SPIRES ID code for this analysis.

Definition at line 60 of file AnalysisInfo.hh.

References AnalysisInfo::_spiresId.

00060 { _spiresId = spiresId; }

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

Set the analysis code status.

Definition at line 165 of file AnalysisInfo.hh.

References AnalysisInfo::_status.

00165 { _status = status; }

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

Set the short description for this analysis.

Definition at line 79 of file AnalysisInfo.hh.

References AnalysisInfo::_summary.

00079 { _summary = summary; }

void setTodos ( const std::vector< std::string > &  todos  )  [inline]

Set the to-do list.

Definition at line 172 of file AnalysisInfo.hh.

References AnalysisInfo::_todos.

00172 { _todos = todos; }

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

Set the year in which the original experimental analysis was published.

Definition at line 137 of file AnalysisInfo.hh.

References AnalysisInfo::_year.

00137 { _year = year; }

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

Get the SPIRES ID code for this analysis.

Definition at line 57 of file AnalysisInfo.hh.

References AnalysisInfo::_spiresId.

Referenced by AnalysisInfo::name(), and Analysis::spiresId().

00057 { return _spiresId; }

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

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

Definition at line 162 of file AnalysisInfo.hh.

References AnalysisInfo::_status.

Referenced by Analysis::status(), and Rivet::toString().

00162 { return _status; }

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 76 of file AnalysisInfo.hh.

References AnalysisInfo::_summary.

Referenced by Analysis::summary(), and Rivet::toString().

00076 { return _summary; }

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

Any work to be done on this analysis.

Definition at line 169 of file AnalysisInfo.hh.

References AnalysisInfo::_todos.

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

00169 { return _todos; }

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

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

Definition at line 134 of file AnalysisInfo.hh.

References AnalysisInfo::_year.

Referenced by AnalysisInfo::name(), and Analysis::year().

00134 { return _year; }


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::vector<std::string> _authors [private]
std::vector<std::pair<PdgId, PdgId> > _beams [private]
std::string _bibKey [private]
std::string _bibTeX [private]
std::string _collider [private]
std::string _description [private]
std::vector<std::pair<double, double> > _energies [private]
std::string _experiment [private]
std::string _name [private]
bool _needsCrossSection [private]
std::vector<std::string> _references [private]
std::string _runInfo [private]
std::string _spiresId [private]
std::string _status [private]
std::string _summary [private]
std::vector<std::string> _todos [private]
std::string _year [private]

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