| Factory.h | | Factory.h | |
|
| // @(#)root/tmva $Id: Factory.h 40012 2011-06-27 16:03:11Z stelzer $ | | // @(#)root/mathcore:$Id: Factory.h 37448 2010-12-09 20:20:56Z moneta $ | |
| // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss, Ka | | // Author: L. Moneta Fri Dec 22 14:43:33 2006 | |
| i Voss, Eckhard von Toerne, Jan Therhaag | | | |
| | | | |
|
| /************************************************************************** | | /********************************************************************** | |
| ******** | | * * | |
| * Project: TMVA - a Root-integrated toolkit for multivariate data analysis | | * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT * | |
| * | | * * | |
| * Package: TMVA | | * * | |
| * | | **********************************************************************/ | |
| * Class : Factory | | | |
| * | | // Header file for class Factory | |
| * Web : http://tmva.sourceforge.net | | | |
| * | | #ifndef ROOT_Math_Factory | |
| * | | #define ROOT_Math_Factory | |
| * | | | |
| * Description: | | | |
| * | | | |
| * This is the main MVA steering class: it creates (books) all MVA met | | | |
| hods, * | | | |
| * and guides them through the training, testing and evaluation phases | | | |
| . * | | | |
| * | | | |
| * | | | |
| * Authors (alphabetical): | | | |
| * | | | |
| * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland | | | |
| * | | | |
| * Joerg Stelzer <stelzer@cern.ch> - DESY, Germany | | | |
| * | | | |
| * Peter Speckmayer <peter.speckmayer@cern.ch> - CERN, Switzerland | | | |
| * | | | |
| * Jan Therhaag <Jan.Therhaag@cern.ch> - U of Bonn, Germany | | | |
| * | | | |
| * Eckhard v. Toerne <evt@uni-bonn.de> - U of Bonn, Germany | | | |
| * | | | |
| * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, German | | | |
| y * | | | |
| * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada | | | |
| * | | | |
| * | | | |
| * | | | |
| * Copyright (c) 2005-2011: | | | |
| * | | | |
| * CERN, Switzerland | | | |
| * | | | |
| * U. of Victoria, Canada | | | |
| * | | | |
| * MPI-K Heidelberg, Germany | | | |
| * | | | |
| * U. of Bonn, Germany | | | |
| * | | | |
| * | | | |
| * | | | |
| * Redistribution and use in source and binary forms, with or without | | | |
| * | | | |
| * modification, are permitted according to the terms listed in LICENSE | | | |
| * | | | |
| * (http://tmva.sourceforge.net/LICENSE) | | | |
| * | | | |
| ************************************************************************** | | | |
| ********/ | | | |
| | | | |
| #ifndef ROOT_TMVA_Factory | | | |
| #define ROOT_TMVA_Factory | | | |
| | | | |
| ////////////////////////////////////////////////////////////////////////// | | | |
| // // | | | |
| // Factory // | | | |
| // // | | | |
| // This is the main MVA steering class: it creates all MVA methods, // | | | |
| // and guides them through the training, testing and evaluation // | | | |
| // phases // | | | |
| // // | | | |
| ////////////////////////////////////////////////////////////////////////// | | | |
| | | | |
| #include <string> | | #include <string> | |
|
| #include <vector> | | | |
| #include <map> | | | |
| #ifndef ROOT_TCut | | | |
| #include "TCut.h" | | | |
| #endif | | | |
| | | | |
| #ifndef ROOT_TMVA_Configurable | | | |
| #include "TMVA/Configurable.h" | | | |
| #endif | | | |
| #ifndef ROOT_TMVA_Types | | | |
| #include "TMVA/Types.h" | | | |
| #endif | | | |
| #ifndef ROOT_TMVA_DataSet | | | |
| #include "TMVA/DataSet.h" | | | |
| #endif | | | |
| | | | |
| class TFile; | | | |
| class TTree; | | | |
| class TDirectory; | | | |
| | | | |
| namespace TMVA { | | | |
| | | | |
| class IMethod; | | | |
| class MethodBase; | | | |
| class DataInputHandler; | | | |
| class DataSetInfo; | | | |
| class DataSetManager; | | | |
| class VariableTransformBase; | | | |
| | | | |
| class Factory : public Configurable { | | | |
| public: | | | |
| | | | |
| typedef std::vector<IMethod*> MVector; | | | |
| | | | |
| // no default constructor | | | |
| Factory( TString theJobName, TFile* theTargetFile, TString theOption | | | |
| = "" ); | | | |
| | | | |
| // default destructor | | | |
| virtual ~Factory(); | | | |
| | | | |
| virtual const char* GetName() const { return "Factory"; } | | | |
| | | | |
| // add events to training and testing trees | | | |
| void AddSignalTrainingEvent ( const std::vector<Double_t>& event, | | | |
| Double_t weight = 1.0 ); | | | |
| void AddBackgroundTrainingEvent( const std::vector<Double_t>& event, | | | |
| Double_t weight = 1.0 ); | | | |
| void AddSignalTestEvent ( const std::vector<Double_t>& event, | | | |
| Double_t weight = 1.0 ); | | | |
| void AddBackgroundTestEvent ( const std::vector<Double_t>& event, | | | |
| Double_t weight = 1.0 ); | | | |
| void AddTrainingEvent( const TString& className, const std::vector<Do | | | |
| uble_t>& event, Double_t weight ); | | | |
| void AddTestEvent ( const TString& className, const std::vector<Do | | | |
| uble_t>& event, Double_t weight ); | | | |
| void AddEvent ( const TString& className, Types::ETreeType tt, | | | |
| const std::vector<Double_t>& event, Double_t weight ); | | | |
| Bool_t UserAssignEvents(UInt_t clIndex); | | | |
| TTree* CreateEventAssignTrees( const TString& name ); | | | |
| | | | |
| DataSetInfo& AddDataSet( DataSetInfo& ); | | | |
| DataSetInfo& AddDataSet( const TString& ); | | | |
| | | | |
| // special case: signal/background | | | |
| | | | |
| // Data input related | | | |
| void SetInputTrees( const TString& signalFileName, const TString& bac | | | |
| kgroundFileName, | | | |
| Double_t signalWeight=1.0, Double_t backgroundWei | | | |
| ght=1.0 ); | | | |
| void SetInputTrees( TTree* inputTree, const TCut& SigCut, const TCut& | | | |
| BgCut ); | | | |
| // Set input trees at once | | | |
| void SetInputTrees( TTree* signal, TTree* background, | | | |
| Double_t signalWeight=1.0, Double_t backgroundWei | | | |
| ght=1.0) ; | | | |
| | | | |
| void AddSignalTree( TTree* signal, Double_t weight=1.0, Types::ETr | | | |
| eeType treetype = Types::kMaxTreeType ); | | | |
| void AddSignalTree( TString datFileS, Double_t weight=1.0, Types::ETr | | | |
| eeType treetype = Types::kMaxTreeType ); | | | |
| void AddSignalTree( TTree* signal, Double_t weight, const TString& tr | | | |
| eetype ); | | | |
| | | | |
| // ... depreciated, kept for backwards compatibility | | | |
| void SetSignalTree( TTree* signal, Double_t weight=1.0); | | | |
| | | | |
| void AddBackgroundTree( TTree* background, Double_t weight=1.0, Types | | | |
| ::ETreeType treetype = Types::kMaxTreeType ); | | | |
| void AddBackgroundTree( TString datFileB, Double_t weight=1.0, Types | | | |
| ::ETreeType treetype = Types::kMaxTreeType ); | | | |
| void AddBackgroundTree( TTree* background, Double_t weight, const TSt | | | |
| ring & treetype ); | | | |
| | | | |
| // ... depreciated, kept for backwards compatibility | | | |
| void SetBackgroundTree( TTree* background, Double_t weight=1.0 ); | | | |
| | | | |
| void SetSignalWeightExpression( const TString& variable ); | | | |
| void SetBackgroundWeightExpression( const TString& variable ); | | | |
| | | | |
| // special case: regression | | | |
| void AddRegressionTree( TTree* tree, Double_t weight = 1.0, | | | |
| Types::ETreeType treetype = Types::kMaxTreeTy | | | |
| pe ) { | | | |
| AddTree( tree, "Regression", weight, "", treetype ); | | | |
| } | | | |
| | | | |
| // general | | | |
| | | | |
| // Data input related | | | |
| void SetTree( TTree* tree, const TString& className, Double_t weight | | | |
| ); // depreciated | | | |
| void AddTree( TTree* tree, const TString& className, Double_t weight= | | | |
| 1.0, | | | |
| const TCut& cut = "", | | | |
| Types::ETreeType tt = Types::kMaxTreeType ); | | | |
| void AddTree( TTree* tree, const TString& className, Double_t weight, | | | |
| const TCut& cut, const TString& treeType ); | | | |
| | | | |
| // set input variable | | | |
| void SetInputVariables ( std::vector<TString>* theVariables ); // de | | | |
| preciated | | | |
| void AddVariable ( const TString& expression, const TString& t | | | |
| itle, const TString& unit, | | | |
| char type='F', Double_t min = 0, Double_t m | | | |
| ax = 0 ); | | | |
| void AddVariable ( const TString& expression, char type='F', | | | |
| Double_t min = 0, Double_t max = 0 ); | | | |
| void AddTarget ( const TString& expression, const TString& t | | | |
| itle = "", const TString& unit = "", | | | |
| Double_t min = 0, Double_t max = 0 ); | | | |
| void AddRegressionTarget( const TString& expression, const TString& t | | | |
| itle = "", const TString& unit = "", | | | |
| Double_t min = 0, Double_t max = 0 ) | | | |
| { | | | |
| AddTarget( expression, title, unit, min, max ); | | | |
| } | | | |
| void AddSpectator ( const TString& expression, const TString& | | | |
| title = "", const TString& unit = "", | | | |
| Double_t min = 0, Double_t max = 0 ); | | | |
| | | | |
| // set weight for class | | | |
| void SetWeightExpression( const TString& variable, const TString& cla | | | |
| ssName = "" ); | | | |
| | | | |
| // set cut for class | | | |
| void SetCut( const TString& cut, const TString& className = "" ); | | | |
| void SetCut( const TCut& cut, const TString& className = "" ); | | | |
| void AddCut( const TString& cut, const TString& className = "" ); | | | |
| void AddCut( const TCut& cut, const TString& className = "" ); | | | |
| | | | |
| // prepare input tree for training | | | |
| void PrepareTrainingAndTestTree( const TCut& cut, const TString& spli | | | |
| tOpt ); | | | |
| void PrepareTrainingAndTestTree( TCut sigcut, TCut bkgcut, const TStr | | | |
| ing& splitOpt ); | | | |
| | | | |
| // ... deprecated, kept for backwards compatibility | | | |
| void PrepareTrainingAndTestTree( const TCut& cut, Int_t Ntrain, Int_t | | | |
| Ntest = -1 ); | | | |
| | | | |
| void PrepareTrainingAndTestTree( const TCut& cut, Int_t NsigTrain, In | | | |
| t_t NbkgTrain, Int_t NsigTest, Int_t NbkgTest, | | | |
| const TString& otherOpt="SplitMode=R | | | |
| andom:!V" ); | | | |
| | | | |
| MethodBase* BookMethod( TString theMethodName, TString methodTitle, T | | | |
| String theOption = "" ); | | | |
| MethodBase* BookMethod( Types::EMVA theMethod, TString methodTitle, | | | |
| TString theOption = "" ); | | | |
| MethodBase* BookMethod( TMVA::Types::EMVA /*theMethod*/, | | | |
| TString /*methodTitle*/, | | | |
| TString /*methodOption*/, | | | |
| TMVA::Types::EMVA /*theCommittee*/, | | | |
| TString /*committeeOption = ""*/ ) { return 0 | | | |
| ; } | | | |
| | | | |
| // optimize all booked methods (well, if desired by the method) | | | |
| void OptimizeAllMethods (TString fomType="ROCIntegral | | | |
| ", TString fitType="FitGA"); | | | |
| void OptimizeAllMethodsForClassification(TString fomType="ROCIntegral | | | |
| ", TString fitType="FitGA") { OptimizeAllMethods(fomType,fitType); } | | | |
| void OptimizeAllMethodsForRegression (TString fomType="ROCIntegral | | | |
| ", TString fitType="FitGA") { OptimizeAllMethods(fomType,fitType); } | | | |
| | | | |
| // training for all booked methods | | | |
| void TrainAllMethods (); | | | |
| void TrainAllMethodsForClassification( void ) { TrainAllMethods(); } | | | |
| void TrainAllMethodsForRegression ( void ) { TrainAllMethods(); } | | | |
| | | | |
| // testing | | | |
| void TestAllMethods(); | | | |
| | | | |
| // performance evaluation | | | |
| void EvaluateAllMethods( void ); | | | |
| void EvaluateAllVariables( TString options = "" ); | | | |
| | | | |
| // delete all methods and reset the method vector | | | |
| void DeleteAllMethods( void ); | | | |
| | | | |
| // accessors | | | |
| IMethod* GetMethod( const TString& title ) const; | | | |
| | | | |
| Bool_t Verbose( void ) const { return fVerbose; } | | | |
| void SetVerbose( Bool_t v=kTRUE ); | | | |
| | | | |
| // make ROOT-independent C++ class for classifier response | | | |
| // (classifier-specific implementation) | | | |
| // If no classifier name is given, help messages for all booked | | | |
| // classifiers are printed | | | |
| virtual void MakeClass( const TString& methodTitle = "" ) const; | | | |
| | | | |
| // prints classifier-specific hepl messages, dedicated to | | | |
| // help with the optimisation and configuration options tuning. | | | |
| // If no classifier name is given, help messages for all booked | | | |
| // classifiers are printed | | | |
| void PrintHelpMessage( const TString& methodTitle = "" ) const; | | | |
| | | | |
| static TDirectory* RootBaseDir() { return (TDirectory*)fgTargetFile; | | | |
| } | | | |
| | | | |
| private: | | | |
| | | | |
| // the beautiful greeting message | | | |
| void Greetings(); | | | |
| | | | |
| void WriteDataInformation(); | | | |
| | | | |
| DataInputHandler& DataInput() { return *fDataInputHandler; } | | | |
| DataSetInfo& DefaultDataSetInfo(); | | | |
| void SetInputTreesFromEventAssignTrees(); | | | |
| | | | |
| private: | | | |
| | | | |
| // data members | | | |
| | | | |
| DataSetManager* fDataSetManager; // DSMTEST | | | |
| | | | |
| static TFile* fgTargetFile; //! ROOT | | | |
| output file | | | |
| | | | |
| DataInputHandler* fDataInputHandler; | | | |
| | | | |
| std::vector<TMVA::VariableTransformBase*> fDefaultTrfs; //! list | | | |
| of transformations on default DataSet | | | |
| | | | |
| // cd to local directory | | | |
| TString fOptions; //! optio | | | |
| n string given by construction (presently only "V") | | | |
| TString fTransformations; //! List | | | |
| of transformations to test | | | |
| Bool_t fVerbose; //! verbo | | | |
| se mode | | | |
| | | | |
| MVector fMethods; //! all M | | | |
| VA methods | | | |
| TString fJobName; //! jobna | | | |
| me, used as extension in weight file names | | | |
| | | | |
| // flag determining the way training and test data are assigned to Fa | | | |
| ctory | | | |
| enum DataAssignType { kUndefined = 0, | | | |
| kAssignTrees, | | | |
| kAssignEvents }; | | | |
| DataAssignType fDataAssignType; //! flags | | | |
| for data assigning | | | |
| std::vector<TTree*> fTrainAssignTree; //! for e | | | |
| ach class: tmp tree if user wants to assign the events directly | | | |
| std::vector<TTree*> fTestAssignTree; //! for e | | | |
| ach class: tmp tree if user wants to assign the events directly | | | |
| | | | |
| Int_t fATreeType; // typ | | | |
| e of event (=classIndex) | | | |
| Float_t fATreeWeight; // wei | | | |
| ght of the event | | | |
| Float_t* fATreeEvent; // eve | | | |
| nt variables | | | |
| | | | |
| Types::EAnalysisType fAnalysisType; //! the t | | | |
| raining type | | | |
| | | | |
|
| protected: | | namespace ROOT { | |
| | | | |
| | | namespace Math { | |
| | | | |
| | | class Minimizer; | |
| | | class DistSampler; | |
| | | | |
| | | //_________________________________________________________________________ | |
| | | __ | |
| | | /** | |
| | | Factory class holding static functions to create the interfaces like RO | |
| | | OT::Math::Minimizer | |
| | | via the Plugin Manager | |
| | | */ | |
| | | class Factory { | |
| | | public: | |
| | | | |
| | | /** | |
| | | static method to create the corrisponding Minimizer given the string | |
| | | Supported Minimizers types are: | |
| | | Minuit (TMinuit), Minuit2, GSLMultiMin, GSLMultiFit, GSLSimAn, Linear | |
| | | , Fumili, Genetic | |
| | | If no name is given use default values defined in MinimizerOptions | |
| | | */ | |
| | | static ROOT::Math::Minimizer * CreateMinimizer(const std::string & minim | |
| | | izerType = "", const std::string & algoType = ""); | |
| | | | |
| | | /** | |
| | | static method to create the distribution sampler class given a string | |
| | | specifying the type | |
| | | Supported sampler types are: | |
| | | Unuran, Foam | |
| | | If no name is given use default values defined in DistSamplerOptions | |
| | | */ | |
| | | static ROOT::Math::DistSampler * CreateDistSampler(const std::string & s | |
| | | amplerType =""); | |
| | | | |
| | | }; | |
| | | | |
|
| ClassDef(Factory,0) // The factory creates all MVA methods, and perf | | } // end namespace Fit | |
| orms their training and testing | | | |
| }; | | | |
| | | | |
|
| } // namespace TMVA | | } // end namespace ROOT | |
| | | | |
|
| #endif | | #endif /* ROOT_Fit_MinimizerFactory */ | |
| | | | |
End of changes. 7 change blocks. |
| 360 lines changed or deleted | | 53 lines changed or added | |
|
| MCMCCalculator.h | | MCMCCalculator.h | |
|
| // @(#)root/roostats:$Id: MCMCCalculator.h 39391 2011-05-26 09:51:59Z monet
a $ | | // @(#)root/roostats:$Id: MCMCCalculator.h 40961 2011-09-20 17:08:56Z monet
a $ | |
| // Authors: Kevin Belasco 17/06/2009 | | // Authors: Kevin Belasco 17/06/2009 | |
| // Authors: Kyle Cranmer 17/06/2009 | | // Authors: Kyle Cranmer 17/06/2009 | |
| /************************************************************************* | | /************************************************************************* | |
| * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * | | * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * | |
| * All rights reserved. * | | * All rights reserved. * | |
| * * | | * * | |
| * For the licensing terms see $ROOTSYS/LICENSE. * | | * For the licensing terms see $ROOTSYS/LICENSE. * | |
| * For the list of contributors see $ROOTSYS/README/CREDITS. * | | * For the list of contributors see $ROOTSYS/README/CREDITS. * | |
| *************************************************************************/ | | *************************************************************************/ | |
| | | | |
| | | | |
| skipping to change at line 85 | | skipping to change at line 85 | |
| | | | |
| // Set the Pdf if not already there | | // Set the Pdf if not already there | |
| virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; } | | virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; } | |
| | | | |
| // Set the Prior Pdf if not already there | | // Set the Prior Pdf if not already there | |
| virtual void SetPriorPdf(RooAbsPdf& pdf) { fPriorPdf = &pdf; } | | virtual void SetPriorPdf(RooAbsPdf& pdf) { fPriorPdf = &pdf; } | |
| | | | |
| // specify the parameters of interest in the interval | | // specify the parameters of interest in the interval | |
| virtual void SetParameters(const RooArgSet& set) { fPOI.removeAll();
fPOI.add(set); } | | virtual void SetParameters(const RooArgSet& set) { fPOI.removeAll();
fPOI.add(set); } | |
| | | | |
|
| | | // specify the parameters to store in the Markov chain | |
| | | // By default all the parameters are stored | |
| | | virtual void SetChainParameters(const RooArgSet & set) { fChainParams | |
| | | .removeAll(); fChainParams.add(set); } | |
| | | | |
| // specify the nuisance parameters (eg. the rest of the parameters) | | // specify the nuisance parameters (eg. the rest of the parameters) | |
| virtual void SetNuisanceParameters(const RooArgSet& set) {fNuisParams
.removeAll(); fNuisParams.add(set);} | | virtual void SetNuisanceParameters(const RooArgSet& set) {fNuisParams
.removeAll(); fNuisParams.add(set);} | |
| | | | |
| // set the size of the test (rate of Type I error) ( Eg. 0.05 for a 9
5% Confidence Interval) | | // set the size of the test (rate of Type I error) ( Eg. 0.05 for a 9
5% Confidence Interval) | |
| virtual void SetTestSize(Double_t size) {fSize = size;} | | virtual void SetTestSize(Double_t size) {fSize = size;} | |
| | | | |
| // set the confidence level for the interval (eg. 0.95 for a 95% Conf
idence Interval) | | // set the confidence level for the interval (eg. 0.95 for a 95% Conf
idence Interval) | |
| virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl;} | | virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl;} | |
| | | | |
| // set the proposal function for suggesting new points for the MCMC | | // set the proposal function for suggesting new points for the MCMC | |
| | | | |
| skipping to change at line 175 | | skipping to change at line 179 | |
| << "negative delta value" << endl; | | << "negative delta value" << endl; | |
| else | | else | |
| fDelta = delta; | | fDelta = delta; | |
| } | | } | |
| | | | |
| protected: | | protected: | |
| | | | |
| Double_t fSize; // size of the test (eg. specified rate of Type I e
rror) | | Double_t fSize; // size of the test (eg. specified rate of Type I e
rror) | |
| RooArgSet fPOI; // parameters of interest for interval | | RooArgSet fPOI; // parameters of interest for interval | |
| RooArgSet fNuisParams; // nuisance parameters for interval (not rea
lly used) | | RooArgSet fNuisParams; // nuisance parameters for interval (not rea
lly used) | |
|
| | | RooArgSet fChainParams; // parameters to store in the chain (if not
specified they are all of them ) | |
| mutable ProposalFunction* fPropFunc; // Proposal function for MCMC in
tegration | | mutable ProposalFunction* fPropFunc; // Proposal function for MCMC in
tegration | |
| RooAbsPdf * fPdf; // pointer to common PDF (owned by the works
pace) | | RooAbsPdf * fPdf; // pointer to common PDF (owned by the works
pace) | |
| RooAbsPdf * fPriorPdf; // pointer to prior PDF (owned by the works
pace) | | RooAbsPdf * fPriorPdf; // pointer to prior PDF (owned by the works
pace) | |
| RooAbsData * fData; // pointer to the data (owned by the workspac
e) | | RooAbsData * fData; // pointer to the data (owned by the workspac
e) | |
| Int_t fNumIters; // number of iterations to run metropolis algorithm | | Int_t fNumIters; // number of iterations to run metropolis algorithm | |
| Int_t fNumBurnInSteps; // number of iterations to discard as burn-in,
starting from the first | | Int_t fNumBurnInSteps; // number of iterations to discard as burn-in,
starting from the first | |
| Int_t fNumBins; // set the number of bins to create for each | | Int_t fNumBins; // set the number of bins to create for each | |
| // axis when constructing the interval | | // axis when constructing the interval | |
| RooArgList * fAxes; // which variables to put on each axis | | RooArgList * fAxes; // which variables to put on each axis | |
| Bool_t fUseKeys; // whether to use kernel estimation to determine int
erval | | Bool_t fUseKeys; // whether to use kernel estimation to determine int
erval | |
| | | | |
| skipping to change at line 208 | | skipping to change at line 213 | |
| void SetBins(const RooAbsCollection& coll, Int_t numBins) const | | void SetBins(const RooAbsCollection& coll, Int_t numBins) const | |
| { | | { | |
| TIterator* it = coll.createIterator(); | | TIterator* it = coll.createIterator(); | |
| RooAbsArg* r; | | RooAbsArg* r; | |
| while ((r = (RooAbsArg*)it->Next()) != NULL) | | while ((r = (RooAbsArg*)it->Next()) != NULL) | |
| if (dynamic_cast<RooRealVar*>(r)) | | if (dynamic_cast<RooRealVar*>(r)) | |
| ((RooRealVar*)r)->setBins(numBins); | | ((RooRealVar*)r)->setBins(numBins); | |
| delete it; | | delete it; | |
| } | | } | |
| | | | |
|
| ClassDef(MCMCCalculator,1) // Markov Chain Monte Carlo calculator for
Bayesian credible intervals | | ClassDef(MCMCCalculator,2) // Markov Chain Monte Carlo calculator for
Bayesian credible intervals | |
| }; | | }; | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 8 lines changed or added | |
|
| MaxLikelihoodEstimateTestStat.h | | MaxLikelihoodEstimateTestStat.h | |
| | | | |
| skipping to change at line 35 | | skipping to change at line 35 | |
| #endif | | #endif | |
| | | | |
| #ifndef ROO_NLL_VAR | | #ifndef ROO_NLL_VAR | |
| #include "RooNLLVar.h" | | #include "RooNLLVar.h" | |
| #endif | | #endif | |
| | | | |
| #include "RooFitResult.h" | | #include "RooFitResult.h" | |
| #include "RooStats/TestStatistic.h" | | #include "RooStats/TestStatistic.h" | |
| #include "RooAbsPdf.h" | | #include "RooAbsPdf.h" | |
| #include "RooRealVar.h" | | #include "RooRealVar.h" | |
|
| | | #include "RooMinimizer.h" | |
| | | #include "Math/MinimizerOptions.h" | |
| | | | |
| namespace RooStats { | | namespace RooStats { | |
| | | | |
| class MaxLikelihoodEstimateTestStat: public TestStatistic { | | class MaxLikelihoodEstimateTestStat: public TestStatistic { | |
| | | | |
| public: | | public: | |
| | | | |
| //__________________________________ | | //__________________________________ | |
| MaxLikelihoodEstimateTestStat() : | | MaxLikelihoodEstimateTestStat() : | |
| fPdf(NULL),fParameter(NULL), fUpperLimit(true) | | fPdf(NULL),fParameter(NULL), fUpperLimit(true) | |
| { | | { | |
| // constructor | | // constructor | |
| // fPdf = pdf; | | // fPdf = pdf; | |
| // fParameter = parameter; | | // fParameter = parameter; | |
|
| | | | |
| | | fMinimizer=ROOT::Math::MinimizerOptions::DefaultMinimizerType().c_st | |
| | | r(); | |
| | | fStrategy=ROOT::Math::MinimizerOptions::DefaultStrategy(); | |
| | | fPrintLevel=ROOT::Math::MinimizerOptions::DefaultPrintLevel(); | |
| | | | |
| } | | } | |
| //__________________________________ | | //__________________________________ | |
| MaxLikelihoodEstimateTestStat(RooAbsPdf& pdf, RooRealVar& parameter) : | | MaxLikelihoodEstimateTestStat(RooAbsPdf& pdf, RooRealVar& parameter) : | |
| fPdf(&pdf),fParameter(¶meter), fUpperLimit(true) | | fPdf(&pdf),fParameter(¶meter), fUpperLimit(true) | |
| { | | { | |
| // constructor | | // constructor | |
| // fPdf = pdf; | | // fPdf = pdf; | |
| // fParameter = parameter; | | // fParameter = parameter; | |
|
| | | fMinimizer=ROOT::Math::MinimizerOptions::DefaultMinimizerType().c_st | |
| | | r(); | |
| | | fStrategy=ROOT::Math::MinimizerOptions::DefaultStrategy(); | |
| | | fPrintLevel=ROOT::Math::MinimizerOptions::DefaultPrintLevel(); | |
| | | | |
| } | | } | |
| | | | |
| //______________________________ | | //______________________________ | |
| virtual Double_t Evaluate(RooAbsData& data, RooArgSet& /*nullPOI*/) { | | virtual Double_t Evaluate(RooAbsData& data, RooArgSet& /*nullPOI*/) { | |
| | | | |
| RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelow()
; | | RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelow()
; | |
| RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL); | | RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL); | |
| | | | |
| /* | | /* | |
| // this is more straight forward, but produces a lot of messages | | // this is more straight forward, but produces a lot of messages | |
| RooFitResult* res = fPdf.fitTo(data, RooFit::CloneData(kFALSE),RooFit::
Minos(0),RooFit::Hesse(false), RooFit::Save(1),RooFit::PrintLevel(-1),RooFi
t::PrintEvalErrors(0)); | | RooFitResult* res = fPdf.fitTo(data, RooFit::CloneData(kFALSE),RooFit::
Minos(0),RooFit::Hesse(false), RooFit::Save(1),RooFit::PrintLevel(-1),RooFi
t::PrintEvalErrors(0)); | |
| RooRealVar* mle = (RooRealVar*) res->floatParsFinal().find(fParameter.G
etName()); | | RooRealVar* mle = (RooRealVar*) res->floatParsFinal().find(fParameter.G
etName()); | |
| double ret = mle->getVal(); | | double ret = mle->getVal(); | |
| delete res; | | delete res; | |
| return ret; | | return ret; | |
| */ | | */ | |
| | | | |
|
| RooAbsReal* nll = fPdf->createNLL(data, RooFit::CloneData(false)); | | RooArgSet* allParams = fPdf->getParameters(data); | |
| RooAbsReal* profile = nll->createProfile(RooArgSet()); | | RooStats::RemoveConstantParameters(allParams); | |
| profile->getVal(); | | | |
| RooArgSet* vars = profile->getVariables(); | | // need to call constrain for RooSimultaneous until stripDisconnected p | |
| RooMsgService::instance().setGlobalKillBelow(msglevel); | | roblem fixed | |
| double ret = vars->getRealValue(fParameter->GetName()); | | RooAbsReal* nll = (RooNLLVar*) fPdf->createNLL(data, RooFit::CloneData( | |
| delete vars; | | kFALSE),RooFit::Constrain(*allParams)); | |
| delete nll; | | | |
| delete profile; | | //RooAbsReal* nll = fPdf->createNLL(data, RooFit::CloneData(false)); | |
| return ret; | | | |
| | | // RooAbsReal* profile = nll->createProfile(RooArgSet()); | |
| | | // profile->getVal(); | |
| | | // RooArgSet* vars = profile->getVariables(); | |
| | | // RooMsgService::instance().setGlobalKillBelow(msglevel); | |
| | | // double ret = vars->getRealValue(fParameter->GetName()); | |
| | | // delete vars; | |
| | | // delete nll; | |
| | | // delete profile; | |
| | | // return ret; | |
| | | | |
| | | RooMinimizer minim(*nll); | |
| | | minim.setStrategy(fStrategy); | |
| | | //LM: RooMinimizer.setPrintLevel has +1 offset - so subtruct here -1 | |
| | | minim.setPrintLevel(fPrintLevel-1); | |
| | | int status = -1; | |
| | | // minim.optimizeConst(true); | |
| | | for (int tries = 0, maxtries = 4; tries <= maxtries; ++tries) { | |
| | | // status = minim.minimize(fMinimizer, ROOT::Math::MinimizerOp | |
| | | tions::DefaultMinimizerAlgo().c_str()); | |
| | | status = minim.minimize(fMinimizer, "Minimize"); | |
| | | if (status == 0) { | |
| | | break; | |
| | | } else { | |
| | | if (tries > 1) { | |
| | | printf(" ----> Doing a re-scan first\n"); | |
| | | minim.minimize(fMinimizer,"Scan"); | |
| | | } | |
| | | if (tries > 2) { | |
| | | printf(" ----> trying with strategy = 1\n"); | |
| | | minim.setStrategy(1); | |
| | | } | |
| | | } | |
| | | } | |
| | | std::cout << "BEST FIT values " << std::endl; | |
| | | allParams->Print("V"); | |
| | | | |
| | | RooMsgService::instance().setGlobalKillBelow(msglevel); | |
| | | delete nll; | |
| | | | |
| | | if (status != 0) return -1; | |
| | | return fParameter->getVal(); | |
| | | | |
| } | | } | |
| | | | |
| virtual const TString GetVarName() const { | | virtual const TString GetVarName() const { | |
| TString varName = Form("Maximum Likelihood Estimate of %s",fParameter->
GetName()); | | TString varName = Form("Maximum Likelihood Estimate of %s",fParameter->
GetName()); | |
| return varName; | | return varName; | |
| } | | } | |
| | | | |
| virtual void PValueIsRightTail(bool isright) { fUpperLimit = isright; } | | virtual void PValueIsRightTail(bool isright) { fUpperLimit = isright; } | |
| virtual bool PValueIsRightTail(void) const { return fUpperLimit; } | | virtual bool PValueIsRightTail(void) const { return fUpperLimit; } | |
| | | | |
| private: | | private: | |
| RooAbsPdf *fPdf; | | RooAbsPdf *fPdf; | |
| RooRealVar *fParameter; | | RooRealVar *fParameter; | |
| bool fUpperLimit; | | bool fUpperLimit; | |
|
| | | TString fMinimizer; | |
| | | Int_t fStrategy; | |
| | | Int_t fPrintLevel; | |
| | | | |
| protected: | | protected: | |
| ClassDef(MaxLikelihoodEstimateTestStat,1) | | ClassDef(MaxLikelihoodEstimateTestStat,1) | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 5 change blocks. |
| 10 lines changed or deleted | | 67 lines changed or added | |
|
| MetropolisHastings.h | | MetropolisHastings.h | |
|
| // @(#)root/roostats:$Id: MetropolisHastings.h 39391 2011-05-26 09:51:59Z m
oneta $ | | // @(#)root/roostats:$Id: MetropolisHastings.h 40961 2011-09-20 17:08:56Z m
oneta $ | |
| // Authors: Kevin Belasco 17/06/2009 | | // Authors: Kevin Belasco 17/06/2009 | |
| // Authors: Kyle Cranmer 17/06/2009 | | // Authors: Kyle Cranmer 17/06/2009 | |
| /************************************************************************* | | /************************************************************************* | |
| * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * | | * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * | |
| * All rights reserved. * | | * All rights reserved. * | |
| * * | | * * | |
| * For the licensing terms see $ROOTSYS/LICENSE. * | | * For the licensing terms see $ROOTSYS/LICENSE. * | |
| * For the list of contributors see $ROOTSYS/README/CREDITS. * | | * For the list of contributors see $ROOTSYS/README/CREDITS. * | |
| *************************************************************************/ | | *************************************************************************/ | |
| | | | |
| | | | |
| skipping to change at line 46 | | skipping to change at line 46 | |
| class MetropolisHastings : public TObject { | | class MetropolisHastings : public TObject { | |
| | | | |
| public: | | public: | |
| enum FunctionSign {kNegative, kPositive, kSignUnset}; | | enum FunctionSign {kNegative, kPositive, kSignUnset}; | |
| enum FunctionType {kRegular, kLog, kTypeUnset}; | | enum FunctionType {kRegular, kLog, kTypeUnset}; | |
| | | | |
| // default constructor | | // default constructor | |
| MetropolisHastings(); | | MetropolisHastings(); | |
| | | | |
| // alternate constructor | | // alternate constructor | |
|
| MetropolisHastings(RooAbsReal& function, RooArgSet& paramsOfInterest, | | MetropolisHastings(RooAbsReal& function, const RooArgSet& paramsOfInt
erest, | |
| ProposalFunction& proposalFunction, Int_t numIters); | | ProposalFunction& proposalFunction, Int_t numIters); | |
| | | | |
| virtual ~MetropolisHastings() {} | | virtual ~MetropolisHastings() {} | |
| | | | |
| // main purpose of MetropolisHastings - run Metropolis-Hastings | | // main purpose of MetropolisHastings - run Metropolis-Hastings | |
| // algorithm to generate Markov Chain of points in the parameter spac
e | | // algorithm to generate Markov Chain of points in the parameter spac
e | |
| virtual MarkovChain* ConstructChain(); | | virtual MarkovChain* ConstructChain(); | |
| | | | |
|
| // specify the parameters of interest in the interval | | // specify the parameters to store in the chain | |
| // kbelasco: should clone before removing constant parameters? | | // if not specified all of them will be stored | |
| virtual void SetParameters(RooArgSet& set) | | virtual void SetChainParameters(const RooArgSet& set) | |
| { fParameters = &set; RemoveConstantParameters(fParameters); } | | { fChainParams.removeAll(); fChainParams.add(set); RemoveConstantPa | |
| | | rameters(&fChainParams); } | |
| | | // specify all the parameters of interest in the interval | |
| | | virtual void SetParameters(const RooArgSet& set) | |
| | | { fParameters.removeAll(); fParameters.add(set); RemoveConstantPara | |
| | | meters(&fParameters); } | |
| // set the proposal function for suggesting new points for the MCMC | | // set the proposal function for suggesting new points for the MCMC | |
| virtual void SetProposalFunction(ProposalFunction& proposalFunction) | | virtual void SetProposalFunction(ProposalFunction& proposalFunction) | |
| { fPropFunc = &proposalFunction; } | | { fPropFunc = &proposalFunction; } | |
| // set the number of iterations to run the metropolis algorithm | | // set the number of iterations to run the metropolis algorithm | |
| virtual void SetNumIters(Int_t numIters) | | virtual void SetNumIters(Int_t numIters) | |
| { fNumIters = numIters; } | | { fNumIters = numIters; } | |
| // set the number of steps in the chain to discard as burn-in, | | // set the number of steps in the chain to discard as burn-in, | |
| // starting from the first | | // starting from the first | |
| virtual void SetNumBurnInSteps(Int_t numBurnInSteps) | | virtual void SetNumBurnInSteps(Int_t numBurnInSteps) | |
| { fNumBurnInSteps = numBurnInSteps; } | | { fNumBurnInSteps = numBurnInSteps; } | |
| // set the (likelihood) function | | // set the (likelihood) function | |
| virtual void SetFunction(RooAbsReal& function) { fFunction = &functio
n; } | | virtual void SetFunction(RooAbsReal& function) { fFunction = &functio
n; } | |
| // set the sign of the function | | // set the sign of the function | |
| virtual void SetSign(enum FunctionSign sign) { fSign = sign; } | | virtual void SetSign(enum FunctionSign sign) { fSign = sign; } | |
| // set the type of the function | | // set the type of the function | |
| virtual void SetType(enum FunctionType type) { fType = type; } | | virtual void SetType(enum FunctionType type) { fType = type; } | |
| | | | |
| protected: | | protected: | |
| RooAbsReal* fFunction; // function that will generate likelihood valu
es | | RooAbsReal* fFunction; // function that will generate likelihood valu
es | |
|
| RooArgSet* fParameters; // RooRealVars that define parameter space | | RooArgSet fParameters; // RooRealVars that define all parameter space | |
| | | RooArgSet fChainParams; // RooRealVars that are stored in the chain | |
| ProposalFunction* fPropFunc; // Proposal function for MCMC integratio
n | | ProposalFunction* fPropFunc; // Proposal function for MCMC integratio
n | |
| Int_t fNumIters; // number of iterations to run metropolis algorithm | | Int_t fNumIters; // number of iterations to run metropolis algorithm | |
| Int_t fNumBurnInSteps; // number of iterations to discard as burn-in,
starting from the first | | Int_t fNumBurnInSteps; // number of iterations to discard as burn-in,
starting from the first | |
| enum FunctionSign fSign; // whether the likelihood is negative (like
NLL) or positive | | enum FunctionSign fSign; // whether the likelihood is negative (like
NLL) or positive | |
| enum FunctionType fType; // whether the likelihood is on a regular, l
og, (or other) scale | | enum FunctionType fType; // whether the likelihood is on a regular, l
og, (or other) scale | |
| | | | |
| // whether we should take the step, based on the value of d, fSign, f
Type | | // whether we should take the step, based on the value of d, fSign, f
Type | |
| virtual Bool_t ShouldTakeStep(Double_t d); | | virtual Bool_t ShouldTakeStep(Double_t d); | |
| virtual Double_t CalcNLL(Double_t xL); | | virtual Double_t CalcNLL(Double_t xL); | |
| | | | |
|
| ClassDef(MetropolisHastings,1) // Markov Chain Monte Carlo calculator
for Bayesian credible intervals | | ClassDef(MetropolisHastings,2) // Markov Chain Monte Carlo calculator
for Bayesian credible intervals | |
| }; | | }; | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 5 change blocks. |
| 8 lines changed or deleted | | 14 lines changed or added | |
|
| ProfileLikelihoodTestStat.h | | ProfileLikelihoodTestStat.h | |
|
| // @(#)root/roostats:$Id: ProfileLikelihoodTestStat.h 40567 2011-08-11 16:3
1:47Z moneta $ | | // @(#)root/roostats:$Id: ProfileLikelihoodTestStat.h 40937 2011-09-19 16:1
6:56Z moneta $ | |
| // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke | | // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke | |
| // Additional Contributions: Giovanni Petrucciani | | // Additional Contributions: Giovanni Petrucciani | |
| /************************************************************************* | | /************************************************************************* | |
| * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * | | * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * | |
| * All rights reserved. * | | * All rights reserved. * | |
| * * | | * * | |
| * For the licensing terms see $ROOTSYS/LICENSE. * | | * For the licensing terms see $ROOTSYS/LICENSE. * | |
| * For the list of contributors see $ROOTSYS/README/CREDITS. * | | * For the list of contributors see $ROOTSYS/README/CREDITS. * | |
| *************************************************************************/ | | *************************************************************************/ | |
| | | | |
| | | | |
| skipping to change at line 120 | | skipping to change at line 120 | |
| //paramsOfInterest.getRealValue(firstPOI->GetName()); | | //paramsOfInterest.getRealValue(firstPOI->GetName()); | |
| | | | |
| RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelo
w(); | | RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelo
w(); | |
| RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL); | | RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL); | |
| | | | |
| // simple | | // simple | |
| Bool_t reuse=(fReuseNll || fgAlwaysReuseNll) ; | | Bool_t reuse=(fReuseNll || fgAlwaysReuseNll) ; | |
| | | | |
| Bool_t created(kFALSE) ; | | Bool_t created(kFALSE) ; | |
| if (!reuse || fNll==0) { | | if (!reuse || fNll==0) { | |
|
| RooArgSet* allParams = fPdf->getParameters(data); | | RooArgSet* allParams = fPdf->getParameters(data); | |
| RooStats::RemoveConstantParameters(allParams); | | RooStats::RemoveConstantParameters(allParams); | |
| | | | |
|
| // need to call constrain for RooSimultaneous until stripDisconnect | | // need to call constrain for RooSimultaneous until stripDisconne | |
| ed problem fixed | | cted problem fixed | |
| fNll = (RooNLLVar*) fPdf->createNLL(data, RooFit::CloneData(kFALSE) | | fNll = (RooNLLVar*) fPdf->createNLL(data, RooFit::CloneData(kFALS | |
| ,RooFit::Constrain(*allParams)); | | E),RooFit::Constrain(*allParams)); | |
| | | | |
|
| // fNll = (RooNLLVar*) fPdf->createNLL(data, RooFit::CloneData | | // fNll = (RooNLLVar*) fPdf->createNLL(data, RooFit::CloneData | |
| (kFALSE)); | | (kFALSE)); | |
| // fProfile = (RooProfileLL*) fNll->createProfile(paramsOfInte | | // fProfile = (RooProfileLL*) fNll->createProfile(paramsOfInte | |
| rest); | | rest); | |
| created = kTRUE ; | | created = kTRUE ; | |
| //cout << "creating profile LL " << fNll << " " << fProfile << " da | | delete allParams; | |
| ta = " << &data << endl ; | | //cout << "creating profile LL " << fNll << " " << fProfile << " | |
| | | data = " << &data << endl ; | |
| } | | } | |
| if (reuse && !created) { | | if (reuse && !created) { | |
|
| //cout << "reusing profile LL " << fNll << " new data = " << &data | | //cout << "reusing profile LL " << fNll << " new data = " << &dat | |
| << endl ; | | a << endl ; | |
| fNll->setData(data,kFALSE) ; | | fNll->setData(data,kFALSE) ; | |
| // if (fProfile) delete fProfile ; | | // if (fProfile) delete fProfile ; | |
| // fProfile = (RooProfileLL*) fNll->createProfile(paramsOfInte | | // fProfile = (RooProfileLL*) fNll->createProfile(paramsOfInte | |
| rest) ; | | rest) ; | |
| //fProfile->clearAbsMin() ; | | //fProfile->clearAbsMin() ; | |
| } | | } | |
| | | | |
| // make sure we set the variables attached to this nll | | // make sure we set the variables attached to this nll | |
| RooArgSet* attachedSet = fNll->getVariables(); | | RooArgSet* attachedSet = fNll->getVariables(); | |
| | | | |
| *attachedSet = paramsOfInterest; | | *attachedSet = paramsOfInterest; | |
| RooArgSet* origAttachedSet = (RooArgSet*) attachedSet->snapshot(); | | RooArgSet* origAttachedSet = (RooArgSet*) attachedSet->snapshot(); | |
| | | | |
| ////////////////////////////////////////////////////////////////////
/// | | ////////////////////////////////////////////////////////////////////
/// | |
| // Main profiling version as of 5.30 | | // Main profiling version as of 5.30 | |
| | | | |
| skipping to change at line 205 | | skipping to change at line 206 | |
| double uncondML = GetMinNLL(statusD); | | double uncondML = GetMinNLL(statusD); | |
| */ | | */ | |
| | | | |
| // other order | | // other order | |
| // get the numerator | | // get the numerator | |
| RooArgSet* snap = (RooArgSet*)paramsOfInterest.snapshot(); | | RooArgSet* snap = (RooArgSet*)paramsOfInterest.snapshot(); | |
| // get the denominator | | // get the denominator | |
| int statusD; | | int statusD; | |
| double uncondML = GetMinNLL(statusD); | | double uncondML = GetMinNLL(statusD); | |
| | | | |
|
| // cout <<" reestablish snapshot"<<endl; | | // get best fit value for one-sided interval | |
| *attachedSet = *snap; | | double fit_favored_mu = attachedSet->getRealValue(firstPOI->GetName( | |
| | | )) ; | |
| | | | |
|
| TIterator* it = paramsOfInterest.createIterator(); | | double ret = 0; | |
| RooRealVar* tmpPar = NULL, *tmpParA=NULL; | | int statusN = 0; | |
| while((tmpPar = (RooRealVar*)it->Next())){ | | | |
| tmpParA = ((RooRealVar*)attachedSet->find(tmpPar->GetName())); | | | |
| tmpParA->setConstant(); | | | |
| } | | | |
| int statusN; | | | |
| double condML = GetMinNLL(statusN); | | | |
| | | | |
| *attachedSet = *origAttachedSet; | | | |
| | | | |
|
| double ret=condML-uncondML;; | | // do the conditional ML (the numerator) only when fit value is smal | |
| | | ler than test value | |
| | | if (!fOneSided || fit_favored_mu <= initial_mu_value) { | |
| | | | |
|
| if(fOneSided){ | | // cout <<" reestablish snapshot"<<endl; | |
| // double fit_favored_mu = ((RooProfileLL*) fProfile)->bestFit | | *attachedSet = *snap; | |
| Obs().getRealValue(firstPOI->GetName()) ; | | | |
| double fit_favored_mu = attachedSet->getRealValue(firstPOI->GetName | | // in case no nuisance parameters are present | |
| ()) ; | | // no need to minimize just evaluate the nll | |
| | | double condML = 0; | |
| | | | |
| | | // set the POI to constant | |
| | | RooLinkedListIter it = paramsOfInterest.iterator(); | |
| | | RooRealVar* tmpPar = NULL, *tmpParA=NULL; | |
| | | while((tmpPar = (RooRealVar*)it.Next())){ | |
| | | tmpParA = ((RooRealVar*)attachedSet->find(tmpPar->GetName())) | |
| | | ; | |
| | | tmpParA->setConstant(); | |
| | | } | |
| | | | |
| | | // check if there are non-const parameters so it is worth to do t | |
| | | he minimization | |
| | | RooArgSet allParams(*attachedSet); | |
| | | RooStats::RemoveConstantParameters(&allParams); | |
| | | | |
| | | if (allParams.getSize() == 0 ) { | |
| | | condML = fNll->getVal(); | |
| | | } | |
| | | else { | |
| | | condML = GetMinNLL(statusN); | |
| | | } | |
| | | | |
|
| if( fit_favored_mu > initial_mu_value) | | ret=condML-uncondML; | |
| ret = 0 ; | | | |
| } | | } | |
|
| | | | |
| | | // need to restore the values ? | |
| | | *attachedSet = *origAttachedSet; | |
| | | | |
| delete attachedSet; | | delete attachedSet; | |
| delete origAttachedSet; | | delete origAttachedSet; | |
| delete snap; | | delete snap; | |
|
| delete it; | | | |
| | | | |
| if (!reuse) { | | if (!reuse) { | |
| delete fNll; | | delete fNll; | |
| fNll = 0; | | fNll = 0; | |
| // delete fProfile; | | // delete fProfile; | |
| fProfile = 0 ; | | fProfile = 0 ; | |
| } | | } | |
| | | | |
| RooMsgService::instance().setGlobalKillBelow(msglevel); | | RooMsgService::instance().setGlobalKillBelow(msglevel); | |
| | | | |
| | | | |
End of changes. 12 change blocks. |
| 42 lines changed or deleted | | 62 lines changed or added | |
|
| ToyMCSampler.h | | ToyMCSampler.h | |
|
| // @(#)root/roostats:$Id: ToyMCSampler.h 40023 2011-06-27 16:58:44Z moneta
$ | | // @(#)root/roostats:$Id: ToyMCSampler.h 40961 2011-09-20 17:08:56Z moneta
$ | |
| // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke | | // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke | |
| // Additions and modifications by Mario Pelliccioni | | // Additions and modifications by Mario Pelliccioni | |
| /************************************************************************* | | /************************************************************************* | |
| * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * | | * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * | |
| * All rights reserved. * | | * All rights reserved. * | |
| * * | | * * | |
| * For the licensing terms see $ROOTSYS/LICENSE. * | | * For the licensing terms see $ROOTSYS/LICENSE. * | |
| * For the list of contributors see $ROOTSYS/README/CREDITS. * | | * For the list of contributors see $ROOTSYS/README/CREDITS. * | |
| *************************************************************************/ | | *************************************************************************/ | |
| | | | |
| | | | |
| skipping to change at line 206 | | skipping to change at line 206 | |
| // Forces n events even for extended PDFs. Set NEvents=0 to | | // Forces n events even for extended PDFs. Set NEvents=0 to | |
| // use the Poisson distributed events from the extended PDF. | | // use the Poisson distributed events from the extended PDF. | |
| fNEvents = nevents; | | fNEvents = nevents; | |
| } | | } | |
| | | | |
| // specify the values of parameters used when evaluating test statist
ic | | // specify the values of parameters used when evaluating test statist
ic | |
| virtual void SetParametersForTestStat(const RooArgSet& nullpoi) { | | virtual void SetParametersForTestStat(const RooArgSet& nullpoi) { | |
| if (fNullPOI) delete fNullPOI; fNullPOI = (RooArgSet*)nullpoi.snap
shot(); | | if (fNullPOI) delete fNullPOI; fNullPOI = (RooArgSet*)nullpoi.snap
shot(); | |
| } | | } | |
| // Set the Pdf, add to the the workspace if not already there | | // Set the Pdf, add to the the workspace if not already there | |
|
| virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; } | | virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; ClearCache(); } | |
| // How to randomize the prior. Set to NULL to deactivate randomizatio
n. | | // How to randomize the prior. Set to NULL to deactivate randomizatio
n. | |
| virtual void SetPriorNuisance(RooAbsPdf* pdf) { fPriorNuisance = pdf;
} | | virtual void SetPriorNuisance(RooAbsPdf* pdf) { fPriorNuisance = pdf;
} | |
| // specify the nuisance parameters (eg. the rest of the parameters) | | // specify the nuisance parameters (eg. the rest of the parameters) | |
| virtual void SetNuisanceParameters(const RooArgSet& np) { fNuisancePa
rs = &np; } | | virtual void SetNuisanceParameters(const RooArgSet& np) { fNuisancePa
rs = &np; } | |
| // specify the observables in the dataset (needed to evaluate the tes
t statistic) | | // specify the observables in the dataset (needed to evaluate the tes
t statistic) | |
| virtual void SetObservables(const RooArgSet& o) { fObservables = &o;
} | | virtual void SetObservables(const RooArgSet& o) { fObservables = &o;
} | |
| // specify the conditional observables | | // specify the conditional observables | |
| virtual void SetGlobalObservables(const RooArgSet& o) { fGlobalObserv
ables = &o; } | | virtual void SetGlobalObservables(const RooArgSet& o) { fGlobalObserv
ables = &o; } | |
| | | | |
| // set the size of the test (rate of Type I error) ( Eg. 0.05 for a 9
5% Confidence Interval) | | // set the size of the test (rate of Type I error) ( Eg. 0.05 for a 9
5% Confidence Interval) | |
| | | | |
| skipping to change at line 274 | | skipping to change at line 274 | |
| // calling with argument or NULL deactivates proof | | // calling with argument or NULL deactivates proof | |
| void SetProofConfig(ProofConfig *pc = NULL) { fProofConfig = pc; } | | void SetProofConfig(ProofConfig *pc = NULL) { fProofConfig = pc; } | |
| | | | |
| void SetProtoData(const RooDataSet* d) { fProtoData = d; } | | void SetProtoData(const RooDataSet* d) { fProtoData = d; } | |
| | | | |
| protected: | | protected: | |
| | | | |
| // helper for GenerateToyData | | // helper for GenerateToyData | |
| RooAbsData* Generate(RooAbsPdf &pdf, RooArgSet &observables, const Ro
oDataSet *protoData=NULL, int forceEvents=0) const; | | RooAbsData* Generate(RooAbsPdf &pdf, RooArgSet &observables, const Ro
oDataSet *protoData=NULL, int forceEvents=0) const; | |
| | | | |
|
| | | // helper method for clearing the cache | |
| | | void ClearCache(); | |
| | | | |
| TestStatistic *fTestStat; // test statistic that is being sampled | | TestStatistic *fTestStat; // test statistic that is being sampled | |
| RooAbsPdf *fPdf; // model | | RooAbsPdf *fPdf; // model | |
| string fSamplingDistName; // name of the model | | string fSamplingDistName; // name of the model | |
| RooAbsPdf *fPriorNuisance; // prior pdf for nuisance parameters | | RooAbsPdf *fPriorNuisance; // prior pdf for nuisance parameters | |
| RooArgSet *fNullPOI; // parameters of interest | | RooArgSet *fNullPOI; // parameters of interest | |
| const RooArgSet *fNuisancePars; | | const RooArgSet *fNuisancePars; | |
| const RooArgSet *fObservables; | | const RooArgSet *fObservables; | |
| const RooArgSet *fGlobalObservables; | | const RooArgSet *fGlobalObservables; | |
| Int_t fNToys; // number of toys to generate | | Int_t fNToys; // number of toys to generate | |
| Int_t fNEvents; // number of events per toy (may be ignored depending
on settings) | | Int_t fNEvents; // number of events per toy (may be ignored depending
on settings) | |
| | | | |
End of changes. 3 change blocks. |
| 2 lines changed or deleted | | 5 lines changed or added | |
|