00001 // @(#)root/roostats:$Id: ToyMCStudy.cxx 36602 2010-11-11 16:52:13Z moneta $ 00002 // Author: Sven Kreiss and Kyle Cranmer June 2010 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 #include "RooStats/ToyMCStudy.h" 00012 00013 #include "RooStats/ToyMCSampler.h" 00014 00015 00016 #ifndef ROO_MSG_SERVICE 00017 #include "RooMsgService.h" 00018 #endif 00019 00020 #include "RooRandom.h" 00021 00022 00023 00024 ClassImp(RooStats::ToyMCStudy) 00025 00026 namespace RooStats { 00027 00028 00029 // _____________________________________________________________________________ 00030 Bool_t ToyMCStudy::initialize(void) { 00031 coutP(Generation) << "initialize" << endl; 00032 00033 //coutI(InputArguments) << "SetSeed(0)" << endl; 00034 //RooRandom::randomGenerator()->SetSeed(0); 00035 coutI(InputArguments) << "Seed is: " << RooRandom::randomGenerator()->GetSeed() << endl; 00036 00037 if(!fToyMCSampler) { 00038 coutE(InputArguments) << "Need an instance of ToyMCSampler to run." << endl; 00039 }else{ 00040 coutI(InputArguments) << "Using given ToyMCSampler." << endl; 00041 } 00042 00043 return kFALSE; 00044 } 00045 00046 // _____________________________________________________________________________ 00047 Bool_t ToyMCStudy::execute(void) { 00048 SamplingDistribution *sd = fToyMCSampler->GetSamplingDistributionSingleWorker(fParamPointOfInterest); 00049 storeDetailedOutput(*sd); 00050 00051 return kFALSE; 00052 } 00053 00054 // _____________________________________________________________________________ 00055 Bool_t ToyMCStudy::finalize(void) { 00056 coutP(Generation) << "finalize" << endl; 00057 00058 if(fToyMCSampler) delete fToyMCSampler; 00059 fToyMCSampler = NULL; 00060 00061 return kFALSE; 00062 } 00063 00064 00065 Bool_t ToyMCStudy::merge(SamplingDistribution& result) { 00066 // returns true if there was an error 00067 coutP(Generation) << "merge" << endl; 00068 00069 if(!detailedData()) { 00070 coutE(Generation) << "No detailed output present." << endl; 00071 return kTRUE; 00072 } 00073 00074 RooLinkedListIter iter = detailedData()->iterator(); 00075 TObject *o = NULL; 00076 while((o = iter.Next())) { 00077 if(!dynamic_cast<SamplingDistribution*>(o)) { 00078 coutW(Generation) << "Merging Results problem: not a SamplingDistribution" << endl; 00079 continue; 00080 } 00081 00082 result.Add(dynamic_cast<SamplingDistribution*>(o)); 00083 } 00084 00085 return kFALSE; 00086 } 00087 00088 00089 } // end namespace RooStats