CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
unsigned int maxSlots () const
 
 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,
valueType
evalType
 
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 209 of file CachingVariable.h.

Constructor & Destructor Documentation

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

Definition at line 211 of file CachingVariable.h.

References CachingVariable::conf_, edm::ParameterSet::dump(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), i, CachingVariable::CachingVariableFactoryArg::iConfig, prof2calltree::l, Splitter::labels_, CachingVariable::CachingVariableFactoryArg::m, maxSlots(), CachingVariable::CachingVariableFactoryArg::n, CachingVariable::name(), Splitter::short_labels_, slots_, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, useOverFlow_, useUnderFlow_, and var_.

211  :
212  Splitter("VarSplitter",arg.n,arg.iConfig,iC) {
213  var_=arg.iConfig.getParameter<std::string>("var");
214  useUnderFlow_=arg.iConfig.getParameter<bool>("useUnderFlow");
215  useOverFlow_=arg.iConfig.getParameter<bool>("useOverFlow");
216  slots_=arg.iConfig.getParameter<std::vector<double> >("slots");
217  if (useUnderFlow_){
218  labels_.push_back("underflow");
219  short_labels_.push_back("_"+arg.n+"_underflow");}
220  std::vector<std::string> confLabels;
221  if (arg.iConfig.exists("labels")){
222  confLabels=arg.iConfig.getParameter<std::vector<std::string> >("labels");
223  }
224  else{
225  std::string labelFormat = arg.iConfig.getParameter<std::string>("labelsFormat");
226  for (unsigned int is=0;is!=slots_.size()-1;++is){
227  std::string l(Form(labelFormat.c_str(),slots_[is],slots_[is+1]));
228  confLabels.push_back(l);
229  }
230  }
231  for (unsigned int i=0;i!=confLabels.size();++i){
232  labels_.push_back(confLabels[i]);
233  std::stringstream ss;
234  ss<<"_"<<arg.n<<"_"<<i;
235  short_labels_.push_back(ss.str());
236  }
237  if (useOverFlow_)
238  { labels_.push_back("overFlow");
239  short_labels_.push_back("_"+arg.n+"_overFlow");}
240 
241  //check consistency
242  if (labels_.size()!=maxSlots())
243  edm::LogError("Splitter")<<"splitter with name: "<<name()<<" has inconsistent configuration\n"<<conf_.dump();
244 
245  arg.m[arg.n]=this;
246  }
int i
Definition: DBlmapReader.cc:9
unsigned int maxSlots() const
std::string dump(unsigned int indent=0) const
std::vector< std::string > short_labels_
A arg
Definition: Factorize.h:36
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_
const std::string & name() const

Member Function Documentation

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

Implements Splitter.

Definition at line 4 of file CachingVariable.cc.

References CachingVariable::compute(), i, iEvent, Splitter::maxIndex(), slots_, useOverFlow_, useUnderFlow_, findQualityFiles::v, and var_.

4  {
5  const CachingVariable * var=edm::Service<VariableHelperService>()->get().variable(var_);
6  if (!var->compute(iEvent)) return std::make_pair(false,0);
7 
8  double v=(*var)(iEvent);
9  if (v<slots_.front()){
10  if (useUnderFlow_) return std::make_pair(true,0);
11  else return std::make_pair(false,0);
12  }
13  if (v>=slots_.back()){
14  if (useOverFlow_) return std::make_pair(true,(double)maxIndex());
15  else return std::make_pair(false,0);
16  }
17  unsigned int i=1;
18  for (;i<slots_.size();++i)
19  if (v<slots_[i]) break;
20 
21  if (useUnderFlow_) return std::make_pair(true,(double) i);
22  //need to substract 1 because checking on upper edges
23  else return std::make_pair(true,(double)i-1);
24 }
int i
Definition: DBlmapReader.cc:9
std::vector< double > slots_
unsigned int maxIndex() const
int iEvent
Definition: GenABIO.cc:230
bool compute(const edm::Event &iEvent) const
std::string var_
unsigned int VarSplitter::maxSlots ( ) const
inlinevirtual

Reimplemented from Splitter.

Definition at line 251 of file CachingVariable.h.

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

Referenced by VarSplitter().

251  {
252  unsigned int s=slots_.size()-1;
253  if (useUnderFlow_) s++;
254  if (useOverFlow_) s++;
255  return s;}
std::vector< double > slots_

Member Data Documentation

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

Definition at line 261 of file CachingVariable.h.

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

bool VarSplitter::useOverFlow_
protected

Definition at line 260 of file CachingVariable.h.

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

bool VarSplitter::useUnderFlow_
protected

Definition at line 259 of file CachingVariable.h.

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

std::string VarSplitter::var_
protected

Definition at line 258 of file CachingVariable.h.

Referenced by eval(), and VarSplitter().