//#define ff_cxx #include #include #include #include class Fittt { public : char *ntuplename; char *title; char *fitfunc; char *tw14; char *cut0001; char func[2000]; int xmin1, xmax1, ymin1, ymax1; Int_t fit1; Int_t fit2; Int_t i; Int_t nbinx, nbiny; TNtuple *ntuple; TFile *f1; TCut cut3; TH1F *hm1m2; TH1F *hm3; char angle11[100]; TCanvas* c1; TH2D *histp; Double_t rms1; TFile *f; }; void Fittt::Fittt(char *nn,Int_t ab,Int_t cd,Int_t sizex,Int_t sizey,char *name01){ ntuplename = nn; //f1 = new TFile("1.root","RECREATE"); f = new TFile("chamberdata.root","READ"); ntuple = new TNtuple(ntuplename,"m1,m2,m3,m4,m5,m6,m7,m8","m1:m2:m3:m4:m5:m6:m7:m8"); ntuple = (TNtuple)gDirectory->Get(ntuplename); c1 = new TCanvas(name01,"",sizex,sizey); // c1 = new TCanvas(); c1->Divide(ab,cd); i=1; c1->cd(i); }; void Fittt::Init( char *tit, char *fitf, char *tww, Double_t ft1, Double_t ft2, char fun[2000],Int_t nbnx,Int_t nbny) { title=tit; fitfunc=fitf; tw14=tww; fit1=ft1; fit2=ft2; strcpy(func,fun);// abcd=0; nbinx =nbnx; nbiny =nbny; }; void Fittt::draw_2dh(int ii){ ntuple->Draw(Form("%s",func),cut3); ymin1 = (int) htemp->GetMean()-5*htemp->GetRMS(); ymax1 = (int) htemp->GetMean()+5*htemp->GetRMS(); ntuple->Draw(Form("%s", tw14),cut3); xmin1 = (int) htemp->GetMean()-5*htemp->GetRMS(); xmax1 = (int) htemp->GetMean()+5*htemp->GetRMS(); TCut Dcut01 = Form("%s : %s",func,tw14); ntuple->Draw(Dcut01,cut3); if(ii==0) histp = new TH2D("histp",title, nbinx, xmin1, xmax1, nbiny, ymin1, ymax1); else if(ii==1) histp = new TH2D("histp",title, nbinx, xmin1, xmax1, nbiny, ymin1, ymax1); else { histp = new TH2D("histp",title, nbinx, 76, 105, nbiny, -200, 200); ii= ii-2; } TCut Dcut02 = Form("%s : %s >> histp",func,tw14); ntuple->Draw(Dcut02,cut3); if(ii==0) {i++; c1->cd(i);} }; void Fittt::draw_fit(int ii){ TProfile *prof = histp->ProfileX("histp_pfx"); TF1 *e = new TF1("e",fitfunc,-1,1); prof->Fit(e,"","", fit1, fit2); }; typedef struct set01 { int num; char *ntuplename; char *tt; char *f1v; char *f1f; double ft1St, ft1Ed; } set01; void ee(){ gROOT->Reset(); struct set01 dset[100] = { { 0, "20070418-5000V;1", "(m1+m2-m3)/20", "(m5+m8)/10", "pol3", 2200, 3650 } }; int j=0; char aaa[2000]; //a= new Fittt(dset[j].ntuplename,2,2,800,600,Form("%s-1","5000V-F95CO25")); a= new Fittt(dset[j].ntuplename,2,1,800,300,Form("%s-1","5000V-F95CO25")); a->Init("(t1+t4)/2-(t2+t3)/2 vs w1+w4", dset[j].f1f, dset[j].f1v, dset[j].ft1St, dset[j].ft1Ed, dset[j].tt,50,50); a->draw_2dh(0); a->draw_fit(0); }