Rivet API documentation

Rivet 4.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
8namespace Rivet {
9
10
13 public:
14
16 static unique_ptr<AnalysisInfo> make(const std::string& name);
17
20 clear();
21 }
22
23 ~AnalysisInfo() { }
24
25 void parseInfoFile();
26
27
33
36 std::string name() const {
37 if (!_name.empty()) return _name;
38 if (!experiment().empty() && !year().empty()) {
39 if (!inspireID().empty()) {
40 return experiment() + "_" + year() + "_I" + inspireID();
41 }
42 else if (!spiresID().empty()) {
43 return experiment() + "_" + year() + "_S" + spiresID();
44 }
45 }
46 return "";
47 }
48
49 void setName(const std::string& name) {
50 _name = name;
51 }
52
54 std::string getRefDataName() const {
55 if (!_refDataName.empty()) return _refDataName;
56 return name();
57 }
58
59 void setRefDataName(const std::string& name) {
60 _refDataName = name;
61 }
62
64 const std::string& inspireID() const {
65 return _inspireID;
66 }
67
69 void setInspireID(const std::string& inspireID) {
70 _inspireID = inspireID;
71 }
72
74 const std::string& spiresID() const {
75 return _spiresID;
76 }
77
79 void setSpiresID(const std::string& spiresID) {
80 _spiresID = spiresID;
81 }
82
87 const std::vector<std::string>& authors() const {
88 return _authors;
89 }
90
91 void setAuthors(const std::vector<std::string>& authors) {
92 _authors = authors;
93 }
94
100 const std::string& summary() const {
101 return _summary;
102 }
103
104 void setSummary(const std::string& summary) {
105 _summary = summary;
106 }
107
114 const std::string& description() const {
115 return _description;
116 }
117
118 void setDescription(const std::string& description) {
119 _description = description;
120 }
121
127 const std::string& runInfo() const {
128 return _runInfo;
129 }
130
131 void setRunInfo(const std::string& runInfo) {
132 _runInfo = runInfo;
133 }
134
136 const std::vector<PdgIdPair>& beamIDs() const {
137 return _beams;
138 }
139
141 void setBeamIDs(const std::vector<PdgIdPair>& beamids) {
142 _beams = beamids;
143 }
144
146 const std::vector<std::pair<double, double>>& energies() const {
147 return _energies;
148 }
149
150 void setEnergies(const std::vector<std::pair<double, double>>& energies) {
151 _energies = energies;
152 }
153
155 const std::string& experiment() const {
156 return _experiment;
157 }
158
159 void setExperiment(const std::string& experiment) {
160 _experiment = experiment;
161 }
162
164 const std::string& collider() const {
165 return _collider;
166 }
167
168 void setCollider(const std::string& collider) {
169 _collider = collider;
170 }
171
175 const std::string& year() const {
176 return _year;
177 }
178
180 void setYear(const std::string& year) {
181 _year = year;
182 }
183
185 double luminosityfb() const {
186 return _luminosityfb;
187 }
188
189 double luminosity() const {
190 return 1000 * _luminosityfb;
191 }
192
194 void setLuminosityfb(const double luminosityfb) {
195 _luminosityfb = luminosityfb;
196 }
197
199 const std::vector<std::string>& references() const {
200 return _references;
201 }
202
203 void setReferences(const std::vector<std::string>& references) {
204 _references = references;
205 }
206
208 const std::vector<std::string>& keywords() const {
209 return _keywords;
210 }
211 void setKeywords(const std::vector<std::string>& keywords) {
212 _keywords = keywords;
213 }
214
216 const std::string& warning() const {
217 return _warning;
218 }
219 void setWarning(const std::string warning) {
220 _warning = warning;
221 }
222
224 const std::string& refMatch() const {
225 return _refmatch;
226 }
227 void setRefMatch(const std::string refmatch) {
228 _refmatch = refmatch;
229 }
230
232 const std::string& refUnmatch() const {
233 return _refunmatch;
234 }
235 void setRefUnmatch(const std::string refunmatch) {
236 _refunmatch = refunmatch;
237 }
238
240 const std::string& writerDoublePrecision() const {
241 return _writerdoubleprecision;
242 }
243 void setWriterDoublePrecision(const std::string dp) {
244 _writerdoubleprecision = dp;
245 }
246
248 const std::string& bibKey() const {
249 return _bibKey;
250 }
251
252 void setBibKey(const std::string& bibKey) {
253 _bibKey = bibKey;
254 }
255
257 const std::string& bibTeX() const {
258 return _bibTeX;
259 }
260
261 void setBibTeX(const std::string& bibTeX) {
262 _bibTeX = bibTeX;
263 }
264
266 const std::vector<std::string>& todos() const {
267 return _todos;
268 }
269
270 void setTodos(const std::vector<std::string>& todos) {
271 _todos = todos;
272 }
273
275
276
279
281 const std::vector<std::string>& options() const {
282 return _options;
283 }
284
286 bool validOption(std::string key, std::string val) const;
287
289 void setOptions(const std::vector<std::string>& opts) {
290 _options = opts;
292 }
293
296
298
299
302
304 const std::string& status() const {
305 return _status;
306 }
307
308 void setStatus(const std::string& status) {
309 _status = status;
310 }
311
313 bool reentrant() const {
314 return _reentrant;
315 }
316
317 void setReentrant(bool ree = true) {
318 _reentrant = ree;
319 }
320
322 bool validated() const {
323 return statuscheck("VALIDATED");
324 }
325
327 bool preliminary() const {
328 return statuscheck("PRELIMINARY");
329 }
330
332 bool obsolete() const {
333 return statuscheck("OBSOLETE");
334 }
335
337 bool unvalidated() const {
338 return statuscheck("UNVALIDATED");
339 }
340
342 bool random() const {
343 return statuscheck("RANDOM");
344 }
345
347 bool unphysical() const {
348 return statuscheck("UNPHYSICAL");
349 }
350
352 bool hepdata() const {
353 return !statuscheck("NOHEPDATA");
354 }
355
357 bool multiweight() const {
358 return !statuscheck("SINGLEWEIGHT");
359 }
360
362 bool statuscheck(const string& word) const {
363 auto pos = _status.find(word);
364 if (pos == string::npos) return false;
365 if (pos > 0 && isalnum(_status[pos - 1])) return false;
366 if (pos + word.length() < _status.length() && isalnum(_status[pos + word.length()])) return false;
367 return true;
368 }
369
371
372
374 std::string refFile() const;
375
377 const std::vector<std::string>& validation() const {
378 return _validation;
379 }
380
381
382 private:
383
384 // std::map<string,string> _yamldict;
385
386 static std::string _infoFilePath;
387
388 std::string _name;
389 std::string _refDataName;
390 std::string _spiresID, _inspireID;
391 std::vector<std::string> _authors;
392 std::string _summary;
393 std::string _description;
394 std::string _runInfo;
395 std::string _experiment;
396 std::string _collider;
397 std::vector<std::pair<PdgId, PdgId>> _beams;
398 std::vector<std::pair<double, double>> _energies;
399 std::string _year;
400 double _luminosityfb;
401 std::vector<std::string> _references;
402 std::vector<std::string> _keywords;
403 std::string _bibKey;
404 std::string _bibTeX;
405 //std::string _bibTeXBody; ///< Was thinking of avoiding duplication of BibKey...
406 std::string _status;
407 std::string _warning;
408 std::string _refmatch;
409 std::string _refunmatch;
410 std::string _writerdoubleprecision;
411 std::vector<std::string> _todos;
412 bool _needsCrossSection;
413 bool _isInitialised;
414
415 std::vector<std::string> _options;
416 std::map<std::string, std::set<std::string>> _optionmap;
417
418 std::vector<std::string> _validation;
419
420 bool _reentrant;
421
422 void clear() {
423 //_yamldict.clear();
424 _name = "";
425 _refDataName = "";
426 _spiresID = "";
427 _inspireID = "";
428 _authors.clear();
429 _summary = "";
430 _description = "";
431 _runInfo = "";
432 _experiment = "";
433 _collider = "";
434 _beams.clear();
435 _energies.clear();
436 _year = "";
437 _luminosityfb = -1;
438 _references.clear();
439 _keywords.clear();
440 _bibKey = "";
441 _bibTeX = "";
442 //_bibTeXBody = "";
443 _status = "";
444 _warning = "";
445 _refmatch = "";
446 _refunmatch = "";
447 _writerdoubleprecision = "";
448 _todos.clear();
449 _needsCrossSection = false;
450 _options.clear();
451 _optionmap.clear();
452 _validation.clear();
453 _reentrant = false;
454 _isInitialised = false;
455 }
456 };
457
458
460 std::string toString(const AnalysisInfo& ai);
461
463 inline std::ostream& operator<<(std::ostream& os, const AnalysisInfo& ai) {
464 os << toString(ai);
465 return os;
466 }
467
468
469}
470
471#endif
Holder of analysis metadata.
Definition AnalysisInfo.hh:12
static unique_ptr< AnalysisInfo > make(const std::string &name)
Static factory method: returns null pointer if no metadata found.
std::string refFile() const
Find the path to the reference-data file for this analysis.
const std::vector< std::string > & validation() const
List a series of command lines to be used for valdation.
Definition AnalysisInfo.hh:377
AnalysisInfo()
Default constructor.
Definition AnalysisInfo.hh:19
void setCollider(const std::string &collider)
Set the collider on which the experiment ran.
Definition AnalysisInfo.hh:168
void setTodos(const std::vector< std::string > &todos)
Set the to-do list.
Definition AnalysisInfo.hh:270
const std::string & refUnmatch() const
Negative filtering regex for ref-data HepData sync.
Definition AnalysisInfo.hh:232
void setBeamIDs(const std::vector< PdgIdPair > &beamids)
Set beam particle types.
Definition AnalysisInfo.hh:141
void setYear(const std::string &year)
Set the year in which the original experimental analysis was published.
Definition AnalysisInfo.hh:180
const std::string & description() const
Get a full description of the analysis.
Definition AnalysisInfo.hh:114
const std::string & warning() const
Any warning message.
Definition AnalysisInfo.hh:216
const std::string & bibKey() const
BibTeX citation key for this article.
Definition AnalysisInfo.hh:248
void setRefDataName(const std::string &name)
Set the reference data name of the analysis (if different from plugin name).
Definition AnalysisInfo.hh:59
void setBibTeX(const std::string &bibTeX)
Set the BibTeX citation entry for this article.
Definition AnalysisInfo.hh:261
const std::vector< std::string > & todos() const
Any work to be done on this analysis.
Definition AnalysisInfo.hh:266
const std::string & collider() const
Collider on which the experiment ran.
Definition AnalysisInfo.hh:164
void setRunInfo(const std::string &runInfo)
Set the full description for this analysis.
Definition AnalysisInfo.hh:131
const std::string & inspireID() const
Get the Inspire (SPIRES replacement) ID code for this analysis.
Definition AnalysisInfo.hh:64
const std::string & bibTeX() const
BibTeX citation entry for this article.
Definition AnalysisInfo.hh:257
const std::vector< PdgIdPair > & beamIDs() const
Beam particle types.
Definition AnalysisInfo.hh:136
const std::vector< std::string > & references() const
Journal and preprint references.
Definition AnalysisInfo.hh:199
void setExperiment(const std::string &experiment)
Set the experiment which performed and published this analysis.
Definition AnalysisInfo.hh:159
void setInspireID(const std::string &inspireID)
Set the Inspire (SPIRES replacement) ID code for this analysis.
Definition AnalysisInfo.hh:69
void setSummary(const std::string &summary)
Set the short description for this analysis.
Definition AnalysisInfo.hh:104
void setLuminosityfb(const double luminosityfb)
Set the integrated data luminosity of the data set.
Definition AnalysisInfo.hh:194
const std::string & summary() const
Get a short description of the analysis.
Definition AnalysisInfo.hh:100
const std::vector< std::pair< double, double > > & energies() const
Sets of valid beam energies.
Definition AnalysisInfo.hh:146
const std::string & refMatch() const
Positive filtering regex for ref-data HepData sync.
Definition AnalysisInfo.hh:224
void setEnergies(const std::vector< std::pair< double, double > > &energies)
Set the valid beam energies.
Definition AnalysisInfo.hh:150
const std::string & spiresID() const
Get the SPIRES ID code for this analysis.
Definition AnalysisInfo.hh:74
double luminosity() const
The integrated data luminosity of the data set in 1/pb.
Definition AnalysisInfo.hh:189
const std::vector< std::string > & keywords() const
Analysis keywords, for grouping etc.
Definition AnalysisInfo.hh:208
const std::string & runInfo() const
Information about the events needed as input for this analysis.
Definition AnalysisInfo.hh:127
void setBibKey(const std::string &bibKey)
Set the BibTeX citation key for this article.
Definition AnalysisInfo.hh:252
const std::vector< std::string > & authors() const
Names & emails of paper/analysis authors.
Definition AnalysisInfo.hh:87
std::string name() const
Definition AnalysisInfo.hh:36
std::string getRefDataName() const
Get the reference data name of the analysis (if different from plugin name).
Definition AnalysisInfo.hh:54
const std::string & year() const
When the original experimental analysis was published.
Definition AnalysisInfo.hh:175
const std::string & writerDoublePrecision() const
Positive filtering regex for setting double precision in Writer.
Definition AnalysisInfo.hh:240
void setReferences(const std::vector< std::string > &references)
Set the journal and preprint reference list.
Definition AnalysisInfo.hh:203
void setAuthors(const std::vector< std::string > &authors)
Set the author list.
Definition AnalysisInfo.hh:91
void setDescription(const std::string &description)
Set the full description for this analysis.
Definition AnalysisInfo.hh:118
double luminosityfb() const
The integrated data luminosity of the data set in 1/fb.
Definition AnalysisInfo.hh:185
void setName(const std::string &name)
Set the name of the analysis.
Definition AnalysisInfo.hh:49
const std::string & experiment() const
Experiment which performed and published this analysis.
Definition AnalysisInfo.hh:155
void setSpiresID(const std::string &spiresID)
Set the SPIRES ID code for this analysis.
Definition AnalysisInfo.hh:79
const std::vector< std::string > & options() const
Get the option list.
Definition AnalysisInfo.hh:281
void buildOptionMap()
Build a map of options to facilitate checking.
bool validOption(std::string key, std::string val) const
Check if the given option is valid.
void setOptions(const std::vector< std::string > &opts)
Set the option list.
Definition AnalysisInfo.hh:289
bool statuscheck(const string &word) const
Helper function for checking status-string contents.
Definition AnalysisInfo.hh:362
bool preliminary() const
Return true if preliminary.
Definition AnalysisInfo.hh:327
bool validated() const
Return true if validated.
Definition AnalysisInfo.hh:322
void setStatus(const std::string &status)
Set the analysis code status.
Definition AnalysisInfo.hh:308
bool random() const
Return true if includes random variations.
Definition AnalysisInfo.hh:342
bool unphysical() const
Return true if the analysis uses generator-dependent information.
Definition AnalysisInfo.hh:347
const std::string & status() const
Whether this analysis is trusted (in any way!).
Definition AnalysisInfo.hh:304
void setReentrant(bool ree=true)
Set re-entrant status.
Definition AnalysisInfo.hh:317
bool unvalidated() const
Return true if unvalidated.
Definition AnalysisInfo.hh:337
bool hepdata() const
Check if refdata comes automatically from Hepdata.
Definition AnalysisInfo.hh:352
bool obsolete() const
Return true if obsolete.
Definition AnalysisInfo.hh:332
bool reentrant() const
Return true if finalize() can be run multiple times for this analysis.
Definition AnalysisInfo.hh:313
bool multiweight() const
Check if this analysis can handle multiple weights.
Definition AnalysisInfo.hh:357
Definition LHCbCommon.hh:9
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition AnalysisInfo.hh:463
std::string toString(const AnalysisInfo &ai)
String representation.