00001 // @(#)root/roostats:$Id: RooStatsUtils.h 37161 2010-12-01 22:04:07Z moneta $ 00002 // Author: Kyle Cranmer 28/07/2008 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #ifndef RooStats_RooStatsUtils 00013 #define RooStats_RooStatsUtils 00014 00015 #ifndef ROOT_TMath 00016 #include "TMath.h" 00017 #endif 00018 00019 #ifndef ROOT_Math_DistFuncMathCore 00020 #include"Math/DistFuncMathCore.h" 00021 #endif 00022 00023 #include "RooArgSet.h" 00024 #include "RooRealVar.h" 00025 #include "RooAbsCollection.h" 00026 #include "TIterator.h" 00027 00028 #include <iostream> 00029 using namespace std ; 00030 00031 namespace RooStats { 00032 00033 // returns one-sided significance corresponding to a p-value 00034 inline Double_t PValueToSignificance(Double_t pvalue){ 00035 return ::ROOT::Math::normal_quantile_c(pvalue,1); 00036 } 00037 00038 // returns p-value corresponding to a 1-sided significance 00039 inline Double_t SignificanceToPValue(Double_t Z){ 00040 return ::ROOT::Math::normal_cdf_c(Z); 00041 } 00042 00043 00044 inline void SetParameters(const RooArgSet* desiredVals, RooArgSet* paramsToChange){ 00045 *paramsToChange=*desiredVals ; 00046 } 00047 00048 inline void RemoveConstantParameters(RooArgSet* set){ 00049 RooArgSet constSet; 00050 TIter it = set->createIterator(); 00051 RooRealVar *myarg; 00052 while ((myarg = (RooRealVar *)it.Next())) { 00053 if(myarg->isConstant()) constSet.add(*myarg); 00054 } 00055 set->remove(constSet); 00056 } 00057 00058 // assuming all values in set are RooRealVars, randomize their values 00059 inline void RandomizeCollection(RooAbsCollection& set, 00060 Bool_t randomizeConstants = kTRUE) 00061 { 00062 TIterator* it = set.createIterator(); 00063 RooRealVar* var; 00064 00065 while ((var = (RooRealVar*)it->Next()) != NULL) 00066 if (!var->isConstant() || randomizeConstants) 00067 var->randomize(); 00068 00069 delete it; 00070 } 00071 00072 } 00073 00074 #endif