00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "FWCore/Utilities/interface/Exception.h"
00016
00017 #include "PhysicsTools/MVAComputer/interface/VarProcessor.h"
00018 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
00019
00020 using namespace PhysicsTools;
00021
00022 namespace {
00023
00024 class ProcOptional : public VarProcessor {
00025 public:
00026 typedef VarProcessor::Registry::Registry<ProcOptional,
00027 Calibration::ProcOptional> Registry;
00028
00029 ProcOptional(const char *name,
00030 const Calibration::ProcOptional *calib,
00031 const MVAComputer *computer);
00032 virtual ~ProcOptional() {}
00033
00034 virtual void configure(ConfIterator iter, unsigned int n);
00035 virtual void eval(ValueIterator iter, unsigned int n) const;
00036
00037 private:
00038 std::vector<double> neutralPos;
00039 };
00040
00041 static ProcOptional::Registry registry("ProcOptional");
00042
00043 ProcOptional::ProcOptional(const char *name,
00044 const Calibration::ProcOptional *calib,
00045 const MVAComputer *computer) :
00046 VarProcessor(name, calib, computer),
00047 neutralPos(calib->neutralPos)
00048 {
00049 }
00050
00051 void ProcOptional::configure(ConfIterator iter, unsigned int n)
00052 {
00053 if (n != neutralPos.size())
00054 return;
00055
00056 while(iter)
00057 iter++(Variable::FLAG_OPTIONAL) << Variable::FLAG_NONE;
00058 }
00059
00060 void ProcOptional::eval(ValueIterator iter, unsigned int n) const
00061 {
00062 for(std::vector<double>::const_iterator pos = neutralPos.begin();
00063 pos != neutralPos.end(); pos++, ++iter) {
00064 switch(iter.size()) {
00065 case 0:
00066 iter(*pos);
00067 break;
00068 case 1:
00069 iter(*iter);
00070 break;
00071 default:
00072 throw cms::Exception("ProcOptionalError")
00073 << "Multiple input variables encountered."
00074 << std::endl;
00075 }
00076 }
00077 }
00078
00079 }