Exemplo n.º 1
0
void setGraphOptions(TF2 &f, 
		     const char *xname, 
		     const char *yname)
{
  TAxis::TAxis *axis1;
  TAxis::TAxis *axis2;
  axis1 = f.GetXaxis();
  axis2 = f.GetYaxis();
  axis1->SetTitle(xname);
  axis2->SetTitle(yname);
  setAxisOptions(axis1);
  setAxisOptions(axis2);
}
Exemplo n.º 2
0
int main(int argc, char** argv){
  if(argc!=2){
    std::cerr << "### Usage like ... \n   ./gaus2d 10000(imax)" << std::endl ;
    return EXIT_FAILURE ;
  }
  else{/* DO NOT ANYTHING */}
  TApplication app( "app", &argc, argv );  
  double x ;
  double y ;
  int imax = atoi(argv[1]) ;
  TString title("2D Gaussian") ;
  TString titleimax(argv[1])   ;
  title += titleimax ;
  
  TCanvas *c1 = new TCanvas("c1", "c1", 600, 600) ;
  gStyle->SetOptStat("enRM") ;
  c1->SetTicks(1,1) ;
  c1->SetGrid(1,1) ;
  c1->SetRightMargin(0.15) ;
  TH2D *hist    = new TH2D("hist",title,100, -5., 5., 100, -5., 5.) ;
  TF2 *gausfunc = new TF2("gausfunc","[0]*TMath::Exp( - TMath::Sqrt(  TMath::Power((x-[1])/[2],2)/2. + TMath::Power((y-[3])/[4],2)/2. ))", -5., 5., -5., 5.) ;
  gausfunc->SetParameters(1., 0., 0.5, 0., 0.5) ;
  gausfunc->SetNpx(300) ;
  gausfunc->SetNpy(300) ;

  gRandom->SetSeed(unsigned(time(NULL))) ;
  for(int i =0 ; i< imax ; i++){
    gausfunc->GetRandom2(x,y) ;
    hist->Fill(x,y) ;
  }
  hist->Draw("colz") ;
  gPad->Update();
  TPaveStats *st = (TPaveStats*)hist->FindObject("stats") ;
  st->SetX1NDC(0.60) ;
  st->SetX2NDC(0.85) ;
  st->SetY1NDC(0.70) ;
  st->SetY2NDC(0.90) ;
  c1->SaveAs("gaus2dc1.eps") ;
  app.Run() ;
  delete c1 ;
  delete hist ;
  delete gausfunc ;
  return EXIT_SUCCESS ;
}
Exemplo n.º 3
0
Int_t VisualizeSurface()
{
    std::string rfname = GetROOTFile();
    TFile *fle = new TFile(rfname.data());
    if (!fle->IsOpen()) return -1;

    Eta2C eta(fle);
    AngMarginalEta2C marg_eta(eta);
    fle->Close();

    ParamFunctorAdapter *pfa = new ParamFunctorAdapter(marg_eta);

    ROOT::Math::ParamFunctor pf;
    pf.SetFunction(pfa);
    TF2* f = new TF2("f", pf, -1, 1, -1.0*CLHEP::pi,CLHEP::pi,0);
    f->SetNpx(50);
    f->SetNpy(50);

//    TPaveText* pt = new TPaveText(0.5, 0.75, 0.8, 0.95);
//    std::ostringstream os(std::ios::out | std::ios::app);
//    os << "a = " << params[0]->GetValue();
//    pt->InsertText(os.str().data());
//    os.str("b = ");
//    os << params[1]->GetValue();
//    pt->InsertText(os.str().data());
//    os.str("c = ");
//    os << params[2]->GetValue();
//    pt->InsertText(os.str().data());
//    os.str("d = ");
//    os << params[3]->GetValue();
//    pt->InsertText(os.str().data());

    TCanvas* c = new TCanvas("c");
    c->Divide(2,1,0.001,0.001);
    c->cd(1);
    f->Draw("cont1 z");
    c->cd(2);
    f->DrawCopy("surf1 z");

//    pt->Draw();

    return 0;
}
Exemplo n.º 4
0
// Render a TF2 looking like a rose.
// Author: Timur Pocheptsov
void glrose()
{
  //Define and set user's palette,
   //use polar system.
   const Int_t paletteSize = 10;
   Float_t rgb[paletteSize * 3] =
      {0.80f, 0.55f, 0.40f,
       0.85f, 0.60f, 0.45f,
       0.90f, 0.65f, 0.50f,
       0.95f, 0.70f, 0.55f,
       1.f,   0.75f, 0.60f,
       1.f,   0.80f, 0.65f,
       1.f,   0.85f, 0.70f,
       1.f,   0.90f, 0.75f,
       1.f,   0.95f, 0.80f,
       1.f,   1.f,   0.85f};

   Int_t palette[paletteSize] = {0};

   for (Int_t i = 0; i < paletteSize; ++i)
      palette[i] = TColor::GetColor(rgb[i * 3], rgb[i * 3 + 1], rgb[i * 3 + 2]);

   gStyle->SetPalette(paletteSize, palette);

   gStyle->SetCanvasPreferGL(1);
   TCanvas *cnv = new TCanvas("glc", "Surface sample", 200, 10, 600, 550);

   TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98,
                           "\"glsurf2pol\" option + user defined palette.");
   title->SetFillColor(32);
   title->Draw();

   TPad *rosePad  = new TPad("box", "box", 0.04, 0.04, 0.96, 0.8);
   rosePad->Draw();


   TF2 *fun = new TF2("a", "cos(y)*sin(x)+cos(x)*sin(y)", -6, 6, -6, 6);
   fun->SetContour(paletteSize);
   fun->SetNpx(30);
   fun->SetNpy(30);
   rosePad->cd();
   fun->Draw("glsurf2pol");
}
void
plot2DSignalAnalytisch(
    TString filename,
    TString histogramName,
    TString xtitle = "x",
    TString ytitle = "y",
    double rebinx = 1,
    double rebiny = 1,
    double xtitleOffset = 1.1,
    double ytitleOffset = 1.3
    )
{
// {{{
    InitgStyle();
    //gStyle->SetOptStat(0);
    //gCanvas = new TCanvas("gCanvas", "gCanvas", 0, 0, 800, 600);
    

    LoadHistogramTH2D(histogramName , filename, 1.0, histogram);// Summe (SM

    //gCanvas->Clear();
  
    histogram->GetXaxis()->SetTitle(xtitle);
    histogram->GetXaxis()->SetTitleOffset(xtitleOffset);
    histogram->GetYaxis()->SetTitle(ytitle);
    histogram->GetYaxis()->SetTitleOffset(ytitleOffset);

    //histogram->GetZaxis()->SetTitle("d^{2}#sigma / dM_{#bar{t}}dM_{t} [pb]");
    //histogram->GetZaxis()->SetTitleOffset(ytitleOffset);

//    gCanvas->Update();

    //TF2 *fitFunction = new TF2("fitFunction", HistoSum, -1, 1, -1, 1, 4);  //allgemeine "return"-Varianten
    //fitFunction->SetParameters(0.9,0.,0.);

    TF2 *fitFunction = new TF2("fitFunction", HistoSum, -1, 1, -1, 1, 2);


    histogram->Fit(fitFunction, "N");
//    for(int i =1; i<=5;i++){
//        for(int j=1;j<=5;j++){
//            cout << "Bininhalt("<<i<<","<<j<<"): " << histogram->GetBinContent(i,j) << endl;
//        }
//    }
        
    histogram->RebinX(rebinx);
    histogram->RebinY(rebiny);
    histogram->Draw("lego"); 
    fitFunction->SetLineColor(kRed);
    fitFunction->SetLineWidth(0.5);
    fitFunction->Draw("same");
    cout << fitFunction->GetChisquare()/fitFunction->GetNDF() << endl;
       
    
    //gCanvas->Print(epsFilename(filename, histogramName)+".eps");
	//cout << histogram[0]->Integral() << endl;
// }}}
};
Exemplo n.º 6
0
void integrate_yield() {

  double* mom;

  TF2* momF;

  if (PART == 0) {
    mom = electron_m;
    momF = dndxdlFelectron;
    momF->SetParameter(0, eMass);
  }
  if (PART == 1) {
    mom = pion_m;
    momF = dndxdlFpion;
    momF->SetParameter(0, piMass);
  }
  if (PART == 2) {
    mom = kaon_m;
    momF = dndxdlFkaon;
    momF->SetParameter(0, kMass);
  }

  momF->SetParameter(1, MIRROR);
  momF->SetParameter(2, PMT);
  momF->SetParameter(3, GAS);
  momF->SetParameter(4, WC);

  double ngammas[MNP];
  for (int i = 0; i < MNP; i++) {
    TF12 temp("temp", momF, mom[i], "x");

    // ngammas[i] = temp.Integral(190, 650, nullptr, 0.1);
    ngammas[i] = temp.Integral(190, 650, 0.1);

    cout << pname[PART] << " momentum: " << mom[i]
         << "   n gammas: " << ngammas[i] << " mirror: " << mirname[MIRROR]
         << "  pmt: " << pmtname[PMT] << " wc: " << wcname[WC] << endl;

    if (PART == 0) {
      electron_n[i] = ngammas[i];
    }
    if (PART == 1) {
      pion_n[i] = ngammas[i];
    }
    if (PART == 2) {
      kaon_n[i] = ngammas[i];
    }
  }
}
Exemplo n.º 7
0
void LS(int ups, int iy, int ipt){
	TString LS_name = Form("LS_y%d_pt%d_ups%d",iy,ipt,ups);
	double dm_scale_max;
	double dm_scale_min;
	if(ipt==fNpt){
		dm_scale_max=1.0+dm_scale_width_last[0];
		dm_scale_min=1.0-dm_scale_width_last[1];
	}
	else {
		dm_scale_min=1.0-dm_scale_width; 
		dm_scale_max=1.0+dm_scale_width; 
	}
	
	TF2 *LS = new TF2(LS_name, PDF_shape, 8.7,11.3,dm_scale_min,dm_scale_max,N_event*2); 

	//Main loop
	//R was 11.6
	int Ntail=static_cast<int>(static_cast<double>(N_event)/(R+1) );

	for(int iSample=0; iSample<N_event; iSample++){
		int im=2*iSample; 
		int is=2*iSample+1; 
		
		double zeta=get_dm(dm);//Get mass uncertainty 
		
		double m=0; 	
		if(iSample<Ntail)m=mass_function->GetRandom(8.7,fill_cutoff[ups-1]); //should be pm-0.002
		else m=PDG_mass[ups-1]; // Get Mass 
			
		LS->SetParameter(im,m);
		LS->SetParameter(is,zeta); 	
	}
	//Write output
	LS->SetNpx(Npx); 
	LS->SetNpy(Npy); 
	output_file->cd();
	LS->Write(); 
	//delete pointers 
	delete LS; 
	
}
Exemplo n.º 8
0
int TwoHistoFit2D(bool global = true) {

    // create two histograms

    int nbx1 = 50;
    int nby1 = 50;
    int nbx2 = 50;
    int nby2 = 50;
    double xlow1 = 0.;
    double ylow1 = 0.;
    double xup1 = 10.;
    double yup1 = 10.;
    double xlow2 = 5.;
    double ylow2 = 5.;
    double xup2 = 20.;
    double yup2 = 20.;

    TH2D * h1 = new TH2D("h1","core",nbx1,xlow1,xup1,nby1,ylow1,yup1);
    TH2D * h2 = new TH2D("h2","tails",nbx2,xlow2,xup2,nby2,ylow2,yup2);

    double iniParams[10] = { 100, 6., 2., 7., 3, 100, 12., 3., 11., 2. };
    // create fit function
    TF2 * func = new TF2("func",my2Dfunc,xlow2,xup2,ylow2,yup2, 10);
    func->SetParameters(iniParams);

    // fill Histos
    int n1 = 50000;
    int n2 = 50000;
    //  h1->FillRandom("func", n1);
    //h2->FillRandom("func",n2);
    FillHisto(h1,n1,iniParams);
    FillHisto(h2,n2,iniParams);

    // scale histograms to same heights (for fitting)
    double dx1 = (xup1-xlow1)/double(nbx1);
    double dy1 = (yup1-ylow1)/double(nby1);
    double dx2 = (xup2-xlow2)/double(nbx2);
    double dy2 = (yup2-ylow2)/double(nby2);
//   h1->Sumw2();
//   h1->Scale( 1.0 / ( n1 * dx1 * dy1 ) );
    // scale histo 2 to scale of 1
    h2->Sumw2();
    h2->Scale(  ( double(n1) * dx1 * dy1 )  / ( double(n2) * dx2 * dy2 ) );


    if (global) {
        // fill data structure for fit (coordinates + values + errors)
        std::cout << "Do global fit" << std::endl;
        // fit now all the function together

        // fill data structure for fit (coordinates + values + errors)
        TAxis *xaxis1  = h1->GetXaxis();
        TAxis *yaxis1  = h1->GetYaxis();
        TAxis *xaxis2  = h2->GetXaxis();
        TAxis *yaxis2  = h2->GetYaxis();

        int nbinX1 = h1->GetNbinsX();
        int nbinY1 = h1->GetNbinsY();
        int nbinX2 = h2->GetNbinsX();
        int nbinY2 = h2->GetNbinsY();

        /// reset data structure
        coords = std::vector<std::pair<double,double> >();
        values = std::vector<double>();
        errors = std::vector<double>();


        for (int ix = 1; ix <= nbinX1; ++ix) {
            for (int iy = 1; iy <= nbinY1; ++iy) {
                if ( h1->GetBinContent(ix,iy) > 0 ) {
                    coords.push_back( std::make_pair(xaxis1->GetBinCenter(ix), yaxis1->GetBinCenter(iy) ) );
                    values.push_back( h1->GetBinContent(ix,iy) );
                    errors.push_back( h1->GetBinError(ix,iy) );
                }
            }
        }
        for (int ix = 1; ix <= nbinX2; ++ix) {
            for (int iy = 1; iy <= nbinY2; ++iy) {
                if ( h2->GetBinContent(ix,iy) > 0 ) {
                    coords.push_back( std::make_pair(xaxis2->GetBinCenter(ix), yaxis2->GetBinCenter(iy) ) );
                    values.push_back( h2->GetBinContent(ix,iy) );
                    errors.push_back( h2->GetBinError(ix,iy) );
                }
            }
        }

        TVirtualFitter::SetDefaultFitter("Minuit");
        TVirtualFitter * minuit = TVirtualFitter::Fitter(0,10);
        for (int i = 0; i < 10; ++i) {
            minuit->SetParameter(i, func->GetParName(i), func->GetParameter(i), 0.01, 0,0);
        }
        minuit->SetFCN(myFcn);

        double arglist[100];
        arglist[0] = 0;
        // set print level
        minuit->ExecuteCommand("SET PRINT",arglist,2);

// minimize
        arglist[0] = 5000; // number of function calls
        arglist[1] = 0.01; // tolerance
        minuit->ExecuteCommand("MIGRAD",arglist,2);

        //get result
        double minParams[10];
        double parErrors[10];
        for (int i = 0; i < 10; ++i) {
            minParams[i] = minuit->GetParameter(i);
            parErrors[i] = minuit->GetParError(i);
        }
        double chi2, edm, errdef;
        int nvpar, nparx;
        minuit->GetStats(chi2,edm,errdef,nvpar,nparx);

        func->SetParameters(minParams);
        func->SetParErrors(parErrors);
        func->SetChisquare(chi2);
        int ndf = coords.size()-nvpar;
        func->SetNDF(ndf);

        std::cout << "Chi2 Fit = " << chi2 << " ndf = " << ndf << "  " << func->GetNDF() << std::endl;

        // add to list of functions
        h1->GetListOfFunctions()->Add(func);
        h2->GetListOfFunctions()->Add(func);
    }
    else {
        // fit independently
        h1->Fit(func);
        h2->Fit(func);
    }



    // Create a new canvas.
    TCanvas * c1 = new TCanvas("c1","Two HIstogram Fit example",100,10,900,800);
    c1->Divide(2,2);
    gStyle->SetOptFit();
    gStyle->SetStatY(0.6);

    c1->cd(1);
    h1->Draw();
    func->SetRange(xlow1,ylow1,xup1,yup1);
    func->DrawCopy("cont1 same");
    c1->cd(2);
    h1->Draw("lego");
    func->DrawCopy("surf1 same");
    c1->cd(3);
    func->SetRange(xlow2,ylow2,xup2,yup2);
    h2->Draw();
    func->DrawCopy("cont1 same");
    c1->cd(4);
    h2->Draw("lego");
    gPad->SetLogz();
    func->Draw("surf1 same");

    return 0;
}
Exemplo n.º 9
0
int main(int argc, char **argv) {

  // This allows you to view ROOT-based graphics in your C++ program
  // If you don't want view graphics (eg just read/process/write data files), 
  // this can be ignored
  TApplication theApp("App", &argc, argv);

  TCanvas* canvas = new TCanvas();
  // ***************************************
  // not important for this exmple
  // Set a bunch of parameters to make the plot look nice
  canvas->SetFillColor(0);
  canvas->UseCurrentStyle();
  canvas->SetBorderMode(0);        // still leaves red frame bottom and right
  canvas->SetFrameBorderMode(0);   // need this to turn off red hist frame!
  gROOT->SetStyle("Plain");
  canvas->UseCurrentStyle();
  gROOT->ForceStyle();
  canvas->Divide(2, 1);

  gStyle->SetOptStat(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetTitleSize(0.04);
  gStyle->SetTitleFont(42, "hxy");      // for histogram and axis titles
  gStyle->SetLabelFont(42, "xyz");      // for axis labels (values)
  gROOT->ForceStyle();
  // ***************************************

  TFile *f=new TFile("fitInputs.root");
  TH2F *hist1 = (TH2F*)f->Get("hdata");
  TH2F *hback = (TH2F*)f->Get("hbkg"); 
 
  double xmin = 0.0;
  double xmax = 6.0;
  double ymin = 0.0;
  double ymax=6.0;  
  // Initialize minuit, set initial values etc. of parameters.
  const int npar = 6;              // the number of parameters
 
  TMinuit minuit(npar);
  minuit.SetFCN(fcn);              // the fcn to be minized 
  // (eg calculates chi^2 or NLL, not the
  // parameterization of the data!


  TF2* myfunc = new TF2("myfunc", gausPdf, xmin, xmax, ymin, ymax, npar);  
  // use this to fit the data and get results
  double par[npar];               // the start values
  double stepSize[npar];          // step sizes 
  double minVal[npar];            // minimum bound on parameter 
  double maxVal[npar];            // maximum bound on parameter
  TString parName[npar];

  par[0] = hback->GetMaximum();       // guesses for starting the fit
  par[1] = hist1->GetMaximum();                     
  par[2] = 3.555;                     //use mean and rms values from histogram
  par[3] = 1.17;                      //as initial guesses for parameters 
  par[4] = 1.879;
  par[5] = 1.229;
  stepSize[0] = TMath::Abs(par[0]*0.1);   
  stepSize[1] = TMath::Abs(par[1]*0.1);   // step size MUST be positive!
  stepSize[2] = TMath::Abs(par[2]*0.1);
  stepSize[3] = TMath::Abs(par[3]*0.1);
  stepSize[4] = TMath::Abs(par[4]*0.1);
  stepSize[5] = TMath::Abs(par[5]*0.1);
  minVal[0] = 0;      // if min and max values = 0, parameter is unbounded.
  maxVal[0] = 0;
  minVal[1] = 0; 
  maxVal[1] = 0;
  minVal[2] = 0;
  maxVal[2] = 6;
  minVal[3] = 0;
  maxVal[3] = 6;
  minVal[4] = 0;
  maxVal[4] = 6;
  minVal[5] = 0;
  maxVal[5] = 6;

  parName[0] = "Bkg";
  parName[1] = "A";
  parName[2] = "x0";
  parName[3] = "sigma_x";
  parName[4] = "y0";
  parName[5] = "sigma_y";

  for (int i=0; i<npar; i++){
    minuit.DefineParameter(i, parName[i].Data(), 
			   par[i], stepSize[i], minVal[i], maxVal[i]);
  }


  // here we define the pointers to pass information to Minuit's fcn
  // not pretty, but works well
  hdata=hist1;
  hback->Scale(1.0/3600.0); //scale over total number of entries first
  hb=hback;
  fparam=myfunc;

  // Do the minimization!
  minuit.Migrad();       // Minuit's best minimization algorithm
  double outpar[npar], err[npar];
  for (int i=0; i<npar; i++){
    minuit.GetParameter(i,outpar[i],err[i]);
  }
  TH2F *residual = new TH2F("residual", "Residuals Plot: data-fit", 
			    50, 0, 6, 50, 0, 6);
  myfunc->SetParameters(outpar);
  for (int i=1; i<=hist1->GetNbinsX(); i++){
    for(int j=1; j<=hist1->GetNbinsY(); j++){
      double x = hist1->GetBinCenter(i);
      double y = hist1->GetBinCenter(j);
      double f= myfunc->Eval(x, y);
      double r = hist1->GetBinContent(i, j) -f;
      residual->Fill(x, y, r);
    }
  }


  canvas->cd(1);
  residual->GetXaxis()->SetTitle("x");
  residual->GetYaxis()->SetTitle("y");
  residual->GetXaxis()->CenterTitle();
  residual->GetYaxis()->CenterTitle();
  residual->GetXaxis()->SetTitleOffset(1.25);
  residual->GetYaxis()->SetTitleOffset(1.25);
  residual->Draw("colz");
  canvas->cd(2);
  hist1->Add(hback, -outpar[0]);
  hist1->SetTitle("Data Signal with Fitted Background Subtracted");
  hist1->GetXaxis()->SetTitle("x");
  hist1->GetYaxis()->SetTitle("y");
  hist1->GetZaxis()->SetTitle("signal value");
  hist1->GetXaxis()->CenterTitle();
  hist1->GetYaxis()->CenterTitle();
  hist1->GetXaxis()->SetTitleOffset(1.25);
  hist1->GetYaxis()->SetTitleOffset(1.25);
  hist1->Draw("lego");

 
  cout << "To exit, quit ROOT from the File menu of the plot (or use control-C)" << endl;
  theApp.Run(true);
  canvas->Close();

  return 0;

}
Exemplo n.º 10
0
void PlotPhaseVelocityFunctions( const TString &opt="")
{
#ifdef __CINT__
  gSystem->Load("libplasma.so");
#endif

  PlasmaGlob::Initialize();

  // Palettes!
  gROOT->Macro("PlasmaPalettes.C");
  
  gStyle->SetPadTopMargin(0.06); 
  gStyle->SetPadGridY(0);
  gStyle->SetPadGridX(0);
  gStyle->SetFrameLineWidth(2);
  gStyle->SetLabelSize(0.04, "xyz");
  gStyle->SetTitleOffset(1.2,"y");
  gStyle->SetTitleOffset(1.2,"z");
  gStyle->SetNdivisions(505,"xyz");

  PUnits::UnitsTable::Get();
  
  // // SPS parameters from Pukhov, Kumar et al. PRL107,145003(2011)
  // Double_t n0 = 7.76e14 / PUnits::cm3;
  // Double_t nb = 1.5e12 / PUnits::cm3;
  // Double_t lambda = PFunc::PlasmaWavelength(n0);
  // Double_t kp = PFunc::PlasmaWavenumber(n0);
  // Double_t skindepth =  PFunc::PlasmaSkindepth(n0);
  // Double_t r0 = 0.19 * PUnits::mm;
  // Double_t z  = 2.5 * PUnits::m;
  // Double_t zg = -28.6 * PUnits::mm;
  // Double_t E  = 450 * PUnits::GeV;
  // Double_t gamma = E / PConst::ProtonMassE ;

  // SPS parameters from Schroeder et al. PRL107,145002(2011)
  // Double_t n0 = 1.0;
  // Double_t nb = 0.002;
  // Double_t lambda = TMath::TwoPi();
  // Double_t kp = 1.0;
  // Double_t r0 = 1.0;
  // Double_t z  = 13105;
  // Double_t E  = 450 * PUnits::GeV;
  // Double_t gamma = E / PConst::ProtonMassE ;

  // PITZ parameters
  Double_t n0 = 1.0e15 / PUnits::cm3;
  Double_t nb = 1.05e13 / PUnits::cm3;
  Double_t lambda = PFunc::PlasmaWavelength(n0);
  Double_t kp = PFunc::PlasmaWavenumber(n0);
  Double_t skindepth =  PFunc::PlasmaSkindepth(n0);
  Double_t r0 = 34.259 * PUnits::um;
  Double_t z  = 150. * PUnits::mm;
  Double_t zg = -5. * PUnits::mm;
  Double_t E  = 25 * PUnits::MeV;
  Double_t gamma = (E / PConst::ElectronMassE) + 1.0;
  Double_t vb = TMath::Sqrt(1. - (1./(gamma*gamma)));

  cout << " n0 = " << n0 * PUnits::cm3 << "  e/cc" << endl;
  cout << " Wavelength = " << PUnits::BestUnit(lambda, "Length") << endl;
  cout << " Skindepth = " << PUnits::BestUnit(skindepth, "Length") << endl;
  cout << " Wavenumber = " << kp * PUnits::mm << "  mm^-1" << endl;

  // Normalized variables
  if(!opt.Contains("units")){
    r0 *= kp;
    nb /= n0;
    n0 = 1.0;
    z *= kp;
    zg *= kp;
  }
  

  Double_t N = PFunc::Nefoldings(z,zg,r0,gamma,nb,n0);
  Double_t r1 = (TMath::Power(3.,1./4.)/TMath::Power(8.*TMath::Pi()*N,1./2.)) * TMath::Exp(N) ;
  Double_t Gamma = PFunc::PhaseGamma(z,zg,r0,gamma,nb,n0);
  Double_t vph = PFunc::PhaseVelocity(z,zg,r0,gamma,nb,n0);
  Double_t vph2 = PFunc::PhaseVelocity2(z,zg,gamma,nb,n0);

  cout << " gamma beam = " << gamma << endl;
  cout << " zeta = " << z << endl;
  cout << " zeta comov. = " << zg << endl;
  cout << " r0 = " << r0 << endl;
  cout << " n_b0/n_0 = " << nb/n0 << endl;
  cout << " nu constant = " << PFunc::Nu(r0,n0) << endl;
  cout << " Number e-foldings = " << N << endl; 
  cout << " r1 = " << r1 << endl;
  cout << " Gamma wake = " << Gamma << endl;
  cout << " Wake Phase velocity  = " << vph << endl;
  cout << " Wake Phase velocity2 = " << vph2 << endl;
  cout << " Beam phase velocity  = " << vb << endl;

  const Int_t NPAR = 5;
  Double_t par[NPAR] = {zg,r0,gamma,nb,n0};
  TF1 *fPhaseVsZ2 = new TF1("fPhaseVsZ2",PhaseVelocityVsZ2,0,z,NPAR);
  fPhaseVsZ2->SetParameters(par);  
  TF1 *fPhaseVsZ = new TF1("fPhaseVsZ",PhaseVelocityVsZ,0,z,NPAR);
  fPhaseVsZ->SetParameters(par);

  Double_t par2[NPAR] = {z,r0,gamma,nb,n0};
  TF1 *fPhaseVsZg2 = new TF1("fPhaseVsZg2",PhaseVelocityVsZg2,zg,0.,NPAR);
  fPhaseVsZg2->SetParameters(par2);
  TF1 *fPhaseVsZg = new TF1("fPhaseVsZg",PhaseVelocityVsZg,zg,0.,NPAR);
  fPhaseVsZg->SetParameters(par2);
  
  const Int_t NPAR2D = 4;
  Double_t par3[NPAR2D] = {r0,gamma,nb,n0};
  TF2 *fPhaseVsZVsZg2 = new TF2("fPhaseVsZVsZg2",PhaseVelocityVsZVsZg2,0.,z,zg,0.,NPAR2D);
  fPhaseVsZVsZg2->SetParameters(par3);
  TF2 *fPhaseVsZVsZg = new TF2("fPhaseVsZVsZg",PhaseVelocityVsZVsZg,0.,z,zg,0.,NPAR2D);
  fPhaseVsZVsZg->SetParameters(par3);
  
  char ctext[64];
  TPaveText *textZetag = new TPaveText(0.13,0.85,0.38,0.92,"NDC");
  PlasmaGlob::SetPaveTextStyle(textZetag,12); 
  textZetag->SetTextColor(kGray+3);
  if(opt.Contains("units"))
    sprintf(ctext,"#zeta_{0} = %6.2f mm", zg / PUnits::mm);
  else
    sprintf(ctext,"#zeta_{0} = %6.2f c/#omega_{p}", zg);
  textZetag->AddText(ctext);
  
  TPaveText *textZeta = new TPaveText(0.13,0.85,0.38,0.92,"NDC");
  PlasmaGlob::SetPaveTextStyle(textZeta,12); 
  textZeta->SetTextColor(kGray+3);
  if(opt.Contains("units"))
    sprintf(ctext,"z_{0} = %6.2f mm", z / PUnits::mm);
  else
    sprintf(ctext,"z_{0} = %6.2f c/#omega_{p}", z);
  textZeta->AddText(ctext);

  // Graph for de-phasing:
  const Int_t NP = 100;
  TGraph *gPhase = new TGraph(NP);
  TGraph *gPhase2 = new TGraph(NP);
  Float_t phase  = zg;
  Float_t phase2 = zg;
  Float_t Dz = z / NP;
  for(Int_t i=0;i<NP;i++) {
    Float_t zp = (i+1)*Dz;
    Float_t v = PFunc::PhaseVelocity(zp,phase,r0,gamma,nb,n0);
    phase += (v - vb) * Dz;
    // cout << " z = " << zp << "  phase = " << phase << endl;
    if(opt.Contains("units"))
      gPhase->SetPoint(i,zp,(phase-zg)*kp);
    else
      gPhase->SetPoint(i,zp,(phase-zg));

    v = PFunc::PhaseVelocity2(zp,phase2,gamma,nb,n0);
    phase2 += (v - 1) * Dz;
    // cout << " z = " << zp << "  phase = " << phase << endl;
    if(opt.Contains("units"))
      gPhase2->SetPoint(i,zp,(phase2-zg)*kp);
    else
      gPhase2->SetPoint(i,zp,(phase2-zg));
  }
  
  TCanvas *C = new TCanvas("C","Wake phase velocity",1000,750);
  C->Divide(2,2);

  TLegend *Leg = new TLegend(0.6,0.20,0.85,0.35);
  PlasmaGlob::SetPaveStyle(Leg);
  Leg->SetTextAlign(22);
  Leg->SetTextColor(kGray+3);
  Leg->SetLineColor(1);
  Leg->SetBorderSize(1);
  Leg->SetFillColor(0);
  Leg->SetFillStyle(1001);
  //Leg-> SetNColumns(2);
  Leg->AddEntry(fPhaseVsZ,"PRL 107,145002","L");
  Leg->AddEntry(fPhaseVsZ2,"PRL 107,145003","L");
  Leg->SetTextColor(kGray+3);
  

  C->cd(1);
  fPhaseVsZ->GetYaxis()->SetTitle("(v_{p} - c)/c");
  if(opt.Contains("units")) 
    fPhaseVsZ->GetXaxis()->SetTitle("z [m]"); 
  else
    fPhaseVsZ->GetXaxis()->SetTitle("z [c/#omega_{p}]"); 
  fPhaseVsZ->GetYaxis()->SetRangeUser(-3e-4,0.);
  fPhaseVsZ->GetXaxis()->CenterTitle();
  fPhaseVsZ->GetYaxis()->CenterTitle();
  fPhaseVsZ->SetLineWidth(2);
  fPhaseVsZ->Draw("C");
  fPhaseVsZ2->SetLineWidth(2);
  fPhaseVsZ2->SetLineStyle(2);
  fPhaseVsZ2->Draw("C same");
  textZetag->Draw();
  Leg->Draw();

  C->cd(2);
  fPhaseVsZg->GetYaxis()->SetTitle("(v_{p} - c)/c");
  if(opt.Contains("units"))
    fPhaseVsZg->GetXaxis()->SetTitle("#zeta [m]"); 
  else
    fPhaseVsZg->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); 
  fPhaseVsZg->GetYaxis()->SetRangeUser(-3e-4,0.);
  fPhaseVsZg->GetYaxis()->SetNdivisions(505);
  fPhaseVsZg->GetXaxis()->CenterTitle();
  fPhaseVsZg->SetLineWidth(2);
  fPhaseVsZg->GetYaxis()->CenterTitle();
  fPhaseVsZg->Draw("C");
  fPhaseVsZg2->SetLineWidth(2);
  fPhaseVsZg2->SetLineStyle(2);
  fPhaseVsZg2->Draw("C same");
  textZeta->Draw();
  
  C->cd(3);
  gPhase->GetYaxis()->SetTitle("#Delta#zeta [c/#omega_{p}]");
  
  if(opt.Contains("units")) {
    gPhase->GetXaxis()->SetTitle("z [m]"); 
    gPhase->GetXaxis()->SetNdivisions(510);
  } else
    gPhase->GetXaxis()->SetTitle("z [c/#omega_{p}]"); 
 
  
  // gPhase->GetXaxis()->SetNdivisions(510);
  gPhase->GetXaxis()->CenterTitle();
  gPhase->GetYaxis()->CenterTitle();
  gPhase->GetXaxis()->SetRangeUser(0.,z);
  gPhase->GetYaxis()->SetNdivisions(505);  
  gPhase->SetLineWidth(2);
  gPhase->Draw("AC");
  gPhase2->SetLineStyle(2);
  gPhase2->SetLineWidth(2);
  gPhase2->Draw("C");
  textZetag->Draw();

  C->cd(4);
  gPad->SetLeftMargin(0.18);

  if(opt.Contains("units")) {
    fPhaseVsZVsZg->GetYaxis()->SetTitle("#zeta [m]"); 
  } else
    fPhaseVsZVsZg->GetYaxis()->SetTitle("#zeta [c/#omega_{p}]"); 
  
  if(opt.Contains("units")) {
    fPhaseVsZVsZg->GetXaxis()->SetTitle("z [m]"); 
  } else
    fPhaseVsZVsZg->GetXaxis()->SetTitle("z [c/#omega_{p}]"); 
  
  fPhaseVsZVsZg->GetZaxis()->SetTitle("(v_{p} - c)/c"); 

  fPhaseVsZVsZg->GetYaxis()->SetNdivisions(505);
  // fPhaseVsZVsZg->GetXaxis()->SetNdivisions(510);
  fPhaseVsZVsZg->GetXaxis()->CenterTitle();
  fPhaseVsZVsZg->GetXaxis()->SetTitleOffset(1.6);
  fPhaseVsZVsZg->GetYaxis()->CenterTitle();
  fPhaseVsZVsZg->GetYaxis()->SetTitleOffset(2.0); 
  fPhaseVsZVsZg->GetZaxis()->CenterTitle();
  fPhaseVsZVsZg->GetZaxis()->SetTitleOffset(1.4); 
  
  fPhaseVsZVsZg->Draw("surf2");

  C->cd();

  // Print to a file
  PlasmaGlob::imgconv(C,"./WakePhaseVelocity",opt);
  // ---------------------------------------------------------

}
Exemplo n.º 11
0
void annotation3d()
{
   TCanvas *c = new TCanvas("c", "c", 600, 600);
   c->SetTheta(30);
   c->SetPhi(50);
   gStyle->SetOptStat(0);
   gStyle->SetHistTopMargin(0);
   gStyle->SetOptTitle(kFALSE);

   // Define and draw a surface
   TF2 *f = new TF2("f", "[0]*cos(x)*cos(y)", -1, 1, -1, 1);
   f->SetParameter(0, 1);
   double s = 1./f->Integral(-1, 1, -1, 1);
   f->SetParameter(0, s);
   f->SetNpx(50);
   f->SetNpy(50);

   f->GetXaxis()->SetTitle("x");
   f->GetXaxis()->SetTitleOffset(1.4);
   f->GetXaxis()->SetTitleSize(0.04);
   f->GetXaxis()->CenterTitle();
   f->GetXaxis()->SetNdivisions(505);
   f->GetXaxis()->SetTitleOffset(1.3);
   f->GetXaxis()->SetLabelSize(0.03);
   f->GetXaxis()->ChangeLabel(2,-1,-1,-1,kRed,-1,"X_{0}");

   f->GetYaxis()->SetTitle("y");
   f->GetYaxis()->CenterTitle();
   f->GetYaxis()->SetTitleOffset(1.4);
   f->GetYaxis()->SetTitleSize(0.04);
   f->GetYaxis()->SetTitleOffset(1.3);
   f->GetYaxis()->SetNdivisions(505);
   f->GetYaxis()->SetLabelSize(0.03);

   f->GetZaxis()->SetTitle("dP/dx");
   f->GetZaxis()->CenterTitle();
   f->GetZaxis()->SetTitleOffset(1.3);
   f->GetZaxis()->SetNdivisions(505);
   f->GetZaxis()->SetTitleSize(0.04);
   f->GetZaxis()->SetLabelSize(0.03);

   f->SetLineWidth(1);
   f->SetLineColorAlpha(kAzure-2, 0.3);

   f->Draw("surf1 fb");

   // Lines for 3D annotation
   double x[11] = {-0.500, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.500};
   double y[11] = {-0.985, -0.8, -0.6, -0.4, -0.2,  0.0,  0.2,  0.4,  0.6,  0.8,  0.985};
   double z[11];
   for (int i = 0; i < 11; ++i) z[i] = s*cos(x[i])*cos(y[i]);
   TPolyLine3D *g2 = new TPolyLine3D(11, x, y, z);

   double xx[2] = {-0.5, -0.5};
   double yy[2] = {-0.985, -0.985};
   double zz[2] = {0.11, s*cos(-0.5)*cos(-0.985)};
   TPolyLine3D *l2 = new TPolyLine3D(2, xx, yy, zz);

   g2->SetLineColor(kRed);
   g2->SetLineWidth(3);
   g2->Draw();

   l2->SetLineColor(kRed);
   l2->SetLineStyle(2);
   l2->SetLineWidth(1);
   l2->Draw();

   // Draw text Annotations
   TLatex *txt = new TLatex(0.05, 0, "f(y,x_{0})");
   txt->SetTextFont(42);
   txt->SetTextColor(kRed);
   txt->Draw();

   TLatex *txt1 = new TLatex(0.12, 0.52, "f(x,y)");
   txt1->SetTextColor(kBlue);
   txt1->SetTextFont(42);
   txt1->Draw();
}
Exemplo n.º 12
0
void
plot2DSignalHisto(
    TString filename1,
    TString filename2, 
    TString histogramName,
//    TString drawopts = "",
    TString xtitle = "x",
    TString ytitle = "y",
    double xtitleOffset = 1.1,
    double ytitleOffset = 1.3
    )
{
// {{{
    InitgStyle();
    //gStyle->SetOptStat(0);
    //gCanvas = new TCanvas("gCanvas", "gCanvas", 0, 0, 800, 600);
    
    TFile *outputFile = new TFile("FitErgebnisse.root","RECREATE");
    TH2D *histogram__DiffAbs = new TH2D("histogram__DiffAbs","Differenz Fit - Input (Absolut)", 5, -1, 1, 5, -1, 1);
    TH2D *histogram__DiffRel = new TH2D("histogram__DiffRel","Differenz Fit - Input (Relativ)", 5, -1, 1, 5, -1, 1);
    TH2D *histogram__FitResult = new TH2D("histogram__FitResult ", "Ergebnis-Histogramm des Fits", 5, -1, 1, 5, -1, 1);


    
//    LoadHistogramTH2D(histogramName , filename1, 1.0, histogram);// Summe (SM)
    LoadHistogramTH2D("histogram__Correlation"+histogramName , filename1, 1.0, histogram);// Summe (SM

    //LoadHistogramTH2D(histogramName+"_LL" , filename2, 1.0, histo1);	// LL
    //LoadHistogramTH2D(histogramName+"_LR" , filename2, 1.0, histo2);	// LR
    //LoadHistogramTH2D(histogramName+"_RL" , filename2, 1.0, histo3);	// RL
    //LoadHistogramTH2D(histogramName+"_RR" , filename2, 1.0, histo4);	// RR
    
    //LoadHistogramTH2D("histogram__gen_N" , filename2, 1.0, histo1);
    //LoadHistogramTH2D("histogram__gen_A" , filename2, 1.0, histo2);
    
    LoadHistogramTH2D("histogram__N"+histogramName , filename2, 1.0, histo1);
    LoadHistogramTH2D("histogram__A"+histogramName , filename2, 1.0, histo2);


    //gCanvas->Clear();
  

    histogram->GetXaxis()->SetTitle(xtitle);
    histogram->GetXaxis()->SetTitleOffset(xtitleOffset);
    histogram->GetYaxis()->SetTitle(ytitle);
    histogram->GetYaxis()->SetTitleOffset(ytitleOffset);
    //histogram->GetZaxis()->SetTitle("d^{2}#sigma / dM_{#bar{t}}dM_{t} [pb]");
    //histogram->GetZaxis()->SetTitleOffset(ytitleOffset);

//    gCanvas->Update();

    /*    
    histo1->Scale(1.0/histo4->Integral());
    histo2->Scale(1.0/histo4->Integral());
    histo3->Scale(1.0/histo4->Integral());
    histo4->Scale(1.0/histo4->Integral());
    */

       
    //faktor = 1.0;
    faktor=Double_t(histogram->Integral())/Double_t(histo1->Integral());
    cout<<faktor<<endl; 
    
    TF2 *fitFunction = new TF2("fitFunction", HistoSum, -1, 1, -1, 1, 2);  //allgemeine "return"-Varianten
    //fitFunction->SetParameters(0.9,0.,0.);
    //fitFunction->SetLineColor(kRed);
    
    histogram->Fit(fitFunction, "N");
    fitFunction->SetNpx(5);
    fitFunction->SetNpy(5);
    
    double p0 = fitFunction->GetParameter(0);
    double p1 = fitFunction->GetParameter(1);
//    double p2 = fitFunction->GetParameter(2);
//    double p3 = fitFunction->GetParameter(3);

    for(int i =1; i <= 5; i++)
    {
        for(int j = 1; j <= 5; j++)
        {
            //double sigmaLL = p0*faktor*histo1->GetBinError(i,j);
            //double sigmaLR = p1*faktor*histo2->GetBinError(i,j);
            //double sigmaRL = p2*faktor*histo3->GetBinError(i,j);
            //double sigmaRR = p3*faktor*histo4->GetBinError(i,j);
            double sigmaN = p0*faktor*histo1->GetBinError(i,j);
            double sigmaA = p1*faktor*histo2->GetBinError(i,j);
            //histogram->SetBinError(i,j, sqrt( histogram->GetBinContent(i,j) + pow(sigmaLL,2) + pow(sigmaRR,2) + pow(sigmaRL,2) + pow(sigmaLR, 2) ));
            histogram->SetBinError(i,j, sqrt( histogram->GetBinContent(i,j) + pow(sigmaN,2) + pow(sigmaA,2) ));
        }
    }
    histogram->Fit(fitFunction, "NE");

    p0 = fitFunction->GetParameter(0);
    p1 = fitFunction->GetParameter(1);

    for(int i =1; i <= 5; i++)
    {
        for(int j = 1; j <= 5; j++)
        {
            //double sigmaLL = p0*faktor*histo1->GetBinError(i,j);
            //double sigmaLR = p1*faktor*histo2->GetBinError(i,j);
            //double sigmaRL = p2*faktor*histo3->GetBinError(i,j);
            //double sigmaRR = p3*faktor*histo4->GetBinError(i,j);
            double sigmaN = p0*faktor*histo1->GetBinError(i,j);
            double sigmaA = p1*faktor*histo2->GetBinError(i,j);
            //histogram->SetBinError(i,j, sqrt( histogram->GetBinContent(i,j) + pow(sigmaLL,2) + pow(sigmaRR,2) + pow(sigmaRL,2) + pow(sigmaLR, 2) ));
            histogram->SetBinError(i,j, sqrt( histogram->GetBinContent(i,j) + pow(sigmaN,2) + pow(sigmaA,2) ));
        }
    }
    histogram->Fit(fitFunction, "NE");

        
    //histogram->Draw("lego1");  
    //fitFunction->Draw("lego");
    cout << fitFunction->GetChisquare()/fitFunction->GetNDF() << endl;

    for(int i = 1; i <= 5; i++)
    {
        for(int j = 1; j <= 5; j++)
        {
            histogram__DiffAbs->SetBinContent(i,j, fitFunction->Eval(histogram->GetXaxis()->GetBinCenter(i),histogram->GetYaxis()->GetBinCenter(j))-histogram->GetBinContent(i,j) );
            histogram__DiffRel->SetBinContent(i,j, (fitFunction->Eval(histogram->GetXaxis()->GetBinCenter(i),histogram->GetYaxis()->GetBinCenter(j))-histogram->GetBinContent(i,j))/histogram->GetBinContent(i,j) );
            histogram__FitResult->SetBinContent(i,j, fitFunction->Eval(histogram->GetXaxis()->GetBinCenter(i),histogram->GetYaxis()->GetBinCenter(j)));
        }
    }
    
        
    outputFile->cd("");
    histogram__DiffAbs->Write("histogram__DiffAbs");
    histogram__DiffRel->Write("histogram__DiffRel");
    histogram__FitResult->Write("histogram__FitResult");
    outputFile->Close();
    delete outputFile;
       
    
    //gCanvas->Print(epsFilename(filename, histogramName)+".eps");
	//cout << histogram[0]->Integral() << endl;
// }}}
};
void PrintVertexRosenbrock()
{
	// open file

	std::ifstream data ("Vertex.txt", std::ios::in);
	
	double buf;
	std::vector<double> x1;
	std::vector<double> x2;
	std::vector<double> x3;
	std::vector<double> y1;
	std::vector<double> y2;
	std::vector<double> y3;

	// loop on file
	while (1)
	{
		data >> buf;
		if (data.eof())
		{break;}
		x1.push_back(buf);
		data >> buf;
		y1.push_back(buf);
		data >> buf;
		x2.push_back(buf);
		data >> buf;
		y2.push_back(buf);
		data >> buf;
		x3.push_back(buf);
		data >> buf;
		y3.push_back(buf);	
	}

	// functions
	//TF2* f = new TF2 ("himmelblau", "(x*x + y - 11)*(x*x + y - 11) + (x + y*y - 7)*(x + y*y - 7)", 0, 10, 0, 10); // himmelblau
	gStyle->SetOptTitle(0);	
	TF2* f = new TF2 ("rosenbrock", "100*(y-x*x)*(y-x*x) + (1-x)*(1-x)", -1.5, 2.2, -0.5, 2.2); // rosenbrock
 	f->SetNpx(1000);
	f->SetNpy(1000);
	f->GetXaxis()->SetTitle("x");
	f->GetYaxis()->SetTitle("y");
	TCanvas* c1 = new TCanvas;
	c1->SetLogz();	
	rosenbrock->Draw("COLZ");

	
	// loop on vertex
	std::vector<TLine*> vl1;
	std::vector<TLine*> vl2;
	std::vector<TLine*> vl3;
	TLine* l1;
	TLine* l2;
	TLine* l3;	
	for (int i = 0; i < x1.size(); i++)
	{
		l1 = new TLine(0,0,0,0);
		l2 = new TLine(0,0,0,0);
		l3 = new TLine(0,0,0,0);	
		
		l1->SetLineWidth(1.5);
		l2->SetLineWidth(1.5);
		l3->SetLineWidth(1.5);

		l1->SetLineColor(kBlue -10 + i);
		l2->SetLineColor(kBlue -10 + i);
		l3->SetLineColor(kBlue -10 + i);

		l1->SetX1(x1.at(i));
		l1->SetY1(y1.at(i));
		l1->SetX2(x2.at(i));
		l1->SetY2(y2.at(i));

		l2->SetX1(x2.at(i));
		l2->SetY1(y2.at(i));
		l2->SetX2(x3.at(i));
		l2->SetY2(y3.at(i));

		l3->SetX1(x3.at(i));
		l3->SetY1(y3.at(i));
		l3->SetX2(x1.at(i));
		l3->SetY2(y1.at(i));

		l1->Draw("same");
		l2->Draw("same");
		l3->Draw("same");
	}

	TMarker* min = new TMarker (1,1,0);
	min ->SetMarkerColor (kBlue);
	min->SetMarkerStyle(20);
	min->SetMarkerSize (1.0);
	min->Draw();

}
Exemplo n.º 14
0
void FitXS (int nminx = 0, int nmaxx = 1509, int nmintest = 0, int nmaxtest = 1509) {
    ////////////////////////////////////////////////////
    // ftp://root.cern.ch/root/doc/ROOTUsersGuideHTML/ch09s05.html
    TStyle *defaultStyle = new TStyle("defaultStyle","Default Style");
    //gStyle->SetOptStat(0);
    //  defaultStyle->SetOptStat(0000);
    //  defaultStyle->SetOptFit(000); 
    //  defaultStyle->SetPalette(1);
    ////////////////////////
    defaultStyle->SetOptStat(0); // remove info box
    /////// pad ////////////
    defaultStyle->SetPadBorderMode(0);
    defaultStyle->SetPadBorderSize(3);
    defaultStyle->SetPadColor(0);
    defaultStyle->SetPadTopMargin(0.1);
    defaultStyle->SetPadBottomMargin(0.16);
    defaultStyle->SetPadRightMargin(5.5);
    defaultStyle->SetPadLeftMargin(0.18);
    /////// canvas /////////
    defaultStyle->SetCanvasBorderMode(1);
    defaultStyle->SetCanvasColor(0);
    //  defaultStyle->SetCanvasDefH(600);
    //  defaultStyle->SetCanvasDefW(600);
    /////// frame //////////
    //defaultStyle->SetFrameBorderMode(1);
    //defaultStyle->SetFrameBorderSize(1);
    defaultStyle->SetFrameFillColor(0); 
    defaultStyle->SetFrameLineColor(1);
    /////// label //////////
    //  defaultStyle->SetLabelOffset(0.005,"XY");
    //  defaultStyle->SetLabelSize(0.05,"XY");
    //defaultStyle->SetLabelFont(46,"XY");
    /////// title //////////
    //defaultStyle->SetTitleW(0.6);
    defaultStyle->SetTitleSize(0.08, "XYZ");
    defaultStyle->SetTitleBorderSize(0);
    defaultStyle->SetTitleX(0.2);
    //  defaultStyle->SetTitleOffset(1.1,"X");
    //  defaultStyle->SetTitleSize(0.01,"X");
    //  defaultStyle->SetTitleOffset(1.25,"Y");
    //  defaultStyle->SetTitleSize(0.05,"Y");
    //defaultStyle->SetTitleFont(42, "XYZ");
    /////// various ////////
    defaultStyle->SetNdivisions(303,"Y");
    defaultStyle->SetTitleFillColor(0);//SetTitleFillStyle(0, "Z");
    //defaultStyle->SetTitleX(0.2);
    //defaultStyle->SetTitleY(0.1);
    //defaultStyle->SetTitleBorderSize(-0.1);  // For the axis titles:
    
    //    defaultStyle->SetTitleColor(1, "XYZ");
    //    defaultStyle->SetTitleFont(42, "XYZ");
    
    
    // defaultStyle->SetTitleYSize(0.08);
    //defaultStyle->SetTitleXOffset(0.9);
    //defaultStyle->SetTitleYOffset(1.05);
    defaultStyle->SetTitleOffset(1.3, "Y"); // Another way to set the Offset
    //defaultStyle->SetTitleOffset(1.0, "X"); // Another way to set the Offset    
    // For the axis labels:
    defaultStyle->SetLabelColor(1, "XYZ");
    //defaultStyle->SetLabelFont(46, "XYZ");
    defaultStyle->SetLabelOffset(0.03, "XYZ");
    defaultStyle->SetLabelSize(0.07, "XYZ");
    //defaultStyle->SetLabelY(0.06);    
    // For the axis:
    //    defaultStyle->SetAxisColor(1, "XYZ");
    defaultStyle->SetStripDecimals(kTRUE);
    defaultStyle->SetTickLength(0.03, "XYZ");
    defaultStyle->SetNdivisions(7, "XYZ");
    //    defaultStyle->SetPadTickX(1);   // To get tick marks on the opposite side of the frame
    //    defaultStyle->SetPadTickY(1);
    defaultStyle->cd();

    ///////////////////////////////////////////

  nmin=nminx;
  nmax=nmaxx;
  if (nmin<0) nmin=0;
  if (nmax>Npoints) nmax=Npoints;
  // Read in the cross section values and the parameters space points
  ifstream XSvals;
    XSvals.open("list_all_translation_CX.txt");//"14TeV_CX_5k_opositecgw.ascii");// "8TeV_CX_5k_opositecgw.ascii");//
  for (int i=nmin; i<nmax; i++)  {
    XSvals >> par0[i] >> par1[i] >> par2[i] >> par3[i] >> par4[i] >> cross_section[i] >> cross_sectionerr[i];
    cout << "For point i = " << i << "pars are " << par0[i] << " " << par1[i] << " " << par2[i] 
    	 << " " << par3[i] << " " << par4[i] << " and xs is " << cross_section[i] << endl;
  }
  
  cout << "**********************************************" << endl;
  
  // Likelihood maximization
  // -----------------------  
  // Minuit routine
  TMinuit rmin(2);
  rmin.SetFCN(Likelihood);
  // Main initialization member function for MINUIT
  rmin.mninit(5,6,7);
  // Parameters needed to be unambiguous with MINOS
  int iflag=0; // You can use this for selection
  double arglis[4];
  //arglis[0]=2;
  arglis[0]=1;
  // Sets the strategy to be used in calculating first and second derivatives 
  // and in certain minimization methods. 1 is default
  rmin.mnexcm("SET STR", arglis, 1, iflag);
  // Set fit parameters
  
  double Start[15];//  ={ 0.030642286182762914, 0.1502216514258229, 0.004287943879883482, 0.0016389029559123376, 0.01930407853512356, -0.12540818099961384, -0.02048425705808435,  0.04246248185144494, 0.02590360491719489,  -0.05255851386689693,  -0.010393610828707423,  0.02770339496466713,  0.005468667874225809,  -0.011297300064522649,  -0.02261561923548796}; // cx in pb
  //  double Start[15] = {2.2646, 1.102, 0.316898, 16, 192, -3, -1, 1, 7, 15, -8, -23, 4, 9, 200}; // normalized to SM
  double Step[15];// ={ 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01 }; //={0.01};
  double Min[15]; // ={-3.1415926};
  double Max[15]; // = {3.1415926}; 
  for (int i=0; i<15; i++) {
    Start[i]=1.;
    Step[i]=1;
    Min[i]=-100000;
    Max[i]=+100000;
  }
  TString parnamEj[15]={"A1","A2","A3","A4","A5","A6","A7","A8","A9","A10","A11","A12","A13","A14","A15"};
  for (int i=0; i<15; i++) {
    rmin.mnparm(i, parnamEj[i],  Start[i], Step[i], Min[i], Max[i], iflag);
  }
  // Instructs Minuit to call subroutine FCN with the value of IFLAG
  rmin.mnexcm("call fcn", arglis, 1, iflag); // command executed normally
  // Causes minimization of the function by the method of Migrad
  rmin.mnexcm("mini", arglis, 0, iflag);
  // Read results
  double a[15], err[15], pmin, pmax;
  int ivar;
  for (int i=0; i<15; i++) {
    rmin.mnpout (i, parnamEj[i], a[i], err[i], pmin, pmax, ivar);
  }

  // End of program
  // --------------
  gROOT->Time();
    cout<<endl<<" Making plots "<<endl;
    cout<<"$A_1$ = "<<a[0]<<" $\\pm$ "<<err[0]<<" & $A_4$ = "<<a[3]<<" $\\pm$ "<<err[3]<<" & $A_7$ = "<<a[6]<<" $\\pm$ "<<err[6]<<" & $A_{10}$ = "<<a[9]<<" $\\pm$ "<<err[9]<<" & $A_{13}$ = "<<a[12]<<" $\\pm$ "<<err[12]<< " \\\ "<<endl;
    cout<<"$A_2$ = "<<a[1]<<" $\\pm$ "<<err[1]<<" & $A_5$ = "<<a[4]<<" $\\pm$ "<<err[4]<<" & $A_8$ = "<<a[7]<<" $\\pm$ "<<err[7]<<" & $A_{11}$ = "<<a[10]<<" $\\pm$ "<<err[10]<<" & $A_{14}$ = "<<a[13]<<" $\\pm$ "<<err[13]<< " \\\ "<<endl;
    cout<<"$A_3$ = "<<a[2]<<" $\\pm$ "<<err[2]<<" & $A_6$ = "<<a[5]<<" $\\pm$ "<<err[5]<<" & $A_9$ = "<<a[8]<<" $\\pm$ "<<err[8]<<" & $A_{12}$ = "<<a[11]<<" $\\pm$ "<<err[11]<<" & $A_{15}$ = "<<a[14]<<" $\\pm$ "<<err[14]<< " \\\ "<<endl;
    cout<<endl<<" To mathematica: "<<endl;
    cout<<"{"<<a[0]<<","<<a[1]<<","<<a[2]<<","<<a[3]<<","<<a[4]<<","<<a[5]<<","<<a[6]<<","<<a[7]<<","<<a[8]<<","<<a[9]<<","<<a[10]<<","<<a[11]<<","<<a[12]<<","<<a[13]<<","<<a[14]<<"}"<<endl;
    cout<<endl<<" To mathematica (errors): "<<endl;
    cout<<"{"<<err[0]<<","<<err[1]<<","<<err[2]<<","<<err[3]<<","<<err[4]<<","<<err[5]<<","<<err[6]<<","<<err[7]<<","<<err[8]<<","<<err[9]<<","<<err[10]<<","<<err[11]<<","<<err[12]<<","<<err[13]<<","<<err[14]<<"}"<<endl;
    
    /////////////////
    // plot the CX 
    ////////////////
    // plane b
    double norm =  1; //0.013531;// 0.0041758;//1;//  8tev 13 tev  1;// 
    double kt5d=1.0;
    double kl5d=1.0;
    double c25d=0.0;
    double mincg = -2.99, maxcg=2.99;
    // cg ===> x 
    // c2g ===> y
    TF2 *fg2 = new TF2("fg2","(([0]*[15]**4 + [1]*[17]**2 + [2]*[15]**2*[16]**2 + [3]*x**2*[16]**2 +  [4]*y**2 + [5]*[17]*[15]**2 + [6]*[15]*[16]*[15]**2 + [7]*[15]*[16]*[17] + [8]*x*[16]*[17] + [9]*[17]*y + [10]*x*[16]*[15]**2 + [11]*y*[15]**2 + [12]*[16]*x*[15]*[16] + [13]*y*[15]*[16] + [14]*x*y*[16])/[18])",mincg,maxcg,mincg,maxcg);
    fg2->SetParameter(0,a[0]);
    fg2->SetParameter(1,a[1]);
    fg2->SetParameter(2,a[2]);    
    fg2->SetParameter(3,a[3]);
    fg2->SetParameter(4,a[4]);
    fg2->SetParameter(5,a[5]); 
    fg2->SetParameter(6,a[6]);
    fg2->SetParameter(7,a[7]);
    fg2->SetParameter(8,a[8]); 
    fg2->SetParameter(9,a[9]);
    fg2->SetParameter(10,a[10]);
    fg2->SetParameter(11,a[11]); 
    fg2->SetParameter(12,a[12]);    
    fg2->SetParameter(13,a[13]);
    fg2->SetParameter(14,a[14]);
    fg2->SetTitle("kt = #kappa_{#lambda} = 1 , c_{2} = 0 ; c_{g} ; c_{2g}");
    fg2->SetParameter(15,kt5d);    
    fg2->SetParameter(16,kl5d);
    fg2->SetParameter(17,c25d);
    fg2->SetParameter(18,norm); //0.013531
    //fg2->SetMinimum(0);
    fg2->SetContour(100);
    // 
    ////////////////////////////////
    kt5d=1.0;
    kl5d=10.0;
    c25d=0.0;
    // cg ===> x 
    // c2g ===> y
    TF2 *fg10 = new TF2("fg10","([0]*[15]**4 + [1]*[17]**2 + [2]*[15]**2*[16]**2 + [3]*x**2*[16]**2 +  [4]*y**2 + [5]*[17]*[15]**2 + [6]*[15]*[16]*[15]**2 + [7]*[15]*[16]*[17] + [8]*x*[16]*[17] + [9]*[17]*y + [10]*x*[16]*[15]**2 + [11]*y*[15]**2 + [12]*[16]*x*[15]*[16] + [13]*y*[15]*[16] + [14]*x*y*[16])/[18]",mincg,maxcg,mincg,maxcg);
    fg10->SetParameter(0,a[0]);
    fg10->SetParameter(1,a[1]);
    fg10->SetParameter(2,a[2]);    
    fg10->SetParameter(3,a[3]);
    fg10->SetParameter(4,a[4]);
    fg10->SetParameter(5,a[5]); 
    fg10->SetParameter(6,a[6]);
    fg10->SetParameter(7,a[7]);
    fg10->SetParameter(8,a[8]); 
    fg10->SetParameter(9,a[9]);
    fg10->SetParameter(10,a[10]);
    fg10->SetParameter(11,a[11]); 
    fg10->SetParameter(12,a[12]);    
    fg10->SetParameter(13,a[13]);
    fg10->SetParameter(14,a[14]);
    fg10->SetTitle("");
    fg10->SetParameter(15,kt5d);    
    fg10->SetParameter(16,kl5d);
    fg10->SetParameter(17,c25d);
    fg10->SetParameter(18,norm);// 0.013531
    fg10->SetMinimum(0);
    ////////////////////////////////
    kt5d=1.0;
    kl5d=-10.0;
    c25d=0.0;
    // cg ===> x 
    // c2g ===> y
    TF2 *fgm10 = new TF2("fgm10","([0]*[15]**4 + [1]*[17]**2 + [2]*[15]**2*[16]**2 + [3]*x**2*[16]**2 +  [4]*y**2 + [5]*[17]*[15]**2 + [6]*[15]*[16]*[15]**2 + [7]*[15]*[16]*[17] + [8]*x*[16]*[17] + [9]*[17]*y + [10]*x*[16]*[15]**2 + [11]*y*[15]**2 + [12]*[16]*x*[15]*[16] + [13]*y*[15]*[16] + [14]*x*y*[16])/[18]",mincg,maxcg,mincg,maxcg);
    fgm10->SetParameter(0,a[0]);
    fgm10->SetParameter(1,a[1]);
    fgm10->SetParameter(2,a[2]);    
    fgm10->SetParameter(3,a[3]);
    fgm10->SetParameter(4,a[4]);
    fgm10->SetParameter(5,a[5]); 
    fgm10->SetParameter(6,a[6]);
    fgm10->SetParameter(7,a[7]);
    fgm10->SetParameter(8,a[8]); 
    fgm10->SetParameter(9,a[9]);
    fgm10->SetParameter(10,a[10]);
    fgm10->SetParameter(11,a[11]); 
    fgm10->SetParameter(12,a[12]);    
    fgm10->SetParameter(13,a[13]);
    fgm10->SetParameter(14,a[14]);
    fgm10->SetTitle("");
    fgm10->SetParameter(15,kt5d);    
    fgm10->SetParameter(16,kl5d);
    fgm10->SetParameter(17,c25d);
    fgm10->SetParameter(18,norm);//0.013531
    fgm10->SetMinimum(0);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb"<<a[0]<<endl;
    cout<<"teste funcao cg , c2g : 0,0 "<< fg2->Eval(0,0)<<endl;
    cout<<"teste funcao cg , c2g : -1,1  "<<  fg2->Eval(-1,1)<<endl;
    cout<<"teste funcao cg , c2g : 1,-1  "<<  fg2->Eval(-1,1)<<endl;
    cout<<" "<<endl;
    ////////////////////////////////////////////////////
    double cg=0.0;
    double c2g=0.0;
    c25d=0.0;
    // cg ===> x  ===> kl
    // c2g ===> y ===> kt
    TF2 *SM0 = new TF2("SM0","(([0]*y**4 + [1]*[17]**2 + [2]*y**2*x**2 + [3]*[15]**2*x**2 +  [4]*[15]**2 + [5]*[17]*y**2 + [6]*y*x*y**2 + [7]*[15]*x*[17] + [8]*[16]*x*[17] + [9]*[17]*y + [10]*[16]*x*[15]**2 + [11]*[16]*y**2 + [12]*x*[16]*[15]*x + [13]*[15]*[15]*x + [14]*[16]*[15])/[18])+[19]",-15,15,0.5,2.5);
    SM0->SetParameter(0,a[0]);
    SM0->SetParameter(1,a[1]);
    SM0->SetParameter(2,a[2]);    
    SM0->SetParameter(3,a[3]);
    SM0->SetParameter(4,a[4]);
    SM0->SetParameter(5,a[5]); 
    SM0->SetParameter(6,a[6]);
    SM0->SetParameter(7,a[7]);
    SM0->SetParameter(8,a[8]); 
    SM0->SetParameter(9,a[9]);
    SM0->SetParameter(10,a[10]);
    SM0->SetParameter(11,a[11]); 
    SM0->SetParameter(12,a[12]);    
    SM0->SetParameter(13,a[13]);
    SM0->SetParameter(14,a[14]);
    SM0->SetParameter(15,cg); //==>y     
    SM0->SetParameter(16,c2g);//==>x
    SM0->SetParameter(17,c25d);
    SM0->SetParameter(18,norm);// 0.013531
    SM0->SetParameter(19,0.0001);// 0.013531
    SM0->SetTitle("c_{2} = c_{2g} = c_{g} = 0 ; #kappa_{#lambda} ; #kappa_{t}");
    //SM0->SetMinimum(0);
    SM0->SetContour(200);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb "<<endl;
    cout<<"teste funcao kl , kt : 1,1 "<< SM0->Eval(1,1)<<endl;
    cout<<"teste funcao kl , kt : -10, 1  "<<  SM0->Eval(-10,1)<<endl;
    cout<<"teste funcao kl , kt : 10, 1  "<<  SM0->Eval(10,1)<<endl;
    ////////////////////////////////
    kt5d=1.0;
    kl5d=1.0;
    c25d=0.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt
    TF2 *l1 = new TF2("l1","([0]*y**4 + [1]*x**2 + [2]*y**2*[16]**2 + [3]*[17]**2*[16]**2 +  [4]*[15]**2 + [5]*x*y**2 + [6]*y*[16]*y**2 + [7]*y*[16]*x + [8]*[17]*[16]*x + [9]*x*[15] + [10]*[17]*[16]*y**2 + [11]*[15]*y**2 + [12]*[16]*[17]*y*[16] + [13]*[15]*y*[16] + [14]*[17]*[15]*[16])/[18]",-4,4,0.5,2.5);
    l1->SetParameter(0,a[0]);
    l1->SetParameter(1,a[1]);
    l1->SetParameter(2,a[2]);    
    l1->SetParameter(3,a[3]);
    l1->SetParameter(4,a[4]);
    l1->SetParameter(5,a[5]); 
    l1->SetParameter(6,a[6]);
    l1->SetParameter(7,a[7]);
    l1->SetParameter(8,a[8]); 
    l1->SetParameter(9,a[9]);
    l1->SetParameter(10,a[10]);
    l1->SetParameter(11,a[11]); 
    l1->SetParameter(12,a[12]);    
    l1->SetParameter(13,a[13]);
    l1->SetParameter(14,a[14]);
    l1->SetTitle("#kappa_{#lambda} =1 , c_{2g} = c_{g} = 0 ; c_{2} ; #kappa_{t}");
    l1->SetParameter(15,c2g); //==> c2g
    l1->SetParameter(16,kl5d);
    l1->SetParameter(17,cg); //==> cg
    l1->SetParameter(18,norm);//0.013531
    //l1->->SetRange(1e1,0.1,1e3,1);
    //l1->SetMaximum(4e2);
    //l1->SetMinimum(0);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb"<<a[0]<<endl;
    cout<<"teste funcao cg , c2g : 0,0 "<< l1->Eval(0,1)<<endl;
    cout<<"teste funcao cg , c2g : -1,1  "<<  l1->Eval(-1,1)<<endl;
    cout<<"teste funcao cg , c2g : 1,-1  "<<  l1->Eval(-1,1)<<endl;
    cout<<" "<<endl;
    
    ////////////////////////////////
    kt5d=1.0;
    kl5d=0.0;
    c25d=0.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt
    TF2 *l0 = new TF2("l0","([0]*y**4 + [1]*x**2 + [2]*y**2*[16]**2 + [3]*[17]**2*[16]**2 +  [4]*[15]**2 + [5]*x*y**2 + [6]*y*[16]*y**2 + [7]*y*[16]*x + [8]*[17]*[16]*x + [9]*x*[15] + [10]*[17]*[16]*y**2 + [11]*[15]*y**2 + [12]*[16]*[17]*y*[16] + [13]*[15]*y*[16] + [14]*[17]*[15]*[16])/[18]",-4,4,0.5,2.5);
    l0->SetParameter(0,a[0]);
    l0->SetParameter(1,a[1]);
    l0->SetParameter(2,a[2]);    
    l0->SetParameter(3,a[3]);
    l0->SetParameter(4,a[4]);
    l0->SetParameter(5,a[5]); 
    l0->SetParameter(6,a[6]);
    l0->SetParameter(7,a[7]);
    l0->SetParameter(8,a[8]); 
    l0->SetParameter(9,a[9]);
    l0->SetParameter(10,a[10]);
    l0->SetParameter(11,a[11]); 
    l0->SetParameter(12,a[12]);    
    l0->SetParameter(13,a[13]);
    l0->SetParameter(14,a[14]);
    l0->SetTitle("");
    l0->SetParameter(15,c2g); //==> c2g
    l0->SetParameter(16,kl5d);
    l0->SetParameter(17,cg); //==> cg
    l0->SetParameter(18,norm);//0.013531
    l0->SetMinimum(0);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb"<<a[0]<<endl;
    cout<<"teste funcao cg , c2g : 0,0 "<< l0->Eval(0,1)<<endl;
    cout<<"teste funcao cg , c2g : -1,1  "<<  l0->Eval(-1,1)<<endl;
    cout<<"teste funcao cg , c2g : 1,-1  "<<  l0->Eval(-1,1)<<endl;
    cout<<" "<<endl;
    ////////////////////////////////
    kt5d=1.0;
    kl5d=2.4;
    c25d=0.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt
    TF2 *l24 = new TF2("l24","([0]*y**4 + [1]*x**2 + [2]*y**2*[16]**2 + [3]*[17]**2*[16]**2 +  [4]*[15]**2 + [5]*x*y**2 + [6]*y*[16]*y**2 + [7]*y*[16]*x + [8]*[17]*[16]*x + [9]*x*[15] + [10]*[17]*[16]*y**2 + [11]*[15]*y**2 + [12]*[16]*[17]*y*[16] + [13]*[15]*y*[16] + [14]*[17]*[15]*[16])/[18]",-4,4,0.5,2.5);
    l24->SetParameter(0,a[0]);
    l24->SetParameter(1,a[1]);
    l24->SetParameter(2,a[2]);    
    l24->SetParameter(3,a[3]);
    l24->SetParameter(4,a[4]);
    l24->SetParameter(5,a[5]); 
    l24->SetParameter(6,a[6]);
    l24->SetParameter(7,a[7]);
    l24->SetParameter(8,a[8]); 
    l24->SetParameter(9,a[9]);
    l24->SetParameter(10,a[10]);
    l24->SetParameter(11,a[11]); 
    l24->SetParameter(12,a[12]);    
    l24->SetParameter(13,a[13]);
    l24->SetParameter(14,a[14]);
    l24->SetTitle("");
    l24->SetParameter(15,c2g); //==> c2g
    l24->SetParameter(16,kl5d);
    l24->SetParameter(17,cg); //==> cg
    l24->SetParameter(18,norm);//0.013531
    l24->SetMinimum(0);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb"<<a[0]<<endl;
    cout<<"teste funcao cg , c2g : 0,0 "<< l24->Eval(0,1)<<endl;
    cout<<"teste funcao cg , c2g : -1,1  "<<  l24->Eval(-1,1)<<endl;
    cout<<"teste funcao cg , c2g : 1,-1  "<<  l24->Eval(-1,1)<<endl;
    cout<<" "<<endl;
    ////////////////////////////////
    kt5d=1.0;
    kl5d=5.0;
    c25d=0.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt
    TF2 *l5 = new TF2("l5","([0]*y**4 + [1]*x**2 + [2]*y**2*[16]**2 + [3]*[17]**2*[16]**2 +  [4]*[15]**2 + [5]*x*y**2 + [6]*y*[16]*y**2 + [7]*y*[16]*x + [8]*[17]*[16]*x + [9]*x*[15] + [10]*[17]*[16]*y**2 + [11]*[15]*y**2 + [12]*[16]*[17]*y*[16] + [13]*[15]*y*[16] + [14]*[17]*[15]*[16])/[18]",-4,4,0.5,2.5);
    l5->SetParameter(0,a[0]);
    l5->SetParameter(1,a[1]);
    l5->SetParameter(2,a[2]);    
    l5->SetParameter(3,a[3]);
    l5->SetParameter(4,a[4]);
    l5->SetParameter(5,a[5]); 
    l5->SetParameter(6,a[6]);
    l5->SetParameter(7,a[7]);
    l5->SetParameter(8,a[8]); 
    l5->SetParameter(9,a[9]);
    l5->SetParameter(10,a[10]);
    l5->SetParameter(11,a[11]); 
    l5->SetParameter(12,a[12]);    
    l5->SetParameter(13,a[13]);
    l5->SetParameter(14,a[14]);
    l5->SetTitle("");
    l5->SetParameter(15,c2g); //==> c2g
    l5->SetParameter(16,kl5d);
    l5->SetParameter(17,cg); //==> cg
    l5->SetParameter(18,norm);//0.013531
    l5->SetMinimum(0);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb"<<a[0]<<endl;
    cout<<"teste funcao cg , c2g : 0,0 "<< l5->Eval(0,1)<<endl;
    cout<<"teste funcao cg , c2g : -1,1  "<<  l5->Eval(-1,1)<<endl;
    cout<<"teste funcao cg , c2g : 1,-1  "<<  l5->Eval(-1,1)<<endl;
    cout<<" "<<endl;
    ////////////////////////////////
    kt5d=1.0;
    kl5d=10.0;
    c25d=0.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt
    TF2 *l10 = new TF2("l10","([0]*y**4 + [1]*x**2 + [2]*y**2*[16]**2 + [3]*[17]**2*[16]**2 +  [4]*[15]**2 + [5]*x*y**2 + [6]*y*[16]*y**2 + [7]*y*[16]*x + [8]*[17]*[16]*x + [9]*x*[15] + [10]*[17]*[16]*y**2 + [11]*[15]*y**2 + [12]*[16]*[17]*y*[16] + [13]*[15]*y*[16] + [14]*[17]*[15]*[16])/[18]",-4,4,0.5,2.5);
    l10->SetParameter(0,a[0]);
    l10->SetParameter(1,a[1]);
    l10->SetParameter(2,a[2]);    
    l10->SetParameter(3,a[3]);
    l10->SetParameter(4,a[4]);
    l10->SetParameter(5,a[5]); 
    l10->SetParameter(6,a[6]);
    l10->SetParameter(7,a[7]);
    l10->SetParameter(8,a[8]); 
    l10->SetParameter(9,a[9]);
    l10->SetParameter(10,a[10]);
    l10->SetParameter(11,a[11]); 
    l10->SetParameter(12,a[12]);    
    l10->SetParameter(13,a[13]);
    l10->SetParameter(14,a[14]);
    l10->SetTitle("");
    l10->SetParameter(15,c2g); //==> c2g
    l10->SetParameter(16,kl5d);
    l10->SetParameter(17,cg); //==> cg
    l10->SetParameter(18,norm);//0.013531
    l10->SetMinimum(0);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb"<<a[0]<<endl;
    cout<<"teste funcao cg , c2g : 0,0 "<< l10->Eval(0,1)<<endl;
    cout<<"teste funcao cg , c2g : -1,1  "<<  l10->Eval(-1,1)<<endl;
    cout<<"teste funcao cg , c2g : 1,-1  "<<  l10->Eval(-1,1)<<endl;
    cout<<" "<<endl;
    ////////////////////////////////
    kt5d=1.0;
    kl5d=-2.4;
    c25d=0.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt
    TF2 *lm24 = new TF2("lm24","([0]*y**4 + [1]*x**2 + [2]*y**2*[16]**2 + [3]*[17]**2*[16]**2 +  [4]*[15]**2 + [5]*x*y**2 + [6]*y*[16]*y**2 + [7]*y*[16]*x + [8]*[17]*[16]*x + [9]*x*[15] + [10]*[17]*[16]*y**2 + [11]*[15]*y**2 + [12]*[16]*[17]*y*[16] + [13]*[15]*y*[16] + [14]*[17]*[15]*[16])/[18]",-17,17,0.5,2.5);
    lm24->SetParameter(0,a[0]);
    lm24->SetParameter(1,a[1]);
    lm24->SetParameter(2,a[2]);    
    lm24->SetParameter(3,a[3]);
    lm24->SetParameter(4,a[4]);
    lm24->SetParameter(5,a[5]); 
    lm24->SetParameter(6,a[6]);
    lm24->SetParameter(7,a[7]);
    lm24->SetParameter(8,a[8]); 
    lm24->SetParameter(9,a[9]);
    lm24->SetParameter(10,a[10]);
    lm24->SetParameter(11,a[11]); 
    lm24->SetParameter(12,a[12]);    
    lm24->SetParameter(13,a[13]);
    lm24->SetParameter(14,a[14]);
    lm24->SetTitle("");
    lm24->SetParameter(15,c2g); //==> c2g
    lm24->SetParameter(16,kl5d);
    lm24->SetParameter(17,cg); //==> cg
    lm24->SetParameter(18,norm);//0.013531
    lm24->SetMinimum(0);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb"<<a[0]<<endl;
    cout<<"teste funcao cg , c2g : 0,0 "<< lm24->Eval(0,1)<<endl;
    cout<<"teste funcao cg , c2g : -1,1  "<<  lm24->Eval(-1,1)<<endl;
    cout<<"teste funcao cg , c2g : 1,-1  "<<  lm24->Eval(-1,1)<<endl;
    cout<<" "<<endl;
    ////////////////////////////////
    kt5d=1.0;
    kl5d=-5.0;
    c25d=0.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt
    TF2 *lm5 = new TF2("lm5","([0]*y**4 + [1]*x**2 + [2]*y**2*[16]**2 + [3]*[17]**2*[16]**2 +  [4]*[15]**2 + [5]*x*y**2 + [6]*y*[16]*y**2 + [7]*y*[16]*x + [8]*[17]*[16]*x + [9]*x*[15] + [10]*[17]*[16]*y**2 + [11]*[15]*y**2 + [12]*[16]*[17]*y*[16] + [13]*[15]*y*[16] + [14]*[17]*[15]*[16])/[18]",-4,4,0.5,2.5);
    lm5->SetParameter(0,a[0]);
    lm5->SetParameter(1,a[1]);
    lm5->SetParameter(2,a[2]);    
    lm5->SetParameter(3,a[3]);
    lm5->SetParameter(4,a[4]);
    lm5->SetParameter(5,a[5]); 
    lm5->SetParameter(6,a[6]);
    lm5->SetParameter(7,a[7]);
    lm5->SetParameter(8,a[8]); 
    lm5->SetParameter(9,a[9]);
    lm5->SetParameter(10,a[10]);
    lm5->SetParameter(11,a[11]); 
    lm5->SetParameter(12,a[12]);    
    lm5->SetParameter(13,a[13]);
    lm5->SetParameter(14,a[14]);
    lm5->SetTitle("");
    lm5->SetParameter(15,c2g); //==> c2g
    lm5->SetParameter(16,kl5d);
    lm5->SetParameter(17,cg); //==> cg
    lm5->SetParameter(18,norm);//0.013531
    lm5->SetMinimum(0);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb"<<a[0]<<endl;
    cout<<"teste funcao cg , c2g : 0,0 "<< lm5->Eval(0,1)<<endl;
    cout<<"teste funcao cg , c2g : -1,1  "<<  lm5->Eval(-1,1)<<endl;
    cout<<"teste funcao cg , c2g : 1,-1  "<<  lm5->Eval(-1,1)<<endl;
    cout<<" "<<endl;
    ////////////////////////////////
    kt5d=1.0;
    kl5d=-10.0;
    c25d=0.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt
    TF2 *lm10 = new TF2("lm10","([0]*y**4 + [1]*x**2 + [2]*y**2*[16]**2 + [3]*[17]**2*[16]**2 +  [4]*[15]**2 + [5]*x*y**2 + [6]*y*[16]*y**2 + [7]*y*[16]*x + [8]*[17]*[16]*x + [9]*x*[15] + [10]*[17]*[16]*y**2 + [11]*[15]*y**2 + [12]*[16]*[17]*y*[16] + [13]*[15]*y*[16] + [14]*[17]*[15]*[16])/[18]",-4,4,0.5,2.5);
    lm10->SetParameter(0,a[0]);
    lm10->SetParameter(1,a[1]);
    lm10->SetParameter(2,a[2]);    
    lm10->SetParameter(3,a[3]);
    lm10->SetParameter(4,a[4]);
    lm10->SetParameter(5,a[5]); 
    lm10->SetParameter(6,a[6]);
    lm10->SetParameter(7,a[7]);
    lm10->SetParameter(8,a[8]); 
    lm10->SetParameter(9,a[9]);
    lm10->SetParameter(10,a[10]);
    lm10->SetParameter(11,a[11]); 
    lm10->SetParameter(12,a[12]);    
    lm10->SetParameter(13,a[13]);
    lm10->SetParameter(14,a[14]);
    lm10->SetTitle("");
    lm10->SetParameter(15,c2g); //==> c2g
    lm10->SetParameter(16,kl5d);
    lm10->SetParameter(17,cg); //==> cg
    lm10->SetParameter(18,norm);//0.013531
    lm10->SetMinimum(0);
    //
    cout<<endl<<"Value of the formula in SM point: 0.013531 pb"<<a[0]<<endl;
    cout<<"teste funcao cg , c2g : 0,0 "<< lm10->Eval(0,1)<<endl;
    cout<<"teste funcao cg , c2g : -1,1  "<<  lm10->Eval(-1,1)<<endl;
    cout<<"teste funcao cg , c2g : 1,-1  "<<  lm10->Eval(-1,1)<<endl;
    cout<<" "<<endl;
    ///////////////////////////////////////////////////////////////
    // Draw this function in pad1 with Gouraud shading option
    TCanvas *c1 = new TCanvas("c1","Surfaces Drawing Options",1500,2500);
    const int Number = 3;
    Double_t Red[Number]    = { 1.00, 0.00, 0.00};
    Double_t Green[Number]  = { 0.00, 1.00, 0.00};
    Double_t Blue[Number]   = { 1.00, 0.00, 1.00};
    Double_t Length[Number] = { 0.00, 0.50, 1.00 };
    Int_t nb=30;
    TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);
    ////////////////////////////
    TLatex* text = new TLatex();
    text->SetTextSize(0.09);
    c1->SetLogz(0);
    //////////////////////////////////////
    /*
    c1->Divide(3,4);   
    c1->cd(1);
    //c1_1->SetLogz();
    //c1->SetTicks(0,0);
    //c1->SetRightMargin(0.15);
    //c1->SetLeftMargin(0.15);
    //c1->SetBottomMargin(0.02);
    fg2->Draw("colz1");
    text->DrawLatex(-0.85,-0.8,"#kappa_{#lambda} = 1, #kappa_{t} = 1,  c_{2} = 0");
    //-----------------
    c1->cd(2);
    //c1_1->SetLogz();
    //c1_2->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    fg10->Draw("colz1");
    text->DrawLatex(-0.85,-0.8,"#kappa_{#lambda} = 10, #kappa_{t} = 1,  c_{2} = 0");
    //-----------------
    c1->cd(3);
    //c1_1->SetLogz();
    //c1_2->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    fgm10->Draw("colz1");
    text->DrawLatex(-0.85,-0.8,"#kappa_{#lambda} = -10, #kappa_{t} = 1,  c_{2} = 0");
    //text->SetTextSize(0.08);
    //text->SetTextColor(0);
    //text->DrawLatex(-0.85.,-0.8,"#kappa_{#lambda} = 2.4, #kappa_{t} = 1,  c_{2} = 0");
    c1->cd(4);
    //c1_1->SetLogz();
    //c1_2->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    SM0->Draw("colz1");
    text->DrawLatex(-3.,0.7,"c_{2} = c_{g}  = c_{2} = 0");  
    //text->SetTextSize(0.08);
    //text->SetTextColor(0);
    //text->DrawLatex(-0.85.,-0.8,"#kappa_{#lambda} = 2.4, #kappa_{t} = 1,  c_{2} = 0");
    c1->cd(5);
    //c1_5->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    l1->Draw("colz1");
    text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = 1, c_{g}  = c_{2} = 0");  
    c1->cd(6);
    //c1_5->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    l0->Draw("colz1");
    text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = c_{g}  = c_{2} = 0");  
    //text->SetTextSize(0.08);
    //text->SetTextColor(0);
    //text->DrawLatex(-0.85.,-0.8,"#kappa_{#lambda} = 2.4, #kappa_{t} = 1,  c_{2} = 0");   
    c1->cd(7);
    //c1_5->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    l24->Draw("colz");
    text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = 2.4, c_{g}  = c_{2} = 0");  
    //text->SetTextSize(0.08);
    //text->SetTextColor(0);
    //text->DrawLatex(-0.85.,-0.8,"#kappa_{#lambda} = 2.4, #kappa_{t} = 1,  c_{2} = 0");  
    c1->cd(8);
    //c1_5->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    l5->Draw("colz1");
    text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = 5, c_{g}  = c_{2} = 0");  
    //text->SetTextSize(0.08);
    //text->SetTextColor(0);
    //text->DrawLatex(-0.85.,-0.8,"#kappa_{#lambda} = 2.4, #kappa_{t} = 1,  c_{2} = 0");  
    c1->cd(9);
    //c1_5->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    l10->Draw("colz1");
    text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = 10, c_{g}  = c_{2} = 0");  
    //text->DrawLatex(-3,1,"SM plane in log scale");
    //text->SetTextSize(0.08);
    //text->SetTextColor(0);
    //text->DrawLatex(-0.85.,-0.8,"#kappa_{#lambda} = 2.4, #kappa_{t} = 1,  c_{2} = 0");  
    c1->cd(10);
    //c1_5->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    lm24->Draw("colz1");
    text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = -2.4, c_{g}  = c_{2} = 0");  
    c1->cd(11);
    //c1_5->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    lm5->Draw("colz1");
    text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = -5, c_{g}  = c_{2} = 0");  
    c1->cd(12);
    //c1_5->SetTicks(0,0);
    //c1_2->SetRightMargin(0.15);
    //c1_2->SetLeftMargin(0.15);
    //c1_2->SetBottomMargin(0.02);
    lm10->Draw("colz1");
    //text->DrawLatex(-3,1,"SM plane in log scale");
    //text->SetTextSize(0.08);
    //text->SetTextColor(0);
    text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = -10, c_{g}  = c_{2} = 0");  
    c1->SaveAs("C2Fit.pdf");
    c1->Close();
     */
    //////////////////////////////////////////////////
    //
    // do histrograms with errors
    //
    // plot (point - fit)/fit between int nmintest, int nmaxtest
    // do by the planes
    //////////////////////////////////////////////////
    // take the fit
    // need to be done by planes
    //c1->Clear();
    // a
    double SMxs =  0.013531; // 1 0.017278;// 14 0.0041758;// 8tev 0.013531; // 13 tev 0.017278;// 0.0041758;
    TGraph2D *g2 = new TGraph2D(117);//(118);
    g2->SetMarkerStyle(20);
    g2->SetMarkerSize(2);
    g2->SetTitle("0");
    g2->SetTitle("#kappa_{t} = #kappa_{#lambda} = 1 , c_{2} = 0 ; c_{g} ; c_{2g}");
    int j=0;
    for (unsigned int ij = 0; ij < nmaxx ; ij++) if( par1[ij] ==1 && par0[ij] ==1 && par2[ij]==0 && cross_section[ij] >0.0001) if(ij!=301) {
        double fit = SMxs*(fg2->Eval(par3[ij], par4[ij]));
        cout<<j<<" "<< par3[ij]<<" "<< par4[ij]<<" "<<fit <<" "<< cross_section[ij]<<" diff: " <<(fit - cross_section[ij])/fit<< endl;
        g2->SetPoint(j, par3[ij], par4[ij], 100*(fit - cross_section[ij])/fit); 
        j++;
        //Differences2->Fill(par3[i], par4[i], (fit - cross_section[i])/fit); 
    }
    // b 
    ////////////////////////////////
    int ktb=1.0;
    int klb=1.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt ==> cg = c2g
    TF2 *pb = new TF2("pb","([0]*[15]**4 + [1]*x**2 + [2]*[15]**2*[16]**2 + [3]*y**2*[16]**2 +  [4]*y**2 + [5]*x*[15]**2 + [6]*[15]*[16]*[15]**2 + [7]*[15]*[16]*x + [8]*y*[16]*x - [9]*x*y + [10]*y*[16]*[15]**2 - [11]*y*[15]**2 + [12]*[16]*y*[15]*[16] - [13]*y*[15]*[16] - [14]*y*y*[16])/[17]",-3,3,-1,1);
    pb->SetParameter(0,a[0]);
    pb->SetParameter(1,a[1]);
    pb->SetParameter(2,a[2]);    
    pb->SetParameter(3,a[3]);
    pb->SetParameter(4,a[4]);
    pb->SetParameter(5,a[5]); 
    pb->SetParameter(6,a[6]);
    pb->SetParameter(7,a[7]);
    pb->SetParameter(8,a[8]); 
    pb->SetParameter(9,a[9]);
    pb->SetParameter(10,a[10]);
    pb->SetParameter(11,a[11]); 
    pb->SetParameter(12,a[12]);    
    pb->SetParameter(13,a[13]);
    pb->SetParameter(14,a[14]);
    pb->SetTitle("#kappa_{t} = #kappa_{#lambda} = 1 , c_{2g} = - c_{g} ; c_{2} ; c_{g}");
    pb->SetParameter(15,ktb); //==> c2g ==>kt
    pb->SetParameter(16,klb);
    pb->SetContour(200);
    //l5->SetParameter(17,cg); //==> cg
    pb->SetParameter(17,norm);//0.013531
    //pb->SetMinimum(0);
    TGraph2D *gb = new TGraph2D(132);//(118);
    gb->SetMarkerStyle(20);
    gb->SetMarkerSize(2);
    //gb->SetTitle("0");
    gb->SetTitle("#kappa_{t} = #kappa_{#lambda} = 1 , c_{2g} = - c_{g} ; c_{2} ; c_{g}");
    int jb=0;
    for (unsigned int ijb = 0; ijb < nmaxx ; ijb++) if( par1[ijb] ==1 && par0[ijb] ==1 && par3[ijb] == -par4[ijb] && cross_section[ijb] >0.0001) {
        double fitb = SMxs*(pb->Eval(par2[ijb], par3[ijb]));
        cout<<jb<<" "<<ijb<<" "<< par2[ijb]<<" "<< par4[ijb]<<" "<<fitb <<" "<< cross_section[ijb]<<" diff: " <<(fitb - cross_section[ijb])/fitb<< endl;
        if (abs((fitb - cross_section[ijb])/fitb) > 0.1) cout<<"here"<<endl;
        gb->SetPoint(jb, par2[ijb], par4[ijb], 100*((fitb - cross_section[ijb])/fitb)); 
        jb++;
        //Differences2->Fill(par3[i], par4[i], (fit - cross_section[i])/fit); 
    }
    //////////////////////////////////////////////
    // c
    ////////////////////////////////
    int ktc=1.0;
    int c2c=0.0;//==>c2
    // cg ===> x ==> c2 =//=>kl
    // c2g ===> y ==> kt ==> c2g = -cg 
    TF2 *pc = new TF2("pb","([0]*[15]**4 + [1]*[16]**2 + [2]*[15]**2*x**2 + [3]*y**2*x**2 +  [4]*y**2 + [5]*[16]*[15]**2 + [6]*[15]*x*[15]**2 + [7]*[15]*x*[16] + [8]*y*x*[16] - [9]*[16]*y + [10]*y*x*[15]**2 - [11]*y*[15]**2 + [12]*x*y*[15]*x - [13]*y*[15]*x - [14]*y*y*x)/[17]",-17,17,-1,1);
    pc->SetParameter(0,a[0]);
    pc->SetParameter(1,a[1]);
    pc->SetParameter(2,a[2]);    
    pc->SetParameter(3,a[3]);
    pc->SetParameter(4,a[4]);
    pc->SetParameter(5,a[5]); 
    pc->SetParameter(6,a[6]);
    pc->SetParameter(7,a[7]);
    pc->SetParameter(8,a[8]); 
    pc->SetParameter(9,a[9]);
    pc->SetParameter(10,a[10]);
    pc->SetParameter(11,a[11]); 
    pc->SetParameter(12,a[12]);    
    pc->SetParameter(13,a[13]);
    pc->SetParameter(14,a[14]);
    pc->SetTitle("#kappa_{t} = 1 , c2 = 0 , c_{2g} = - c_{g} ; #kappa_{#lambda} ; c_{g}");
    pc->SetParameter(15,ktc); //==> c2g ==>kt
    pc->SetParameter(16,c2c);// ==>c2
    //l5->SetParameter(17,cg); //==> cg
    pc->SetParameter(17,norm);//0.013531
    //pc->SetMinimum(0);
    pc->SetContour(200);
    TGraph2D *gc = new TGraph2D(125);//(118);
    gc->SetMarkerStyle(20);
    gc->SetMarkerSize(2);
    gc->SetTitle("#kappa_{t} = 1 , c2 = 0 , c_{2g} = - c_{g} ; #kappa_{#lambda} ; c_{g}");
  //  gc->GetYaxis()->SetTitle("c_{g}");
  //  gc->GetXaxis()->SetTitle("#kappa_{#lambda}");
    int jc=0;
    for (unsigned int ijb = 0; ijb < nmaxx ; ijb++) if( par1[ijb] ==1 && par2[ijb] ==0 && par3[ijb] == -par4[ijb]  && cross_section[ijb] >0.0001 && par3[ijb] >-1.5) { //&& abs(par0[ijb]) <6
        double fitc = SMxs*(pc->Eval(par0[ijb], par3[ijb]));
        //cout<<jb<<" "<<ijb<<" "<< par0[ijb]<<" "<< par4[ijb]<<" "<<fitc <<" "<< cross_section[ijb]<<" diff: " <<(fitc - cross_section[ijb])/fitc<< endl;
        if (abs((fitc - cross_section[ijb])/fitc) > 0.1) cout<<"here"<<endl;
        gc->SetPoint(jc, par0[ijb], par3[ijb], 100*((fitc - cross_section[ijb])/fitc)); 
        jc++;
        //Differences2->Fill(par3[i], par4[i], (fit - cross_section[i])/fit); 
    }
    //////////////////////////////////
    // d -- SM plane
    //SM0->Eval(1,1)
    // cg ===> x  ===> kl
    // c2g ===> y ===> kt
    TGraph2D *gSM = new TGraph2D(112);//(118);
    gSM->SetMarkerStyle(20);
    gSM->SetMarkerSize(2);
    gSM->SetTitle("0");
    gSM->SetTitle("c_{2} = c_{2g} = c_{g} = 0 ; #kappa_{#lambda} ; #kappa_{t}");
    int jSM=0;
    for (unsigned int ii = 0; ii < nmaxx ; ii++) if( par2[ii] ==0 && par3[ii] ==0 && par4[ii]==0 && cross_section[ii] >0.00001 &&  cross_section[ii] <10000 && par1[ii] >0.3 && ii!=301) {
        double fitSM = SMxs*(SM0->Eval(par0[ii], par1[ii]));
        //{
        //cout<<" SM plane"<<jSM<<" "<<ii<<" " << par0[ii]<<" "<< par1[ii]<<" "<<fitSM <<" "<< cross_section[ii]<<" diff: " <<(fitSM - cross_section[ii])/fitSM<< endl;
        if (abs((fitSM - cross_section[ii])/fitSM) > 0.1) cout<<"here"<<endl;
        gSM->SetPoint(jSM, par0[ii], par1[ii], 100*(fitSM - cross_section[ii])/fitSM); 
        jSM++;
        //}
        //Differences2->Fill(par3[i], par4[i], (fit - cross_section[i])/fit); 
    }    
    //////////////////////////////////
    // e -- SM plane
    //SM0->Eval(1,1)
    // cg ===> x  ===> c2
    // c2g ===> y ===> kt
    TGraph2D *gSMc2 = new TGraph2D(62);//(118);//57 13 tev
    gSMc2->SetMarkerStyle(20);
    gSMc2->SetMarkerSize(2);
    //gSMc2->SetTitle("0");
    gSMc2->SetTitle("#kappa_{#lambda} =1 , c_{2g} = c_{g} = 0 ; c_{2} ; #kappa_{t}");
    int jSMc2=0;
    for (unsigned int ii = 0; ii < nmaxx ; ii++) if( par0[ii] ==1 && par3[ii] ==0 && par4[ii]==0 && cross_section[ii] >0.00001 &&  cross_section[ii] <10000 && par1[ii] >0.25 ) if(ii!=301){
        double fitSM = SMxs*(l1->Eval(par2[ii], par1[ii]));
        //{
        cout<<jSMc2<<" "<<ii<<" " << par2[ii]<<" "<< par1[ii]<<" "<<fitSM <<" "<< cross_section[ii]<<" diff: " <<(fitSM - cross_section[ii])/fitSM<< endl;
        if (abs((fitSM - cross_section[ii])/fitSM) > 0.1) cout<<"here"<<endl;
        gSMc2->SetPoint(jSMc2, par2[ii], par1[ii], 100*(fitSM - cross_section[ii])/fitSM); 
        jSMc2++;
        //}
        //Differences2->Fill(par3[i], par4[i], (fit - cross_section[i])/fit); 
    }   
    ////////////////////////////////
    // f = cg =0
    int ktf=1.0;
    int klf=1.0;
    // cg ===> x ==> c2
    // c2g ===> y ==> kt ==> cg = c2g
    TF2 *pf = new TF2("pf","([0]*[15]**4 + [1]*x**2 + [2]*[15]**2*[16]**2 +  [4]*y**2 + [5]*x*[15]**2 + [6]*[15]*[16]*[15]**2 + [7]*[15]*[16]*x + [9]*x*y + [11]*y*[15]**2  + [13]*y*[15]*[16])/[17]",-3,3,-1,1);
    pf->SetParameter(0,a[0]);
    pf->SetParameter(1,a[1]);
    pf->SetParameter(2,a[2]);    
    pf->SetParameter(3,a[3]);
    pf->SetParameter(4,a[4]);
    pf->SetParameter(5,a[5]); 
    pf->SetParameter(6,a[6]);
    pf->SetParameter(7,a[7]);
    pf->SetParameter(8,a[8]); 
    pf->SetParameter(9,a[9]);
    pf->SetParameter(10,a[10]);
    pf->SetParameter(11,a[11]); 
    pf->SetParameter(12,a[12]);    
    pf->SetParameter(13,a[13]);
    pf->SetParameter(14,a[14]);
    pf->SetTitle("#kappa_{t} = #kappa_{#lambda} = 1 , c_{g} = 0 ; c_{2} ; c_{2g}");
    //pf->SetTitleSize(0.3);
    pf->SetParameter(15,ktf); //==> c2g ==>kt
    pf->SetParameter(16,klf);
    pf->SetContour(200);
    //l5->SetParameter(17,cg); //==> cg
    pf->SetParameter(17,norm);//0.013531
    //pb->SetMinimum(0);
    TGraph2D *gf = new TGraph2D(132);//(118);
    gf->SetMarkerStyle(20);
    gf->SetMarkerSize(2);
    //gb->SetTitle("0");
    gf->SetTitle("#kappa_{t} = #kappa_{#lambda} = 1 , c_{g} = 0 ; c_{2} ; c_{2g}");
    int jf=0;
    for (unsigned int ijb = 0; ijb < nmaxx ; ijb++) if( par1[ijb] ==1 && par0[ijb] ==1 && par3[ijb] == 0 && cross_section[ijb] >0.0001) {
        double fitb = SMxs*(pf->Eval(par2[ijb], par4[ijb]));
        cout<<jf<<" "<<ijb<<" "<< par2[ijb]<<" "<< par4[ijb]<<" "<<fitb <<" "<< cross_section[ijb]<<" diff: " <<(fitb - cross_section[ijb])/fitb<< endl;
        if (abs((fitb - cross_section[ijb])/fitb) > 0.1) cout<<"here"<<endl;
        gf->SetPoint(jf, par2[ijb], par4[ijb], 100*((fitb - cross_section[ijb])/fitb)); 
        jf++;
        //Differences2->Fill(par3[i], par4[i], (fit - cross_section[i])/fit); 
    }
    //////////////////////////////////////////////
    // rest square
    TCanvas *c2 = new TCanvas("c2","Surfaces Drawing Options",700,2200);
    c2->Divide(2,3);   
    c2->cd(1);
    c2_1->SetRightMargin(0.17);
    c2_1->SetLeftMargin(0.21);
    //c2->cd();
    c2_1->SetTheta(90.0-0.001);
    c2_1->SetPhi(0.0+0.001);
    gSM->Draw("Pcolz");
    //fg2->Draw("cont3SAME");
    c2->cd(2);
    c2_2->SetRightMargin(0.2);
    c2_2->SetLeftMargin(0.21);
    c2_2->SetTheta(90.0-0.001);
    c2_2->SetPhi(0.0+0.001);
    gSMc2->Draw("Pcolz");
    //SM0->Draw("cont3SAME");
    c2->cd(3);
    c2_3->SetRightMargin(0.2);
    c2_3->SetLeftMargin(0.21);
    c2_3->SetTheta(90.0-0.001);
    c2_3->SetPhi(0.0+0.001);
    gb->Draw("Pcolz");
    //pb->Draw("cont3SAME");
    c2->cd(4);
    c2_4->SetRightMargin(0.2);
    c2_4->SetLeftMargin(0.21);
    c2_4->SetTheta(90.0-0.001);
    c2_4->SetPhi(0.0+0.001);
    gc->Draw("Pcolz");
    //pc->Draw("cont3SAME");
    c2->cd(5);
    c2_5->SetRightMargin(0.2);
    c2_5->SetLeftMargin(0.21);
    c2_5->SetTheta(90.0-0.001);
    c2_5->SetPhi(0.0+0.001);
    
    g2->Draw("Pcolz");
    //
    c2->cd(6);
    c2_6->SetRightMargin(0.2);
    c2_6->SetLeftMargin(0.21);
    c2_6->SetTheta(90.0-0.001);
    c2_6->SetPhi(0.0+0.001);
    gf->Draw("Pcolz");
    c2->SaveAs("DiffSMplane_all_orthogonal_13tev.pdf");
    //////////////////////////////////////////////
    // rest square
    TCanvas *c3 = new TCanvas("c3","Surfaces Drawing Options",2200,700);
    c3->Divide(3,2); 
    c3->cd(1);
    c3_1->SetLogz(1);
    c3_1->SetLeftMargin(0.19);
    c3_1->SetBottomMargin(0.19);
    c3_1->SetRightMargin(0.2);
    //c2->cd();
    //g2->Draw("Pcolz");
    SM0->Draw("colz");
    
    c3->cd(2);
    c3_2->SetLogz(1);
    c3_2->SetRightMargin(0.19);
    c3_2->SetBottomMargin(0.19);
    c3_2->SetLeftMargin(0.21);
    //gSM->Draw("Pcolz");
    l1->Draw("colz");
    //c3_2->SetRightMargin(0.2);
    c3->cd(3);
    c3_3->SetLogz(1);
    c3_3->SetRightMargin(0.17);
    c3_3->SetBottomMargin(0.19);
    c3_3->SetLeftMargin(0.21);
    //gb->Draw("Pcolz");
    pb->Draw("colz");
    c3->cd(4);
    c3_4->SetLogz(1);
    c3_4->SetRightMargin(0.16);
    c3_4->SetBottomMargin(0.19);
    c3_4->SetLeftMargin(0.21);
    //gc->Draw("Pcolz");
    pc->Draw("colz");
    c3->cd(5);
    c3_5->SetLogz(1);
    c3_5->SetRightMargin(0.19);
    c3_5->SetBottomMargin(0.19);
    c3_5->SetLeftMargin(0.21);
    //gSMc2->Draw("Pcolz");
    
    fg2->Draw("colz");
    c3->cd(6);
    c3_6->SetLogz(1);
    c3_6->SetRightMargin(0.19);
    c3_6->SetBottomMargin(0.19);
    c3_6->SetLeftMargin(0.21);
    //gSMc2->Draw("Pcolz");
    pf->Draw("colz");
    
    c3->SaveAs("CX_all_orthogonal_13tev.pdf");
    //////////////////////////////////////////////
    
    /*  TGraph *gall = new TGraph(nmaxx - nminx);
    gall->SetMarkerStyle(20);
    gall->SetMarkerSize(2);
    gall->SetTitle("0");
    for (unsigned int i = 0; i < nmaxx - nminx; i++) if( par1[i] ==1 && par0[i] ==1 && par2[i]==0 ) {
        double fit = fg2->Eval(par3[i], par4[i]);
        cout<< par3[i]<<" "<< par4[i]<<" "<< (fit - cross_section[i])/fit<< endl;
        g2->SetPoint(i, par3[i], par4[i], (fit - cross_section[i])/fit); 
        //Differences2->Fill(par3[i], par4[i], (fit - cross_section[i])/fit); 
    }*/
    



    
}