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 // $Id: Interceptor.cc,v 1.2 2007/05/17 15:04:10 saout Exp $
14 //
15 
16 #include <vector>
17 #include <algorithm>
18 
21 
23 
24 namespace PhysicsTools {
25 
26 class Interceptor : public VarProcessor {
27  public:
30 
31  Interceptor(const char *name,
33  const MVAComputer *computer);
34  virtual ~Interceptor();
35 
36  virtual void configure(ConfIterator iter, unsigned int n);
37  virtual void eval(ValueIterator iter, unsigned int n) const;
38 
39  private:
41  std::vector<double> *values;
42 };
43 
44 static Interceptor::Registry registry("Interceptor");
45 
48  const MVAComputer *computer) :
49  VarProcessor(name, calib, computer),
50  interceptor(const_cast<Calibration::Interceptor*>(calib)),
51  values(0)
52 {
53 }
54 
56 {
57  delete[] values;
58 }
59 
60 void Interceptor::configure(ConfIterator iter, unsigned int n)
61 {
62  std::vector<Variable::Flags> flags;
63  for(ConfIterator iter2 = iter; iter2; iter2++)
64  flags.push_back(*iter2);
65 
66  flags = interceptor->configure(computer, n, flags);
67  if (flags.size() != n)
68  return;
69 
70  for(unsigned int i = 0; i < n; i++)
71  iter++(flags[i]);
72 
73  iter << Variable::FLAG_NONE;
74 
75  values = new std::vector<double>[n];
76 }
77 
78 void Interceptor::eval(ValueIterator iter, unsigned int n) const
79 {
80  std::vector<double> *var = values;
81 
82  for(unsigned int i = 0; i < n; i++) {
83  var->resize(iter.size());
84  std::copy(iter.begin(), iter.end(), var->begin());
85  iter++;
86  var++;
87  }
88 
90 
91  iter(0.0);
92 }
93 
94 } // namespace PhysicsTools
int i
Definition: DBlmapReader.cc:9
unsigned int size() const
number of values for current input variable
Definition: VarProcessor.h:183
Calibration::Interceptor * interceptor
Definition: Interceptor.cc:40
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
double * end() const
end of value array for current input variable
Definition: VarProcessor.h:190
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
Main interface class to the generic discriminator computer framework.
Definition: MVAComputer.h:40
Iterator to loop over the input/output variable configuration.
Definition: VarProcessor.h:128
virtual void configure(ConfIterator iter, unsigned int n)
virtual configure method, implemented in actual processor
Definition: Interceptor.cc:60
virtual void eval(ValueIterator iter, unsigned int n) const
virtual evaluation method, implemented in actual processor
Definition: Interceptor.cc:78
virtual double intercept(const std::vector< double > *values) const =0
Interceptor(const char *name, const Calibration::Interceptor *calib, const MVAComputer *computer)
Definition: Interceptor.cc:46
double * begin() const
begin of value array for current input variable
Definition: VarProcessor.h:187
std::vector< double > * values
Definition: Interceptor.cc:41
const MVAComputer * computer
Definition: VarProcessor.h:297
VarProcessor::Registry::Registry< Interceptor, Calibration::Interceptor > Registry
Definition: Interceptor.cc:29
template to generate a registry singleton for a type.
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:39