ATLAS Offline Software
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):
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 
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 
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  }
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
xAOD::MissingET
MissingET_v1 MissingET
Version control by type defintion.
Definition: Event/xAOD/xAODMissingET/xAODMissingET/MissingET.h:15
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
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
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
lumiFormat.i
int i
Definition: lumiFormat.py:85
main
int main()
Definition: testMETHash.cxx:66
MissingETAuxContainer.h
xAOD::MissingET_v1
Principal data object for Missing ET.
Definition: MissingET_v1.h:25
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
calcMean
double calcMean(std::vector< double > &times)
Definition: testMETHash.cxx:55
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
testStringComparisonVersion
int testStringComparisonVersion(xAOD::MissingETContainer &cont)
Definition: testMETHash.cxx:33
testHashComparisonVersion
int testHashComparisonVersion(xAOD::MissingETContainer &cont)
Definition: testMETHash.cxx:44
MissingETAssociationMap.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
MissingETContainer.h
plot_times.times
def times(fn)
Definition: plot_times.py:11