ATLAS Offline Software
Functions
AlgSelect.cxx File Reference
#include <EventLoopAlgs/AlgSelect.h>
#include <TH1.h>
#include <EventLoop/StatusCode.h>
#include <EventLoop/IWorker.h>
#include <EventLoopAlgs/NTupleSvc.h>
#include <MultiDraw/Formula.h>
#include <MultiDraw/FormulaSvc.h>
#include <RootCoreUtils/Assert.h>
#include <RootCoreUtils/ThrowMsg.h>
Include dependency graph for AlgSelect.cxx:

Go to the source code of this file.

Functions

 ClassImp (EL::AlgSelect) namespace EL
 

Function Documentation

◆ ClassImp()

ClassImp ( EL::AlgSelect  )

Definition at line 32 of file AlgSelect.cxx.

35 {
36  void AlgSelect ::
37  testInvariant () const
38  {
39  RCU_INVARIANT (this != 0);
40 
41  RCU_INVARIANT (!m_outputStream.empty());
42  for (std::size_t form = 0, end = m_cuts.size(); form != end; ++ form)
43  RCU_INVARIANT (!m_cuts[form].empty());
44  if (m_skim != 0)
45  {
46  RCU_INVARIANT (m_cuts.size() == m_index.size());
47  RCU_INVARIANT (m_hist != 0);
48  RCU_INVARIANT (m_formSvc != 0);
49  }
50  if (m_hist != 0)
51  {
52  RCU_INVARIANT (m_cuts.size() == std::size_t (m_hist->GetNbinsX()));
53  }
54  }
55 
56 
57 
58  AlgSelect ::
59  AlgSelect ()
60  : m_outputStream ("output"),
61  m_hist (0), m_formSvc (0), m_skim (0)
62  {
63  RCU_NEW_INVARIANT (this);
64  }
65 
66 
67 
68  AlgSelect ::
69  AlgSelect (const std::string& val_outputStream, const std::string& cut)
70  : m_outputStream (val_outputStream),
71  m_hist (0), m_formSvc (0), m_skim (0)
72  {
73  RCU_ASSERT (!val_outputStream.empty());
74 
75  if (!cut.empty())
76  m_cuts.push_back (cut);
77 
78  RCU_NEW_INVARIANT (this);
79  }
80 
81 
82 
83  const std::string& AlgSelect ::
84  outputStream () const
85  {
86  RCU_READ_INVARIANT (this);
87  return m_outputStream;
88  }
89 
90 
91 
92  const std::string& AlgSelect ::
93  histName () const
94  {
95  RCU_READ_INVARIANT (this);
96  return m_histName;
97  }
98 
99 
100 
101  void AlgSelect ::
102  histName (const std::string& val_histName)
103  {
104  RCU_CHANGE_INVARIANT (this);
105  m_histName = val_histName;
106  }
107 
108 
109 
110  void AlgSelect ::
111  addCut (const std::string& cut)
112  {
113  RCU_CHANGE_INVARIANT (this);
114  RCU_REQUIRE_SOFT (!cut.empty());
115  m_cuts.push_back (cut);
116  }
117 
118 
119 
120  StatusCode AlgSelect ::
121  setupJob (Job& job)
122  {
123  RCU_CHANGE_INVARIANT (this);
125  return StatusCode::SUCCESS;
126  }
127 
128 
129 
131  initialize ()
132  {
133  RCU_CHANGE_INVARIANT (this);
134 
135  try
136  {
137  m_formSvc = MD::formulas (wk());
138  if (!m_cuts.empty() && !m_histName.empty())
139  {
140  m_hist = new TH1D (m_histName.c_str(), 0, m_cuts.size(), 0, m_cuts.size());
141  wk()->addOutput (m_hist);
142  }
143  for (std::size_t form = 0, end = m_cuts.size(); form != end; ++ form)
144  {
145  m_index.push_back (m_formSvc->addForm (m_cuts[form]));
146  m_hist->GetXaxis()->SetBinLabel (1 + form, m_cuts[form].c_str());
147  }
148 
149  m_skim = getNTupleSvc (wk(), m_outputStream);
150  } catch (...)
151  {
152  m_index.clear ();
153  throw;
154  }
155  return StatusCode::SUCCESS;
156  }
157 
158 
159 
161  execute ()
162  {
163  RCU_CHANGE_INVARIANT (this);
164 
165  RCU_ASSERT (m_hist != 0);
166 
167  double weight = 1;
168  for (std::size_t form = 0; form != m_cuts.size() && weight != 0; ++ form)
169  {
170  double myweight = 1;
171  if (m_index[form]) switch (m_index[form]->ndim())
172  {
173  case -1:
174  RCU_THROW_MSG ("formula not valid: " + m_cuts[form]);
175  break;
176  case 0:
177  myweight = m_index[form]->value (0);
178  break;
179  case 1:
180  RCU_THROW_MSG ("formula is an array: " + m_cuts[form]);
181  break;
182  default:
183  RCU_THROW_MSG ("unknown formula dimension: " + m_cuts[form]);
184  }
185 
186  weight *= myweight;
187  if (m_hist && weight != 0)
188  m_hist->Fill (form);
189  }
190 
191  if (weight)
192  m_skim->setFilterPassed ();
193  return StatusCode::SUCCESS;
194  }
195 }
AddEmptyComponent.histName
string histName
Definition: AddEmptyComponent.py:64
initialize
void initialize()
Definition: run_EoverP.cxx:894
RunGeantinoStepRecordingITk.outputStream
outputStream
Definition: RunGeantinoStepRecordingITk.py:126
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
MD::formulas
FormulaSvc * formulas(EL::IWorker *worker)
returns: the formula service for this worker guarantee: strong failures: formula service not configur...
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
RCU_REQUIRE_SOFT
#define RCU_REQUIRE_SOFT(x)
Definition: Assert.h:153
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
MD::useFormulas
void useFormulas(EL::Job &job)
effects: register the formula service for this job guarantee: strong failures: out of memory I
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
RCU_THROW_MSG
#define RCU_THROW_MSG(message)
Definition: PrintMsg.h:58
test_interactive_athena.job
job
Definition: test_interactive_athena.py:6
RCU_ASSERT
#define RCU_ASSERT(x)
Definition: Assert.h:222
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
EL::getNTupleSvc
NTupleSvc * getNTupleSvc(IWorker *worker, const std::string &outputStream, const std::string &treeName="")
effects: get the skimming algorithm for the given output for this worker guarantee: strong failures: ...
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233