CMS 3D CMS Logo

ProcSplitter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     MVAComputer
00004 // Class  :     ProcSplitter
00005 // 
00006 
00007 // Implementation:
00008 //     Splits the first n instances of the input variables into separate
00009 //     output variables.
00010 //
00011 // Author:      Christophe Saout
00012 // Created:     Sat Apr 24 15:18 CEST 2007
00013 // $Id: ProcSplitter.cc,v 1.3 2007/07/15 22:31:46 saout Exp $
00014 //
00015 
00016 #include "FWCore/Utilities/interface/Exception.h"
00017 
00018 #include "PhysicsTools/MVAComputer/interface/VarProcessor.h"
00019 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
00020 
00021 using namespace PhysicsTools;
00022 
00023 namespace { // anonymous
00024 
00025 class ProcSplitter : public VarProcessor {
00026     public:
00027         typedef VarProcessor::Registry::Registry<ProcSplitter,
00028                                         Calibration::ProcSplitter> Registry;
00029 
00030         ProcSplitter(const char *name,
00031                      const Calibration::ProcSplitter *calib,
00032                      const MVAComputer *computer);
00033         virtual ~ProcSplitter() {}
00034 
00035         virtual void configure(ConfIterator iter, unsigned int n);
00036         virtual void eval(ValueIterator iter, unsigned int n) const;
00037 
00038     private:
00039         unsigned int    count;
00040 };
00041 
00042 static ProcSplitter::Registry registry("ProcSplitter");
00043 
00044 ProcSplitter::ProcSplitter(const char *name,
00045                           const Calibration::ProcSplitter *calib,
00046                           const MVAComputer *computer) :
00047         VarProcessor(name, calib, computer),
00048         count(calib->nFirst)
00049 {
00050 }
00051 
00052 void ProcSplitter::configure(ConfIterator iter, unsigned int n)
00053 {
00054         while(iter) {
00055                 for(unsigned int i = 0; i < count; i++)
00056                         iter << Variable::FLAG_OPTIONAL;
00057                 iter << iter++(Variable::FLAG_ALL);
00058         }
00059 }
00060 
00061 void ProcSplitter::eval(ValueIterator iter, unsigned int n) const
00062 {
00063         while(iter) {
00064                 unsigned int i = 0;
00065                 while(i < iter.size()) {
00066                         iter << iter[i];
00067                         if (i++ < count)
00068                                 iter();
00069                 }
00070                 while(i++ < count)
00071                         iter();
00072                 iter();
00073                 iter++;
00074         }
00075 }
00076 
00077 } // anonymous namespace

Generated on Tue Jun 9 17:41:30 2009 for CMSSW by  doxygen 1.5.4