90 likes | 99 Views
This collection features algorithms for data analysis, systematics, confidence limits, signal significance, AI, neural nets, pattern recognition, genetic algorithms, wavelet analysis, and more. Includes examples of Feldman-Cousins method, generators, fitting, and Monte Carlo fractions fitting with TFractionFitter in ROOT.
E N D
Collection of algorithms in ROOT Advanced Multivariate & Statistical Techniques FermiLab Workshop May 31, 2002 René Brun (Rene.Brun@cern.ch) CERN Durham
Follow-on of ACAT2000 at FermiLab • At ACAT2000, many interesting algorithms were presented. • Many of us agreed that it would be nice to collect these algorithms in a coherent framework. • Many people have the know-how to develop very clever algorithms, but not the opportunity to make the source/doc available to a large community. • I proposed to gradually collect such algorithms in the ROOT suite. • Your workshop is an opportunity to make some progress. • ACAT2002 in Moscow could be another step. Collection of algorithms in ROOT
Which ingredients • Statistical methods for Data Analysis • Systematics • Confidence Limits • Signal significance • Unfolding techniques • Artificial Intelligence • Neural nets • Pattern recognition techniques • Genetic algorithms • Wavelet Analysis • other algorithms • Multi-dim integration, etc Collection of algorithms in ROOT
Already in Root • Random Number generators • standard distributions: flat, gaus, landau, Poisson, • from a function 1-d, 2-d, 3-d • from histograms 1-d, 2-d, 3-d • Principal components Analysis • Multidimensional parametrisation and Fitting • Histogram peak finders • Feldman Cousins • Fitting MC fractions to data histogram Collection of algorithms in ROOT
FeldmanCousins example void FeldmanCousins() { // Example macro of using the TFeldmanCousins class in root. // Author : Adrian John Bevan <bevan@SLAC.Stanford.EDU> // // get a FeldmanCousins calculation object with the default limits // of calculating a 90% CL with the minimum signal value scanned // = 0.0 and the maximum signal value scanned of 50.0 TFeldmanCousins f; // calculate either the upper or lower limit for 10 observerd // events with an estimated background of 3. The calculation of // either upper or lower limit will return that limit and fill // data memebers with both the upper and lower limit for you. Double_t Nobserved = 10.0; Double_t Nbackground = 3.0; Double_t ul = f.CalculateUpperLimit(Nobserved, Nbackground); Double_t ll = f.GetLowerLimit(); cout << "For " << Nobserved << " data observed with and estimated background"<<endl; cout << "of " << Nbackground << " candidates, the Feldman-Cousins method of "<<endl; cout << "calculating confidence limits gives:"<<endl; cout << "\tUpper Limit = " << ul << endl; cout << "\tLower Limit = " << ll << endl; cout << "at the 90% CL"<< endl; } Collection of algorithms in ROOT
Generators, Fitting // Quadratic background function Double_t background(Double_t *x, Double_t *par) { return par[0] + par[1]*x[0] + par[2]*x[0]*x[0]; } // Lorenzian Peak function Double_t lorentzianPeak(Double_t *x, Double_t *par) { return (0.5*par[0]*par[1]/TMath::Pi()) / TMath::Max( 1.e-10,(x[0]-par[2])*(x[0]-par[2]) + .25*par[1]*par[1]); } // Sum of background and peak function Double_t myFunction(Double_t *x, Double_t *par) { return background(x,par) + lorentzianPeak(x,&par[3]); } void getrandom() { TCanvas *c1 = new TCanvas("c1","Fitting Demo",10,10,700,900); c1->Divide(1,2); // create a source function with 6 parameters c1->cd(1); TF1 *source = new TF1("source",myFunction,0,3,6); source->SetParameters(-0.86,45.8,-13.3,13.8,0.172,0.987); source->SetNpx(200); source->DrawCopy(); // fill histogram with 10000 numbers sampled from the source function c1->cd(2); TH1F *histo = new TH1F("histo","Lorentzian Peak on Quadratic Background",60,0,3); for (Int_t i=0;i<10000;i++) { Double_t sval = source->GetRandom(); histo->Fill(sval); } //fit histogram with original function gStyle->SetOptFit(); histo->Fit(source); } Collection of algorithms in ROOT
MonteCarlo Fractions Fitter TFractionFitter: Fits MC fractions to data histogram (see R. Barlow and C. Beeston, Comp. Phys. Comm. 77 (1993) 219-228) The virtue of this fit is that it takes into account both data and Monte Carlo statistical uncertainties. The way in which this is done is through a standard likelihood fit using Poisson statistics; however, the template (MC) predictions are also varied within statistics, leading to additional contributions to the overall likelihood. This leads to many more fit parameters (one per bin per template), but the minimisation with respect to these additional parameters is done analytically rather than introducing them as formal fit parameters. Collection of algorithms in ROOT
TFractionFitter example { TH1F *data; //data histogram TH1F *mc0; // first MC histogram TH1F *mc1; // second MC histogram TH1F *mc2; // third MC histogram TObjArray *mc = new TObjArray(3); mc->Add(mc0); // MC histograms are put in this array mc->Add(mc1); mc->Add(mc2); TFractionFitter* fit = new TFractionFitter(data, mc); fit->Constrain(1,0.0,1.0); // fraction 1 to be between 0 and 1 fit->SetRangeX(1,15); // use only the first 15 bins in the fit fit->Fit(); // perform the fit TH1F* prediction = (TH1F*) fit->GetPlot(); data->Draw("Ep"); prediction->Draw("same"); } Collection of algorithms in ROOT
Procedure • We can give help to create a class in a portable way. • Author is responsible for the doc and support • We generate the html pages at each release • We compile and distribute binaries + source for most machines and compilers. • Examples: http://root.cern.ch/root/htmldoc/TFractionFitter.html http://root.cern.ch/root/htmldoc/TFeldmanCousins.html http://root.cern.ch/root/htmldoc/TMultiDimFit.html http://root.cern.ch/root/htmldoc/TPrincipal.html http://root.cern.ch/root/htmldoc/TF1.html http://root.cern.ch/root/htmldoc/TMinuit.html http://root.cern.ch/root/htmldoc/TRandom3.html Collection of algorithms in ROOT