gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
getAnalysisContainer.cpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
37 
39 
40 // #define COLLIDERBIT_DEBUG
41 #define DEBUG_PREFIX "DEBUG: OMP thread " << omp_get_thread_num() << ": "
42 
43 namespace Gambit
44 {
45 
46  namespace ColliderBit
47  {
48 
51  const str& detname,
52  const MCLoopInfo& RunMC,
53  const xsec_container& TotalCrossSection,
54  int iteration)
55  {
56  if (RunMC.analyses.empty() or iteration == BASE_INIT) return;
57  if (not RunMC.current_analyses_exist_for(detname)) return;
58 
59  if (iteration == START_SUBPROCESS)
60  {
61  // Register analysis container
62  result.register_thread(detname+"AnalysisContainer");
63 
64  // Set current collider
65  result.set_current_collider(RunMC.current_collider());
66 
67  // Initialize analysis container or reset all the contained analyses
68  if (!result.has_analyses())
69  {
70  try
71  {
72  result.init(RunMC.current_analyses_for(detname));
73  }
74  catch (std::runtime_error& e)
75  {
76  piped_errors.request(LOCAL_INFO, e.what());
77  }
78  }
79  else result.reset();
80  }
81 
82  if (iteration == COLLIDER_FINALIZE)
83  {
84  result.collect_and_add_signal();
85  int ntot = RunMC.current_event_count();
86  double xs = TotalCrossSection.xsec();
87  double xs_per_event = 0;
88  if (xs >= 0 && ntot > 0)
89  {
90  xs_per_event = xs / ntot;
91  }
92  #ifdef COLLIDERBIT_DEBUG
93  cout << DEBUG_PREFIX << "getAnalysisContainer: "
94  << "ntot = " << ntot << ", "
95  << "xs = " << xs << ", "
96  << "xs_per_event = " << xs_per_event << endl;
97  #endif
98  // Scale all analysis results with the total cross-section per event
99  result.scale(xs_per_event);
100  }
101 
102  }
103 
105  #define GET_ANALYSIS_CONTAINER(NAME, EXPERIMENT) \
106  void NAME(AnalysisContainer& result) \
107  { \
108  using namespace Pipes::NAME; \
109  getAnalysisContainer(result, #EXPERIMENT, *Dep::RunMC, \
110  *Dep::TotalCrossSection, *Loop::iteration); \
111  }
112 
113  GET_ANALYSIS_CONTAINER(getATLASAnalysisContainer, ATLAS)
114  GET_ANALYSIS_CONTAINER(getCMSAnalysisContainer, CMS)
115  GET_ANALYSIS_CONTAINER(getIdentityAnalysisContainer, Identity)
116 
117 
118  }
119 }
Piped_exceptions piped_errors
Global instance of Piped_exceptions class for errors.
A base class for holding cross-section info within ColliderBit.
Definition: xsec.hpp:37
void init(const std::vector< str > &, str)
Initialize analyses (by names) for a specified collider.
void request(std::string origin, std::string message)
Request an exception.
Definition: exceptions.cpp:547
#define LOCAL_INFO
Definition: local_info.hpp:34
const int & current_event_count() const
Get the number of events generated for the current collider.
Definition: MCLoopInfo.cpp:135
void register_thread(str)
Add container to instances map.
#define DEBUG_PREFIX
const std::vector< str > & current_analyses_for(const str &) const
Get the set of analyses for the current collider and a given detector.
Definition: MCLoopInfo.cpp:144
void getAnalysisContainer(AnalysisContainer &result, const str &detname, const MCLoopInfo &RunMC, const xsec_container &TotalCrossSection, int iteration)
Retrieve an analysis container for a specific detector.
GET_ANALYSIS_CONTAINER(getATLASAnalysisContainer, ATLAS) GET_ANALYSIS_CONTAINER(getCMSAnalysisContainer
Declarations common to all ColliderBit event loop functions.
void reset(str, str)
Reset specific analysis.
bool current_analyses_exist_for(const str &) const
Query whether any analyses exist for a given detector for the current collider.
Definition: MCLoopInfo.cpp:120
const str & current_collider() const
Get the current collider.
Definition: MCLoopInfo.cpp:127
void collect_and_add_signal(str, str)
Collect signal predictions from other threads and add to this one, for specific analysis.
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
void set_current_collider(str)
Set name of current collider.
void scale(str, str, double)
Scale results for specific analysis.
A class for managing collections of Analysis instances.
TODO: see if we can use this one:
Definition: Analysis.hpp:33
Container for event loop status data and settings.
Definition: MCLoopInfo.hpp:31
bool has_analyses(str) const
Does this instance contain analyses for the given collider.
std::map< str, std::vector< str > > analyses
Analysis list for each collider.
Definition: MCLoopInfo.hpp:58