ATLAS Offline Software
Functions
UnitTestAlgXAOD.cxx File Reference
#include <EventLoopTest/UnitTestAlgXAOD.h>
#include <EventLoop/Job.h>
#include <EventLoop/OutputStream.h>
#include <EventLoop/Worker.h>
#include <RootCoreUtils/Assert.h>
#include <RootCoreUtils/ThrowMsg.h>
#include <AsgMessaging/MessageCheck.h>
#include <TFile.h>
#include <TH1.h>
#include <TTree.h>
#include <AsgMessaging/MsgStream.h>
#include <AsgMessaging/MsgStreamMacros.h>
#include <xAODEventInfo/EventInfo.h>

Go to the source code of this file.

Functions

 ClassImp (EL::UnitTestAlgXAOD) namespace EL
 

Function Documentation

◆ ClassImp()

ClassImp ( EL::UnitTestAlgXAOD  )
Author
Nils Krumnack

Definition at line 32 of file UnitTestAlgXAOD.cxx.

35 {
36  void UnitTestAlgXAOD ::
37  testInvariant () const
38  {
39  RCU_INVARIANT (this != 0);
40  }
41 
42 
43 
44  UnitTestAlgXAOD ::
45  UnitTestAlgXAOD ()
46  {
47  RCU_NEW_INVARIANT (this);
48  }
49 
50 
51 
52  UnitTestAlgXAOD ::
53  ~UnitTestAlgXAOD ()
54  {
55  RCU_DESTROY_INVARIANT (this);
56 
57  if (m_state != State::START && m_state != State::HIST_FINALIZED)
58  {
59  ANA_MSG_FATAL ("never got completely finalized");
60  RCU_THROW_MSG ("never got completely finalized");
61  }
62  }
63 
64 
65 
66  StatusCode UnitTestAlgXAOD ::
67  setupJob (Job& job)
68  {
69  RCU_CHANGE_INVARIANT (this);
70 
71  job.useXAOD ();
72 
73  return StatusCode::SUCCESS;
74  }
75 
76 
77 
78  StatusCode UnitTestAlgXAOD ::
79  changeInput (bool /*firstFile*/)
80  {
82  RCU_CHANGE_INVARIANT (this);
83  ANA_MSG_INFO ("changeInput");
84  ANA_CHECK (testWorkerState (true, {State::HIST_INITIALIZED, State::INITIALIZED, State::INPUT_CHANGED}));
85  if (m_state == State::HIST_INITIALIZED)
86  m_state = State::INPUT_CHANGED;
87  return StatusCode::SUCCESS;
88  }
89 
90 
91 
92  StatusCode UnitTestAlgXAOD ::
93  histInitialize ()
94  {
96  RCU_CHANGE_INVARIANT (this);
97  ANA_MSG_INFO ("histInitialize");
98  ANA_CHECK (testWorkerState (false, {State::START}));
99  m_state = State::HIST_INITIALIZED;
100  return StatusCode::SUCCESS;
101  }
102 
103 
104 
106  initialize ()
107  {
109  RCU_CHANGE_INVARIANT (this);
110  ANA_MSG_INFO ("initialize");
111  ANA_CHECK (testWorkerState (true, {State::INPUT_CHANGED}));
112  m_state = State::INITIALIZED;
113  return StatusCode::SUCCESS;
114  }
115 
116 
117 
118  StatusCode UnitTestAlgXAOD ::
119  fileExecute ()
120  {
122  RCU_CHANGE_INVARIANT (this);
123  ANA_MSG_INFO ("fileExecute");
124  ANA_CHECK (testWorkerState (false, {State::HIST_INITIALIZED, State::INPUT_CHANGED, State::INITIALIZED}));
125 
126  // in principle I should check here that TEvent is connected to a
127  // good file, but I'm not sure how, just checking that I can
128  // retrieve EventInfo, which is not guaranteed, as the input file
129  // may be empty, but none of the test files is
130 
131  if (wk()->inputFile() == nullptr)
132  {
133  ANA_MSG_ERROR ("didn't find input file");
134  return StatusCode::FAILURE;
135  }
136 
137  const xAOD::EventInfo *info {nullptr};
138  ANA_CHECK (evtStore()->retrieve (info, "EventInfo"));
139 
140  return StatusCode::SUCCESS;
141  }
142 
143 
144 
146  execute ()
147  {
149  RCU_CHANGE_INVARIANT (this);
150  ANA_MSG_DEBUG ("execute");
151  ANA_CHECK (testWorkerState (true, {State::INITIALIZED}));
152  return StatusCode::SUCCESS;
153  }
154 
155 
156 
158  finalize ()
159  {
161  RCU_CHANGE_INVARIANT (this);
162  ANA_MSG_INFO ("finalize");
163  ANA_CHECK (testWorkerState (false, {State::INITIALIZED}));
164  m_state = State::FINALIZED;
165  return StatusCode::SUCCESS;
166  }
167 
168 
169 
170  StatusCode UnitTestAlgXAOD ::
171  histFinalize ()
172  {
174  RCU_CHANGE_INVARIANT (this);
175  ANA_MSG_INFO ("histFinalize");
176  ANA_CHECK (testWorkerState (false, {State::FINALIZED, State::HIST_FINALIZED}));
177  m_state = State::HIST_FINALIZED;
178  return StatusCode::SUCCESS;
179  }
180 
181 
182 
183  StatusCode UnitTestAlgXAOD ::
184  testWorkerState (bool validEvent, std::set<State> validStates) const
185  {
186  if (validStates.find (m_state) == validStates.end())
187  {
188  ANA_MSG_ERROR ("invalid state: " << unsigned (m_state));
189  return StatusCode::FAILURE;
190  }
191 
192  if (wk()->xaodEvent() == nullptr)
193  {
194  ANA_MSG_ERROR ("didn't find TEvent");
195  return StatusCode::FAILURE;
196  }
197 
198  if (wk()->xaodStore() == nullptr)
199  {
200  ANA_MSG_ERROR ("didn't find TStore");
201  return StatusCode::FAILURE;
202  }
203 
204  if (validEvent)
205  {
206  if (wk()->tree() == nullptr)
207  {
208  ANA_MSG_ERROR ("didn't find tree");
209  return StatusCode::FAILURE;
210  }
211 
212  if (wk()->treeEntry() < 0 ||
213  wk()->treeEntry() >= wk()->tree()->GetEntries())
214  {
215  ANA_MSG_ERROR ("invalid tree entry");
216  return StatusCode::FAILURE;
217  }
218 
219  const xAOD::EventInfo *info {nullptr};
220  ANA_CHECK (evtStore()->retrieve (info, "EventInfo"));
221  }
222  return StatusCode::SUCCESS;
223  }
224 }
grepfile.info
info
Definition: grepfile.py:38
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
internal_poltrig::START
@ START
Definition: PolygonTriangulator.cxx:112
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
initialize
void initialize()
Definition: run_EoverP.cxx:894
tree
TChain * tree
Definition: tile_monitor.h:30
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:17
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
ANA_MSG_FATAL
#define ANA_MSG_FATAL(xmsg)
Macro printing fatal messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:296
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
RCU_DESTROY_INVARIANT
#define RCU_DESTROY_INVARIANT(x)
Definition: Assert.h:235
ANA_CHECK_SET_TYPE
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:314
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
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233