void GunMagnet_Bz(){ gROOT->Reset(); #define MAX_nentries 10000; TString pstit; // define style here // general parameters gStyle->SetOptDate(0); gStyle->SetOptTitle(0); gStyle->SetStatColor(10); gStyle->SetStatH(0.1); gStyle->SetStatW(0.2); gStyle->SetOptStat(1); gStyle->SetOptFit(0); // canvas parameters gStyle->SetFrameBorderMode(0); gStyle->SetFrameBorderSize(0); gStyle->SetFrameFillColor(0); gStyle->SetCanvasColor(0); // pads parameters // gStyle->SetPadColor(39); gStyle->SetPadColor(0); gStyle->SetPadBorderMode(0); gStyle->SetPadBorderSize(0); gStyle->SetPadBottomMargin(0.18); gStyle->SetPadRightMargin(0.10); gStyle->SetPadLeftMargin(0.14); gStyle->SetLabelSize(0.04,"x"); gStyle->SetLabelSize(0.04,"y"); gStyle->SetTitleXSize(0.08); gStyle->SetPaperSize(10,12); gStyle->SetOptLogx(0); gStyle->SetOptLogy(0); gStyle->SetTitleYOffset(0.8); gStyle->SetTitleYSize(0.10); gROOT->ForceStyle(); // Double_t zc[MAX_nentries], zp[MAX_nentries]; Double_t x[MAX_nentries], y[MAX_nentries]; Double_t Bz_coil_puck[MAX_nentries], Bz_coil[MAX_nentries]; Double_t err1[MAX_nentries]; // ifstream txtfile1; char file1[200]; sprintf(file1,"std_puck_air2.dat"); // x y zc Bz_coil // Jay Opera model of magnetized beam gun magnet // cout << "Data file is " << file1 << endl; txtfile1.open(file1); UInt_t n1=0; while(1) { txtfile1 >> x[n1] >> y[n1] >> zc[n1] >> Bz_coil[n1]; err1[n1] = 0.0; if(!txtfile1.good()) break; n1++; } // for(Int_t i=0; i> x[n2] >> y[n2] >> zp[n2] >> Bz_coil_puck[n2]; err1[n2] = 0.0; if(!txtfile2.good()) break; n2++; } // for(Int_t i=0; iSetGrid(); TGraphErrors *grS1 = new TGraphErrors(n1,zc,Bz_coil,err1,err1); TGraphErrors *grS2 = new TGraphErrors(n2,zp,Bz_coil_puck,err1,err1); grS1->GetXaxis()->SetLimits(0.0,100.0); grS1->SetMaximum(4000.0); grS1->SetMinimum(0.0); grS1->SetMarkerColor(kBlue); grS1->SetLineColor(kBlue); grS1->SetLineWidth(4); grS1->SetMarkerSize(1.0); grS1->SetMarkerStyle(20); grS1->SetLineStyle(1); grS1->GetXaxis()->CenterTitle(); grS1->GetXaxis()->SetTitleOffset(1.2); grS1->GetXaxis()->SetTitleSize(0.06); TString tit = "z (cm)"; grS1->GetXaxis()->SetTitle(tit.Data()); grS1->GetYaxis()->CenterTitle(); grS1->GetYaxis()->SetTitleOffset(1.0); grS1->GetYaxis()->SetTitleSize(0.06); TString tit = "B_{z} (Gauss)"; grS1->GetYaxis()->SetTitle(tit.Data()); grS1->Draw("A L"); // grS2->SetLineColor(kRed); grS2->SetLineWidth(4); grS2->SetLineStyle(7); grS2->Draw("same L"); // leg = new TLegend(0.45,0.70,0.85,0.85); leg->SetFillColor(0); leg->SetShadowColor(0); leg->AddEntry(grS1,"Cathode Solenoid","L"); leg->AddEntry(grS2,"Cathode Solenoid + Hybrid Puck","L"); leg->Draw(); leg->Draw(); // // b1->cd(); pstit = "GunMagnet_Bz.gif"; b1->Print(pstit.Data()); }