コード例 #1
0
void plotter::good_bad(vector<double> &vecx, vector<double> &best_gen, vector<double> &smeared_gen, string filename, string title, string xaxis_label)
{
    cout << "scattering plot" << endl;
    int n = vecx.size();
    double arrx[n];
    double arry[n];
    for (int i=0; i<n; i++){
        //arrx[i] = log10(vecx.at(i)+1e-20);
        arrx[i] = vecx.at(i);
        double dif = abs(best_gen.at(i)) - abs(smeared_gen.at(i));
        arry[i] = dif;
    }

    cout << "created arrs" << endl;
    TCanvas* canvas = new TCanvas("canvas");
    TGraph *g = new TGraph(n, arrx, arry);
    g->SetMarkerStyle(2);

    cout << "getting axes" << endl;
    g->Draw("ap");
    g->GetXaxis()->SetTitle(xaxis_label.c_str());
    g->GetYaxis()->SetTitle("abs(best_gen) - abs(smeared_gen)");
    //g->GetXaxis()->SetRangeUser(0,1);
    //g->GetYaxis()->SetRangeUser(0,20000);
    g->SetTitle((title).c_str());

    canvas->Update();

    TLine *l = new TLine(canvas->GetUxmin(), 0.0, canvas->GetUxmax(), 0.0);
    l->SetLineColor(kBlue);
    l->Draw();

    cout << "before draw" << endl;
    //g->Draw("ap");
    canvas->Update();

    cout << "after draw" << endl;
    canvas->Print(filename.c_str());
    cout << "after print" << endl;

}
コード例 #2
0
ファイル: drawEvent.cpp プロジェクト: bwoneill/rdk
void drawEvent(TString str){
	Int_t nseries,nrun,nevent,ch;
	Char_t type;
	TString temp=str(TPRegexp("[SCD*]\\d+"));
	type=temp(TPRegexp("[SCD]"));
	TPRegexp digits("\\d+");
	temp=temp(digits);
	nseries=temp.Atoi();
	temp=str(TPRegexp("r\\d+"));
	temp=temp(digits);
	nrun=temp.Atoi();
	temp=str(TPRegexp("e\\d+"));
	temp=temp(digits);
	nevent=temp.Atoi();
	temp=str(TPRegexp("c\\d+"));
	temp=temp(digits);
	ch=temp.Atoi();
	//cout<<"*"<<nseries<<"r"<<nrun<<"e"<<nevent<<"c"<<ch<<endl;
	RawFileReader reader;
	reader.open(type,nseries,nrun);
	reader.seek(nevent);
	Entry entry;
	RawData rdata;
	reader.readNext(entry,rdata);
	reader.close();
	g.SetLineColor(kBlue);
	Float_t g_min=rdata.ch[ch][0],g_max=g_min,h_min=rdata.ch[15][0],h_max=h_min;
	for(Int_t i=1;i<2048;i++){
		if(rdata.ch[ch][i]>g_max){
			g_max=rdata.ch[ch][i];
		}else if(rdata.ch[ch][i]<g_min){
			g_min=rdata.ch[ch][i];
		}
		if(rdata.ch[15][i]>h_max){
			h_max=rdata.ch[15][i];
		}else if(rdata.ch[15][i]<h_min){
			h_min=rdata.ch[15][i];
		}
	}
	Float_t scale=(h_max-h_min)/(g_max-g_min),shift=(g_max*h_min-g_min*h_max)/(g_max-g_min);
	for(Int_t i=0;i<2048;i++){
		g.SetPoint(i,0.04*i,scale*rdata.ch[ch][i]+shift);
		h.SetPoint(i,0.04*i,rdata.ch[15][i]);
	}
	g.GetXaxis()->SetRangeUser(0,2047*0.04);
	h.GetXaxis()->SetRangeUser(0,2047*0.04);
	h.Draw("al");
	g.Draw("same");
	if(axis){
		delete axis;
	}
	c1.Update();
	Float_t min=(gPad->GetUymin()-shift)/scale;
	Float_t max=(gPad->GetUymax()-shift)/scale;
	axis=new TGaxis(c1.GetUxmax(),c1.GetUymin(),c1.GetUxmax(),c1.GetUymax(),min,max,510,"+L");
	axis->SetLineColor(kBlue);
	axis->SetLabelColor(kBlue);
	axis->Draw();
	cout<<g_min<<endl;
	cout<<g_max<<endl;
}