//-------------------------------------------------------------- // test prg //general header #ifndef __CINT__ // to compile outside of the CINT #include #include // also includen in TMATH //-----ROOT--#includes------------------------------------------ #include #include #include // histo #include #include #include #include #include #include #include #include #include #include #include #include #include #include // to print (save) in ps #include #include #include #include #include #include //not need #include #include #include #include //general IO //-----LOCAL--#includes------------------------------------------ //------------- inline variables---------------------------------- #define XMAX 5 // coord. max integer #define YMAX 5 // integer!! #define BINSIZE 100 //---------------------------------------------------------------- int test(); // declarations end----------------------------------------------- int main(int argc, char **argv) //default main { delete gRandom; // i'll change it immidiatly to avoid problems gRandom=new TRandom3(); // this is mucsh better random generator // i don't know why not default (slow?) gROOT->SetStyle("Plain"); TApplication theApp("App", &argc, argv);// for the GUI TTree::SetBranchStyle(1); // Gui style see user guide for more option int i=test() ; // our test program theApp.Run(); // Gui loop return i; } #endif // for CINT //______________________________________________________________________ //__BEGIN THE PROG______________________________________________________ //______________________________________________________________________ int test(){ gStyle->SetNdivisions(5,"X");// set divisions gStyle->SetNdivisions(5,"Y"); gStyle->SetNdivisions(5,"Z"); //gStyle->SetFrameLineColor(0); //gStyle->SetFrameBorderMode(0); TCanvas *MyC = new TCanvas( "MyC","TestCanvas",800,600); //gROOT->LoadClass("TPostScript","Postscript");// postcrip //TPostScript ps("rayl.ps",112); //name of the ps file:: 112==landscape!!!!! MyC->Divide(1,2); TH2F *hist_h =new TH2F("some data","Some Title",BINSIZE,-XMAX,XMAX,BINSIZE,-YMAX,YMAX);//create histo for surface TH2F *hist_v =new TH2F("some data","Some Title",BINSIZE,-XMAX,XMAX,BINSIZE,-YMAX,YMAX);//create histo for surface double X,Y,R,const1,const2; // some values R=2; const1=1.0; const2=0.1; //--------------------------------------------------------------------------------------------------- int J=1; int I=1; double I_horizontal; double part1_hor; double part2a_hor; double phi, A; // fill histo for (int i=1;i<=BINSIZE;i++){ X=-1.0*XMAX+(2.0*XMAX/(BINSIZE-1.0))*(I-1.0); for (int j=1;j<=BINSIZE;j++){ Y=-1.0*YMAX+(2.0*YMAX/(BINSIZE-1.0))*(J-1.0); A=1.0+X*X-Y*Y; // checking a part1_hor = (const1*(X*X)/(1.00+(X*X)))*TMath::Exp(-1.0*R*TMath::Power((1.00+(X*X)),(0.5)))/(1.0+(X*X+Y*Y)); //part2b_hor =TMath::ACos((-2.0*TMath::Power((1+X*X),0.5)*Y)/(1.0+X*X+Y*Y))); if ( A > 0.0){ phi =TMath::ASin((1.0+X*X-Y*Y)/(1.0+X*X+Y*Y)); } else { phi =TMath::Pi()-TMath::ASin(TMath::Abs((1.0+X*X-Y*Y))/(1.0+X*X+Y*Y)); } part2a_hor =(1.0+2.0*(const2*const2)*(1.0+X*X))+TMath::Sin(R*Y+phi); I_horizontal=part1_hor *part2a_hor; //std::cout << I<<"\t"<SetBinContent(I,J,I_horizontal); hist_v->SetBinContent(I,J,I_horizontal); } I++; J=1; } //-------------------------------------------------------------------------------------------- // label axis for horizonatl hist_h->GetXaxis()->SetTitle("X axis"); hist_h->GetYaxis()->SetTitle("Y axis"); hist_h->GetZaxis()->SetTitle("Intensity (au)"); MyC->cd(1); hist_h->Draw("SURF"); MyC->cd(2); //gPad->SetGrid(1,1); hist_v->Draw("SURF"); MyC->cd(0); MyC-> Modified(); MyC-> Update(); return 0; }