gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
runAnalyses.cpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
37 
40 
41 // #define COLLIDERBIT_DEBUG
42 #define DEBUG_PREFIX "DEBUG: OMP thread " << omp_get_thread_num() << ": "
43 
44 namespace Gambit
45 {
46 
47  namespace ColliderBit
48  {
49 
52  #ifdef COLLIDERBIT_DEBUG
53  const str& detname,
54  #else
55  const str&,
56  #endif
57  const MCLoopInfo& RunMC,
58  const AnalysisContainer& Container,
59  const HEPUtils::Event& SmearedEvent,
60  int iteration,
61  void(*wrapup)())
62  {
63  if (iteration == BASE_INIT)
64  {
65  result.clear();
66  return;
67  }
68 
69  static MC_convergence_checker convergence;
70  if (iteration == COLLIDER_INIT)
71  {
72  convergence.init(RunMC.current_convergence_options());
73  return;
74  }
75 
76  if (not Container.has_analyses()) return;
77 
78  if (iteration == COLLECT_CONVERGENCE_DATA)
79  {
80  // Update the convergence tracker with the new results
81  convergence.update(Container);
82  return;
83  }
84 
85  if (iteration == CHECK_CONVERGENCE)
86  {
87  // Call quits on the event loop if every analysis in every analysis container has sufficient statistics
88  if (convergence.achieved(Container)) wrapup();
89  return;
90  }
91 
92  // #ifdef COLLIDERBIT_DEBUG
93  // if (iteration == END_SUBPROCESS)
94  // {
95  // for (auto& analysis_pointer_pair : Container.get_current_analyses_map())
96  // {
97  // for (auto& sr : analysis_pointer_pair.second->get_results().srdata)
98  // {
99  // cout << DEBUG_PREFIX << "run"+detname+"Analyses: signal region " << sr.sr_label << ", n_signal = " << sr.n_signal << endl;
100  // }
101  // }
102  // }
103  // #endif
104 
105  if (iteration == COLLIDER_FINALIZE)
106  {
107  // The final iteration for this collider: collect results
108  for (auto& analysis_pointer_pair : Container.get_current_analyses_map())
109  {
110  #ifdef COLLIDERBIT_DEBUG
111  cout << DEBUG_PREFIX << "run"+detname+"Analyses: Collecting result from " << analysis_pointer_pair.first << endl;
112  #endif
113 
114  str warning;
115  result.push_back(analysis_pointer_pair.second->get_results_ptr(warning));
116  if (RunMC.event_generation_began && not RunMC.exceeded_maxFailedEvents && not warning.empty())
117  {
118  ColliderBit_error().raise(LOCAL_INFO, warning);
119  }
120  }
121  return;
122  }
123 
124  if (iteration == BASE_FINALIZE)
125  {
126  // Final iteration. Just return.
127  #ifdef COLLIDERBIT_DEBUG
128  cout << DEBUG_PREFIX << "run"+detname+"Analyses: 'result' contains " << result.size() << " results." << endl;
129  #endif
130  return;
131  }
132 
133  if (iteration <= BASE_INIT) return;
134 
135  // Loop over contained analyses and run them.
136  Container.analyze(SmearedEvent);
137 
138  }
139 
141  #define RUN_ANALYSES(NAME, EXPERIMENT, SMEARED_EVENT_DEP) \
142  void NAME(AnalysisDataPointers& result) \
143  { \
144  using namespace Pipes::NAME; \
145  runAnalyses(result, #EXPERIMENT, *Dep::RunMC, \
146  *Dep::CAT(EXPERIMENT,AnalysisContainer), *Dep::SMEARED_EVENT_DEP, \
147  *Loop::iteration, Loop::wrapup); \
148  }
149 
150  RUN_ANALYSES(runATLASAnalyses, ATLAS, ATLASSmearedEvent)
151  RUN_ANALYSES(runCMSAnalyses, CMS, CMSSmearedEvent)
152  RUN_ANALYSES(runIdentityAnalyses, Identity, CopiedEvent)
153 
154  }
155 }
void analyze(const HEPUtils::Event &, str, str) const
Pass event through specific analysis.
const std::map< str, Analysis * > & get_current_analyses_map() const
Get analyses map for the current collider.
void runAnalyses(AnalysisDataPointers &result, const str &, const MCLoopInfo &RunMC, const AnalysisContainer &Container, const HEPUtils::Event &SmearedEvent, int iteration, void(*wrapup)())
Run all the analyses in a given container.
Definition: runAnalyses.cpp:51
#define LOCAL_INFO
Definition: local_info.hpp:34
#define DEBUG_PREFIX
Definition: runAnalyses.cpp:42
Helper class for testing for convergence of analyses.
Declarations common to all ColliderBit event loop functions.
GAMBIT warning class.
Definition: exceptions.hpp:165
void init(const convergence_settings &)
Initialise (or re-initialise) the object.
RUN_ANALYSES(runATLASAnalyses, ATLAS, ATLASSmearedEvent) RUN_ANALYSES(runCMSAnalyses
#define COLLIDERBIT_DEBUG
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
bool achieved(const AnalysisContainer &ac)
Check if convergence has been achieved across threads, and across all instances of this class...
void update(const AnalysisContainer &)
Update the convergence data. This is the only routine meant to be called in parallel.
A class for managing collections of Analysis instances.
std::vector< const AnalysisData * > AnalysisDataPointers
TODO: see if we can use this one:
Definition: Analysis.hpp:33
Class for ColliderBit analyses.
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.