コード例 #1
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
コード例 #2
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";
}
コード例 #3
0
void makeLikelihood(){

   gSystem->Load("libHiggsAnalysisCombinedLimit.so");
   //TFile *fi = TFile::Open("lduscan_neg_ext/3D/lduscan_neg_ext_3D.root");
   TFile *fi = TFile::Open("allthepoints.root");
   TTree *tree = (TTree*)fi->Get("limit");
   //TTree *tree = new TTree("tree_vals","tree_vals");  

   // ------------------------------ THIS IS WHERE WE BUILD THE SPLINE ------------------------ //
   // Create 2 Real-vars, one for each of the parameters of the spline 
   // The variables MUST be named the same as the corresponding branches in the tree
   RooRealVar ldu("lambda_du","lambda_du",0.1,-2.5,2.5); 
   RooRealVar lVu("lambda_Vu","lambda_Vu",0.1,0,3);
   RooRealVar kuu("kappa_uu","kappa_uu",0.1,0,3);
   
   RooSplineND *spline = new RooSplineND("spline","spline",RooArgList(ldu,lVu,kuu),tree,"deltaNLL",1.,true,"deltaNLL<1000 && TMath::Abs(quantileExpected)!=1 && TMath::Abs(quantileExpected)!=0");
   // ----------------------------------------------------------------------------------------- //
   
   //TGraph *gr = spline->getGraph("x",0.1); // Return 1D graph. Will be a slice of the spline for fixed y generated at steps of 0.1
   fOut = new TFile("outplots-2hdm-neg-fine-mssm-final-try2.root","RECREATE");
   // Plot the 2D spline 
   TGraph2D *gr  		= new TGraph2D();  gr->SetName("type1");
   TGraph2D *gr2 		= new TGraph2D();  gr2->SetName("type2");
   TGraph2D *gr_ldu 		= new TGraph2D(); gr_ldu->SetName("ldu");
   TGraph2D *gr_lVu 		= new TGraph2D(); gr_lVu->SetName("lVu");
   TGraph2D *gr_kuu 		= new TGraph2D(); gr_kuu->SetName("kuu");
   TGraph2D *gr2_ldu		= new TGraph2D(); gr2_ldu->SetName("ldu_2");
   TGraph2D *gr2_lVu 		= new TGraph2D(); gr2_lVu->SetName("lVu_2");
   TGraph2D *gr2_kuu 		= new TGraph2D(); gr2_kuu->SetName("kuu_2");
   TGraph2D *gr_t1_lVu_V_kuu    = new TGraph2D(); gr_t1_lVu_V_kuu->SetName("t1_lVu_V_kuu");

   TGraph2D *gr_mssm_ldu 	= new TGraph2D(); gr_mssm_ldu->SetName("mssm_ldu");
   TGraph2D *gr_mssm_lVu 	= new TGraph2D(); gr_mssm_lVu->SetName("mssm_lVu");
   TGraph2D *gr_mssm_kuu 	= new TGraph2D(); gr_mssm_kuu->SetName("mssm_kuu");

   TGraph2D *g_FFS = new TGraph2D(); g_FFS->SetName("ffs_kuu1");
   double x,y,z;
   double mintF = 10000;
   int pt=0 ;
   /*
   for (double x=-1.6;x<=1.6;x+=0.05){
     for (double y=0.5;y<=1.5;y+=0.05){
	ldu.setVal(x);
	lVu.setVal(y);
	kuu.setVal(1);
	double dnll2 = 2*spline->getVal();
	if (dnll2 < mintF) mintF = dnll2;
	g_FFS->SetPoint(pt,x,y,dnll2);
	pt++;
     }
   }
   */

   TGraph2D *gcvcf = new TGraph2D(); gcvcf->SetName("cvcf");
   TGraph2D *gcvcf_kuu = new TGraph2D(); gcvcf_kuu->SetName("cvcf_kuu");
   TGraph2D *gcvcf_lVu = new TGraph2D(); gcvcf_lVu->SetName("cvcf_lVu");
   double mintkvkf = 10000;
   int pt=0 ;
   if (doXCHECK){
   // Sanity check, for ldu = 1, we should resolve kv kf ?
   //
   for (double cv=0.5;cv<=1.4;cv+=0.05){
     for (double cf=0.3;cf<=1.7;cf+=0.05){
	ldu.setVal(1.);
	lVu.setVal(cv/cf);
	kuu.setVal(cf*cf/gamma(cv,cf,cf));
	double dnll2 = 2*spline->getVal();
	if (dnll2 < mintkvkf) mintkvkf = dnll2;
	gcvcf->SetPoint(pt,cv,cf,dnll2);
	gcvcf_lVu->SetPoint(pt,cv,cf,lVu.getVal());
	gcvcf_kuu->SetPoint(pt,cv,cf,kuu.getVal());
	pt++;
     }
   }
   std::cout << " Min cV-cF = " << mintkvkf << std::endl;
   for (int p=0;p<gcvcf->GetN();p++){
        double z = (gcvcf->GetZ())[p] - mintkvkf;
        double x = (gcvcf->GetX())[p];
        double y = (gcvcf->GetY())[p];
	gcvcf->SetPoint(p,x,y,z);
   }
   }


   double Vldu, VlVu, Vkuu;

   int pt = 0;
   double mint2 = 10000;
   double mint1 = 10000;

   if (doTHDM){
   for (double scbma=-1;scbma<1;scbma+=0.01){
     for (double b=0.01;b<1.45;b+=0.01){
        double tanb = TMath::Tan(b);
     	if (tanb>1. ) b+=0.05;
	double cbma;
	if (scbma < 0) cbma = -1*scbma*scbma;
	else cbma = scbma*scbma;
	// Type 1 
	type1(cbma, tanb, &Vldu, &VlVu, &Vkuu);
	if (Vldu > ldu.getMax() || Vldu < ldu.getMin()) {
        	gr->SetPoint(pt,cbma,tanb,10);
	}
	if (VlVu > lVu.getMax() || VlVu < lVu.getMin()) {
        	gr->SetPoint(pt,cbma,tanb,10);
	}
	if (Vkuu > kuu.getMax() || Vkuu < kuu.getMin()) {
        	gr->SetPoint(pt,cbma,tanb,10);
	} else {
          ldu.setVal(Vldu);
          lVu.setVal(VlVu);
          kuu.setVal(Vkuu);
	  double dnll2 = 2*spline->getVal();
	  //std::cout << " pt, cbma, tanb , 2xdeltaNLL " << pt << ", " << cbma << ", " << tanb << ", " << dnll2  << std::endl;
	  if (dnll2 < mint1) mint1 = dnll2;
          gr->SetPoint(pt,cbma,tanb,dnll2);
	}
        gr_ldu->SetPoint(pt,cbma,tanb,Vldu);
        gr_lVu->SetPoint(pt,cbma,tanb,VlVu);
        gr_kuu->SetPoint(pt,cbma,tanb,Vkuu);
	gr_t1_lVu_V_kuu->SetPoint(pt,VlVu,Vkuu,dnll2);
	// Type 2 
	type2(cbma, tanb, &Vldu, &VlVu, &Vkuu);
	if (Vldu > ldu.getMax() || Vldu < ldu.getMin()) {
        	gr2->SetPoint(pt,cbma,tanb,10);
	}
	if (VlVu > lVu.getMax() || VlVu < lVu.getMin()) {
        	gr2->SetPoint(pt,cbma,tanb,10);
	}
	if (Vkuu > kuu.getMax() || Vkuu < kuu.getMin()) {
        	gr2->SetPoint(pt,cbma,tanb,10);
	} else {
          ldu.setVal(Vldu);
          lVu.setVal(VlVu);
          kuu.setVal(Vkuu);
	  double dnll2 = 2*spline->getVal();
	  //std::cout << " pt, cbma, tanb , 2xdeltaNLL " << pt << ", " << cbma << ", " << tanb << ", " << dnll2  << std::endl;
	  if (dnll2 < mint2) mint2 = dnll2;
          gr2->SetPoint(pt,cbma,tanb,dnll2);
	}
	// Fill variables too 
        gr2_ldu->SetPoint(pt,cbma,tanb,Vldu);
        gr2_lVu->SetPoint(pt,cbma,tanb,VlVu);
        gr2_kuu->SetPoint(pt,cbma,tanb,Vkuu);

        pt++;
     }
   }


   std::cout << " T2 minimum 2xdeltaNLL "  << mint2  << std::endl;
   // Need to re-normalise deltaNLL for the type-2 histogram 
   for (int p=0;p<gr2->GetN();p++){
        z = (gr2->GetZ())[p] - mint2;
        x = (gr2->GetX())[p];
        y = (gr2->GetY())[p];
	gr2->SetPoint(p,x,y,z);

        z = (gr->GetZ())[p] - mint1;
        x = (gr->GetX())[p];
        y = (gr->GetY())[p];
	gr->SetPoint(p,x,y,z);
   }
   }


   // MSSM Plot 
   TGraph2D *gr_mssm    = new TGraph2D(); gr_mssm->SetName("mssm");
   
   
   int pt = 0;
   double minmssm = 10000;
   if (doMSSM){
   for (double mA=200;mA<=550;mA+=10){
     for (double b=0.1;b<1.4;b+=0.02){
        double tanb = TMath::Tan(b);
     	if (tanb >10.) b+=0.05;
	// MSSM
	MSSM(mA, tanb, &Vldu, &VlVu, &Vkuu);
	std::cout << " pt, mA, tanb, ldu, lvu, kuu = " << pt << ", " << mA << ", " << tanb << ", " << Vldu << ", " << VlVu << ", " << Vkuu << std::endl;
	if (Vldu > ldu.getMax() || Vldu < ldu.getMin()) {
        	gr_mssm->SetPoint(pt,mA,tanb,10);
	}
	if (VlVu > lVu.getMax() || VlVu < lVu.getMin()) {
        	gr_mssm->SetPoint(pt,mA,tanb,10);
	}
	if (Vkuu > kuu.getMax() || Vkuu < kuu.getMin()) {
        	gr_mssm->SetPoint(pt,mA,tanb,10);
	} else {
	  //std::cout << " pt, mA, tanb, ldu, lvu, kuu = " << pt << ", " << mA << ", " << tanb << ", " << Vldu << ", " << VlVu << ", " << Vkuu << std::endl;
          ldu.setVal(Vldu);
          lVu.setVal(VlVu);
          kuu.setVal(Vkuu);
	  double dnll2 = 2*spline->getVal();
//	  std::cout << " pt, mA, tanb, ldu, lvu, kuu = " << pt << ", " << mA << ", " << tanb << ", " << Vldu << ", " << VlVu << ", " << Vkuu << ", "<<dnll2 <<std::endl;
	  if (dnll2 < minmssm) minmssm = dnll2;
          gr_mssm->SetPoint(pt,mA,tanb,dnll2);
	}
	gr_mssm_ldu->SetPoint(pt,mA,tanb,Vldu);
	gr_mssm_lVu->SetPoint(pt,mA,tanb,VlVu);
	gr_mssm_kuu->SetPoint(pt,mA,tanb,Vkuu);

        pt++;
     }
   }

   for (int p=0;p<gr_mssm->GetN();p++){
        z = (gr_mssm->GetZ())[p] - minmssm;
        x = (gr_mssm->GetX())[p];
        y = (gr_mssm->GetY())[p];
	gr_mssm->SetPoint(p,x,y,z);

   }
   }


  gr->SetMaximum(10);   		
  gr2->SetMaximum(10);  		
  gr_ldu->SetMaximum(10);  	
  gr_lVu->SetMaximum(10);  		
  gr_kuu->SetMaximum(10);  		
  gr2_ldu->SetMaximum(10); gr2_ldu->SetMinimum(-10);		
  gr2_lVu->SetMaximum(10);  		
  gr2_kuu->SetMaximum(10);  		
  gr_t1_lVu_V_kuu->SetMaximum(10);   
  gr_mssm->SetMaximum(10);   
  gr_mssm_ldu->SetMaximum(10);   gr_mssm_ldu->SetMinimum(-10); 
  gr_mssm_lVu->SetMaximum(10);
  gr_mssm_kuu->SetMaximum(10);
  gcvcf->SetMaximum(10);
//   TH2F *h = (TH2F*)gr->GetHistogram(); h->SetName("h_type1"); h->SetMaximum(10);
//   TH2F *h2 = (TH2F*)gr2->GetHistogram(); h2->SetName("h_type2"); h2->SetMaximum(10);
//   TH2F *hmssm = (TH2F*)gr_mssm->GetHistogram(); hmssm->SetName("h_mssm"); hmssm->SetMaximum(10);
//   TH2F *hldu = (TH2F*)gr_ldu->GetHistogram(); hldu->SetName("h_ldu"); hldu->SetMaximum(10);
//   TH2F *hlVu = (TH2F*)gr_lVu->GetHistogram(); hlVu->SetName("h_lVu"); hlVu->SetMaximum(10);
//   TH2F *hkuu = (TH2F*)gr_kuu->GetHistogram(); hkuu->SetName("h_kuu"); hkuu->SetMaximum(10);
//   TH2F *h2ldu = (TH2F*)gr2_ldu->GetHistogram(); h2ldu->SetName("h2_ldu"); h2ldu->SetMaximum(10);
//   TH2F *h2lVu = (TH2F*)gr2_lVu->GetHistogram(); h2lVu->SetName("h2_lVu"); h2lVu->SetMaximum(10);
//   TH2F *h2kuu = (TH2F*)gr2_kuu->GetHistogram(); h2kuu->SetName("h2_kuu"); h2kuu->SetMaximum(10);
//   TH2F *ht1_lVu_V_kuu = (TH2F*) gr_t1_lVu_V_kuu->GetHistogram(); ht1_lVu_V_kuu->SetName("h2_t1_lVu_V_kuu"); ht1_lVu_V_kuu->SetMaximum(10);

   fOut->cd(); 
   gr->Write(); gr2->Write(); 
   gr_ldu->Write(); gr_lVu->Write(); gr_kuu->Write();
   gr2_ldu->Write(); gr2_lVu->Write(); gr2_kuu->Write();
   gr_t1_lVu_V_kuu->Write();
   gr_mssm->Write();
   gcvcf->Write();
   gcvcf_kuu->Write();
   gcvcf_lVu->Write();
   gr_mssm_ldu->Write();
   gr_mssm_lVu->Write();
   gr_mssm_kuu->Write();
   g_FFS->Write();
   
   std::cout << "Saved stuff to -> " << fOut->GetName() << std::endl; 
   fOut->Close();
}
コード例 #4
0
void plotContsSingle(TFile *fOUT, std::string dirname, std::string fin, float X, int keepMDM=10){

   //gSystem->Load("libHiggsAnalysisCombinedLimit.so");
   gROOT->SetBatch(1);

   TFile *fiSignals = TFile::Open("signalsVA.root");
   RooWorkspace *workspace = (RooWorkspace*)fiSignals->Get("combinedws");
   TFile *fiSignalsPS = TFile::Open("signalsPS.root");
   RooWorkspace *workspacePS = (RooWorkspace*)fiSignalsPS->Get("combinedws");

   //TFile *fi = TFile::Open("limits-output.root");
   //TFile *fi = TFile::Open("signal-scans.root");
   TFile *fi = TFile::Open(fin.c_str());
   TTree *tree = (TTree*)fi->Get("limit");

   double mh;
   double limit;
   float quantile;
   tree->SetBranchAddress("mh",&mh);
   tree->SetBranchAddress("limit",&limit);
   tree->SetBranchAddress("quantileExpected",&quantile);

   int nvt = tree->GetEntries();
   
   TGraph2D *grV = new TGraph2D(); grV->SetName("vector");
   TGraph2D *grA = new TGraph2D(); grA->SetName("axial");
   TGraph2D *grS = new TGraph2D(); grS->SetName("scalar");
   TGraph2D *grP = new TGraph2D(); grP->SetName("pseudoscalar");


   TGraph2D *grVs = new TGraph2D(); grVs->SetName("vector_signal");
   TGraph2D *grAs = new TGraph2D(); grAs->SetName("axial_signal");
   TGraph2D *grSs = new TGraph2D(); grSs->SetName("scalar_signal");
   TGraph2D *grPs = new TGraph2D(); grPs->SetName("pseudoscalar_signal");

   int ptV=0;
   int ptA=0;
   int ptS=0;
   int ptP=0;

   TGraph *grV_mMED = new TGraph(); grV_mMED->SetName(Form("vector_mMED_mDM%d",keepMDM));
   TGraph *grA_mMED = new TGraph(); grA_mMED->SetName(Form("axial_mMED_mDM%d",keepMDM));
   TGraph *grS_mMED = new TGraph(); grS_mMED->SetName(Form("scalar_mMED_mDM%d",keepMDM));
   TGraph *grP_mMED = new TGraph(); grP_mMED->SetName(Form("pseudoscalar_mMED_mDM%d",keepMDM));
   int ptVm=0;
   int ptAm=0;
   int ptSm=0;
   int ptPm=0;

   grV_mMED->SetLineWidth(2); grV_mMED->SetMarkerSize(1.0);
   grA_mMED->SetLineWidth(2); grA_mMED->SetMarkerSize(1.0);
   grS_mMED->SetLineWidth(2); grS_mMED->SetMarkerSize(1.0);
   grP_mMED->SetLineWidth(2); grP_mMED->SetMarkerSize(1.0);

   for (int i=0; i<nvt;i++){
     //if ( ! ( i%6==X ) ) continue; // 2 or 5
     tree->GetEntry(i);
     if (quantile!=X) continue;
      
     int cd = code(mh);

     float mmed = MMED(mh,cd);
     float mdm  = MDM(mh,cd);

     // onshell crazyness?
     if ((int)mmed==2*( (int)mdm) ) continue;
     //
     //std::cout << " int X = " << i << std::endl;
     //std::cout << mh << ", " << cd << ", " << mmed << ", " << mdm <<  ", " << limit << std::endl;  
     //std::cout << mh << ", " << Form("monojet_signal_signal_%3d%04d%04d",cd,(int)mmed,(int)mdm) << std::endl; 
     //exit();
     
     //std::vector<std::pair<double,double>> pointsV_mMED;
     //std::vector<std::pair<double,double>> pointsA_mMED;
     //std::vector<std::pair<double,double>> pointsS_mMED;
     //std::vector<std::pair<double,double>> pointsP_mMED;

     RooDataHist *dh; 
     if      (cd==801 || cd==800) dh = (RooDataHist*) workspace->data(Form("monojet_signal_signal_%3d%04d%04d",cd,(int)mmed,(int)mdm));
     else if (cd==805 || cd==806) dh = (RooDataHist*) workspacePS->data(Form("monojet_signal_signal_%3d%04d%04d",cd,(int)mmed,(int)mdm));
     double nsignal = 0;
     if (dh) {
     	nsignal = dh->sumEntries();
     }
     if (cd==800) {
	grVs->SetPoint(ptV,mmed,mdm,nsignal);
     	grV->SetPoint(ptV,mmed,mdm,limit);
	ptV++;
	if ( (int)mdm == keepMDM ) { 
		grV_mMED->SetPoint(ptVm,mmed,limit);
		//pointsV_mMED.push_back(std::mk_pair<double,double>(mmed,limit));
		ptVm++;
	}
     } else if (cd==801){
	grAs->SetPoint(ptA,mmed,mdm,nsignal);
     	grA->SetPoint(ptA,mmed,mdm,limit);
	ptA++;
	if ( (int)mdm == keepMDM ) { 
		grA_mMED->SetPoint(ptAm,mmed,limit);
		ptAm++;
	}
     } else if (cd==805){
	grSs->SetPoint(ptS,mmed,mdm,nsignal);
     	grS->SetPoint(ptS,mmed,mdm,limit);
	ptS++;
	if ( (int)mdm == keepMDM ) { 
		grS_mMED->SetPoint(ptSm,mmed,limit);
		ptSm++;
	}
     } else if (cd==806){
	grPs->SetPoint(ptP,mmed,mdm,nsignal);
     	grP->SetPoint(ptP,mmed,mdm,limit);
	ptP++;
	if ( (int)mdm == keepMDM ) { 
     		//std::cout << mh << ", " << cd << ", " << mmed << ", " << mdm <<  ", " << limit <<std::endl;  
		grP_mMED->SetPoint(ptPm,mmed,limit);
		ptPm++;
	}
     }
   }

   // Add a strip of points to the edges of the graphs as contours suck?
   //
   /*
   dress2d(grV);
   dress2d(grA);
   dress2d(grS);
   dress2d(grP);
   */

   TDirectory *fout = fOUT->mkdir(dirname.c_str());
   //TFile *fout = new TDirectory(); 
   // TFile(Form("fout-%s.root",fin.c_str()),"RECREATE");
   fout->WriteTObject(grV);
   fout->WriteTObject(grA);
   fout->WriteTObject(grS);
   fout->WriteTObject(grP);

   reorderFuckingUselessGraph(grV_mMED);
   reorderFuckingUselessGraph(grA_mMED);
   reorderFuckingUselessGraph(grS_mMED);
   reorderFuckingUselessGraph(grP_mMED);

   fout->WriteTObject(grV_mMED);
   fout->WriteTObject(grA_mMED);
   fout->WriteTObject(grS_mMED);
   fout->WriteTObject(grP_mMED);

   fout->WriteTObject(grVs);
   fout->WriteTObject(grAs);
   fout->WriteTObject(grSs);
   fout->WriteTObject(grPs);
   
   //TGraph2D *grVf = (TGraph2D*) supergraph(grV);
   //TGraph2D *grAf = (TGraph2D*) supergraph(grA);
//   TGraph2D *grSf = (TGraph2D*) supergraph(grS);
//   TGraph2D *grPf = (TGraph2D*) supergraph(grP);

   //fout->WriteTObject(grVf);
   //fout->WriteTObject(grAf);
//   fout->WriteTObject(grSf);
//   fout->WriteTObject(grPf);

 //  limit->Draw("limit: ((Int_t)(mh-80100000000))/10000 : (mh-80100000000)  - ( ((Int_t)(mh-80100000000))/10000 )*10000 ","Entry$%6==2")

}
コード例 #5
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");
}
コード例 #6
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;
}
コード例 #7
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); 
    }*/
    



    
}
コード例 #8
0
Int_t line3dfit_copy()
{
   gStyle->SetOptStat(0);
   gStyle->SetOptFit();


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


//    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);
   // }


   // gr->SetPoint(0, 3, 3, 5);
   // gr->SetPoint(1, 3, 3, 3);
   // gr->SetPoint(2, 4, 3.5, 5);
   // gr->SetPoint(3, 6.2, 7.3, 5.8);
   // gr->SetPoint(4, 9, 8, 7);
   // gr->SetPoint(5, 5, 5, 5);

   gr->SetPoint(0, 19, -4.25, 1.92);
   gr->SetPoint(1, 19, -4.30, 1.92);
   gr->SetPoint(2, 19, -4.35, 1.92);
   gr->SetPoint(3, 19, -4.40, 1.92);
   gr->SetPoint(4, 19, -4.45, 1.92);
   gr->SetPoint(5, 19, -4.50, 1.92);
   gr->SetPoint(6, 19, -4.55, 1.92);
   gr->SetPoint(7, 19, -4.60, 1.92);
   gr->SetPoint(8, 18.75, -4.30, 1.92);
   gr->SetPoint(9, 18.75, -4.35, 1.92);
   gr->SetPoint(10, 18.75, -4.40, 1.92);
   gr->SetPoint(11, 18.75, -4.45, 1.92);
   gr->SetPoint(12, 18.75, -4.50, 1.92);
   gr->SetPoint(13, 18.75, -4.55, 1.92);
   gr->SetPoint(14, 19, -4.20, 2.08);
   gr->SetPoint(15, 19, -4.65, 2.08);
   gr->SetPoint(16, 19, -4.70, 2.08);
   gr->SetPoint(17, 18.75, -4.25, 2.08);
   gr->SetPoint(18, 18.75, -4.60, 2.08);
   // gr->SetPoint(19, 19.001, -4.151, 2.241);
   // gr->SetPoint(20, 18.751, -4.201, 2.241);
   gr->SetPoint(19, 19., -4.15, 2.24);
   gr->SetPoint(20, 18.5723, -4.20, 2.24);

   // gr->SetMarkerStyle(8);
   // gr->Draw("p");
   
   // gr->Draw("p0");
   // TFitResultPtr fit = gr->Fit("pol1", "WS");
   // // fit->Print("V");
   // Double_t p0 = fit->Value(0);
   // Double_t p1 = fit->Value(1);

   // // draw the line
   // TPolyLine3D *l = new TPolyLine3D(2);
   // double dz = 8;
   // l->SetPoint(0,0,0,p0);
   // l->SetPoint(1,dz,0,dz * p1);

   // l->SetLineColor(kRed);
   // l->Draw("same");

   // fit the graph now, and make the functor objet

   ROOT::Fit::Fitter  fitter;

   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); // @@@ suppress output


   // 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");

   // Access to fit params and minfcnvalue
   cout << parFit[1] << "\n";
   cout << result.MinFcnValue() << "\n";


   // // 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
ファイル: 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();
}