{ gROOT->ProcessLine(".L th1fmorph.C"); // Dependency gStyle->SetOptStat(false); gStyle->SetOptTitle(false); // Background model is simple exponential Double_t exponent1=-0.020,exponent2=-0.040; Double_t exponentmid=0.5*(exponent1+exponent2); TF1 *pdf1 = new TF1("exp1","expo",80,150); TF1 *pdf2 = new TF1("exp2","expo",80,150); TF1 *pdfmid = new TF1("expmid","expo",80,150); pdf1->SetParameters(1,exponent1); pdf2->SetParameters(1,exponent2); pdfmid->SetParameters(1,exponentmid); TH1F *hdf1=(TH1F *)gROOT->FindObject("hdf1"); if(hdf1) delete hdf1; TH1F *hdf2=(TH1F *)gROOT->FindObject("hdf2"); if(hdf2) delete hdf2; TH1F *hdfmid=(TH1F *)gROOT->FindObject("hdfmid"); if(hdfmid) delete hdfmid; hdf1=new TH1F("hdf1","new",100,80,150); hdf2=new TH1F("hdf2","new",100,80,150); hdfmid=new TH1F("hdfmid","new",100,80,150); Double_t s=0, b=5000000; hdf1->FillRandom("exp1",b); hdf2->FillRandom("exp2",b); hdfmid->FillRandom("expmid",b); hdf1->SetLineStyle(2); hdf2->SetLineStyle(2); hdfmid->SetLineStyle(2); hdf1->Draw(); hdf2->Draw("same"); hdfmid->Draw("same"); TH1F *ginterpnew,*ginterpprev; // =(TH1F *)gROOT->FindObject("ginterp"); // if(ginterpprev) delete ginterpprev; // ginterpprev = (TH1F *)th1fmorph("ginterp","Interpolated pdf" // ,hdf1,hdf2,-0.02,-0.04,-0.02,s+b,0); // ginterpprev->Draw("same"); ostringstream histname; TString hname; Double_t x; for(Int_t ix=-200;ix>=-400;ix-=1) { x = (Double_t)ix/10000; // Prepare the new distribution histname.seekp(0); histname << "ginterp" << x; hname = histname.str(); ginterpnew = (TH1F *)gROOT->FindObject(hname); if (ginterpnew) delete ginterpnew; ginterpnew = (TH1F *)th1fmorph(hname,"Interpolated gaussian" ,hdf1,hdf2,-0.02,-0.04,x,s+b,0); // Draw the new distribution. ginterpnew->Draw("same"); // Delete the previous disttribution delete ginterpprev; // Swap what is new and previous for the next iteration ginterpprev = ginterpnew; c1->Update(); gSystem->Sleep(0010); } }