CMS 3D CMS Logo

PhysicsTools::SourceVariableSet Class Reference

#include <PhysicsTools/MVATrainer/interface/SourceVariableSet.h>

List of all members.

Public Types

enum  Magic { kRegular = 0, kTarget, kWeight }
typedef std::size_t size_type

Public Member Functions

bool append (SourceVariable *var, Magic magic=kRegular, int offset=-1)
SourceVariablefind (Magic magic) const
SourceVariablefind (AtomicId name) const
std::vector< SourceVariable * > get (bool withMagic=false) const
size_type size (bool withMagic=false) const
 SourceVariableSet ()
 ~SourceVariableSet ()

Private Attributes

std::vector< PosVarvars

Classes

struct  PosVar


Detailed Description

Definition at line 14 of file SourceVariableSet.h.


Member Typedef Documentation

typedef std::size_t PhysicsTools::SourceVariableSet::size_type

Definition at line 16 of file SourceVariableSet.h.


Member Enumeration Documentation

enum PhysicsTools::SourceVariableSet::Magic

Enumerator:
kRegular 
kTarget 
kWeight 

Definition at line 21 of file SourceVariableSet.h.

00021                    {
00022                 kRegular = 0,
00023                 kTarget,
00024                 kWeight
00025         };


Constructor & Destructor Documentation

PhysicsTools::SourceVariableSet::SourceVariableSet (  )  [inline]

Definition at line 18 of file SourceVariableSet.h.

00018 {}

PhysicsTools::SourceVariableSet::~SourceVariableSet (  )  [inline]

Definition at line 19 of file SourceVariableSet.h.

00019 {}


Member Function Documentation

bool PhysicsTools::SourceVariableSet::append ( SourceVariable var,
Magic  magic = kRegular,
int  offset = -1 
)

Definition at line 12 of file SourceVariableSet.cc.

References PhysicsTools::Variable::getName(), PhysicsTools::Source::getName(), PhysicsTools::SourceVariable::getSource(), PhysicsTools::SourceVariableSet::PosVar::magic, PhysicsTools::SourceVariableSet::PosVar::pos, PhysicsTools::SourceVariableSet::PosVar::var, PhysicsTools::SourceVariableSet::PosVar::VarNameLess(), and vars.

Referenced by PhysicsTools::MVATrainer::fillInputVars(), and PhysicsTools::MVATrainer::fillOutputVars().

00013 {
00014         std::vector<PosVar>::iterator pos =
00015                         std::lower_bound(vars.begin(), vars.end(),
00016                                          var->getName(), PosVar::VarNameLess);
00017 
00018         if (pos != vars.end() && (pos->var == var ||
00019                                   (pos->var->getSource() == var->getSource() &&
00020                                    pos->var->getName() == var->getName())))
00021                 return true;
00022 
00023         PosVar item;
00024         item.pos = offset < 0 ? vars.size() : offset;
00025         item.var = var;
00026         item.magic = magic;
00027 
00028         vars.insert(pos, 1, item);
00029 
00030         return false;
00031 }

SourceVariable * PhysicsTools::SourceVariableSet::find ( Magic  magic  )  const

Definition at line 45 of file SourceVariableSet.cc.

References vars.

00046 {
00047         for(std::vector<PosVar>::const_iterator pos = vars.begin();
00048             pos != vars.end(); ++pos)
00049                 if (pos->magic == magic)
00050                         return pos->var;
00051 
00052         return 0;
00053 }

SourceVariable * PhysicsTools::SourceVariableSet::find ( AtomicId  name  )  const

Definition at line 33 of file SourceVariableSet.cc.

References PhysicsTools::SourceVariableSet::PosVar::VarNameLess(), and vars.

Referenced by PhysicsTools::Source::getOutput().

00034 {
00035         std::vector<PosVar>::const_iterator pos =
00036                         std::lower_bound(vars.begin(), vars.end(),
00037                                          name, PosVar::VarNameLess);
00038 
00039         if (pos == vars.end() || pos->var->getName() != name)
00040                 return 0;
00041 
00042         return pos->var;
00043 }

std::vector< SourceVariable * > PhysicsTools::SourceVariableSet::get ( bool  withMagic = false  )  const

Definition at line 55 of file SourceVariableSet.cc.

References if(), iter, kRegular, HLT_VtxMuL3::result, and vars.

Referenced by PhysicsTools::MVATrainer::connectProcessors(), PhysicsTools::TrainProcessor::doTrainBegin(), PhysicsTools::MVATrainer::findFinalProcessors(), and PhysicsTools::MVATrainer::findUntrainedComputers().

00056 {
00057         std::vector<SourceVariable*> result(vars.size());
00058 
00059         for(std::vector<PosVar>::const_iterator iter = vars.begin();
00060             iter != vars.end(); iter++)
00061                 result[iter->pos] = iter->var;
00062 
00063         if (!withMagic) {
00064                 unsigned int pos = vars.size();
00065                 for(std::vector<PosVar>::const_iterator iter = vars.begin();
00066                     iter != vars.end(); iter++)
00067                         if (iter->magic != kRegular) {
00068                                 result.erase(result.begin() +
00069                                              (iter->pos - (iter->pos >= pos)));
00070                                 pos = iter->pos;
00071                         }
00072         }
00073 
00074         return result;
00075 }

size_type PhysicsTools::SourceVariableSet::size ( bool  withMagic = false  )  const [inline]

Definition at line 33 of file SourceVariableSet.h.

References PhysicsTools::SourceVariableSet::PosVar::noMagic(), and vars.

Referenced by PhysicsTools::MVATrainer::connectProcessors().

00034         {
00035                 if (withMagic)
00036                         return vars.size();
00037                 else
00038                         return std::count_if(vars.begin(), vars.end(),
00039                                              std::mem_fun_ref(&PosVar::noMagic));
00040         }


Member Data Documentation

std::vector<PosVar> PhysicsTools::SourceVariableSet::vars [private]

Definition at line 54 of file SourceVariableSet.h.

Referenced by append(), find(), get(), and size().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:50:14 2009 for CMSSW by  doxygen 1.5.4