35const char*
const Event::EVENT_RNTUPLE_NAME =
"EventData";
37const char*
const Event::EVENT_TREE_NAME =
"CollectionTree";
39const char*
const Event::METADATA_OBJECT_NAME =
"MetaData";
50 auto event = std::make_unique<Experimental::REvent>();
51 if (event->readFrom(inFile).isFailure()) {
52 ANA_MSG_ERROR(
"Could not read RNTuple from: " << inFile.GetName());
60 std::string sauxMode =
"kClassAccess";
61 auto metaData =
dynamic_cast<TTree*
>(inFile.Get(
"MetaData"));
63 auto rc = metaData->LoadTree(0);
68 if (metaData->GetBranch(
"StreamAOD")) {
70 sauxMode =
"kAthenaAccess";
73 ANA_MSG_INFO(
"Using aux mode " << sauxMode <<
" for file " << inFile.GetName());
74 auto event = std::make_unique<TEvent>(eauxMode);
75 if (event->readFrom(inFile).isFailure()) {
76 ANA_MSG_ERROR(
"Could not read TTree from: " << inFile.GetName());
81 ANA_MSG_ERROR(
"Could not recognize file: " << inFile.GetName());
98 ATH_MSG_DEBUG(
"Copying objects matching pattern \"" << pattern
99 <<
"\" to the output");
102 std::set<std::string>
keys;
105 std::regex
re{pattern};
111 ATH_MSG_VERBOSE(
"Considering input object with key \"" << key <<
"\"");
114 if (std::regex_match(key,
re) ==
false) {
118 if (key.ends_with(
"Aux.")) {
122 if (efe.parentName() !=
"") {
126 static const bool SILENT =
true;
142 if (std::regex_match(newname,
re) ==
false) {
146 static const bool SILENT =
true;
152 keys.insert(newname);
156 for (
const std::string& key :
keys) {
159 std::string keyToUse = key;
164 keyToUse = remap_itr->second;
168 static const bool SILENT =
false;
175 return StatusCode::FAILURE;
179 if (objMgr ==
nullptr) {
181 return StatusCode::FAILURE;
183 static const bool METADATA =
false;
185 SILENT, METADATA) ==
nullptr) {
187 return StatusCode::FAILURE;
191 static const bool OVERWRITE =
true;
192 static const bool IS_OWNER =
true;
194 key, OVERWRITE, METADATA, IS_OWNER));
198 const std::string auxKey = keyToUse +
"Aux.";
206 return StatusCode::SUCCESS;
222 bool metadata)
const {
228 auto itr = objects.find(key);
229 if (itr == objects.end()) {
235 if ((!store) || (!store->contains(key, ti)) || store->isConst(key, ti)) {
240 void* result = store->getObject(key, ti);
249 if (itr->second->isSet() ==
false) {
256 if (mgr ==
nullptr) {
257 ATH_MSG_ERROR(
"Object of wrong type found for key \"" << key <<
"\"");
262 void* result = mgr->holder()->getAs(ti);
263 if (result ==
nullptr) {
286 const std::type_info& ti,
bool silent,
290 std::string keyToUse = key;
295 keyToUse = remap_itr->second;
301 if (store && store->contains(keyToUse, ti) && store->isConst(keyToUse, ti)) {
302 const void* result = store->getConstObject(keyToUse, ti);
308 if (silent ==
false) {
317 if (
sc.isSuccess() ==
false) {
325 auto itr = objects.find(keyToUse);
326 if (itr == objects.end()) {
327 ATH_MSG_FATAL(
"There is an internal logic error in the code...");
334 if (mgr ==
nullptr) {
335 if (key == keyToUse) {
336 ATH_MSG_ERROR(
"Object of wrong type found for key \"" << key <<
"\"");
339 << key <<
"\"/\"" << keyToUse <<
"\"");
345 if (metadata ==
false) {
346 const Int_t readBytes = mgr->getEntry();
351 static const bool IS_METADATA =
false;
352 if (
setAuxStore(key, *mgr, IS_METADATA).isSuccess() ==
false) {
354 << mgr->holder()->getClass()->GetName() <<
"/"
358 }
else if (readBytes < 0) {
360 << mgr->holder()->getClass()->GetName() <<
"/" << keyToUse);
366 const void* result = mgr->holder()->getAsConst(ti, silent);
367 if (result ==
nullptr) {
370 << keyToUse <<
"\" as \""
389::Bool_t
Event::contains(
const std::string& key,
const std::type_info& ti,
392 static const bool SILENT =
true;
393 return ((getOutputObject(key, ti, metadata) !=
nullptr) ||
394 (getInputObject(key, ti, SILENT, metadata) !=
nullptr));
408::Bool_t Event::transientContains(
const std::string& key,
409 const std::type_info& ti,
410 ::Bool_t metadata)
const {
412 return (getOutputObject(key, ti, metadata) !=
nullptr);
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Manager for EDM objects created by ROOT.
const THolder * holder() const
Accessor to the Holder object.
virtual bool hasInput() const =0
Check if an input file is connected to the object.
EventFormat m_inputEventFormat
Format of the current input file.
virtual StatusCode recordAux(TVirtualManager &mgr, const std::string &key, bool metadata)=0
Record an auxiliary store into a connected output file.
static std::unique_ptr< Event > createAndReadFrom(TFile &file)
static method to create an Event object and readFrom a file, given by a TFile.
bool contains(const std::string &key)
Function checking if an object is available from the store.
const void * getInputObject(SG::sgkey_t key, const std::type_info &ti, bool silent) override
Function for retrieving an input object in a non-template way.
virtual StatusCode connectObject(const std::string &key, bool silent)=0
Function setting up access to a particular object.
std::unordered_map< std::string, std::unique_ptr< TVirtualManager > > Object_t
Definition of the internal data structure type.
Object_t m_inputObjects
Collection of all the managed input objects.
static const char *const EVENT_TREE_NAME
Default name of the event TTree.
StatusCode copy(const std::string &pattern=".*")
Copy an object directly from the input to the output.
void * getOutputObject(SG::sgkey_t key, const std::type_info &ti) override
Function for retrieving an output object in a non-template way.
virtual StatusCode connectMetaObject(const std::string &key, bool silent)=0
Function setting up access to a particular metadata object.
virtual StatusCode setAuxStore(const std::string &key, Details::IObjectManager &mgr, bool metadata)=0
Function connecting a DV object to its auxiliary store.
StatusCode record(T *obj, const std::string &key)
Add an output object to the event.
StatusCode keys(std::vector< std::string > &vkeys, bool metadata) const
Provide a list of all data object keys associated with a specific type.
static const char *const EVENT_RNTUPLE_NAME
Name of the event RNTuple.
std::unordered_map< std::string, std::string > m_nameRemapping
Container name re-mapping rules.
Object_t m_inputMetaObjects
Collection of all the managed input meta-objects.
Object_t m_outputObjects
Collection of all the managed output object.
Object_t m_outputMetaObjects
Collection of all the managed output meta-objects.
static TStore * store()
Access the currently active TStore object.
@ kAthenaAccess
Access containers/objects like Athena does.
@ kClassAccess
Access auxiliary data using the aux containers.
const ::TClass * getClass() const
A relatively simple transient store for objects created in analysis.
virtual const void * object() const =0
Function getting a const pointer to the object being handled.
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...