Rivet  3.1.3
AnalysisInfo.hh
1 // -*- C++ -*-
2 #ifndef RIVET_AnalysisInfo_HH
3 #define RIVET_AnalysisInfo_HH
4 
5 #include "Rivet/Config/RivetCommon.hh"
6 #include <ostream>
7 
8 namespace Rivet {
9 
10 
12  class AnalysisInfo {
13  public:
14 
16  static unique_ptr<AnalysisInfo> make(const std::string& name);
17 
19 
20 
22  AnalysisInfo() { clear(); }
23 
26 
28 
29 
30  public:
31 
37 
40  std::string name() const {
41  if (!_name.empty()) return _name;
42  if (!experiment().empty() && !year().empty()) {
43  if (!inspireId().empty()) {
44  return experiment() + "_" + year() + "_I" + inspireId();
45  } else if (!spiresId().empty()) {
46  return experiment() + "_" + year() + "_S" + spiresId();
47  }
48  }
49  return "";
50  }
51 
53  void setName(const std::string& name) { _name = name; }
54 
56  std::string getRefDataName() const {
57  if (!_refDataName.empty()) return _refDataName;
58  return name();
59  }
60 
62  void setRefDataName(const std::string& name) { _refDataName = name; }
63 
65  const std::string& inspireId() const { return _inspireId; }
66 
68  void setInspireId(const std::string& inspireId) { _inspireId = inspireId; }
69 
70 
72  const std::string& spiresId() const { return _spiresId; }
73 
75  void setSpiresId(const std::string& spiresId) { _spiresId = spiresId; }
76 
77 
81  const std::vector<std::string>& authors() const { return _authors; }
82 
84  void setAuthors(const std::vector<std::string>& authors) { _authors = authors; }
85 
86 
91  const std::string& summary() const { return _summary; }
92 
94  void setSummary(const std::string& summary) { _summary = summary; }
95 
96 
102  const std::string& description() const { return _description; }
103 
105  void setDescription(const std::string& description) { _description = description; }
106 
107 
112  const std::string& runInfo() const { return _runInfo; }
113 
115  void setRunInfo(const std::string& runInfo) { _runInfo = runInfo; }
116 
117 
119  const std::vector<PdgIdPair>& beams() const { return _beams; }
120 
122  void setBeams(const std::vector<PdgIdPair>& beams) { _beams = beams; }
123 
124 
126  const std::vector<std::pair<double,double> >& energies() const { return _energies; }
127 
129  void setEnergies(const std::vector<std::pair<double, double> >& energies) { _energies = energies; }
130 
131 
133  const std::string& experiment() const { return _experiment; }
134 
136  void setExperiment(const std::string& experiment) { _experiment = experiment; }
137 
138 
140  const std::string& collider() const { return _collider; }
141 
143  void setCollider(const std::string& collider) { _collider = collider; }
144 
145 
149  const std::string& year() const { return _year; }
150 
152  void setYear(const std::string& year) { _year = year; }
153 
155  const double luminosityfb() const { return _luminosityfb; }
157  const double luminosity() const { return 1000*_luminosityfb; }
158 
160  void setLuminosityfb(const double luminosityfb) { _luminosityfb = luminosityfb; }
161 
163  const std::vector<std::string>& references() const { return _references; }
164 
166  void setReferences(const std::vector<std::string>& references) { _references = references; }
167 
169  const std::vector<std::string>& keywords() const { return _keywords; }
170 
172  const std::string& bibKey() const { return _bibKey;}
173 
175  void setBibKey(const std::string& bibKey) { _bibKey = bibKey; }
176 
177 
179  const std::string& bibTeX() const { return _bibTeX; }
180 
182  void setBibTeX(const std::string& bibTeX) { _bibTeX = bibTeX; }
183 
184 
186  const std::vector<std::string>& todos() const { return _todos; }
187 
189  void setTodos(const std::vector<std::string>& todos) { _todos = todos; }
190 
192 
193 
196 
198  const std::vector<std::string>& options() const { return _options; }
199 
201  bool validOption(std::string key, std::string val) const;
202 
204  void setOptions(const std::vector<std::string>& opts) {
205  _options = opts;
206  buildOptionMap();
207  }
208 
210  void buildOptionMap();
211 
213 
214 
217 
219  const std::string& status() const { return _status; }
220 
222  void setStatus(const std::string& status) { _status = status; }
223 
225  bool reentrant() const { return _reentrant; }
226 
228  void setReentrant(bool ree = true) { _reentrant = ree; }
229 
231  bool validated() const {
232  return statuscheck("VALIDATED");
233  }
234 
236  bool preliminary() const {
237  return statuscheck("PRELIMINARY");
238  }
239 
241  bool obsolete() const {
242  return statuscheck("OBSOLETE");
243  }
244 
246  bool unvalidated() const {
247  return statuscheck("UNVALIDATED");
248  }
249 
251  bool random() const {
252  return statuscheck("RANDOM");
253  }
254 
257  bool unphysical() const {
258  return statuscheck("UNPHYSICAL");
259  }
260 
262  bool hepdata() const {
263  return !statuscheck("NOHEPDATA");
264  }
265 
267  bool multiweight() const {
268  return !statuscheck("SINGLEWEIGHT");
269  }
270 
272  bool statuscheck(string word) const {
273  auto pos =_status.find(word);
274  if ( pos == string::npos ) return false;
275  if ( pos > 0 && isalnum(_status[pos - 1]) ) return false;
276  if ( pos + word.length() < _status.length() &&
277  isalnum(_status[pos + word.length()]) ) return false;
278  return true;
279  }
280 
282 
283 
285  std::string refFile() const;
286 
288  const std::vector<std::string> & validation() const {
289  return _validation;
290  }
291 
294  bool needsCrossSection() const { return _needsCrossSection; }
295 
296 
297 
298  private:
299 
300  std::string _name;
301  std::string _refDataName;
302  std::string _spiresId, _inspireId;
303  std::vector<std::string> _authors;
304  std::string _summary;
305  std::string _description;
306  std::string _runInfo;
307  std::string _experiment;
308  std::string _collider;
309  std::vector<std::pair<PdgId, PdgId> > _beams;
310  std::vector<std::pair<double, double> > _energies;
311  std::string _year;
312  double _luminosityfb;
313  std::vector<std::string> _references;
314  std::vector<std::string> _keywords;
315  std::string _bibKey;
316  std::string _bibTeX;
317  //std::string _bibTeXBody; ///< Was thinking of avoiding duplication of BibKey...
318  std::string _status;
319  std::vector<std::string> _todos;
320  bool _needsCrossSection;
321 
322  std::vector<std::string> _options;
323  std::map< std::string, std::set<std::string> > _optionmap;
324 
325  std::vector<std::string> _validation;
326 
327  bool _reentrant;
328 
329  void clear() {
330  _name = "";
331  _refDataName = "";
332  _spiresId = "";
333  _inspireId = "";
334  _authors.clear();
335  _summary = "";
336  _description = "";
337  _runInfo = "";
338  _experiment = "";
339  _collider = "";
340  _beams.clear();
341  _energies.clear();
342  _year = "";
343  _luminosityfb = -1;
344  _references.clear();
345  _keywords.clear();
346  _bibKey = "";
347  _bibTeX = "";
348  //_bibTeXBody = "";
349  _status = "";
350  _todos.clear();
351  _needsCrossSection = false;
352  _options.clear();
353  _optionmap.clear();
354  _validation.clear();
355  _reentrant = false;
356  }
357 
358  };
359 
360 
362  std::string toString(const AnalysisInfo& ai);
363 
365  inline std::ostream& operator<<(std::ostream& os, const AnalysisInfo& ai) {
366  os << toString(ai);
367  return os;
368  }
369 
370 
371 }
372 
373 #endif
Definition: MC_Cent_pPb.hh:10
void setName(const std::string &name)
Set the name of the analysis.
Definition: AnalysisInfo.hh:53
bool hepdata() const
Check if refdata comes automatically from Hepdata.
Definition: AnalysisInfo.hh:262
void setYear(const std::string &year)
Set the year in which the original experimental analysis was published.
Definition: AnalysisInfo.hh:152
AnalysisInfo()
The default constructor.
Definition: AnalysisInfo.hh:22
bool random() const
Return true if includes random variations.
Definition: AnalysisInfo.hh:251
const double luminosityfb() const
The integrated data luminosity of the data set in 1/fb.
Definition: AnalysisInfo.hh:155
void setEnergies(const std::vector< std::pair< double, double > > &energies)
Set the valid beam energies.
Definition: AnalysisInfo.hh:129
void setBeams(const std::vector< PdgIdPair > &beams)
Set beam particle types.
Definition: AnalysisInfo.hh:122
void setAuthors(const std::vector< std::string > &authors)
Set the author list.
Definition: AnalysisInfo.hh:84
const std::vector< std::string > & references() const
Journal and preprint references.
Definition: AnalysisInfo.hh:163
bool obsolete() const
Return true if obsolete.
Definition: AnalysisInfo.hh:241
void setInspireId(const std::string &inspireId)
Set the Inspire (SPIRES replacement) ID code for this analysis.
Definition: AnalysisInfo.hh:68
Holder of analysis metadata.
Definition: AnalysisInfo.hh:12
bool unvalidated() const
Return true if unvalidated.
Definition: AnalysisInfo.hh:246
void setTodos(const std::vector< std::string > &todos)
Set the to-do list.
Definition: AnalysisInfo.hh:189
void buildOptionMap()
Build a map of options to facilitate checking.
~AnalysisInfo()
The destructor.
Definition: AnalysisInfo.hh:25
static unique_ptr< AnalysisInfo > make(const std::string &name)
Static factory method: returns null pointer if no metadata found.
const std::string & status() const
Whether this analysis is trusted (in any way!)
Definition: AnalysisInfo.hh:219
bool preliminary() const
Return true if preliminary.
Definition: AnalysisInfo.hh:236
const std::string & spiresId() const
Get the SPIRES ID code for this analysis.
Definition: AnalysisInfo.hh:72
bool multiweight() const
Check if This analysis can handle mulltiple weights.
Definition: AnalysisInfo.hh:267
const std::vector< std::string > & keywords() const
Analysis Keywords for grouping etc.
Definition: AnalysisInfo.hh:169
void setBibTeX(const std::string &bibTeX)
Set the BibTeX citation entry for this article.
Definition: AnalysisInfo.hh:182
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.
Definition: AnalysisInfo.hh:102
const std::string & bibKey() const
BibTeX citation key for this article.
Definition: AnalysisInfo.hh:172
const double luminosity() const
The integrated data luminosity of the data set in 1/pb.
Definition: AnalysisInfo.hh:157
void setSummary(const std::string &summary)
Set the short description for this analysis.
Definition: AnalysisInfo.hh:94
const std::vector< std::string > & validation() const
List a series of command lines to be used for valdation.
Definition: AnalysisInfo.hh:288
void setRefDataName(const std::string &name)
Set the reference data name of the analysis (if different from plugin name).
Definition: AnalysisInfo.hh:62
bool unphysical() const
Definition: AnalysisInfo.hh:257
const std::string & year() const
When the original experimental analysis was published. When the refereed paper on which this is based...
Definition: AnalysisInfo.hh:149
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)
Definition: AnalysisInfo.hh:112
bool validOption(std::string key, std::string val) const
Check if the given option is valid.
bool validated() const
Return true if validated.
Definition: AnalysisInfo.hh:231
const std::string & inspireId() const
Get the Inspire (SPIRES replacement) ID code for this analysis.
Definition: AnalysisInfo.hh:65
void setRunInfo(const std::string &runInfo)
Set the full description for this analysis.
Definition: AnalysisInfo.hh:115
void setSpiresId(const std::string &spiresId)
Set the SPIRES ID code for this analysis.
Definition: AnalysisInfo.hh:75
std::string name() const
Definition: AnalysisInfo.hh:40
const std::vector< std::string > & todos() const
Any work to be done on this analysis.
Definition: AnalysisInfo.hh:186
bool reentrant() const
Return true if finalize() can be run multiple times for this analysis.
Definition: AnalysisInfo.hh:225
void setCollider(const std::string &collider)
Set the collider on which the experiment ran.
Definition: AnalysisInfo.hh:143
const std::string & experiment() const
Experiment which performed and published this analysis.
Definition: AnalysisInfo.hh:133
void setDescription(const std::string &description)
Set the full description for this analysis.
Definition: AnalysisInfo.hh:105
const std::string & collider() const
Collider on which the experiment ran.
Definition: AnalysisInfo.hh:140
void setExperiment(const std::string &experiment)
Set the experiment which performed and published this analysis.
Definition: AnalysisInfo.hh:136
std::string toString(const AnalysisInfo &ai)
String representation.
bool needsCrossSection() const
Definition: AnalysisInfo.hh:294
const std::vector< std::string > & authors() const
Names & emails of paper/analysis authors. Names and email of authors in &#39;NAME <EMAIL>&#39; format...
Definition: AnalysisInfo.hh:81
const std::vector< std::pair< double, double > > & energies() const
Sets of valid beam energies.
Definition: AnalysisInfo.hh:126
void setReferences(const std::vector< std::string > &references)
Set the journal and preprint reference list.
Definition: AnalysisInfo.hh:166
const std::vector< PdgIdPair > & beams() const
Beam particle types.
Definition: AnalysisInfo.hh:119
bool statuscheck(string word) const
?
Definition: AnalysisInfo.hh:272
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition: AnalysisInfo.hh:365
const std::vector< std::string > & options() const
Get the option list.
Definition: AnalysisInfo.hh:198
void setBibKey(const std::string &bibKey)
Set the BibTeX citation key for this article.
Definition: AnalysisInfo.hh:175
const std::string & summary() const
Get a short description of the analysis. Short (one sentence) description used as an index entry...
Definition: AnalysisInfo.hh:91
void setReentrant(bool ree=true)
setReentrant
Definition: AnalysisInfo.hh:228
void setStatus(const std::string &status)
Set the analysis code status.
Definition: AnalysisInfo.hh:222
std::string refFile() const
Find the path to the reference-data file for this analysis.
void setLuminosityfb(const double luminosityfb)
Set the integrated data luminosity of the data set.
Definition: AnalysisInfo.hh:160
std::string getRefDataName() const
Get the reference data name of the analysis (if different from plugin name).
Definition: AnalysisInfo.hh:56
const std::string & bibTeX() const
BibTeX citation entry for this article.
Definition: AnalysisInfo.hh:179
void setOptions(const std::vector< std::string > &opts)
Set the option list.
Definition: AnalysisInfo.hh:204