ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
PileUpTools
src
PileUpHashHelper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
#include <
CxxUtils/MD5.h
>
8
9
#include "
PileUpTools/PileUpHashHelper.h
"
10
11
void
PileUpHashHelper::addToHashSource
(
const
std::string &
string
)
12
{
13
m_stream
<<
string
;
14
}
15
16
void
PileUpHashHelper::addToHashSource
(
const
xAOD::EventInfo
*eventInfo)
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
}
43
44
void
PileUpHashHelper::clearHashSource
()
45
{
46
m_stream
.str(std::string());
47
}
48
49
void
PileUpHashHelper::calculateHash
(uuid_t &hash)
const
50
{
51
std::string sourceStr =
m_stream
.str();
52
53
MD5
md5Hash(sourceStr);
54
md5Hash.
uuid_digest
(hash);
55
}
56
57
xAOD::EventInfo::PileUpMixtureID
PileUpHashHelper::uuidToPileUpMixtureId
(
const
uuid_t &hash)
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
}
68
69
void
PileUpHashHelper::pileUpMixtureIdToUuid
(
const
xAOD::EventInfo::PileUpMixtureID
&mixture,
70
uuid_t &hash)
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
}
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
MD5.h
solar's public-domain MD5, wrapped for C++.
PileUpHashHelper.h
A helper class to compute a hash of pile-up events.
MD5
Definition
MD5.h:20
MD5::uuid_digest
void uuid_digest(uuid_t &uuid) const
Definition
MD5.cxx:88
PileUpHashHelper::clearHashSource
void clearHashSource()
Clear the stream.
Definition
PileUpHashHelper.cxx:44
PileUpHashHelper::m_stream
std::stringstream m_stream
Definition
PileUpHashHelper.h:51
PileUpHashHelper::addToHashSource
void addToHashSource(const std::string &string)
Add a plain string to the stream.
Definition
PileUpHashHelper.cxx:11
PileUpHashHelper::calculateHash
void calculateHash(uuid_t &hash) const
Calculate the hash.
Definition
PileUpHashHelper.cxx:49
PileUpHashHelper::pileUpMixtureIdToUuid
static void pileUpMixtureIdToUuid(const xAOD::EventInfo::PileUpMixtureID &mixture, uuid_t &hash)
xAOD::EventInfo::PileUpMixtureID to uuid_t
Definition
PileUpHashHelper.cxx:69
PileUpHashHelper::uuidToPileUpMixtureId
static xAOD::EventInfo::PileUpMixtureID uuidToPileUpMixtureId(const uuid_t &hash)
Convert uuid_t to xAOD::EventInfo::PileUpMixtureID.
Definition
PileUpHashHelper.cxx:57
PileUpHashHelper::PILEUP_SIZE_BYTES
static const uint16_t PILEUP_SIZE_BYTES
Size of individual low/high bits in bytes.
Definition
PileUpHashHelper.h:48
string
STL class.
xAOD::EventInfo_v1::SubEvent
Class describing the properties of one pileup sub-event.
Definition
EventInfo_v1.h:286
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
xAOD::EventInfo_v1::subEvents
const std::vector< SubEvent > & subEvents() const
Get the pileup events that were used in the simulation.
Definition
EventInfo_v1.cxx:596
xAOD::EventInfo_v1::Signal
@ Signal
The signal event.
Definition
EventInfo_v1.h:266
std::stable_sort
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
Definition
DVL_algorithms.h:644
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
xAOD::EventInfo_v1::PileUpMixtureID
Unique pile-up mixture identifier definition.
Definition
EventInfo_v1.h:243
xAOD::EventInfo_v1::PileUpMixtureID::lowBits
uint64_t lowBits
Definition
EventInfo_v1.h:244
xAOD::EventInfo_v1::PileUpMixtureID::highBits
uint64_t highBits
Definition
EventInfo_v1.h:245
Generated on
for ATLAS Offline Software by
1.17.0