CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
utils::CheapValueSnapshot Struct Reference

#include <utils.h>

Public Member Functions

 CheapValueSnapshot ()
 
 CheapValueSnapshot (const RooAbsCollection &src)
 
void clear ()
 
bool empty () const
 
void Print (const char *fmt) const
 
void readFrom (const RooAbsCollection &)
 
const RooAbsCollection & src () const
 
void writeTo (const RooAbsCollection &) const
 

Private Attributes

const RooAbsCollection * src_
 
std::vector< double > values_
 

Detailed Description

Definition at line 72 of file utils.h.

Constructor & Destructor Documentation

utils::CheapValueSnapshot::CheapValueSnapshot ( )
inline

Definition at line 74 of file utils.h.

74 : src_(0) {}
const RooAbsCollection * src_
Definition: utils.h:83
utils::CheapValueSnapshot::CheapValueSnapshot ( const RooAbsCollection &  src)
inline

Definition at line 75 of file utils.h.

References readFrom().

75 : src_(0), values_() { readFrom(src); }
const RooAbsCollection * src_
Definition: utils.h:83
std::vector< double > values_
Definition: utils.h:84
const RooAbsCollection & src() const
Definition: utils.h:79
void readFrom(const RooAbsCollection &)
Definition: utils.cc:448

Member Function Documentation

void utils::CheapValueSnapshot::clear ( void  )
inline

Definition at line 78 of file utils.h.

References src_, and values_.

78 { src_ = 0; values_.clear(); }
const RooAbsCollection * src_
Definition: utils.h:83
std::vector< double > values_
Definition: utils.h:84
bool utils::CheapValueSnapshot::empty ( void  ) const
inline

Definition at line 80 of file utils.h.

References src_.

Referenced by Asymptotic::getCLs().

80 { return src_ == 0; }
const RooAbsCollection * src_
Definition: utils.h:83
void utils::CheapValueSnapshot::Print ( const char *  fmt) const

Definition at line 478 of file utils.cc.

References a, and i.

Referenced by Asymptotic::getCLs(), and Asymptotic::runLimit().

478  {
479  if (src_ == 0) { printf("<NIL>\n"); return; }
480  if (fmt[0] == 'V') {
481  RooLinkedListIter iter = src_->iterator(); int i = 0;
482  for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next(), ++i) {
483  printf(" %3d) %-30s = %9.6g\n", i, a->GetName(), values_[i]);
484  }
485  printf("\n");
486  } else {
487  src_->Print(fmt);
488  }
489 }
const RooAbsCollection * src_
Definition: utils.h:83
int i
Definition: DBlmapReader.cc:9
std::vector< double > values_
Definition: utils.h:84
static const char * fmt
Definition: Version.cc:9
double a
Definition: hdecay.h:121
void utils::CheapValueSnapshot::readFrom ( const RooAbsCollection &  src)

Definition at line 448 of file utils.cc.

References a, i, src(), src_, and values_.

Referenced by CheapValueSnapshot(), Asymptotic::getCLs(), and Asymptotic::runLimit().

448  {
449  if (&src != src_) {
450  src_ = &src;
451  values_.resize(src.getSize());
452  }
453  RooLinkedListIter iter = src.iterator(); int i = 0;
454  for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next(), ++i) {
455  RooRealVar *rrv = dynamic_cast<RooRealVar *>(a);
456  if (rrv == 0) throw std::invalid_argument("Collection to read from contains a non-RooRealVar");
457  values_[i] = rrv->getVal();
458  }
459 }
const RooAbsCollection * src_
Definition: utils.h:83
int i
Definition: DBlmapReader.cc:9
std::vector< double > values_
Definition: utils.h:84
const RooAbsCollection & src() const
Definition: utils.h:79
double a
Definition: hdecay.h:121
const RooAbsCollection& utils::CheapValueSnapshot::src ( ) const
inline

Definition at line 79 of file utils.h.

References src_.

Referenced by readFrom().

79 { return *src_; }
const RooAbsCollection * src_
Definition: utils.h:83
void utils::CheapValueSnapshot::writeTo ( const RooAbsCollection &  src) const

Definition at line 461 of file utils.cc.

References a, and i.

Referenced by Asymptotic::runLimit().

461  {
462  if (&src == src_) {
463  RooLinkedListIter iter = src.iterator(); int i = 0;
464  for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next(), ++i) {
465  RooRealVar *rrv = dynamic_cast<RooRealVar *>(a);
466  rrv->setVal(values_[i]);
467  }
468  } else {
469  RooLinkedListIter iter = src_->iterator(); int i = 0;
470  for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next(), ++i) {
471  RooAbsArg *a2 = src.find(a->GetName()); if (a2 == 0) continue;
472  RooRealVar *rrv = dynamic_cast<RooRealVar *>(a2);
473  rrv->setVal(values_[i]);
474  }
475  }
476 }
const RooAbsCollection * src_
Definition: utils.h:83
int i
Definition: DBlmapReader.cc:9
std::vector< double > values_
Definition: utils.h:84
const RooAbsCollection & src() const
Definition: utils.h:79
double a
Definition: hdecay.h:121

Member Data Documentation

const RooAbsCollection* utils::CheapValueSnapshot::src_
private

Definition at line 83 of file utils.h.

Referenced by clear(), empty(), readFrom(), and src().

std::vector<double> utils::CheapValueSnapshot::values_
private

Definition at line 84 of file utils.h.

Referenced by clear(), and readFrom().