ATLAS Offline Software
Loading...
Searching...
No Matches
testMETHash.cxx File Reference
#include <cassert>
#include <ctime>
#include <utility>
#include "xAODMissingET/MissingETAuxContainer.h"
#include "xAODMissingET/MissingETAssociationMap.h"
#include "xAODMissingET/MissingETContainer.h"
Include dependency graph for testMETHash.cxx:

Go to the source code of this file.

Functions

int testStringComparisonVersion (xAOD::MissingETContainer &cont)
int testHashComparisonVersion (xAOD::MissingETContainer &cont)
double calcMean (std::vector< double > &times)
int main ()

Variables

static const std::map< int, std::string > metStringsMap

Function Documentation

◆ calcMean()

double calcMean ( std::vector< double > & times)

Definition at line 55 of file testMETHash.cxx.

55 {
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}

◆ main()

int main ( )

Definition at line 66 of file testMETHash.cxx.

66 {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){
77 cont.first.push_back(met);
78 }
79
80 clock_t begin = clock();
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 }
MissingET_v1 MissingET
Version control by type defintion.
static const std::map< int, std::string > metStringsMap
int testStringComparisonVersion(xAOD::MissingETContainer &cont)
int testHashComparisonVersion(xAOD::MissingETContainer &cont)
double calcMean(std::vector< double > &times)

◆ testHashComparisonVersion()

int testHashComparisonVersion ( xAOD::MissingETContainer & cont)

Definition at line 44 of file testMETHash.cxx.

44 {
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}
size_type size() const noexcept
Returns the number of elements in the collection.

◆ testStringComparisonVersion()

int testStringComparisonVersion ( xAOD::MissingETContainer & cont)

Definition at line 33 of file testMETHash.cxx.

33 {
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}
const_iterator find(const std::string &name) const
Find non-modifiable MET object by name.

Variable Documentation

◆ metStringsMap

const std::map<int, std::string> metStringsMap
static
Initial value:
= {
{0, "RefEle"},
{1, "RefGamma"},
{2, "RefJet"},
{3, "RefTau"},
{4, "Muons"},
{5, "SoftTrk"},
{6, "Final"},
}

Definition at line 23 of file testMETHash.cxx.

23 {
24 {0, "RefEle"},
25 {1, "RefGamma"},
26 {2, "RefJet"},
27 {3, "RefTau"},
28 {4, "Muons"},
29 {5, "SoftTrk"},
30 {6, "Final"},
31};