CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
PhysicsTools::SourceVariableSet Class Reference

#include <SourceVariableSet.h>

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 13 of file SourceVariableSet.h.

Member Typedef Documentation

Definition at line 15 of file SourceVariableSet.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

PhysicsTools::SourceVariableSet::SourceVariableSet ( )
inline

Definition at line 17 of file SourceVariableSet.h.

17 {}
PhysicsTools::SourceVariableSet::~SourceVariableSet ( )
inline

Definition at line 18 of file SourceVariableSet.h.

18 {}

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::Source::getName(), PhysicsTools::Variable::getName(), PhysicsTools::SourceVariable::getSource(), PhysicsTools::SourceVariableSet::PosVar::magic, PFRecoTauDiscriminationByIsolation_cfi::offset, PhysicsTools::SourceVariableSet::PosVar::pos, JetChargeProducer_cfi::var, PhysicsTools::SourceVariableSet::PosVar::var, PhysicsTools::SourceVariableSet::PosVar::VarNameLess(), and vars.

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

13 {
14  std::vector<PosVar>::iterator pos =
15  std::lower_bound(vars.begin(), vars.end(),
16  var->getName(), PosVar::VarNameLess);
17 
18  if (pos != vars.end() && (pos->var == var ||
19  (pos->var->getSource() == var->getSource() &&
20  pos->var->getName() == var->getName())))
21  return true;
22 
23  PosVar item;
24  item.pos = offset < 0 ? vars.size() : offset;
25  item.var = var;
26  item.magic = magic;
27 
28  vars.insert(pos, 1, item);
29 
30  return false;
31 }
static bool VarNameLess(const PosVar &var, AtomicId name)
SourceVariable * PhysicsTools::SourceVariableSet::find ( AtomicId  name) const

Definition at line 33 of file SourceVariableSet.cc.

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

Referenced by PhysicsTools::Source::getOutput(), and PhysicsTools::stdStringPrintf().

34 {
35  std::vector<PosVar>::const_iterator pos =
36  std::lower_bound(vars.begin(), vars.end(),
38 
39  if (pos == vars.end() || pos->var->getName() != name)
40  return nullptr;
41 
42  return pos->var;
43 }
static bool VarNameLess(const PosVar &var, AtomicId name)
SourceVariable * PhysicsTools::SourceVariableSet::find ( Magic  magic) const

Definition at line 45 of file SourceVariableSet.cc.

References vars.

46 {
47  for(std::vector<PosVar>::const_iterator pos = vars.begin();
48  pos != vars.end(); ++pos)
49  if (pos->magic == magic)
50  return pos->var;
51 
52  return nullptr;
53 }
std::vector< SourceVariable * > PhysicsTools::SourceVariableSet::get ( bool  withMagic = false) const

Definition at line 55 of file SourceVariableSet.cc.

References reco::if(), kRegular, mps_fire::result, and vars.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), PhysicsTools::MVATrainer::connectProcessors(), PhysicsTools::TrainProcessor::doTrainBegin(), PhysicsTools::MVATrainer::findFinalProcessors(), PhysicsTools::MVATrainer::findUntrainedComputers(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), and PhysicsTools::stdStringPrintf().

56 {
57  std::vector<SourceVariable*> result(vars.size());
58 
59  for(std::vector<PosVar>::const_iterator iter = vars.begin();
60  iter != vars.end(); iter++)
61  result[iter->pos] = iter->var;
62 
63  if (!withMagic) {
64  unsigned int pos = vars.size();
65  for(std::vector<PosVar>::const_iterator iter = vars.begin();
66  iter != vars.end(); iter++)
67  if (iter->magic != kRegular) {
68  result.erase(result.begin() +
69  (iter->pos - (iter->pos >= pos)));
70  pos = iter->pos;
71  }
72  }
73 
74  return result;
75 }
if(dp >Float(M_PI)) dp-
size_type PhysicsTools::SourceVariableSet::size ( bool  withMagic = false) const
inline

Definition at line 32 of file SourceVariableSet.h.

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

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and PhysicsTools::MVATrainer::connectProcessors().

33  {
34  if (withMagic)
35  return vars.size();
36  else
37  return std::count_if(vars.begin(), vars.end(),
38  std::mem_fun_ref(&PosVar::noMagic));
39  }

Member Data Documentation

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

Definition at line 53 of file SourceVariableSet.h.

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