gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
Analysis.cpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
26 
27 #include <vector>
28 #include "HEPUtils/Event.h"
30 
31 namespace Gambit
32 {
33  namespace ColliderBit
34  {
35 
36  Analysis::Analysis() : _luminosity(0)
37  , _luminosity_is_set(false)
38  , _is_scaled(false)
39  , _needs_collection(true)
40  { }
41 
44  {
45  _is_scaled = false;
46  _needs_collection = true;
47  _results.clear();
49  }
50 
52  void Analysis::analyze(const HEPUtils::Event& e) { analyze(&e); }
53 
55  void Analysis::analyze(const HEPUtils::Event* e)
56  {
57  _needs_collection = true;
58  run(e);
59  }
60 
62  double Analysis::luminosity() const { return _luminosity; }
63 
65  void Analysis::set_luminosity(double lumi) { _luminosity_is_set = true; _luminosity = lumi; }
66 
69  {
70  _analysis_name = aname;
72  }
73 
76 
79  {
81  {
83  _needs_collection = false;
84  }
85  return _results;
86  }
87 
90  {
91  warning = "";
92  if (not _luminosity_is_set)
93  warning += "Luminosity has not been set for analysis " + _analysis_name + ".";
94  if (not _is_scaled)
95  warning += "Results have not been scaled for analysis " + _analysis_name + ".";
96 
97  return get_results();
98  }
99 
102  {
103  return &get_results();
104  }
105 
108  {
109  return &get_results(warning);
110  }
111 
114 
116  void Analysis::set_covariance(const Eigen::MatrixXd& srcov) { _results.srcov = srcov; }
117 
119  void Analysis::set_covariance(const std::vector<std::vector<double>>& srcov)
120  {
121  Eigen::MatrixXd cov(srcov.size(), srcov.front().size());
122  for (size_t i = 0; i < srcov.size(); ++i)
123  {
124  for (size_t j = 0; j < srcov.front().size(); ++j)
125  {
126  cov(i,j) = srcov[i][j];
127  }
128  }
129  set_covariance(cov);
130  }
131 
133  void Analysis::scale(double xsec_per_event)
134  {
135  double factor = luminosity() * xsec_per_event;
136  assert(factor >= 0);
137  for (SignalRegionData& sr : _results)
138  {
139  sr.n_sig_scaled = factor * sr.n_sig_MC;
140  }
141  _is_scaled = true;
142  }
143 
145  void Analysis::add(Analysis* other)
146  {
147  if (_results.empty()) collect_results();
148  if (this == other) return;
149  const AnalysisData otherResults = other->get_results();
151  assert(otherResults.size() == _results.size());
152  for (size_t i = 0; i < _results.size(); ++i)
153  {
154  _results[i].n_sig_MC += otherResults[i].n_sig_MC;
155  }
156  combine(other);
157  }
158 
159  }
160 }
void add_result(const SignalRegionData &sr)
Add the given result to the internal results list.
Definition: Analysis.cpp:113
void reset()
Public method to reset this instance for reuse, avoiding the need for "new" or "delete".
Definition: Analysis.cpp:43
Eigen::MatrixXd srcov
Optional covariance matrix between SRs (0x0 null matrix = no correlation info)
void set_luminosity(double)
Set the integrated luminosity.
Definition: Analysis.cpp:65
void scale(double)
Scale by xsec per event.
Definition: Analysis.cpp:133
void add(const SignalRegionData &srd)
Add a SignalRegionData.
void add(Analysis *other)
Add the results of another analysis to this one. Argument is not const, because the other needs to be...
Definition: Analysis.cpp:145
virtual void collect_results()=0
Gather together the info for likelihood calculation.
A container for the result of an analysis, potentially with many signal regions and correlations...
void set_covariance(const Eigen::MatrixXd &srcov)
Set the covariance matrix, expressing SR correlations.
Definition: Analysis.cpp:116
GAMBIT warning class.
Definition: exceptions.hpp:165
virtual void analysis_specific_reset()=0
Reset the analysis-specific variables.
const AnalysisData * get_results_ptr()
Get a pointer to _results.
Definition: Analysis.cpp:101
void set_analysis_name(str)
Set the analysis name.
Definition: Analysis.cpp:68
A class for collider analyses within ColliderBit.
Definition: Analysis.hpp:41
virtual void run(const HEPUtils::Event *)=0
void analyze(const HEPUtils::Event &)
Analyze the event (accessed by reference).
Definition: Analysis.cpp:52
std::string analysis_name
Analysis name.
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
A simple container for the result of one signal region from one analysis.
void clear()
Clear the list of SignalRegionData, and nullify the covariance matrix.
virtual void combine(const Analysis *other)=0
Add the analysis-specific variables of another analysis to this one.
Analysis()
Construction.
Definition: Analysis.cpp:36
str analysis_name()
Get the analysis name.
Definition: Analysis.cpp:75
double luminosity() const
Return the integrated luminosity.
Definition: Analysis.cpp:62
bool empty() const
Is this container empty of signal regions?
TODO: see if we can use this one:
Definition: Analysis.hpp:33
Class for ColliderBit analyses.
const AnalysisData & get_results()
Get the collection of SignalRegionData for likelihood computation.
Definition: Analysis.cpp:78
size_t size() const
Number of analyses.