LCFIVertex  0.7.2
vertex_lcfi/inc/algo.h
1 #ifndef LCFIALGO_H
2 #define LCFIALGO_H
3 
4 #include <string>
5 #include <sstream>
6 #include <vector>
7 #include <iostream>
8 //For exception
9 #include "lcio.h"
10 #include "util/inc/memorymanager.h"
11 
12 using std::string;
13 
14 namespace vertex_lcfi
15 {
17 
20  template <class INTYPE, class OUTTYPE>
21  class Algo
22  {
23 
24  public:
25  typedef OUTTYPE OutType;
26  typedef INTYPE InType;
27 
28  virtual ~Algo() {}
29 
31 
35  virtual string name() const =0;
36 
38 
42  virtual std::vector<string> parameterNames() const =0;
43 
45 
49  virtual std::vector<string> parameterValues() const =0;
50 
52 
57  virtual void setStringParameter(const string & Parameter, const string & Value) =0;
58 
60 
65  virtual void setDoubleParameter(const string & Parameter, const double Value) =0;
66 
68 
73  virtual void setPointerParameter(const string & Parameter, void * Value) =0;
74 
76 
81  virtual OUTTYPE calculateFor(INTYPE Input) const =0;
82 
83  protected:
84  void badParameter(std::string Parameter)
85  {
86  std::stringstream Msg;
87  Msg << this->name() << " does not have parameter " << Parameter << "." << std::endl;
88  Msg << "(or parameter was of wrong type)" << std::endl;
89  Msg << "Avaliable parameters are:" << std::endl;
90  std::vector<std::string> Names = this->parameterNames();
91  for (std::vector<std::string>::const_iterator iP = Names.begin();iP != Names.end(); ++iP)
92  Msg << (*iP) << std::endl;
95  //Replace with your systems exception if not LCIO
96  throw lcio::Exception(Msg.str());
97  }
98  };
99 }
100 #endif //LCFIALGO_H
101 
102 
virtual string name() const =0
Name.
static MetaMemoryManager * Event()
Returns the Event duration singleton instance of the controller.
virtual void setPointerParameter(const string &Parameter, void *Value)=0
Set Pointer Parameter.
void delAllObjects()
Delete all objects of all types held by this instance.
static MetaMemoryManager * Run()
Returns the Run duration singleton instance of the controller.
virtual void setDoubleParameter(const string &Parameter, const double Value)=0
Set Double Parameter.
virtual std::vector< string > parameterValues() const =0
Parameter Values.
virtual void setStringParameter(const string &Parameter, const string &Value)=0
Set String Parameter.
virtual OUTTYPE calculateFor(INTYPE Input) const =0
Run the algorithm on a jet.
virtual std::vector< string > parameterNames() const =0
Parameter Names.