ATLAS Offline Software
Loading...
Searching...
No Matches
PileUpHashHelper Class Reference

#include <PileUpHashHelper.h>

Collaboration diagram for PileUpHashHelper:

Public Member Functions

 PileUpHashHelper ()
void addToHashSource (const std::string &string)
 Add a plain string to the stream.
void addToHashSource (const xAOD::EventInfo *eventInfo)
 Add subevents to the stream.
void clearHashSource ()
 Clear the stream.
std::string hashSource () const
 Get the current hash base.
void calculateHash (uuid_t &hash) const
 Calculate the hash.

Static Public Member Functions

static xAOD::EventInfo::PileUpMixtureID uuidToPileUpMixtureId (const uuid_t &hash)
 Convert uuid_t to xAOD::EventInfo::PileUpMixtureID.
static void pileUpMixtureIdToUuid (const xAOD::EventInfo::PileUpMixtureID &mixture, uuid_t &hash)
 xAOD::EventInfo::PileUpMixtureID to uuid_t

Static Public Attributes

static const uint16_t PILEUP_SIZE_BYTES = 8
 Size of individual low/high bits in bytes.

Private Attributes

std::stringstream m_stream

Detailed Description

Definition at line 20 of file PileUpHashHelper.h.

Constructor & Destructor Documentation

◆ PileUpHashHelper()

PileUpHashHelper::PileUpHashHelper ( )
inline

Definition at line 23 of file PileUpHashHelper.h.

23{}

Member Function Documentation

◆ addToHashSource() [1/2]

void PileUpHashHelper::addToHashSource ( const std::string & string)

Add a plain string to the stream.

Author
Tadej Novak

Definition at line 11 of file PileUpHashHelper.cxx.

12{
13 m_stream << string;
14}
std::stringstream m_stream

◆ addToHashSource() [2/2]

void PileUpHashHelper::addToHashSource ( const xAOD::EventInfo * eventInfo)

Add subevents to the stream.

Definition at line 16 of file PileUpHashHelper.cxx.

17{
18 const std::vector<xAOD::EventInfo::SubEvent> &subEventsSource = eventInfo->subEvents();
19 std::vector<std::reference_wrapper<const xAOD::EventInfo::SubEvent>> subEvents(subEventsSource.begin(), subEventsSource.end());
20
21 std::stable_sort(subEvents.begin(), subEvents.end(), [](const xAOD::EventInfo::SubEvent &a, const xAOD::EventInfo::SubEvent &b) {
22 return (a.ptr()->bcid() < b.ptr()->bcid()) ||
23 ((a.ptr()->bcid() == b.ptr()->bcid()) && (a.type() < b.type())) ||
24 ((a.ptr()->bcid() == b.ptr()->bcid()) && (a.type() == b.type()) && (a.ptr()->eventNumber() < b.ptr()->eventNumber()));
25 });
26
27 // Generate subevents info string
28 bool first = true;
29 for (const xAOD::EventInfo::SubEvent &subevent : subEvents) {
30 if (subevent.type() == xAOD::EventInfo::Signal) {
31 continue;
32 }
33
34 if (first) {
35 first = false;
36 } else {
37 m_stream << ";";
38 }
39
40 m_stream << (static_cast<int32_t>(subevent.ptr()->bcid()) - static_cast<int32_t>(eventInfo->bcid())) << "_" << subevent.type() << "_" << subevent.ptr()->eventNumber();
41 }
42}
static Double_t a
uint32_t bcid() const
The bunch crossing ID of the event.
const std::vector< SubEvent > & subEvents() const
Get the pileup events that were used in the simulation.
@ Signal
The signal event.
bool first
Definition DeMoScan.py:534
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.

◆ calculateHash()

void PileUpHashHelper::calculateHash ( uuid_t & hash) const

Calculate the hash.

Definition at line 49 of file PileUpHashHelper.cxx.

50{
51 std::string sourceStr = m_stream.str();
52
53 MD5 md5Hash(sourceStr);
54 md5Hash.uuid_digest(hash);
55}

◆ clearHashSource()

void PileUpHashHelper::clearHashSource ( )

Clear the stream.

Definition at line 44 of file PileUpHashHelper.cxx.

45{
46 m_stream.str(std::string());
47}

◆ hashSource()

std::string PileUpHashHelper::hashSource ( ) const
inline

Get the current hash base.

Definition at line 35 of file PileUpHashHelper.h.

35{ return m_stream.str(); }

◆ pileUpMixtureIdToUuid()

void PileUpHashHelper::pileUpMixtureIdToUuid ( const xAOD::EventInfo::PileUpMixtureID & mixture,
uuid_t & hash )
static

xAOD::EventInfo::PileUpMixtureID to uuid_t

Definition at line 69 of file PileUpHashHelper.cxx.

71{
72 for (uint16_t i = 0; i < PILEUP_SIZE_BYTES; i++) {
73 hash[i] |= (mixture.lowBits >> (i * sizeof(unsigned char) * CHAR_BIT));
74 hash[i + PILEUP_SIZE_BYTES] |= (mixture.highBits >> (i * sizeof(unsigned char) * CHAR_BIT));
75 }
76}
static const uint16_t PILEUP_SIZE_BYTES
Size of individual low/high bits in bytes.

◆ uuidToPileUpMixtureId()

xAOD::EventInfo::PileUpMixtureID PileUpHashHelper::uuidToPileUpMixtureId ( const uuid_t & hash)
static

Convert uuid_t to xAOD::EventInfo::PileUpMixtureID.

Definition at line 57 of file PileUpHashHelper.cxx.

58{
59 xAOD::EventInfo::PileUpMixtureID mixture{};
60
61 for (uint16_t i = 0; i < PILEUP_SIZE_BYTES; i++) {
62 mixture.lowBits |= (static_cast<unsigned long long>(hash[i]) << (i * sizeof(unsigned char) * CHAR_BIT));
63 mixture.highBits |= (static_cast<unsigned long long>(hash[i + PILEUP_SIZE_BYTES]) << (i * sizeof(unsigned char) * CHAR_BIT));
64 }
65
66 return mixture;
67}

Member Data Documentation

◆ m_stream

std::stringstream PileUpHashHelper::m_stream
private

Definition at line 51 of file PileUpHashHelper.h.

◆ PILEUP_SIZE_BYTES

const uint16_t PileUpHashHelper::PILEUP_SIZE_BYTES = 8
static

Size of individual low/high bits in bytes.

Definition at line 48 of file PileUpHashHelper.h.


The documentation for this class was generated from the following files: