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 
10 
13 
14 namespace PhysicsTools {
15 
17  public:
18  MVATrainerLooper(const edm::ParameterSet &params);
19  virtual ~MVATrainerLooper();
20 
21  virtual void startingNewLoop(unsigned int iteration);
22  virtual Status duringLoop(const edm::Event &ev,
23  const edm::EventSetup &es);
24  virtual Status endOfLoop(const edm::EventSetup &es,
25  unsigned int iteration);
26 
27  typedef std::shared_ptr<Calibration::MVAComputer> TrainObject;
28  typedef std::shared_ptr<Calibration::MVAComputerContainer>
30 
31  template<class T>
32  static inline bool isUntrained(const T *ptr);
33 
34  protected:
35  class Trainer {
36  public:
37  Trainer(const edm::ParameterSet &params);
38  virtual ~Trainer() {}
39 
40  inline const MVATrainer *getTrainer() const
41  { return trainer.get(); }
42  inline const TrainObject getCalibration() const
43  { return trainCalib; }
44 
45  private:
46  friend class MVATrainerLooper;
47 
48  std::auto_ptr<MVATrainer> trainer;
50  };
51 
53  public:
55  void clear();
56 
57  typedef std::vector<Trainer*>::const_iterator const_iterator;
58 
59  inline const_iterator begin() const { return content.begin(); }
60  inline const_iterator end() const { return content.end(); }
61  inline bool empty() const { return content.empty(); }
62 
63  inline void add(Trainer *trainer)
64  { content.push_back(trainer); }
65 
66  private:
67  std::vector<Trainer*> content;
68  };
69 
73 
74  void addTrainer(Trainer *trainer) { trainers.add(trainer); }
75 
76  inline const TrainerContainer &getTrainers() const { return trainers; }
77 
78  private:
81 };
82 
83 template<> inline bool
85 { return dynamic_cast<const UntrainedMVAComputer*>(ptr) != 0; }
86 
87 template<> inline bool
89 { return dynamic_cast<const UntrainedMVAComputerContainer*>(ptr) != 0; }
90 
91 } // namespace PhysicsTools
92 
93 #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)
Trainer(const edm::ParameterSet &params)
const TrainerContainer & getTrainers() const
std::shared_ptr< Calibration::MVAComputerContainer > TrainContainer
const TrainObject getCalibration() const
std::vector< Trainer * >::const_iterator const_iterator
std::shared_ptr< Calibration::MVAComputer > TrainObject
const MVATrainer * getTrainer() const
static bool isUntrained(const T *ptr)
long double T