test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MVATrainerLooper.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_MVATrainer_MVATrainerLooper_h
2 #define PhysicsTools_MVATrainer_MVATrainerLooper_h
3 
4 #include <string>
5 #include <vector>
6 #include <memory>
7 
8 #include <boost/shared_ptr.hpp>
9 
12 
15 
16 namespace PhysicsTools {
17 
19  public:
20  MVATrainerLooper(const edm::ParameterSet &params);
21  virtual ~MVATrainerLooper();
22 
23  virtual void startingNewLoop(unsigned int iteration);
24  virtual Status duringLoop(const edm::Event &ev,
25  const edm::EventSetup &es);
26  virtual Status endOfLoop(const edm::EventSetup &es,
27  unsigned int iteration);
28 
29  typedef boost::shared_ptr<Calibration::MVAComputer> TrainObject;
30  typedef boost::shared_ptr<Calibration::MVAComputerContainer>
32 
33  template<class T>
34  static inline bool isUntrained(const T *ptr);
35 
36  protected:
37  class Trainer {
38  public:
39  Trainer(const edm::ParameterSet &params);
40  virtual ~Trainer() {}
41 
42  inline const MVATrainer *getTrainer() const
43  { return trainer.get(); }
44  inline const TrainObject getCalibration() const
45  { return trainCalib; }
46 
47  private:
48  friend class MVATrainerLooper;
49 
50  std::auto_ptr<MVATrainer> trainer;
52  };
53 
55  public:
57  void clear();
58 
59  typedef std::vector<Trainer*>::const_iterator const_iterator;
60 
61  inline const_iterator begin() const { return content.begin(); }
62  inline const_iterator end() const { return content.end(); }
63  inline bool empty() const { return content.empty(); }
64 
65  inline void add(Trainer *trainer)
66  { content.push_back(trainer); }
67 
68  private:
69  std::vector<Trainer*> content;
70  };
71 
75 
76  void addTrainer(Trainer *trainer) { trainers.add(trainer); }
77 
78  inline const TrainerContainer &getTrainers() const { return trainers; }
79 
80  private:
83 };
84 
85 template<> inline bool
87 { return dynamic_cast<const UntrainedMVAComputer*>(ptr) != 0; }
88 
89 template<> inline bool
91 { return dynamic_cast<const UntrainedMVAComputerContainer*>(ptr) != 0; }
92 
93 } // namespace PhysicsTools
94 
95 #endif // PhysicsTools_MVATrainer_MVATrainerLooper_h
void addTrainer(Trainer *trainer)
virtual Status duringLoop(const edm::Event &ev, const edm::EventSetup &es)
bool ev
std::auto_ptr< MVATrainer > trainer
MVATrainerLooper(const edm::ParameterSet &params)
virtual void startingNewLoop(unsigned int iteration)
tuple iteration
Definition: align_cfg.py:5
virtual Status endOfLoop(const edm::EventSetup &es, unsigned int iteration)
boost::shared_ptr< Calibration::MVAComputerContainer > TrainContainer
Trainer(const edm::ParameterSet &params)
const TrainerContainer & getTrainers() const
const TrainObject getCalibration() const
boost::shared_ptr< Calibration::MVAComputer > TrainObject
std::vector< Trainer * >::const_iterator const_iterator
const MVATrainer * getTrainer() const
static bool isUntrained(const T *ptr)
long double T