 |
ATLAS Offline Software
|
Go to the documentation of this file.
14 #include <TFriendElement.h>
15 #include <TChainElement.h>
18 #include <TMethodCall.h>
28 #ifndef XAOD_STANDALONE
31 #endif // not XAOD_STANDALONE
72 void removeVersionNames( std::string&
name ) {
75 while( (
pos =
name.find(
"_v1" ) ) !=
name.npos ) {
78 while( (
pos =
name.find(
"_v2" ) ) !=
name.npos ) {
81 while( (
pos =
name.find(
"_v3" ) ) !=
name.npos ) {
84 while( (
pos =
name.find(
"_v4" ) ) !=
name.npos ) {
87 while( (
pos =
name.find(
"_v5" ) ) !=
name.npos ) {
90 while( (
pos =
name.find(
"_v6" ) ) !=
name.npos ) {
93 while( (
pos =
name.find(
"_v7" ) ) !=
name.npos ) {
96 while( (
pos =
name.find(
"_v8" ) ) !=
name.npos ) {
113 ForceTrackIndices& xvec =
static_cast< ForceTrackIndices&
>(
vec );
123 namespace Experimental {
139 m_inNtupleReader( nullptr ), m_inMetaTree( nullptr ), m_inMetaTreeIsTTree( true ),
140 m_entry( -1 ), m_outTree( nullptr ),
141 m_inputObjects(), m_inputMissingObjects(), m_outputObjects(),
142 m_inputMetaObjects(), m_outputMetaObjects(),
143 m_inputEventFormat(), m_outputEventFormat( nullptr ),
144 m_auxItemList(), m_listeners(), m_nameRemapping() {
155 if( gSystem->Getenv(
"ROOTCORE_AUTO_UT" ) ||
156 gSystem->Getenv(
"ROOTCORE_FAST_UT" ) ||
157 gSystem->Getenv(
"ROOTCORE_SLOW_UT" ) ) {
158 ::Info(
"xAOD::REvent::REvent",
159 "Using access mode \"%i\" for the unit test",
160 static_cast< int >( UNIT_TEST_ACCESS_MODE ) );
175 for( ; itr !=
end; ++itr ) {
180 for( ; itr !=
end; ++itr ) {
185 for( ; itr !=
end; ++itr ) {
190 for( ; itr !=
end; ++itr ) {
200 #ifndef XAOD_STANDALONE
204 #endif // not XAOD_STANDALONE
226 std::ostringstream
ost;
227 ost <<
"<<<<<<<<<<<<<<<<<<<< xAOD::REvent Dump >>>>>>>>>>>>>>>>>>>>\n";
232 for( ; ef_itr != ef_end; ++ef_itr ) {
235 std::string
typeName = ef_itr->second.className();
240 ::TClass::GetClass( ef_itr->second.className().c_str() );
241 const std::type_info* ti = (
cl ?
cl->GetTypeInfo() : nullptr );
242 if( ( !
cl ) || ( !
cl->IsLoaded() ) || ( ! ti ) ) {
243 Warning(
"xAOD::REvent::dump",
244 "Unknown type (%s) found in the event format",
245 ef_itr->second.className().c_str() );
250 if( !
contains( ef_itr->second.branchName(), *ti ) ) {
255 ost <<
" Hash: 0x" << std::setw( 8 ) << std::setfill(
'0' )
256 << std::hex << ef_itr->second.hash()
257 <<
" Key: \"" << ef_itr->second.branchName() <<
"\"\n";
262 ost <<
" isConst: " << ( isNonConst ?
"No" :
"Yes" ) <<
"\n";
270 ost <<
"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
295 if(
fileName.size() == 0 )
return StatusCode::SUCCESS;
298 std::unique_ptr< TFile >
infile( TFile::Open(
fileName.c_str(),
"READ" ) );
300 ::Error(
"xAOD::REvent::readFrom",
302 return StatusCode::FAILURE;
308 for( ; itr !=
end; ++itr ) {
322 for( ; itr !=
end; ++itr ) {
337 ::Error(
"xAOD::REvent::readFrom",
338 XAOD_MESSAGE(
"Couldn't find metadata tree on input. Object "
340 return StatusCode::FAILURE;
346 ::Error(
"xAOD::REvent::readFrom",
347 XAOD_MESSAGE(
"Failed to load entry for metadata tree=%s" ),
349 return StatusCode::FAILURE;
354 ::Info(
"xAOD::REvent::readFrom",
355 "Was expecting a metadata tree with size 1, instead of %i.",
357 ::Info(
"xAOD::REvent::readFrom",
358 "File most probably produced by hadd..." );
364 static const std::string eventFormatTypeName =
366 ::TClass*
cl = ::TClass::GetClass( eventFormatTypeName.c_str() );
368 ::Warning(
"xAOD::REvent::readFrom",
369 "Couldn't load the EventFormat dictionary" );
373 const std::string eventFormatBranchName =
375 if( !
m_inMetaTree->GetBranch( eventFormatBranchName.c_str() ) ) {
379 ::Info(
"xAOD::REvent::readFrom",
"Input file provides no event or "
382 return StatusCode::SUCCESS;
388 m_inMetaTree->SetBranchAddress( eventFormatBranchName.c_str(),
391 ::Error(
"xAOD::REvent::readFrom",
392 XAOD_MESSAGE(
"Failed to connect to EventFormat object" ) );
393 return StatusCode::FAILURE;
410 std::set<std::string> lOtherMetaTreeNames = {};
411 TList *lKeys =
infile->GetListOfKeys();
414 for (
int iKey = 0; iKey < lKeys->GetEntries() ; iKey++){
416 std::string
keyName = lKeys->At(iKey)->GetName();
421 && (
keyName.find(
"MetaData") != std::string::npos)
422 && !(
keyName.find(
"MetaDataHdr") != std::string::npos)){
424 const char *
className = ((::TKey*)lKeys->At(iKey))->GetClassName();
425 static constexpr Bool_t LOAD = kFALSE;
426 static constexpr Bool_t SILENT = kTRUE;
427 ::TClass*
cl = ::TClass::GetClass(
className, LOAD, SILENT);
428 if ((
cl !=
nullptr) &&
cl->InheritsFrom(::TTree::Class())){
429 lOtherMetaTreeNames.insert(std::move(
keyName));
435 ::Info(
"xAOD::REvent::readFrom",
XAOD_MESSAGE(
"no keys found"));
439 for (
const std::string & metaTreeName : lOtherMetaTreeNames){
440 TTree *tmpMetaTree =
dynamic_cast< ::TTree*
>(
infile->Get( metaTreeName.c_str() ) );
444 ::Warning(
"xAOD::REvent::readFrom",
"Could not read metadata tree=%s",metaTreeName.c_str());
450 if ( tmpMetaTree->LoadTree(0) < 0 ){
451 ::Error(
"xAOD::REvent::readFrom",
452 XAOD_MESSAGE(
"Failed to load entry for metadata tree=%s" ),
453 tmpMetaTree->GetName() );
454 return StatusCode::FAILURE;
458 const std::string tmpEventFormatBranchName =
460 if( ! tmpMetaTree->GetBranch( tmpEventFormatBranchName.c_str() ) ) {
462 ::Warning(
"xAOD::REvent::readFrom",
"No EventFormat branch found in metadata tree=%s",tmpMetaTree->GetName() );
468 tmpMetaTree->SetBranchAddress( tmpEventFormatBranchName.c_str(),
469 &tmpFormat, &tmpBr );
471 ::Error(
"xAOD::REvent::readFrom",
472 XAOD_MESSAGE(
"Failed to connect to EventFormat object for metadata tree = %s"), tmpMetaTree->GetName() );
473 return StatusCode::FAILURE;
476 tmpBr->GetEntry( 0 );
478 for (
const std::pair<const std::string, xAOD::EventFormatElement> &evtElem : *tmpFormat){
495 ::Error(
"xAOD::REvent::readFrom",
XAOD_MESSAGE(
"inNtupleReader is empty") );
496 return StatusCode::FAILURE;
510 const TIncident beginIncident( IncidentType::BeginInputFile );
512 listener->handle( beginIncident );
519 const TIncident endIncident( IncidentType::EndInputFile );
521 listener->handle( endIncident );
525 return StatusCode::SUCCESS;
711 #ifndef XAOD_STANDALONE
713 #endif // not XAOD_STANDALONE
736 while( std::getline(
ss, attr,
'.' ) ) {
758 ::Error(
"xAOD::REvent::addListener",
759 XAOD_MESSAGE(
"Received a null pointer for the listener" ) );
760 return StatusCode::FAILURE;
764 bool listenerKnown =
false;
766 if(
l == listener ) {
767 ::Warning(
"xAOD::REvent::addListener",
768 "Listener %p was added previously already",
769 static_cast< void*
>( listener ) );
770 listenerKnown =
true;
776 if( ! listenerKnown ) {
781 return StatusCode::SUCCESS;
798 ::Error(
"xAOD::REvent::removeListener",
800 static_cast< void*
>( listener ) );
801 return StatusCode::FAILURE;
808 return StatusCode::SUCCESS;
840 ::Error(
"xAOD::REvent::addNameRemap",
841 XAOD_MESSAGE(
"Can't use \"%s\" as the target name in the"
842 "\"%s\" -> \"%s\" remapping" ),
844 return StatusCode::FAILURE;
850 ::Warning(
"xAOD::REvent::addNameRemap",
851 "Overriding existing name remapping \"%s\" -> \"%s\"",
852 itr->second.c_str(), itr->first.c_str() );
853 ::Warning(
"xAOD::REvent::addNameRemap",
" with: \"%s\" -> \"%s\"",
854 onfile.c_str(),
newName.c_str() );
861 return StatusCode::SUCCESS;
880 ::Info(
"xAOD::REvent::printNameRemap",
"Name remapping rules:" );
884 ::Info(
"xAOD::REvent::printNameRemap",
" NONE" );
891 ::Info(
"xAOD::REvent::printNameRemap",
" \"%s\" -> \"%s\"",
892 itr->second.c_str(), itr->first.c_str() );
1142 ::Error(
"xAOD::REvent::getEntries",
1167 ::Error(
"xAOD::REvent::getEntry",
1183 const TIncident incident( IncidentType::BeginEvent );
1186 for( ; l_itr != l_end; ++l_itr ) {
1187 ( *l_itr )->handle( incident );
1201 static const std::string dynStorePostfix =
"Aux.Dynamic";
1202 if( inObj.first.find( dynStorePostfix ) ==
1203 ( inObj.first.size() - dynStorePostfix.size() ) ) {
1217 result += inObj.second->getEntry( getall );
1222 const TIncident incident( IncidentType::BeginEvent );
1225 for( ; l_itr != l_end; ++l_itr ) {
1226 ( *l_itr )->handle( incident );
1395 ::Warning(
"xAOD::REvent::inputEventFormat",
1396 "No input file is connected at the moment" );
1436 if(
key ==
"" )
return 0;
1473 for( ; obj_itr != obj_end; ++obj_itr ) {
1476 if( obj_itr->second->object() !=
obj )
continue;
1479 return obj_itr->first;
1485 for( ; obj_itr != obj_end; ++obj_itr ) {
1488 if( obj_itr->second->object() !=
obj )
continue;
1491 return obj_itr->first;
1502 ::Warning(
"xAOD::REvent::getName",
1503 "Didn't find object with pointer %p in the event",
1505 static const std::string
dummy;
1510 std::vector<std::string>& vkeys,
1513 std::set<std::string>
keys;
1517 std::vector<TObjArray*> fullListOfBranches = {};
1521 ::Info(
"xAOD::REvent::getNames",
"scanning input objects");
1523 fullListOfBranches.push_back(
m_inMetaTree->GetListOfBranches());
1527 ::Error(
"xAOD::REvent::getNames",
"Cannot (yet) get names for event object of typename %s",
1528 targetClassName.c_str());
1559 for (
const TObjArray * in : fullListOfBranches){
1562 const TObject *
obj = in->At(
index);
1563 if ( !
obj )
continue;
1564 const TBranch * element =
dynamic_cast<const TBranch*
>(
obj);
1566 ::Error(
"xAOD::REvent::getNames",
"Failure inspecting input objects");
1569 std::string objClassName = element->GetClassName();
1570 std::string
key =
obj->GetName();
1571 ::Info(
"xAOD::REvent::getNames",
1572 "Inspecting %s / %s",
1573 objClassName.c_str(),
key.c_str());
1574 if (objClassName == targetClassName) {
1575 ::Info(
"xAOD::REvent::getNames",
1576 "Matched %s to key %s",
1577 targetClassName.c_str(),
key.c_str());
1586 ::Info(
"xAOD::REvent::getNames",
1587 "scanning input Aux objects for %s", targetClassName.c_str());
1588 for(
const auto&
object : inAux ) {
1592 if ( !
mgr )
continue;
1593 const std::string& objClassName =
mgr->holder()->getClass()->GetName();
1594 const std::string&
key =
object.first;
1595 ::Info(
"xAOD::REvent::getNames",
1596 "Inspecting %s / %s",
1597 objClassName.c_str(),
key.c_str());
1598 if (objClassName == targetClassName) {
1599 ::Info(
"xAOD::REvent::getNames",
1600 "Matched %s to key %s",
1601 targetClassName.c_str(),
key.c_str());
1610 const TObjArray *
out =
tree->GetListOfBranches();
1611 ::Info(
"xAOD::REvent::getNames",
"scanning output objects");
1615 if ( !
obj )
continue;
1616 const TBranch * element =
dynamic_cast<const TBranch*
>(
obj);
1618 ::Error(
"xAOD::REvent::getNames",
"Failure inspecting input objects");
1621 std::string objClassName = element->GetClassName();
1622 std::string
key =
obj->GetName();
1623 ::Info(
"xAOD::REvent::getNames",
1624 "Inspecting %s / %s",
1625 objClassName.c_str(),
key.c_str());
1626 if (objClassName == targetClassName) {
1627 ::Info(
"xAOD::REvent::getNames",
1628 "Matched %s to key %s",
1629 targetClassName.c_str(),
key.c_str());
1634 ::Info(
"xAOD::REvent::getNames",
"no output tree connected");
1643 ::Info(
"xAOD::REvent::getNames",
1644 "scanning output Aux objects for %s", targetClassName.c_str());
1645 for(
const auto&
object : outAux ) {
1649 if ( !
mgr )
continue;
1650 const std::string& objClassName =
mgr->holder()->getClass()->GetName();
1651 const std::string&
key =
object.first;
1652 ::Info(
"xAOD::REvent::getNames",
1653 "Inspecting %s / %s",
1654 objClassName.c_str(),
key.c_str());
1655 if (objClassName == targetClassName) {
1656 ::Info(
"xAOD::REvent::getNames",
1657 "Matched %s to key %s",
1658 targetClassName.c_str(),
key.c_str());
1663 vkeys.insert(vkeys.end(),
keys.begin(),
keys.end());
1693 static const std::string
dummy;
1708 const std::type_info& ti ) {
1712 if( !
name.length() ) {
1732 const std::type_info& ti,
1738 Warning(
"xAOD::REvent::getInputObject",
1739 "Key 0x%08x unknown",
key );
1758 ::Error(
"xAOD::REvent::initStats",
1761 return StatusCode::FAILURE;
1770 for( ; itr !=
end; ++itr ) {
1773 const std::string& branchName = itr->second.branchName();
1776 if( branchName.find(
"Aux." ) != std::string::npos ) {
1785 const std::string intName =
1786 branchName.substr( 0, branchName.size() - 4 );
1795 ::Bool_t auxFound = kFALSE;
1830 ::Warning(
"xAOD::REvent::initStats",
1831 "Couldn't find interface object/container "
1832 "\"%s\" belonging to branch \"%s\"",
1833 intName.c_str(), branchName.c_str() );
1840 ::TClass*
cl = ::TClass::GetClass(
el->className().c_str() );
1841 if( ( !
cl ) || ( !
cl->IsLoaded() ) ) {
1842 ::Warning(
"xAOD::REvent::initStats",
1843 "Couldn't find dictionary for type \"%s\"",
1844 el->className().c_str() );
1850 static const std::string baseName =
1852 static ::TClass*
const baseCl = ::TClass::GetClass( baseName.c_str() );
1854 ::Error(
"xAOD::REvent::initStats",
1856 "\"%s\"" ), baseName.c_str() );
1857 return StatusCode::FAILURE;
1867 static constexpr
bool TOP_STORE =
true;
1878 stats.branch(branchName,
id);
1897 return StatusCode::SUCCESS;
1913 const std::type_info& ti,
1921 Object_t::const_iterator itr =
objects.find(
key );
1943 if( ! itr->second->isSet() ) {
1951 ::Error(
"xAOD::REvent::getOutputObject",
1952 XAOD_MESSAGE(
"Object of wrong type found for key \"%s\"" ),
1958 void*
result =
mgr->holder()->getAs( ti );
1960 ::Warning(
"xAOD::REvent::getOutputObject",
1961 "Couldn't retrieve object as \"%s\"",
1983 const std::type_info& ti,
1988 std::string keyToUse =
key;
1993 keyToUse = remap_itr->second;
1999 if(
store &&
store->contains( keyToUse, ti ) &&
2000 store->isConst( keyToUse, ti ) ) {
2001 const void*
result =
store->getConstObject( keyToUse, ti );
2032 ::Fatal(
"xAOD::REvent::getInputObject",
2033 XAOD_MESSAGE(
"There is an internal logic error in the "
2050 if(
key == keyToUse ) {
2051 ::Error(
"xAOD::REvent::getInputObject",
2056 ::Error(
"xAOD::REvent::getInputObject",
2058 "\"%s\"/\"%s\"" ),
key.c_str(),
2065 if(
mgr->getEntry() ) {
2070 ::Error(
"xAOD::REvent::getInputObject",
2073 mgr->holder()->getClass()->GetName(),
2083 ::Warning(
"xAOD::REvent::getInputObject",
2084 "Could not retrieve object with key \"%s\" "
2085 "as \"%s\"", keyToUse.c_str(),
2097 ::Error(
"xAOD::REvent::getInputObject",
2098 XAOD_MESSAGE(
"Metadata is in RNTuple technology which is not yet implemented. key %s" ),
key.c_str() );
2106 if(
key == keyToUse ) {
2107 ::Error(
"xAOD::REvent::getInputObject",
2112 ::Error(
"xAOD::REvent::getInputObject",
2114 "\"%s\"/\"%s\"" ),
key.c_str(),
2124 ::Warning(
"xAOD::REvent::getInputObject",
2125 "Could not retrieve object with key \"%s\" "
2126 "as \"%s\"", keyToUse.c_str(),
2140 const std::string& ) {
2142 return StatusCode::SUCCESS;
2422 ::Error(
"xAOD::REvent::connectBranch",
2423 XAOD_MESSAGE(
"Function called on un-initialised object" ) );
2424 return StatusCode::FAILURE;
2432 return StatusCode::SUCCESS;
2437 ::Warning(
"xAOD::REvent::connectBranch",
2438 "Branch \"%s\" not available on input",
2441 return StatusCode::RECOVERABLE;
2449 auto key_to_read =
key;
2450 if (
key.rfind(
"Aux.") != std::string::npos) {
2452 std::replace(key_to_read.begin(), key_to_read.end(),
'.',
':');
2457 ::Warning(
"xAOD::REvent::connectBranch",
2458 "No metadata available for branch: %s ef key %s",
2459 key.c_str(), key_ef.c_str() );
2467 if (
m_inNtupleReader->GetDescriptor().FindFieldId(key_to_read.c_str()) == ROOT::kInvalidDescriptorId) {
2470 ::Warning(
"xAOD::REvent::connectBranch",
"Key \"%s\" not available on input",
key.c_str() );
2473 return StatusCode::RECOVERABLE;
2490 ::Error(
"xAOD::REvent::connectBranch",
2491 XAOD_MESSAGE(
"Couldn't find an appropriate type with a "
2492 "dictionary for branch \"%s\"" ),
2494 return StatusCode::FAILURE;
2497 ::TClass* realClass = ::TClass::GetClass(
className.c_str() );
2498 if( ( ( ! realClass ) || ( ! realClass->IsLoaded() ) ) &&
ef ) {
2503 realClass = ::TClass::GetClass(
className.c_str() );
2505 if( ( ! realClass ) || ( ! realClass->IsLoaded() ) ) {
2507 ::Error(
"xAOD::REvent::connectBranch",
2508 XAOD_MESSAGE(
"Couldn't find an appropriate type with a "
2509 "dictionary for branch \"%s\"" ),
2511 return StatusCode::FAILURE;
2547 ptr = realClass->New();
2566 if( !
hasAuxStore( *
mgr->holder() ) )
return StatusCode::SUCCESS;
2588 ::Error(
"xAOD::REvent::connectMetaBranch",
2589 XAOD_MESSAGE(
"Function called on un-initialised object" ) );
2590 return StatusCode::FAILURE;
2595 return StatusCode::SUCCESS;
2602 ::Warning(
"xAOD::REvent::connectMetaBranch",
2603 "Branch \"%s\" not available on input",
2606 return StatusCode::RECOVERABLE;
2610 if( !
br->GetEntries() ) {
2612 ::Warning(
"xAOD::REvent::connectMetaBranch",
2613 "Branch \"%s\" doesn't hold any data",
2616 return StatusCode::RECOVERABLE;
2620 br->SetMakeClass( 0 );
2624 ::EDataType
dt = kOther_t;
2625 if(
br->GetExpectedType(
cl,
dt ) || ( !
cl ) ) {
2626 ::Error(
"xAOD::REvent::connectMetaBranch",
2628 "branch %s" ),
key.c_str() );
2629 return StatusCode::FAILURE;
2633 void*
ptr =
cl->New();
2646 ::Error(
"xAOD::REvent::connectMetaBranch",
2647 XAOD_MESSAGE(
"Couldn't connect variable of type \"%s\" to "
2648 "input branch \"%s\". Return code: %i" ),
2654 return StatusCode::FAILURE;
2658 if(
mgr->getEntry() < 0 ) {
2659 ::Error(
"xAOD::REvent::connectMetaBranch",
2660 XAOD_MESSAGE(
"Couldn't read in metadata object with key "
2661 "\"%s\"" ),
key.c_str() );
2662 return StatusCode::FAILURE;
2672 if( !
hasAuxStore( *
mgr->holder() ) )
return StatusCode::SUCCESS;
2684 return StatusCode::SUCCESS;
2702 ::Error(
"xAOD::REvent::connectAux",
2704 return StatusCode::FAILURE;
2719 return StatusCode::SUCCESS;
2728 if( !
result.isSuccess() ) {
2729 ::Error(
"xAOD::REvent::connectAux",
XAOD_MESSAGE(
"Failed to execute connectBranch : for prefix %s" ),
2737 ::Fatal(
"xAOD::REvent::connectAux",
2743 ::Fatal(
"xAOD::REvent::connectAux",
2745 return StatusCode::FAILURE;
2749 static const TClass*
const holderClass =
2751 if( ! omgr->
holder()->
getClass()->InheritsFrom( holderClass ) ) {
2753 return StatusCode::SUCCESS;
2760 if( ! storeHolder ) {
2761 ::Fatal(
"xAOD::REvent::connectAux",
2772 ::Error(
"xAOD::REvent::connectAux",
2774 "for: %s" ),
prefix.c_str() );
2775 ::Error(
"xAOD::REvent::connectAux",
2776 XAOD_MESSAGE(
"standalone = %s, getStoreType() = %i" ),
2779 return StatusCode::FAILURE;
2783 return StatusCode::SUCCESS;
2804 return StatusCode::SUCCESS;
2808 ::Error(
"xAOD::REvent::connectAux",
2809 XAOD_MESSAGE(
"Unknown auxiliary access mode set (%i)" ),
2811 return StatusCode::FAILURE;
2828 return StatusCode::SUCCESS;
2833 ::Fatal(
"xAOD::REvent::connectMetaAux",
2835 return StatusCode::FAILURE;
2849 ::Fatal(
"xAOD::REvent::connectMetaAux",
2855 ::Fatal(
"xAOD::REvent::connectMetaAux",
2857 return StatusCode::FAILURE;
2861 static const TClass*
const holderClass =
2863 if( ! omgr->
holder()->
getClass()->InheritsFrom( holderClass ) ) {
2865 return StatusCode::SUCCESS;
2872 if( ! storeHolder ) {
2873 ::Fatal(
"xAOD::REvent::connectMetaAux",
2884 ::Error(
"xAOD::REvent::connectMetaAux",
2885 XAOD_MESSAGE(
"Requested store types inconsistent" ) );
2886 ::Error(
"xAOD::REvent::connectMetaAux",
2887 XAOD_MESSAGE(
"standalone = %s, getStoreType() = %i" ),
2890 return StatusCode::FAILURE;
2894 return StatusCode::SUCCESS;
2915 store->getEntry( 0 );
2918 return StatusCode::SUCCESS;
2922 ::Error(
"xAOD::REvent::connectMetaAux",
2923 XAOD_MESSAGE(
"Unknown auxiliary access mode set (%i)" ),
2925 return StatusCode::FAILURE;
2940 ::TMethodCall setNameCall;
2944 setNameCall.InitWithPrototype(
mgr.holder()->getClass(),
2945 "setName",
"const char*" );
2946 if( setNameCall.IsValid() ) {
2951 const char* charParams =
params.Data();
2952 setNameCall.Execute(
mgr.holder()->get(), charParams );
2955 ::Warning(
"xAOD::REvent::setUpDynamicStore",
2956 "Couldn't find setName(...) function for container %s "
2958 mgr.fieldName().c_str(),
2959 mgr.holder()->getClass()->GetName() );
2964 static const TClass*
const holderClass =
2966 if( !
mgr.holder()->getClass()->InheritsFrom( holderClass ) ) {
2968 return StatusCode::SUCCESS;
2975 if( ! storeHolder ) {
2976 ::Fatal(
"xAOD::REvent::setUpDynamicStore",
2978 return StatusCode::FAILURE;
2997 RETURN_CHECK(
"xAOD::REvent::setUpDynamicStore",
store->readFrom( *ntupleReader ) );
3009 return StatusCode::SUCCESS;
3025 ::TMethodCall setNameCall;
3029 setNameCall.InitWithPrototype(
mgr.holder()->getClass(),
3030 "setName",
"const char*" );
3031 if( setNameCall.IsValid() ) {
3036 const char* charParams =
params.Data();
3037 setNameCall.Execute(
mgr.holder()->get(), charParams );
3040 ::Warning(
"xAOD::REvent::setUpDynamicStore",
3041 "Couldn't find setName(...) function for container %s "
3043 mgr.branch()->GetName(),
3044 mgr.holder()->getClass()->GetName() );
3049 static const TClass*
const holderClass =
3051 if( !
mgr.holder()->getClass()->InheritsFrom( holderClass ) ) {
3053 return StatusCode::SUCCESS;
3060 if( ! storeHolder ) {
3061 ::Fatal(
"xAOD::REvent::setUpDynamicStore",
3063 return StatusCode::FAILURE;
3087 store->getEntry( 0 );
3093 return StatusCode::SUCCESS;
3111 return StatusCode::SUCCESS;
3115 const std::string
key =
mgr.fieldName();
3127 auxKey = std::move(
key);
3133 return StatusCode::SUCCESS;
3135 auxMgr = itr->second;
3137 auxKey =
key +
"Aux:";
3146 const std::string dynAuxKey = auxKey +
"Dynamic";
3147 auto dynAuxMgr =
objects.find( dynAuxKey );
3149 if( ( dynAuxMgr !=
objects.end() ) &&
3151 ( auxMgr == &
mgr ) ) ) {
3157 dynAuxMgr->second->getEntry();
3175 auto dynAuxMgr =
objects.find( dynAuxKey );
3176 if( dynAuxMgr ==
objects.end() ) {
3177 ::Error(
"xAOD::REvent::setAuxStore",
3179 return StatusCode::FAILURE;
3181 dynAuxMgr->second->getEntry();
3187 if( auxMgr == &
mgr ) {
3188 return StatusCode::SUCCESS;
3194 switch(
mgr.holder()->typeKind() ) {
3213 if(
vec && ( !
vec->trackIndices() ) ) {
3214 forceTrackIndices( *
vec );
3218 if( ( !
vec ) && ( ! aux ) ) {
3219 ::Fatal(
"xAOD::REvent::setAuxStore",
3221 "SG::AuxVectorBase or SG::AuxElement" ),
3222 mgr.holder()->getClass()->GetName() );
3231 ::Fatal(
"xAOD::REvent::setAuxStore",
3232 XAOD_MESSAGE(
"Auxiliary manager for \"%s\" is not of the "
3233 "right type" ), auxKey.c_str() );
3234 return StatusCode::FAILURE;
3250 ::Fatal(
"xAOD::REvent::setAuxStore",
3251 XAOD_MESSAGE(
"Auxiliary manager for \"%s\" is not of the "
3252 "right type" ), auxKey.c_str() );
3253 return StatusCode::FAILURE;
3260 ::Fatal(
"xAOD::REvent::setAuxStore",
3270 ::Fatal(
"xAOD::REvent::setAuxStore",
3275 return StatusCode::SUCCESS;
3290 return StatusCode::SUCCESS;
3294 const std::string
key =
mgr.branch()->GetName();
3305 auxKey = std::move(
key);
3311 return StatusCode::SUCCESS;
3313 auxMgr = itr->second;
3314 auxKey =
key +
"Aux.";
3359 if( auxMgr == &
mgr ) {
3360 return StatusCode::SUCCESS;
3366 switch(
mgr.holder()->typeKind() ) {
3385 if(
vec && ( !
vec->trackIndices() ) ) {
3386 forceTrackIndices( *
vec );
3390 if( ( !
vec ) && ( ! aux ) ) {
3391 ::Fatal(
"xAOD::REvent::setAuxStore",
3393 "SG::AuxVectorBase or SG::AuxElement" ),
3394 mgr.holder()->getClass()->GetName() );
3403 ::Fatal(
"xAOD::REvent::setAuxStore",
3404 XAOD_MESSAGE(
"Auxiliary manager for \"%s\" is not of the "
3405 "right type" ), auxKey.c_str() );
3406 return StatusCode::FAILURE;
3421 ::Fatal(
"xAOD::REvent::setAuxStore",
3422 XAOD_MESSAGE(
"Auxiliary manager for \"%s\" is not of the "
3423 "right type" ), auxKey.c_str() );
3424 return StatusCode::FAILURE;
3430 ::Fatal(
"xAOD::REvent::setAuxStore",
3440 ::Fatal(
"xAOD::REvent::setAuxStore",
3445 return StatusCode::SUCCESS;
3713 static const TClass*
const dvClass =
3715 static const TClass*
const aeClass =
3719 return ( holder.
getClass()->InheritsFrom( dvClass ) ||
3720 holder.
getClass()->InheritsFrom( aeClass ) );
3733 static const TClass*
const storeClass =
3735 static const TClass*
const storeHolderClass =
3739 return ( holder.
getClass()->InheritsFrom( storeClass ) ||
3740 holder.
getClass()->InheritsFrom( storeHolderClass ) );
3757 static const TClass*
const dvClass =
3759 static const TClass*
const aeClass =
3763 if( holder.
getClass()->InheritsFrom( aeClass ) ) {
3765 }
else if( holder.
getClass()->InheritsFrom( dvClass ) ) {
3770 ::Error(
"xAOD::REvent::isStandalone",
3772 "auxiliary store" ),
3788 const std::type_info& ti,
3807 const std::type_info& ti,
std::set< std::string > m_inputMissingObjects
Objects that have been asked for, but were found to be missing in the current input.
JetConstituentVector::iterator iterator
::Bool_t transientContains(const std::string &key) const
Function checking if an object is already in memory.
Base interface for getting objects out of the input file.
std::string replace(std::string s, const std::string &s2, const std::string &s3)
@ kBranchAccess
Access auxiliary data branch-by-branch.
Object_t m_outputObjects
Collection of all the managed output object.
@ AUXELEMENT
A type inheriting from SG::AuxElement.
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Tool for accessing xAOD files outside of Athena, version RNTuple.
void initAuxVectorBase(SG::OwnershipPolicy ownPolicy, SG::IndexTrackingPolicy indexTrackingPolicy)
Initialize index tracking mode.
virtual AuxStoreType getStoreType() const =0
Return the type of the store object.
::Bool_t contains(const std::string &key)
Function checking if an object is available from the store.
std::string find(const std::string &s)
return a remapped string
upgrade_mutex_t m_branchesMutex
StatusCode removeListener(TVirtualIncidentListener *listener)
Remove an incident listener object.
ReadStats & stats()
Access the object belonging to the current thread.
std::unordered_map< std::string, TVirtualManager * > Object_t
Definition of the internal data structure type.
std::string dump()
Function creating a user-readable dump of the current input.
TAuxStore * getStore()
Get a type-specific pointer to the managed object.
virtual const SG::auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
::Long64_t getEntries() const
Get how many entries are available from the current input file(s)
EAuxMode
Auxiliary store "mode".
void * getOutputObject(SG::sgkey_t key, const std::type_info &ti) override
This function is used by the TVirtualEvent interface to access an output object with a given hashed k...
static void setEvent(TVirtualEvent *ptr)
Set the active event pointer.
Manager for EDM objects created by ROOT.
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...
Base class for elements of a container that can have aux data.
const THolder * holder() const
Accessor to the Holder object.
@ DATAVECTOR
A DataVector container.
virtual void * getAs(const std::type_info &tid, ::Bool_t silent=kFALSE) const
Return the object as a specific pointer.
This class takes care of holding EDM objects in memory.
virtual ::Int_t getEntry(::Int_t getall=0)=0
Function for updating the object in memory if needed.
void Print(::Option_t *option="") const
Print information about the collected statistics.
EStructMode
"Structural" modes of the object
void ** getPtr()
Return a typeless pointer to the held object's pointer.
const void * get() const
Return a typeless const pointer to the held object.
@ ALWAYS_TRACK_INDICES
Always track indices, regardless of the setting of the ownership policy.
static IProxyDict * setStore(IProxyDict *store)
Set the current store.
Helper class for making sure the current directory is preserved.
"ROOT @c RNTuple implementation" of IAuxStore
#define NO_SANITIZE_UNDEFINED
const SG::IConstAuxStore * getConstStore() const
Get a convenience pointer to the managed object.
"ROOT @c TTree implementation" of IAuxStore
static TStore * store()
Access the currently active TStore object.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
static IProxyDict * store()
Fetch the current store.
Class providing an interface for classes listening to xAOD incidents.
std::vector< size_t > vec
Interface class for the "manager classes".
::Int_t getEntry(::Long64_t entry, ::Int_t getall=0)
Function loading a given entry of the input TTree.
void setPrintEventProxyWarnings(bool)
Function to silence warnings associated with broken element links.
@ kObjectStore
The object describes a single object.
EStructMode structMode() const
Get what structure mode the object was constructed with.
StatusCode addNameRemap(const std::string &onfile, const std::string &newName)
Add a name re-mapping rule.
Manage index tracking and synchronization of auxiliary data.
@ kContainerStore
The object describes an entire container.
Manage index tracking and synchronization of auxiliary data.
void nextEvent()
Function incrementing the processed event counter.
const ::TClass * getClass() const
static const char *const METADATA_TREE_NAME
Name of the metadata tree.
static TVirtualEvent * event()
Access the currently active TVirtualEvent object.
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
std::unordered_map< std::string, std::string > m_nameRemapping
Container name re-mapping rules.
size_t auxid_t
Identifier for a particular aux data item.
bit_t size() const
Count the number of 1 bits in the set.
void setStructMode(EStructMode mode)
Set the structure mode of the object to a new value.
StatusCode connectMetaBranch(const std::string &key, ::Bool_t silent=kFALSE)
Function setting up access to a branch in the metadata tree.
const void * getInputObject(SG::sgkey_t key, const std::type_info &ti, bool silent=false) override
Function for retrieving an input object in a non-template way.
::Bool_t hasAuxStore(const THolder &holder)
RDS: for the three following methods, moving to directly take THolder rather than have one for TObjec...
std::string getTypeName(const std::type_info &ti)
This function is necessary in order to create type names that ROOT can understand.
@ OWN_ELEMENTS
this data object owns its elements
@ kAthenaAccess
Access containers/objects like Athena does.
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
Interface providing I/O for a generic auxiliary store.
void printIOStats() const
Function printing the I/O statistics of the current process.
::StatusCode StatusCode
StatusCode definition for legacy code.
Class describing a certain "incident" that is communicated to user code.
Object_t m_inputObjects
Collection of all the managed input objects.
StatusCode record(void *obj, const std::string &typeName, const std::string &key)
Internal function for recording an object into the output.
::Bool_t isStandalone(const THolder &holder)
Function checking if an object is standalone (not a container)
SG::sgkey_t getHash(const std::string &key) const override
Function returning the hash describing an object name.
void printNameRemap() const
Print the current name re-mapping rules.
void setBranchNum(::Int_t num)
Set the total number of branches on the input.
@ kUndefinedAccess
Undefined, to be selected by the object.
::TTree * m_outTree
The tree that we are writing to.
StatusCode connectBranch(const std::string &key, ::Bool_t silent=kFALSE)
Function setting up access to a particular branch.
StatusCode setAuxStore(RObjectManager &mgr, ::Bool_t metadata=kFALSE)
Function connecting a DV object to its auxiliary store.
std::unique_ptr< ROOT::RNTupleReader > m_inNtupleReader
The main event reader: RNTupleReader.
static IOStats & instance()
Singleton object accessor.
EventFormat m_inputEventFormat
Format of the current input file.
static const ::Int_t CACHE_SIZE
Size of a possible TTreeCache (30 MB)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
virtual ~REvent()
Destructor.
void setActive() const
Set this event object as the currently active one.
StatusCode connectMetaAux(const std::string &prefix, ::Bool_t standalone)
Function setting up access to a set of auxiliary branches for a metadata object.
Listener_t m_listeners
Listeners who should be notified when certain incidents happen.
virtual void setStore(IAuxStore *store)=0
Give an auxiliary store object to the holder object.
void print(char *figname, TCanvas *c1)
void keys(std::vector< std::string > &vkeys, bool metadata=false) const
provide list of all keys associated with provided type.
StatusCode readFrom(ROOT::RNTupleReader &reader)
Connect the object to an input RNTuple.
EAuxMode m_auxMode
The auxiliary access mode.
void setAuxItemList(const std::string &containerKey, const std::string &itemList)
Configure which dynamic variables to write out for a given store.
REvent(EAuxMode mode=kUndefinedAccess)
Default constructor.
StatusCode setUpDynamicStore(TObjectManager &mgr, ::TTree *tree)
Function adding dynamic variable reading capabilities to an auxiliary store object metadata still use...
void readContainer(const std::string &name)
Function incrementing the read counter on a specific container.
Manager for EDM objects created by ROOT.
StatusCode readFrom(const std::string &fileName)
This function takes care of connecting the event object to a new input file.
SG::SGKeyMap< BranchInfo > m_branches ATLAS_THREAD_SAFE
Map from hashed sgkey to BranchInfo.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Manager for TAuxStore objects.
static PerfStats & instance()
Function accessing the singleton instance.
StatusCode addListener(TVirtualIncidentListener *listener)
Register an incident listener object.
::Long64_t m_entry
The entry to look at from the input tree.
A relatively simple transient store for objects created in analysis.
def silent(func)
Redirect stdout/err to /dev/null Useful wrapper to get rid of ROOT verbosity...
std::unordered_map< std::string, std::set< std::string > > m_auxItemList
Rules for selecting which auxiliary branches to write.
Bool_t m_printEventProxyWarnings
Option to silence common warnings that seem to be harmless.
std::string getFirstBranchMatch(TTree *tree, const std::string &pre)
This function is used to search for a branch in a TTree that contains a given substring.
Manager for RAuxStore objects.
const THolder * holder() const
Accessor to the Holder object.
::Bool_t m_inMetaTreeIsTTree
Boolean indicating the technology of the metadata tree, i.e. TTree of RNTuple.
void clearNameRemap()
Clear the current name re-mapping.
Handle mappings between names and auxid_t.
static const char *const EVENT_RNTUPLE_NAME
Name of the event tree.
@ kClassAccess
Access auxiliary data using the aux containers.
::Bool_t isAuxStore(const THolder &holder)
Function checking if a given object may be an auxiliary store.
@ kUndefinedStore
The structure mode is not defined.
Lock object for taking out upgradable locks.
Helper to disable undefined behavior sanitizer for a function.
SG::sgkey_t getKey(const void *obj) const override
Function returning the hash describing a known object.
StatusCode initStats()
Function to initialise the statistics for all Tree content.
const EventFormat * inputEventFormat() const
RDS: Only valid for TChains, i.e.
EventFormat * m_outputEventFormat
Format of the current output file.
Object_t m_inputMetaObjects
Collection of all the managed input meta-objects.
Class describing the access statistics of a collection of branches.
Interface for const operations on an auxiliary store.
const std::string & getName(const void *obj) const override
Function returning the key describing a known object.
void clearListeners()
Remove all listeners from the object.
@ AST_ObjectStore
The store describes a single object.
Interface for objects taking part in direct ROOT I/O.
SG::sgkey_t hash(const std::string &name)
This function provides a hashed version of the key (branch) names used in the xAOD file,...
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
const std::string & name() const override
Get the name of the instance.
::TTree * m_inMetaTree
Pointer to the metadata tree in the input file.
Object_t m_outputMetaObjects
Collection of all the managed output meta-objects.
EAuxMode auxMode() const
Get what auxiliary access mode the object was constructed with.
Base class for elements of a container that can have aux data.
void getNames(const std::string &targetClassName, std::vector< std::string > &vkeys, bool metadata=false) const override
Function determining the list keys associated with a type name.
StatusCode connectAux(const std::string &prefix, ::Bool_t standalone)
Function setting up access to a set of auxiliary branches.
@ AST_ContainerStore
The store describes a container.