CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
VarSplitter Class Reference

#include <CachingVariable.h>

Inheritance diagram for VarSplitter:
Splitter CachingVariable

Public Member Functions

CachingVariable::evalType eval (const edm::Event &iEvent) const override
 
unsigned int maxSlots () const override
 
 VarSplitter (const CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
 
- Public Member Functions inherited from Splitter
const std::string & label (unsigned int i) const
 
unsigned int maxIndex () const
 
const std::string shortLabel (unsigned int i) const
 
 Splitter (std::string method, std::string n, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
- Public Member Functions inherited from CachingVariable
void addDescriptionLine (const std::string &s)
 
 CachingVariable (std::string m, std::string n, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
bool compute (const edm::Event &iEvent) const
 
const Descriptiondescription () const
 
const std::string & holderName () const
 
const std::string & method () const
 
const std::string & name () const
 
valueType operator() (const edm::Event &iEvent) const
 
void print () const
 
void setHolder (std::string hn) const
 
virtual ~CachingVariable ()
 

Protected Attributes

std::vector< double > slots_
 
bool useOverFlow_
 
bool useUnderFlow_
 
std::string var_
 
- Protected Attributes inherited from Splitter
std::vector< std::string > labels_
 
std::vector< std::string > short_labels_
 
- Protected Attributes inherited from CachingVariable
evalType cache_
 
edm::ParameterSet conf_
 
Description d_
 
edm::Event::CacheIdentifier_t eventCacheID_ = 0
 
std::string holderName_
 
std::string method_
 
std::string name_
 

Additional Inherited Members

- Public Types inherited from CachingVariable
typedef std::pair< bool, valueTypeevalType
 
typedef double valueType
 
typedef std::map< std::string, const CachingVariable * > vMap
 
- Protected Member Functions inherited from CachingVariable
evalTypebaseEval (const edm::Event &iEvent) const
 
bool notSeenThisEventAlready (const edm::Event &iEvent) const
 
void setCache (valueType &v) const
 
void setNotCompute () const
 

Detailed Description

Definition at line 220 of file CachingVariable.h.

Constructor & Destructor Documentation

◆ VarSplitter()

VarSplitter::VarSplitter ( const CachingVariableFactoryArg arg,
edm::ConsumesCollector iC 
)
inline

Definition at line 222 of file CachingVariable.h.

References CachingVariable::conf_, edm::ParameterSet::dump(), mps_fire::i, MainPageGenerator::l, Splitter::labels_, maxSlots(), CachingVariable::name(), Splitter::short_labels_, slots_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, useOverFlow_, useUnderFlow_, and var_.

223  : Splitter("VarSplitter", arg.n, arg.iConfig, iC) {
224  var_ = arg.iConfig.getParameter<std::string>("var");
225  useUnderFlow_ = arg.iConfig.getParameter<bool>("useUnderFlow");
226  useOverFlow_ = arg.iConfig.getParameter<bool>("useOverFlow");
227  slots_ = arg.iConfig.getParameter<std::vector<double> >("slots");
228  if (useUnderFlow_) {
229  labels_.push_back("underflow");
230  short_labels_.push_back("_" + arg.n + "_underflow");
231  }
232  std::vector<std::string> confLabels;
233  if (arg.iConfig.exists("labels")) {
234  confLabels = arg.iConfig.getParameter<std::vector<std::string> >("labels");
235  } else {
236  std::string labelFormat = arg.iConfig.getParameter<std::string>("labelsFormat");
237  for (unsigned int is = 0; is != slots_.size() - 1; ++is) {
238  std::string l(Form(labelFormat.c_str(), slots_[is], slots_[is + 1]));
239  confLabels.push_back(l);
240  }
241  }
242  for (unsigned int i = 0; i != confLabels.size(); ++i) {
243  labels_.push_back(confLabels[i]);
244  std::stringstream ss;
245  ss << "_" << arg.n << "_" << i;
246  short_labels_.push_back(ss.str());
247  }
248  if (useOverFlow_) {
249  labels_.push_back("overFlow");
250  short_labels_.push_back("_" + arg.n + "_overFlow");
251  }
252 
253  //check consistency
254  if (labels_.size() != maxSlots())
255  edm::LogError("Splitter") << "splitter with name: " << name() << " has inconsistent configuration\n"
256  << conf_.dump();
257 
258  arg.m[arg.n] = this;
259  }
unsigned int maxSlots() const override
std::vector< std::string > short_labels_
A arg
Definition: Factorize.h:31
std::vector< double > slots_
Splitter(std::string method, std::string n, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
edm::ParameterSet conf_
std::vector< std::string > labels_
std::string var_
std::string dump(unsigned int indent=0) const
const std::string & name() const

Member Function Documentation

◆ eval()

CachingVariable::evalType VarSplitter::eval ( const edm::Event iEvent) const
overridevirtual

Implements Splitter.

Definition at line 4 of file CachingVariable.cc.

References mps_fire::i, iEvent, Splitter::maxIndex(), slots_, useOverFlow_, useUnderFlow_, findQualityFiles::v, trigObjTnPSource_cfi::var, and var_.

4  {
6  if (!var->compute(iEvent))
7  return std::make_pair(false, 0);
8 
9  double v = (*var)(iEvent);
10  if (v < slots_.front()) {
11  if (useUnderFlow_)
12  return std::make_pair(true, 0);
13  else
14  return std::make_pair(false, 0);
15  }
16  if (v >= slots_.back()) {
17  if (useOverFlow_)
18  return std::make_pair(true, (double)maxIndex());
19  else
20  return std::make_pair(false, 0);
21  }
22  unsigned int i = 1;
23  for (; i < slots_.size(); ++i)
24  if (v < slots_[i])
25  break;
26 
27  if (useUnderFlow_)
28  return std::make_pair(true, (double)i);
29  //need to substract 1 because checking on upper edges
30  else
31  return std::make_pair(true, (double)i - 1);
32 }
unsigned int maxIndex() const
std::vector< double > slots_
int iEvent
Definition: GenABIO.cc:224
std::string var_

◆ maxSlots()

unsigned int VarSplitter::maxSlots ( ) const
inlineoverridevirtual

Reimplemented from Splitter.

Definition at line 264 of file CachingVariable.h.

References alignCSCRings::s, slots_, useOverFlow_, and useUnderFlow_.

Referenced by VarSplitter().

264  {
265  unsigned int s = slots_.size() - 1;
266  if (useUnderFlow_)
267  s++;
268  if (useOverFlow_)
269  s++;
270  return s;
271  }
std::vector< double > slots_

Member Data Documentation

◆ slots_

std::vector<double> VarSplitter::slots_
protected

Definition at line 277 of file CachingVariable.h.

Referenced by eval(), maxSlots(), and VarSplitter().

◆ useOverFlow_

bool VarSplitter::useOverFlow_
protected

Definition at line 276 of file CachingVariable.h.

Referenced by eval(), maxSlots(), and VarSplitter().

◆ useUnderFlow_

bool VarSplitter::useUnderFlow_
protected

Definition at line 275 of file CachingVariable.h.

Referenced by eval(), maxSlots(), and VarSplitter().

◆ var_

std::string VarSplitter::var_
protected

Definition at line 274 of file CachingVariable.h.

Referenced by eval(), and VarSplitter().