gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
Gambit::ColliderBit::AnalysisData Struct Reference

A container for the result of an analysis, potentially with many signal regions and correlations. More...

#include <AnalysisData.hpp>

Collaboration diagram for Gambit::ColliderBit::AnalysisData:

Public Member Functions

 AnalysisData ()
 Default constructor. More...
 
 AnalysisData (const std::string &name)
 Constructor with analysis name. More...
 
 AnalysisData (const std::vector< SignalRegionData > &srds, const Eigen::MatrixXd &cov=Eigen::MatrixXd())
 Constructor from a list of SignalRegionData and an optional correlation (or covariance?) matrix. More...
 
void clear ()
 Clear the list of SignalRegionData, and nullify the covariance matrix. More...
 
size_t size () const
 Number of analyses. More...
 
bool empty () const
 Is this container empty of signal regions? More...
 
bool hasCorrs () const
 Is there non-null correlation data? More...
 
void add (const SignalRegionData &srd)
 Add a SignalRegionData. More...
 
bool check () const
 Check that the SRData list and the covariance matrix are consistent. More...
 
void pythonize_me () const
 bjf> Experimental! But already useful for helping me convert the key numbers from these analyses to Python for the p-value calculuations. More...
 
SignalRegionDataoperator[] (size_t i)
 Access the i'th signal region's data. More...
 
const SignalRegionDataoperator[] (size_t i) const
 Access the i'th signal region's data (const) More...
 
std::vector< SignalRegionData >::iterator begin ()
 Iterators (sugar for direct access to this->srdata) More...
 
std::vector< SignalRegionData >::const_iterator begin () const
 
std::vector< SignalRegionData >::iterator end ()
 
std::vector< SignalRegionData >::const_iterator end () const
 

Public Attributes

std::string analysis_name
 Analysis name. More...
 
std::vector< SignalRegionDatasrdata
 List of signal regions' data summaries. More...
 
std::map< std::string, intsrdata_identifiers
 Map of names and indices of all entries in srdata, for easy lookup. More...
 
Eigen::MatrixXd srcov
 Optional covariance matrix between SRs (0x0 null matrix = no correlation info) More...
 

Detailed Description

A container for the result of an analysis, potentially with many signal regions and correlations.

Definition at line 148 of file AnalysisData.hpp.

Constructor & Destructor Documentation

◆ AnalysisData() [1/3]

Gambit::ColliderBit::AnalysisData::AnalysisData ( )
inline

Default constructor.

Definition at line 152 of file AnalysisData.hpp.

153  {
154  #ifdef ANALYSISDATA_DEBUG
155  std::cerr << "DEBUG: AnalysisData: " << this << " - Constructed (default ctor)" << std::endl;
156  #endif
157  clear();
158  }
void clear()
Clear the list of SignalRegionData, and nullify the covariance matrix.

◆ AnalysisData() [2/3]

Gambit::ColliderBit::AnalysisData::AnalysisData ( const std::string &  name)
inline

Constructor with analysis name.

Definition at line 161 of file AnalysisData.hpp.

References analysis_name, srcov, srdata, and srdata_identifiers.

161  :
162  analysis_name(name)
163  {
164  #ifdef ANALYSISDATA_DEBUG
165  std::cerr << "DEBUG: AnalysisData: " << this << " - Constructed (ctor with analysis name)" << std::endl;
166  #endif
167  clear();
168  }
std::string analysis_name
Analysis name.
void clear()
Clear the list of SignalRegionData, and nullify the covariance matrix.

◆ AnalysisData() [3/3]

Gambit::ColliderBit::AnalysisData::AnalysisData ( const std::vector< SignalRegionData > &  srds,
const Eigen::MatrixXd &  cov = Eigen::MatrixXd() 
)
inline

Constructor from a list of SignalRegionData and an optional correlation (or covariance?) matrix.

If corrs is a null matrix (the default), this AnalysisData is to be interpreted as having no correlation information, and hence the likelihood calculation should use the single best-expected-limit SR.

Definition at line 194 of file AnalysisData.hpp.

References Gambit::ColliderBit::SignalRegionData::check().

195  : srdata(srds), srcov(cov)
196  {
197  #ifdef ANALYSISDATA_DEBUG
198  std::cerr << "DEBUG: AnalysisData: " << this << " - Constructed (special ctor)" << std::endl;
199  #endif
200  check();
201  }
Eigen::MatrixXd srcov
Optional covariance matrix between SRs (0x0 null matrix = no correlation info)
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.
bool check() const
Check that the SRData list and the covariance matrix are consistent.
Here is the call graph for this function:

Member Function Documentation

◆ add()

void Gambit::ColliderBit::AnalysisData::add ( const SignalRegionData srd)
inline

Add a SignalRegionData.

Definition at line 238 of file AnalysisData.hpp.

References Gambit::ColliderBit::SignalRegionData::check(), Gambit::ColliderBit::SignalRegionData::n_sig_MC, and Gambit::ColliderBit::SignalRegionData::sr_label.

Referenced by Gambit::ColliderBit::Analysis::add_result().

239  {
240  std::string key = analysis_name + srd.sr_label;
241  auto loc = srdata_identifiers.find(key);
242  if (loc == srdata_identifiers.end())
243  {
244  // If the signal region doesn't exist in this object yet, add it
245  srdata.push_back(srd);
246  srdata_identifiers[key] = srdata.size() - 1;
247  }
248  else
249  {
250  // If it does, just update the signal count in the existing SignalRegionData object
251  srdata[loc->second].n_sig_MC = srd.n_sig_MC;
252  }
253  check();
254  }
std::map< std::string, int > srdata_identifiers
Map of names and indices of all entries in srdata, for easy lookup.
std::string analysis_name
Analysis name.
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.
bool check() const
Check that the SRData list and the covariance matrix are consistent.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin() [1/2]

std::vector<SignalRegionData>::iterator Gambit::ColliderBit::AnalysisData::begin ( )
inline

Iterators (sugar for direct access to this->srdata)

Definition at line 284 of file AnalysisData.hpp.

284 { return srdata.begin(); }
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.

◆ begin() [2/2]

std::vector<SignalRegionData>::const_iterator Gambit::ColliderBit::AnalysisData::begin ( ) const
inline

Definition at line 285 of file AnalysisData.hpp.

285 { return srdata.begin(); }
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.

◆ check()

bool Gambit::ColliderBit::AnalysisData::check ( ) const
inline

Check that the SRData list and the covariance matrix are consistent.

Definition at line 257 of file AnalysisData.hpp.

References int.

258  {
259  for (const SignalRegionData& srd : srdata) srd.check();
260  assert(srcov.rows() == 0 || srcov.rows() == (int) srdata.size());
261  // for (int isr = 0; isr < srcov.rows(); ++isr) {
262  // const double& srbg = srdata[isr].n_bkg_err;
263  // #ifdef ANALYSISDATA_DEBUG
264  // std::cerr << "DEBUG: AnalysisData: isr:" << isr << ", srbg:" << srbg << ", srcov(isr,isr):" << srcov(isr,isr) << std::endl;
265  // #endif
266  // assert(fabs(srcov(isr,isr) - srbg*srbg) < 1e-2);
267  // }
268  return true;
269  }
Eigen::MatrixXd srcov
Optional covariance matrix between SRs (0x0 null matrix = no correlation info)
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.
DS5_MSPCTM DS_INTDOF int

◆ clear()

void Gambit::ColliderBit::AnalysisData::clear ( )
inline

Clear the list of SignalRegionData, and nullify the covariance matrix.

Definition at line 205 of file AnalysisData.hpp.

Referenced by Gambit::ColliderBit::Analysis::reset().

206  {
207  for (auto& sr : srdata)
208  {
209  sr.n_sig_MC = 0;
210  sr.n_sig_scaled = 0;
211  sr.n_sig_MC_sys = 0;
212  }
213  srcov = Eigen::MatrixXd();
214  #ifdef ANALYSISDATA_DEBUG
215  std::cerr << "DEBUG: AnalysisData: " << this << " - Cleared" << std::endl;
216  #endif
217  }
Eigen::MatrixXd srcov
Optional covariance matrix between SRs (0x0 null matrix = no correlation info)
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.
Here is the caller graph for this function:

◆ empty()

bool Gambit::ColliderBit::AnalysisData::empty ( ) const
inline

Is this container empty of signal regions?

Definition at line 227 of file AnalysisData.hpp.

Referenced by Gambit::ColliderBit::Analysis::add().

227 { return size() == 0; }
size_t size() const
Number of analyses.
Here is the caller graph for this function:

◆ end() [1/2]

std::vector<SignalRegionData>::iterator Gambit::ColliderBit::AnalysisData::end ( )
inline

Definition at line 286 of file AnalysisData.hpp.

286 { return srdata.end(); }
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.

◆ end() [2/2]

std::vector<SignalRegionData>::const_iterator Gambit::ColliderBit::AnalysisData::end ( ) const
inline

Definition at line 287 of file AnalysisData.hpp.

287 { return srdata.end(); }
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.

◆ hasCorrs()

bool Gambit::ColliderBit::AnalysisData::hasCorrs ( ) const
inline

Is there non-null correlation data?

Definition at line 230 of file AnalysisData.hpp.

231  {
232  // check(); // bjf> This was wrong! Needs to be !=, not ==
233  return srcov.rows() != 0;
234  }
Eigen::MatrixXd srcov
Optional covariance matrix between SRs (0x0 null matrix = no correlation info)

◆ operator[]() [1/2]

SignalRegionData& Gambit::ColliderBit::AnalysisData::operator[] ( size_t  i)
inline

Access the i'th signal region's data.

Definition at line 279 of file AnalysisData.hpp.

279 { return srdata[i]; }
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.

◆ operator[]() [2/2]

const SignalRegionData& Gambit::ColliderBit::AnalysisData::operator[] ( size_t  i) const
inline

Access the i'th signal region's data (const)

Definition at line 281 of file AnalysisData.hpp.

281 { return srdata[i]; }
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.

◆ pythonize_me()

void Gambit::ColliderBit::AnalysisData::pythonize_me ( ) const

bjf> Experimental! But already useful for helping me convert the key numbers from these analyses to Python for the p-value calculuations.

This is a dumb place to define this, but there is no cpp file for AnalysisData and I can't be bothered making one.

Could record or something, but for now just dump to stdout

Definition at line 12 of file Analysis_Covariance.cpp.

References colouring::combine(), Gambit::ColliderBit::DEFINE_ANALYSIS_FACTORY(), and run().

13  {
14  static std::set<std::string> done; // Only want this printed out once for each analysis
15  if(done.find(analysis_name)==done.end())
16  {
17  done.insert(analysis_name);
18  std::ostringstream SR_names;
19  std::ostringstream SR_n;
20  std::ostringstream SR_b;
21  std::ostringstream SR_b_sys;
22  std::ostringstream SR_s_sys;
23  std::ostringstream SR_s;
24  SR_names << "a.SR_names = [";
25  SR_n << "a.SR_n = [";
26  SR_b << "a.SR_b = [";
27  SR_b_sys << "a.SR_b_sys = [";
28  //SR_s_sys << "a.SR_s_sys = [";
29  //SR_s << "a.SR_s = [";
30  int i = 0;
31  for (auto srd = begin(); srd != end(); ++srd,++i)
32  {
33  SR_names << "\"" << srd->sr_label << "__i"<<i << "\", ";
34  SR_n << srd->n_obs << ", ";
35  SR_b << srd->n_bkg << ", ";
36  SR_b_sys << srd->n_bkg_err << ", ";
37  //SR_s_sys << srd->n_sig_MC_sys << ", ";
38  //SR_s << srd->n_sig_MC << ", ";
39  }
40  SR_names << "]";
41  SR_n << "]";
42  SR_b << "]";
43  SR_b_sys << "]";
44  //SR_s_sys << "]";
45  //SR_s << "]";
46  std::ostringstream full;
47  full << "a = Analysis(\""<<analysis_name<<"\")"<<std::endl;
48  full << SR_names.str() << std::endl;
49  full << SR_n.str() << std::endl;
50  full << SR_b.str() << std::endl;
51  full << SR_b_sys.str() << std::endl;
52  //full << SR_s_sys.str() << std::endl;
53  //full << SR_s.str() << std::endl;
54  if(hasCorrs())
55  {
56  full << "a.cov = ";
57  Eigen::IOFormat PythonFmt(Eigen::FullPrecision, 0, ", ", ",\n", "[", "]", "[", "]");
58  full << srcov.format(PythonFmt) << std::endl;
59  }
60  full << "a.N_SR = len(a.SR_names)" << std::endl;
61  if(hasCorrs())
62  {
63  full << "if allow_corr: ";
64  }
65  full << "analyses += [a]" << std::endl << std::endl;
67  std::cout << full.str();
68  }
69  }
Eigen::MatrixXd srcov
Optional covariance matrix between SRs (0x0 null matrix = no correlation info)
std::vector< SignalRegionData >::iterator begin()
Iterators (sugar for direct access to this->srdata)
std::string analysis_name
Analysis name.
std::vector< SignalRegionData >::iterator end()
bool hasCorrs() const
Is there non-null correlation data?
Here is the call graph for this function:

◆ size()

size_t Gambit::ColliderBit::AnalysisData::size ( ) const
inline

Number of analyses.

Definition at line 220 of file AnalysisData.hpp.

Referenced by Gambit::ColliderBit::Analysis::add(), Gambit::ColliderBit::calc_LHC_LogLikes(), Gambit::ColliderBit::calc_LHC_signals(), and main().

221  {
222  // check();
223  return srdata.size();
224  }
std::vector< SignalRegionData > srdata
List of signal regions&#39; data summaries.
Here is the caller graph for this function:

Member Data Documentation

◆ analysis_name

std::string Gambit::ColliderBit::AnalysisData::analysis_name

◆ srcov

Eigen::MatrixXd Gambit::ColliderBit::AnalysisData::srcov

Optional covariance matrix between SRs (0x0 null matrix = no correlation info)

Definition at line 296 of file AnalysisData.hpp.

Referenced by AnalysisData(), Gambit::ColliderBit::calc_LHC_LogLikes(), and Gambit::ColliderBit::Analysis::set_covariance().

◆ srdata

std::vector<SignalRegionData> Gambit::ColliderBit::AnalysisData::srdata

List of signal regions' data summaries.

Definition at line 290 of file AnalysisData.hpp.

Referenced by AnalysisData().

◆ srdata_identifiers

std::map<std::string, int> Gambit::ColliderBit::AnalysisData::srdata_identifiers

Map of names and indices of all entries in srdata, for easy lookup.

Definition at line 293 of file AnalysisData.hpp.

Referenced by AnalysisData().


The documentation for this struct was generated from the following files: