Linear Collider Forum



Home » Analysis and Reconstruction » Analysis Tools » Fitting histograms with other histograms
Re: Fitting histograms with other histograms [message #1709 is a reply to message #1708] Mon, 16 March 2009 11:14 Go to previous message
turri
Messages: 1
Registered: March 2009
Hi,
probably the easier way to solve your fitting problem is to create your own function as described here.

Your function would extend AbstractIFunction and provide the double value(double x[]) as:

double value(double x[]) {
     return parameter("a")*h1.binHeight( h1.coordToIndex(x[0]) ) + parameter("b")*h2.binHeight( h2.coordToIndex(x[0]) ) + parameter("c")*h3.binHeight( h3.coordToIndex(x[0]) );
}


where the histograms h1,h2,h3 are passed to your function when constructing it (for example).

To specify that "a", "b" and "c" are parameters you have to invoke the proper constructor of AbstractIFunction in your function's constructor:

    public MyFunction(String title, IHistogram h1, IHistogram h2, IHistogram h3) {
         super(title, new String[]{"x0"}, new String[] {"a","b","c"});
         this.h1 = h1;
         this.h2 = h2;
         this.h3 = h3;
     }


You could then do a chi2 fit to your histogram data hist_data as:

IAnalysisFactory af = IAnalysisFactory.create();
IFitter fitter = af.createFitFactory().createFitter("chi2","jminuit","noClone=true");

MyFunction f = new MyFunction(h1,h2,h3);

IFitResult result = fitter.fit(hist_data,f);


Hope this helps.
Please let me know if you have any problems with the above instructions.
Ciao
Max
 
Read Message
Read Message
Previous Topic:Efficiency plot using AIDA
Next Topic:Concerning TrackerHits vs. SimTrackerHits
Goto Forum:
  


Current Time: Fri Apr 20 03:58:56 Pacific Daylight Time 2018
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.1.
Copyright ©2001-2010 FUDforum Bulletin Board Software