Rivet: /Users/chrisg/software/rivet/include/Rivet/AnalysisInfo.hh Source File

| Rivet 3.1.9

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
12 class AnalysisInfo {
13 public:
14
16 static unique_ptr<AnalysisInfo> make(const std::string& name);
17
19 AnalysisInfo() { clear(); }
20
21 ~AnalysisInfo() { }
22
23 void parseInfoFile();
24
25
31
34 std::string name() const {
35 if (!_name.empty()) return _name;
36 if (!experiment().empty() && !year().empty()) {
37 if (!inspireId().empty()) {
38 return experiment() + "_" + year() + "_I" + inspireId();
39 } else if (!spiresId().empty()) {
40 return experiment() + "_" + year() + "_S" + spiresId();
41 }
42 }
43 return "";
44 }
46 void setName(const std::string& name) { _name = name; }
47
49 std::string getRefDataName() const {
50 if (!_refDataName.empty()) return _refDataName;
51 return name();
52 }
54 void setRefDataName(const std::string& name) { _refDataName = name; }
55
57 const std::string& inspireId() const { return _inspireId; }
59 void setInspireId(const std::string& inspireId) { _inspireId = inspireId; }
60
64 const std::string& spiresId() const { return _spiresId; }
68 void setSpiresId(const std::string& spiresId) { _spiresId = spiresId; }
69
74 const std::vector<std::string>& authors() const { return _authors; }
76 void setAuthors(const std::vector<std::string>& authors) { _authors = authors; }
77
83 const std::string& summary() const { return _summary; }
85 void setSummary(const std::string& summary) { _summary = summary; }
86
93 const std::string& description() const { return _description; }
95 void setDescription(const std::string& description) { _description = description; }
96
102 const std::string& runInfo() const { return _runInfo; }
104 void setRunInfo(const std::string& runInfo) { _runInfo = runInfo; }
105
107 const std::vector<PdgIdPair>& beams() const { return _beams; }
109 void setBeams(const std::vector<PdgIdPair>& beams) { _beams = beams; }
110
112 const std::vector<std::pair<double,double> >& energies() const { return _energies; }
114 void setEnergies(const std::vector<std::pair<double, double> >& energies) { _energies = energies; }
115
117 const std::string& experiment() const { return _experiment; }
119 void setExperiment(const std::string& experiment) { _experiment = experiment; }
120
122 const std::string& collider() const { return _collider; }
124 void setCollider(const std::string& collider) { _collider = collider; }
125
129 const std::string& year() const { return _year; }
130
132 void setYear(const std::string& year) { _year = year; }
133
135 double luminosityfb() const { return _luminosityfb; }
137 double luminosity() const { return 1000*_luminosityfb; }
138
140 void setLuminosityfb(const double luminosityfb) { _luminosityfb = luminosityfb; }
141
143 const std::vector<std::string>& references() const { return _references; }
145 void setReferences(const std::vector<std::string>& references) { _references = references; }
146
148 const std::vector<std::string>& keywords() const { return _keywords; }
149 void setKeywords(const std::vector<std::string>& keywords) { _keywords = keywords; }
150
152 const std::string& warning() const { return _warning; }
153 void setWarning(const std::string warning) { _warning = warning; }
154
156 const std::string& refMatch() const { return _refmatch; }
157 void setRefMatch(const std::string refmatch) { _refmatch = refmatch; }
158
160 const std::string& refUnmatch() const { return _refunmatch; }
161 void setRefUnmatch(const std::string refunmatch) { _refunmatch = refunmatch; }
162
164 const std::string& writerDoublePrecision() const { return _writerdoubleprecision; }
165 void setWriterDoublePrecision(const std::string dp) { _writerdoubleprecision = dp; }
166
168 const std::string& bibKey() const { return _bibKey; }
170 void setBibKey(const std::string& bibKey) { _bibKey = bibKey; }
171
173 const std::string& bibTeX() const { return _bibTeX; }
175 void setBibTeX(const std::string& bibTeX) { _bibTeX = bibTeX; }
176
178 const std::vector<std::string>& todos() const { return _todos; }
180 void setTodos(const std::vector<std::string>& todos) { _todos = todos; }
181
183
184
187
189 const std::vector<std::string>& options() const { return _options; }
190
192 bool validOption(std::string key, std::string val) const;
193
195 void setOptions(const std::vector<std::string>& opts) {
196 _options = opts;
197 buildOptionMap();
198 }
199
201 void buildOptionMap();
202
204
205
208
210 const std::string& status() const { return _status; }
212 void setStatus(const std::string& status) { _status = status; }
213
215 bool reentrant() const { return _reentrant; }
217 void setReentrant(bool ree=true) { _reentrant = ree; }
218
220 bool validated() const {
221 return statuscheck("VALIDATED");
222 }
223
225 bool preliminary() const {
226 return statuscheck("PRELIMINARY");
227 }
228
230 bool obsolete() const {
231 return statuscheck("OBSOLETE");
232 }
233
235 bool unvalidated() const {
236 return statuscheck("UNVALIDATED");
237 }
238
240 bool random() const {
241 return statuscheck("RANDOM");
242 }
243
245 bool unphysical() const {
246 return statuscheck("UNPHYSICAL");
247 }
248
250 bool hepdata() const {
251 return !statuscheck("NOHEPDATA");
252 }
253
255 bool multiweight() const {
256 return !statuscheck("SINGLEWEIGHT");
257 }
258
260 bool statuscheck(const string& word) const {
261 auto pos =_status.find(word);
262 if ( pos == string::npos ) return false;
263 if ( pos > 0 && isalnum(_status[pos - 1]) ) return false;
264 if ( pos + word.length() < _status.length() &&
265 isalnum(_status[pos + word.length()]) ) return false;
266 return true;
267 }
268
270
271
273 std::string refFile() const;
274
276 const std::vector<std::string> & validation() const {
277 return _validation;
278 }
279
283 bool needsCrossSection() const { return _needsCrossSection; }
284
285
286 private:
287
288 // std::map<string,string> _yamldict;
289
290 static std::string _infoFilePath;
291
292 std::string _name;
293 std::string _refDataName;
294 std::string _spiresId, _inspireId;
295 std::vector<std::string> _authors;
296 std::string _summary;
297 std::string _description;
298 std::string _runInfo;
299 std::string _experiment;
300 std::string _collider;
301 std::vector<std::pair<PdgId, PdgId> > _beams;
302 std::vector<std::pair<double, double> > _energies;
303 std::string _year;
304 double _luminosityfb;
305 std::vector<std::string> _references;
306 std::vector<std::string> _keywords;
307 std::string _bibKey;
308 std::string _bibTeX;
309 //std::string _bibTeXBody; ///< Was thinking of avoiding duplication of BibKey...
310 std::string _status;
311 std::string _warning;
312 std::string _refmatch;
313 std::string _refunmatch;
314 std::string _writerdoubleprecision;
315 std::vector<std::string> _todos;
316 bool _needsCrossSection;
317 bool _isInitialised;
318
319 std::vector<std::string> _options;
320 std::map< std::string, std::set<std::string> > _optionmap;
321
322 std::vector<std::string> _validation;
323
324 bool _reentrant;
325
326 void clear() {
327 //_yamldict.clear();
328 _name = "";
329 _refDataName = "";
330 _spiresId = "";
331 _inspireId = "";
332 _authors.clear();
333 _summary = "";
334 _description = "";
335 _runInfo = "";
336 _experiment = "";
337 _collider = "";
338 _beams.clear();
339 _energies.clear();
340 _year = "";
341 _luminosityfb = -1;
342 _references.clear();
343 _keywords.clear();
344 _bibKey = "";
345 _bibTeX = "";
346 //_bibTeXBody = "";
347 _status = "";
348 _warning = "";
349 _refmatch = "";
350 _refunmatch = "";
351 _writerdoubleprecision = "";
352 _todos.clear();
353 _needsCrossSection = false;
354 _options.clear();
355 _optionmap.clear();
356 _validation.clear();
357 _reentrant = false;
358 _isInitialised = false;
359 }
360
361 };
362
363
365 std::string toString(const AnalysisInfo& ai);
366
368 inline std::ostream& operator<<(std::ostream& os, const AnalysisInfo& ai) {
369 os << toString(ai);
370 return os;
371 }
372
373
374}
375
376#endif
Rivet::AnalysisInfo
Holder of analysis metadata.
Definition AnalysisInfo.hh:12
Rivet::AnalysisInfo::needsCrossSection
bool needsCrossSection() const
Definition AnalysisInfo.hh:283
Rivet::AnalysisInfo::make
static unique_ptr< AnalysisInfo > make(const std::string &name)
Static factory method: returns null pointer if no metadata found.
Rivet::AnalysisInfo::refFile
std::string refFile() const
Find the path to the reference-data file for this analysis.
Rivet::AnalysisInfo::validation
const std::vector< std::string > & validation() const
List a series of command lines to be used for valdation.
Definition AnalysisInfo.hh:276
Rivet::AnalysisInfo::AnalysisInfo
AnalysisInfo()
Default constructor.
Definition AnalysisInfo.hh:19
Rivet::AnalysisInfo::setCollider
void setCollider(const std::string &collider)
Set the collider on which the experiment ran.
Definition AnalysisInfo.hh:124
Rivet::AnalysisInfo::setTodos
void setTodos(const std::vector< std::string > &todos)
Set the to-do list.
Definition AnalysisInfo.hh:180
Rivet::AnalysisInfo::refUnmatch
const std::string & refUnmatch() const
Negative filtering regex for ref-data HepData sync.
Definition AnalysisInfo.hh:160
Rivet::AnalysisInfo::setYear
void setYear(const std::string &year)
Set the year in which the original experimental analysis was published.
Definition AnalysisInfo.hh:132
Rivet::AnalysisInfo::description
const std::string & description() const
Get a full description of the analysis.
Definition AnalysisInfo.hh:93
Rivet::AnalysisInfo::warning
const std::string & warning() const
Any warning message.
Definition AnalysisInfo.hh:152
Rivet::AnalysisInfo::bibKey
const std::string & bibKey() const
BibTeX citation key for this article.
Definition AnalysisInfo.hh:168
Rivet::AnalysisInfo::setRefDataName
void setRefDataName(const std::string &name)
Set the reference data name of the analysis (if different from plugin name).
Definition AnalysisInfo.hh:54
Rivet::AnalysisInfo::setBibTeX
void setBibTeX(const std::string &bibTeX)
Set the BibTeX citation entry for this article.
Definition AnalysisInfo.hh:175
Rivet::AnalysisInfo::todos
const std::vector< std::string > & todos() const
Any work to be done on this analysis.
Definition AnalysisInfo.hh:178
Rivet::AnalysisInfo::collider
const std::string & collider() const
Collider on which the experiment ran.
Definition AnalysisInfo.hh:122
Rivet::AnalysisInfo::setRunInfo
void setRunInfo(const std::string &runInfo)
Set the full description for this analysis.
Definition AnalysisInfo.hh:104
Rivet::AnalysisInfo::bibTeX
const std::string & bibTeX() const
BibTeX citation entry for this article.
Definition AnalysisInfo.hh:173
Rivet::AnalysisInfo::references
const std::vector< std::string > & references() const
Journal and preprint references.
Definition AnalysisInfo.hh:143
Rivet::AnalysisInfo::setExperiment
void setExperiment(const std::string &experiment)
Set the experiment which performed and published this analysis.
Definition AnalysisInfo.hh:119
Rivet::AnalysisInfo::setSummary
void setSummary(const std::string &summary)
Set the short description for this analysis.
Definition AnalysisInfo.hh:85
Rivet::AnalysisInfo::inspireId
const std::string & inspireId() const
Get the Inspire (SPIRES replacement) ID code for this analysis.
Definition AnalysisInfo.hh:57
Rivet::AnalysisInfo::setLuminosityfb
void setLuminosityfb(const double luminosityfb)
Set the integrated data luminosity of the data set.
Definition AnalysisInfo.hh:140
Rivet::AnalysisInfo::summary
const std::string & summary() const
Get a short description of the analysis.
Definition AnalysisInfo.hh:83
Rivet::AnalysisInfo::energies
const std::vector< std::pair< double, double > > & energies() const
Sets of valid beam energies.
Definition AnalysisInfo.hh:112
Rivet::AnalysisInfo::refMatch
const std::string & refMatch() const
Positive filtering regex for ref-data HepData sync.
Definition AnalysisInfo.hh:156
Rivet::AnalysisInfo::setEnergies
void setEnergies(const std::vector< std::pair< double, double > > &energies)
Set the valid beam energies.
Definition AnalysisInfo.hh:114
Rivet::AnalysisInfo::setBeams
void setBeams(const std::vector< PdgIdPair > &beams)
Set beam particle types.
Definition AnalysisInfo.hh:109
Rivet::AnalysisInfo::luminosity
double luminosity() const
The integrated data luminosity of the data set in 1/pb.
Definition AnalysisInfo.hh:137
Rivet::AnalysisInfo::keywords
const std::vector< std::string > & keywords() const
Analysis keywords, for grouping etc.
Definition AnalysisInfo.hh:148
Rivet::AnalysisInfo::runInfo
const std::string & runInfo() const
Information about the events needed as input for this analysis.
Definition AnalysisInfo.hh:102
Rivet::AnalysisInfo::setBibKey
void setBibKey(const std::string &bibKey)
Set the BibTeX citation key for this article.
Definition AnalysisInfo.hh:170
Rivet::AnalysisInfo::authors
const std::vector< std::string > & authors() const
Names & emails of paper/analysis authors.
Definition AnalysisInfo.hh:74
Rivet::AnalysisInfo::name
std::string name() const
Definition AnalysisInfo.hh:34
Rivet::AnalysisInfo::getRefDataName
std::string getRefDataName() const
Get the reference data name of the analysis (if different from plugin name).
Definition AnalysisInfo.hh:49
Rivet::AnalysisInfo::spiresId
const std::string & spiresId() const
Definition AnalysisInfo.hh:64
Rivet::AnalysisInfo::year
const std::string & year() const
When the original experimental analysis was published.
Definition AnalysisInfo.hh:129
Rivet::AnalysisInfo::beams
const std::vector< PdgIdPair > & beams() const
Beam particle types.
Definition AnalysisInfo.hh:107
Rivet::AnalysisInfo::setSpiresId
void setSpiresId(const std::string &spiresId)
Definition AnalysisInfo.hh:68
Rivet::AnalysisInfo::writerDoublePrecision
const std::string & writerDoublePrecision() const
Positive filtering regex for setting double precision in Writer.
Definition AnalysisInfo.hh:164
Rivet::AnalysisInfo::setReferences
void setReferences(const std::vector< std::string > &references)
Set the journal and preprint reference list.
Definition AnalysisInfo.hh:145
Rivet::AnalysisInfo::setAuthors
void setAuthors(const std::vector< std::string > &authors)
Set the author list.
Definition AnalysisInfo.hh:76
Rivet::AnalysisInfo::setDescription
void setDescription(const std::string &description)
Set the full description for this analysis.
Definition AnalysisInfo.hh:95
Rivet::AnalysisInfo::luminosityfb
double luminosityfb() const
The integrated data luminosity of the data set in 1/fb.
Definition AnalysisInfo.hh:135
Rivet::AnalysisInfo::setInspireId
void setInspireId(const std::string &inspireId)
Set the Inspire (SPIRES replacement) ID code for this analysis.
Definition AnalysisInfo.hh:59
Rivet::AnalysisInfo::setName
void setName(const std::string &name)
Set the name of the analysis.
Definition AnalysisInfo.hh:46
Rivet::AnalysisInfo::experiment
const std::string & experiment() const
Experiment which performed and published this analysis.
Definition AnalysisInfo.hh:117
Rivet::AnalysisInfo::options
const std::vector< std::string > & options() const
Get the option list.
Definition AnalysisInfo.hh:189
Rivet::AnalysisInfo::buildOptionMap
void buildOptionMap()
Build a map of options to facilitate checking.
Rivet::AnalysisInfo::validOption
bool validOption(std::string key, std::string val) const
Check if the given option is valid.
Rivet::AnalysisInfo::setOptions
void setOptions(const std::vector< std::string > &opts)
Set the option list.
Definition AnalysisInfo.hh:195
Rivet::AnalysisInfo::statuscheck
bool statuscheck(const string &word) const
Helper function for checking status-string contents.
Definition AnalysisInfo.hh:260
Rivet::AnalysisInfo::preliminary
bool preliminary() const
Return true if preliminary.
Definition AnalysisInfo.hh:225
Rivet::AnalysisInfo::validated
bool validated() const
Return true if validated.
Definition AnalysisInfo.hh:220
Rivet::AnalysisInfo::setStatus
void setStatus(const std::string &status)
Set the analysis code status.
Definition AnalysisInfo.hh:212
Rivet::AnalysisInfo::random
bool random() const
Return true if includes random variations.
Definition AnalysisInfo.hh:240
Rivet::AnalysisInfo::unphysical
bool unphysical() const
Return true if the analysis uses generator-dependent information.
Definition AnalysisInfo.hh:245
Rivet::AnalysisInfo::status
const std::string & status() const
Whether this analysis is trusted (in any way!)
Definition AnalysisInfo.hh:210
Rivet::AnalysisInfo::setReentrant
void setReentrant(bool ree=true)
Set re-entrant status.
Definition AnalysisInfo.hh:217
Rivet::AnalysisInfo::unvalidated
bool unvalidated() const
Return true if unvalidated.
Definition AnalysisInfo.hh:235
Rivet::AnalysisInfo::hepdata
bool hepdata() const
Check if refdata comes automatically from Hepdata.
Definition AnalysisInfo.hh:250
Rivet::AnalysisInfo::obsolete
bool obsolete() const
Return true if obsolete.
Definition AnalysisInfo.hh:230
Rivet::AnalysisInfo::reentrant
bool reentrant() const
Return true if finalize() can be run multiple times for this analysis.
Definition AnalysisInfo.hh:215
Rivet::AnalysisInfo::multiweight
bool multiweight() const
Check if this analysis can handle multiple weights.
Definition AnalysisInfo.hh:255
Rivet
Definition MC_Cent_pPb.hh:10
Rivet::operator<<
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition AnalysisInfo.hh:368
Rivet::toString
std::string toString(const AnalysisInfo &ai)
String representation.