Bool_t THSEventsFit::InitialiseFit(){ if(GetDataSet()->numEntries()<2) {cout<<" THSEventsFit::InitialiseFit() less than 2 entries in dataset!"<<endl; return kFALSE;} RooAbsPdf* pdf=0; Long64_t PdfN[GetPDFs().getSize()]; Long64_t TotalN=0; for(Int_t ip=0;ip<GetPDFs().getSize();ip++){ pdf=(RooAbsPdf*)&(GetPDFs()[ip]); THSEventsPDF* mpdf=0; cout<<" THSEventsFit::InitialiseFit(); PDFs "<<pdf->GetName()<<endl; if(mpdf=dynamic_cast<THSEventsPDF*>(pdf)){//Only applies to THSEventsPDF if(!(mpdf->GetHistPdf())){ cout<<"Start smeared model "<<gDirectory->GetName()<<endl; PdfN[ip]=mpdf->AddSmearedModel(0,GetAuxVars()); cout<<"Stop smeared model "<<gDirectory->GetName()<<endl; TotalN+=PdfN[ip]; if(PdfN[ip]<10) { cout<<" THSEventsFit::InitialiseFit() no events found for "<<GetName()<<" MODEL: "<<pdf->GetName()<<" probably no events kinmatically allowed in this bin" <<endl; GetPDFsp()->remove(GetPDFs()[ip]); GetYieldsp()->remove(*(GetWorkSpace()->var(fYld+pdf->GetName()))); GetWorkSpace()->removeSet("Yields"); GetWorkSpace()->removeSet("PDFs"); GetWorkSpace()->defineSet("Yields",GetYields()); GetWorkSpace()->defineSet("PDFs",GetPDFs()); } } } } for(Int_t ip=0;ip<GetPDFs().getSize();ip++){ if(PdfN[ip]/TotalN<fAccFrac){ // cout<<" THSEventsFit::InitialiseFit() "<<GetName()<<" MODEL: "<<GetPDFs()[ip]->GetName()<<" N events below acceptance fraction so not considered significant enough background " <<PdfN[ip] <<" out of "<<TotalN<<endl; GetPDFsp()->remove(GetPDFs()[ip]); GetYieldsp()->remove(*(GetWorkSpace()->var(fYld+pdf->GetName()))); GetWorkSpace()->removeSet("Yields"); GetWorkSpace()->removeSet("PDFs"); GetWorkSpace()->defineSet("Yields",GetYields()); GetWorkSpace()->defineSet("PDFs",GetPDFs()); } } if(GetPDFs().getSize()) TotalPDF(); else { cout<<" THSEventsFit::InitialiseFit() no model found for "<<GetName()<<" probably no events kinmatically allowed in this bin" <<endl; return kFALSE; } return kTRUE; }
void THSSimFit::SetModelEventsTree(TString name,TTree* tree){ THSEventsPDF* mpdf=dynamic_cast<THSEventsPDF*>(fWS->pdf(name)); mpdf->SetTree(tree);//set the tree for the MC model cout<< "THSRooFit::SetMCModelTree(TString name,TTree* tree) "<<name<<endl; //if bins are defined split tree up into bins if(fDataBins&&!fIsBinTrees){//use either entrylists fDataBins->InitialiseLists("MCModelBins",fOutDir+TString("Bins")+mpdf->GetName()+".root"); fDataBins->RunEntryList(tree); fDataBins->SaveLists(); } else if(fDataBins){//or trees fDataBins->InitialiseTrees("MCModelBins",fOutDir+TString("Bins")+mpdf->GetName()+".root"); fDataBins->RunTree(tree); fDataBins->SaveTrees(); } else mpdf->AddSmearedModel(0,GetAuxVars());//only one bin, go ahead and make the model, with ranges defined in aux vars }