ToolDAQFramework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
MyTool.cpp
Go to the documentation of this file.
1 #include "MyTool.h"
2 
3 MyTool::MyTool():Tool(){}
4 
5 
6 bool MyTool::Initialise(std::string configfile, DataModel &data){
7 
8  if(configfile!="") m_variables.Initialise(configfile);
9  //m_variables.Print();
10 
11  m_verbose = 0;
12  m_variables.Get("verbose", m_verbose);
13 
14  //Setup and start the stopwatch
15  bool use_stopwatch = false;
16  m_variables.Get("use_stopwatch", use_stopwatch);
17  m_stopwatch = use_stopwatch ? new util::Stopwatch("MyTool") : 0;
18 
19  m_stopwatch_file = "";
20  m_variables.Get("stopwatch_file", m_stopwatch_file);
21 
23 
24  m_data= &data;
25  m_log= m_data->Log;
26 
27  if(!m_variables.Get("verbose",m_verbose)) m_verbose=1;
28 
29 
30 
32 
33 
34  if(m_stopwatch) Log(m_stopwatch->Result("Initialise"), INFO, m_verbose);
35 
36  return true;
37 }
38 
39 
41 
43 
45 
47 
48  return true;
49 }
50 
51 
53 
54  if(m_stopwatch) {
56  m_stopwatch->Start();
57  }
58 
60 
61  if(m_stopwatch) {
62  Log(m_stopwatch->Result("Finalise"), INFO, m_verbose);
63  delete m_stopwatch;
64  }
65 
66  return true;
67 }
std::string Result(std::string method_name, std::string output_file="")
Definition: Stopwatch.cpp:38
void Start()
Start the stopwatch.
Definition: Stopwatch.cpp:18
StopwatchTimes Stop()
Stop the stopwatch, returning the CPU time.
Definition: Stopwatch.cpp:24
MyTool()
Simple constructor.
Definition: MyTool.cpp:3
Logging * Log
Log class pointer for use in Tools, it can be used to send messages which can have multiple error lev...
Definition: DataModel.h:60
util::Stopwatch * m_stopwatch
The stopwatch, if we're using one.
Definition: MyTool.h:35
bool Finalise()
Finalise funciton used to clean up resorces.
Definition: MyTool.cpp:52
int m_verbose
Verbosity level, as defined in tool parameter file.
Definition: MyTool.h:40
std::string m_stopwatch_file
Image filename to save the histogram to, if required.
Definition: MyTool.h:37
void Log(const std::string &message, const int message_level)
Format messages in the same way as for tools.
Definition: Utilities.cpp:276
bool Initialise(std::string configfile, DataModel &data)
Initialise Function for setting up Tool resorces.
Definition: MyTool.cpp:6
bool Execute()
Executre function used to perform Tool perpose.
Definition: MyTool.cpp:40