CMS 3D CMS Logo

VarSplitter Class Reference

#include <PhysicsTools/UtilAlgos/interface/CachingVariable.h>

Inheritance diagram for VarSplitter:

Splitter CachingVariable

List of all members.

Public Member Functions

CachingVariable::evalType eval (const edm::Event &iEvent) const
uint maxSlots () const
 VarSplitter (CachingVariableFactoryArg arg)

Protected Attributes

std::vector< double > slots_
bool useOverFlow_
bool useUnderFlow_
std::string var_


Detailed Description

Definition at line 188 of file CachingVariable.h.


Constructor & Destructor Documentation

VarSplitter::VarSplitter ( CachingVariableFactoryArg  arg  )  [inline]

Definition at line 190 of file CachingVariable.h.

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

00190                                               :
00191     Splitter("VarSplitter",arg.n,arg.iConfig) {
00192     var_=arg.iConfig.getParameter<std::string>("var");
00193     useUnderFlow_=arg.iConfig.getParameter<bool>("useUnderFlow");
00194     useOverFlow_=arg.iConfig.getParameter<bool>("useOverFlow");
00195     slots_=arg.iConfig.getParameter<std::vector<double> >("slots");
00196     if (useUnderFlow_){
00197       labels_.push_back("underflow");
00198       short_labels_.push_back("_"+arg.n+"_underflow");}
00199     std::vector<std::string> confLabels;
00200     if (arg.iConfig.exists("labels")){
00201       confLabels=arg.iConfig.getParameter<std::vector<std::string> >("labels");
00202     }
00203     else{
00204       std::string labelFormat = arg.iConfig.getParameter<std::string>("labelsFormat");
00205       for (uint is=0;is!=slots_.size()-1;++is){
00206         std::string l(Form(labelFormat.c_str(),slots_[is],slots_[is+1]));
00207         confLabels.push_back(l);
00208       }
00209     }
00210     for (uint i=0;i!=confLabels.size();++i){
00211       labels_.push_back(confLabels[i]);
00212       std::stringstream ss;
00213       ss<<"_"<<arg.n<<"_"<<i;
00214       short_labels_.push_back(ss.str());
00215     }
00216     if (useOverFlow_)
00217       { labels_.push_back("overFlow");
00218         short_labels_.push_back("_"+arg.n+"_overFlow");}
00219     
00220     //check consistency
00221     if (labels_.size()!=maxSlots())
00222       edm::LogError("Splitter")<<"splitter with name: "<<name()<<" has inconsistent configuration\n"<<conf_.dump();
00223 
00224     arg.m[arg.n]=this;
00225   }


Member Function Documentation

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

Implements Splitter.

Definition at line 6 of file CachingVariable.cc.

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

00006                                                                       {
00007   const CachingVariable * var=edm::Service<VariableHelperService>()->get().variable(var_);
00008   if (!var->compute(iEvent)) return std::make_pair(false,0);
00009 
00010   double v=(*var)(iEvent);
00011   if (v<slots_.front()){
00012     if (useUnderFlow_) return std::make_pair(true,0);
00013     else return std::make_pair(false,0);
00014   }
00015   if (v>=slots_.back()){
00016     if (useOverFlow_) return std::make_pair(true,(double)maxIndex());
00017     else return std::make_pair(false,0);
00018   }
00019   uint i=1;
00020   for (;i<slots_.size();++i)
00021     if (v<slots_[i]) break;
00022 
00023   if (useUnderFlow_) return std::make_pair(true,(double) i);
00024   //need to substract 1 because checking on upper edges
00025   else return std::make_pair(true,(double)i-1);
00026 }

uint VarSplitter::maxSlots (  )  const [inline, virtual]

Reimplemented from Splitter.

Definition at line 230 of file CachingVariable.h.

References s, slots_, useOverFlow_, and useUnderFlow_.

Referenced by VarSplitter().

00230                        {
00231     uint s=slots_.size()-1;
00232     if (useUnderFlow_) s++;
00233     if (useOverFlow_) s++;
00234     return s;}


Member Data Documentation

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

Definition at line 240 of file CachingVariable.h.

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

bool VarSplitter::useOverFlow_ [protected]

Definition at line 239 of file CachingVariable.h.

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

bool VarSplitter::useUnderFlow_ [protected]

Definition at line 238 of file CachingVariable.h.

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

std::string VarSplitter::var_ [protected]

Definition at line 237 of file CachingVariable.h.

Referenced by eval(), and VarSplitter().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:34:57 2009 for CMSSW by  doxygen 1.5.4