CMS 3D CMS Logo

Public Member Functions | Private Attributes

utils::CheapValueSnapshot Struct Reference

#include <utils.h>

List of all members.

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.

: src_(0) {}
utils::CheapValueSnapshot::CheapValueSnapshot ( const RooAbsCollection &  src) [inline]

Definition at line 75 of file utils.h.

References readFrom().

: src_(0), values_() { readFrom(src); }

Member Function Documentation

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

Definition at line 78 of file utils.h.

References src_, and values_.

{ src_ = 0; values_.clear(); }
bool utils::CheapValueSnapshot::empty ( void  ) const [inline]

Definition at line 80 of file utils.h.

References src_.

Referenced by Asymptotic::getCLs().

{ return src_ == 0; }
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().

                                                         {
    if (src_ == 0) { printf("<NIL>\n"); return; }
    if (fmt[0] == 'V') {
        RooLinkedListIter iter = src_->iterator(); int i = 0;
        for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next(), ++i) {
            printf(" %3d) %-30s = %9.6g\n", i, a->GetName(), values_[i]);
        }
        printf("\n");
    } else {
        src_->Print(fmt);
    }
}
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().

                                                                  {
    if (&src != src_) {
        src_ = &src;
        values_.resize(src.getSize());
    }
    RooLinkedListIter iter = src.iterator(); int i = 0;
    for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next(), ++i) {
        RooRealVar *rrv = dynamic_cast<RooRealVar *>(a);
        if (rrv == 0) throw std::invalid_argument("Collection to read from contains a non-RooRealVar");
        values_[i] = rrv->getVal();
    }
}
const RooAbsCollection& utils::CheapValueSnapshot::src ( ) const [inline]

Definition at line 79 of file utils.h.

References src_.

Referenced by readFrom().

{ return *src_; }
void utils::CheapValueSnapshot::writeTo ( const RooAbsCollection &  src) const

Definition at line 461 of file utils.cc.

References a, and i.

Referenced by Asymptotic::runLimit().

                                                                       {
    if (&src == src_) {
        RooLinkedListIter iter = src.iterator();  int i = 0;
        for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next(), ++i) {
            RooRealVar *rrv = dynamic_cast<RooRealVar *>(a);
            rrv->setVal(values_[i]);
        }
    } else {
        RooLinkedListIter iter = src_->iterator();  int i = 0;
        for (RooAbsArg *a = (RooAbsArg *) iter.Next(); a != 0; a = (RooAbsArg *) iter.Next(), ++i) {
            RooAbsArg *a2 = src.find(a->GetName()); if (a2 == 0) continue;
            RooRealVar *rrv = dynamic_cast<RooRealVar *>(a2);
            rrv->setVal(values_[i]);
        }
    }
}

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