コード例 #1
0
int
plotting_output()
{

	vector< int > x, y;
	vector< double > laplace;
	string mapping_tower_file = "./numerical_solution.txt";


	/* Stream to read table from file */
	ifstream istream_mapping;

	/* Open the datafile, if it won't open return an error */
	if (!istream_mapping.is_open())
	{
		istream_mapping.open( mapping_tower_file.c_str() );
		if(!istream_mapping)
		{
			cerr << "CaloTowerGeomManager::ReadGeometryFromTable - ERROR Failed to open mapping file " << mapping_tower_file << endl;
			exit(1);
		}
	}

	string line_mapping;
	int x_i, y_i;
	double laplace_i;

	while ( getline( istream_mapping, line_mapping ) )
	{
		istringstream iss(line_mapping);
		iss >> x_i >> y_i >> laplace_i;
		x.push_back( x_i );
		y.push_back( y_i );
		laplace.push_back( laplace_i );
	}

	TCanvas *c1 = new TCanvas();
	TGraph2D *gr = new TGraph2D();
	for(int i = 0; i < x.size(); i++)
	{
		gr->SetPoint( gr->GetN(), x.at(i), y.at(i), laplace.at(i) );
	}
	gr->Draw("surf1");
	cout << "graph drawn " << endl;

	TCanvas *c1 = new TCanvas();
	gr->Draw("P");





	return 0;
}
コード例 #2
0
ファイル: graph2D.C プロジェクト: Vlad-ole/Roughness
TCanvas* graph2dfit_test()
{
	gStyle->SetOptStat(0);
	gStyle->SetOptFit();

	TCanvas *c = new TCanvas("c", "Graph2D example", 0, 0, 600, 800);
	
	Double_t rnd, x, y, z;
	Double_t e = 0.3;
	Int_t nd = 400;
	Int_t np = 10000;

	TRandom r;
	Double_t fl = 6;
	TF2  *f2 = new TF2("f2", "1000*(([0]*sin(x)/x)*([1]*sin(y)/y))+200", -fl, fl, -fl, fl);
	f2->SetParameters(1, 1);
	TGraph2D *dt = new TGraph2D();

	// Fill the 2D graph
	Double_t zmax = 0;
	for (Int_t N = 0; N<nd; N++) {
		f2->GetRandom2(x, y);
		// Generate a random number in [-e,e]
		rnd = 2 * r.Rndm()*e - e;
		z = f2->Eval(x, y)*(1 + rnd);
		if (z>zmax) zmax = z;
		dt->SetPoint(N, x, y, z);
	}


	f2->SetParameters(0.5, 1.5);
	dt->Fit(f2);
	TF2 *fit2 = (TF2*)dt->FindObject("f2");

	f2->SetParameters(1, 1);

	for (Int_t N = 0; N<np; N++) {
		f2->GetRandom2(x, y);
		// Generate a random number in [-e,e]
		rnd = 2 * r.Rndm()*e - e;
		z = f2->Eval(x, y)*(1 + rnd);
		h1->Fill(f2->Eval(x, y) - z);
		z = dt->Interpolate(x, y);
		h2->Fill(f2->Eval(x, y) - z);
		z = fit2->Eval(x, y);
		h3->Fill(f2->Eval(x, y) - z);
	}

	gStyle->SetPalette(1);
	
	f2->SetTitle("Original function with Graph2D points on top");
	f2->SetMaximum(zmax);
	gStyle->SetHistTopMargin(0);
	f2->Draw("surf1");
	dt->Draw("same p0");



	return c;
}
コード例 #3
0
  bool PlotBundle::drawHistsAndGraphs(const PlotStyle &plot_style) const {
    if (hasDrawables()) {
      std::vector<DrawableDataObjectDrawOptionPair<TH1*> >::const_iterator hist_it;

      for (hist_it = histograms.begin(); hist_it != histograms.end();
          hist_it++) {
        TH1* hist = hist_it->data_object;
        std::string draw_option(hist_it->draw_option);
        if (hist) {
          if (hist->GetDimension() > 1) {
            hist->GetZaxis()->SetLimits(plot_axis.z_axis_range.low,
                plot_axis.z_axis_range.high);
            hist->GetZaxis()->SetRangeUser(plot_axis.z_axis_range.low,
                plot_axis.z_axis_range.high);
          }
          draw_option.append("SAME");
          hist->Draw(draw_option.c_str());
        }
      }

      std::vector<DrawableDataObjectDrawOptionPair<TGraph*> >::const_iterator graph_it;

      for (graph_it = graphs.begin(); graph_it != graphs.end(); graph_it++) {
        TGraph* graph = graph_it->data_object;
        std::string draw_option(graph_it->draw_option);
        if (graph) {
          draw_option.append("SAME");
          graph->Draw(draw_option.c_str());
        }
      }

      std::vector<DrawableDataObjectDrawOptionPair<TGraph2D*> >::const_iterator graph2d_it;

      for (graph2d_it = graphs2d.begin(); graph2d_it != graphs2d.end();
          graph2d_it++) {
        TGraph2D* graph = graph2d_it->data_object;
        std::string draw_option(graph2d_it->draw_option);
        if (graph) {
          draw_option.append("SAME");
          graph->Draw(draw_option.c_str());
        }
      }
      return true;
    } else {
      std::cout
          << "Dude, you forgot to add a histogram or graph in the plot bundle..."
          << " Please add at least one and make sure it points to an existing object!"
          << std::endl;
      return false;
    }
  }
コード例 #4
0
ファイル: drawer.cpp プロジェクト: Iximiel/Tesina-Calcolo2
//g++ allDataPrint.cpp `root-config --cflags --glibs`
int main(int argc, char** argv)
#endif
{
  TCanvas c3("c3","Grafico",640,512);
  TCanvas c1("c1","Confronto",1280,512);
  c1.Divide(2,1);
  
  preparedraw myData (argv[1],
		      // preparedraw::doMax |
		      preparedraw::doFh |
		      preparedraw::doSh |
		      preparedraw::doErr);
  
  TGraph2D *g = myData.data();
  TGraph *gb = myData.firsthalf();//before
  TGraph *ga = myData.secondhalf();//after
  TGraph *gerrs = myData.errs();
  //  TGraph *maxs = myData.maximum();
  
  c3.cd();
  g->GetXaxis()->SetTitle("X");
  g->GetYaxis()->SetTitle("T");
  //g->Draw("cont1");
  g->Draw("pcol");
  //g->Draw();
  //grafo.Draw("surf1");

  cout<<"Disegno i grafici\n";
  TMultiGraph *mg = new TMultiGraph("integrali","Integrali prima e dopo la barriera");
  
  ga->SetLineColor(2);
  mg->Add(gb);
  mg->Add(ga);
  c1.cd(1);
  mg->Draw("apl");
    

  gerrs->SetTitle("Andamento degli errori");
  c1.cd(2);
  gerrs->Draw("apl");
#ifndef __CINT__
  theApp.Run(true);
  return 0;
#endif
}
コード例 #5
0
//g++ allDataPrint.cpp `root-config --cflags --glibs`
int main(int argv, char** argc)
#endif
{
  /*  TCanvas c("c","Real",640,512);
  TGraph2D *grafo = new TGraph2D("out.txt");
  grafo->Draw("pcol");
  TCanvas c2("c2","Imaginary",640,512);
  TGraph2D *Cgrafo = new TGraph2D("iout.txt");
  Cgrafo->Draw("pcol");*/
  TCanvas c3("c3","Norm",640,512);
  TGraph2D *Ngrafo = new TGraph2D(argc[1]);
  Ngrafo->Draw("pcol");
  //grafo.Draw("surf1");
#ifndef __CINT__
  theApp.Run(true);
  return 0;
#endif
}
コード例 #6
0
ファイル: hist1.cpp プロジェクト: mslosarz/simulation
int w1() {

	TCanvas *c = new TCanvas("c1", "", 0, 0, 700, 600);
	TGraph2D *dt = new TGraph2D();

	ifstream in("/opt/workspace-cpp/simulation/result_rand3.csv");

	string buff;

	getline(in, buff);

	int meanResidenceTime;
	int products;
	float lastProductPrice;
	float shopIncome;

	int n = 0;
	while (getline(in, buff)) {
			for (unsigned int i = 0; i < buff.size(); i++) {
				if (buff[i] == ';') {
					buff[i] = ' ';
				}
			}
			stringstream ss(buff);
			ss >> meanResidenceTime;
			ss >> products;
			ss >> lastProductPrice;
			ss >> shopIncome;
			dt->SetPoint(n, products, meanResidenceTime, shopIncome);
			n++;
	}
	gStyle->SetPalette(1);
	dt->SetTitle("Zaleznosc zysku od liczby produktow oraz czasu przebywania w sklepie");
	dt->GetXaxis()->SetTitle("Liczba produktow");
	dt->GetYaxis()->SetTitle("Sredni czas przebywania w sklepie");
	dt->GetZaxis()->SetTitle("Dochod");
	dt->Draw("surf1");
}
コード例 #7
0
TH2D grMu(TTree *tree, double quantileExpected){

	TGraph2D *gr = new TGraph2D();
	float X, Y, qE;
	double limit;

	std::string x = "trackedParam_proc_scaling_muV";
	std::string y = "trackedParam_proc_scaling_muF";

	tree->SetBranchAddress(Form("%s",x.c_str()),&X);
	tree->SetBranchAddress(Form("%s",y.c_str()),&Y);
	tree->SetBranchAddress("quantileExpected",&qE);
	tree->SetBranchAddress("limit",&limit);

	int pt = 0;
	for (int i=0;i<tree->GetEntries();i++){
	  tree->GetEntry(i);
	  if (TMath::Abs(qE-quantileExpected)>0.001) continue;
	  gr->SetPoint(pt,X,Y,limit); pt++;
	  //std::cout << " Lim " << X << ", " << Y << ", " << limit << std::endl;
	}
	gr->Draw("colz");
	TH2D * expected = (TH2D*) gr->GetHistogram();
	expected->SetTitle("");
	expected->GetZaxis()->SetTitleOffset(1.2);
	expected->GetYaxis()->SetTitle("#it{#mu}_{ggH}");
	expected->GetXaxis()->SetTitle("#it{#mu}_{qqH,VH}");
	expected->GetZaxis()->SetTitle("B(H #rightarrow inv.) - 95% CL upper limit");
	expected->GetXaxis()->SetRangeUser(MUVMIN,MUVMAX);
	expected->GetYaxis()->SetRangeUser(MUFMIN,MUFMAX);
	//expected->GetXaxis()->SetLimits(MUVMIN,MUVMAX);
	//expected->GetYaxis()->SetLimits(MUFMIN,MUFMAX);

	expected->SetMaximum(0.6);
	expected->SetMinimum(0.05);
	return *expected;
}
コード例 #8
0
Int_t line3Dfit()
{
   gStyle->SetOptStat(0);
   gStyle->SetOptFit();


   //double e = 0.1;
   Int_t nd = 10000;


//    double xmin = 0; double ymin = 0;
//    double xmax = 10; double ymax = 10;

   TGraph2D * gr = new TGraph2D();

   // Fill the 2D graph
   double p0[4] = {10,20,1,2};

   // generate graph with the 3d points
   for (Int_t N=0; N<nd; N++) {
      double x,y,z = 0;
      // Generate a random number 
      double t = gRandom->Uniform(0,10);
      line(t,p0,x,y,z);
      double err = 1;
    // do a gaussian smearing around the points in all coordinates
      x += gRandom->Gaus(0,err);  
      y += gRandom->Gaus(0,err);  
      z += gRandom->Gaus(0,err);  
      gr->SetPoint(N,x,y,z);
      //dt->SetPointError(N,0,0,err);
   }
   // fit the graph now 
   
   ROOT::Fit::Fitter  fitter;
   
   
   // make the functor objet
   SumDistance2 sdist(gr);
#ifdef __CINT__
   ROOT::Math::Functor fcn(&sdist,4,"SumDistance2");
#else
   ROOT::Math::Functor fcn(sdist,4);
#endif
   // set the function and the initial parameter values
   double pStart[4] = {1,1,1,1};
   fitter.SetFCN(fcn,pStart);
   // set step sizes different than default ones (0.3 times parameter values)
   for (int i = 0; i < 4; ++i) fitter.Config().ParSettings(i).SetStepSize(0.01);
  
   bool ok = fitter.FitFCN();
   if (!ok) {
      Error("line3Dfit","Line3D Fit failed");
      return 1;
   }
   
   const ROOT::Fit::FitResult & result = fitter.Result();
   
   std::cout << "Total final distance square " << result.MinFcnValue() << std::endl;
   result.Print(std::cout);
   

   gr->Draw("p0");

   // get fit parameters
   const double * parFit = result.GetParams();

   
   // draw the fitted line
   int n = 1000;
   double t0 = 0;
   double dt = 10;
   TPolyLine3D *l = new TPolyLine3D(n);
   for (int i = 0; i <n;++i) {
      double t = t0+ dt*i/n;
      double x,y,z;
      line(t,parFit,x,y,z);
      l->SetPoint(i,x,y,z);
   }
   l->SetLineColor(kRed);
   l->Draw("same");
   
   // draw original line
   TPolyLine3D *l0 = new TPolyLine3D(n);
   for (int i = 0; i <n;++i) {
      double t = t0+ dt*i/n;
      double x,y,z;
      line(t,p0,x,y,z);
      l0->SetPoint(i,x,y,z);
   }
   l0->SetLineColor(kBlue);
   l0->Draw("same");
   return 0;
}
コード例 #9
0
int
numerical_laplace()
{

    const int x_max = 49, y_max = 39;					//set the dimensions of the area within your boundary conditions
    double v_top = 0.0, v_bottom = 0.0, v_left = 9.8, v_right = 0.0;	//set the boundary conditions. additional points can be specified below, but this is useful if one row should be set to ground
    int iterations = 1000;							//iterations of the calculation. Can take a while past 100,000
    bool write_matrix_init = true;						//Will output the initial matrix to stdout if true
    bool additional_constraints = true;					//Will apply the additional constraints below if true
    bool write_matrix_final = false;					//Will output the final matrix after iterating if true
    bool output = true;							//Will generate output file if true.
    bool plot = true;							//Will plot output if true

    //Create array filled with 0's in the size of the grid + 2 (add boundary conitions)
    double laplace[x_max+2][y_max+2];
    for(int i = 0; i < x_max+2; i++)
    {
        for(int j = 0; j < y_max+2; j++)
        {
            laplace[i][j] = 0.0;
            if(i == 0) laplace[i][j] = v_left;
            if(j == 0 && i != 0) laplace[i][j] = v_bottom;
            if(i == x_max+1) laplace[i][j] = v_right;
            if(j == y_max+1 && i != 0) laplace[i][j] = v_top;
        }
    }
    cout << "Matrix Created." << endl;

    //These additional constraints are appplied to the matrix before iteration. EX) Only this point on the boundary is at 5V
    if(additional_constraints)
    {
        laplace[1][0] = v_left / 2;
        laplace[2][0] = v_left / 2;
        laplace[3][0] = v_left / 2;
        laplace[1][40] = v_left;
        laplace[2][40] = v_left / 2;
        laplace[3][40] = v_left / 2;
        laplace[4][40] = v_left / 4;
        cout << "    (additional Constraints applied)" << endl;
    }

    //Write out the initial matrix
    if(write_matrix_init == true)
    {
        for(int i = 0; i < x_max+2; i++)
        {
            cout << " | ";
            for(int j = 0; j < y_max+2; j++)
            {
                cout << laplace[i][j] << " | ";
            }
            cout << endl;
        }
        cout << endl << endl;
    }


    //Iterate over the inner rows/columns of the matrix, averaging at each point.
    for ( int k = 0; k < iterations; k++)
    {
        //Loop over all iterations, averaging each point with those around them... skipping over boundary conditions
        for(int i = 1; i < x_max+1; i++)
        {
            for(int j = 1; j < y_max+1; j++)
            {
                laplace[i][j] = 0.25*( laplace[i-1][j] + laplace[i+1][j] + laplace[i][j-1] + laplace[i][j+1] );
//				laplace[i][j] = 0.125*( laplace[i-1][j] + laplace[i+1][j] + laplace[i][j-1] + laplace[i][j+1] + laplace[i-1][j-1] + laplace[i-1][j+1] + laplace[i+1][j-1] + laplace [i+1][j+1] );
            }
        }
    }
    cout << "Computations Completed. Plotting..." << endl;

    //Write out the final matrix
    if(write_matrix_final == true)
    {
        for(int i = 0; i < x_max+2; i++)
        {
            cout << " | ";
            for(int j = 0; j < y_max+2; j++)
            {
                cout << laplace[i][j] << " | ";
            }
            cout << endl;
        }
        cout << endl << endl;
    }

    //Write the output to a file
    if(output)
    {
        ofstream myfile;
        myfile.open("numerical_solution.txt");

        for(int i = 1; i < x_max+1; i++)
        {
            for(int j = 1; j < y_max+1; j++)
            {
                myfile << i << " " << j << " " << laplace[i][j] << endl;
//				myfile << j << " " << i << " " << laplace[i][j] << endl;
            }
        }
        myfile.close();
        cout << "Output file created." << endl;
    }


    //Plot the final output
    if(plot)
    {
        //Create the output graph
        TCanvas *c1 = new TCanvas();
        TGraph2D *gr = new TGraph2D();
        for(int i = 1; i < x_max+1; i++)
        {
            for(int j = 1; j < y_max+1; j++)
            {
                gr->SetPoint( gr->GetN(), i, j, laplace[i][j] );
            }
        }
        //gr->Draw("surf1");
        gr->Draw("COLZ");

        TCanvas *c2 = new TCanvas();
        gr->Draw("surf1");

        //	TH2 *h2 = gr->Project("xy");
        //	h2->Draw();
    }

    return 0;
}
コード例 #10
0
void fillGraphsFromFilesDeltaNLL( const TString& par1name,
				  const TString& par2name,
				  const vector<TString>& fnames,
				  vector<string>&  keys,
				  map<string,TGraph2D *>& m_graphs)
{

  std::cout << "fillGraphsFromFilesDeltaNLL 1" << std::endl;

  keys.push_back("exp68");
  keys.push_back("exp95");
  keys.push_back("exp99");

  // uncommented below to plot observed!
  keys.push_back("obs95");

  TGraph2D *grobs = new TGraph2D();
  TGraph2D *grexp = new TGraph2D();

  m_graphs["obs95"] = grobs;
  m_graphs["exp95"] = grexp;

  grobs->SetName("graph2Dobs95");
  grexp->SetName("graph2Dexp95");

  Int_t nobs=0, nexp=0;

  for( size_t i=0; i<fnames.size(); i++) {
    
    TFile *f = new TFile(fnames[i]);
    TTree *t = (TTree *) f->Get("limit");

    if (!t) { 
      std::cerr<<"TFile "<<f->GetName()<<" does not contain the tree"<<std::endl;
      return;
    }
    cout << fnames[i] << " has limit tree with " << t->GetEntries() << " entries." << endl;

    Float_t deltaNLL, par1, par2;
    Int_t iToy;

    t->SetBranchAddress("iToy", &iToy);
    t->SetBranchAddress("deltaNLL", &deltaNLL);
    t->SetBranchAddress(par1name, &par1);
    t->SetBranchAddress(par2name, &par2);

    for (size_t j = 0, n = t->GetEntries(); j < n; ++j) {
      t->GetEntry(j);
      printf ("%d\r",j);
      if( !iToy){
	//	cout <<"!iToy" << endl;
	grobs->SetPoint(nobs++,par1,par2,2*deltaNLL);
	//	cout <<"grobs->SetPoint("<<nobs++<<","<<par1<<","<< par2<< ","<< 2*deltaNLL << endl;
      }
      else if (iToy == -1) {
	//	cout <<"iToy == -1" << endl;
	grexp->SetPoint(nexp++,par1,par2,2*deltaNLL);
      }
      else {
	cerr << "Unexpected value for iToy, = " << iToy << endl;
	exit(-1);
      }
    } // tree entry loop

    f->Close();
    delete f;

  } // file loop
  cout << endl;

  m_graphs["exp68"] = (TGraph2D*)grexp->Clone("graph2Dexp68");
  m_graphs["exp99"] = (TGraph2D*)grexp->Clone("graph2Dexp99");

#if 0
  TCanvas *canv = new TCanvas("tester","tester",500,500);
  cout << grexp->GetN()<<" points. " <<endl;
  grexp->Draw("TRI"); // cont 5z list");
#endif
}                                         // fillGraphsFromFilesDeltaNLL
コード例 #11
0
  PadBoundaries PlotBundle::calculatePadBoundaries() const {
    PadBoundaries union_pad_boundaries;
    bool nothing_drawn(true);

    std::vector<DrawableDataObjectDrawOptionPair<TH1*> >::const_iterator hist_it;

    for (hist_it = histograms.begin(); hist_it != histograms.end(); hist_it++) {
      TH1* hist = hist_it->data_object;
      std::string draw_option(hist_it->draw_option);
      if (hist) {
        hist->Draw(draw_option.c_str());
        if (plot_axis.x_axis_range.active)
          hist->GetXaxis()->SetRangeUser(plot_axis.x_axis_range.low,
              plot_axis.x_axis_range.high);
        PadBoundaries current_pad_boundaries(*hist);

        if (nothing_drawn) {
          union_pad_boundaries = current_pad_boundaries;
          nothing_drawn = false;
        } else {
          union_pad_boundaries = union_pad_boundaries.getUnionBoundaries(
              current_pad_boundaries);
        }
      }
    }

    std::vector<DrawableDataObjectDrawOptionPair<TGraph*> >::const_iterator graph_it;

    for (graph_it = graphs.begin(); graph_it != graphs.end(); graph_it++) {
      TGraph* graph = graph_it->data_object;
      std::string draw_option("A");
      draw_option.append(graph_it->draw_option);
      if (graph) {
        graph->Draw(draw_option.c_str());
        if (plot_axis.x_axis_range.active)
          graph->GetXaxis()->SetRangeUser(plot_axis.x_axis_range.low,
              plot_axis.x_axis_range.high);
        PadBoundaries current_pad_boundaries(*graph->GetHistogram());
        if (nothing_drawn) {
          union_pad_boundaries = current_pad_boundaries;
          nothing_drawn = false;
        } else {
          union_pad_boundaries = union_pad_boundaries.getUnionBoundaries(
              current_pad_boundaries);
        }
      }
    }

    std::vector<DrawableDataObjectDrawOptionPair<TGraph2D*> >::const_iterator graph2d_it;

    for (graph2d_it = graphs2d.begin(); graph2d_it != graphs2d.end();
        graph2d_it++) {
      TGraph2D* graph = graph2d_it->data_object;
      std::string draw_option("A");
      draw_option.append(graph2d_it->draw_option);
      if (graph) {
        graph->Draw(draw_option.c_str());
        PadBoundaries current_pad_boundaries(*(TH1*) graph->GetHistogram());
        current_pad_boundaries.is_2d = true;
        current_pad_boundaries.z_min = graph->GetZmin();
        current_pad_boundaries.z_max = graph->GetZmax();
        if (nothing_drawn) {
          union_pad_boundaries = current_pad_boundaries;
          nothing_drawn = false;
        } else {
          union_pad_boundaries = union_pad_boundaries.getUnionBoundaries(
              current_pad_boundaries);
        }
      }
    }

    return union_pad_boundaries;
  }
コード例 #12
0
void view_SMEvents_3D_from_Hits() {
	/*** Displays an 3D occupancy plot for each SM Event. (stop mode event)

	Can choose which SM event to start at. (find "CHOOSE THIS" in this script)
	Input file must be a Hits file (_interpreted_Hits.root file).
	***/
	gROOT->Reset();

	// Setting up file, treereader, histogram
	TFile *f = new TFile("/home/pixel/pybar/tags/2.0.2_new/pyBAR-master/pybar/module_202_new/101_module_202_new_stop_mode_ext_trigger_scan_interpreted_Hits.root");


	if (!f) { // if we cannot open the file, print an error message and return immediately
		cout << "Error: cannot open the root file!\n";
		//return;
	}

	TTreeReader *reader = new TTreeReader("Table", f);

	TTreeReaderValue<UInt_t> h5_file_num(*reader, "h5_file_num");
	TTreeReaderValue<Long64_t> event_number(*reader, "event_number");
	TTreeReaderValue<UChar_t> tot(*reader, "tot");
	TTreeReaderValue<UChar_t> relative_BCID(*reader, "relative_BCID");
	TTreeReaderValue<Long64_t> SM_event_num(*reader, "SM_event_num");
	TTreeReaderValue<Double_t> x(*reader, "x");
	TTreeReaderValue<Double_t> y(*reader, "y");
	TTreeReaderValue<Double_t> z(*reader, "z");

	// Initialize the canvas and graph
	TCanvas *c1 = new TCanvas("c1","3D Occupancy for Specified SM Event", 1000, 10, 900, 550);
	c1->SetRightMargin(0.25);
	TGraph2D *graph = new TGraph2D();

	// Variables used to loop the main loop
	bool endOfReader = false; // if reached end of the reader
	bool quit = false; // if pressed q
	int smEventNum = 1; // the current SM-event CHOOSE THIS to start at desired SM event number
	
	// Main Loop (loops for every smEventNum)
	while (!endOfReader && !quit) {
		// Variables used in this main loop
		int startEntryNum = 0;
		int endEntryNum = 0;
		string histTitle = "3D Occupancy for SM Event ";
		string inString = "";
		bool fitFailed = false; // true if the 3D fit failed
		bool lastEvent = false;

		// Declaring some important output values for the current graph and/or line fit
		int numEntries = 0;
		double sumSquares = 0;

		// Get startEntryNum and endEntryNum
		startEntryNum = getEntryNumWithSMEventNum(reader, smEventNum);
		endEntryNum = getEntryNumWithSMEventNum(reader, smEventNum + 1);

		if (startEntryNum == -2) { // can't find the smEventNum
			cout << "Error: There should not be any SM event numbers that are missing." << "\n";
		} else if (startEntryNum == -3) { 
			endOfReader = true;
			break;
		} else if (endEntryNum == -3) { // assuming no SM event nums are skipped
			endEntryNum = reader->GetEntries(false);
			lastEvent = true;
		}

		// Fill TGraph with points and set title and axes
		graph = new TGraph2D(); // create a new TGraph to refresh

		reader->SetEntry(startEntryNum);
		for (int i = 0; i < endEntryNum - startEntryNum; i++) {
			graph->SetPoint(i, (*x - 0.001), (*y + 0.001), (*z - 0.001));
			endOfReader = !(reader->Next());
		}

		histTitle.append(to_string(smEventNum));
		graph->SetTitle(histTitle.c_str());
		graph->GetXaxis()->SetTitle("x (mm)");
		graph->GetYaxis()->SetTitle("y (mm)");
		graph->GetZaxis()->SetTitle("z (mm)");

		graph->GetXaxis()->SetLimits(0, 20); // ROOT is buggy, x and y use setlimits()
		graph->GetYaxis()->SetLimits(-16.8, 0); // but z uses setrangeuser()
		graph->GetZaxis()->SetRangeUser(0, 40.96);
		c1->SetTitle(histTitle.c_str());

		// 3D Fit, display results, draw graph and line fit, only accept "good" events, get input
		if (!endOfReader || lastEvent) {
			// Display some results
			numEntries = graph->GetN();
			cout << "Current SM Event Number: " << smEventNum << "\n";
			cout << "Number of entries:       " << numEntries << "\n";

			// Starting the fit. First, get decent starting parameters for the fit - do two 2D fits (one for x vs z, one for y vs z)
			TGraph *graphZX = new TGraph();
			TGraph *graphZY = new TGraph();
			reader->SetEntry(startEntryNum);
			for (int i = 0; i < endEntryNum - startEntryNum; i++) {
				graphZX->SetPoint(i, (*z - 0.001), (*x + 0.001));
				graphZY->SetPoint(i, (*z - 0.001), (*y + 0.001));
				reader->Next();
			}
			TFitResultPtr fitZX = graphZX->Fit("pol1", "WQS"); // w for ignore error of each pt, q for quiet (suppress results output), s for return a tfitresultptr
			TFitResultPtr fitZY = graphZY->Fit("pol1", "WQS");
			Double_t param0 = fitZX->GetParams()[0];
			Double_t param1 = fitZX->GetParams()[1];
			Double_t param2 = fitZY->GetParams()[0];
			Double_t param3 = fitZY->GetParams()[1];

			// // Draw the lines for the two 2D fits
			// int n = 2;
			// TPolyLine3D *lineZX = new TPolyLine3D(n);
			// TPolyLine3D *lineZY = new TPolyLine3D(n);
			// lineZX->SetPoint(0, param0, 0, 0);
			// lineZX->SetPoint(1, param0 + param1 * 40.96, 0, 40.96);
			// lineZX->SetLineColor(kBlue);
			// lineZX->Draw("same");
			// lineZY->SetPoint(0, 0, param2, 0);
			// lineZY->SetPoint(1, 0, param2 + param3 * 40.96, 40.96);
			// lineZY->SetLineColor(kGreen);
			// lineZY->Draw("same");


			// 3D FITTING CODE (based on line3Dfit.C), draw graph and line fit
			ROOT::Fit::Fitter  fitter;
		   	SumDistance2 sdist(graph);
#ifdef __CINT__
		   	ROOT::Math::Functor fcn(&sdist,4,"SumDistance2");
#else
		   	ROOT::Math::Functor fcn(sdist,4);
#endif
			// set the function and the initial parameter values
			double pStart[4] = {param0,param1,param2,param3};
			fitter.SetFCN(fcn,pStart);
			// set step sizes different than default ones (0.3 times parameter values)
			for (int i = 0; i < 4; ++i) fitter.Config().ParSettings(i).SetStepSize(0.01);

			bool ok = fitter.FitFCN();
			if (!ok) {
			  Error("line3Dfit","Line3D Fit failed");
			  fitFailed = true;
			} else {
				const ROOT::Fit::FitResult & result = fitter.Result();
				const double * fitParams = result.GetParams();

				sumSquares = result.MinFcnValue();
				std::cout << "Sum of distance squares:  " << sumSquares << std::endl;
				std::cout << "Sum of distance squares divided by numEntries: " << sumSquares/numEntries << std::endl;
				std::cout << "Theta : " << TMath::ATan(sqrt(pow(fitParams[1], 2) + pow(fitParams[3], 2))) << std::endl;
				// result.Print(std::cout); // (un)suppress results output

				// Draw the graph
				graph->SetMarkerStyle(8);
				graph->SetMarkerSize(0.5);
				graph->Draw("pcol");

				// Draw the fitted line
				int n = 1000;
				double t0 = 0; // t is the z coordinate
				double dt = 40.96;
				TPolyLine3D *l = new TPolyLine3D(n);
				for (int i = 0; i <n;++i) {
				  double t = t0+ dt*i/n;
				  double x,y,z;
				  line(t,fitParams,x,y,z);
				  l->SetPoint(i,x,y,z);
				}
				l->SetLineColor(kRed);
				l->Draw("same");

				// Access fit params and minfcnvalue
				// cout << "FIT1: " << fitParams[1] << "\n";
				// cout << "FIT2: " << result.MinFcnValue() << "\n";
			}

			// Criteria to be a good event (if not good entry, then don't show)
			bool isGoodEvent = false;

				// the following block of code finds the mean X, Y ans Z values
				double meanX = 0;
				double meanY = 0;
				double meanZ = 0;
				reader->SetEntry(startEntryNum);
				for (int i = 0; i < endEntryNum - startEntryNum; i++) {
					meanX += graph->GetX()[i];
					meanY += graph->GetY()[i];
					meanZ += graph->GetZ()[i];
					reader->Next();
				}
				meanX /= endEntryNum - startEntryNum;
				meanY /= endEntryNum - startEntryNum;
				meanZ /= endEntryNum - startEntryNum;

				// the following code block calculates the fraction of the hits in the smEvent that are inside a sphere, centered at the mean XYZ, of radius 'radius' (larger fraction means the track is less like a long streak and more like a dense blob)
				double radius = 1; // length in mm 
				double fractionInsideSphere = 0;
				reader->SetEntry(startEntryNum);
				for (int i = 0; i < endEntryNum - startEntryNum; i++) {
					double distanceFromMeanXYZ = sqrt(pow(graph->GetX()[i] - meanX, 2) + pow(graph->GetY()[i] - meanY, 2) + pow(graph->GetZ()[i] - meanZ, 2));
					if (distanceFromMeanXYZ <= 2) {
						fractionInsideSphere += 1;
					}
					reader->Next();
				}
				fractionInsideSphere /= endEntryNum - startEntryNum;

				cout << "fraction inside sphere: " << fractionInsideSphere << "\n";

			// if (numEntries >= 50 
			// 	&& sumSquares/numEntries < 2.0 
			// 	&& fractionInsideSphere < 0.8) {

			// 	isGoodEvent = true;
			// }

			isGoodEvent = true;

			if (isGoodEvent) { // won't show drawings or ask for input unless its a good event
				c1->Update(); // show all the drawings
				// handle input
				bool inStringValid = false;
	            do {
		            cout << "<Enter>: next event; 'b': previous SM event; [number]: specific SM event number; 'q': quit.\n";
		            getline(cin, inString);

		            // Handles behavior according to input
		            if (inString.empty()) { // <Enter>
		            	// leave things be
						inStringValid = true;
		            } else if (inString.compare("b") == 0) {
						smEventNum -= 2; // because it gets incremented once at the end of this do while loop
						inStringValid = true;
					} else if (inString.compare("q") == 0 || inString.compare(".q") == 0) {
						quit = true;
						inStringValid = true;
					} else if (canConvertStringToPosInt(inString)) {
						smEventNum = convertStringToPosInt(inString) - 1; // -1 because it gets incremented once at the end of this do while loop
						inStringValid = true;
					} // else, leave inStringValid as false, so that it asks for input again
				} while (!inStringValid);
			} else {
				cout << "\n";
			}

		}
		smEventNum++;
	}

	cout << "Exiting program.\n";
}
コード例 #13
0
ファイル: kdTreeBinning.C プロジェクト: MycrofD/root
void kdTreeBinning() {

   // -----------------------------------------------------------------------------------------------
   //  C r e a t e  r a n d o m  s a m p l e  w i t h  r e g u l a r  b i n n i n g  p l o t t i n g
   // -----------------------------------------------------------------------------------------------

   const UInt_t DATASZ = 10000;
   const UInt_t DATADIM = 2;
   const UInt_t NBINS = 50;

   Double_t smp[DATASZ * DATADIM];

   double mu[2] = {0,2};
   double sig[2] = {2,3};
   TRandom3 r;
   r.SetSeed(1);
   for (UInt_t i = 0; i < DATADIM; ++i)
      for (UInt_t j = 0; j < DATASZ; ++j)
         smp[DATASZ * i + j] = r.Gaus(mu[i], sig[i]);

   UInt_t h1bins = (UInt_t) sqrt(NBINS);

   TH2D* h1 = new TH2D("h1BinTest", "Regular binning", h1bins, -5., 5., h1bins, -5., 5.);
   for (UInt_t j = 0; j < DATASZ; ++j)
      h1->Fill(smp[j], smp[DATASZ + j]);


   // ---------------------------------------------------------------------------------------------
   // C r e a t e  K D T r e e B i n n i n g  o b j e c t  w i t h  T H 2 P o l y  p l o t t i n g
   // ---------------------------------------------------------------------------------------------

   TKDTreeBinning* kdBins = new TKDTreeBinning(DATASZ, DATADIM, smp, NBINS);

   UInt_t nbins = kdBins->GetNBins();
   UInt_t dim   = kdBins->GetDim();

   const Double_t* binsMinEdges = kdBins->GetBinsMinEdges();
   const Double_t* binsMaxEdges = kdBins->GetBinsMaxEdges();

   TH2Poly* h2pol = new TH2Poly("h2PolyBinTest", "KDTree binning", kdBins->GetDataMin(0), kdBins->GetDataMax(0), kdBins->GetDataMin(1), kdBins->GetDataMax(1));

   for (UInt_t i = 0; i < nbins; ++i) {
      UInt_t edgeDim = i * dim;
      h2pol->AddBin(binsMinEdges[edgeDim], binsMinEdges[edgeDim + 1], binsMaxEdges[edgeDim], binsMaxEdges[edgeDim + 1]);
   }

   for (UInt_t i = 1; i <= kdBins->GetNBins(); ++i)
      h2pol->SetBinContent(i, kdBins->GetBinDensity(i - 1));

   std::cout << "Bin with minimum density: " << kdBins->GetBinMinDensity() << std::endl;
   std::cout << "Bin with maximum density: " << kdBins->GetBinMaxDensity() << std::endl;

   TCanvas* c1 = new TCanvas("glc1", "TH2Poly from a kdTree",0,0,600,800);
   c1->Divide(1,3);
   c1->cd(1);
   h1->Draw("lego");

   c1->cd(2);
   h2pol->Draw("COLZ L");
   c1->Update();


   /* Draw an equivalent plot showing the data points */
   /*-------------------------------------------------*/

   std::vector<Double_t> z = std::vector<Double_t>(DATASZ, 0.);
   for (UInt_t i = 0; i < DATASZ; ++i)
      z[i] = (Double_t) h2pol->GetBinContent(h2pol->FindBin(smp[i], smp[DATASZ + i]));

   TGraph2D *g = new TGraph2D(DATASZ, smp, &smp[DATASZ], &z[0]);
   gStyle->SetPalette(1);
   g->SetMarkerStyle(20);

   c1->cd(3);
   g->Draw("pcol");
   c1->Update();

   // ---------------------------------------------------------
   // make a new TH2Poly where bins are ordered by the density
   // ---------------------------------------------------------

   TH2Poly* h2polrebin = new TH2Poly("h2PolyBinTest", "KDTree binning", kdBins->GetDataMin(0), kdBins->GetDataMax(0), kdBins->GetDataMin(1), kdBins->GetDataMax(1));
   h2polrebin->SetFloat();

   /*---------------------------------*/
   /* Sort the bins by their density  */
   /*---------------------------------*/

   kdBins->SortBinsByDensity();

   for (UInt_t i = 0; i < kdBins->GetNBins(); ++i) {
      const Double_t* binMinEdges = kdBins->GetBinMinEdges(i);
      const Double_t* binMaxEdges = kdBins->GetBinMaxEdges(i);
      h2polrebin->AddBin(binMinEdges[0], binMinEdges[1], binMaxEdges[0], binMaxEdges[1]);
   }

   for (UInt_t i = 1; i <= kdBins->GetNBins(); ++i){
      h2polrebin->SetBinContent(i, kdBins->GetBinDensity(i - 1));}

   std::cout << "Bin with minimum density: " << kdBins->GetBinMinDensity() << std::endl;
   std::cout << "Bin with maximum density: " << kdBins->GetBinMaxDensity() << std::endl;

   // now make a vector with bin number vs position
   for (UInt_t i = 0; i < DATASZ; ++i)
     z[i] = (Double_t) h2polrebin->FindBin(smp[i], smp[DATASZ + i]);

   TGraph2D *g2 = new TGraph2D(DATASZ, smp, &smp[DATASZ], &z[0]);
   g2->SetMarkerStyle(20);


   // plot new TH2Poly (ordered one) and TGraph2D
   // The new TH2Poly has to be same as old one and the TGraph2D should be similar to
   // the previous one. It is now made using as z value the bin number

   TCanvas* c4 = new TCanvas("glc4", "TH2Poly from a kdTree (Ordered)",50,50,800,800);

   c4->Divide(2,2);
   c4->cd(1);
   h2polrebin->Draw("COLZ L");  // draw as scatter plot

   c4->cd(2);
   g2->Draw("pcol");

   c4->Update();

   // make also the 1D binned histograms

   TKDTreeBinning* kdX = new TKDTreeBinning(DATASZ, 1, &smp[0], 20);
   TKDTreeBinning* kdY = new TKDTreeBinning(DATASZ, 1, &smp[DATASZ], 40);


  kdX->SortOneDimBinEdges();
  kdY->SortOneDimBinEdges();

  TH1* hX=new TH1F("hX", "X projection", kdX->GetNBins(), kdX->GetOneDimBinEdges());
  for(int i=0; i<kdX->GetNBins(); ++i){
    hX->SetBinContent(i+1, kdX->GetBinDensity(i));
  }

  TH1* hY=new TH1F("hY", "Y Projection", kdY->GetNBins(), kdY->GetOneDimBinEdges());
  for(int i=0; i<kdY->GetNBins(); ++i){
    hY->SetBinContent(i+1, kdY->GetBinDensity(i));
  }

  c4->cd(3);
  hX->Draw();
  c4->cd(4);
  hY->Draw();
}
コード例 #14
0
void PlotSVMopt(){

 //  // TString FileData = "SVMoptData.dat";
//   TFile *f = new TFile("SVMoptTree.root","RECREATE");
//   TTree *T = new TTree("SVMoptTree","data from ascii file");
//   Long64_t nlines = T->ReadFile("SVMoptData.dat","Gamma:C:ROCint:SigAt1Bkg_test:SigAt1Bkg_train");
//   printf(" found %lld pointsn",nlines);
//   T->Write();

// TGraph2D *grROCint = new TGraph2D();
//  for(int i=0;i<nlines;i++){

//    grROCint->SetPoint(i,);
//  }

  TGraph2D *grROCint = new TGraph2D();
  

TGraph2D *grSigAt1Bkg_test = new TGraph2D();
TGraph2D *grOverTrain = new TGraph2D();

 TString dir = gSystem->UnixPathName(__FILE__);
 dir.ReplaceAll("PlotSVMopt.C","");
 dir.ReplaceAll("/./","/");
 ifstream in;
 // in.open(Form("%sSVMoptData.dat",dir.Data()));
 in.open(Form("%sSVMoptData_NEW2.dat",dir.Data()));

 Float_t Gamma,C,ROCint, SigAt1Bkg_test, SigAt1Bkg_train;
 Int_t nlines = 0;
 while (1) {
   in >> Gamma >> C >> ROCint >> SigAt1Bkg_test >> SigAt1Bkg_train;
   if (!in.good()) break;
   // if (in.good()){
      if (nlines < 5) printf("Gamma=%8f, C=%8f, ROCint=%8f\n",Gamma, C, ROCint);
      grROCint->SetPoint(nlines,Gamma,C,ROCint);
      grSigAt1Bkg_test->SetPoint(nlines,Gamma,C,SigAt1Bkg_test);
      grOverTrain->SetPoint(nlines,Gamma,C,fabs(SigAt1Bkg_train-SigAt1Bkg_test));
      nlines++;
      //   }
   }
   printf(" found %d points\n",nlines);
   in.close();
   TCanvas *cSVMopt = new TCanvas("cSVMopt","SVM model choice",600,600);
   cSVMopt->Divide(2,2);
   cSVMopt->cd(1);
   cSVMopt_1->SetLogx();
   cSVMopt_1->SetLogy();
   grROCint->GetXaxis()->SetLabelSize(0.04);
   grROCint->GetYaxis()->SetLabelSize(0.04);
   grROCint->GetZaxis()->SetLabelSize(0.04);
   grROCint->GetXaxis()->SetTitle("#gamma");
   grROCint->GetYaxis()->SetTitle("C");
   grROCint->GetZaxis()->SetTitle("ROC integral");
   grROCint->SetTitle("ROC integral");
   grROCint->SetMaximum(1.0);
   grROCint->SetMinimum(0.9);
   grROCint->Draw("COLZ");
   cSVMopt->cd(2);
   cSVMopt_2->SetLogx();
   cSVMopt_2->SetLogy();
   grSigAt1Bkg_test->SetTitle("Signal at 1% Bkg level (test)");
   //   grSigAt1Bkg_test->Draw("surf1");
   grSigAt1Bkg_test->Draw("COLZ");
   cSVMopt->cd(3);
   cSVMopt_3->SetLogx();
   cSVMopt_3->SetLogy();
   grOverTrain->SetTitle("Overtraining");
   grOverTrain->Draw("COLZ");
   //cSVMopt->SaveAs("SVMoptC1.root");
}
コード例 #15
0
ファイル: graph_main.cpp プロジェクト: wutzi15/Laser
int main(int argc , char* argv[]){
		
		//Program Options

	po::options_description desc("Allowed Options");
	desc.add_options()
		 ("help,h", "Produce this help message")
		 ("startwl,s",po::value<double>(),"Set the start Wavelength for the Analysis")
		 ("stopwl,p",po::value<double>(),"Set the stop Wavelength for the Analysis")
		 ("non-interactive,n","Runs the program in Noninteractive mode. It quits when it's finished")
		 ("version,v","Prints Version")
	;
		 
	po::variables_map vm;
		 po::store(po::parse_command_line(argc,argv,desc),vm);
		 po::notify(vm);
	if (vm.count("help")) {
		std::cout << desc<< std::endl;
		return 3;
	}
	if (vm.count("version")) {
		std::cout << "VCSEL Laser Analysis Version " << _VERSION << std::endl;
		std::cout << "Using ROOT version " << _ROOT_VERSION << " and Boost version " << _BOOST_VERSION << std::endl;
		return 0;
	}
	
	if (argc < 4) {
		std::cout << desc;
		return 2;
	}	
	double startwl, stopwl;
	startwl = 842.;
	stopwl = 860.;
	bool run = true;
	if (vm.count("startwl")) {
		startwl = vm["startwl"].as<double>();
		NUM_ARGS +=2;
	}
	if (vm.count("stopwl")) {
		double tmp =  vm["stopwl"].as<double>();
		stopwl =tmp;
		NUM_ARGS +=2;
	}
	if (vm.count("non-interactive")) {
		run = false;
		NUM_ARGS++;
	}
	
	
	//checking filetypes must be txt, csv or CSV
	if (!check_extensions(argc, argv)) {
		return 1;
	}
	std::cout <<"startwl: "<< startwl << '\t' << "stopwl: " << stopwl << std::endl;
	
	Double_t max = -210;
	Double_t maxwl = 0;
	int _argc = argc;
	TApplication *t = new TApplication("big",&_argc,argv);
	std::cout << "Running with boost and ROOT" <<std::endl;
	std::vector<double> _x,_y;
	Double_t x[LINES], y[LINES], _inta[LINES], _intb[LINES]; 
	
	Double_t *cmp_int = new Double_t[argc];
	Double_t *argc_ary = new Double_t[argc];
	Double_t *cmp_int_root = new Double_t[argc];
	Double_t *asymmety_ary = new Double_t[argc];
	Double_t *width_ary = new Double_t [argc];
	

	
	TGraph2D *gr = new TGraph2D(LINES*(argc-1));
		//Setting up canvas for plot of all sectrums (is it called spectrums? ;) )
	TCanvas *c1 = new TCanvas("All Plots","All Plots",10,10,3000,1500);
	TH1F *integral_hist = new TH1F("Asymmerty", "Asymmetry", 100,0, 100);
	

	if(!(argc % ROWS)){
		c1->Divide(argc/ROWS,ROWS);
		
	}else{
		c1->Divide(argc/ROWS+(argc %ROWS -1),ROWS);
	}
	
	for (Int_t i = NUM_ARGS +1; i < argc ; i++){
		try{ 
			
			max = -211;
			maxwl = 0;
			argc_ary[i] = i-NUM_ARGS;
			
			std::ifstream in;
			in.seekg(0, std::ios::beg);
				// voodoo keep this;
			char **arg1 = t->Argv() ;
			std::string tmp = arg1[i];
			in.open(tmp.c_str());
			
			std::cout<< "file: " << tmp << std::endl;
			std::string line;
			int cline = 0;
			std::vector<double> a,b, inta, intb;
			
				//reading file
			
			while(getline(in,line)){
				read_file(line, a, b, inta, intb);
				cline++;
			}
			
			if (cline < LINES){
				for(int i = cline ; i < LINES ; i++){
					a.push_back(100);
					b.push_back(-70);
				}
			}
			std::cout<< "\n\ncline: " << cline<< std::endl; 
			cline =(cline > LINES) ? LINES :cline;
			
			for(Int_t j = 0; j <LINES ;j++){
				x[j] = a[j];
				y[j] = b[j];
				_inta[j] = inta[j];
				_intb[j]= (intb[j] < 0)? 0:intb[j];
			}
			
			
			
			double s_integral = 0;
			
			std::cout <<"size of int " <<  intb.size()<< std::endl;
			for (size_t it = 0; it < intb.size() - 1; it++){
				double y_val = (intb[it]+intb[it+1])/2;
				assert (y_val >= 0);
				double area = 0.002*y_val;
				if(area > 0 )
					s_integral += area;
			}
			
			
			
			
			std::cout << "Simpson integral: " <<s_integral <<std::endl;
			integral_hist->Fill(s_integral);
			cmp_int[i] = s_integral;
			Int_t lines = (Int_t)intb.size();
			TGraph *r_integral = new TGraph(lines, _inta, _intb);
			
			std::cout << "ROOT integral: " << r_integral->Integral() << std::endl;
			cmp_int_root[i] = r_integral->Integral();
			
				//expanding
				//expand(y, THRS_EXPAND, RATIO_EXPAND, LINES);
			
			
				//Filling TGraph2D
			
			for(Int_t j = 0; j <LINES ; j++){
				if (y[j] > max){
					max = y[j];
					maxwl = x[j];
				}
				gr->SetPoint(j+i*LINES, x[j],i,y[j]);
			}
			
			
			in.seekg(0, std::ios::beg);
			in.close();
			
				//Plotting each spectrum
			
			TGraph *_gr = new TGraph(LINES,x,y);
			_gr->GetHistogram()->GetXaxis()->SetTitle("#lambda in nm");
			_gr->GetHistogram()->GetYaxis()->SetTitle("Intensity in dB");
			c1->cd(i-NUM_ARGS);
			_gr->Draw("AP");
			_gr->GetYaxis()->SetRangeUser(-80.,-10.);
			_gr->GetXaxis()->SetRangeUser(startwl,stopwl);
			_gr->SetTitle(tmp.c_str());
			c1->Update();
			
			
				//Calculating asymmetry
			std::cout << "maximum: " << max << std::endl;
			double leftlimit, rightlimit = 1;
			leftlimit = findlower(x,y, max);
			rightlimit = findupper(x,y, max);
			if (leftlimit != 1 && rightlimit != 1){
				width_ary[i] = (leftlimit +rightlimit)/2;
			}else{
				width_ary[i] = maxwl;
			}
			double calced_asy = (maxwl-leftlimit)/(rightlimit-maxwl);
			asymmety_ary[i-NUM_ARGS] = calced_asy;
			
			std::cout << "Asymmetry: " << calced_asy << std::endl;
			
		}catch(std::exception e){
			std::cout << e.what()<< std::endl;
		}
	}
	
	
		//Setting style for 3D Plot
	TCanvas *d = new TCanvas("big","big",10,10,1500,800);
	d->Divide(2,2);
	d->cd(1);
	TGraph *the_ints = new TGraph(argc-1,argc_ary,cmp_int);
	the_ints->Draw("A*");
	the_ints->SetTitle("My Ints");
	d->Update();
	d->cd(2);
	std::cout << "Fitting\n\n";
	integral_hist->SetFillColor(kBlue);
		//settig everything to print fitresuts
	gStyle->SetOptStat(1211);
	gStyle->SetOptFit(1111);
	integral_hist->Draw();
	integral_hist->Fit("gaus","W","" ,10,100);
		//integral_hist->Draw("SAME");
	d->Update();
	d->cd(3);
	
	TGraph *roots_int = new TGraph(argc-1, argc_ary, cmp_int_root);
	roots_int->SetTitle("ROOTS Int");
	roots_int->Draw("A*");
	d->Update();
	d->cd(4);
	d->Update();
		//gROOT->SetStyle("modern");
	gr->SetTitle("big");
	gr->GetHistogram("empty")->GetXaxis()->SetTitle("#lambda in nm");
	gr->GetHistogram("empty")->GetXaxis()->SetLimits(startwl,stopwl);
	gr->GetHistogram("empty")->GetYaxis()->SetTitle("Messurement"); 
	gr->GetHistogram("empty")->GetZaxis()->SetTitle("Intensity in dB");
	gr->GetHistogram("empty")->GetXaxis()->SetTitleOffset(1.5);
	gr->GetHistogram("empty")->GetYaxis()->SetTitleOffset(1.5);
	gr->GetHistogram("empty")->GetZaxis()->SetTitleOffset(1.5);
	gr->GetHistogram("empty")->GetZaxis()->SetRangeUser(-70.,max);
	gr->GetHistogram("empty")->GetXaxis()->CenterTitle();
	gr->GetHistogram("empty")->GetYaxis()->CenterTitle();
	gr->GetHistogram("empty")->GetZaxis()->CenterTitle();
	gr->Draw("PCOL");
	d->SetFillColor(16);
	
	
#ifdef RENDER
		//Render 3D animation
	const Int_t kUPDATE = 1;
	TSlider *slider = 0;
	
	for (Int_t i = 1; i <= 125; i++){
		TView3D *v = new TView3D();
		v->RotateView(5+i,45+i,d);
			//d->Update();
		
		if(i && (i%kUPDATE)== 0){
			if (i == kUPDATE){
				gr->Draw("PCOL");
				d->Update();
				slider = new TSlider("slider","test",850,-70,856,max);
			}
			if (slider) slider->SetRange(0,Float_t(i)/10000.);
			d->Modified();
			d->Update();
			d->Print("3d.gif+");
		} 
	}
	d->Update();
	d->Print("3d.gif++");
#endif
	
	
		//Saving image
	TImage *img = TImage::Create();
	boost::filesystem::path p(t->Argv(3));
	std::string file = p.parent_path().string();
	file += "_big.png";
	img->FromPad(d);
	img->WriteImage(file.c_str());
		//cleaning
	
	TCanvas *e = new TCanvas("Asymmetry","Asymmetry",10,10,1500,800);
	e->Divide(2,1);
	TGraph *asy_plot = new TGraph(argc-1, argc_ary, asymmety_ary);
	e->cd(1);
	asy_plot->SetTitle("Asymmetry");
	asy_plot->GetHistogram()->GetXaxis()->SetTitle("# Meassurement");
	asy_plot->GetHistogram()->GetYaxis()->SetTitle("Asymmetry");
	asy_plot->GetHistogram()->GetXaxis()->SetRange(1, argc);
	asy_plot->Draw("A*");
	e->Update();
	e->cd(2);
	
	
	TGraph *center_plot = new TGraph(argc-1 , argc_ary, width_ary);
	center_plot->GetHistogram()->GetXaxis()->SetTitle("# Meassurement");
	center_plot->GetHistogram()->GetYaxis()->SetTitle("Center in nm");
	center_plot->GetHistogram()->GetYaxis()->SetRangeUser(startwl, stopwl);
	center_plot->SetTitle("Center");
	center_plot->Draw("A*");
	e->Update();
		//Saving Images
	TImage *secimg = TImage::Create();
	boost::filesystem::path p2(t->Argv(3));
	file = p2.parent_path().string();
	file += "_asy_cent.png";
	secimg->FromPad(e);
	secimg->WriteImage(file.c_str());
	
	TImage *thrdimg = TImage::Create();
	boost::filesystem::path p3(t->Argv(3));
	file = p3.parent_path().string();
	file += "_allplots.png";
	thrdimg->FromPad(c1);
	thrdimg->WriteImage(file.c_str());
	
		//detecting Gradients
	gradient(asymmety_ary, width_ary,cmp_int, argc-1,c1);
	std::cout << "\n\n\nDone !!\nYou can quit now using CTRL+C \n" ;
	
	if (run == true){
		t->Run();
	}
	std::cout << "With \n" ;
	
	delete[] cmp_int;
	delete[] argc_ary; 
	delete[] cmp_int_root;
	delete[] asymmety_ary;
	delete[] width_ary;
	return 0;
}
コード例 #16
0
ファイル: FitXS.C プロジェクト: acarvalh/generateHH
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); 
    }*/
    



    
}
コード例 #17
0
ファイル: graph2dfit.C プロジェクト: Y--/root
TCanvas* graph2dfit()
{
   gStyle->SetOptStat(0);
   gStyle->SetOptFit();

   TCanvas *c = new TCanvas("c","Graph2D example",0,0,600,800);
   c->Divide(2,3);

   Double_t rnd, x, y, z;
   Double_t e = 0.3;
   Int_t nd = 400;
   Int_t np = 10000;

   TRandom r;
   Double_t fl = 6;
   TF2  *f2 = new TF2("f2","1000*(([0]*sin(x)/x)*([1]*sin(y)/y))+200",
      -fl,fl,-fl,fl);
   f2->SetParameters(1,1);
   TGraph2D *dt = new TGraph2D();

   // Fill the 2D graph
   Double_t zmax = 0;
   for (Int_t N=0; N<nd; N++) {
      f2->GetRandom2(x,y);
      // Generate a random number in [-e,e]
      rnd = 2*r.Rndm()*e-e;
      z = f2->Eval(x,y)*(1+rnd);
      if (z>zmax) zmax = z;
      dt->SetPoint(N,x,y,z);
   }

   Double_t hr = 350;
   TH1D *h1 = new TH1D("h1",
   "#splitline{Difference between Original}{#splitline{function and Function}{with noise}}",
   100, -hr, hr);
   TH1D *h2 = new TH1D("h2",
   "#splitline{Difference between Original}{#splitline{function and Delaunay triangles}{interpolation}}",
   100, -hr, hr);
   TH1D *h3 = new TH1D("h3",
   "#splitline{Difference between Original}{function and Minuit fit}",
   500, -hr, hr);

   f2->SetParameters(0.5,1.5);
   dt->Fit(f2);
   TF2 *fit2 = (TF2*)dt->FindObject("f2");

   f2->SetParameters(1,1);

   for (Int_t N=0; N<np; N++) {
      f2->GetRandom2(x,y);
      // Generate a random number in [-e,e]
      rnd = 2*r.Rndm()*e-e;
      z = f2->Eval(x,y)*(1+rnd);
      h1->Fill(f2->Eval(x,y)-z);
      z = dt->Interpolate(x,y);
      h2->Fill(f2->Eval(x,y)-z);
      z = fit2->Eval(x,y);
      h3->Fill(f2->Eval(x,y)-z);
   }

   c->cd(1);
   f2->SetTitle("Original function with Graph2D points on top");
   f2->SetMaximum(zmax);
   gStyle->SetHistTopMargin(0);
   f2->Draw("surf1");
   dt->Draw("same p0");

   c->cd(3);
   dt->SetMargin(0.1);
   dt->SetFillColor(36);
   dt->SetTitle("Histogram produced with Delaunay interpolation");
   dt->Draw("surf4");

   c->cd(5);
   fit2->SetTitle("Minuit fit result on the Graph2D points");
   fit2->Draw("surf1");

   h1->SetFillColor(47);
   h2->SetFillColor(38);
   h3->SetFillColor(29);

   c->cd(2); h1->Fit("gaus","Q") ; h1->Draw();
   c->cd(4); h2->Fit("gaus","Q") ; h2->Draw();
   c->cd(6); h3->Fit("gaus","Q") ; h3->Draw();
   c->cd();
   return c;
}
コード例 #18
0
ファイル: rs101_limitexample.C プロジェクト: Y--/root
void rs101_limitexample()
{
    // --------------------------------------
    // An example of setting a limit in a number counting experiment with uncertainty on background and signal

    // to time the macro
    TStopwatch t;
    t.Start();

    // --------------------------------------
    // The Model building stage
    // --------------------------------------
    RooWorkspace* wspace = new RooWorkspace();
    wspace->factory("Poisson::countingModel(obs[150,0,300], sum(s[50,0,120]*ratioSigEff[1.,0,3.],b[100]*ratioBkgEff[1.,0.,3.]))"); // counting model
    //  wspace->factory("Gaussian::sigConstraint(ratioSigEff,1,0.05)"); // 5% signal efficiency uncertainty
    //  wspace->factory("Gaussian::bkgConstraint(ratioBkgEff,1,0.1)"); // 10% background efficiency uncertainty
    wspace->factory("Gaussian::sigConstraint(gSigEff[1,0,3],ratioSigEff,0.05)"); // 5% signal efficiency uncertainty
    wspace->factory("Gaussian::bkgConstraint(gSigBkg[1,0,3],ratioBkgEff,0.2)"); // 10% background efficiency uncertainty
    wspace->factory("PROD::modelWithConstraints(countingModel,sigConstraint,bkgConstraint)"); // product of terms
    wspace->Print();

    RooAbsPdf* modelWithConstraints = wspace->pdf("modelWithConstraints"); // get the model
    RooRealVar* obs = wspace->var("obs"); // get the observable
    RooRealVar* s = wspace->var("s"); // get the signal we care about
    RooRealVar* b = wspace->var("b"); // get the background and set it to a constant.  Uncertainty included in ratioBkgEff
    b->setConstant();

    RooRealVar* ratioSigEff = wspace->var("ratioSigEff"); // get uncertain parameter to constrain
    RooRealVar* ratioBkgEff = wspace->var("ratioBkgEff"); // get uncertain parameter to constrain
    RooArgSet constrainedParams(*ratioSigEff, *ratioBkgEff); // need to constrain these in the fit (should change default behavior)

    RooRealVar * gSigEff = wspace->var("gSigEff");     // global observables for signal efficiency
    RooRealVar * gSigBkg = wspace->var("gSigBkg");  // global obs for background efficiency
    gSigEff->setConstant();
    gSigBkg->setConstant();

    // Create an example dataset with 160 observed events
    obs->setVal(160.);
    RooDataSet* data = new RooDataSet("exampleData", "exampleData", RooArgSet(*obs));
    data->add(*obs);

    RooArgSet all(*s, *ratioBkgEff, *ratioSigEff);

    // not necessary
    modelWithConstraints->fitTo(*data, RooFit::Constrain(RooArgSet(*ratioSigEff, *ratioBkgEff)));

    // Now let's make some confidence intervals for s, our parameter of interest
    RooArgSet paramOfInterest(*s);

    ModelConfig modelConfig(wspace);
    modelConfig.SetPdf(*modelWithConstraints);
    modelConfig.SetParametersOfInterest(paramOfInterest);
    modelConfig.SetNuisanceParameters(constrainedParams);
    modelConfig.SetObservables(*obs);
    modelConfig.SetGlobalObservables( RooArgSet(*gSigEff,*gSigBkg));
    modelConfig.SetName("ModelConfig");
    wspace->import(modelConfig);
    wspace->import(*data);
    wspace->SetName("w");
    wspace->writeToFile("rs101_ws.root");



    // First, let's use a Calculator based on the Profile Likelihood Ratio
    //ProfileLikelihoodCalculator plc(*data, *modelWithConstraints, paramOfInterest);
    ProfileLikelihoodCalculator plc(*data, modelConfig);
    plc.SetTestSize(.05);
    ConfInterval* lrinterval = plc.GetInterval();  // that was easy.

    // Let's make a plot
    TCanvas* dataCanvas = new TCanvas("dataCanvas");
    dataCanvas->Divide(2,1);

    dataCanvas->cd(1);
    LikelihoodIntervalPlot plotInt((LikelihoodInterval*)lrinterval);
    plotInt.SetTitle("Profile Likelihood Ratio and Posterior for S");
    plotInt.Draw();

    // Second, use a Calculator based on the Feldman Cousins technique
    FeldmanCousins fc(*data, modelConfig);
    fc.UseAdaptiveSampling(true);
    fc.FluctuateNumDataEntries(false); // number counting analysis: dataset always has 1 entry with N events observed
    fc.SetNBins(100); // number of points to test per parameter
    fc.SetTestSize(.05);
    //  fc.SaveBeltToFile(true); // optional
    ConfInterval* fcint = NULL;
    fcint = fc.GetInterval();  // that was easy.

    RooFitResult* fit = modelWithConstraints->fitTo(*data, Save(true));

    // Third, use a Calculator based on Markov Chain monte carlo
    // Before configuring the calculator, let's make a ProposalFunction
    // that will achieve a high acceptance rate
    ProposalHelper ph;
    ph.SetVariables((RooArgSet&)fit->floatParsFinal());
    ph.SetCovMatrix(fit->covarianceMatrix());
    ph.SetUpdateProposalParameters(true);
    ph.SetCacheSize(100);
    ProposalFunction* pdfProp = ph.GetProposalFunction();  // that was easy

    MCMCCalculator mc(*data, modelConfig);
    mc.SetNumIters(20000); // steps to propose in the chain
    mc.SetTestSize(.05); // 95% CL
    mc.SetNumBurnInSteps(40); // ignore first N steps in chain as "burn in"
    mc.SetProposalFunction(*pdfProp);
    mc.SetLeftSideTailFraction(0.5);  // find a "central" interval
    MCMCInterval* mcInt = (MCMCInterval*)mc.GetInterval();  // that was easy


    // Get Lower and Upper limits from Profile Calculator
    cout << "Profile lower limit on s = " << ((LikelihoodInterval*) lrinterval)->LowerLimit(*s) << endl;
    cout << "Profile upper limit on s = " << ((LikelihoodInterval*) lrinterval)->UpperLimit(*s) << endl;

    // Get Lower and Upper limits from FeldmanCousins with profile construction
    if (fcint != NULL) {
        double fcul = ((PointSetInterval*) fcint)->UpperLimit(*s);
        double fcll = ((PointSetInterval*) fcint)->LowerLimit(*s);
        cout << "FC lower limit on s = " << fcll << endl;
        cout << "FC upper limit on s = " << fcul << endl;
        TLine* fcllLine = new TLine(fcll, 0, fcll, 1);
        TLine* fculLine = new TLine(fcul, 0, fcul, 1);
        fcllLine->SetLineColor(kRed);
        fculLine->SetLineColor(kRed);
        fcllLine->Draw("same");
        fculLine->Draw("same");
        dataCanvas->Update();
    }

    // Plot MCMC interval and print some statistics
    MCMCIntervalPlot mcPlot(*mcInt);
    mcPlot.SetLineColor(kMagenta);
    mcPlot.SetLineWidth(2);
    mcPlot.Draw("same");

    double mcul = mcInt->UpperLimit(*s);
    double mcll = mcInt->LowerLimit(*s);
    cout << "MCMC lower limit on s = " << mcll << endl;
    cout << "MCMC upper limit on s = " << mcul << endl;
    cout << "MCMC Actual confidence level: "
         << mcInt->GetActualConfidenceLevel() << endl;

    // 3-d plot of the parameter points
    dataCanvas->cd(2);
    // also plot the points in the markov chain
    RooDataSet * chainData = mcInt->GetChainAsDataSet();

    assert(chainData);
    std::cout << "plotting the chain data - nentries = " << chainData->numEntries() << std::endl;
    TTree* chain =  RooStats::GetAsTTree("chainTreeData","chainTreeData",*chainData);
    assert(chain);
    chain->SetMarkerStyle(6);
    chain->SetMarkerColor(kRed);

    chain->Draw("s:ratioSigEff:ratioBkgEff","nll_MarkovChain_local_","box"); // 3-d box proportional to posterior

    // the points used in the profile construction
    RooDataSet * parScanData = (RooDataSet*) fc.GetPointsToScan();
    assert(parScanData);
    std::cout << "plotting the scanned points used in the frequentist construction - npoints = " << parScanData->numEntries() << std::endl;
    // getting the tree and drawing it -crashes (very strange....);
    // TTree* parameterScan =  RooStats::GetAsTTree("parScanTreeData","parScanTreeData",*parScanData);
    // assert(parameterScan);
    // parameterScan->Draw("s:ratioSigEff:ratioBkgEff","","goff");
    TGraph2D *gr = new TGraph2D(parScanData->numEntries());
    for (int ievt = 0; ievt < parScanData->numEntries(); ++ievt) {
        const RooArgSet * evt = parScanData->get(ievt);
        double x = evt->getRealValue("ratioBkgEff");
        double y = evt->getRealValue("ratioSigEff");
        double z = evt->getRealValue("s");
        gr->SetPoint(ievt, x,y,z);
        // std::cout << ievt << "  " << x << "  " << y << "  " << z << std::endl;
    }
    gr->SetMarkerStyle(24);
    gr->Draw("P SAME");


    delete wspace;
    delete lrinterval;
    delete mcInt;
    delete fcint;
    delete data;

    // print timing info
    t.Stop();
    t.Print();
}