Hi Francescoo,
When closing a file, all objects associated with this file in the current
directory in memory are also deleted.
See Chapter "Object Ownsership" at page 107 of the Users Guide.
Your statement
delete h1;
deletes an already deleted object. You can remove this statement.
Rene Brun
On Fri, 20 Sep 2002, Perfetto Francesco wrote:
> Hi all,
> I have a problem with the following code:
> I want plotting the histo hdiv2 in the canvas for any values of howbins...
> ...
>
> TF1 *f = new TF1("myfunc",myfunction,-1,.88,0);
> TFile *f1 = new TFile("analisi_mc.root");
> TFile *f2 = new TFile("efficienza_Y.root");
> TH1D *h1 = new TH1D("h1","daliy_rec",howbins,-1,.88);
> TH1D *h2 = new TH1D("h2","eff_Y",howbins,-1,.88);
> TH1D *heff = new TH1D("heff","eff_Y" ,howbins,-1,.88);
> TH1D *hdiv = new TH1D("hdiv","hdiv" ,howbins,-1,.88);
> TH1D *hdiv2 = new TH1D("hdiv2","FIT" ,howbins,-1,.88);
>
> tmc->Draw("daliy_mc_rec >> h1","isrec==1");
> tmc->Draw("daliy_mc >> h2");
> heff->Sumw2();
> heff->Divide(h1,h2,1,1,"B");
>
> f1->cd();
> h1 = new TH1D("h1","daliy_rec",howbins,-1,.88);
> tmc->Draw("daliy_rec >> h1","isrec==1");
> hdiv->Divide(h1,heff,1,1,"E");
>
> Int_t nbins = hdiv->GetNbinsX();
>
> for (Int_t i=1;i<=nbins;i++)
> {
> Double_t min_bin = hdiv->GetBinLowEdge(i);
> Double_t max_bin = min_bin + hdiv->GetBinWidth(i);
> Double_t binContent = hdiv->GetBinContent(i);
> Double_t integrale = f->Integral(min_bin,max_bin);
> Double_t div = binContent/(2*integrale);
>
> hdiv2->SetBinContent(i,div);
> }
>
> hdiv2->Draw("E");
>
> If I delete the files open (how in the example)
> delete f1;
> delete f2;
> delete h1;
> ...
>
> it do:
>
> *** Break *** illegal instruction
> Root > Function myfunc() busy flag cleared
>
> if on the other hand I close the file :
> f1->Close();
> f2->Close();
> it don't give me any error but it don't draw the histogram hdiv2 in the
> canvas.
> Is there someone that can to show me where mistake (possibly wiyh an
> example).
>
> ManyThanks to all
> Francesco.
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET