CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes

PhysicsTools::SourceVariableSet Class Reference

#include <SourceVariableSet.h>

List of all members.

Classes

struct  PosVar

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 (AtomicId name) const
SourceVariablefind (Magic magic) const
std::vector< SourceVariable * > get (bool withMagic=false) const
size_type size (bool withMagic=false) const
 SourceVariableSet ()
 ~SourceVariableSet ()

Private Attributes

std::vector< PosVarvars

Detailed Description

Definition at line 14 of file SourceVariableSet.h.


Member Typedef Documentation

Definition at line 16 of file SourceVariableSet.h.


Member Enumeration Documentation

Enumerator:
kRegular 
kTarget 
kWeight 

Definition at line 21 of file SourceVariableSet.h.

                   {
                kRegular = 0,
                kTarget,
                kWeight
        };

Constructor & Destructor Documentation

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

Definition at line 18 of file SourceVariableSet.h.

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

Definition at line 19 of file SourceVariableSet.h.

{}

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, evf::evtn::offset(), pos, PhysicsTools::SourceVariableSet::PosVar::pos, PhysicsTools::SourceVariableSet::PosVar::var, PhysicsTools::SourceVariableSet::PosVar::VarNameLess(), and vars.

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

{
        std::vector<PosVar>::iterator pos =
                        std::lower_bound(vars.begin(), vars.end(),
                                         var->getName(), PosVar::VarNameLess);

        if (pos != vars.end() && (pos->var == var ||
                                  (pos->var->getSource() == var->getSource() &&
                                   pos->var->getName() == var->getName())))
                return true;

        PosVar item;
        item.pos = offset < 0 ? vars.size() : offset;
        item.var = var;
        item.magic = magic;

        vars.insert(pos, 1, item);

        return false;
}
SourceVariable * PhysicsTools::SourceVariableSet::find ( Magic  magic) const

Definition at line 45 of file SourceVariableSet.cc.

References pos, and vars.

{
        for(std::vector<PosVar>::const_iterator pos = vars.begin();
            pos != vars.end(); ++pos)
                if (pos->magic == magic)
                        return pos->var;

        return 0;
}
SourceVariable * PhysicsTools::SourceVariableSet::find ( AtomicId  name) const

Definition at line 33 of file SourceVariableSet.cc.

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

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

{
        std::vector<PosVar>::const_iterator pos =
                        std::lower_bound(vars.begin(), vars.end(),
                                         name, PosVar::VarNameLess);

        if (pos == vars.end() || pos->var->getName() != name)
                return 0;

        return pos->var;
}
std::vector< SourceVariable * > PhysicsTools::SourceVariableSet::get ( bool  withMagic = false) const

Definition at line 55 of file SourceVariableSet.cc.

References if(), kRegular, pos, query::result, and vars.

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

{
        std::vector<SourceVariable*> result(vars.size());

        for(std::vector<PosVar>::const_iterator iter = vars.begin();
            iter != vars.end(); iter++)
                result[iter->pos] = iter->var;

        if (!withMagic) {
                unsigned int pos = vars.size();
                for(std::vector<PosVar>::const_iterator iter = vars.begin();
                    iter != vars.end(); iter++)
                        if (iter->magic != kRegular) {
                                result.erase(result.begin() +
                                             (iter->pos - (iter->pos >= pos)));
                                pos = iter->pos;
                        }
        }

        return result;
}
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().

        {
                if (withMagic)
                        return vars.size();
                else
                        return std::count_if(vars.begin(), vars.end(),
                                             std::mem_fun_ref(&PosVar::noMagic));
        }

Member Data Documentation

Definition at line 54 of file SourceVariableSet.h.

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