ATLAS Offline Software
Functions
FormulaSvc.cxx File Reference
#include <MultiDraw/FormulaSvc.h>
#include <memory>
#include <sstream>
#include <TTree.h>
#include <TTreeFormula.h>
#include <TTreeFormulaManager.h>
#include <EventLoop/Job.h>
#include <EventLoop/StatusCode.h>
#include <EventLoop/IWorker.h>
#include <MultiDraw/Formula.h>
#include <RootCoreUtils/Assert.h>
#include <RootCoreUtils/ThrowMsg.h>

Go to the source code of this file.

Functions

 ClassImp (MD::FormulaSvc) namespace MD
 

Function Documentation

◆ ClassImp()

ClassImp ( MD::FormulaSvc  )

Definition at line 35 of file FormulaSvc.cxx.

38 {
39  //
40  // legacy implementations
41  //
42 
43  const std::string FormulaSvc::name = "MultiDraw";
44 
45 
46 
47  std::string dbg (const FormulaSvc& /*obj*/, unsigned /*verbosity*/)
48  {
49  return "FormulaSvc";
50  }
51 
52 
53 
54  void useFormulas (EL::Job& job)
55  {
56  if (!job.algsHas (FormulaSvc::name))
57  job.algsAdd (new FormulaSvc);
58  }
59 
60 
61 
62  FormulaSvc *formulas (EL::IWorker *worker)
63  {
64  RCU_REQUIRE_SOFT (worker != 0);
65 
66  FormulaSvc *const svc
67  = dynamic_cast<FormulaSvc*>(worker->getAlg (FormulaSvc::name));
68  if (svc == 0)
69  RCU_THROW_MSG ("Job not configured for FormulaSvc support");
70  return svc;
71  }
72 
73 
74 
75  void FormulaSvc ::
76  testInvariant () const
77  {
78  RCU_INVARIANT (this != 0);
79 
80  for (std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
81  {
82  RCU_INVARIANT (m_vars[form] != 0);
83  }
84  }
85 
86 
87 
88  FormulaSvc ::
89  FormulaSvc ()
90  : m_tree (0)
91  {
92  RCU_NEW_INVARIANT (this);
93  }
94 
95 
96 
97  FormulaSvc ::
98  ~FormulaSvc ()
99  {
100  RCU_DESTROY_INVARIANT (this);
101 
102  for (std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
103  {
104  delete m_vars[form];
105  }
106  }
107 
108 
109 
110  const Formula *FormulaSvc ::
111  addForm (const std::string& formula)
112  {
113  RCU_CHANGE_INVARIANT (this);
114  RCU_REQUIRE_SOFT (!formula.empty());
115 
116  for (std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
117  {
118  if (m_vars[form]->formula() == formula)
119  return m_vars[form];
120  }
121  RCU_ASSERT (m_tree != 0);
122  std::ostringstream name;
123  name << "var" << m_vars.size();
124  m_vars.push_back (new Formula (name.str(), formula, m_tree));
125  return m_vars.back();
126  }
127 
128 
129 
130  const char *FormulaSvc ::
131  GetName () const
132  {
133  RCU_READ_INVARIANT (this);
134  return name.c_str();
135  }
136 
137 
138 
139  EL::StatusCode FormulaSvc ::
140  changeInput (bool /*firstFile*/)
141  {
142  RCU_CHANGE_INVARIANT (this);
143 
144  m_tree = 0;
145 
146  try
147  {
148  m_tree = wk()->tree();
149  m_tree->ResetBit (TTree::kForceRead);
150 
151  for (std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
152  m_vars[form]->reset (m_tree);
153  } catch (...)
154  {
155  m_tree = 0;
156  throw;
157  }
158 
159  return EL::StatusCode::SUCCESS;
160  }
161 
162 
163 
165  execute ()
166  {
167  RCU_CHANGE_INVARIANT (this);
168  if (wk()->treeEntry() != wk()->tree()->GetReadEvent())
169  wk()->tree()->LoadTree (wk()->treeEntry());
170  RCU_ASSERT (wk()->treeEntry() == wk()->tree()->GetReadEvent());
171  return EL::StatusCode::SUCCESS;
172  }
173 }
EL::IWorker::getAlg
virtual EL::Algorithm * getAlg(const std::string &name) const =0
effects: returns the algorithms with the given name or NULL if there is none guarantee: strong failur...
tree
TChain * tree
Definition: tile_monitor.h:30
SH::Meta::dbg
std::string dbg(const Meta &obj, unsigned verbosity=0)
the debugging info of this object
Definition: Meta.cxx:28
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...
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
EL::IWorker
the interface for algorithms to access IWorker
Definition: IWorker.h:40
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
RCU_DESTROY_INVARIANT
#define RCU_DESTROY_INVARIANT(x)
Definition: Assert.h:235
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
EL::Job
Definition: Job.h:51
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
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233