13#include <ROOT/RNTupleDescriptor.hxx>
33 void removeDefaultTemplateParameters( std::string& name,
34 const std::string& vectorName ) {
37 while( ( vecPos =
name.find( vectorName +
"<", vecPos ) ) !=
41 vecPos += ( vectorName.size() + 1 );
46 size_t commaPos = std::string::npos;
47 for(
size_t pos = vecPos;
pos <
name.size(); ++
pos ) {
48 switch( name[ pos ] ) {
63 if( commaPos != std::string::npos ) {
69 if( commaPos == std::string::npos ) {
75 size_t closingPos = std::string::npos;
76 for(
size_t pos = commaPos;
pos <
name.size(); ++
pos ) {
77 switch( name[ pos ] ) {
91 if( closingPos != std::string::npos ) {
97 if( closingPos == std::string::npos ) {
98 ::Error(
"removeDefaultTemplateParameters",
105 name.erase( commaPos, closingPos - commaPos );
130 static constexpr SG::sgkey_t MASK = (~static_cast<SG::sgkey_t>(0)) >> 2;
133 static const std::hash< std::string > helper;
150 std::string result = key;
154 if( result[ result.size() - 1 ] ==
'.' ) {
155 result.replace( result.size() - 1, 1,
"Dyn." );
175 std::string result = key;
179 if( result[ result.size() - 1 ] ==
':' ) {
180 result.replace( result.size() - 1, 1,
"Dyn:" );
203 return typeid( Char_t );
205 return typeid( UChar_t );
207 return typeid( Short_t );
209 return typeid( UShort_t );
212 return typeid( Int_t );
215 case kDataTypeAliasUnsigned_t:
216 return typeid( UInt_t );
218 return typeid( Long_t );
220 return typeid( ULong_t );
222 return typeid( Float_t );
224 return typeid( Double_t );
226 return typeid( Double32_t );
228 return typeid( Bool_t );
230 return typeid( Long64_t );
232 return typeid( ULong64_t );
234 return typeid( Float16_t );
236 return typeid(
char* );
238 return typeid( void );
240 ::Error(
"xAOD::Utils::getTypeInfo",
242 static_cast< int >(
type ) );
243 return typeid( void );
248#define TYPE_CHECK_INSTANTIATE(MACRO) \
250 MACRO(std::uint8_t) \
251 MACRO(std::int16_t) \
252 MACRO(std::uint16_t) \
253 MACRO(std::int32_t) \
254 MACRO(std::uint32_t) \
255 MACRO(std::int64_t) \
256 MACRO(std::uint64_t) \
263#define GETTYPEINFO_SPECIALIZE(TYPE) \
264 if(typeName == #TYPE) { \
265 return typeid(TYPE); \
270 ::Error(
"xAOD::Utils::getTypeInfo",
276#undef GETTYPEINFO_SPECIALIZE
278#define ISPRIMITIVETYPE_SPECIALIZE(TYPE) \
279 if(typeName == #TYPE) { \
288#undef ISPRIMITIVETYPE_SPECIALIZE
289#undef TYPE_CHECK_INSTANTIATE
301 switch( typeidType ) {
340 Error(
"xAOD::Utils::rootType",
341 XAOD_MESSAGE(
"Received an unknown type: %c" ), typeidType );
360 std::string result = AthContainers_detail::typeinfoName( ti );
364 if( ( result.find(
"DataVector<" ) == std::string::npos ) &&
365 ( result.find(
"std::vector<" ) == std::string::npos ) &&
366 ( result.find(
"std::__1::vector<") == std::string::npos ) ) {
371 removeDefaultTemplateParameters( result,
"DataVector" );
372 removeDefaultTemplateParameters( result,
"std::vector" );
373 removeDefaultTemplateParameters( result,
"std::__1::vector" );
377 while( ( pos = result.find(
">>" ) ) != std::string::npos ) {
378 result.replace( pos, 2,
"> >" );
382 while( ( pos = result.find(
"__1::" ) ) != std::string::npos ) {
383 result.replace( pos, 5,
"" );
398 const std::string& pre ) {
399 const TObjArray * pBranches =
tree->GetListOfBranches();
400 const std::regex pattern(
".*" + pre +
".*" );
402 for(
int i = 0, nLast = pBranches->GetLast(); i <= nLast; ++i ) {
403 const std::string
name = pBranches->At(i)->GetName();
405 if( std::regex_match(
name, pattern ) )
427 const std::string& key ) {
429 std::string fieldName = key;
430 if( fieldName.ends_with(
"Aux." ) ) {
431 fieldName.back() =
':';
433 if( descriptor.FindFieldId( fieldName ) !=
434 ROOT::kInvalidDescriptorId ) {
440 std::replace_if( fieldName.begin(), fieldName.end(),
441 [](
unsigned char c ) { return !std::isalnum( c ); },
443 if( fieldName.ends_with(
"Aux_" ) ) {
444 fieldName.back() =
':';
#define TYPE_CHECK_INSTANTIATE(MACRO)
Macro instantiating another macro for all usual "primitive" types.
#define ISPRIMITIVETYPE_SPECIALIZE(TYPE)
#define GETTYPEINFO_SPECIALIZE(TYPE)
Macro returning the type info for a given type name.
Helper for emitting error messages.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
const std::type_info & getTypeInfo(EDataType type)
This function is used when reading a primitive branch from an input file without the user explicitly ...
SG::sgkey_t hash(const std::string &name)
This function provides a hashed version of the key (branch) names used in the xAOD file,...
std::string dynBranchPrefix(const std::string &key)
This function is used to figure out what to name dynamic auxiliary branches coming from a container c...
char rootType(char typeidType)
This function is used internally in the code when creating primitive dynamic auxiliary branches.
std::string getFieldName(const ROOT::RNTupleDescriptor &descriptor, const std::string &key)
This function is used to find the name of the field in an RNTuple that stores the object with a given...
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.
bool isPrimitiveType(std::string_view typeName)
Check if the type name describes a primitive type.
std::string getTypeName(const std::type_info &ti)
This function is necessary in order to create type names that ROOT can understand.
std::string dynFieldPrefix(const std::string &key)
This function is used to figure out what to name dynamic auxiliary field coming from a container call...
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.