diff --git a/Event/xAOD/xAODEventInfo/Root/EventInfoAuxContainer_v1.cxx b/Event/xAOD/xAODEventInfo/Root/EventInfoAuxContainer_v1.cxx index 7a21219d864a0424cb3708ebb2b37bd5754c8ec8..bc92ea14dec3557c62dd4bcd70171a38e802eef4 100644 --- a/Event/xAOD/xAODEventInfo/Root/EventInfoAuxContainer_v1.cxx +++ b/Event/xAOD/xAODEventInfo/Root/EventInfoAuxContainer_v1.cxx @@ -44,6 +44,10 @@ namespace xAOD { AUX_VARIABLE( mcChannelNumber ); AUX_VARIABLE( mcEventNumber ); AUX_VARIABLE( mcEventWeights ); + + // Pileup information: + AUX_VARIABLE( pileUpMixtureIDLowBits ); + AUX_VARIABLE( pileUpMixtureIDHighBits ); } } // namespace xAOD diff --git a/Event/xAOD/xAODEventInfo/Root/EventInfo_v1.cxx b/Event/xAOD/xAODEventInfo/Root/EventInfo_v1.cxx index d2499c7f22da232b2941a3c7406a5280ca097646..35708c8b8ad36ada25e1863c2ff6adb42daccb78 100644 --- a/Event/xAOD/xAODEventInfo/Root/EventInfo_v1.cxx +++ b/Event/xAOD/xAODEventInfo/Root/EventInfo_v1.cxx @@ -346,6 +346,37 @@ namespace xAOD { AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( EventInfo_v1, float, averageInteractionsPerCrossing, setAverageInteractionsPerCrossing ) + + AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( EventInfo_v1, unsigned long long, + pileUpMixtureIDLowBits, + setPileUpMixtureIDLowBits ) + AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( EventInfo_v1, unsigned long long, + pileUpMixtureIDHighBits, + setPileUpMixtureIDHighBits ) + + EventInfo_v1::PileUpMixtureID EventInfo_v1::pileUpMixtureID() const { + + static Accessor< unsigned long long > accLow( "pileUpMixtureIDLowBits" ); + static Accessor< unsigned long long > accHigh( "pileUpMixtureIDHighBits" ); + + PileUpMixtureID id{}; + + // We need to check if the values are actually stored + if ( accLow.isAvailable( *this ) && accHigh.isAvailable( *this ) ) { + id.lowBits = pileUpMixtureIDLowBits(); + id.highBits = pileUpMixtureIDHighBits(); + } + + return id; + + } + + void EventInfo_v1::setPileUpMixtureID( const PileUpMixtureID& value ) { + + setPileUpMixtureIDLowBits( value.lowBits ); + setPileUpMixtureIDHighBits( value.highBits ); + + } EventInfo_v1::SubEvent:: SubEvent( int16_t time, uint16_t index, PileUpType type, @@ -832,4 +863,48 @@ namespace xAOD { return out; } + /// This operator is provided to make it convenient to print debug messages + /// including information about the PileUpMixtureID in hex. + /// + /// @param out The output stream to write PileUpMixtureID information to + /// @param id The PileUpMixtureID object to print information about + /// @returns The same output stream that the operator received + /// + std::ostream& operator<<( std::ostream &out, + const xAOD::EventInfo_v1::PileUpMixtureID& id ) { + + // Get the current state of the stream: + const char fillChar = out.fill(); + const std::ios_base::fmtflags flags = out.flags(); + const std::streamsize width = out.width(); + + // Do the printout: + out << std::hex << std::setw( 16 ) << std::setfill( '0' ); + out << id.lowBits; + out << id.highBits; + + // Restore the original state of the stream: + out.fill( fillChar ); + out.flags( flags ); + out.width( width ); + + + // Return the stream: + return out; + } + + /// This operator is provided to make it convenient to compare two + /// instances of PileUpMixtureID directly. + /// + /// @param a The PileUpMixtureID object to compare + /// @param b The PileUpMixtureID object to compare + /// @returns Comparison result + /// + bool operator== ( const xAOD::EventInfo_v1::PileUpMixtureID& a, + const xAOD::EventInfo_v1::PileUpMixtureID& b ) { + + return a.lowBits == b.lowBits && a.highBits == b.highBits; + + } + } // namespace xAOD diff --git a/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfoAuxContainer_v1.h b/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfoAuxContainer_v1.h index c9aeaa12abe398c196549b372cd2e74040af66f4..a60369ca55e3e4fa17208965291ec4e644358795 100644 --- a/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfoAuxContainer_v1.h +++ b/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfoAuxContainer_v1.h @@ -79,6 +79,12 @@ namespace xAOD { std::vector< std::vector< float > > mcEventWeights; /// @} + /// @name Pileup information + /// @{ + std::vector< unsigned long long > pileUpMixtureIDLowBits; + std::vector< unsigned long long > pileUpMixtureIDHighBits; + /// @} + }; // class EventInfoAuxContainer_v1 } // namespace xAOD diff --git a/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfo_v1.h b/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfo_v1.h index 84db5251c3f3dc1612b94c72eb88bcf4330e4100..e8e223a6ce8c724440ebfd19e8b0dc427dfd11be 100644 --- a/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfo_v1.h +++ b/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfo_v1.h @@ -243,6 +243,27 @@ namespace xAOD { /// Set average interactions per crossing for all BCIDs void setAverageInteractionsPerCrossing( float value ); + /// Unique pile-up mixture identifier definition + struct PileUpMixtureID { + unsigned long long lowBits{}; + unsigned long long highBits{}; + }; + + /// Unique pile-up mixture identifier + PileUpMixtureID pileUpMixtureID() const; + /// Set unique pile-up mixture identifier + void setPileUpMixtureID( const PileUpMixtureID &value ); + + /// Unique pile-up mixture identifier low bits + unsigned long long pileUpMixtureIDLowBits() const; + /// Set unique pile-up mixture identifier low bits + void setPileUpMixtureIDLowBits( unsigned long long value ); + + /// Unique pile-up mixture identifier high bits + unsigned long long pileUpMixtureIDHighBits() const; + /// Set unique pile-up mixture identifier high bits + void setPileUpMixtureIDHighBits( unsigned long long value ); + /// Enumerator describing the types of pileup events enum PileUpType { Unknown = 99, ///< Type not known/specified @@ -458,8 +479,11 @@ namespace xAOD { }; // class EventInfo_v1 - /// A helper operator to be able to print debug messages easily + /// A helper operators to be able to print debug messages easily std::ostream& operator<< ( std::ostream& out, const xAOD::EventInfo_v1& ei ); + std::ostream& operator<< ( std::ostream& out, const xAOD::EventInfo_v1::PileUpMixtureID& id ); + /// PileUpMixtureID comparison helper operator + bool operator== ( const xAOD::EventInfo_v1::PileUpMixtureID& a, const xAOD::EventInfo_v1::PileUpMixtureID& b ); } // namespace xAOD