TankResponseSpeed.cc
Go to the documentation of this file.
1 
10 #include <tls/TankResponseFactory.h>
11 #include <tls/VTankResponse.h>
12 
13 #include <iostream>
14 #include <cstdlib>
15 #include <cstdio>
16 #include <cmath>
17 
18 #include <utl/Reader.h>
19 #include <utl/AugerUnits.h>
20 #include <utl/AugerException.h>
21 #include <utl/ErrorLogger.h>
22 
23 #include <TRandom.h>
24 #include <TBenchmark.h>
25 
26 using namespace tls;
27 using namespace utl;
28 using namespace std;
29 
30 int main(int argc, char* argv[]) {
31 
32  const int nCycles = 10000;
33 
34  // Get the configuration. Which implementation is used is determined there.
35  if (argc != 2)
36  {
37  cerr << "wrong number of arguments, need exactly one which is path to XML configuration file" << endl;
38  exit(1);
39  }
40 
41  Reader reader(argv[1]);
42  Branch branch = reader.GetTopBranch().GetFirstChild();
43  vector<Branch> branchList;
44  while (branch) { branchList.push_back(branch); branch = branch.GetNextSibling(); }
45 
46  TBenchmark bench;
47 
48  cout << "No. of calls " << nCycles << endl;
49 
50  vector<double> thetaList;
51  vector<double> signalList;
52 
53  for (int i=0;i<nCycles;++i)
54  {
55  thetaList.push_back(gRandom->Uniform(60.1*degree,87.9*degree));
56  signalList.push_back(gRandom->Exp(10.));
57  }
58 
59  cout << "Calls to PDF(...)" << endl;
60  for (unsigned short ib=0;ib<branchList.size();++ib)
61  {
62  Branch& branch = branchList[ib];
63 
64  try {
65  VTankResponse& tankResponse = TankResponseFactory::GetInstance().GetTankResponse(branch);
66  ostringstream msg1;
67  msg1 << branch.GetName() << "1";
68 
69  bench.Start(msg1.str().c_str());
70  for (int i=0;i<nCycles;++i) tankResponse.PDF(signalList[i], thetaList[i], 0, 1);
71  bench.Stop(msg1.str().c_str());
72 
73  ostringstream msg2;
74  msg2 << branch.GetName() << "20";
75 
76  bench.Start(msg2.str().c_str());
77  for (int i=0;i<nCycles;++i) tankResponse.PDF(signalList[i], thetaList[i], 0, 20);
78  bench.Stop(msg2.str().c_str());
79 
80  char buf[1024];
81  sprintf(buf,"%20s - 1 muon : real time %5.2f",branch.GetName().c_str(),bench.GetRealTime(msg1.str().c_str()));
82  cout << buf << endl;
83  sprintf(buf,"%20s - 20 muons: real time %5.2f",branch.GetName().c_str(),bench.GetRealTime(msg2.str().c_str()));
84  cout << buf << endl;
85  } catch (NonExistentComponentException& e) {
86  ERROR(e.GetMessage());
87  }
88  }
89 
90  bench.Reset();
91  cout << "Calls to CDF(...)" << endl;
92  for (unsigned short ib=0;ib<branchList.size();++ib)
93  {
94  Branch& branch = branchList[ib];
95 
96  try {
97  VTankResponse& tankResponse = TankResponseFactory::GetInstance().GetTankResponse(branch);
98 
99  ostringstream msg1;
100  msg1 << branch.GetName() << "1";
101 
102  bench.Start(msg1.str().c_str());
103  for (int i=0;i<nCycles;++i) tankResponse.CDF(signalList[i], thetaList[i], 0, 1);
104  bench.Stop(msg1.str().c_str());
105 
106  ostringstream msg2;
107  msg2 << branch.GetName() << "20";
108 
109  bench.Start(msg2.str().c_str());
110  for (int i=0;i<nCycles;++i) tankResponse.CDF(signalList[i], thetaList[i], 0, 20);
111  bench.Stop(msg2.str().c_str());
112 
113  char buf[1024];
114  sprintf(buf,"%20s - 1 muon : real time %5.2f",branch.GetName().c_str(),bench.GetRealTime(msg1.str().c_str()));
115  cout << buf << endl;
116  sprintf(buf,"%20s - 20 muons: real time %5.2f",branch.GetName().c_str(),bench.GetRealTime(msg2.str().c_str()));
117  cout << buf << endl;
118  } catch (NonExistentComponentException& e) {
119  ERROR(e.GetMessage());
120  }
121  }
122 
123  return 0;
124 }
const double degree
virtual double PDF(const double signal, const double theta, const double r, const ulong muons) const =0
PDF of signal, given a fixed number of muons.
Base class for exceptions trying to access non-existing components.
int exit
Definition: dump1090.h:237
Branch GetTopBranch() const
Get the top Branch (represents same entity as document node)
Definition: Reader.h:45
Branch GetNextSibling() const
Get next sibling of this branch.
Definition: Branch.cc:284
Utility for parsing XML files.
Definition: Reader.h:25
Class representing a document branch.
Definition: Branch.h:107
Interface class for coupling different tank response calculations into the reconstruction code...
Definition: VTankResponse.h:26
int main(int argc, char *argv[])
Definition: DBSync.cc:58
std::string GetName() const
function to get the Branch name
Definition: Branch.cc:374
v push_back(value)
Branch GetFirstChild() const
Get first child of this Branch.
Definition: Branch.cc:98
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
const std::string & GetMessage() const
Retrieve the message from the exception.
virtual double CDF(const double smax, const double theta, const double r, const ulong muons) const =0
Probability of signal begin smaller than smax, given a fixed number of muons.

, generated on Tue Sep 26 2023.