ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODMissingET
util
testMETHash.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
//Author: Russell Smith
6
//Email : rsmith@cern.ch
7
//Date : April 2016
8
9
// Make sure that asserts work:
10
#undef NDEBUG
11
12
// System include(s):
13
#include <cassert>
14
#include <ctime>
15
#include <utility>
16
17
// Local include(s):
18
#include "
xAODMissingET/MissingETAuxContainer.h
"
19
#include "
xAODMissingET/MissingETAssociationMap.h
"
20
#include "
xAODMissingET/MissingETContainer.h
"
21
22
23
static
const
std::map<int, std::string>
metStringsMap
= {
24
{0,
"RefEle"
},
25
{1,
"RefGamma"
},
26
{2,
"RefJet"
},
27
{3,
"RefTau"
},
28
{4,
"Muons"
},
29
{5,
"SoftTrk"
},
30
{6,
"Final"
},
31
};
32
33
int
testStringComparisonVersion
(
xAOD::MissingETContainer
& cont){
34
//std::cout << __PRETTY_FUNCTION__ << std::endl;
35
for
(
size_t
j = 0; j < 10000; ++j){
36
for
(
size_t
i = 0; i < cont.
size
(); ++i ){
37
xAOD::MissingET
*
met
= *(cont.
find
(
metStringsMap
.at(i)));
38
assert(
met
);
39
}
40
}
41
return
0;
42
}
43
44
int
testHashComparisonVersion
(
xAOD::MissingETContainer
& cont){
45
//std::cout << __PRETTY_FUNCTION__ << std::endl;
46
for
(
size_t
j = 0; j < 10000; ++j){
47
for
(
size_t
i = 0; i < cont.
size
(); ++i ){
48
// xAOD::MissingET * met = *(cont.findByHash(metStringsMap.at(i)));
49
// assert(met);
50
}
51
}
52
return
0;
53
}
54
55
double
calcMean
(std::vector<double> & times){
56
//std::cout << __PRETTY_FUNCTION__ << std::endl;
57
double
sum = 0;
58
for
(
auto
i : times ){
59
//std::cout << sum << std::endl;
60
sum += i;
61
}
62
63
return
sum/
static_cast<
double
>
(times.size());
64
}
65
66
int
main
(){std::cout << __PRETTY_FUNCTION__ << std::endl;
67
68
std::pair<xAOD::MissingETContainer, xAOD::MissingETAuxContainer> cont;
69
cont.first.setStore(& cont.second);
70
71
std::vector<double> stringComparisonTimes;
72
std::vector<double> hashComparisonTimes;
73
74
for
(
size_t
i = 0; i < 1000; ++i){
75
for
(
size_t
j = 0; j < 7; ++j){
76
xAOD::MissingET
*
met
=
new
xAOD::MissingET
(
metStringsMap
.at(j));
77
cont.first.push_back(
met
);
78
}
79
80
clock_t begin = clock();
81
testStringComparisonVersion
(cont.first);
82
clock_t end = clock();
83
84
cont.first.clear();
85
86
clock_t begin2 = clock();
87
testHashComparisonVersion
(cont.first);
88
clock_t end2 = clock();
89
90
cont.first.clear();
91
92
double
stringTime = double(end - begin );
93
double
hashTime = double(end2 - begin2);
94
// std::cout << "stringTime : " << stringTime << std::endl;
95
// std::cout << "hashTime : " << hashTime << std::endl;
96
stringComparisonTimes.push_back(stringTime);
97
hashComparisonTimes .push_back(hashTime);
98
}
99
100
std::cout <<
"Avg time to run testStringComparisonVersion : "
<<
calcMean
(stringComparisonTimes)/CLOCKS_PER_SEC << std::endl;
101
std::cout <<
"Avg time to run testHashComparisonVersion : "
<<
calcMean
(hashComparisonTimes )/CLOCKS_PER_SEC << std::endl;
102
103
return
0;
104
}
MissingETContainer.h
MissingETAssociationMap.h
MissingETAuxContainer.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::MissingETContainer_v1::find
const_iterator find(const std::string &name) const
Find non-modifiable MET object by name.
Definition
MissingETContainer_v1.cxx:52
met
Definition
IMETSignificance.h:24
xAOD::MissingET
MissingET_v1 MissingET
Version control by type defintion.
Definition
Event/xAOD/xAODMissingET/xAODMissingET/MissingET.h:15
xAOD::MissingETContainer
MissingETContainer_v1 MissingETContainer
Definition
Event/xAOD/xAODMissingET/xAODMissingET/MissingETContainer.h:16
metStringsMap
static const std::map< int, std::string > metStringsMap
Definition
testMETHash.cxx:23
testStringComparisonVersion
int testStringComparisonVersion(xAOD::MissingETContainer &cont)
Definition
testMETHash.cxx:33
testHashComparisonVersion
int testHashComparisonVersion(xAOD::MissingETContainer &cont)
Definition
testMETHash.cxx:44
main
int main()
Definition
testMETHash.cxx:66
calcMean
double calcMean(std::vector< double > ×)
Definition
testMETHash.cxx:55
Generated on
for ATLAS Offline Software by
1.17.0