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

A class for holding a total cross-section calculated via MC across multiple threads. More...

#include <xsec.hpp>

Inheritance diagram for Gambit::ColliderBit::MC_xsec_container:
Collaboration diagram for Gambit::ColliderBit::MC_xsec_container:

Public Member Functions

 MC_xsec_container ()
 Definitions of MC_xsec_container members. More...
 
virtual ~MC_xsec_container ()
 
void reset ()
 Reset this instance for reuse. More...
 
void log_event ()
 Tell the xsec object that there has been a new event. More...
 
long long num_events () const
 Return the total number of events seen so far. More...
 
double xsec_per_event () const
 Return the cross-section per event seen (in fb). More...
 
void set_num_events (long long)
 Set the total number of events seen so far. More...
 
void average_xsec (double, double, long long)
 Average cross-sections and combine errors. More...
 
void average_xsec (const MC_xsec_container &)
 
void sum_xsecs (double, double, long long)
 Sum cross-sections and add errors in quadrature. More...
 
void sum_xsecs (const MC_xsec_container &)
 
void gather_xsecs ()
 Collect xsec predictions from other threads and do a weighted combination. More...
 
void gather_num_events ()
 Collect total events seen on all threads. More...
 
std::map< std::string, doubleget_content_as_map () const
 Get content as map <string,double> map (for easy printing). More...
 
- Public Member Functions inherited from Gambit::ColliderBit::xsec_container
 xsec_container ()
 Definitions of xsec members. More...
 
virtual ~xsec_container ()
 
void reset ()
 Reset this instance for reuse. More...
 
double operator() () const
 Return the full cross-section (in fb). More...
 
double xsec () const
 
double xsec_err () const
 Return the cross-section error (in fb). More...
 
double xsec_relerr () const
 Return the cross-section relative error. More...
 
void set_xsec (double, double)
 Set the cross-section and its error (in fb). More...
 
void average_xsec (double, double)
 Average cross-sections and combine errors. More...
 
void average_xsec (const xsec_container &)
 
void sum_xsecs (double, double)
 Sum cross-sections and add errors in quadrature. More...
 
void sum_xsecs (const xsec_container &)
 
std::map< std::string, doubleget_content_as_map () const
 Get content as map <string,double> map (for easy printing). More...
 
void set_info_string (std::string)
 Set the info string. More...
 
std::string info_string () const
 Get the info string. More...
 
void set_trust_level (int)
 Set the trust level. More...
 
int trust_level () const
 Get the trust level. More...
 

Private Attributes

long long _ntot
 

Static Private Attributes

static std::map< int, const MC_xsec_container * > instances_map
 A map with pointers to all instances of this class. The key is the OMP thread number. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Gambit::ColliderBit::xsec_container
static const std::string unit = "fb"
 String Let's make it clear that we work with fb as unit. More...
 
- Protected Attributes inherited from Gambit::ColliderBit::xsec_container
double _xsec
 
double _xsecerr
 
std::string _info_string
 
int _trust_level
 

Detailed Description

A class for holding a total cross-section calculated via MC across multiple threads.

Definition at line 96 of file xsec.hpp.

Constructor & Destructor Documentation

◆ MC_xsec_container()

Gambit::ColliderBit::MC_xsec_container::MC_xsec_container ( )

Definitions of MC_xsec_container members.

Constructor

Definition at line 160 of file xsec.cpp.

160  :
162  _ntot(0)
163  { }
xsec_container()
Definitions of xsec members.
Definition: xsec.cpp:39

◆ ~MC_xsec_container()

virtual Gambit::ColliderBit::MC_xsec_container::~MC_xsec_container ( )
inlinevirtual

Member Function Documentation

◆ average_xsec() [1/2]

void Gambit::ColliderBit::MC_xsec_container::average_xsec ( double  other_xsec,
double  other_xsecerr,
long long  other_ntot 
)

Average cross-sections and combine errors.

Definition at line 195 of file xsec.cpp.

References _ntot, Gambit::ColliderBit::xsec_container::_xsec, Gambit::ColliderBit::xsec_container::average_xsec(), and set_num_events().

Referenced by average_xsec(), and gather_xsecs().

196  {
197  // Run base class function
198  xsec_container::average_xsec(other_xsec, other_xsecerr);
199 
200  // Update _ntot
201  if (other_xsec > 0)
202  {
203  if (_xsec <= 0) set_num_events(other_ntot);
204  else _ntot += other_ntot;
205  }
206  }
void set_num_events(long long)
Set the total number of events seen so far.
Definition: xsec.cpp:192
void average_xsec(double, double)
Average cross-sections and combine errors.
Definition: xsec.cpp:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ average_xsec() [2/2]

void Gambit::ColliderBit::MC_xsec_container::average_xsec ( const MC_xsec_container other)

Definition at line 208 of file xsec.cpp.

References average_xsec(), num_events(), and Gambit::ColliderBit::xsec_container::xsec_err().

209  {
210  MC_xsec_container::average_xsec(other(), other.xsec_err(), other.num_events());
211  }
void average_xsec(double, double, long long)
Average cross-sections and combine errors.
Definition: xsec.cpp:195
Here is the call graph for this function:

◆ gather_num_events()

void Gambit::ColliderBit::MC_xsec_container::gather_num_events ( )

Collect total events seen on all threads.

Definition at line 246 of file xsec.cpp.

References _ntot, instances_map, and num_events().

247  {
248  int this_thread = omp_get_thread_num();
249  for (auto& thread_xsec_pair : instances_map)
250  {
251  if (thread_xsec_pair.first == this_thread) continue;
252  const MC_xsec_container& other = (*thread_xsec_pair.second);
253  _ntot += other.num_events();
254  }
255  }
MC_xsec_container()
Definitions of MC_xsec_container members.
Definition: xsec.cpp:160
static std::map< int, const MC_xsec_container * > instances_map
A map with pointers to all instances of this class. The key is the OMP thread number.
Definition: xsec.hpp:142
Here is the call graph for this function:

◆ gather_xsecs()

void Gambit::ColliderBit::MC_xsec_container::gather_xsecs ( )

Collect xsec predictions from other threads and do a weighted combination.

Definition at line 234 of file xsec.cpp.

References average_xsec(), instances_map, num_events(), and Gambit::ColliderBit::xsec_container::xsec_err().

Referenced by Gambit::ColliderBit::getEvGenCrossSection().

235  {
236  int this_thread = omp_get_thread_num();
237  for (auto& thread_xsec_pair : instances_map)
238  {
239  if (thread_xsec_pair.first == this_thread) continue;
240  const MC_xsec_container& other = (*thread_xsec_pair.second);
241  average_xsec(other(), other.xsec_err(), other.num_events());
242  }
243  }
void average_xsec(double, double, long long)
Average cross-sections and combine errors.
Definition: xsec.cpp:195
MC_xsec_container()
Definitions of MC_xsec_container members.
Definition: xsec.cpp:160
static std::map< int, const MC_xsec_container * > instances_map
A map with pointers to all instances of this class. The key is the OMP thread number.
Definition: xsec.hpp:142
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_content_as_map()

std::map< std::string, double > Gambit::ColliderBit::MC_xsec_container::get_content_as_map ( ) const

Get content as map <string,double> map (for easy printing).

Get content as a <string,double> map (for easy printing).

Definition at line 258 of file xsec.cpp.

References Gambit::ColliderBit::xsec_container::_info_string, _ntot, Gambit::ColliderBit::xsec_container::get_content_as_map(), instances_map, Gambit::ColliderBit::xsec_container::unit, and xsec_per_event().

259  {
260  // Get content from base class
261  std::map<std::string, double> content_map = xsec_container::get_content_as_map();
262 
263  // Add content specific to this class
264  std::string key;
265  std::string base_key;
266  if (_info_string != "") base_key = _info_string + "__";
267  else base_key = "";
268 
269  key = base_key + "xsec_per_event_" + unit;
270  content_map[key] = this->xsec_per_event();
271 
272  key = base_key + "logged_events_" + unit;
273  content_map[key] = _ntot;
274 
275  return content_map;
276  }
std::map< std::string, double > get_content_as_map() const
Get content as map <string,double> map (for easy printing).
Definition: xsec.cpp:115
static const std::string unit
String Let&#39;s make it clear that we work with fb as unit.
Definition: xsec.hpp:84
double xsec_per_event() const
Return the cross-section per event seen (in fb).
Definition: xsec.cpp:189
Here is the call graph for this function:

◆ log_event()

void Gambit::ColliderBit::MC_xsec_container::log_event ( )

Tell the xsec object that there has been a new event.

Increment the number of events seen so far.

Definition at line 183 of file xsec.cpp.

References _ntot.

Referenced by Gambit::ColliderBit::getEvGenCrossSection().

183 { _ntot += 1; }
Here is the caller graph for this function:

◆ num_events()

long long Gambit::ColliderBit::MC_xsec_container::num_events ( ) const

Return the total number of events seen so far.

Definition at line 186 of file xsec.cpp.

References _ntot.

Referenced by average_xsec(), gather_num_events(), gather_xsecs(), and sum_xsecs().

186 { return _ntot; }
Here is the caller graph for this function:

◆ reset()

void Gambit::ColliderBit::MC_xsec_container::reset ( )

Reset this instance for reuse.

Public method to reset this instance for reuse, avoiding the need for "new" or "delete".

Definition at line 166 of file xsec.cpp.

References _ntot, instances_map, and Gambit::ColliderBit::xsec_container::reset().

Referenced by Gambit::ColliderBit::getEvGenCrossSection().

167  {
169  _ntot = 0;
170 
171  // Add this instance to the instances map if it's not there already.
172  int thread = omp_get_thread_num();
173  if (instances_map.count(thread) == 0)
174  {
175  #pragma omp critical
176  {
177  instances_map[thread] = this;
178  }
179  }
180  }
static std::map< int, const MC_xsec_container * > instances_map
A map with pointers to all instances of this class. The key is the OMP thread number.
Definition: xsec.hpp:142
void reset()
Reset this instance for reuse.
Definition: xsec.cpp:47
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_num_events()

void Gambit::ColliderBit::MC_xsec_container::set_num_events ( long long  n)

Set the total number of events seen so far.

Definition at line 192 of file xsec.cpp.

References _ntot, and generate_raster_scan_settings::n.

Referenced by average_xsec(), and sum_xsecs().

Here is the caller graph for this function:

◆ sum_xsecs() [1/2]

void Gambit::ColliderBit::MC_xsec_container::sum_xsecs ( double  other_xsec,
double  other_xsecerr,
long long  other_ntot 
)

Sum cross-sections and add errors in quadrature.

Definition at line 214 of file xsec.cpp.

References _ntot, Gambit::ColliderBit::xsec_container::_xsec, set_num_events(), and Gambit::ColliderBit::xsec_container::sum_xsecs().

Referenced by sum_xsecs().

215  {
216  // Run base class function
217  xsec_container::sum_xsecs(other_xsec, other_xsecerr);
218 
219  // Update _ntot
220  if (other_xsec > 0)
221  {
222  if (_xsec <= 0) set_num_events(other_ntot);
223  else _ntot += other_ntot;
224  }
225  }
void set_num_events(long long)
Set the total number of events seen so far.
Definition: xsec.cpp:192
void sum_xsecs(double, double)
Sum cross-sections and add errors in quadrature.
Definition: xsec.cpp:93
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sum_xsecs() [2/2]

void Gambit::ColliderBit::MC_xsec_container::sum_xsecs ( const MC_xsec_container other)

Definition at line 227 of file xsec.cpp.

References num_events(), sum_xsecs(), and Gambit::ColliderBit::xsec_container::xsec_err().

228  {
229  MC_xsec_container::sum_xsecs(other(), other.xsec_err(), other.num_events());
230  }
void sum_xsecs(double, double, long long)
Sum cross-sections and add errors in quadrature.
Definition: xsec.cpp:214
Here is the call graph for this function:

◆ xsec_per_event()

double Gambit::ColliderBit::MC_xsec_container::xsec_per_event ( ) const

Return the cross-section per event seen (in fb).

Definition at line 189 of file xsec.cpp.

References _ntot, and Gambit::ColliderBit::xsec_container::_xsec.

Referenced by get_content_as_map().

189 { return (_xsec >= 0 && _ntot > 0) ? _xsec/_ntot : 0; }
Here is the caller graph for this function:

Member Data Documentation

◆ _ntot

long long Gambit::ColliderBit::MC_xsec_container::_ntot
private

◆ instances_map

std::map< int, const MC_xsec_container * > Gambit::ColliderBit::MC_xsec_container::instances_map
staticprivate

A map with pointers to all instances of this class. The key is the OMP thread number.

A map with pointers to all instances of this class. The key is the thread number.

Definition at line 142 of file xsec.hpp.

Referenced by gather_num_events(), gather_xsecs(), get_content_as_map(), and reset().


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