[d2n-analysis-talk] ROOT TH2D Fit Trouble: S1 Timewalk

Diana Parno dseymour at andrew.cmu.edu
Wed Mar 24 10:54:44 EDT 2010


Hi Dave,

On Wed, 24 Mar 2010, David Flay wrote:

> I have drawn profiles of my 2D histos, using:
>
>  for(Int_t i=0; i<6; i++){
>    c1->cd(i+1);
>    rootvar.Form("1e+9*L.s1.lt_c[%d]:1.0/sqrt(L.s1.la_c[%d])",i,i);
>    hname.Form("h1[%d]",i+1);
>    h1[i] = new TH2F(hname,rootvar,1000,0.02,0.2,1000,0,220);
>    h1[i]->SetName(hname);
>    h1[i]->GetXaxis()->SetTitle("1/sqrt(ADC) (arb.)");
>    h1[i]->GetXaxis()->CenterTitle();
>    h1[i]->GetYaxis()->SetTitle("TDC (ns)");
>    h1[i]->GetYaxis()->CenterTitle();
>    h1[i]->SetMarkerColor(kBlack);
>    cut = cut0;
>    T->Project(hname,rootvar,cut);
>    h1[i]->SetMinimum(0.1);
>    h1[i]->ProfileX()->Draw();
>
>    c1->Update();
>
>  }
>
> This gives the plots attached.  However, if I use the FitPanel, a linear fit
> does not work at all -- I get a solid line along the x-axis, similar to the
> problem before using the Profile function...  I tried hard-coding the fit
> in, but it then neglects the Profile function, and just draws the histogram,
> as if the ProfileX() didn't exist...

I might advise creating a separate, explicit TProfile object, as in

 	h1[i]->SetMinimum(0.1);
 	TProfile *myprofX = h1[i]->ProfileX();
 	myprofX->Draw();
 	myprofX->Fit("pol1");
 	// etc

If the profile isn't attached to its own object, I'm really not sure how 
ROOT would handle it -- I wouldn't expect the ProfileX to persist as an 
object past the line where you write "h1[i]->ProfileX()->Draw();". There 
is no reason for ROOT to think it might have to hang onto the profile once 
it's drawn. My terminology here is probably not sound, but I suspect that 
this is why the fits aren't working.

Diana


More information about the d2n-analysis-talk mailing list