void collectContours(map<string,TGraph2D *>& m_graphs,
		     const vector<string>&  keys,
		     map<string,double>& m_contourlevels,
		     map<string,TList *>& m_contours)
{
  cout << "CollectContours" << endl;

  TCanvas *canv = new TCanvas("dummy","dummy",100,100);
  //canv->Divide(3,2);

  std::cout << "keys.size() = " << keys.size() << std::endl;

  //process TGraph2Ds into contours at levels m_contourlevels
  for (size_t i=0; i<keys.size(); i++) {
    double clev = m_contourlevels[keys[i]];
    TGraph2D *gr2d = m_graphs[keys[i]];
    std::cout << "gr2d = " << gr2d << std::endl;
    std::cout << "gr2d->GetN() = " << gr2d->GetN() << std::endl;


    if (gr2d && (gr2d->GetN() > 0)) {
      gr2d->GetHistogram()->SetContour(1, &clev);
      //canv->cd(i+1);
      cout << "drawing... " << endl;

      gr2d->Draw("CONT LIST"); // it's stupid, but only "CONT" will generate the list
      gPad->Update();

      TObjArray *contours = (TObjArray *)gROOT->GetListOfSpecials()->FindObject("contours");
      assert(contours);

      TList *newlist = 0;
      for (int ci=0; ci<contours->GetEntriesFast(); ci++) {
	TList *contLevel = (TList*)contours->At(ci);
	printf("%s: Contour %d has %d Graphs\n", keys[i].c_str(), ci, contLevel->GetSize());

	if (contLevel->GetSize()) {
	  assert(contLevel->First());
	  if (!newlist) newlist = new TList();
	  TGraph *curv = (TGraph*)(contLevel->First());

	  for (int j=0; j<contLevel->GetSize(); j++) {
	    newlist->Add((TGraph *)(curv->Clone()));
	    curv=(TGraph *)(contLevel->After(curv));
	  }
	}
      } // contour loop

      cout << "Inserting contour list for "<< keys[i] << " newlist="<<newlist<<endl;
      m_contours[keys[i]] = newlist;

    } // if (gr2d)
  } // key loop

  //delete canv;
}                                                     // collectContours
Ejemplo n.º 2
0
TGraph* GetContour(TGraph2D *g, TString name){
  TGraph *gnew;
  //cout << g->GetName() << " " << g->GetN() << endl;
  TH2D *temp = (TH2D*)g->GetHistogram();//need this for list to work?
  //g->Draw("alp");//need this for list to work?
  TList *glist = (TList*)g->GetContourList(1.0);
  if(glist == nullptr) return gnew;
  int max_points = -1;
  int nn = glist->GetSize();
  //cout << "number of entries in list " << nn << endl;
  for(int i = 0; i<glist->GetSize(); ++i){
    TGraph *gtemp = (TGraph*)glist->At(i);
    int Npoints = gtemp->GetN();
    if(Npoints>max_points){
      gnew = (TGraph*)gtemp->Clone(name);
      max_points = Npoints;
    }
  }
  return gnew;
}
Ejemplo n.º 3
0
//______________________________________________________________________________
void Draw(TFile* f, const char* gname, TLegend* l, Bool_t normalized)
{
  if (!f) return;

  TGraph* g = static_cast<TGraph*>(f->Get(gname));

  if (!g) return;

  if ( normalized )
  {
    g = static_cast<TGraph*>(g->Clone());
    for ( Int_t i = 0; i < g->GetN(); ++i )
    {
      Double_t y = g->GetY()[i];
      g->SetPoint(i,g->GetX()[i],y/NTOTALNUMBEROFPADS);
    }
  }

  g->Draw("lp");
  g->GetXaxis()->SetNdivisions(505);
  g->GetXaxis()->SetNoExponent();

  if (l) l->AddEntry(g,gname,"LP");
}
Ejemplo n.º 4
0
int main (int argc, char* argv[] )
{
	cout << endl << "Really, REALLY stupid plotter for producing comparative plots between Edinburgh fit outputs." << endl;
	cout << endl << "USAGE: merge_plot Output_1.root Output_2.root \"Title 1\" \"Title 2\" " << endl;
	gStyle->SetCanvasColor(0);
	gStyle->SetFillColor(0);
	gROOT->SetStyle("Plain");
	if( argc != 5) exit(-1);
	TCanvas* c3 = new TCanvas("throw2","throw");
	TFile* input_1 = new TFile( argv[1], "READ" );
	gDirectory->ls();
	TH2D* hist_1 = (TH2D*)gDirectory->Get("pllhist");//"Graph2D");//pllhist");//Graph2D_from_nllhist");
	TGraph2D* graph_1 = (TGraph2D*)gDirectory->Get("pllhist");//"Graph2D");//pllhist");//Graph2D_from_nllhist");
	graph_1->Draw();
	c3->Update();
	TFile* input_2 = new TFile( argv[2], "READ" );
	gDirectory->ls();
	TH2D* hist_2 = (TH2D*)gDirectory->Get("pllhist");//"fcnew");//pllhist");//lr_data");
	TGraph2D* graph_2 = (TGraph2D*)gDirectory->Get("pllhist");//"fcnew");//pllhist");//lr_data");
	graph_2->Draw();
	hist_2->Draw();
	c3->Update();

	TString Plot_Title_1( argv[3] );
	TString Plot_Title_2( argv[4] );

	TCanvas* c1 = new TCanvas("Output_Plot","Output_Plot",1680,1050);
	double pllconts[3] = {1.15,2.305,3.0};//,4.61};
	//double pll2[3] = {2.3,4.61,6};//,9.62};
	//double pll2[3] = {0.68,0.9,0.95};
	double confs[3] = {68.0,90.0,95.0};//,99.0};
	TList* contLevel = NULL;
	TGraph* curv     = NULL;
	TGraph* gc    = NULL;
	//gStyle->SetCanvasColor(0);
	//gStyle->SetPalette(1);
	//gROOT->SetStyle("Plain");
	//gROOT->ForceStyle();
//	gStyle->SetFrameBorderMode(0);
//	gStyle->SetCanvasBorderMode(0);
//	gStyle->SetPadBorderMode(0);
//	gStyle->SetPadColor(0);
//	gStyle->SetCanvasColor(0);
//	gStyle->SetStatColor(0);
//	gStyle->SetTitleFillColor(0);
//	gStyle->SetFillColor(0);
//	gStyle->SetFrameFillColor(0);
	//gStyle->SetFillStyle(0);
	//gROOT->ForceStyle();

	hist_1->SetContour(3,pllconts);
	hist_1->SetLineWidth(1);
	c1->cd();
	hist_1->Draw("cont2");
//	hist_1->GetXaxis()->SetRangeUser(-3.1,2);
	hist_1->SetContour(3,pllconts);
//	c1->cd();
	hist_1->Draw("cont2");
	//	StyleTH2D(hist_2);
//	c3->cd();
	hist_2->Draw();
//	hist_2->GetXaxis()->SetRangeUser(-3.1,2);
//	hist_2->Draw();
	hist_1->Draw("cont2");
//	hist_2->Draw("SAME");//cont2");
	hist_2->SetContour(3,pllconts);//pll2);//pllconts);//pll2);
	hist_2->SetLineColor(2);
	hist_2->SetLineWidth(1);
//	c3->cd();
	c1->Update();
//	hist_2->Draw("SAMEcont2");
//	hist_2->GetXaxis()->SetRangeUser(-3.1,1);
//	hist_2->SetContour(3,pll2);//pllconts);//pll2);
//	c1->cd();
//	hist_2->Draw("SAMEcont2");
//	c1->Update();

	TCanvas* c2 = new TCanvas( "Throw","Throw" );
	hist_1->Draw("CONT LIST");
	c2->Update();

	//addLHCbLabel("NLL Scan")->Draw();
	TObjArray *contObjArr = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
	int TotalConts = contObjArr->GetSize();
	c1->cd();
	TLegend *leg = new TLegend(0.65,0.7,1.1,0.9);
	leg->SetHeader( Plot_Title_1 );
	leg->SetBorderSize(0);
	leg->SetFillStyle(0);
	for(int i = 0; i < TotalConts; i++){
		TString confname = "";
		double cl = confs[i];
		confname +=cl;
		confname += "% C.L.";
		contLevel = (TList*)contObjArr->At(i);
		for(int j =0; j<contLevel->GetSize(); j++){
			curv = (TGraph*)contLevel->At(j);
			gc = (TGraph*)curv->Clone();
			if( i!=3 ) gc->SetLineColor(Color_t(i+2));
			else gc->SetLineColor(Color_t(i+3));
			gc->Draw("L");
		}
		leg->AddEntry(gc,confname, "L");
	}
	c1->cd();
	TLegend *leg2 = new TLegend(0.13,0.7,0.5,0.9);
	leg2->SetHeader( Plot_Title_2 );
	leg2->SetBorderSize(0);
	leg2->SetFillStyle(0);

	c2->cd();
	hist_2->Draw("CONT LIST");
	c2->Update();
	contObjArr = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
	TotalConts = contObjArr->GetSize();
	for(int i = 0; i < TotalConts; i++){
		TString confname = "";
		double cl = confs[i];
		confname +=cl;
		confname += "% C.L.";
		contLevel = (TList*)contObjArr->At(i);
		for(int j =0; j<contLevel->GetSize(); j++){
			curv = (TGraph*)contLevel->At(j);
			gc = (TGraph*)curv->Clone();
			if( i!=3 ) gc->SetLineColor(Color_t(i+2));
			else gc->SetLineColor(Color_t(i+3));
			gc->SetLineStyle(Style_t(i+2));
			c1->cd();
			gc->Draw("L");
			c2->cd();
		}
		leg2->AddEntry(gc,confname, "L");

	}
//	c1->cd();

//	Double_t X_min_1 = strtod( argv[3], NULL );
//	Double_t Y_min_1 = strtod( argv[4], NULL );
//	Double_t X_min_2 = strtod( argv[5], NULL );
//	Double_t Y_min_2 = strtod( argv[6], NULL );

//	c1->cd();
//	TMarker* new_mark = new TMarker( X_min_1, Y_min_1, 20 );
//	new_mark->SetMarkerSize(1);
//	new_mark->SetMarkerColor(8);
	//new_mark->Draw("SAME");
//	TMarker* new_mark2 = new TMarker( X_min_2, Y_min_2, 20 );
//	new_mark2->SetMarkerSize(1);
//	new_mark2->SetMarkerColor(9);
	//new_mark2->Draw("SAME");
//	c1->Update();

	c1->cd();
	leg->Draw();
	leg2->Draw();
	addLHCbLabel("NLL Contours")->Draw();
	c1->Update();
	c1->Print("Output.png");
	c1->Print("Output.pdf");

	input_1->Close();
	input_2->Close();
	return 0;
}
Ejemplo n.º 5
0
void plotMSSM(const TString& what="(ggA+bbA)*BRAZh*BRhbb"){
  const double BRZll=0.06726;
  const double fb2pb=1000;
  //TString scale(Form("*%f*%f",BRZll,fb2pb));
  TString scale("");

  TString cname(what);
  cname.ReplaceAll("*","x");
  cname.ReplaceAll("(","U");
  cname.ReplaceAll(")","U");
  cname+="_MSSM_mhmax";
  //
  TString goodName(what);
  goodName.ReplaceAll("mh","m_{h}");
  goodName.ReplaceAll("ggA","#sigma_{gg#rightarrowA}");
  goodName.ReplaceAll("bbA","#sigma_{bb#rightarrowA}");
  goodName.ReplaceAll("BRAZh","B(A#rightarrowZh)");
  goodName.ReplaceAll("BRhbb","B(h#rightarrowbb)");
  //goodName+=("*B(Z#rightarrowll)");
  //goodName+=("[pb] ");
  goodName+=("[GeV] ");
  TString goodType("MSSM m_{h}^{max}");
  //goodName=("#sigma*B(pp#rightarrowA#rightarrowZh#rightarrowllbb) [fb]");
  //goodName=("#sigma*B(pp#rightarrowA) [fb]");
  //goodName=("BR(A#rightarrowZh)");
  //goodName=("BR(h#rightarrowbb)");

  //if (m>0) mass=(Form(" * (mA==%d)",m));
  //TString ok(" * validity * stability * perturbativity * unitarity ");
  //TString ok(" * unitarity");
  TString ok("");


  TChain* ch=new TChain("TreeMSSM");

  ch->Add("lsf_working_dir_M225_20636539/parameter_MSSM.root");
  ch->Add("lsf_working_dir_M250_20636540/parameter_MSSM.root");
  ch->Add("lsf_working_dir_M275_20636541/parameter_MSSM.root");
  ch->Add("lsf_working_dir_M300_20636542/parameter_MSSM.root");
  ch->Add("lsf_working_dir_M325_20636543/parameter_MSSM.root");
  ch->Add("lsf_working_dir_M350_20636544/parameter_MSSM.root");
  ch->Add("lsf_working_dir_M400_20636545/parameter_MSSM.root");
  ch->Add("lsf_working_dir_M500_20636546/parameter_MSSM.root");
  ch->Add("lsf_working_dir_M600_20636547/parameter_MSSM.root");

  //double tanbeta[30]={1,10,20,30,40,50,60,70,80,90,100,120,140,160,180,200,220,240,260,280,300,400,500,600,700,800,900,1000,1100,10000};
  //double tanbeta[51]={0,10,20,30,40,50,60,70,80,90,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380,400,420,440,460,480,500,550,600,650,700,750,800,850,900,950,1000,1100,1200,1300,1400,1500,2000,3000,4000,5000,6000};
  double tanbeta[51]={0,10,20,30,40,50,60,70,80,90,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380,400,420,440,460,500,550,580,600,650,700,750,800,850,900,950,1000,1100,1200,1300,1400,1500,2000,3000,4000,5000,6000};
  Double_t bin_tb[50];
  for (unsigned int i=0; i<50; i++) {
    bin_tb[i]=0.005*(tanbeta[i]+tanbeta[i+1]);
    //cout << "bin_tb[" << i << "]=" << bin_tb[i] << " " << tanbeta[i+1]/100. << endl;
  }

  double mA[11]={200,225,250,275,300,325,350,400,500,600,700};
  Double_t bin_mA[10];
  for (unsigned int i=0; i<=10; ++i) {
    bin_mA[i]=0.5*(mA[i]+mA[i+1]);
    //cout << "bin_mA["<<i<<"]="  << bin_mA[i] << endl;
  }
  bin_mA[10]=650;
  
  TH2F* hggA=new TH2F("hggA","ggA cross section vs tan#beta,m_{A}; m_{A} GeV; tan#beta",9,bin_mA,49,bin_tb);
  hggA->Sumw2();
  //hggA->Draw();
  TString cut=what+scale+ok;
  cout << "CUT: " << cut << endl;
  ch->Project("hggA","tb:mA",cut);

  TStyle *tdrStyle = gROOT->GetStyle("tdrStyle");
  // Double_t level[15]={.01,.02,.05,.1,.2,.5,1.,2.,5.,10.,20.,50.,100.,200.,500.};
  // hggA->SetContour(14,level);
  // hggA->SetMinimum(level[0]);
  //
  //Double_t level[10]={1.,5.,10.,20.,50.,100.,200.,500.,800.,1000.}; // for x-section
  //Double_t level[10]={100,105,110.,115.,120.,123,125.7,127,130.,135.}; // for mh
  Double_t level[10]={1,2,3.,4.,120.,123,125.7,127,130.,135.}; // for mh
  //Double_t level[10]={.01,.1,.2,0.5,0.6,0.65,0.7,0.75,0.8,0.9}; // for BR
  //Double_t level[10]={.01,.02,.05,.07,.1,.15,0.2,0.5,0.75,1.}; // for BR
  hggA->SetContour(9,level);
  hggA->SetMinimum(level[0]);
  
  Double_t level[7]={122.7.,123.7,125.4,126.0,127.7,128.7.,150}; // for mh
  hggA->SetContour(6,level);
  hggA->SetMinimum(90);
  Int_t colors[7] = {kWhite,kGreen,kGreen+2,kBlack,kGreen+2,kGreen,kWhite};
  tdrStyle->SetPalette((sizeof(colors)/sizeof(Int_t)), colors);

// DRAW
  tdrStyle->SetOptStat(0);
  // tdrStyle->SetPadGridX(true);
  // tdrStyle->SetPadGridY(true);
  // tdrStyle->SetPadTopMargin(0.05);
  // tdrStyle->SetPadBottomMargin(0.13);
  tdrStyle->SetTitleYOffset(1.3);
  tdrStyle->SetTitleXOffset(1.6);
  tdrStyle->SetTitleOffset(1.3,"Z");
  // tdrStyle->SetOptLogz(1);
  // tdrStyle->SetOptLogy(1);
  tdrStyle->SetPadRightMargin(0.14);
  //tdrStyle->SetPalette(1);


  tdrStyle->cd();
  gROOT->ForceStyle();

  cout << "Creating canvas " << cname << endl;
  TCanvas* c1=new TCanvas(cname,goodName,1200,600);
  cout << " done " << c1->GetName() << endl;
  c1->Divide(2);

  c1->cd(1);
  hggA->DrawCopy("lego2");
  gPad->SetLogz();
  gPad->SetLogy();
  //gPad->SetPhi(120);
  gPad->SetPhi(-150);
  //gPad->SetTheta(30);
  gPad->UseCurrentStyle();
  gPad->Update();

  TLatex tl;
  tl.SetTextSize(0.04);
  tl.SetNDC();
  tl.DrawLatex(0.1,0.95,goodName);
  tl.SetTextAlign(11);
  tl.DrawLatex(0.1,0.89,goodType);

  c1->cd(2);
 // tdrStyle->SetPadLeftMargin(0.25);

  gPad->UseCurrentStyle();
  gPad->Update();
  hggA->GetXaxis()->SetTitleOffset(1.1);
  hggA->GetYaxis()->SetTitleOffset(1.1);
  hggA->GetZaxis()->SetTitleOffset(100);
  //hggA->Smooth();
  gPad->SetLogy(kFALSE);
  hggA->DrawCopy("zcont1");
  tl.DrawLatex(0.15,0.97,goodName);
  tl.SetTextAlign(11);
  tl.DrawLatex(0.2,0.9,goodType);

  TCanvas* ctmp=new TCanvas(cname,goodName,600,600);
  hggA->GetYaxis()->SetRangeUser(0.1,10.);
  hggA->DrawCopy("zcont1");
  tl.DrawLatex(0.83,0.97,goodName);
  tl.SetTextAlign(11);
  tl.DrawLatex(0.2,0.9,goodType);
  pCan(ctmp,cname+"_Lin");

  // TH1F* test=new TH1F("test","ggA cross section vs tan#beta; tan#beta",27,bin_tb);
  // ch->Project("test","tb",what);
  // test->Draw();


  TCanvas* c2=new TCanvas(cname+"Obs",goodName,800,800);
  gPad->UseCurrentStyle();
  gPad->Update();
  hggA->GetXaxis()->SetTitleOffset(1.1);
  hggA->GetYaxis()->SetTitleOffset(1.1);
  hggA->DrawCopy("cont list");
  gPad->Update();

  //return;
  // Get Contours
   TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
   TList* contLevel = NULL;
   TGraph* curv     = NULL;
   TGraph* gc       = NULL;

   Int_t nGraphs    = 0;
   Int_t TotalConts = 0;

   if (conts == NULL){
      printf("*** No Contours Were Extracted!\n");
      TotalConts = 0;
      return;
   } else {
      TotalConts = conts->GetSize();
   }

   printf("TotalConts = %d\n", TotalConts);

   for(i = 0; i < TotalConts; i++){
      contLevel = (TList*)conts->At(i);
      printf("Contour %d has %d Graphs\n", i, contLevel->GetSize());
      nGraphs += contLevel->GetSize();
   }

   nGraphs = 0;

   TH2F *hr = new TH2F("hr", ";m_{A};tan#beta", 2, 225, 600, 2, 0.1, 100);

   hr->GetXaxis()->SetTitleOffset(1.1);
   hr->GetXaxis()->SetRangeUser(200,650);
   hr->GetYaxis()->SetTitleOffset(1.2);
   hr->GetYaxis()->SetNdivisions(110,kFALSE);
   hr->GetXaxis()->SetNdivisions(20205,kFALSE);
   hr->Draw();
   Double_t x0, y0, z0;
   TLatex l;
   l.SetTextSize(0.03);
   l.SetTextAlign(32);
   char val[20];

   for(i = 0; i < TotalConts; i++){
      contLevel = (TList*)conts->At(i);
      z0 = level[i];
      printf("Z-Level Passed in as:  Z = %f\n", z0);

      // Get first graph from list on curves on this level
      curv = (TGraph*)contLevel->First();
      for(j = 0; j < contLevel->GetSize(); j++){
        // last point
         //curv->GetPoint(curv->GetN()-1, x0, y0);
        // first point
         curv->GetPoint(2, x0, y0);

         // if (z0<0) curv->SetLineColor(kRed);
         // if (z0>0) curv->SetLineColor(kBlue);
         nGraphs ++;
         printf("\tGraph: %d  -- %d Elements\n", nGraphs,curv->GetN());

	 // Draw clones of the graphs to avoid deletions in case the 1st
	 // pad is redrawn.
         gc = (TGraph*)curv->Clone();
         gc->Draw("C");

         if (z0>=.01) sprintf(val,"%0.2f",z0);
         if (z0>=.1) sprintf(val,"%0.2f",z0);
         if (z0>=1) sprintf(val,"%0.0f",z0);
         l.DrawLatex(x0*0.99,y0,val);
         curv = (TGraph*)contLevel->After(curv); // Get Next graph
      }
   }
   gPad->SetLogy();
   gPad->SetGridx();
   gPad->SetGridy();
   gPad->SetRightMargin(0.05);
   gPad->SetTopMargin(0.10);
   c2->Update();
   printf("\n\n\tExtracted %d Contours and %d Graphs \n", TotalConts, nGraphs );



  tl.SetTextAlign(31);
  tl.DrawLatex(0.8,0.85,goodName);

  tl.SetTextAlign(31);
  tl.DrawLatex(0.8,0.77,goodType);


  pCan(c2,cname+"_BW");

   c1->cd(1);
   gPad->SetLogy();
   gPad->SetLogz();
   c1->cd(2);
   gPad->SetLogy();
   c1->Update();
  pCan(c1,cname);
}
Ejemplo n.º 6
0
void alicePlots(){
    
    TFile* alice = new TFile("~/Downloads/HEPData-ins1288320-v1-root.root");
    alice->cd("Table 16");
    TGraph* aliceData = Graph1D_y1;
    TH1F* hist = Hist1D_y1;
    TH1F* stat = Hist1D_y1_e1;
    TH1F* syst = Hist1D_y1_e2;
    TGraphAsymmErrors* graph2 = (TGraphAsymmErrors*)aliceData->Clone("graph2");

    Int_t numPts = aliceData->GetN();
    Double_t x, y;
    for(int i = 0; i<numPts; i++){
        aliceData->GetPoint(i, x, y);
        aliceData->SetPoint(i, x, (y - 0.89581));
        graph2->SetPoint(i, x, (y- 0.89581));
        hist->SetBinContent(i+1, hist->GetBinContent(i+1) - 0.89581);
        hist->SetBinError(i+1, stat->GetBinContent(i+1));
        graph2->SetPointEXhigh(i, 0.1);
        graph2->SetPointEXlow(i, 0.1);
    }

    graph2->SetLineColor(kBlue-10);
    graph2->SetLineWidth(2);
    graph2->SetMarkerColor(kBlue-10);
    graph2->SetFillColor(kBlue-10);
    hist->SetLineColor(kBlue-2);
    hist->SetLineWidth(2);

    aliceData->SetTitle("");
    aliceData->GetYaxis()->SetTitle("Mass - Vacuum Mass (GeV/c^{2})");
    aliceData->GetYaxis()->SetTitleSize(0.06);
    aliceData->GetYaxis()->SetLabelSize(0.04);
    aliceData->GetYaxis()->SetTitleOffset(1.65);
    aliceData->GetYaxis()->SetTitleFont(42);
    aliceData->GetYaxis()->SetLabelFont(42);
    aliceData->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    aliceData->GetXaxis()->SetTitleSize(0.06);
    aliceData->GetXaxis()->SetLabelSize(0.05);
    aliceData->GetXaxis()->SetTitleFont(42);
    aliceData->GetXaxis()->SetLabelFont(42);
    aliceData->SetMarkerStyle(29);
    aliceData->SetMarkerSize(2.5);
    aliceData->SetMarkerColor(kBlue-2);
    aliceData->SetLineColor(kBlue-2);

    aliceData->GetYaxis()->SetRangeUser(-0.02, 0.015);
    aliceData->GetXaxis()->SetRangeUser(0, 5);

    TFile* phsd = new TFile("~/utaustin/resonancefits/finalplotting/20170721_KKbarAdded2_fixedwidth42_recon_pf100_scaled_error05.root");
    TH1D* mass = phsd->Get("kstar0mass");
    mass->SetName("mass");
    mass->SetMarkerStyle(26);
    mass->SetMarkerSize(2.5);
    mass->SetMarkerColor(2);
    mass->SetLineColor(2);

    TF1* line = new TF1("line", "[0]", 0.0, 5.0);
    line->SetParameter(0, 0.0);
    line->SetLineColor(1);
    line->SetLineStyle(7);
    line->SetLineWidth(3);

    for(int j = 0; j<mass->GetNbinsX(); j++){
        mass->SetBinContent(j+1, (mass->GetBinContent(j+1) - 0.892));
    }


    TFile* phsd2 = new TFile("~/utaustin/resonancefits/finalplotting/20170616_KKbarAdded2_fixedwidth_recon_pf100_scaled_error05.root");
    TH1D* mass2 = phsd2->Get("kstar0mass");
    mass2->SetName("mass2");
    mass2->SetMarkerStyle(22);
    mass2->SetMarkerSize(2.5);
    mass2->SetMarkerColor(2);
    mass2->SetLineColor(2);
    for(int j = 0; j<mass2->GetNbinsX(); j++){
        mass2->SetBinContent(j+1, (mass2->GetBinContent(j+1) - 0.892));
    }



    TExec *exec1 = new TExec("exec1", "gStyle->SetErrorX(0.1)");
    TExec *exec2 = new TExec("exec2", "gStyle->SetErrorX(0.5)");
    
    TCanvas *c = new TCanvas ("c", "c", 50, 50, 650, 600);
    c->cd()->SetMargin(0.1997, 0.0369, 0.1396, 0.0681);
    aliceData->Draw("APX");
    //exec1->Draw();
    graph2->Draw("SAME P2");
    //exec2->Draw();
    hist->Draw("SAME E1");
    line->Draw("SAME");
    mass2->Draw("SAME P E1");
    mass->Draw("SAME P E1");
    aliceData->Draw("SAME PX");
    

    TLegend* legend = new TLegend(0.5836, 0.1815, 0.9489, 0.3438);
    legend->SetMargin(0.2);
    legend->SetTextSizePixels(20);
    legend->AddEntry(aliceData, "ALICE data, 0-20%", "p");
    legend->AddEntry(mass2, "Fit IV to PHSD: w in-med", "p");
    legend->AddEntry(mass, "Fit IV to PHSD: w/o in-med", "p");
    legend->Draw("SAME"); 
  
    TPaveText* text = new TPaveText(0.2554, 0.7243, 0.6006, 0.9162, "NDC");
    text->AddText("(K*^{0} + #bar{K}*^{0})");
    text->AddText("Pb-Pb #sqrt{s_{NN}} = 2.76 TeV");
    text->GetLine(0)->SetTextSizePixels(36);
    text->GetLine(1)->SetTextSizePixels(24);
    text->SetTextFont(42);
    text->SetBorderSize(0);
    text->SetFillStyle(0);
    text->Draw();
}
Ejemplo n.º 7
0
TCanvas *ContourList(){

   const Double_t PI = TMath::Pi();

   TCanvas* c = new TCanvas("c","Contour List",0,0,600,600);
   c->SetRightMargin(0.15);
   c->SetTopMargin(0.15);

   Int_t i, j, TotalConts;

   Int_t nZsamples   = 80;
   Int_t nPhiSamples = 80;

   Double_t HofZwavelength = 4.0;       // 4 meters
   Double_t dZ             =  HofZwavelength/(Double_t)(nZsamples - 1);
   Double_t dPhi           = 2*PI/(Double_t)(nPhiSamples - 1);

   TArrayD z(nZsamples);
   TArrayD HofZ(nZsamples);
   TArrayD phi(nPhiSamples);
   TArrayD FofPhi(nPhiSamples);

   // Discretized Z and Phi Values
   for ( i = 0; i < nZsamples; i++) {
      z[i] = (i)*dZ - HofZwavelength/2.0;
      HofZ[i] = SawTooth(z[i], HofZwavelength);
   }

   for(Int_t i=0; i < nPhiSamples; i++){
      phi[i] = (i)*dPhi;
      FofPhi[i] = sin(phi[i]);
   }

   // Create Histogram
   TH2D *HistStreamFn = new TH2D("HstreamFn",
   "#splitline{Histogram with negative and positive contents. Six contours are defined.}{It is plotted with options CONT LIST to retrieve the contours points in TGraphs}",
   nZsamples, z[0], z[nZsamples-1], nPhiSamples, phi[0], phi[nPhiSamples-1]);

   // Load Histogram Data
   for (Int_t i = 0; i < nZsamples; i++) {
      for(Int_t j = 0; j < nPhiSamples; j++){
         HistStreamFn->SetBinContent(i,j, HofZ[i]*FofPhi[j]);
      }
   }

   gStyle->SetPalette(1);
   gStyle->SetOptStat(0);
   gStyle->SetTitleW(0.99);
   gStyle->SetTitleH(0.08);

   Double_t contours[6];
   contours[0] = -0.7;
   contours[1] = -0.5;
   contours[2] = -0.1;
   contours[3] =  0.1;
   contours[4] =  0.4;
   contours[5] =  0.8;

   HistStreamFn->SetContour(6, contours);

   // Draw contours as filled regions, and Save points
   HistStreamFn->Draw("CONT Z LIST");
   c->Update(); // Needed to force the plotting and retrieve the contours in TGraphs

   // Get Contours
   TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
   TList* contLevel = NULL;
   TGraph* curv     = NULL;
   TGraph* gc       = NULL;

   Int_t nGraphs    = 0;
   Int_t TotalConts = 0;

   if (conts == NULL){
      printf("*** No Contours Were Extracted!\n");
      TotalConts = 0;
      return;
   } else {
      TotalConts = conts->GetSize();
   }

   printf("TotalConts = %d\n", TotalConts);

   for(i = 0; i < TotalConts; i++){
      contLevel = (TList*)conts->At(i);
      printf("Contour %d has %d Graphs\n", i, contLevel->GetSize());
      nGraphs += contLevel->GetSize();
   }

   nGraphs = 0;

   TCanvas* c1 = new TCanvas("c1","Contour List",610,0,600,600);
   c1->SetTopMargin(0.15);
   TH2F *hr = new TH2F("hr",
   "#splitline{Negative contours are returned first (highest to lowest). Positive contours are returned from}{lowest to highest. On this plot Negative contours are drawn in red and positive contours in blue.}",
   2, -2, 2, 2, 0, 6.5);

   hr->Draw();
   Double_t x0, y0, z0;
   TLatex l;
   l.SetTextSize(0.03);
   char val[20];

   for(i = 0; i < TotalConts; i++){
      contLevel = (TList*)conts->At(i);
      if (i<3) z0 = contours[2-i];
      else     z0 = contours[i];
      printf("Z-Level Passed in as:  Z = %f\n", z0);

      // Get first graph from list on curves on this level
      curv = (TGraph*)contLevel->First();
      for(j = 0; j < contLevel->GetSize(); j++){
         curv->GetPoint(0, x0, y0);
         if (z0<0) curv->SetLineColor(kRed);
         if (z0>0) curv->SetLineColor(kBlue);
         nGraphs ++;
         printf("\tGraph: %d  -- %d Elements\n", nGraphs,curv->GetN());

	 // Draw clones of the graphs to avoid deletions in case the 1st
	 // pad is redrawn.
         gc = (TGraph*)curv->Clone();
         gc->Draw("C");

         sprintf(val,"%g",z0);
         l.DrawLatex(x0,y0,val);
         curv = (TGraph*)contLevel->After(curv); // Get Next graph
      }
   }
   c1->Update();
   printf("\n\n\tExtracted %d Contours and %d Graphs \n", TotalConts, nGraphs );
   gStyle->SetTitleW(0.);
   gStyle->SetTitleH(0.);
   return c1;
}
void RemoveDiagonal(TString signaltype, bool prefit, bool fakedata, bool nosigunc, bool nobkgunc, int xsecupdown, int compressed, bool dropsigcont){

  TString myoutputdir = outputdir;
  if(compressed==1) myoutputdir = myoutputdir + "compressed/";
  if(nosigunc&&nobkgunc) myoutputdir = myoutputdir + "nounc/";
  else if(nosigunc) myoutputdir = myoutputdir + "nosigunc/";
  else if(nobkgunc) myoutputdir = myoutputdir + "nobkgunc/";
  if(dropsigcont) myoutputdir = myoutputdir + "dropsigcont/";
  if(fakedata)   myoutputdir = myoutputdir + "fakedata/";
  TString infilename = myoutputdir + "Limits2DHistograms.root";
  TString outfilename = myoutputdir + "Limits2DHistogramsRemovedDiagonal.root";
  
  ifstream infile(infilename.Data());
  if(!(infile.good() ) ) {
    cout << "file " << outfilename << " does not exist - exit" << endl;
    return;
  }
  TFile *fin = new TFile(infilename, "read");
  fin->cd();
  TH2F* hExpOrg   = (TH2F*)fin->Get("hExpOrg");
  TH2F* hObsOrg   = (TH2F*)fin->Get("hObsOrg");
  TH2F* hObs1mOrg = (TH2F*)fin->Get("hObs1mOrg");
  TH2F* hObs1pOrg = (TH2F*)fin->Get("hObs1pOrg");
  TH2F* hExp1mOrg = (TH2F*)fin->Get("hExp1mOrg");
  TH2F* hExp2mOrg = (TH2F*)fin->Get("hExp2mOrg");
  TH2F* hExp1pOrg = (TH2F*)fin->Get("hExp1pOrg");
  TH2F* hExp2pOrg = (TH2F*)fin->Get("hExp2pOrg");
  TH2F* hExpOrgXsec   = (TH2F*)fin->Get("hExpOrgXsec");
  TH2F* hObsOrgXsec   = (TH2F*)fin->Get("hObsOrgXsec");
  TH2F* hObs1mOrgXsec = (TH2F*)fin->Get("hObs1mOrgXsec");
  TH2F* hObs1pOrgXsec = (TH2F*)fin->Get("hObs1pOrgXsec");
  TH2F* hExp1mOrgXsec = (TH2F*)fin->Get("hExp1mOrgXsec");
  TH2F* hExp2mOrgXsec = (TH2F*)fin->Get("hExp2mOrgXsec");
  TH2F* hExp1pOrgXsec = (TH2F*)fin->Get("hExp1pOrgXsec");
  TH2F* hExp2pOrgXsec = (TH2F*)fin->Get("hExp2pOrgXsec");
  TH2F* hExpOrgPass   = (TH2F*)fin->Get("hExpOrgPass");
  TH2F* hObsOrgPass   = (TH2F*)fin->Get("hObsOrgPass");
  TH2F* hObs1mOrgPass = (TH2F*)fin->Get("hObs1mOrgPass");
  TH2F* hObs1pOrgPass = (TH2F*)fin->Get("hObs1pOrgPass");
  TH2F* hExp1mOrgPass = (TH2F*)fin->Get("hExp1mOrgPass");
  TH2F* hExp2mOrgPass = (TH2F*)fin->Get("hExp2mOrgPass");
  TH2F* hExp1pOrgPass = (TH2F*)fin->Get("hExp1pOrgPass");
  TH2F* hExp2pOrgPass = (TH2F*)fin->Get("hExp2pOrgPass");
  TH2F* hExp   = (TH2F*)fin->Get("hExp");
  TH2F* hObs   = (TH2F*)fin->Get("hObs");
  TH2F* hObs1m = (TH2F*)fin->Get("hObs1m");
  TH2F* hObs1p = (TH2F*)fin->Get("hObs1p");
  TH2F* hExp1m = (TH2F*)fin->Get("hExp1m");
  TH2F* hExp2m = (TH2F*)fin->Get("hExp2m");
  TH2F* hExp1p = (TH2F*)fin->Get("hExp1p");
  TH2F* hExp2p = (TH2F*)fin->Get("hExp2p");
  TH2F* hExpXsec   = (TH2F*)fin->Get("hExpXsec");
  TH2F* hObsXsec   = (TH2F*)fin->Get("hObsXsec");
  TH2F* hObs1mXsec = (TH2F*)fin->Get("hObs1mXsec");
  TH2F* hObs1pXsec = (TH2F*)fin->Get("hObs1pXsec");
  TH2F* hExp1mXsec = (TH2F*)fin->Get("hExp1mXsec");
  TH2F* hExp2mXsec = (TH2F*)fin->Get("hExp2mXsec");
  TH2F* hExp1pXsec = (TH2F*)fin->Get("hExp1pXsec");
  TH2F* hExp2pXsec = (TH2F*)fin->Get("hExp2pXsec");
  TH2F* hExpPass   = (TH2F*)fin->Get("hExpPass");
  TH2F* hObsPass   = (TH2F*)fin->Get("hObsPass");
  TH2F* hObs1mPass = (TH2F*)fin->Get("hObs1mPass");
  TH2F* hObs1pPass = (TH2F*)fin->Get("hObs1pPass");
  TH2F* hExp1mPass = (TH2F*)fin->Get("hExp1mPass");
  TH2F* hExp2mPass = (TH2F*)fin->Get("hExp2mPass");
  TH2F* hExp1pPass = (TH2F*)fin->Get("hExp1pPass");
  TH2F* hExp2pPass = (TH2F*)fin->Get("hExp2pPass");

  TGraph2D *g2Exp   = (TGraph2D*)fin->Get("Graph2D_from_hExpOrg");
  TGraph2D *g2Obs   = (TGraph2D*)fin->Get("Graph2D_from_hObsOrg");
  TGraph2D *g2Obs1m = (TGraph2D*)fin->Get("Graph2D_from_hObs1mOrg");
  TGraph2D *g2Obs1p = (TGraph2D*)fin->Get("Graph2D_from_hObs1pOrg");
  TGraph2D *g2Exp1m = (TGraph2D*)fin->Get("Graph2D_from_hExp1mOrg");
  TGraph2D *g2Exp2m = (TGraph2D*)fin->Get("Graph2D_from_hExp2mOrg");
  TGraph2D *g2Exp1p = (TGraph2D*)fin->Get("Graph2D_from_hExp1pOrg");
  TGraph2D *g2Exp2p = (TGraph2D*)fin->Get("Graph2D_from_hExp2mOrg");//XXX - fix this later
  TGraph *gExp   = (TGraph*)fin->Get("gExp");
  TGraph *gObs   = (TGraph*)fin->Get("gObs");
  TGraph *gObs1m = (TGraph*)fin->Get("gObs1m");
  TGraph *gObs1p = (TGraph*)fin->Get("gObs1p");
  TGraph *gExp1m = (TGraph*)fin->Get("gExp1m");
  TGraph *gExp2m = (TGraph*)fin->Get("gExp2m");
  TGraph *gExp1p = (TGraph*)fin->Get("gExp1p");
  TGraph *gExp2p = (TGraph*)fin->Get("gExp2p");
  TGraph *gEmpty= (TGraph*)fin->Get("gEmpty");

  hExpOrg   ->SetName("hExpOrg_x");
  hObsOrg   ->SetName("hObsOrg_x");
  hObs1mOrg ->SetName("hObs1mOrg_x");
  hObs1pOrg ->SetName("hObs1pOrg_x");
  hExp1mOrg ->SetName("hExp1mOrg_x");
  hExp2mOrg ->SetName("hExp2mOrg_x");
  hExp1pOrg ->SetName("hExp1pOrg_x");
  hExp2pOrg ->SetName("hExp2pOrg_x");
  hExpOrgXsec   ->SetName("hExpOrgXsec_x");
  hObsOrgXsec   ->SetName("hObsOrgXsec_x");
  hObs1mOrgXsec ->SetName("hObs1mOrgXsec_x");
  hObs1pOrgXsec ->SetName("hObs1pOrgXsec_x");
  hExp1mOrgXsec ->SetName("hExp1mOrgXsec_x");
  hExp2mOrgXsec ->SetName("hExp2mOrgXsec_x");
  hExp1pOrgXsec ->SetName("hExp1pOrgXsec_x");
  hExp2pOrgXsec ->SetName("hExp2pOrgXsec_x");
  hExpOrgPass   ->SetName("hExpOrgPass_x");
  hObsOrgPass   ->SetName("hObsOrgPass_x");
  hObs1mOrgPass ->SetName("hObs1mOrgPass_x");
  hObs1pOrgPass ->SetName("hObs1pOrgPass_x");
  hExp1mOrgPass ->SetName("hExp1mOrgPass_x");
  hExp2mOrgPass ->SetName("hExp2mOrgPass_x");
  hExp1pOrgPass ->SetName("hExp1pOrgPass_x");
  hExp2pOrgPass ->SetName("hExp2pOrgPass_x");
  hExp   ->SetName("hExp_x");
  hObs   ->SetName("hObs_x");
  hObs1m ->SetName("hObs1m_x");
  hObs1p ->SetName("hObs1p_x");
  hExp1m ->SetName("hExp1m_x");
  hExp2m ->SetName("hExp2m_x");
  hExp1p ->SetName("hExp1p_x");
  hExp2p ->SetName("hExp2p_x");
  hExpXsec   ->SetName("hExpXsec_x");
  hObsXsec   ->SetName("hObsXsec_x");
  hObs1mXsec ->SetName("hObs1mXsec_x");
  hObs1pXsec ->SetName("hObs1pXsec_x");
  hExp1mXsec ->SetName("hExp1mXsec_x");
  hExp2mXsec ->SetName("hExp2mXsec_x");
  hExp1pXsec ->SetName("hExp1pXsec_x");
  hExp2pXsec ->SetName("hExp2pXsec_x");
  hExpPass   ->SetName("hExpPass_x");
  hObsPass   ->SetName("hObsPass_x");
  hObs1mPass ->SetName("hObs1mPass_x");
  hObs1pPass ->SetName("hObs1pPass_x");
  hExp1mPass ->SetName("hExp1mPass_x");
  hExp2mPass ->SetName("hExp2mPass_x");
  hExp1pPass ->SetName("hExp1pPass_x");
  hExp2pPass ->SetName("hExp2pPass_x");

  
  g2Exp   ->SetName("Graph2D_from_hExpOrg_x");
  g2Obs   ->SetName("Graph2D_from_hObsOrg_x");
  g2Obs1m ->SetName("Graph2D_from_hObs1mOrg_x");
  g2Obs1p ->SetName("Graph2D_from_hObs1pOrg_x");
  g2Exp1m ->SetName("Graph2D_from_hExp1mOrg_x");
  g2Exp2m ->SetName("Graph2D_from_hExp2mOrg_x");
  g2Exp1p ->SetName("Graph2D_from_hExp1pOrg_x");
  g2Exp2p ->SetName("Graph2D_from_hExp2pOrg_x");
  gExp   ->SetName("gExp_x");
  gObs   ->SetName("gObs_x");
  gObs1m ->SetName("gObs1m_x");
  gObs1p ->SetName("gObs1p_x");
  gExp1m ->SetName("gExp1m_x");
  gExp2m ->SetName("gExp2m_x");
  gExp1p ->SetName("gExp1p_x");
  gExp2p ->SetName("gExp2p_x");
  gEmpty->SetName("gEmpty_x");

  TFile *fout = new TFile(outfilename, "recreate");
  fout->cd();
  TH2F* nhExpOrg   = (TH2F*)RemoveHistoDiagonal(hExpOrg);
  TH2F* nhObsOrg   = (TH2F*)RemoveHistoDiagonal(hObsOrg);
  TH2F* nhObs1mOrg = (TH2F*)RemoveHistoDiagonal(hObs1mOrg);
  TH2F* nhObs1pOrg = (TH2F*)RemoveHistoDiagonal(hObs1pOrg);
  TH2F* nhExp1mOrg = (TH2F*)RemoveHistoDiagonal(hExp1mOrg);
  TH2F* nhExp2mOrg = (TH2F*)RemoveHistoDiagonal(hExp2mOrg);
  TH2F* nhExp1pOrg = (TH2F*)RemoveHistoDiagonal(hExp1pOrg);
  TH2F* nhExp2pOrg = (TH2F*)RemoveHistoDiagonal(hExp2pOrg);
  TH2F* nhExpOrgXsec   = (TH2F*)RemoveHistoDiagonal(hExpOrgXsec);
  TH2F* nhObsOrgXsec   = (TH2F*)RemoveHistoDiagonal(hObsOrgXsec);
  TH2F* nhObs1mOrgXsec = (TH2F*)RemoveHistoDiagonal(hObs1mOrgXsec);
  TH2F* nhObs1pOrgXsec = (TH2F*)RemoveHistoDiagonal(hObs1pOrgXsec);
  TH2F* nhExp1mOrgXsec = (TH2F*)RemoveHistoDiagonal(hExp1mOrgXsec);
  TH2F* nhExp2mOrgXsec = (TH2F*)RemoveHistoDiagonal(hExp2mOrgXsec);
  TH2F* nhExp1pOrgXsec = (TH2F*)RemoveHistoDiagonal(hExp1pOrgXsec);
  TH2F* nhExp2pOrgXsec = (TH2F*)RemoveHistoDiagonal(hExp2pOrgXsec);
  TH2F* nhExpOrgPass   = (TH2F*)RemoveHistoDiagonal(hExpOrgPass);
  TH2F* nhObsOrgPass   = (TH2F*)RemoveHistoDiagonal(hObsOrgPass);
  TH2F* nhObs1mOrgPass = (TH2F*)RemoveHistoDiagonal(hObs1mOrgPass);
  TH2F* nhObs1pOrgPass = (TH2F*)RemoveHistoDiagonal(hObs1pOrgPass);
  TH2F* nhExp1mOrgPass = (TH2F*)RemoveHistoDiagonal(hExp1mOrgPass);
  TH2F* nhExp2mOrgPass = (TH2F*)RemoveHistoDiagonal(hExp2mOrgPass);
  TH2F* nhExp1pOrgPass = (TH2F*)RemoveHistoDiagonal(hExp1pOrgPass);
  TH2F* nhExp2pOrgPass = (TH2F*)RemoveHistoDiagonal(hExp2pOrgPass);
  TH2F* nhExp   = (TH2F*)RemoveHistoDiagonal(hExp);
  TH2F* nhObs   = (TH2F*)RemoveHistoDiagonal(hObs);
  TH2F* nhObs1m = (TH2F*)RemoveHistoDiagonal(hObs1m);
  TH2F* nhObs1p = (TH2F*)RemoveHistoDiagonal(hObs1p);
  TH2F* nhExp1m = (TH2F*)RemoveHistoDiagonal(hExp1m);
  TH2F* nhExp2m = (TH2F*)RemoveHistoDiagonal(hExp2m);
  TH2F* nhExp1p = (TH2F*)RemoveHistoDiagonal(hExp1p);
  TH2F* nhExp2p = (TH2F*)RemoveHistoDiagonal(hExp2p);
  TH2F* nhExpXsec   = (TH2F*)RemoveHistoDiagonal(hExpXsec);
  TH2F* nhObsXsec   = (TH2F*)RemoveHistoDiagonal(hObsXsec);
  TH2F* nhObs1mXsec = (TH2F*)RemoveHistoDiagonal(hObs1mXsec);
  TH2F* nhObs1pXsec = (TH2F*)RemoveHistoDiagonal(hObs1pXsec);
  TH2F* nhExp1mXsec = (TH2F*)RemoveHistoDiagonal(hExp1mXsec);
  TH2F* nhExp2mXsec = (TH2F*)RemoveHistoDiagonal(hExp2mXsec);
  TH2F* nhExp1pXsec = (TH2F*)RemoveHistoDiagonal(hExp1pXsec);
  TH2F* nhExp2pXsec = (TH2F*)RemoveHistoDiagonal(hExp2pXsec);
  TH2F* nhExpPass   = (TH2F*)RemoveHistoDiagonal(hExpPass);
  TH2F* nhObsPass   = (TH2F*)RemoveHistoDiagonal(hObsPass);
  TH2F* nhObs1mPass = (TH2F*)RemoveHistoDiagonal(hObs1mPass);
  TH2F* nhObs1pPass = (TH2F*)RemoveHistoDiagonal(hObs1pPass);
  TH2F* nhExp1mPass = (TH2F*)RemoveHistoDiagonal(hExp1mPass);
  TH2F* nhExp2mPass = (TH2F*)RemoveHistoDiagonal(hExp2mPass);
  TH2F* nhExp1pPass = (TH2F*)RemoveHistoDiagonal(hExp1pPass);
  TH2F* nhExp2pPass = (TH2F*)RemoveHistoDiagonal(hExp2pPass);

  TGraph2D *ng2Exp   = (TGraph2D*)g2Exp->Clone("Graph2D_from_hExpOrg");
  TGraph2D *ng2Obs   = (TGraph2D*)g2Obs->Clone("Graph2D_from_hObsOrg");
  TGraph2D *ng2Obs1m = (TGraph2D*)g2Obs1m->Clone("Graph2D_from_hObs1mOrg");
  TGraph2D *ng2Obs1p = (TGraph2D*)g2Obs1p->Clone("Graph2D_from_hObs1pOrg");
  TGraph2D *ng2Exp1m = (TGraph2D*)g2Exp1m->Clone("Graph2D_from_hExp1mOrg");
  TGraph2D *ng2Exp2m = (TGraph2D*)g2Exp2m->Clone("Graph2D_from_hExp2mOrg");
  TGraph2D *ng2Exp1p = (TGraph2D*)g2Exp1p->Clone("Graph2D_from_hExp1pOrg");
  TGraph2D *ng2Exp2p = (TGraph2D*)g2Exp2p->Clone("Graph2D_from_hExp2pOrg");
  TGraph *ngExp   = (TGraph*)gExp->Clone("gExp");
  TGraph *ngObs   = (TGraph*)gObs->Clone("gObs");
  TGraph *ngObs1m = (TGraph*)gObs1m->Clone("gObs1m");
  TGraph *ngObs1p = (TGraph*)gObs1p->Clone("gObs1p");
  TGraph *ngExp1m = (TGraph*)gExp1m->Clone("gExp1m");
  TGraph *ngExp2m = (TGraph*)gExp2m->Clone("gExp2m");
  TGraph *ngExp1p = (TGraph*)gExp1p->Clone("gExp1p");
  TGraph *ngExp2p = (TGraph*)gExp2p->Clone("gExp2p");
  TGraph *ngEmpty= (TGraph*)gExp2p->Clone("gEmpty");

  fout->cd();
  nhExpOrg   ->Write();
  nhObsOrg   ->Write();
  nhObs1mOrg ->Write();
  nhObs1pOrg ->Write();
  nhExp1mOrg ->Write();
  nhExp2mOrg ->Write();
  nhExp1pOrg ->Write();
  nhExp2pOrg ->Write();
  nhExpOrgXsec   ->Write();
  nhObsOrgXsec   ->Write();
  nhObs1mOrgXsec ->Write();
  nhObs1pOrgXsec ->Write();
  nhExp1mOrgXsec ->Write();
  nhExp2mOrgXsec ->Write();
  nhExp1pOrgXsec ->Write();
  nhExp2pOrgXsec ->Write();
  nhExpOrgPass   ->Write();
  nhObsOrgPass   ->Write();
  nhObs1mOrgPass ->Write();
  nhObs1pOrgPass ->Write();
  nhExp1mOrgPass ->Write();
  nhExp2mOrgPass ->Write();
  nhExp1pOrgPass ->Write();
  nhExp2pOrgPass ->Write();
  nhExp   ->Write();
  nhObs   ->Write();
  nhObs1m ->Write();
  nhObs1p ->Write();
  nhExp1m ->Write();
  nhExp2m ->Write();
  nhExp1p ->Write();
  nhExp2p ->Write();
  nhExpXsec   ->Write();
  nhObsXsec   ->Write();
  nhObs1mXsec ->Write();
  nhObs1pXsec ->Write();
  nhExp1mXsec ->Write();
  nhExp2mXsec ->Write();
  nhExp1pXsec ->Write();
  nhExp2pXsec ->Write();
  nhExpPass   ->Write();
  nhObsPass   ->Write();
  nhObs1mPass ->Write();
  nhObs1pPass ->Write();
  nhExp1mPass ->Write();
  nhExp2mPass ->Write();
  nhExp1pPass ->Write();
  nhExp2pPass ->Write();

  ng2Exp   ->Write();
  ng2Obs   ->Write();
  ng2Obs1m ->Write();
  ng2Obs1p ->Write();
  ng2Exp1m ->Write();
  ng2Exp2m ->Write();
  ng2Exp1p ->Write();
  ng2Exp2p ->Write();
  ngExp   ->Write();
  ngObs   ->Write();
  ngObs1m ->Write();
  ngObs1p ->Write();
  ngExp1m ->Write();
  ngExp2m ->Write();
  ngExp1p ->Write();
  ngExp2p ->Write();
  ngEmpty->Write();
  fout->Close();
  cout << "Saved all histos in  " << fout->GetName() << endl;
  
}
Ejemplo n.º 9
0
void Polarization(){

    TGraph *gObs;
    TGraph *gExp;
    TGraph *gObsL;
    TGraph *gExpL;
    TGraph *gObsR;
    TGraph *gExpR;
    
    TFile *fc = TFile::Open("Limits2DHistograms_T2tt_postfit.root");
    TFile *fl = TFile::Open("Limits2DHistograms_T2tt_lefthanded_postfit.root");
    TFile *fr = TFile::Open("Limits2DHistograms_T2tt_righthanded_postfit.root");
    
    TGraph *g;
    fc->cd();
    g = (TGraph*)fc->Get("gObs");
    gObs = (TGraph*)g->Clone("Obs");
    g = (TGraph*)fc->Get("gExp");
    gExp = (TGraph*)g->Clone("Exp");
    fl->cd();
    g = (TGraph*)fl->Get("gObs_2");
    gObsL = (TGraph*)g->Clone("ObsL");
    g = (TGraph*)fl->Get("gExp_2");
    gExpL = (TGraph*)g->Clone("ExpL");
    fr->cd();
    g = (TGraph*)fr->Get("gObs");
    gObsR = (TGraph*)g->Clone("ObsR");
    g = (TGraph*)fr->Get("gExp");
    gExpR = (TGraph*)g->Clone("ExpR");
    
    gObs->SetLineWidth(4);
    gExp->SetLineWidth(4);
    gObsL->SetLineWidth(2);
    gExpL->SetLineWidth(2);
    gObsR->SetLineWidth(2);
    gExpR->SetLineWidth(2);
    gObs->SetLineStyle(1);
    gExp->SetLineStyle(7);
    gObsL->SetLineStyle(1);
    gExpL->SetLineStyle(7);
    gObsR->SetLineStyle(1);
    gExpR->SetLineStyle(7);
    gObs->SetLineColor(kBlack);
    gExp->SetLineColor(kBlack);
    gObsL->SetLineColor(kBlue);
    gExpL->SetLineColor(kBlue);
    gObsR->SetLineColor(kRed);
    gExpR->SetLineColor(kRed);
    if(killlowdiag){
    for( int i = gObs->GetN()-1; i>=0;--i){
        double x,y;
        gObs->GetPoint(i,x,y);
        if(x-y<172.5) gObs->RemovePoint(i);
    }
    for( int i = gExp->GetN()-1; i>=0;--i){
        double x,y;
        gExp->GetPoint(i,x,y);
        if(x-y<172.5) gExp->RemovePoint(i);
    }
    }
    for( int i = gObsL->GetN()-1; i>=0;--i){
        double x,y;
        gObsL->GetPoint(i,x,y);
        if(x-y<172.5) gObsL->RemovePoint(i);
    }
    for( int i = gObsR->GetN()-1; i>=0;--i){
        double x,y;
        gObsR->GetPoint(i,x,y);
        if(x-y<172.5) gObsR->RemovePoint(i);
    }
    for( int i = gExpL->GetN()-1; i>=0;--i){
        double x,y;
        gExpL->GetPoint(i,x,y);
        if(x-y<172.5) gExpL->RemovePoint(i);
    }
    for( int i = gExpR->GetN()-1; i>=0;--i){
        double x,y;
        gExpR->GetPoint(i,x,y);
        if(x-y<172.5) gExpR->RemovePoint(i);
    }

    
   TCanvas *c1 = new TCanvas("c1", "c1",50,50,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   gStyle->SetErrorX(0.5); 
   //c1->Range(-6.311689,-1.891383,28.75325,4.56342);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   //c1->SetLogy();
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.15);
   c1->SetRightMargin(0.05);
   c1->SetTopMargin(0.07);
   c1->SetBottomMargin(0.15);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   gStyle->SetHatchesLineWidth(0);

   TH1F *hSum = new TH1F("hSum","",10,150,950);
   hSum->SetMinimum(0.);
   hSum->SetMaximum(550);
   hSum->SetDirectory(0);
   hSum->SetStats(0);
    hSum->Draw();
    hSum->GetYaxis()->SetRangeUser(0,500);
    hSum->GetXaxis()->SetRangeUser(150,950);

   Int_t ci;   // for color index setting
   ci = TColor::GetColor("#000099");
   hSum->SetLineColor(ci);
   hSum->SetLineStyle(0);
   hSum->SetMarkerStyle(20);
   hSum->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
   //hSum->GetXaxis()->SetBit(TAxis::kLabelsVert);
   hSum->GetXaxis()->SetLabelFont(42);
   //hSum->GetXaxis()->SetLabelOffset(0.005);
   hSum->GetXaxis()->SetLabelSize(0.035);
   hSum->GetXaxis()->SetTitleSize(0.06);
   hSum->GetXaxis()->SetTitleOffset(1.2);
   hSum->GetXaxis()->SetTitleFont(42);
   hSum->GetYaxis()->SetTitle("m_{#tilde{#chi}}_{1}^{0} [GeV]");
   hSum->GetYaxis()->SetLabelFont(42);
   //hSum->GetYaxis()->SetLabelOffset(0.007);
   hSum->GetYaxis()->SetLabelSize(0.035);
   hSum->GetYaxis()->SetTitleSize(0.05);
   hSum->GetYaxis()->SetTitleOffset(1.3);
   hSum->GetYaxis()->SetTitleFont(42);
    
    //TLegend *leg = new TLegend(0.4992416,0.4811189,0.898906,0.7503497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.4992416,0.4811189,0.698906,0.7503497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.6992416,0.2811189,0.898906,0.4503497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.6992416,0.3311189,0.898906,0.7903497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.7582416,0.4211189,0.912,0.8043497,NULL,"brNDC");
    TLegend *legE = new TLegend(0.51,0.675,0.81,0.855,NULL,"brNDC");
    //leg-> SetNColumns(2);
    legE->SetBorderSize(0);
    legE->SetTextSize(0.04);
    legE->SetTextFont(42);
    legE->SetLineColor(1);
    legE->SetLineStyle(1);
    legE->SetLineWidth(2);
    legE->SetFillColor(0);
    legE->SetFillStyle(1001);
    legE->SetHeader("Expected");
    legE->AddEntry(gExp, "unpolarized","l");
    legE->AddEntry(gExpR, "right-handed","l");
    legE->AddEntry(gExpL, "left-handed","l");
    
    TLegend *legO = new TLegend(0.175,0.675,0.50,0.855,NULL,"brNDC");
    //legO-> SetNColumns(2);
    legO->SetBorderSize(0);
    legO->SetTextSize(0.04);
    legO->SetTextFont(42);
    legO->SetLineColor(1);
    legO->SetLineStyle(1);
    legO->SetLineWidth(2);
    legO->SetFillColor(0);
    legO->SetFillStyle(1001);
    legO->SetHeader("Observed");
    legO->AddEntry(gObs, "unpolarized","l");
    legO->AddEntry(gObsR, "right-handed","l");
    legO->AddEntry(gObsL, "left-handed","l");
    
    
    TGraph* graphWhite = new TGraph(5);
    graphWhite->SetName("white");
    graphWhite->SetTitle("white");
    graphWhite->SetFillColor(kWhite);
    graphWhite->SetFillStyle(1001);
    graphWhite->SetLineColor(kBlack);
    graphWhite->SetLineStyle(1);
    graphWhite->SetLineWidth(3);
    graphWhite->SetPoint(0,150, 500);
    graphWhite->SetPoint(1,950, 500);
    graphWhite->SetPoint(2,950, 500*0.6666666667);
    graphWhite->SetPoint(3,150, 500*0.6666666667);
    graphWhite->SetPoint(4,150, 500);
    
    Float_t diagX[4] = {175.+25.,175.+25.+5000,175.-25.+5000,175.-25.};
    Float_t diagY[4] = {0,5000,5000,0};
    TGraph *gdiagonal = new TGraph(4, diagX, diagY);
    gdiagonal->SetName("MtopDiagonal");
    gdiagonal->SetFillColor(kWhite);
    //#gdiagonal->SetFillColor(18);
    TLine* ldiagonal = new TLine(175,0.,650-25.,450);
    //TLine* ldiagonal = new TLine(175.,25,175+500,500);
    ldiagonal->SetLineColor(kGray);
    ldiagonal->SetLineStyle(2);
    TLatex* tdiagonal = new TLatex(400-2.5, 400-172.5,"m_{#tilde{t}} = m_{t} + m_{#tilde{#chi}_{1}^{0}}");
    //tdiagonal->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    tdiagonal->SetTextAngle(56.31);
    tdiagonal->SetTextColor(kGray+2);
    tdiagonal->SetTextAlign(11);
    tdiagonal->SetTextSize(0.025);

    TLine* l2 = new TLine(150,75,585,500);
    l2->SetLineColor(kGray);
    l2->SetLineStyle(2);
    if(killlowdiag){
        l2->SetX1(200); l2->SetY1(0); l2->SetX2(600); l2->SetY2(400);
    }
    TLatex *t2 = new TLatex(300, 300-72.5,"m_{#tilde{t}} = m_{W} + m_{#tilde{#chi}_{1}^{0}}");
    //t2->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    t2->SetTextAngle(56.31);
    t2->SetTextColor(kGray+2);
    t2->SetTextAlign(11);
    t2->SetTextSize(0.025);

    hSum->Draw("axis");
    
    gExpR->Draw("c");
    gExpL->Draw("c");
    gExp->Draw("c");
    gObsR->Draw("c");
    gObsL->Draw("c");
    gObs->Draw("c");

    gdiagonal->Draw("FSAME");
    ldiagonal->Draw("LSAME");
    l2->Draw();
    if(!killlowdiag) t2->Draw();
    tdiagonal->Draw("SAME");
    graphWhite->Draw("FSAME");
    graphWhite->Draw("LSAME");

    legE->Draw();
    legO->Draw();
    
    TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}  NLO+NLL exclusion");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"#tilde{#chi} ");
    textModelLabel->SetNDC();
    textModelLabel->SetTextAlign(13);
    textModelLabel->SetTextFont(42);
    textModelLabel->SetTextSize(0.042);
    textModelLabel->Draw();
    
    //final CMS style
    TLatex *tLumi = new TLatex(0.95,0.944,"2.3 fb^{-1} (13 TeV)");
    tLumi->SetNDC();
    tLumi->SetTextAlign(31);
    tLumi->SetTextFont(42);
    tLumi->SetTextSize(0.042);
    tLumi->SetLineWidth(2);
    tLumi->Draw();
    TLatex *tCMS = new TLatex(0.152,0.944,"CMS");
    tCMS->SetNDC();
    tCMS->SetTextAlign(11);
    tCMS->SetTextFont(61);
    tCMS->SetTextSize(0.0525);
    tCMS->SetLineWidth(2);
    tCMS->Draw();
    TLatex *tPrel = new TLatex(0.265,0.944,"Preliminary");
    tPrel->SetNDC();
    tPrel->SetTextAlign(11);
    tPrel->SetTextFont(52);
    tPrel->SetTextSize(0.042);
    tPrel->SetLineWidth(2);
    tPrel->Draw();
    
   c1->Modified();
   c1->cd();
    c1->Update();
   c1->SetSelected(c1);

}