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.

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  }

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

Member Function Documentation

◆ eval()

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

Implements Splitter.

Definition at line 4 of file CachingVariable.cc.

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 }

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

◆ maxSlots()

unsigned int VarSplitter::maxSlots ( ) const
inlineoverridevirtual

Reimplemented from Splitter.

Definition at line 264 of file CachingVariable.h.

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

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

Referenced by VarSplitter().

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().

mps_fire.i
i
Definition: mps_fire.py:428
CachingVariable::conf_
edm::ParameterSet conf_
Definition: CachingVariable.h:110
Splitter::maxIndex
unsigned int maxIndex() const
Definition: CachingVariable.h:190
VarSplitter::maxSlots
unsigned int maxSlots() const override
Definition: CachingVariable.h:264
CachingVariable
Definition: CachingVariable.h:40
Splitter::labels_
std::vector< std::string > labels_
Definition: CachingVariable.h:216
findQualityFiles.v
v
Definition: findQualityFiles.py:179
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
VarSplitter::slots_
std::vector< double > slots_
Definition: CachingVariable.h:277
edm::ParameterSet::dump
std::string dump(unsigned int indent=0) const
Definition: ParameterSet.cc:832
Splitter::Splitter
Splitter(std::string method, std::string n, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
Definition: CachingVariable.h:184
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
VarSplitter::useOverFlow_
bool useOverFlow_
Definition: CachingVariable.h:276
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
VarSplitter::var_
std::string var_
Definition: CachingVariable.h:274
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
Splitter::short_labels_
std::vector< std::string > short_labels_
Definition: CachingVariable.h:217
CachingVariable::name
const std::string & name() const
Definition: CachingVariable.h:66
funct::arg
A arg
Definition: Factorize.h:31
edm::Log
Definition: MessageLogger.h:70
VarSplitter::useUnderFlow_
bool useUnderFlow_
Definition: CachingVariable.h:275