32 ClassImp(RooStats::ToyMCStudy);
34 ClassImp(RooStats::ToyMCPayload);
43 Bool_t ToyMCStudy::initialize(
void) {
44 coutP(Generation) <<
"initialize" << endl;
47 coutE(InputArguments) <<
"Need an instance of ToyMCSampler to run." << endl;
50 coutI(InputArguments) <<
"Using given ToyMCSampler." << endl;
54 TString worknumber = gEnv->GetValue(
"ProofServ.Ordinal",
"undef");
56 if (worknumber !=
"undef") {
57 iworker = int( worknumber.Atof()*10 + 0.1);
60 std::cout <<
"Current global seed is " << fRandomSeed << std::endl;
61 TRandom2 r(fRandomSeed );
63 unsigned int seed = r.Integer(TMath::Limits<unsigned int>::Max() );
64 for (
int i = 0; i< iworker; ++i)
65 seed = r.Integer(TMath::Limits<unsigned int>::Max() );
68 RooRandom::randomGenerator()->SetSeed(seed);
71 coutI(InputArguments) <<
"Worker " << iworker <<
" seed is: " << RooRandom::randomGenerator()->GetSeed() << endl;
78 Bool_t ToyMCStudy::execute(
void) {
80 coutP(Generation) <<
"ToyMCStudy::execute - run with seed " << RooRandom::randomGenerator()->Integer(TMath::Limits<unsigned int>::Max() ) << std::endl;
81 RooDataSet* sd = fToyMCSampler->GetSamplingDistributionsSingleWorker(fParamPoint);
82 ToyMCPayload *sdw =
new ToyMCPayload(sd);
83 storeDetailedOutput(*sdw);
90 Bool_t ToyMCStudy::finalize(
void) {
91 coutP(Generation) <<
"ToyMCStudy::finalize" << endl;
93 if(fToyMCSampler)
delete fToyMCSampler;
101 RooDataSet* ToyMCStudy::merge() {
103 RooDataSet* samplingOutput = NULL;
105 if(!detailedData()) {
106 coutE(Generation) <<
"ToyMCStudy::merge No detailed output present." << endl;
110 RooLinkedListIter iter = detailedData()->iterator();
113 while((o = iter.Next())) {
114 ToyMCPayload *oneWorker =
dynamic_cast< ToyMCPayload*
>(o);
116 coutW(Generation) <<
"Merging Results problem: not correct type" << endl;
120 if( !samplingOutput ) samplingOutput =
new RooDataSet(*oneWorker->GetSamplingDistributions());
122 else samplingOutput->append( *oneWorker->GetSamplingDistributions() );
127 coutP(Generation) <<
"Merged data from nworkers # " << i <<
"- merged data size is " << samplingOutput->numEntries() << std::endl;
130 return samplingOutput;