CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Interceptor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Discriminator
4 // Class : Interceptor
5 //
6 
7 // Implementation:
8 // Pseudo variable processor that just intercepts all the incoming
9 // variables and forwards them to the calibration class.
10 //
11 // Author: Christophe Saout
12 // Created: Sat May 05 09:05 CEST 2007
13 //
14 
15 #include <vector>
16 #include <algorithm>
17 
20 
22 
23 namespace PhysicsTools {
24 
25 class Interceptor : public VarProcessor {
26  public:
29 
30  Interceptor(const char *name,
32  const MVAComputer *computer);
33  virtual ~Interceptor();
34 
35  virtual void configure(ConfIterator iter, unsigned int n) override;
36  virtual void eval(ValueIterator iter, unsigned int n) const override;
37 
38  private:
40  std::vector<double> *values;
41 };
42 
43 static Interceptor::Registry registry("Interceptor");
44 
47  const MVAComputer *computer) :
48  VarProcessor(name, calib, computer),
49  interceptor(const_cast<Calibration::Interceptor*>(calib)),
50  values(0)
51 {
52 }
53 
55 {
56  delete[] values;
57 }
58 
59 void Interceptor::configure(ConfIterator iter, unsigned int n)
60 {
61  std::vector<Variable::Flags> flags;
62  for(ConfIterator iter2 = iter; iter2; iter2++)
63  flags.push_back(*iter2);
64 
65  flags = interceptor->configure(computer, n, flags);
66  if (flags.size() != n)
67  return;
68 
69  for(unsigned int i = 0; i < n; i++)
70  iter++(flags[i]);
71 
72  iter << Variable::FLAG_NONE;
73 
74  values = new std::vector<double>[n];
75 }
76 
77 void Interceptor::eval(ValueIterator iter, unsigned int n) const
78 {
79  std::vector<double> *var = values;
80 
81  for(unsigned int i = 0; i < n; i++) {
82  var->resize(iter.size());
83  std::copy(iter.begin(), iter.end(), var->begin());
84  iter++;
85  var++;
86  }
87 
89 
90  iter(0.0);
91 }
92 
93 } // namespace PhysicsTools
virtual void eval(ValueIterator iter, unsigned int n) const override
virtual evaluation method, implemented in actual processor
Definition: Interceptor.cc:77
int i
Definition: DBlmapReader.cc:9
unsigned int size() const
number of values for current input variable
Definition: VarProcessor.h:203
Calibration::Interceptor * interceptor
Definition: Interceptor.cc:39
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
template to generate a registry singleton for a type.
virtual void configure(ConfIterator iter, unsigned int n) override
virtual configure method, implemented in actual processor
Definition: Interceptor.cc:59
double * end() const
end of value array for current input variable
Definition: VarProcessor.h:210
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
Main interface class to the generic discriminator computer framework.
Definition: MVAComputer.h:39
Iterator to loop over the input/output variable configuration.
Definition: VarProcessor.h:148
virtual double intercept(const std::vector< double > *values) const =0
Interceptor(const char *name, const Calibration::Interceptor *calib, const MVAComputer *computer)
Definition: Interceptor.cc:45
double * begin() const
begin of value array for current input variable
Definition: VarProcessor.h:207
std::vector< double > * values
Definition: Interceptor.cc:40
const MVAComputer * computer
Definition: VarProcessor.h:320
VarProcessor::Registry::Registry< Interceptor, Calibration::Interceptor > Registry
Definition: Interceptor.cc:28
static Interceptor::Registry registry("Interceptor")
virtual std::vector< PhysicsTools::Variable::Flags > configure(const PhysicsTools::MVAComputer *computer, unsigned int n, const std::vector< PhysicsTools::Variable::Flags > &flags)=0
Common base class for variable processors.
Definition: VarProcessor.h:36