void test_macro()//arguements:th1, th2, y axis max { gStyle->SetNdivisions(510,"X"); gStyle->SetNdivisions(505,"Y"); gStyle->SetStatBorderSize(1); gStyle->SetStatW(0.2); gStyle->SetStatH(0.1); gStyle->SetCanvasBorderMode(0); gStyle->SetPadBorderMode(0); gStyle->SetCanvasColor(0); gStyle->SetFrameBorderMode(0); gStyle->SetPadColor(0); gStyle->SetStatColor(0); gStyle->SetLabelSize(.06,"xy"); gStyle->SetLabelOffset(.011,"xy"); gStyle->SetTitleXOffset(1.1); gStyle->SetTitleXSize(0.06); gStyle->SetTitleYOffset(1.12); gStyle->SetTitleYSize(0.06); gStyle->SetTitleW(0.5); gStyle->SetTitleH(0.08); gStyle->SetTitleBorderSize(1); gStyle->SetTitleFillColor(0); gStyle->SetPadLeftMargin(0.18); gStyle->SetPadRightMargin(0.15); gStyle->SetPadBottomMargin(.18); gStyle->SetTextSize(.03); gStyle->SetStatFontSize(.03); gStyle->SetOptStat(11); gStyle->SetOptTitle(0); gStyle->SetPalette(1); Int_t TH1 = 16, TH2 =16; TGraph *tg1, *tg2, *tg3, *tg4; int nn1 = 0, nn2 = 0; float kB1[5500], kB2[5500], kB3[5500], kB4[5500], kB5[5500]; char line[256], cc1[1], kHash1[1], buff1[256], ch1, cc2[1], kHash2[1], buff2[256], ch2; float var1a, var2a, var3a, var4a, var5a; float var1b, var2b, var3b, var4b, var5b; float sigma1[200], ss1[200], ed1[200], ep1[200], en1[200]; float sigma2[200], ss2[200], ed2[200], ep2[200], en2[200]; float ee1, th1a, th2a, phi12a, dummy1a; float ee2, th1b, th2b, phi12b, dummy1b; int points1, dummy2a, dummy3a; int points2, dummy2b, dummy3b; //########### //read a text file //fill vectors //plot TGraphError //save it as png file char file1[500], file2[500]; char text1[500]; float kS1, kCounts1, kNorm; float kS[200], kS_err[200], kCounts[200]; float kSQRT_count1; float kSQRT_count[200]; FILE *pfile, *pfile1, *pfile2; TGraphErrors *tg; int k1[49], k2[49]; float k3[49], k4[49]; int kk1, kk2; float kk3, kk4; int m1[49], m2[49]; float m3[49], m4[49]; int mm1, mm2; float mm3, mm4; float deltaS = 4.0; float tot_effi_d[7], tot_effi_p[7]; //normalising factor: float n_el[7] = {1465730, 793332, 502017, 371621, 279511, 259465, 239448}; float dOhm_p[7] = {0.0605, 0.0678, 0.0750, 0.0822, 0.0892, 0.0961, 0.1030}; float sigma_el[7] = {7.5, 3.55, 2.0, 1.38, 1.02, 0.78, 0.62}; float effi_dE[7]={0.9980, 0.9981, 0.9982, 0.9982, 0.9984, 0.9984, 0.9981}; float effi_MWPC_D[7]={0.8698, 0.8759, 0.8739, 0.8712, 0.8768, 0.8719, 0.8761};//for deuterons float effi_MWPC_P[7]={0.8496, 0.8533, 0.8484, 0.8484, 0.8499, 0.8642, 0.8539};//for protons float effi_cross_over_el[7]={0.9929, 0.9938, 0.9898, 0.9915, 0.9937, 0.9936, 0.9902};//from elastic d simulation float effi_conf[7][7]; float effi_cross_over_br[7][7];//for breakup configurations int TriggReScale = 32; // to scale back the single trigg events of el d int micro2mili = 1000;//convert the elastic cro-sec from micro to mili barn (because theory is in mili) float nonrel2rel = 3.0;//approximate conversion from non-reltivistic theory to relativistic (in MeV) kNorm = 1.0; sprintf(file1,"S_bg_sub_thd%d_thp%d_fi180.dat", TH1, TH2);//WITH BACKGROUND SUB. int n = 0; pfile = fopen(file1,"r"); while (true) { fscanf(pfile," %f %f %f", &kS1, &kCounts1, &kSQRT_count1); if (feof(pfile)) break; kS[n] = kS1; kS_err[n] = 0; kCounts[n] = kCounts1/kNorm; kSQRT_count[n] = kSQRT_count1/kNorm; n++; } tg = new TGraphErrors(n, kS, kCounts, kS_err, kSQRT_count); tg->SetMarkerColor(kOrange); tg->SetMarkerStyle(21); tg->SetMarkerSize(1.0); tg->GetXaxis()->SetTitle("S [MeV]"); tg->GetYaxis()->SetTitle("#frac{d^{5}#sigma}{dSd#Omega_{1}d#Omega_{2}} [#mub#upointsr^{-2}#upointMeV^{-1}]"); tg->GetXaxis()->CenterTitle(); tg->GetYaxis()->CenterTitle(); float gunn = 20.0; TCanvas *can1 = new TCanvas ("can1","can1",700,450); Float_t ymax_my = 1.0; // can1->cd(); tg->Draw("AP"); TAxis *axis = tg->GetXaxis(); axis->SetLimits(20.,190.); // along X tg->GetHistogram()->SetMaximum(ymax_my); // along tg->GetHistogram()->SetMinimum(0); // Y sprintf(text1,"#it{#theta_{p}}=%d#circ", TH2); TPaveText *pt1=new TPaveText(0.2,0.8,0.4,0.85,"NDC"); pt1->SetFillColor(0); pt1->AddText(text1); pt1->SetBorderSize(0); pt1->SetTextFont(82); pt1->SetTextSize(0.05); pt1->SetTextColor(1); pt1->Draw(); can1->Modified(); can1->Update(); Float_t rightmax = ymax_my*gunn; TGaxis *right_axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,505,"+L"); right_axis->SetLineColor(kRed); right_axis->SetTextColor(kRed); right_axis->SetTitle("neutron energy [MeV]"); right_axis->SetTitleSize(0.06); right_axis->CenterTitle(); right_axis->SetLabelOffset(0.008); right_axis->SetTextFont(82); right_axis->SetLabelFont(82); right_axis->SetLabelSize(0.06); right_axis->SetLabelColor(kRed); right_axis->SetTitleOffset(0.9); right_axis->Draw(); can1->SaveAs(Form("S_thd%d_thp%d_fi180.png", TH1, TH2)); }