rivet is hosted by Hepforge, IPPP Durham
Rivet 4.0.0
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
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; }
58
60 void setInspireID(const std::string& inspireID) { _inspireID = inspireID; }
61
63 const std::string& spiresID() const { return _spiresID; }
64
66 void setSpiresID(const std::string& spiresID) { _spiresID = spiresID; }
67
72 const std::vector<std::string>& authors() const { return _authors; }
74 void setAuthors(const std::vector<std::string>& authors) { _authors = authors; }
75
81 const std::string& summary() const { return _summary; }
83 void setSummary(const std::string& summary) { _summary = summary; }
84
91 const std::string& description() const { return _description; }
93 void setDescription(const std::string& description) { _description = description; }
94
100 const std::string& runInfo() const { return _runInfo; }
102 void setRunInfo(const std::string& runInfo) { _runInfo = runInfo; }
103
105 const std::vector<PdgIdPair>& beamIDs() const { return _beams; }
106
108 void setBeamIDs(const std::vector<PdgIdPair>& beamids) { _beams = beamids; }
109
111 const std::vector<std::pair<double,double> >& energies() const { return _energies; }
113 void setEnergies(const std::vector<std::pair<double, double> >& energies) { _energies = energies; }
114
116 const std::string& experiment() const { return _experiment; }
118 void setExperiment(const std::string& experiment) { _experiment = experiment; }
119
121 const std::string& collider() const { return _collider; }
123 void setCollider(const std::string& collider) { _collider = collider; }
124
128 const std::string& year() const { return _year; }
129
131 void setYear(const std::string& year) { _year = year; }
132
134 double luminosityfb() const { return _luminosityfb; }
136 double luminosity() const { return 1000*_luminosityfb; }
137
139 void setLuminosityfb(const double luminosityfb) { _luminosityfb = luminosityfb; }
140
142 const std::vector<std::string>& references() const { return _references; }
144 void setReferences(const std::vector<std::string>& references) { _references = references; }
145
147 const std::vector<std::string>& keywords() const { return _keywords; }
148 void setKeywords(const std::vector<std::string>& keywords) { _keywords = keywords; }
149
151 const std::string& warning() const { return _warning; }
152 void setWarning(const std::string warning) { _warning = warning; }
153
155 const std::string& refMatch() const { return _refmatch; }
156 void setRefMatch(const std::string refmatch) { _refmatch = refmatch; }
157
159 const std::string& refUnmatch() const { return _refunmatch; }
160 void setRefUnmatch(const std::string refunmatch) { _refunmatch = refunmatch; }
161
163 const std::string& writerDoublePrecision() const { return _writerdoubleprecision; }
164 void setWriterDoublePrecision(const std::string dp) { _writerdoubleprecision = dp; }
165
167 const std::string& bibKey() const { return _bibKey; }
169 void setBibKey(const std::string& bibKey) { _bibKey = bibKey; }
170
172 const std::string& bibTeX() const { return _bibTeX; }
174 void setBibTeX(const std::string& bibTeX) { _bibTeX = bibTeX; }
175
177 const std::vector<std::string>& todos() const { return _todos; }
179 void setTodos(const std::vector<std::string>& todos) { _todos = todos; }
180
182
183
186
188 const std::vector<std::string>& options() const { return _options; }
189
191 bool validOption(std::string key, std::string val) const;
192
194 void setOptions(const std::vector<std::string>& opts) {
195 _options = opts;
197 }
198
201
203
204
207
209 const std::string& status() const { return _status; }
211 void setStatus(const std::string& status) { _status = status; }
212
214 bool reentrant() const { return _reentrant; }
216 void setReentrant(bool ree=true) { _reentrant = ree; }
217
219 bool validated() const {
220 return statuscheck("VALIDATED");
221 }
222
224 bool preliminary() const {
225 return statuscheck("PRELIMINARY");
226 }
227
229 bool obsolete() const {
230 return statuscheck("OBSOLETE");
231 }
232
234 bool unvalidated() const {
235 return statuscheck("UNVALIDATED");
236 }
237
239 bool random() const {
240 return statuscheck("RANDOM");
241 }
242
244 bool unphysical() const {
245 return statuscheck("UNPHYSICAL");
246 }
247
249 bool hepdata() const {
250 return !statuscheck("NOHEPDATA");
251 }
252
254 bool multiweight() const {
255 return !statuscheck("SINGLEWEIGHT");
256 }
257
259 bool statuscheck(const string& word) const {
260 auto pos =_status.find(word);
261 if ( pos == string::npos ) return false;
262 if ( pos > 0 && isalnum(_status[pos - 1]) ) return false;
263 if ( pos + word.length() < _status.length() &&
264 isalnum(_status[pos + word.length()]) ) return false;
265 return true;
266 }
267
269
270
272 std::string refFile() const;
273
275 const std::vector<std::string> & validation() const {
276 return _validation;
277 }
278
279
280 private:
281
282 // std::map<string,string> _yamldict;
283
284 static std::string _infoFilePath;
285
286 std::string _name;
287 std::string _refDataName;
288 std::string _spiresID, _inspireID;
289 std::vector<std::string> _authors;
290 std::string _summary;
291 std::string _description;
292 std::string _runInfo;
293 std::string _experiment;
294 std::string _collider;
295 std::vector<std::pair<PdgId, PdgId> > _beams;
296 std::vector<std::pair<double, double> > _energies;
297 std::string _year;
298 double _luminosityfb;
299 std::vector<std::string> _references;
300 std::vector<std::string> _keywords;
301 std::string _bibKey;
302 std::string _bibTeX;
303 //std::string _bibTeXBody; ///< Was thinking of avoiding duplication of BibKey...
304 std::string _status;
305 std::string _warning;
306 std::string _refmatch;
307 std::string _refunmatch;
308 std::string _writerdoubleprecision;
309 std::vector<std::string> _todos;
310 bool _needsCrossSection;
311 bool _isInitialised;
312
313 std::vector<std::string> _options;
314 std::map< std::string, std::set<std::string> > _optionmap;
315
316 std::vector<std::string> _validation;
317
318 bool _reentrant;
319
320 void clear() {
321 //_yamldict.clear();
322 _name = "";
323 _refDataName = "";
324 _spiresID = "";
325 _inspireID = "";
326 _authors.clear();
327 _summary = "";
328 _description = "";
329 _runInfo = "";
330 _experiment = "";
331 _collider = "";
332 _beams.clear();
333 _energies.clear();
334 _year = "";
335 _luminosityfb = -1;
336 _references.clear();
337 _keywords.clear();
338 _bibKey = "";
339 _bibTeX = "";
340 //_bibTeXBody = "";
341 _status = "";
342 _warning = "";
343 _refmatch = "";
344 _refunmatch = "";
345 _writerdoubleprecision = "";
346 _todos.clear();
347 _needsCrossSection = false;
348 _options.clear();
349 _optionmap.clear();
350 _validation.clear();
351 _reentrant = false;
352 _isInitialised = false;
353 }
354
355 };
356
357
359 std::string toString(const AnalysisInfo& ai);
360
362 inline std::ostream& operator<<(std::ostream& os, const AnalysisInfo& ai) {
363 os << toString(ai);
364 return os;
365 }
366
367
368}
369
370#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:275
AnalysisInfo()
Default constructor.
Definition AnalysisInfo.hh:19
void setCollider(const std::string &collider)
Set the collider on which the experiment ran.
Definition AnalysisInfo.hh:123
void setTodos(const std::vector< std::string > &todos)
Set the to-do list.
Definition AnalysisInfo.hh:179
const std::string & refUnmatch() const
Negative filtering regex for ref-data HepData sync.
Definition AnalysisInfo.hh:159
void setBeamIDs(const std::vector< PdgIdPair > &beamids)
Set beam particle types.
Definition AnalysisInfo.hh:108
void setYear(const std::string &year)
Set the year in which the original experimental analysis was published.
Definition AnalysisInfo.hh:131
const std::string & description() const
Get a full description of the analysis.
Definition AnalysisInfo.hh:91
const std::string & warning() const
Any warning message.
Definition AnalysisInfo.hh:151
const std::string & bibKey() const
BibTeX citation key for this article.
Definition AnalysisInfo.hh:167
void setRefDataName(const std::string &name)
Set the reference data name of the analysis (if different from plugin name).
Definition AnalysisInfo.hh:54
void setBibTeX(const std::string &bibTeX)
Set the BibTeX citation entry for this article.
Definition AnalysisInfo.hh:174
const std::vector< std::string > & todos() const
Any work to be done on this analysis.
Definition AnalysisInfo.hh:177
const std::string & collider() const
Collider on which the experiment ran.
Definition AnalysisInfo.hh:121
void setRunInfo(const std::string &runInfo)
Set the full description for this analysis.
Definition AnalysisInfo.hh:102
const std::string & inspireID() const
Get the Inspire (SPIRES replacement) ID code for this analysis.
Definition AnalysisInfo.hh:57
const std::string & bibTeX() const
BibTeX citation entry for this article.
Definition AnalysisInfo.hh:172
const std::vector< PdgIdPair > & beamIDs() const
Beam particle types.
Definition AnalysisInfo.hh:105
const std::vector< std::string > & references() const
Journal and preprint references.
Definition AnalysisInfo.hh:142
void setExperiment(const std::string &experiment)
Set the experiment which performed and published this analysis.
Definition AnalysisInfo.hh:118
void setInspireID(const std::string &inspireID)
Set the Inspire (SPIRES replacement) ID code for this analysis.
Definition AnalysisInfo.hh:60
void setSummary(const std::string &summary)
Set the short description for this analysis.
Definition AnalysisInfo.hh:83
void setLuminosityfb(const double luminosityfb)
Set the integrated data luminosity of the data set.
Definition AnalysisInfo.hh:139
const std::string & summary() const
Get a short description of the analysis.
Definition AnalysisInfo.hh:81
const std::vector< std::pair< double, double > > & energies() const
Sets of valid beam energies.
Definition AnalysisInfo.hh:111
const std::string & refMatch() const
Positive filtering regex for ref-data HepData sync.
Definition AnalysisInfo.hh:155
void setEnergies(const std::vector< std::pair< double, double > > &energies)
Set the valid beam energies.
Definition AnalysisInfo.hh:113
const std::string & spiresID() const
Get the SPIRES ID code for this analysis.
Definition AnalysisInfo.hh:63
double luminosity() const
The integrated data luminosity of the data set in 1/pb.
Definition AnalysisInfo.hh:136
const std::vector< std::string > & keywords() const
Analysis keywords, for grouping etc.
Definition AnalysisInfo.hh:147
const std::string & runInfo() const
Information about the events needed as input for this analysis.
Definition AnalysisInfo.hh:100
void setBibKey(const std::string &bibKey)
Set the BibTeX citation key for this article.
Definition AnalysisInfo.hh:169
const std::vector< std::string > & authors() const
Names & emails of paper/analysis authors.
Definition AnalysisInfo.hh:72
std::string name() const
Definition AnalysisInfo.hh:34
std::string getRefDataName() const
Get the reference data name of the analysis (if different from plugin name).
Definition AnalysisInfo.hh:49
const std::string & year() const
When the original experimental analysis was published.
Definition AnalysisInfo.hh:128
const std::string & writerDoublePrecision() const
Positive filtering regex for setting double precision in Writer.
Definition AnalysisInfo.hh:163
void setReferences(const std::vector< std::string > &references)
Set the journal and preprint reference list.
Definition AnalysisInfo.hh:144
void setAuthors(const std::vector< std::string > &authors)
Set the author list.
Definition AnalysisInfo.hh:74
void setDescription(const std::string &description)
Set the full description for this analysis.
Definition AnalysisInfo.hh:93
double luminosityfb() const
The integrated data luminosity of the data set in 1/fb.
Definition AnalysisInfo.hh:134
void setName(const std::string &name)
Set the name of the analysis.
Definition AnalysisInfo.hh:46
const std::string & experiment() const
Experiment which performed and published this analysis.
Definition AnalysisInfo.hh:116
void setSpiresID(const std::string &spiresID)
Set the SPIRES ID code for this analysis.
Definition AnalysisInfo.hh:66
const std::vector< std::string > & options() const
Get the option list.
Definition AnalysisInfo.hh:188
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:194
bool statuscheck(const string &word) const
Helper function for checking status-string contents.
Definition AnalysisInfo.hh:259
bool preliminary() const
Return true if preliminary.
Definition AnalysisInfo.hh:224
bool validated() const
Return true if validated.
Definition AnalysisInfo.hh:219
void setStatus(const std::string &status)
Set the analysis code status.
Definition AnalysisInfo.hh:211
bool random() const
Return true if includes random variations.
Definition AnalysisInfo.hh:239
bool unphysical() const
Return true if the analysis uses generator-dependent information.
Definition AnalysisInfo.hh:244
const std::string & status() const
Whether this analysis is trusted (in any way!)
Definition AnalysisInfo.hh:209
void setReentrant(bool ree=true)
Set re-entrant status.
Definition AnalysisInfo.hh:216
bool unvalidated() const
Return true if unvalidated.
Definition AnalysisInfo.hh:234
bool hepdata() const
Check if refdata comes automatically from Hepdata.
Definition AnalysisInfo.hh:249
bool obsolete() const
Return true if obsolete.
Definition AnalysisInfo.hh:229
bool reentrant() const
Return true if finalize() can be run multiple times for this analysis.
Definition AnalysisInfo.hh:214
bool multiweight() const
Check if this analysis can handle multiple weights.
Definition AnalysisInfo.hh:254
Definition MC_CENT_PPB_Projections.hh:10
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition AnalysisInfo.hh:362
std::string toString(const AnalysisInfo &ai)
String representation.