{ gStyle->SetOptStat(0); f_2009 = new TFile("r0270101995_v000_digi.01.adcmean.root"); TTree* nt_2009 = (TTree*)f_2009->Get("inl_fit_results"); double erry[200]; double errx[200]; double y[200]; double x[200]; double devy[200]; double xlog[200]; f_2010 = new TFile("r0299679002_v000_digi.root.01.adcmean.root"); TTree* nt_2010 = (TTree*)f_2010->Get("inl_fit_results"); nt_2010->AddFriend(nt_2009,"nt_2009"); TFile* fout = new TFile("fcidiff_2009_2010_rng1_twr15.root","RECREATE"); TNtuple* ntout = new TNtuple("ntout","ntout","slope:offset:chi2:ndf:twr:lyr:col:face:rng"); TH2F* hdifftot = new TH2F("hdifftot","hdifftot",400,0,4,100,-5,5); int rng=1; int twr=15; int lyr=0; int col=0; int face=0; // for (twr=0;twr<16;twr++) for (lyr=0;lyr<8;lyr++) for(col=0;col<12;col++) for(face=0;face<2;face++) { ostringstream canvname; canvname << "canv_twr" << twr <<"_lyr" << lyr << "_col" << col << "_face" << face; TCanvas* canv = new TCanvas(canvname.str().c_str(),canvname.str().c_str(),100,100,800,600); // canv->Divide(1,2); // canv->cd(1); ostringstream hdiffname; hdiffname <<"hdiff_twr" << twr <<"_lyr" << lyr << "_col" << col << "_face" << face; TH2F* hdiff = new TH2F(hdiffname.str().c_str(),hdiffname.str().c_str(),10,0,2500,10,-10,10); ostringstream selstr; selstr << "dac_val<2500 && rng==" << rng <<" && twr==" << twr << " && lyr==" << lyr << " && col==" << col << " && face==" << face; cout << selstr.str().c_str() << endl; // nt_max->Draw("sqrt(pow(final_adcrms,2)/98+pow(gnd.final_adcrms,2)/98):dac_val","rng==3 && dac_val<3800 && twr==0 && lyr==0 && col==0 && face==0"); nt_2010->Draw("sqrt(pow(final_adcrms,2)/98+pow(nt_2009.final_adcrms,2)/98):dac_val",selstr.str().c_str()); TGraph* gr = gPad->GetPrimitive("Graph"); int n = gr->GetN(); double *ey = gr->GetY(); for(int i=0;iDraw("final_adcmean-nt_2009.final_adcmean:dac_val","rng==3 && dac_val<3800 && twr==0 && lyr==0 && col==0 && face==0"); nt_2010->Draw("final_adcmean-nt_2009.final_adcmean:dac_val",selstr.str().c_str()); TGraph *gr = (TGraph*) gPad->GetPrimitive("Graph"); n = gr->GetN(); double* dci = gr->GetY(); double* dac = gr->GetX(); for(int i=0;iSetMarkerStyle(24); grdiff->SetMarkerSize(0.5); ostringstream grname; grname << "gr_twr" << twr <<"_lyr" << lyr << "_col" << col << "_face" << face; grdiff->SetName(grname.str().c_str()); hdiff->Draw(); grdiff->Draw("P"); ostringstream funname; funname <<"lin_twr"<SetParameters(0.0,-0.0005); grdiff->Fit(funname.str().c_str(),"R"); double slope=lin->GetParameter(1); double offset=lin->GetParameter(0); for(int i=0;iFill(xlog[i],devy[i]);} // canv->cd(2); ostringstream canvlogname; canvlogname << "canvlog_twr" << twr <<"_lyr" << lyr << "_col" << col << "_face" << face; TCanvas* canvlog = new TCanvas(canvlogname.str().c_str(),canvlogname.str().c_str(),100,100,800,600); ostringstream hdifflogname; hdiffname <<"hdifflog_twr" << twr <<"_lyr" << lyr << "_col" << col << "_face" << face; TH2F* hdifflog = new TH2F(hdifflogname.str().c_str(),hdifflogname.str().c_str(),10,0,4,10,-10,10); TGraphErrors* grdifflog = new TGraphErrors(n,xlog,devy,errx,erry); grdifflog->SetMarkerStyle(24); grdifflog->SetMarkerSize(0.5); hdifflog->Draw(); grdifflog->Draw("P"); canv->Write(); canvlog->Write(); // grdiff->Write(); // lin->Write(); float par[10]; par[0]=lin->GetParameter(1); par[1]=lin->GetParameter(0); par[2]=lin->GetChisquare(); par[3]=lin->GetNDF(); par[4]=twr; par[5]=lyr; par[6]=col; par[7]=face; par[8]=rng; ntout->Fill(par); canv->Close(); canvlog->Close(); delete lin; delete grdiff; delete hdiff; delete grdifflog; delete hdifflog; } hdifftot->Write(); ntout->Write(); fout->Close(); }