HybridCalculator.cxx

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: HybridCalculator.cxx 37084 2010-11-29 21:37:13Z moneta $
00002 // Author: Kyle Cranmer, Sven Kreiss   23/05/10
00003 /*************************************************************************
00004  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 /**
00012 Same purpose as HybridCalculatorOriginal, but different implementation.
00013 */
00014 
00015 #include "RooStats/HybridCalculator.h"
00016 #include "RooStats/ToyMCSampler.h"
00017 
00018 
00019 ClassImp(RooStats::HybridCalculator)
00020 
00021 using namespace RooStats;
00022 
00023 
00024 int HybridCalculator::PreNullHook(double obsTestStat) const {
00025    // check whether TestStatSampler is a ToyMCSampler
00026    ToyMCSampler *toymcs = dynamic_cast<ToyMCSampler*>(GetTestStatSampler());
00027    if(toymcs) {
00028       oocoutI((TObject*)0,InputArguments) << "Using a ToyMCSampler. Now configuring for Null." << endl;
00029 
00030       // variable number of toys
00031       if(fNToysNull) toymcs->SetNToys(fNToysNull);
00032 
00033       // adaptive sampling
00034       if(fNToysNullTail) {
00035          oocoutI((TObject*)0,InputArguments) << "Adaptive Sampling" << endl;
00036          if(GetTestStatSampler()->GetTestStatistic()->PValueIsRightTail()) {
00037             toymcs->SetToysRightTail(fNToysNullTail, obsTestStat);
00038          }else{
00039             toymcs->SetToysLeftTail(fNToysNullTail, obsTestStat);
00040          }
00041       }else{
00042          toymcs->SetToysBothTails(0, 0, obsTestStat); // disable adaptive sampling
00043       }
00044 
00045       // importance sampling
00046       if(fNullImportanceDensity) {
00047          oocoutI((TObject*)0,InputArguments) << "Importance Sampling" << endl;
00048          toymcs->SetImportanceDensity(fNullImportanceDensity);
00049          if(fNullImportanceSnapshot) toymcs->SetImportanceSnapshot(*fNullImportanceSnapshot);
00050       }else{
00051          toymcs->SetImportanceDensity(NULL);       // disable importance sampling
00052       }
00053       GetNullModel()->LoadSnapshot();
00054    }
00055 
00056    return 0;
00057 }
00058 
00059 
00060 int HybridCalculator::PreAltHook(double obsTestStat) const {
00061    // check whether TestStatSampler is a ToyMCSampler
00062    ToyMCSampler *toymcs = dynamic_cast<ToyMCSampler*>(GetTestStatSampler());
00063    if(toymcs) {
00064       oocoutI((TObject*)0,InputArguments) << "Using a ToyMCSampler. Now configuring for Alt." << endl;
00065 
00066       // variable number of toys
00067       if(fNToysAlt) toymcs->SetNToys(fNToysAlt);
00068 
00069       // adaptive sampling
00070       if(fNToysAltTail) {
00071          oocoutI((TObject*)0,InputArguments) << "Adaptive Sampling" << endl;
00072          if(GetTestStatSampler()->GetTestStatistic()->PValueIsRightTail()) {
00073             toymcs->SetToysLeftTail(fNToysAltTail, obsTestStat);
00074          }else{
00075             toymcs->SetToysRightTail(fNToysAltTail, obsTestStat);
00076          }
00077       }else{
00078          toymcs->SetToysBothTails(0, 0, obsTestStat); // disable adaptive sampling
00079       }
00080 
00081 
00082       // importance sampling
00083       if(fAltImportanceDensity) {
00084          oocoutI((TObject*)0,InputArguments) << "Importance Sampling" << endl;
00085          toymcs->SetImportanceDensity(fAltImportanceDensity);
00086          if(fAltImportanceSnapshot) toymcs->SetImportanceSnapshot(*fAltImportanceSnapshot);
00087       }else{
00088          toymcs->SetImportanceDensity(NULL);       // disable importance sampling
00089       }
00090    }
00091 
00092    return 0;
00093 }
00094 
00095 
00096 
00097 

Generated on Tue Jul 5 15:14:34 2011 for ROOT_528-00b_version by  doxygen 1.5.1