From 579b36a6f3488ca087b33fe412a2a588bf347d43 Mon Sep 17 00:00:00 2001 From: Tadej Novak <tadej.novak@cern.ch> Date: Thu, 11 Oct 2018 08:16:32 +0200 Subject: [PATCH] Add simple PileUpMixtureID struct to xAOD::EventInfo --- .../Root/EventInfoAuxContainer_v1.cxx | 4 + .../xAOD/xAODEventInfo/Root/EventInfo_v1.cxx | 75 +++++++++++++++++++ .../versions/EventInfoAuxContainer_v1.h | 6 +- .../xAODEventInfo/versions/EventInfo_v1.h | 26 ++++++- 4 files changed, 109 insertions(+), 2 deletions(-) diff --git a/Event/xAOD/xAODEventInfo/Root/EventInfoAuxContainer_v1.cxx b/Event/xAOD/xAODEventInfo/Root/EventInfoAuxContainer_v1.cxx index 22f8bbcbcbf..095d6e07a61 100644 --- a/Event/xAOD/xAODEventInfo/Root/EventInfoAuxContainer_v1.cxx +++ b/Event/xAOD/xAODEventInfo/Root/EventInfoAuxContainer_v1.cxx @@ -49,6 +49,10 @@ namespace xAOD { AUX_VARIABLE( mcChannelNumber ); AUX_VARIABLE( mcEventNumber ); AUX_VARIABLE( mcEventWeights ); + + // Pileup information: + AUX_VARIABLE( pileUpMixtureIDLowBits ); + AUX_VARIABLE( pileUpMixtureIDHighBits ); } /** diff --git a/Event/xAOD/xAODEventInfo/Root/EventInfo_v1.cxx b/Event/xAOD/xAODEventInfo/Root/EventInfo_v1.cxx index dcf950f390e..9fabf1a9c85 100644 --- a/Event/xAOD/xAODEventInfo/Root/EventInfo_v1.cxx +++ b/Event/xAOD/xAODEventInfo/Root/EventInfo_v1.cxx @@ -350,6 +350,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 const Accessor< unsigned long long > accLow( "pileUpMixtureIDLowBits" ); + static const 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, @@ -966,4 +997,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 d26545d105c..cbae095f29c 100644 --- a/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfoAuxContainer_v1.h +++ b/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfoAuxContainer_v1.h @@ -115,7 +115,11 @@ namespace xAOD { std::vector< std::vector< float > > mcEventWeights; /// @} - + /// @name Pileup information + /// @{ + std::vector< unsigned long long > pileUpMixtureIDLowBits; + std::vector< unsigned long long > pileUpMixtureIDHighBits; + /// @} /// Keep track of the event status flags. /// The set bits here correspond to the auxids of all unlocked diff --git a/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfo_v1.h b/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfo_v1.h index fde9e62af7e..dbc7ee3fa74 100644 --- a/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfo_v1.h +++ b/Event/xAOD/xAODEventInfo/xAODEventInfo/versions/EventInfo_v1.h @@ -245,6 +245,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 @@ -498,8 +519,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 -- GitLab