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
 
- Public Attributes inherited from Splitter
list file = sys.argv[2]
 
list path = sys.argv[1]
 
list prefix = sys.argv[3]
 
tuple s = Splitter(path, file, prefix)
 
- 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 208 of file CachingVariable.h.

Constructor & Destructor Documentation

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

Definition at line 210 of file CachingVariable.h.

References CachingVariable::conf_, edm::ParameterSet::dump(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), i, CachingVariable::CachingVariableFactoryArg::iConfig, ConfigFiles::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_.

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

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

Referenced by VarSplitter().

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

Member Data Documentation

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

Definition at line 260 of file CachingVariable.h.

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

bool VarSplitter::useOverFlow_
protected

Definition at line 259 of file CachingVariable.h.

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

bool VarSplitter::useUnderFlow_
protected

Definition at line 258 of file CachingVariable.h.

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

std::string VarSplitter::var_
protected

Definition at line 257 of file CachingVariable.h.

Referenced by eval(), and VarSplitter().