From 45800a90fb184208fa0815bbad832fe488f650d8 Mon Sep 17 00:00:00 2001 From: Zach Marshall Date: Mon, 27 Jan 2020 15:54:17 +0100 Subject: [PATCH 1/4] Adding metadata for event overlay After a brief discussion on PAT-help, we decided it'd be helpful to include metadata for data overlay in the xAOD metadata object. This adds that metadata, as well as adding accessors and setters for booleans that have been stored as chars. In order to get the unit tests to behave, I had to make explicit the types in the setters and getters. I suspect this is just because we have too many options now, and the compiler is no longer able to automatically tell what we want. --- .../Root/FileMetaDataAccessors_v1.cxx | 25 +++++++ .../Root/FileMetaDataAccessors_v1.h | 4 ++ .../xAODMetaData/Root/FileMetaData_v1.cxx | 71 +++++++++++++++++++ .../ut_xaodmetadata_filemetadata_eq_test.cxx | 50 ++++++------- .../xAODMetaData/versions/FileMetaData_v1.h | 14 +++- .../src/FileMetaDataCreatorTool.cxx | 12 +++- 6 files changed, 149 insertions(+), 27 deletions(-) diff --git a/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.cxx b/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.cxx index 23911293eb1..5129ae2077b 100644 --- a/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.cxx +++ b/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.cxx @@ -26,6 +26,14 @@ return &acc; \ } while( 0 ) +/// Helper macro for implementing the accessor function +#define DECLARE_CHAR_ACCESSOR( TYPE ) \ + case FileMetaData_v1::TYPE: \ + do { \ + static SG::AuxElement::Accessor< char > acc( #TYPE ); \ + return &acc; \ + } while( 0 ) + namespace xAOD { SG::AuxElement::Accessor< std::string >* @@ -71,4 +79,21 @@ namespace xAOD { return 0; } + SG::AuxElement::Accessor< char >* + metaDataTypeCharAccessorV1( FileMetaData_v1::MetaDataType type ) { + + switch( type ) { + + DECLARE_CHAR_ACCESSOR( isDataOverlay ); + + default: + std::cerr << "xAOD::FileMetaData_v1 ERROR No float accessor for " + << "type: " << type << std::endl; + return 0; + } + + // Just to make sure the compiler doesn't complain: + return 0; + } + } // namespace xAOD diff --git a/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.h b/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.h index e5c463d74d2..a2010342a31 100644 --- a/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.h +++ b/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.h @@ -27,6 +27,10 @@ namespace xAOD { SG::AuxElement::Accessor< float >* metaDataTypeFloatAccessorV1( FileMetaData_v1::MetaDataType type ); + /// Helper function for getting an accessor for a pre-defined property + SG::AuxElement::Accessor< char >* + metaDataTypeCharAccessorV1( FileMetaData_v1::MetaDataType type ); + } // namespace xAOD #endif // XAODMETADATA_FILEMETADATAACCESSORS_V1_H diff --git a/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx b/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx index 90ad479372e..504172b4c8c 100644 --- a/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx +++ b/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx @@ -232,6 +232,73 @@ namespace xAOD { return true; } + + + bool FileMetaData_v1::value( MetaDataType type, bool& val ) const { + + // Get the accessor for this type: + Accessor< char >* acc = metaDataTypeCharAccessorV1( type ); + if( ! acc ) { + return false; + } + + // Check if the variable is available: + if( ! acc->isAvailable( *this ) ) { + return false; + } + + // Read the value: + val = ( *acc )( *this ); + + // We were successful: + return true; + } + + bool FileMetaData_v1::value( const std::string& type, + bool& val ) const { + + // Create an accessor object: + Accessor< char > acc( type ); + + // Check if this variable is available: + if( ! acc.isAvailable( *this ) ) { + return false; + } + + // Read the value: + val = acc( *this ); + + // We were successful: + return true; + } + + bool FileMetaData_v1::setValue( MetaDataType type, bool val ) { + + // Get the accessor for this type: + Accessor< char >* acc = metaDataTypeCharAccessorV1( type ); + if( ! acc ) { + return false; + } + + // Set the value: + ( *acc )( *this ) = val; + + // We were successful: + return true; + } + + bool FileMetaData_v1::setValue( const std::string& type, bool val ) { + + // Create the accessor object: + Accessor< char > acc( type ); + + // Set the value: + acc( *this ) = val; + + // We were successful: + return true; + } + } // namespace xAOD /// Helper macro used to print MetaDataType values @@ -253,6 +320,7 @@ std::ostream& operator<< ( std::ostream& out, switch( type ) { PRINT_TYPE( productionRelease ); + PRINT_TYPE( amiTag ); PRINT_TYPE( AODFixVersion ); PRINT_TYPE( AODCalibVersion ); PRINT_TYPE( dataType ); @@ -260,6 +328,9 @@ std::ostream& operator<< ( std::ostream& out, PRINT_TYPE( conditionsTag ); PRINT_TYPE( beamEnergy ); PRINT_TYPE( beamType ); + PRINT_TYPE( mcProcID ); + PRINT_TYPE( simFlavour ); + PRINT_TYPE( isDataOverlay ); default: out << "UNKNOWN (" << static_cast< int >( type ) << ")"; diff --git a/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx b/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx index 647ec50c5dd..28266562f31 100644 --- a/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx +++ b/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx @@ -39,30 +39,30 @@ int main() { // First, set them to equivalent values: SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::productionRelease, - "1.2.3" ) == true ); + std::string("1.2.3") ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::conditionsTag, - "Cond-1" ) == true ); + std::string("Cond-1") ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::beamEnergy, - 123.456 ) == true ); + float(123.456) ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::productionRelease, - "1.2.3" ) == true ); + std::string("1.2.3") ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::conditionsTag, - "Cond-1" ) == true ); + std::string("Cond-1") ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::beamEnergy, - 123.456 ) == true ); + float(123.456) ) == true ); // And then check their equivalency: SIMPLE_ASSERT( meta1 == meta2 ); // Make sure that minor floating point differences are overlooked: SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::beamEnergy, - 123.455999 ) == true ); + float(123.455999) ) == true ); SIMPLE_ASSERT( meta1 == meta2 ); // Now check that a difference is also found: SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::productionRelease, - "1.2.4" ) == true ); + std::string("1.2.4") ) == true ); SIMPLE_ASSERT( meta1 != meta2 ); // Clear out the two objects: @@ -73,18 +73,18 @@ int main() { // Set them up with different types of properties: SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::productionRelease, - "1.2.3" ) == true ); + std::string("1.2.3") ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::conditionsTag, - "Cond-1" ) == true ); + std::string("Cond-1") ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::beamEnergy, - 123.456 ) == true ); + float(123.456) ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::productionRelease, - "1.2.3" ) == true ); + std::string("1.2.3") ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::conditionsTag, - "Cond-1" ) == true ); + std::string("Cond-1") ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::beamType, - "Collision" ) == true ); + std::string("Collision") ) == true ); // Check that they are not equivalent: SIMPLE_ASSERT( meta1 != meta2 ); @@ -97,33 +97,33 @@ int main() { // Now try using some custom variables as well: SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::productionRelease, - "1.2.3" ) == true ); + std::string("1.2.3") ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::conditionsTag, - "Cond-1" ) == true ); - SIMPLE_ASSERT( meta1.setValue( "AnalysisType", "SUSY" ) == true ); + std::string("Cond-1") ) == true ); + SIMPLE_ASSERT( meta1.setValue( "AnalysisType", std::string("SUSY") ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::productionRelease, - "1.2.3" ) == true ); + std::string("1.2.3") ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::conditionsTag, - "Cond-1" ) == true ); - SIMPLE_ASSERT( meta2.setValue( "AnalysisType", "SUSY" ) == true ); + std::string("Cond-1") ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisType", std::string("SUSY") ) == true ); SIMPLE_ASSERT( meta1 == meta2 ); // And check whether a difference in a user type is detected: - SIMPLE_ASSERT( meta2.setValue( "AnalysisType", "Higgs" ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisType", std::string("Higgs") ) == true ); SIMPLE_ASSERT( meta1 != meta2 ); // Try it for a floating point difference as well: - SIMPLE_ASSERT( meta2.setValue( "AnalysisType", "SUSY" ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisType", std::string("SUSY") ) == true ); SIMPLE_ASSERT( meta1 == meta2 ); - SIMPLE_ASSERT( meta1.setValue( "AnalysisValue", 1.2 ) == true ); - SIMPLE_ASSERT( meta2.setValue( "AnalysisValue", 1.3 ) == true ); + SIMPLE_ASSERT( meta1.setValue( "AnalysisValue", float(1.2) ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisValue", float(1.3) ) == true ); SIMPLE_ASSERT( meta1 != meta2 ); // Finally, set an unsupported variable type on the objects, and check that // the code complains about them. But still lets the equivalence stand. - SIMPLE_ASSERT( meta2.setValue( "AnalysisValue", 1.2 ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisValue", float(1.2) ) == true ); SIMPLE_ASSERT( meta1 == meta2 ); meta1.auxdata< int >( "IntValue" ) = 1; meta2.auxdata< int >( "IntValue" ) = 2; diff --git a/Event/xAOD/xAODMetaData/xAODMetaData/versions/FileMetaData_v1.h b/Event/xAOD/xAODMetaData/xAODMetaData/versions/FileMetaData_v1.h index b04f98f3c7c..00e2bbfa1a8 100644 --- a/Event/xAOD/xAODMetaData/xAODMetaData/versions/FileMetaData_v1.h +++ b/Event/xAOD/xAODMetaData/xAODMetaData/versions/FileMetaData_v1.h @@ -68,8 +68,10 @@ namespace xAOD { mcProcID = 9, /// Fast or Full sim [string] simFlavour = 10, + /// Used data overlay for backgrounds [bool] + isDataOverlay = 11, /// End marker - END = 11 + END = 12 }; // enum MetaDataType /// Get a pre-defined string value out of the object @@ -92,6 +94,16 @@ namespace xAOD { /// Set a generic float value on the object bool setValue( const std::string& type, float val ); + /// Get a pre-defined bool value out of the object + bool value( MetaDataType type, bool& val ) const; + /// Get a generic bool value out of the object + bool value( const std::string& type, bool& val ) const; + + /// Set a pre-defined bool value on the object + bool setValue( MetaDataType type, bool val ); + /// Set a generic bool value on the object + bool setValue( const std::string& type, bool val ); + }; // class FileMetaData_v1 } // namespace xAOD diff --git a/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataCreatorTool.cxx b/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataCreatorTool.cxx index 74649af3406..90440dcc708 100644 --- a/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataCreatorTool.cxx +++ b/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataCreatorTool.cxx @@ -223,7 +223,7 @@ namespace xAODMaker { } else { ATH_MSG_WARNING("Did not find beam_energy in TagInfo setting to -1"); - CHECK_BOOL( m_md->setValue( xAOD::FileMetaData::beamEnergy, -1.0 ) ); + CHECK_BOOL( m_md->setValue( xAOD::FileMetaData::beamEnergy, float(-1.0) ) ); } if (al.exists("beam_type")) { @@ -249,6 +249,16 @@ namespace xAODMaker { else { ATH_MSG_ERROR("Unable to retrieve SimulationFlavour from " << SIMFOLDER_NAME); } + + if (simInfo->exists("IsEventOverlayInputSim")) { + bool isDataOverlay = (*simInfo)[ "IsEventOverlayInputSim" ].data< bool >(); + CHECK_BOOL( m_md->setValue( xAOD::FileMetaData::isDataOverlay, + isDataOverlay ) ); + } + else { + ATH_MSG_ERROR("Unable to retrieve IsEventOverlayInputSim from " << SIMFOLDER_NAME); + } + } // Return gracefully: -- GitLab From 58def9c6ce8436efd58fbda7d3b0891da8bd1879 Mon Sep 17 00:00:00 2001 From: Zach Marshall Date: Mon, 27 Jan 2020 17:06:24 +0100 Subject: [PATCH 2/4] Fixing const and adding to else-ifs --- .../Root/FileMetaDataAccessors_v1.cxx | 14 +++---- .../Root/FileMetaDataAccessors_v1.h | 6 +-- .../xAODMetaData/Root/FileMetaData_v1.cxx | 37 ++++++++++++------- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.cxx b/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.cxx index 5129ae2077b..05c046581eb 100644 --- a/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.cxx +++ b/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.cxx @@ -14,7 +14,7 @@ #define DECLARE_STRING_ACCESSOR( TYPE ) \ case FileMetaData_v1::TYPE: \ do { \ - static SG::AuxElement::Accessor< std::string > acc( #TYPE ); \ + const static SG::AuxElement::Accessor< std::string > acc( #TYPE ); \ return &acc; \ } while( 0 ) @@ -22,7 +22,7 @@ #define DECLARE_FLOAT_ACCESSOR( TYPE ) \ case FileMetaData_v1::TYPE: \ do { \ - static SG::AuxElement::Accessor< float > acc( #TYPE ); \ + const static SG::AuxElement::Accessor< float > acc( #TYPE ); \ return &acc; \ } while( 0 ) @@ -30,13 +30,13 @@ #define DECLARE_CHAR_ACCESSOR( TYPE ) \ case FileMetaData_v1::TYPE: \ do { \ - static SG::AuxElement::Accessor< char > acc( #TYPE ); \ + const static SG::AuxElement::Accessor< char > acc( #TYPE ); \ return &acc; \ } while( 0 ) namespace xAOD { - SG::AuxElement::Accessor< std::string >* + const SG::AuxElement::Accessor< std::string >* metaDataTypeStringAccessorV1( FileMetaData_v1::MetaDataType type ) { switch( type ) { @@ -61,7 +61,7 @@ namespace xAOD { return 0; } - SG::AuxElement::Accessor< float >* + const SG::AuxElement::Accessor< float >* metaDataTypeFloatAccessorV1( FileMetaData_v1::MetaDataType type ) { switch( type ) { @@ -79,7 +79,7 @@ namespace xAOD { return 0; } - SG::AuxElement::Accessor< char >* + const SG::AuxElement::Accessor< char >* metaDataTypeCharAccessorV1( FileMetaData_v1::MetaDataType type ) { switch( type ) { @@ -87,7 +87,7 @@ namespace xAOD { DECLARE_CHAR_ACCESSOR( isDataOverlay ); default: - std::cerr << "xAOD::FileMetaData_v1 ERROR No float accessor for " + std::cerr << "xAOD::FileMetaData_v1 ERROR No char accessor for " << "type: " << type << std::endl; return 0; } diff --git a/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.h b/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.h index a2010342a31..a07f57311b8 100644 --- a/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.h +++ b/Event/xAOD/xAODMetaData/Root/FileMetaDataAccessors_v1.h @@ -20,15 +20,15 @@ namespace xAOD { /// Helper function for getting an accessor for a pre-defined property - SG::AuxElement::Accessor< std::string >* + const SG::AuxElement::Accessor< std::string >* metaDataTypeStringAccessorV1( FileMetaData_v1::MetaDataType type ); /// Helper function for getting an accessor for a pre-defined property - SG::AuxElement::Accessor< float >* + const SG::AuxElement::Accessor< float >* metaDataTypeFloatAccessorV1( FileMetaData_v1::MetaDataType type ); /// Helper function for getting an accessor for a pre-defined property - SG::AuxElement::Accessor< char >* + const SG::AuxElement::Accessor< char >* metaDataTypeCharAccessorV1( FileMetaData_v1::MetaDataType type ); } // namespace xAOD diff --git a/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx b/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx index 504172b4c8c..6f7c41a701c 100644 --- a/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx +++ b/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx @@ -57,7 +57,8 @@ namespace xAOD { // Only compare the string and float properties for now: if( ( *ti != typeid( std::string ) ) && - ( *ti != typeid( float ) ) ) { + ( *ti != typeid( float ) ) && + ( *ti != typeid( char ) ) ) { continue; } @@ -85,6 +86,16 @@ namespace xAOD { return false; } + } else if( *ti == typeid( char ) ) { + + // Retrieve the values: + const char& value1 = this->auxdata< char >( name ); + const char& value2 = rhs.auxdata< char >( name ); + // And (not so simply) compare them: + if( value1 != value2 ) { + return false; + } + } else { // We should really never end up here unless a coding mistake was // made upstream. @@ -104,7 +115,7 @@ namespace xAOD { bool FileMetaData_v1::value( MetaDataType type, std::string& val ) const { // Get the accessor for this type: - Accessor< std::string >* acc = metaDataTypeStringAccessorV1( type ); + const Accessor< std::string >* acc = metaDataTypeStringAccessorV1( type ); if( ! acc ) { return false; } @@ -125,7 +136,7 @@ namespace xAOD { std::string& val ) const { // Create an accessor object: - Accessor< std::string > acc( type ); + const Accessor< std::string > acc( type ); // Check if this variable is available: if( ! acc.isAvailable( *this ) ) { @@ -142,7 +153,7 @@ namespace xAOD { bool FileMetaData_v1::setValue( MetaDataType type, const std::string& val ) { // Get the accessor for this type: - Accessor< std::string >* acc = metaDataTypeStringAccessorV1( type ); + const Accessor< std::string >* acc = metaDataTypeStringAccessorV1( type ); if( ! acc ) { return false; } @@ -158,7 +169,7 @@ namespace xAOD { const std::string& val ) { // Create the accessor object: - Accessor< std::string > acc( type ); + const Accessor< std::string > acc( type ); // Set the value: acc( *this ) = val; @@ -170,7 +181,7 @@ namespace xAOD { bool FileMetaData_v1::value( MetaDataType type, float& val ) const { // Get the accessor for this type: - Accessor< float >* acc = metaDataTypeFloatAccessorV1( type ); + const Accessor< float >* acc = metaDataTypeFloatAccessorV1( type ); if( ! acc ) { return false; } @@ -191,7 +202,7 @@ namespace xAOD { float& val ) const { // Create an accessor object: - Accessor< float > acc( type ); + const Accessor< float > acc( type ); // Check if this variable is available: if( ! acc.isAvailable( *this ) ) { @@ -208,7 +219,7 @@ namespace xAOD { bool FileMetaData_v1::setValue( MetaDataType type, float val ) { // Get the accessor for this type: - Accessor< float >* acc = metaDataTypeFloatAccessorV1( type ); + const Accessor< float >* acc = metaDataTypeFloatAccessorV1( type ); if( ! acc ) { return false; } @@ -223,7 +234,7 @@ namespace xAOD { bool FileMetaData_v1::setValue( const std::string& type, float val ) { // Create the accessor object: - Accessor< float > acc( type ); + const Accessor< float > acc( type ); // Set the value: acc( *this ) = val; @@ -237,7 +248,7 @@ namespace xAOD { bool FileMetaData_v1::value( MetaDataType type, bool& val ) const { // Get the accessor for this type: - Accessor< char >* acc = metaDataTypeCharAccessorV1( type ); + const Accessor< char >* acc = metaDataTypeCharAccessorV1( type ); if( ! acc ) { return false; } @@ -258,7 +269,7 @@ namespace xAOD { bool& val ) const { // Create an accessor object: - Accessor< char > acc( type ); + const Accessor< char > acc( type ); // Check if this variable is available: if( ! acc.isAvailable( *this ) ) { @@ -275,7 +286,7 @@ namespace xAOD { bool FileMetaData_v1::setValue( MetaDataType type, bool val ) { // Get the accessor for this type: - Accessor< char >* acc = metaDataTypeCharAccessorV1( type ); + const Accessor< char >* acc = metaDataTypeCharAccessorV1( type ); if( ! acc ) { return false; } @@ -290,7 +301,7 @@ namespace xAOD { bool FileMetaData_v1::setValue( const std::string& type, bool val ) { // Create the accessor object: - Accessor< char > acc( type ); + const Accessor< char > acc( type ); // Set the value: acc( *this ) = val; -- GitLab From 958ac370365d589994e117023b2e610bfb78f748 Mon Sep 17 00:00:00 2001 From: Zach Marshall Date: Mon, 27 Jan 2020 17:10:21 +0100 Subject: [PATCH 3/4] Not throwing an error when metadata is missing --- Event/xAOD/xAODMetaDataCnv/src/FileMetaDataCreatorTool.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataCreatorTool.cxx b/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataCreatorTool.cxx index 90440dcc708..c3a613df882 100644 --- a/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataCreatorTool.cxx +++ b/Event/xAOD/xAODMetaDataCnv/src/FileMetaDataCreatorTool.cxx @@ -256,7 +256,8 @@ namespace xAODMaker { isDataOverlay ) ); } else { - ATH_MSG_ERROR("Unable to retrieve IsEventOverlayInputSim from " << SIMFOLDER_NAME); + ATH_MSG_INFO("Unable to retrieve IsEventOverlayInputSim from " << SIMFOLDER_NAME << " - assuming not data overlay"); + CHECK_BOOL( m_md->setValue( xAOD::FileMetaData::isDataOverlay, false ) ); } } -- GitLab From d29d1c724e601176d69beb08992fca5b20788d32 Mon Sep 17 00:00:00 2001 From: Zach Marshall Date: Tue, 28 Jan 2020 09:37:41 +0100 Subject: [PATCH 4/4] Moving to string literal operator --- .../ut_xaodmetadata_filemetadata_eq_test.cxx | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx b/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx index 28266562f31..ff99cba1dec 100644 --- a/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx +++ b/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx @@ -13,6 +13,7 @@ // System include(s): #include +#include // Local include(s): #include "xAODMetaData/FileMetaData.h" @@ -30,6 +31,8 @@ } while( 0 ) int main() { + // For the string literals operator s + using namespace std::string_literals; // Set up two objects with their private auxiliary stores, which will be // used in the tests: @@ -39,30 +42,30 @@ int main() { // First, set them to equivalent values: SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::productionRelease, - std::string("1.2.3") ) == true ); + "1.2.3"s ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::conditionsTag, - std::string("Cond-1") ) == true ); + "Cond-1"s ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::beamEnergy, - float(123.456) ) == true ); + 123.456f ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::productionRelease, - std::string("1.2.3") ) == true ); + "1.2.3"s ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::conditionsTag, - std::string("Cond-1") ) == true ); + "Cond-1"s ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::beamEnergy, - float(123.456) ) == true ); + 123.456f ) == true ); // And then check their equivalency: SIMPLE_ASSERT( meta1 == meta2 ); // Make sure that minor floating point differences are overlooked: SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::beamEnergy, - float(123.455999) ) == true ); + 123.455999f ) == true ); SIMPLE_ASSERT( meta1 == meta2 ); // Now check that a difference is also found: SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::productionRelease, - std::string("1.2.4") ) == true ); + "1.2.4"s ) == true ); SIMPLE_ASSERT( meta1 != meta2 ); // Clear out the two objects: @@ -73,18 +76,18 @@ int main() { // Set them up with different types of properties: SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::productionRelease, - std::string("1.2.3") ) == true ); + "1.2.3"s ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::conditionsTag, - std::string("Cond-1") ) == true ); + "Cond-1"s ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::beamEnergy, - float(123.456) ) == true ); + 123.456f ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::productionRelease, - std::string("1.2.3") ) == true ); + "1.2.3"s ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::conditionsTag, - std::string("Cond-1") ) == true ); + "Cond-1"s ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::beamType, - std::string("Collision") ) == true ); + "Collision"s ) == true ); // Check that they are not equivalent: SIMPLE_ASSERT( meta1 != meta2 ); @@ -97,33 +100,33 @@ int main() { // Now try using some custom variables as well: SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::productionRelease, - std::string("1.2.3") ) == true ); + "1.2.3"s ) == true ); SIMPLE_ASSERT( meta1.setValue( xAOD::FileMetaData::conditionsTag, - std::string("Cond-1") ) == true ); - SIMPLE_ASSERT( meta1.setValue( "AnalysisType", std::string("SUSY") ) == true ); + "Cond-1"s ) == true ); + SIMPLE_ASSERT( meta1.setValue( "AnalysisType", "SUSY"s ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::productionRelease, - std::string("1.2.3") ) == true ); + "1.2.3"s ) == true ); SIMPLE_ASSERT( meta2.setValue( xAOD::FileMetaData::conditionsTag, - std::string("Cond-1") ) == true ); - SIMPLE_ASSERT( meta2.setValue( "AnalysisType", std::string("SUSY") ) == true ); + "Cond-1"s ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisType", "SUSY"s ) == true ); SIMPLE_ASSERT( meta1 == meta2 ); // And check whether a difference in a user type is detected: - SIMPLE_ASSERT( meta2.setValue( "AnalysisType", std::string("Higgs") ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisType", "Higgs"s ) == true ); SIMPLE_ASSERT( meta1 != meta2 ); // Try it for a floating point difference as well: - SIMPLE_ASSERT( meta2.setValue( "AnalysisType", std::string("SUSY") ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisType", "SUSY"s ) == true ); SIMPLE_ASSERT( meta1 == meta2 ); - SIMPLE_ASSERT( meta1.setValue( "AnalysisValue", float(1.2) ) == true ); - SIMPLE_ASSERT( meta2.setValue( "AnalysisValue", float(1.3) ) == true ); + SIMPLE_ASSERT( meta1.setValue( "AnalysisValue", 1.2f ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisValue", 1.3f ) == true ); SIMPLE_ASSERT( meta1 != meta2 ); // Finally, set an unsupported variable type on the objects, and check that // the code complains about them. But still lets the equivalence stand. - SIMPLE_ASSERT( meta2.setValue( "AnalysisValue", float(1.2) ) == true ); + SIMPLE_ASSERT( meta2.setValue( "AnalysisValue", 1.2f ) == true ); SIMPLE_ASSERT( meta1 == meta2 ); meta1.auxdata< int >( "IntValue" ) = 1; meta2.auxdata< int >( "IntValue" ) = 2; -- GitLab