ATLAS Offline Software
UnitTestAlg4.cxx
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 //
4 
5 // EDM include(s).
8 
9 // Local include(s).
11 
12 namespace EL {
13 
14  UnitTestAlg4::UnitTestAlg4( const std::string& name, ISvcLocator* svcLoc )
15  : AnaAlgorithm( name, svcLoc ) {
16 
17  }
18 
20 
21  // Greet the user.
22  ATH_MSG_INFO( "Initialising algorithm..." );
23 
24  // Make sure that @c beginInputFile() gets called.
26 
27  // Read the file metadata.
29 
30  // Make sure that event data can *not* be accessed yet.
31  const xAOD::EventInfo* ei = nullptr;
32  if( evtStore()->retrieve( ei, "EventInfo" ).isSuccess() == true ) {
33  ATH_MSG_FATAL( "Event information should not be available yet!" );
34  return ::StatusCode::FAILURE;
35  }
36 
37  // Return gracefully.
38  return ::StatusCode::SUCCESS;
39  }
40 
42 
43  // Check that event data access is working by now.
44  const xAOD::EventInfo* ei = nullptr;
45  ATH_CHECK( evtStore()->retrieve( ei, "EventInfo" ) );
46 
47  // Return gracefully.
48  return ::StatusCode::SUCCESS;
49  }
50 
52 
53  // Check whether @c beginInputFile() was called during the job.
54  if( m_callCount == 0 ) {
55  ATH_MSG_FATAL( "The job did not call beginInputFile()" );
56  return ::StatusCode::FAILURE;
57  }
58 
59  // Return gracefully.
60  return ::StatusCode::SUCCESS;
61  }
62 
64 
65  // Increment the internal counter.
66  m_callCount++;
67 
68  // Read the file metadata.
70 
71  // Return gracefully.
72  return ::StatusCode::SUCCESS;
73  }
74 
76 
77  // Access the file metadata object.
78  ATH_MSG_INFO( "Reading the file metadata..." );
79  const xAOD::FileMetaData* fmd = nullptr;
80  ATH_CHECK( inputMetaStore()->retrieve( fmd, "FileMetaData" ) );
81 
82  // Get some information out of the object.
83  std::string amiTag, dataType, simFlavour;
86  fmd->value( xAOD::FileMetaData::simFlavour, simFlavour );
87  ATH_MSG_INFO( " amiTag = " << amiTag );
88  ATH_MSG_INFO( " dataType = " << dataType );
89  ATH_MSG_INFO( " simFlavour = " << simFlavour );
90 
91  // Return gracefully.
92  return ::StatusCode::SUCCESS;
93  }
94 
95 } // namespace EL
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
UnitTestAlg4.h
EL::AnaAlgorithm::inputMetaStore
ConstMetaStorePtr_t inputMetaStore() const
Definition: AnaAlgorithm.cxx:72
downloadSingle.dataType
string dataType
Definition: downloadSingle.py:18
EL::UnitTestAlg4::execute
virtual ::StatusCode execute() override
Function executing the algorithm.
Definition: UnitTestAlg4.cxx:41
EL::UnitTestAlg4::beginInputFile
virtual ::StatusCode beginInputFile() override
Function called whenever a new input file's processing starts.
Definition: UnitTestAlg4.cxx:63
EL::UnitTestAlg4::initialize
virtual ::StatusCode initialize() override
Function initialising the algorithm.
Definition: UnitTestAlg4.cxx:19
hotSpotInTAG.amiTag
amiTag
Definition: hotSpotInTAG.py:102
EL::UnitTestAlg4::finalize
virtual ::StatusCode finalize() override
Function finalising the algorithm.
Definition: UnitTestAlg4.cxx:51
xAOD::FileMetaData_v1::value
bool value(MetaDataType type, std::string &val) const
Get a pre-defined string value out of the object.
Definition: FileMetaData_v1.cxx:195
xAOD::FileMetaData_v1::simFlavour
@ simFlavour
Fast or Full sim [string].
Definition: FileMetaData_v1.h:76
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
EL::AnaAlgorithm
the (new) base class for EventLoop algorithms
Definition: AnaAlgorithm.h:73
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EL::AnaAlgorithm::requestBeginInputFile
::StatusCode requestBeginInputFile()
register this algorithm to have an implementation of beginInputFile
Definition: AnaAlgorithm.cxx:271
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
xAOD::FileMetaData_v1
Class holding file-level metadata about an xAOD file.
Definition: FileMetaData_v1.h:34
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
xAOD::FileMetaData_v1::amiTag
@ amiTag
AMI tag used to process the file the last time [string].
Definition: FileMetaData_v1.h:58
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
FileMetaData.h
EL::UnitTestAlg4::readFileMetaData
StatusCode readFileMetaData()
Function reading some in-file metadata.
Definition: UnitTestAlg4.cxx:75
EL::UnitTestAlg4::m_callCount
int m_callCount
Internal status flag.
Definition: UnitTestAlg4.h:48
EL::UnitTestAlg4::UnitTestAlg4
UnitTestAlg4(const std::string &name, ISvcLocator *svcLoc)
Standard algorithm constructor.
Definition: UnitTestAlg4.cxx:14
xAOD::FileMetaData_v1::dataType
@ dataType
Data type that's in the file [string].
Definition: FileMetaData_v1.h:64