#include <Quantile.h>
Public Types | |
typedef std::vector< pair > | array |
typedef std::pair< double, double > | pair |
Public Member Functions | |
pair | fromHead (const double frac) const |
pair | fromTail (const double frac) const |
pair | operator() (const double frac) const |
pair | operator[] (const double frac) const |
Quantile (const TH1 *h) | |
Quantile (double central, double err) | |
double | spread (TH1F &hist) |
double | spreadError (TH1F &hist) |
double | value (TH1F &hist) |
double | valueError (TH1F &hist) |
~Quantile () | |
Private Member Functions | |
pair | calculateQ (const double frac, const bool fromHead) const |
double | distance (TH1F &hist) |
void | evaluate (double &err) |
template<class T > | |
T | next (T bin, T end) const |
template<class T > | |
T | prev (T bin, T begin) const |
void | quantiles (TH1F &hist, double err) |
Private Attributes | |
double | central_ |
double | err_ |
array | head |
const int | N |
double | qnt_ [3] |
array | tail |
const double | Total |
double | val_ [3] |
Definition at line 8 of file Quantile.h.
typedef std::vector<pair> Quantile::array |
Definition at line 10 of file Quantile.h.
typedef std::pair<double,double> Quantile::pair |
Definition at line 9 of file Quantile.h.
Quantile::Quantile | ( | const TH1 * | h | ) | [inline] |
Definition at line 15 of file Quantile.h.
References head, i, N, and tail.
: N( 1 + h->GetNbinsX()), Total(h->Integral(0,N)) { for(int i=0;i<N; i++) { const double H = h->GetBinContent(i) + (head.size()?head.back().second:0); const double T = h->GetBinContent(N-i) + (tail.size()?tail.back().second:0); if(H) head.push_back( pair( h->GetBinWidth(i) + h->GetBinLowEdge(i) , H)); if(T) tail.push_back( pair( h->GetBinLowEdge(N-i),T)); } }
Quantile::Quantile | ( | double | central, |
double | err | ||
) | [inline] |
Definition at line 42 of file CompMethods.h.
Quantile::~Quantile | ( | ) | [inline] |
Definition at line 43 of file CompMethods.h.
{};
pair Quantile::calculateQ | ( | const double | frac, |
const bool | fromHead | ||
) | const [inline, private] |
Definition at line 31 of file Quantile.h.
References begin, newFWLiteAna::bin, end, f, cropTnPTrees::frac, head, max(), next(), prev(), mathSSE::sqrt(), tail, and Total.
Referenced by fromHead(), and fromTail().
{ const double f = frac<0.5 ? frac : 1-frac ; array::const_iterator begin( ( (frac<0.5) == fromHead ) ? head.begin() : tail.begin()), end( ( (frac<0.5) == fromHead ) ? head.end() : tail.end()), bin(begin); while( bin->second < f*Total ) bin++; //dk if( bin==begin ) return pair(sqrt(-1),0); if( bin==begin ) return pair(-1,0); array::const_iterator binNext( next(bin,end)), binPrev( prev(bin,begin)), binPPrev( prev(binPrev,begin)); const double DX( binNext->first - binPPrev->first ), DY( (binNext->second - binPPrev->second)/Total ), dX( bin->first - binPrev->first ), dY( (bin->second - binPrev->second)/Total ), avgX( ( bin->first + binPrev->first) /2 ), avgY( ( bin->second + binPrev->second) /(2*Total) ), x_q( avgX + dX/dY * ( f - avgY ) ), xerr_q( std::max(fabs(DX/DY),fabs(dX/dY)) * sqrt(f*(1-f)/Total) ); return pair(x_q,xerr_q); }
double Quantile::distance | ( | TH1F & | hist | ) | [inline, private] |
Definition at line 53 of file CompMethods.h.
References qnt_.
Referenced by spread(), spreadError(), and valueError().
void Quantile::evaluate | ( | double & | err | ) | [inline, private] |
pair Quantile::fromHead | ( | const double | frac | ) | const [inline] |
Definition at line 26 of file Quantile.h.
References calculateQ().
Referenced by operator()().
{return calculateQ(frac,true);}
pair Quantile::fromTail | ( | const double | frac | ) | const [inline] |
Definition at line 27 of file Quantile.h.
References calculateQ().
Referenced by operator[]().
{return calculateQ(frac,false);}
Definition at line 72 of file Quantile.h.
References newFWLiteAna::bin, and edm::second().
Referenced by calculateQ().
pair Quantile::operator() | ( | const double | frac | ) | const [inline] |
pair Quantile::operator[] | ( | const double | frac | ) | const [inline] |
Definition at line 64 of file Quantile.h.
References newFWLiteAna::bin, and edm::second().
Referenced by calculateQ().
void Quantile::quantiles | ( | TH1F & | hist, |
double | err | ||
) | [inline, private] |
Definition at line 52 of file CompMethods.h.
References evaluate(), qnt_, and val_.
Referenced by spread(), spreadError(), value(), and valueError().
double Quantile::spread | ( | TH1F & | hist | ) | [inline] |
Definition at line 46 of file CompMethods.h.
References distance(), and quantiles().
Referenced by FitHist::fillTargetHistogramBin().
double Quantile::spreadError | ( | TH1F & | hist | ) |
Definition at line 92 of file CompMethods.cc.
References distance(), err_, SurfaceOrientation::inner, SurfaceOrientation::outer, and quantiles().
Referenced by FitHist::fillTargetHistogramBin().
double Quantile::value | ( | TH1F & | hist | ) | [inline] |
Definition at line 44 of file CompMethods.h.
References err_, qnt_, and quantiles().
Referenced by FitHist::fillTargetHistogramBin().
double Quantile::valueError | ( | TH1F & | hist | ) | [inline] |
Definition at line 45 of file CompMethods.h.
References distance(), err_, and quantiles().
Referenced by FitHist::fillTargetHistogramBin().
double Quantile::central_ [private] |
Definition at line 53 of file CompMethods.h.
Referenced by evaluate().
double Quantile::err_ [private] |
Definition at line 58 of file CompMethods.h.
Referenced by spreadError(), value(), and valueError().
array Quantile::head [private] |
Definition at line 82 of file Quantile.h.
Referenced by calculateQ(), and Quantile().
const int Quantile::N [private] |
Definition at line 80 of file Quantile.h.
Referenced by Quantile().
double Quantile::qnt_[3] [private] |
Definition at line 60 of file CompMethods.h.
Referenced by distance(), quantiles(), and value().
array Quantile::tail [private] |
Definition at line 82 of file Quantile.h.
Referenced by calculateQ(), and Quantile().
const double Quantile::Total [private] |
Definition at line 81 of file Quantile.h.
Referenced by calculateQ().
double Quantile::val_[3] [private] |
Definition at line 59 of file CompMethods.h.
Referenced by evaluate(), and quantiles().