Beispiel #1
0
void drawArrow(Double_t u, Double_t v, Double_t du, Double_t due, Double_t dv, Double_t dve){

  if ( du+dv ){ 

    Double_t arrowLengthSqr = du*du+dv*dv;
    Double_t relErrorOnArrowLength = sqrt(du*du*due*due+dv*dv*dve*dve)/arrowLengthSqr;
    
    Int_t color = 0; //-10, -9, -7, -4, 0
    Int_t lwid = 2;
    if ( relErrorOnArrowLength>0.5 ) color=kBlue-9;
    if ( relErrorOnArrowLength<0.4 ) color=kBlue-7;
    if ( relErrorOnArrowLength<0.3 ) color=kBlue-4;
    if ( relErrorOnArrowLength<0.2 ) color=kBlue;
    //    if ( relErrorOnArrowLength<0.1 ) color=kBlue;
    if ( relErrorOnArrowLength<0.1 ) {
      color=kBlue;
      lwid = 3;
    }
   if ( relErrorOnArrowLength<0.05 ) {
      color=kBlue;
      lwid = 4;
    }
   
   Double_t arrowSize = 0.006;

    TArrow * ar = new TArrow(u-0.5*du,v-0.5*dv,u+0.5*du,v+0.5*dv,arrowSize,"|>");
    ar->SetLineWidth(lwid);
    ar->SetFillColor(color);
    ar->SetLineColor(color);
    ar->Draw();
  }

}
Beispiel #2
0
void normArrow(float x, float y, float norm)
{
	// draw 100 mu m arrow if norm = 1
	TArrow* normArrow = new TArrow(x,y,x+norm,y,arrowSize,">");
	// normArrow->SetLineWidth(2);
	normArrow->Draw();
}
void Plot(RooRealVar *mass, RooDataSet *data, RooAbsPdf *pdf, pair<double,double> sigRange, vector<double> fwhmRange, string title, string savename){

  double semin=sigRange.first;
  double semax=sigRange.second;
  double fwmin=fwhmRange[0];
  double fwmax=fwhmRange[1];
  double halfmax=fwhmRange[2];
  double binwidth=fwhmRange[3];

  RooPlot *plot = mass->frame(Bins(binning_),Range("higgsRange"));
  if (data) data->plotOn(plot,Invisible());
  pdf->plotOn(plot,NormRange("higgsRange"),Range(semin,semax),FillColor(19),DrawOption("F"),LineWidth(2),FillStyle(1001),VLines(),LineColor(15));
  TObject *seffLeg = plot->getObject(int(plot->numItems()-1));
  pdf->plotOn(plot,NormRange("higgsRange"),Range(semin,semax),LineColor(15),LineWidth(2),FillStyle(1001),VLines());
  pdf->plotOn(plot,NormRange("higgsRange"),Range("higgsRange"),LineColor(kBlue),LineWidth(2),FillStyle(0));
  TObject *pdfLeg = plot->getObject(int(plot->numItems()-1));
  if (data) data->plotOn(plot,MarkerStyle(kOpenSquare));
  TObject *dataLeg = plot->getObject(int(plot->numItems()-1));
  TLegend *leg = new TLegend(0.15,0.89,0.5,0.55);
  leg->SetFillStyle(0);
  leg->SetLineColor(0);
  leg->SetTextSize(0.03);
  if (data) leg->AddEntry(dataLeg,"Simulation","lep");
  leg->AddEntry(pdfLeg,"Parametric model","l");
  leg->AddEntry(seffLeg,Form("#sigma_{eff} = %1.2f GeV",0.5*(semax-semin)),"fl");

  plot->GetXaxis()->SetNdivisions(509);
  halfmax*=(plot->getFitRangeBinW()/binwidth);
  TArrow *fwhmArrow = new TArrow(fwmin,halfmax,fwmax,halfmax,0.02,"<>");
  fwhmArrow->SetLineWidth(2.);
  TPaveText *fwhmText = new TPaveText(0.15,0.45,0.45,0.58,"brNDC");
  fwhmText->SetFillColor(0);
  fwhmText->SetLineColor(kWhite);
  fwhmText->SetTextSize(0.03);
  fwhmText->AddText(Form("FWHM = %1.2f GeV",(fwmax-fwmin)));

  TLatex lat1(0.65,0.85,"#splitline{CMS Preliminary}{Simulation}");
  lat1.SetNDC(1);
  lat1.SetTextSize(0.03);
  TLatex lat2(0.65,0.75,title.c_str());
  lat2.SetNDC(1);
  lat2.SetTextSize(0.025);

  TCanvas *canv = new TCanvas("c","c",600,600);
  plot->SetTitle("");
  plot->GetXaxis()->SetTitle("m_{#gamma#gamma} (GeV)");
  plot->Draw();
  leg->Draw("same");
  fwhmArrow->Draw("same <>");
  fwhmText->Draw("same");
  lat1.Draw("same");
  lat2.Draw("same");
  canv->Print(Form("%s.pdf",savename.c_str()));
  canv->Print(Form("%s.png",savename.c_str()));
  string path = savename.substr(0,savename.find('/'));
  canv->Print(Form("%s/animation.gif+100",path.c_str()));
  delete canv;

}
Beispiel #4
0
void Interface::dessinVent(double vent)
{
    if(vent != 0){
        TArrow *vecteurVent = new TArrow(245,290,245 + 5*vent,290);
        vecteurVent->SetLineColor(kBlack);
        vecteurVent->Draw();
    }

}
Beispiel #5
0
void drawLabels(){

  // "Hadron Gas"
  TLatex *xHad1 = new TLatex(0.11, 0.13, "Hadron");
  TLatex *xHad2 = new TLatex(0.15, 0.085, "Gas");
  xHad1->SetTextSize(0.04);
  xHad2->SetTextSize(0.04);
  if(iColor)xHad1->SetTextColor(4);
  if(iColor)xHad2->SetTextColor(4);
  xHad1->Draw();
  xHad2->Draw();

  //"Quark Gloun Plasma"
  TLatex *xQGP1 = new TLatex(0.55, 0.8, "Quark Gluon");
  TLatex *xQGP2 = new TLatex(0.62, 0.755, "Plasma");
  xQGP1->SetTextSize(0.04);
  xQGP2->SetTextSize(0.04);
  if(iColor)xQGP1->SetTextColor(4);
  if(iColor)xQGP2->SetTextColor(4);
  xQGP1->Draw();
  xQGP2->Draw();

  //"Early Universe"
  TArrow *aUniv = new TArrow(.025, 0.95,.025, 0.45,0.03,"|>");
  aUniv->SetLineWidth(2);
  if(iColor)aUniv->SetLineColor(2);
  if(iColor)aUniv->SetFillColor(2);
  aUniv->Draw();
  TLatex *xUniv = new TLatex(0.075, 0.58, "Early Universe");
  xUniv->SetTextSize(0.04);
  xUniv->SetTextAngle(90);
  if(iColor)xUniv->SetTextColor(2);
  xUniv->Draw();
  
  //"Neutron Stars"
  TArrow *aNeut = new TArrow(.65, .05 ,.99, 0.075,0.03,"|>");
  aNeut->SetLineWidth(2);
  if(iColor)aNeut->SetLineColor(8);
  if(iColor)aNeut->SetFillColor(8);
  aNeut->Draw();
  TLatex *xNeut = new TLatex(0.735, 0.08, "Neutron Stars");
  xNeut->SetTextSize(0.04);
  xNeut->SetTextAngle(5);
  if(iColor)xNeut->SetTextColor(8);
  xNeut->Draw();

  //"Critical Point"
  TLatex *xCrit1 = new TLatex(0.2, 0.585, "Critical");
  TLatex *xCrit2 = new TLatex(0.225, 0.54, "Point");
  xCrit1->SetTextSize(0.04);
  xCrit2->SetTextSize(0.04);
  xCrit1->Draw();
  xCrit2->Draw();
}
Beispiel #6
0
// draw a horizontal arrow of a certain length in pad coordinates at xy in NDC
// returns the new x in NDC
double drawArrowLength(TPad* pad, double x, double y, double length, Color_t color = 1)
{
    const double x1 = NDCtoUserX(pad,x);
    const double y1 = NDCtoUserY(pad,y);
    const double x2 = x1 + length;
    const double y2 = y1;
    TArrow *a = new TArrow(x1,y1,x2,y2,.01,">");
    a->SetLineColor(color);
    a->Draw();
    //pad->Update();
    cout << "Arrow: " << length << " " << pad->GetX2()-pad->GetX1() << endl;
    return x + (length/(pad->GetX2()-pad->GetX1()));
}
Beispiel #7
0
void transparency()
{
   TCanvas *c1 = new TCanvas("c1", "c1",224,330,700,527);
   c1->Range(-0.125,-0.125,1.125,1.125);

   TLatex *tex = new TLatex(0.06303724,0.0194223,"This text is opaque and this line is transparent");
   tex->SetLineWidth(2);
   tex->Draw();

   TArrow *arrow = new TArrow(0.5555158,0.07171314,0.8939828,0.6195219,0.05,"|>");
   arrow->SetLineWidth(4);
   arrow->SetAngle(30);
   arrow->Draw();

   // Draw a transparent graph.
   Double_t x[10] = {
   0.5232808, 0.8724928, 0.9280086, 0.7059456, 0.7399714,
   0.4659742, 0.8241404, 0.4838825, 0.7936963, 0.743553};
   Double_t y[10] = {
   0.7290837, 0.9631474, 0.4775896, 0.6494024, 0.3555777,
   0.622012, 0.7938247, 0.9482072, 0.3904382, 0.2410359};
   TGraph *graph = new TGraph(10,x,y);
   graph->SetLineColorAlpha(46, 0.1);
   graph->SetLineWidth(7);
   graph->Draw("l");

   // Draw an ellipse with opaque colors.
   TEllipse *ellipse = new TEllipse(0.1740688,0.8352632,0.1518625,0.1010526,0,360,0);
   ellipse->SetFillColor(30);
   ellipse->SetLineColor(51);
   ellipse->SetLineWidth(3);
   ellipse->Draw();

   // Draw an ellipse with transparent colors, above the previous one.
   ellipse = new TEllipse(0.2985315,0.7092105,0.1566977,0.1868421,0,360,0);
   ellipse->SetFillColorAlpha(9, 0.571);
   ellipse->SetLineColorAlpha(8, 0.464);
   ellipse->SetLineWidth(3);
   ellipse->Draw();

   // Draw a transparent blue text.
   tex = new TLatex(0.04871059,0.1837649,"This text is transparent");
   tex->SetTextColorAlpha(9, 0.476);
   tex->SetTextSize(0.125);
   tex->SetTextAngle(26.0);
   tex->Draw();
}
Beispiel #8
0
void drawEventRPhi(double vxlb, double vylb, double vxl0, double vyl0, double pmu1, double phimu1, double pmu2, double phimu2, double ppr, double phipr, double ppi, double phipi, int colors = 0)
{
    Color_t colMu1(1), colMu2(1), colPr(1), colPi(1), colL0(1), colLb(1);
    switch(colors)
    {
	case 0:
	    colLb=1; colL0=2; colMu1=2; colMu2=2; colPr=3; colPi=4; break;
	case 1:
	    colLb=11; colL0=50; colMu1=50; colMu2=50; colPr=8; colPi=9; break;
    }
    // draw the vertices
    TMarker *m;
    const double xlb = vxlb;
    const double ylb = vylb;
    m = new TMarker(xlb,ylb,7);
    m->SetMarkerColor(colLb);
    m->Draw();
    const double xl0 = vxl0;
    const double yl0 = vyl0;
    m = new TMarker(xl0,yl0,7);
    m->SetMarkerColor(colL0);
    m->Draw();
    // draw the l0 flight line
    TLine *l;
    l = new TLine(vxlb,vylb,vxl0,vyl0);
    l->SetLineColor(colL0);
    l->SetLineStyle(2);
    l->Draw();
    // draw the muons
    TArrow *a;
    const double xmu1 = xlb + scalemu * pmu1 * TMath::Cos(phimu1);
    const double ymu1 = ylb + scalemu * pmu1 * TMath::Sin(phimu1);
    a = new TArrow(xlb,ylb,xmu1,ymu1,.01,">");
    a->SetLineColor(colMu1);
    a->Draw();
    const double xmu2 = xlb + scalemu * pmu2 * TMath::Cos(phimu2);
    const double ymu2 = ylb + scalemu * pmu2 * TMath::Sin(phimu2);
    a = new TArrow(xlb,ylb,xmu2,ymu2,.01,">");
    a->SetLineColor(colMu2);
    a->Draw();
    // draw the p and pi
    const double xpr = xl0 + scalepr * ppr * TMath::Cos(phipr);
    const double ypr = yl0 + scalepr * ppr * TMath::Sin(phipr);
    a = new TArrow(xl0,yl0,xpr,ypr,.01,">");
    a->SetLineColor(colPr);
    a->Draw();
    const double xpi = xl0 + scalepi * ppi * TMath::Cos(phipi);
    const double ypi = yl0 + scalepi * ppi * TMath::Sin(phipi);
    a = new TArrow(xl0,yl0,xpi,ypi,.01,">");
    a->SetLineColor(colPi);
    a->Draw();
}
Beispiel #9
0
void drawExperiments(){
  TEllipse *eRHIC = new TEllipse(0.4, 0.55, 0.035, 0.13, 0., 165., 335.);
  //  eRHIC->SetFillColor(0);
  eRHIC->SetNoEdges();
  eRHIC->SetFillStyle(0);
  eRHIC->SetLineWidth(2);
  eRHIC->Draw();
  TLine *lGarbage = new TLine(0.383507,0.595395,0.401148,0.546523);
  lGarbage->SetLineColor(17);
  lGarbage->SetLineWidth(3);
  lGarbage->Draw();
  TArrow *aRHIC = new TArrow(0.385543,0.600282,0.382829,0.595395, 0.025, "|>");
  aRHIC->Draw();
  TLatex *xRHIC = new TLatex(0.417432, 0.679342, "RHIC");
  xRHIC->SetTextSize(0.04);
  xRHIC->Draw();
}
Beispiel #10
0
int makeZPhiArrowPlot( TTree* data, const char* name, double zLim, double phiLim, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){
	
	
	TCanvas* OBPCanvas = new TCanvas(name,name,1050,875);
	OBPCanvas->DrawFrame(-zLim, -phiLim, 1.2*zLim, phiLim, ";module position z [cm];module position r*phi [cm]");
	OBPCanvas->SetFillColor(0);
	OBPCanvas->SetFrameBorderMode(0);
	
	TFrame* aFrame = OBPCanvas->GetFrame();
	aFrame->SetFillColor(0);
	
	int passcut = 0;
	for(int entry = 0;entry<data->GetEntries(); entry++)
    {
		data->GetEntry(entry);
			if ((level_ == level)&&(((sublevel_ == sublevel)&&(sublevel != 0))||(sublevel == 0))){
			if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){
				TArrow* aArraw = new TArrow( z_, r_*phi_ , z_ + barrelRPhiRescale*dz_, r_*phi_+barrelRPhiRescale*r_*dphi_,0.0075,">");
				aArraw->Draw();
				passcut++;
			}
		}
	}
	DrawRPhiLegend( zLim, phiLim, barrelRPhiRescale );
	
	char sliceLeg[192]; 
	sprintf( sliceLeg, "%s: %f < r <= %f", name, rMin, rMax );
	//Plot10Mu( name, xLim/2, yLim, 0.2*xLim );
	TPaveText* atext = new TPaveText(0.2*zLim,0.85*phiLim,0.66*zLim,0.99*phiLim);
	atext->AddText(sliceLeg);
	atext->SetLineColor(0);
	atext->SetFillColor(0);
	atext->SetTextFont(42);
	atext->SetTextSize(0.04);
	atext->Draw();
	
	
	
	char outfile[192];
	sprintf( outfile, "%s/%s.png", outputDir_, name );
	OBPCanvas->Print( outfile );
	
	return passcut;
}
Beispiel #11
0
void drawAxis()
{
  TArrow *arr = new TArrow(0,0,1,0,0.03,"|>");
  arr->SetFillColor(1);
  arr->SetLineWidth(2);
  arr->Draw();
  
  arr = new TArrow(0,0,0,1,0.03,"|>");
  arr->SetFillColor(1);
  arr->SetLineWidth(2);
  arr->Draw();
}
Beispiel #12
0
void arrow (Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t ls)
{
   TArrow *arr = new TArrow(x1,y1,x2,y2,0.025,"|>");
   arr->SetFillColor(1);
   arr->SetFillStyle(1001);
   arr->SetLineStyle(ls);
   arr->SetAngle(19);
   arr->Draw();
}
Beispiel #13
0
void
HHV4Vector::Draw(Int_t color, Int_t style) const
{  // draw particle for event display in x-y view
  TArrow *Ar = new TArrow(0, 0, Px(), Py(), 0.001, "|>");
  Ar->SetLineColor(color);
  Ar->SetFillColor(color);
  Ar->SetLineWidth(3);
  Ar->SetLineStyle(style);
  Ar->Draw();
}
void draw_synapse(Double_t cx1, Double_t cy1, Double_t cx2, Double_t cy2,
                  Double_t  rad1, Double_t rad2, Double_t weightNormed)
{
   const Double_t TIP_SIZE   = 0.01;
   const Double_t MAX_WEIGHT = 8;
   const Double_t MAX_COLOR  = 100;  // red
   const Double_t MIN_COLOR  = 60;   // blue

   if (weightNormed == 0) return;

   //   gStyle->SetPalette(100, NULL);

   TArrow *arrow = new TArrow(cx1+rad1, cy1, cx2-rad2, cy2, TIP_SIZE, ">");
   arrow->SetFillColor(1);
   arrow->SetFillStyle(1001);
   arrow->SetLineWidth((Int_t)(TMath::Abs(weightNormed)*MAX_WEIGHT+0.5));
   arrow->SetLineColor((Int_t)((weightNormed+1.0)/2.0*(MAX_COLOR-MIN_COLOR)+MIN_COLOR+0.5));
   arrow->Draw();
}
Beispiel #15
0
void drawEventZR(double vrlb, double vzlb, double vrl0, double vzl0, double pmu1, double etamu1, double pmu2, double etamu2, double ppr, double etapr, double ppi, double etapi, int colors = 0)
{
    Color_t colMu1(1), colMu2(1), colPr(1), colPi(1), colL0(1), colLb(1);
    switch(colors)
    {
	case 0:
	    colLb=1; colL0=2; colMu1=2; colMu2=2; colPr=3; colPi=4; break;
	case 1:
	    colLb=11; colL0=50; colMu1=50; colMu2=50; colPr=8; colPi=9; break;
    }
    cout << etamu1 << " " << etamu2 << " " << etapr << " " << etapi << endl;
    const double thetamu1 = 2*TMath::ATan(TMath::Exp(-etamu1));
    const double thetamu2 = 2*TMath::ATan(TMath::Exp(-etamu2));
    const double thetapr = 2*TMath::ATan(TMath::Exp(-etapr));
    const double thetapi = 2*TMath::ATan(TMath::Exp(-etapi));
    //const double thetamu1 = 2*TMath::ATan(TMath::Exp(-TMath::Abs(etamu1)))*sign(etamu1);
    //const double thetamu2 = 2*TMath::ATan(TMath::Exp(-TMath::Abs(etamu2)))*sign(etamu2);
    //const double thetapr = 2*TMath::ATan(TMath::Exp(-TMath::Abs(etapr)))*sign(etapr);
    //const double thetapi = 2*TMath::ATan(TMath::Exp(-TMath::Abs(etapi)))*sign(etapi);
    // draw the vertices
    TMarker *m;
    const double xlb = vzlb;
    const double ylb = vrlb;
    m = new TMarker(xlb,ylb,7);
    m->SetMarkerColor(colLb);
    m->Draw();
    const double xl0 = vzl0;
    const double yl0 = vrl0;
    m = new TMarker(xl0,yl0,7);
    m->SetMarkerColor(colL0);
    m->Draw();
    // draw the l0 flight line
    TLine *l;
    l = new TLine(vzlb,vrlb,vzl0,vrl0);
    l->SetLineColor(colL0);
    l->SetLineStyle(2);
    l->Draw();
    // draw the muons
    TArrow *a;
    const double xmu1 = xlb + scalemu * pmu1 * TMath::Cos(thetamu1);
    const double ymu1 = ylb + scalemu * pmu1 * TMath::Sin(thetamu1);
    a = new TArrow(xlb,ylb,xmu1,ymu1,.01,">");
    a->SetLineColor(colMu1);
    a->Draw();
    const double xmu2 = xlb + scalemu * pmu2 * TMath::Cos(thetamu2);
    const double ymu2 = ylb + scalemu * pmu2 * TMath::Sin(thetamu2);
    a = new TArrow(xlb,ylb,xmu2,ymu2,.01,">");
    a->SetLineColor(colMu2);
    a->Draw();
    // draw the p and pi
    const double xpr = xl0 + scalepr * ppr * TMath::Cos(thetapr);
    const double ypr = yl0 + scalepr * ppr * TMath::Sin(thetapr);
    a = new TArrow(xl0,yl0,xpr,ypr,.01,">");
    a->SetLineColor(colPr);
    a->Draw();
    const double xpi = xl0 + scalepi * ppi * TMath::Cos(thetapi);
    const double ypi = yl0 + scalepi * ppi * TMath::Sin(thetapi);
    a = new TArrow(xl0,yl0,xpi,ypi,.01,">");
    a->SetLineColor(colPi);
    a->Draw();
}
Beispiel #16
0
void toyMC(int nsteps = 1e6) {
    
    Float_t LA = 9.2;
    Float_t LB = 10.3;
    
    Float_t SF = 492./LB;
    Float_t eSF = TMath::Sqrt(23.*23.+19.7*19.7)/LB;
//     Float_t OF = 358./LA;
//     Float_t eOF = 27./LA;
    Float_t OF = 358./LB;
    Float_t eOF = 31./LB;
    
    Float_t SigB = 188.+238-414;
    
    
    TH1F* hSig = new TH1F("hSig ; SF-R_{SF/OF}#timesOF ; ","Signal component",600,-100.,500.);
    
    hSig->SetLineColor(kRed+2);
    
    TRandom3* ran = new TRandom3();
    
    for ( int i=0; i<nsteps; ++i ) {
        
        Float_t nBSF = ran->Gaus(SF*LB,eSF*LB);
        Float_t nBOF = ran->Gaus(OF*LB,eOF*LB);
        Float_t rsfof = ran->Gaus(1.0,0.05);
        
        hSig->Fill(nBSF-nBOF*rsfof);
        
    }
    
    
    TCanvas* mycan = new TCanvas("mycan","",100,10,900,600);
    mycan->SetLogy();
    TH1F* hSigNorm = hSig->DrawNormalized("");
    hSigNorm->SetMinimum(1e-5);
    hSigNorm->Draw();
    
    // Find 95% CL range
    float integral = 0;
    int binStart = -1;
    while ( integral <= 0.025 ) {
        ++binStart;
        integral += hSigNorm->GetBinContent(binStart);
    }
    std::cout << integral << " up to " << hSigNorm->GetBinCenter(binStart) << std::endl;
    integral = 0;
    int binEnd = hSigNorm->GetNbinsX()+2;
    while ( integral <= 0.025 ) {
        --binEnd;
        integral += hSigNorm->GetBinContent(binEnd);
    }
    std::cout << integral << " up to " << hSigNorm->GetBinCenter(binEnd) << std::endl;
    
    // Draw 95% CL
    TBox* range95 = new TBox(hSigNorm->GetBinCenter(binStart),hSigNorm->GetMinimum(),hSigNorm->GetBinCenter(binEnd),1.2*hSigNorm->GetMaximum());
    range95->SetFillColor(kBlue-9);
    range95->SetFillStyle(1000);
    range95->SetLineColor(range95->GetFillColor());
    range95->Draw();
    
    hSigNorm->SetTitle("hSigNorm; \"S\" #equiv SF - R_{SF/OF}#timesOF ; pdf");
    hSigNorm->Draw("same");
    
    std::cout << "Integrating from 0 to " << SigB << ": " << std::endl;
    std::cout << hSigNorm->Integral(0,hSigNorm->FindBin(SigB)) <<std::endl;
    
    TLegend* legend = new TLegend(0.6,0.7,0.95,0.9,"","brNDC");
    legend->SetBorderSize(0);
    legend->AddEntry(hSigNorm,"Expected \"S\" for block B","l");
    legend->AddEntry(range95,"95% region","f");
    legend->Draw();

    mycan->RedrawAxis();
    mycan->SaveAs("toyMCexp.pdf");

    TArrow* a = new TArrow(SigB,hSigNorm->GetMaximum(),SigB,hSigNorm->GetMinimum()*1.1,0.02);
    a->SetLineColor(kBlue+2);
    a->Draw();


    TLegend* legend2 = new TLegend(0.6,0.6,0.95,0.7,"","brNDC");
    legend2->SetBorderSize(0);
    legend2->AddEntry(a,"Observed (p-value 0.6%)","l");
    legend2->Draw();
    

    mycan->SaveAs("toyMC.pdf");
    
}
void RoutePlot(){
gStyle->SetTitleX(0.21);
gStyle->SetTitleY(0.98);

  const int minIteration=0;
  const int Iteration=10;
  int nParticles=20;
  
  TGraph* emptygraph = new TGraph(1);
  emptygraph->SetPoint(0,1000,0.005);
  
  std::vector< std::vector<TGraph*> > graphs;
  std::vector<TPolyLine*> lines;
  std::vector<TGraph*> FirstPoints;
  std::vector<TGraph*> LastPoints;
  std::vector< std::vector<TArrow*> > arrows;
  

  //get max an min ROC
  Int_t bestPartIteration[Iteration];
  Double_t bestROCIteration[Iteration];
  for(int o=0;o<Iteration;o++){bestROCIteration[o]=0.0;}
  Double_t maxROC=0.0;
  Double_t minROC=1.0;
  Double_t bestROCGlobal=0.0;
  for(int i=0;i<nParticles;i++){
//      if(!(i==1 or i==13 or i==5 or i==6 or i==8 or i==4 or i==14 or i==18))continue;

//     std::cout<<i<<std::endl;
    std::string buffer="";
    std::stringstream buffer2;
    buffer2<<i;
//     std::cout<<buffer2.str()<<" "<<buffer2.str()<<std::endl;
//     buffer2>>buffer;
    std::string filename="../Particles_long/Particle";
    filename+=buffer2.str();
    filename+="/ParticleRoute.txt";
//     std::cout<<filename.c_str()<<std::endl;
    std::ifstream inputfile(filename.c_str());
//     std::ifstream inputfile("Particles_long/Particle1/ParticleRoute.txt");

    int k=0;
    double nTrees=0.0;
    double shrinkage=0.0;
    double bagging=0.0;
    double cuts=0.0;
    double ROC=0.0;
    double KS=0.0;
    double depth=0.0;
    bool readline=true;
    while(readline){
      inputfile>>ROC;
      inputfile>>KS;
      inputfile>>nTrees;
      inputfile>>shrinkage;
      inputfile>>bagging;
      inputfile>>cuts;
//       inputfile>>depth;
      std::string dump="";
      int j=0;
      do{
        inputfile>>dump;
//         std::cout<<dump<<std::endl;
        j++;
//         if(dump=="--Next--")std::cout<<"here"<<std::endl;
//         if(dump=="--Next--\n")std::cout<<"too"<<std::endl;
//         if(dump=="")std::cout<<"never"<<std::endl;

      }while(dump!="--Next--" and dump!="--Next--\n" and dump!="");
//       std::cout<<"Data "<<nTrees<<" "<<shrinkage<<" "<<ROC<<std::endl;
      if(dump!="" and k>=minIteration){
        if(ROC>maxROC)maxROC=ROC;
        if(ROC<minROC and ROC!=0)minROC=ROC;
      
      }
      k++;
//      inputfile>>dump;
      if(inputfile.eof() or dump=="" or k==Iteration)readline=false;
    }

    inputfile.close();
    std::cout<<"NPoints: "<<k<<std::endl;
  }
  std::cout<<"ROC range "<<minROC<<"  "<<maxROC<<std::endl;
  
  //get marker scaling;
  Double_t maxSize=2.4;
  Double_t minSize=0.3;
  minROC=0.74;
  Double_t m = (maxSize-minSize)/(maxROC-minROC);
  Double_t abschnitt = maxSize-m*maxROC;
  std::cout<<m<<" "<<abschnitt<<std::endl;
  std::cout<<minSize<<" "<<maxSize<<std::endl;

      
  //read points
  for(int i=0;i<nParticles;i++){
      if(!(i==1 or i==2 or i==4 or i==10 or i==13 or i==14 or i==17))continue;

    std::cout<<i<<std::endl;
    std::string buffer="";
    std::stringstream buffer2;
    buffer2<<i;
//     std::cout<<buffer2.str()<<" "<<buffer2.str()<<std::endl;
//     buffer2>>buffer;
    std::string filename="../Particles_long/Particle";
    filename+=buffer2.str();
    filename+="/ParticleRoute.txt";
    std::cout<<filename.c_str()<<std::endl;
    std::ifstream inputfile(filename.c_str());
//     std::ifstream inputfile("Particles_long/Particle1/ParticleRoute.txt");

    std::vector< TGraph*> buffgraph;
    graphs.push_back( buffgraph);
    lines.push_back(new TPolyLine);
    FirstPoints.push_back(new TGraph);
    LastPoints.push_back(new TGraph);
    std::vector< TArrow*> buffarrow;
    arrows.push_back(buffarrow);


    int k=0;
    int kk=0;
    double nTrees=0.0;
    double shrinkage=0.0;
    double bagging=0.0;
    double cuts=0.0;
    double ROC=0.0;
    double KS=0.0;
    double depth=0.0;
    
    bool readline=true;
    while(readline){
      inputfile>>ROC;
      inputfile>>KS;
      inputfile>>nTrees;
      inputfile>>shrinkage;
      inputfile>>bagging;
      inputfile>>cuts;
//       inputfile>>depth;
      std::string dump="";
      int j=0;
      do{
        inputfile>>dump;
//         std::cout<<dump<<std::endl;
        j++;
//         if(dump=="--Next--")std::cout<<"here"<<std::endl;
//         if(dump=="--Next--\n")std::cout<<"too"<<std::endl;
//         if(dump=="")std::cout<<"never"<<std::endl;

      }while(dump!="--Next--" and dump!="--Next--\n" and dump!="");
//       std::cout<<"Data "<<nTrees<<" "<<shrinkage<<" "<<ROC<<std::endl;
      if(dump!="" and k>=minIteration){
        kk++;
        graphs.back().push_back(new TGraph);
        graphs.back().back()->SetPoint(0,nTrees,shrinkage);
        if(ROC==0)graphs.back().back()->SetMarkerStyle(3);
        else{
          graphs.back().back()->SetMarkerStyle(8);
//           std::cout<<TMath::Exp(ROC)<<std::endl;
          Double_t size=m*ROC+abschnitt;
          graphs.back().back()->SetMarkerSize(size); 
          std::cout<<j<<" "<<ROC<<" "<<size<<std::endl;

        }
        if(k==minIteration)graphs.back().back()->SetMarkerStyle(34);
        if(k>=minIteration)lines.back()->SetPoint(kk-1,nTrees,shrinkage);
        
        
           
          
          //if(k==0)FirstPoints.back()->SetPoint(0,nTrees,shrinkage);
      
      }
      if(ROC>=bestROCIteration[k]){
      bestROCIteration[k]=ROC;
      bestPartIteration[k]=i;
//       if(ROC>=bestROCGlobal)bestROCGlobal=ROC;
//       if(bestROCGlobal>=bestROCIteration[k])bestROCIteration[k]=bestROCGlobal;
      }
      
      k++;
//      inputfile>>dump;
      if(inputfile.eof() or dump=="" or k==Iteration)readline=false;
    }
    
//     LastPoints.back()->SetPoint(0,nTrees,bagging);

    inputfile.close();
    std::cout<<"NPoints: "<<k<<std::endl;
    
    //get velocities
    for(size_t l=1;l<graphs.back().size()-1;l++){
//       std::cout<<graphs.size()<<std::endl;
      Double_t PrevTrees=0.001;
      Double_t PrevShrinkage=0.001;
      graphs.back().at(l-1)->GetPoint(0,PrevTrees,PrevShrinkage);
//       std::cout<<PrevTrees<<" "<<PrevShrinkage<<std::endl;
      Double_t CurrTrees;
      Double_t CurrShrinkage;
      graphs.back().at(l)->GetPoint(0,CurrTrees,CurrShrinkage);
      Double_t NextTrees;
      Double_t NextShrinkage;
      graphs.back().at(l+1)->GetPoint(0,NextTrees,NextShrinkage);
      Double_t velTree=CurrTrees-PrevTrees;
      Double_t velShrinkage=CurrShrinkage-PrevShrinkage;
      Double_t nvelTree=NextTrees-CurrTrees;
      Double_t nvelShrinkage=NextShrinkage-CurrShrinkage;
      Double_t forceTrees=nvelTree-0.73*velTree;
      Double_t forceShrinkage=nvelShrinkage-0.73*velShrinkage;
      arrows.back().push_back(new TArrow(CurrTrees,CurrShrinkage,CurrTrees+forceTrees,CurrShrinkage+forceShrinkage,0.02,">"));
      
    }
    
  }//end input loop
    
    //Get velocities
    
    
    TCanvas* c = new TCanvas("c","c",1024,768);
    TLegend* leg= new TLegend(0.5,0.75,0.7,0.95);
    leg->SetFillColor(0);
    leg->SetTextFont(42);
    std::vector<TGraph*> leggraphs;

    for(size_t i=0;i<graphs.size();i++){
      leggraphs.push_back(new TGraph);
      leggraphs.back()->SetMarkerColor(1+i);
      leggraphs.back()->SetMarkerStyle(8);
      leggraphs.back()->SetMarkerSize(1);
      if(i==2)leggraphs.back()->SetMarkerColor(9);
      leg->AddEntry(leggraphs.back(), Form("particle %i",i+1),"p");
    }
    TLegend* legMarker= new TLegend(0.7,0.65,0.9,0.95);
    legMarker->SetFillColor(0);
    legMarker->SetFillStyle(0);
    legMarker->SetTextFont(42);
    TLegend* legCMS= new TLegend(0.07,0.85,0.39,0.95);
    legCMS->SetFillColor(0);
    legCMS->SetFillStyle(0);
    legCMS->SetBorderSize(0);
    legCMS->SetTextFont(42);
    legCMS->AddEntry((TObject*)0,"CMS private work","");
    TPaveText* legExplain= new TPaveText(0.23,0.84,0.73,0.94,"NDC");
    legExplain->SetFillColor(3);
    legExplain->SetFillStyle(0);
    legExplain->SetBorderSize(0);
    legExplain->AddText("BDTs trained and tested with t#bar{t}H, H#rightarrowb#bar{b} and t#bar{t} MC-Samples");
    legExplain->SetTextFont(42);
    
    TGraph* initMarker = new TGraph();
    initMarker->SetMarkerStyle(34);
    initMarker->SetMarkerSize(1.5);
    TGraph* zeroKSMarker = new TGraph();
    zeroKSMarker->SetMarkerStyle(3);
    zeroKSMarker->SetMarkerSize(1.5);
    legMarker->AddEntry(initMarker,"init. pos.","p");
    
    TArrow* legArrow = new TArrow(100,0.01,200,0.02,0.02,">");
    TArrow* legArrow2 = new TArrow(1270,0.0453,1320,0.0453,0.02,">");
    
    legArrow->SetLineColor(0);
    legArrow->SetFillColor(0);
    legArrow2->SetLineWidth(2);
    legArrow2->SetAngle(40);
    legMarker->AddEntry(legArrow,"#Delta#vec{v}","");
//         legMarker->AddEntry((TObject*)0,"","");
    legMarker->AddEntry(zeroKSMarker,"KS < min KS","p");

    TGraph* sizegraph1 = new TGraph();
    sizegraph1->SetMarkerStyle(8);
    Double_t size2=m*0.74+abschnitt;
    sizegraph1->SetMarkerSize(size2);
    legMarker->AddEntry(sizegraph1, "A_{ROC} = 0.74","p");
    TGraph* sizegraph2 = new TGraph();
    sizegraph2->SetMarkerStyle(8);
    size2=m*0.76+abschnitt;
    sizegraph2->SetMarkerSize(size2);
    legMarker->AddEntry(sizegraph2, "A_{ROC} = 0.76","p");
    TGraph* sizegraph3 = new TGraph();
    sizegraph3->SetMarkerStyle(8);
    size2=m*0.78+abschnitt;
    sizegraph3->SetMarkerSize(size2);
    legMarker->AddEntry(sizegraph3, "A_{ROC} = 0.78","p");
    
    
    
    for(size_t i=0;i<graphs.size();i++){

      if(i==0){
        c->cd();
        
        
        emptygraph->Draw("AP");
        c->Update();
        emptygraph->GetXaxis()->SetLimits(200,1600);
        emptygraph->GetXaxis()->SetRangeUser(200,1600);

        emptygraph->GetYaxis()->SetLimits(0.0,0.05);
        emptygraph->GetYaxis()->SetRangeUser(0.0,0.05);
        //emptygraph->SetTitle("particle paths in the n_{Trees} - shrinkage plane");
        emptygraph->SetTitle("");
        emptygraph->GetXaxis()->SetTitle("n_{Trees}");
        emptygraph->GetYaxis()->SetTitle("shrinkage");
        emptygraph->GetYaxis()->SetTitleOffset(1.5);
        emptygraph->GetXaxis()->SetTitleOffset(1.2);
       std::cout<<emptygraph->GetXaxis()->GetTitleFont()<<std::endl;

	c->SetTopMargin(0.05);
        c->Update();
        for(size_t j=0;j<graphs.at(i).size();j++){
//           graphs.at(i).at(j)->SetMarkerStyle(3);
          graphs.at(i).at(j)->SetMarkerColor(1+i);
          graphs.at(i).at(j)->SetLineColor(1+i);
//         graphs.at(i)->GetXaxis()->SetLimits(200.0,2500.0);
//         graphs.at(i)->GetYaxis()->SetLimits(0.1,0.9);
//         graphs.at(i)->GetZaxis()->SetRangeUser(0.0,1.0);
          graphs.at(i).at(j)->Draw("P SAME");
        c->Update();
        }
        for(size_t j=0;j<arrows.at(i).size();j++){
          arrows.at(i).at(j)->SetLineColor(1+i);
          arrows.at(i).at(j)->SetFillColor(1+i);
          arrows.at(i).at(j)->SetAngle(40);
          arrows.at(i).at(j)->SetLineWidth(1.9);
          arrows.at(i).at(j)->Draw("");
          c->Update();
        }
        lines.at(i)->SetLineColor(1+i);
        lines.at(i)->SetLineStyle(7);
        lines.at(i)->Draw();
        c->Update();
        
//         FirstPoints.at(i)->SetMarkerStyle(20);
//         FirstPoints.at(i)->SetMarkerColor(1+i);
//         FirstPoints.at(i)->Draw("P SAME");
//         LastPoints.at(i)->SetMarkerStyle(21);
//         LastPoints.at(i)->SetMarkerColor(1+i);
//         LastPoints.at(i)->Draw("P SAME");
//         c->Update();
//         LastPoints.at(i)->GetXaxis()->SetRangeUser(200.0,2500.0);
//         LastPoints.at(i)->GetYaxis()->SetRangeUser(0.0001,0.05);
//         LastPoints.at(i)->GetZaxis()->SetRangeUser(0.0,1.0);
//         LastPoints.at(i)->Draw("P SAME");

//         graphs.at(i)->Draw("P SAME");
        c->Update();
//         TObject* view = c->GetView3D();
//         TAxis3D *axis = TAxis3D::GetPadAxis();
//         std::cout<<view<<std::endl;
//         TAxis3D::ToggleRulers();     // To pop axice down
//         axis->SetLabelColor(kBlue); // Paint the axice labels with blue color
//         axis->SetAxisColor(kRed);   // Paint the axice itself with blue color
//         TAxis3D::ToggleRulers(); 
//         axis->Paint();// To pop axice up
//         c->Update();
        
      }
      else{
        c->cd();
        for(size_t j=0;j<graphs.at(i).size();j++){
//           graphs.at(i).at(j)->SetMarkerStyle(3);
          graphs.at(i).at(j)->SetMarkerColor(1+i);
          graphs.at(i).at(j)->SetLineColor(1+i);
          if(i==2){
          graphs.at(i).at(j)->SetMarkerColor(9);
          graphs.at(i).at(j)->SetLineColor(9);
          }
//         graphs.at(i)->GetXaxis()->SetRangeUser(200.0,2500.0);
//         graphs.at(i)->GetYaxis()->SetRangeUser(0.0001,0.05);
//         graphs.at(i)->GetZaxis()->SetRangeUser(0.0,1.0);
          graphs.at(i).at(j)->Draw("SAME P");
        c->Update();
        }
        for(size_t j=0;j<arrows.at(i).size();j++){
        arrows.at(i).at(j)->SetLineColor(1+i);
        arrows.at(i).at(j)->SetFillColor(1+i);
        if(i==2){
        arrows.at(i).at(j)->SetLineColor(9);
        arrows.at(i).at(j)->SetFillColor(9);
        }
        arrows.at(i).at(j)->SetAngle(40);
        arrows.at(i).at(j)->SetLineWidth(1.9);


        arrows.at(i).at(j)->Draw("");
        c->Update();
        }
        lines.at(i)->SetLineColor(1+i);
        lines.at(i)->SetLineStyle(7);
        if(i==2)lines.at(i)->SetLineColor(9);

        lines.at(i)->Draw();
        c->Update();
        
// d        FirstPoints.at(i)->SetMarkerStyle(20);
//     d    FirstPoints.at(i)->SetMarkerColor(1+i);
//         FirstPoints.at(i)->Draw("P Same");
//         LastPoints.at(i)->SetMarkerStyle(21);
//         LastPoints.at(i)->SetMarkerColor(1+i);
//         LastPoints.at(i)->Draw("P Same");
        c->Update();
      }
      
    }
    legArrow2->Draw("");
    leg->Draw();
    legMarker->Draw();
    legCMS->Draw();
    //legExplain->Draw();
    c->Update();
    TString outfile="ParticleRoute_";
    outfile+=Iteration;
    outfile+="eng.eps";
    c->SaveAs(outfile);
    
    
    for(int p=0;p<Iteration;p++){
    if(p>0 and bestROCIteration[p-1]>bestROCIteration[p])bestROCIteration[p]=bestROCIteration[p-1];

    std::cout<<p<<" "<<bestROCIteration[p]<<" "<<bestPartIteration[p]<<std::endl;
    
    }
}
void determineWorkingPoint(TString algo="csv",TString baseURL="~/scratch0/top-nosyst/plotter.root")
{
  float workPoint(0.244);
  float sfb(1.020),    sfberr(0.04);      //from BTV-11-003
  float sflight(1.08), sflighterr(0.13);  //from BTV-11-002
  //  float sfb(0.99),        sfberr(0.099);      //from BTV-11-001
  //  float sflight(1.07882), sflighterr(0.244);  //from BTV-11-001
  if(algo=="tche")
    {
      workPoint=1.7;
      sfb=0.95; sfberr=0.095;
      sflight=1.08018; sflighterr=0.1125;
    }

  TObjArray bjets=getDistributionFromPlotter(algo+"b",baseURL);
  TObjArray lightjets=getDistributionFromPlotter(algo+"light",baseURL);
  
  TH1F *bDisc=(TH1F *) bjets.At(1);
  TH1F *lightDisc=(TH1F *) lightjets.At(1);
  
  setStyle();
  gStyle->SetOptFit(0);

  TCanvas *cnv = getNewCanvas("c","c",false);
  cnv->Clear();
  cnv->SetCanvasSize(1200,1200);
  cnv->SetWindowSize(1200,1200);
  cnv->Divide(2,2);

  //draw the discriminator
  TPad *p = (TPad *)cnv->cd(1); 
  bDisc->SetTitle("b");
  bDisc->SetLineColor(1);
  bDisc->SetMarkerColor(1);
  bDisc->SetMarkerStyle(20);
  bDisc->SetFillStyle(0);
  bDisc->DrawNormalized("histe1");
  lightDisc->SetLineColor(1);
  lightDisc->SetMarkerColor(1);
  lightDisc->SetMarkerStyle(24);
  lightDisc->SetFillStyle(0);
  lightDisc->SetTitle("udcsg");
  lightDisc->DrawNormalized("histe1same");
  TLegend *leg=p->BuildLegend();
  formatForCmsPublic(p,leg,"CMS simulation",2);

  //draw the b/light efficiencies
  p=(TPad *)cnv->cd(2);
  p->SetLogy();
  TGraphAsymmErrors *bEff     = getEfficiencyFrom(bDisc);
  TGraphAsymmErrors *lightEff = getEfficiencyFrom(lightDisc);
  bEff->SetMarkerStyle(20);
  bEff->SetFillStyle(0);
  bEff->Draw("ap");
  bEff->GetXaxis()->SetTitle(bDisc->GetXaxis()->GetTitle());
  bEff->GetYaxis()->SetTitle("Efficiency");
  lightEff->SetMarkerStyle(24);
  lightEff->SetFillStyle(0);
  lightEff->Draw("p");

  //draw relatively to a given working point
  p=(TPad *)cnv->cd(3);
  Double_t baseBEff=bEff->Eval(workPoint);
  TGraphAsymmErrors *relBEff=new TGraphAsymmErrors;
  relBEff->SetMarkerStyle(20);
  relBEff->SetFillStyle(0);
  Double_t baseLightEff=lightEff->Eval(workPoint);
  TGraphAsymmErrors *relLightEff=new TGraphAsymmErrors;
  relLightEff->SetMarkerStyle(24);
  relLightEff->SetFillStyle(0);
  for(int ip=0; ip<bEff->GetN(); ip++)
    {
      Double_t cut, y,ey; 
      bEff->GetPoint(ip,cut,y);     ey = bEff->GetErrorY(ip);
      Double_t relEff(y/baseBEff);
      if(relEff<sfb+2*sfberr && relEff>sfb-2*sfberr)
	{
	  int ipt=relBEff->GetN();
	  relBEff->SetPoint(ipt,cut,relEff);
	  relBEff->SetPointError(ipt,0,0,ey/baseBEff,ey/baseBEff);
	}

      lightEff->GetPoint(ip,cut,y);     ey = lightEff->GetErrorY(ip);
      relEff=y/baseLightEff;
      //      if(relEff<sflight+7*sflighterr && relEff>sflight-7*sflighterr)
      if(relEff<sflight+3*sflighterr && relEff>sflight-3*sflighterr)
	{
	  int ipt=relLightEff->GetN();
	  relLightEff->SetPoint(ipt,cut,relEff);
	  relLightEff->SetPointError(ipt,0,0,ey/baseLightEff,ey/baseLightEff);
	}
    }

  relLightEff->Draw("ap");
  relLightEff->GetXaxis()->SetTitle( bDisc->GetXaxis()->GetTitle() );
  relLightEff->GetYaxis()->SetTitle( "#varepsilon/#varepsilon_{0}" );
  relLightEff->Fit("expo","Q+");
  TF1 *ffunc=relLightEff->GetFunction("expo");
  float newLightCut=(TMath::Log(sflight)-ffunc->GetParameter(0))/ffunc->GetParameter(1);
  float newLightCutErrPlus=(TMath::Log(sflight+sflighterr)-ffunc->GetParameter(0))/ffunc->GetParameter(1)-newLightCut;
  float newLightCutErrMinus=(TMath::Log(sflight-sflighterr)-ffunc->GetParameter(0))/ffunc->GetParameter(1)-newLightCut;
  TArrow *lightArrow = new TArrow(newLightCut, sflight-3*sflighterr, newLightCut, sflight-3*sflighterr*0.8, 0.02, "<|");
  lightArrow->SetLineColor(kGray+2);
  lightArrow->SetFillColor(kGray+2);
  lightArrow->Draw("SAME <|");

  relBEff->Draw("p");
  relBEff->Fit("expo","Q+");
  ffunc=relBEff->GetFunction("expo");
  float newBCut=(TMath::Log(sfb)-ffunc->GetParameter(0))/ffunc->GetParameter(1);
  float newBCutErrPlus=(TMath::Log(sfb+sfberr)-ffunc->GetParameter(0))/ffunc->GetParameter(1)-newBCut;
  float newBCutErrMinus=(TMath::Log(sfb-sfberr)-ffunc->GetParameter(0))/ffunc->GetParameter(1)-newBCut;
  cout <<  sfb << " " << sfb+sfberr << " " << sfb-sfberr << endl;
  TArrow *bArrow    = new TArrow(newBCut, sflight-3*sflighterr, newBCut, sflight-3*sflighterr*0.8, 0.02, "<|");
  bArrow->Draw("SAME <|");

  //draw epsilon_b vs epsilon_q
  p=(TPad *)cnv->cd(4);
  p->SetLogy();

  TGraphAsymmErrors *perf=new TGraphAsymmErrors;
  perf->SetName("algoperformance");
  perf->SetMarkerStyle(20);
  perf->SetFillStyle(0);
  for(int ip=0; ip<bEff->GetN(); ip++)
    {
      Double_t cut;
      Double_t x,ex; bEff->GetPoint(ip,cut,x);     ex = bEff->GetErrorY(ip);
      Double_t y,ey; lightEff->GetPoint(ip,cut,y); ey = lightEff->GetErrorY(ip);
      perf->SetPoint(ip,x,y);
      perf->SetPointError(ip,ex,ex,ey,ey);
    }
  perf->Draw("ap");
  perf->GetXaxis()->SetTitle( bEff->GetTitle() );
  perf->GetYaxis()->SetTitle( lightEff->GetTitle() );

  //new performance expected after applying the new cuts
  TGraphAsymmErrors *newperf=new TGraphAsymmErrors;
  newperf->SetName("newalgoperformance");
  newperf->SetMarkerStyle(24);
  newperf->SetFillStyle(0);
  newperf->SetLineWidth(2);
  newperf->SetLineColor(kRed);
  newperf->SetLineColor(kRed);
  newperf->SetPoint(0,baseBEff*sfb,baseLightEff*sflight);
  newperf->SetPointError(0,baseBEff*sfberr,baseBEff*sfberr,baseLightEff*sflighterr,baseLightEff*sflighterr);
  newperf->Draw("p");

  cnv->Modified();
  cnv->Update();
  cnv->SaveAs("discFlavor.C");  
  cnv->SaveAs("discFlavor.png");  


  cout << "[determineWorkingPoint]" << endl
       << "To emulate the measured scale-factors you can use the following new cuts per jet flavor" << endl
       << "SF-b : "     << newBCut << " +" << newBCutErrPlus << " " << newBCutErrMinus << endl
       << "SF-light : " << newLightCut << " +" << newLightCutErrPlus << " " << newLightCutErrMinus << endl;
}
Beispiel #19
0
int
main (int argc, char *argv[])
{
  if (argc != 2)
    {
      cout << "Usage: " << argv[0] << " INPUT_FILE" << endl;
      cout << "  or:  " << argv[0] << " INPUT_LIST" << endl;
      cout << "" << endl;
      cout << endl;

      return 0;
    }
  string inputFile = argv[1], upperInputFile;
  upperInputFile.resize (inputFile.length ());
  transform (inputFile.begin (), inputFile.end (), upperInputFile.begin (), ::toupper);

  // so canvases don't appear on the screen when being created
  // very useful when running on the OSU T3 from CERN
  gROOT->SetBatch();
  gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadBottomMargin(0.1);
  gStyle->SetPadLeftMargin(0.03);
  gStyle->SetPadRightMargin(0.08);

  //Create chain of root trees
  TChain chain("Delphes");

  if (upperInputFile.length () < 5 || upperInputFile.substr (upperInputFile.length () - 5, 5) != ".ROOT")
  {
    ifstream fin (inputFile);
    string line;
    while(getline(fin, line))
      {
        chain.Add(line.c_str());
      }
    fin.close();
  }
  else
    chain.Add(inputFile.c_str());

  // Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);

  // Get pointers to branches used in this analysis
  TClonesArray *branchTrack = treeReader->UseBranch("Track");
  TClonesArray *branchCluster = treeReader->UseBranch("Cluster"); 
  TClonesArray *branchNPU = treeReader->UseBranch("NPU");

  //gStyle->SetOptStat(10011);
  //actually, let's turn this off for now
  gStyle->SetOptStat(0);


  TH2D *hist[LEN];
  signal (SIGINT, signalHandler);
  //Loop over a LEN Events
  for (int event = 0; event < LEN && !interrupted; event++) {

    //Load Branches
    treeReader->ReadEntry(event);

    // N.B. this is a hack put in by Andrew using the ScalarHT class                                                                                                                                    
    // it's the number of pileup interactions, it's not actually the HT                                                                                                                                 
    unsigned nInteractions = (unsigned) ((ScalarHT *) branchNPU->At(0))->HT + 1;
    int nClusters = branchCluster->GetEntries();


    // create and format the histogram for this event
    TString name = "TrackPtVsTrackZ_" + TString(Form("%d",event+1));
    TCanvas *can = new TCanvas(name,name,1600,500);

    TString title = "Event " + TString(Form("%d",event+1)) + ": ";
    title += TString(Form("%d",nInteractions)) + " Interactions, ";
    title += TString(Form("%d",nClusters)) + " Clusters";

    hist[event] = new TH2D(name, title, X_BIN, X_MIN, X_MAX, Y_BIN, Y_MIN, Y_MAX);
    hist[event]->GetXaxis()->SetTitle("track z [mm]");
    hist[event]->GetXaxis()->SetLabelOffset(0.02);
    hist[event]->GetXaxis()->SetTitleOffset(1.2);
    hist[event]->GetYaxis()->SetTitle("track p_{T} [GeV]");
    hist[event]->GetYaxis()->SetTitleOffset(0.35);


    
    TArrow *genPVArrow = new TArrow(0,0,0,0.01,0.01,"|>");
    genPVArrow->SetLineColor(3);
    genPVArrow->SetFillColor(3);
    genPVArrow->SetLineWidth(0.1);
    genPVArrow->SetAngle(40);

    vector<float> interactionPositions;
    vector<TLine *> clusterLineVector;
    Cluster *recoPV = (Cluster *) branchCluster->At(0);
    TLine *highELine = new TLine(recoPV->Z,0,recoPV->Z,Y_MAX);
    highELine->SetLineColor(1);
    highELine->SetLineWidth(0.8);
    highELine->SetLineStyle(3);

    // Draw cluster lines
    // Skip first cluster since we've already drawn it (start from 1)
    for(int iCluster = 1; iCluster < branchCluster->GetEntries(); iCluster++) {
	Cluster *cluster = (Cluster *) branchCluster->At(iCluster);
	TLine *clusterLine = new TLine(cluster->Z,0,cluster->Z,Y_MAX);
	clusterLine->SetLineWidth(0.5);
	clusterLineVector.push_back(clusterLine);
    }
   
    for(int iTrack = 0; iTrack < branchTrack->GetEntries(); iTrack++) {
        Track *track = (Track *) branchTrack->At(iTrack);
	if (track->PT < Y_MAX) hist[event]->Fill(track->Z, track->PT);
	else hist[event]->Fill(track->Z, Y_MAX-0.01); // if entry would be off the y-scale, draw it in the last bin

        if(track->IsPU==0) { // track comes from primary interaction
//           genPVArrow->SetX1(track->TrueZ);  FIXME
//           genPVArrow->SetX2(track->TrueZ); FIXME
	}
//	else if (find(interactionPositions.begin(), interactionPositions.end(), track->TrueZ) == interactionPositions.end()){ FIXME
//	  interactionPositions.push_back(track->TrueZ); FIXME
//	} FIXME
    }

    //create arrows for all the generated pileup interactions
    vector<TArrow *> interactionArrowVector;
    for(uint iInteraction = 0; iInteraction < interactionPositions.size() ; iInteraction++) {
      TArrow *interactionArrow = new TArrow(interactionPositions.at(iInteraction),0,interactionPositions.at(iInteraction),0.01,0.01,"|>");
      interactionArrow->SetLineWidth(0.1);
      interactionArrow->SetAngle(20);
      interactionArrow->SetLineColor(2);
      interactionArrow->SetFillColor(2);
      interactionArrowVector.push_back(interactionArrow);
    }
  
    //Draw and save images
    hist[event]->Draw("contz");
    for(uint iCluster = 0; iCluster < clusterLineVector.size(); iCluster++) {
      clusterLineVector.at(iCluster)->Draw();
    } 
    for(uint iInteraction = 0; iInteraction < interactionArrowVector.size(); iInteraction++) {
      interactionArrowVector.at(iInteraction)->Draw();
    } 
    highELine->Draw();
    genPVArrow->Draw();

    TLegend *leg = new TLegend(0.07,0.6,0.25,0.89);
    leg->SetBorderSize(0);
    leg->SetFillColor(0);
    leg->SetFillStyle(0);
    leg->AddEntry(genPVArrow, "Primary Gen. Interaction", "");
    if (interactionArrowVector.size() > 0) leg->AddEntry(interactionArrowVector.at(0), "Pileup Interactions", "");
    leg->AddEntry(highELine, "Highest #Sigmap_{T}^{2} Cluster", "l");
    if (clusterLineVector.size() > 0) leg->AddEntry(clusterLineVector.at(0), "Other Clusters", "l");
    leg->Draw();


    //hack to get the triangles to draw in the legend
    double x_left = X_MIN + (X_MAX-X_MIN)/13;
    double x_right = X_MIN + (X_MAX-X_MIN)/13;

    if (interactionArrowVector.size() > 0){
      TArrow *interactionArrowLabel = new TArrow(x_left,Y_MAX*0.86,x_right,Y_MAX*0.86,0.02,"|>");
      interactionArrowLabel->SetLineWidth(1);
      interactionArrowLabel->SetAngle(20);
      interactionArrowLabel->SetLineColor(2);
      interactionArrowLabel->SetFillColor(2);
      interactionArrowLabel->Draw();
    }
    TArrow *genPVArrowLabel = new TArrow(x_left,Y_MAX*0.94,x_right,Y_MAX*0.94,0.02,"|>");
    genPVArrowLabel->SetLineWidth(1);
    genPVArrowLabel->SetAngle(40);
    genPVArrowLabel->SetLineColor(3);
    genPVArrowLabel->SetFillColor(3);
    genPVArrowLabel->Draw();
    
    can->SaveAs("output/" + name + ".pdf");
    //can->Write();

  }
}
Beispiel #20
0
Datei: event.C Projekt: Y--/root
void event(){
   TCanvas *c1 = new TCanvas("c1","ROOT Event description",700,500);
   c1->Range(0,0,14,15.5);
   TPaveText *event = new TPaveText(1,13,3,15);
   event->SetFillColor(11);
   event->Draw();
   event->AddText("Event");
   TLine *line = new TLine(1.1,13,1.1,1.5);
   line->SetLineWidth(2);
   line->Draw();
   line->DrawLine(1.3,13,1.3,3.5);
   line->DrawLine(1.5,13,1.5,5.5);
   line->DrawLine(1.7,13,1.7,7.5);
   line->DrawLine(1.9,13,1.9,9.5);
   line->DrawLine(2.1,13,2.1,11.5);
   TArrow *arrow = new TArrow(1.1,1.5,3.9,1.5,0.02,"|>");
   arrow->SetFillStyle(1001);
   arrow->SetFillColor(1);
   arrow->Draw();
   arrow->DrawArrow(1.3,3.5,3.9,3.5,0.02,"|>");
   arrow->DrawArrow(1.5,5.5,3.9,5.5,0.02,"|>");
   arrow->DrawArrow(1.7,7.5,3.9,7.5,0.02,"|>");
   arrow->DrawArrow(1.9,9.5,3.9,9.5,0.02,"|>");
   arrow->DrawArrow(2.1,11.5,3.9,11.5,0.02,"|>");
   TPaveText *p1 = new TPaveText(4,1,11,2);
   p1->SetTextAlign(12);
   p1->SetFillColor(42);
   p1->AddText("1 Mbyte");
   p1->Draw();
   TPaveText *p2 = new TPaveText(4,3,10,4);
   p2->SetTextAlign(12);
   p2->SetFillColor(42);
   p2->AddText("100 Kbytes");
   p2->Draw();
   TPaveText *p3 = new TPaveText(4,5,9,6);
   p3->SetTextAlign(12);
   p3->SetFillColor(42);
   p3->AddText("10 Kbytes");
   p3->Draw();
   TPaveText *p4 = new TPaveText(4,7,8,8);
   p4->SetTextAlign(12);
   p4->SetFillColor(42);
   p4->AddText("1 Kbytes");
   p4->Draw();
   TPaveText *p5 = new TPaveText(4,9,7,10);
   p5->SetTextAlign(12);
   p5->SetFillColor(42);
   p5->AddText("100 bytes");
   p5->Draw();
   TPaveText *p6 = new TPaveText(4,11,6,12);
   p6->SetTextAlign(12);
   p6->SetFillColor(42);
   p6->AddText("10 bytes");
   p6->Draw();
   TText *text = new TText();
   text->SetTextAlign(12);
   text->SetTextSize(0.04);
   text->SetTextFont(72);
   text->DrawText(6.2,11.5,"Header:Event_flag");
   text->DrawText(7.2,9.5,"Trigger_Info");
   text->DrawText(8.2,7.5,"Muon_Detector: TOF");
   text->DrawText(9.2,5.5,"Calorimeters");
   text->DrawText(10.2,3.5,"Forward_Detectors");
   text->DrawText(11.2,1.5,"TPCs");
}
//void gluinostopMassLifetime(double lumi=4560., double maxInstLumi=5000.) {
void gluinostopMassLifetime(double lumi=4560.) {

  ExtraLimitPlots plots(lumi);
  //mchamp index 0 is used, corresponds to 0th mass point = 100 GeV
  plots.calculateCrossSections(7,4,3,0,39,9);

  // xsecs as extracted from nllfast http://web.physik.rwth-aachen.de/service/wiki/bin/view/Main/SquarksandGluinos
  // gluino (m_squark=m_gluino):  "nllfast gg mstw <mass> <mass>"
  // gluino (m_squark>>m_gluino): "nllfast gdcpl mstw <mass>"
  // stop: "nllfast st mstw <mass>"
  double g_mass [21] = {  
    200 ,     250 ,     300 ,     350 ,     400 ,   
    450 ,     500 ,     550 ,     600 ,     650 ,   
    700 ,     750 ,     800 ,     850 ,     900 ,   
    950 ,    1000 ,    1050 ,    1100 ,    1150 ,   
    1200 };
  double g_xsec [21] = {  
    1010,      302,     106,     42.6,     18.9,
    8.93,     4.52,    2.39,     1.31,    0.744,
    0.434,   0.259,   0.157,   0.0967,   0.0603,
    0.0381, 0.0244,  0.0157,   0.0102,  0.00667,
    0.00440
  };
  double g_xsecdcpl [21] = {  
    1010,      302,     106,     42.6,     18.9,
    8.93,     4.52,    2.39,     1.31,    0.744,
    0.434,   0.259,   0.157,   0.0967,   0.0603,
    0.0381, 0.0244,  0.0157,   0.0102,  0.00667,
    0.00440
  };
  double s_mass [21] = {  
    100 ,     150 ,     200 ,     250 ,     300 ,   
    350 ,     400 ,     450 ,     500 ,     550 ,   
    600 ,     650 ,     700 ,     750 ,     800 ,   
    850 ,     900 ,     950 ,    1000 ,    1050 ,   
    1100 
  };
  double s_xsec [21] = {  
    560,       80.3,     18.5,     5.58,     2.00,
    0.807,    0.357,    0.170,   0.0856,   0.0452,
    0.0248,  0.0140,  0.00811,  0.00480,  0.00290,
    0.00177,0.00110, 0.000687, 0.000435, 0.000278,
    0.000180 
  };
  double m_mass [10] = {  
    100 ,        200 ,     300 ,     400 ,     500 ,   
    600 ,        700 ,     800 ,     900 ,    1000 
  };
  double m_xsec [10] = {  
    1.88,      0.1402,      0.02622,   0.006968, 0.002257,
    0.0008183, 0.0003228, 0.0001333, 0.00005764, 0.0000254
  };

  //gluino xsec
  vector<double> masses;
  for (int i = 0; i < 21; ++i)  {
    masses.push_back(g_mass[i]);
    g_xsec [i] = log10 (g_xsec [i]*1e3) * 20.;
    g_xsecdcpl [i] = log10 (g_xsecdcpl [i]*1e3) * 20.;
  }
  //  Xsection gluino_xs (masses, g_xsec);
  Xsection gluino_xs (masses, g_xsecdcpl);
  
  //stop xsec
  masses.clear();
  for (int i = 0; i < 19; ++i)  {
    masses.push_back(s_mass[i]);
    s_xsec [i] = log10 (s_xsec [i]*1e3) * 20.;
  }
  Xsection stop_xs (masses, s_xsec);

  //mchamp xsec
  masses.clear();
  for (int i = 0; i < 10; ++i)  {
    masses.push_back(m_mass[i]);
    m_xsec [i] = log10 (m_xsec [i]*1e3) * 20.;
  }
  Xsection mchamp_xs (masses, m_xsec);
  
  // graphs
  TGraph* g_obs     = new TGraph (*plots.getLimitGluino());
  gluino_xs.xsec2mass (g_obs);

  TGraph* g_exp      = new TGraph (*plots.getExpLimitGluino());
  gluino_xs.xsec2mass (g_exp);
  TGraphAsymmErrors* g_exp_1sig = new TGraphAsymmErrors (*plots.getExpLimitGluino1Sig());
  gluino_xs.xsec2mass (g_exp_1sig);
  TGraphAsymmErrors* g_exp_2sig = new TGraphAsymmErrors (*plots.getExpLimitGluino2Sig());
  gluino_xs.xsec2mass (g_exp_2sig);

  TGraph* stop_obs     = new TGraph (*plots.getLimitStop());
  stop_xs.xsec2mass (stop_obs);

  TGraph* stop_exp      = new TGraph (*plots.getExpLimitStop());
  stop_xs.xsec2mass (stop_exp);
  TGraphAsymmErrors* stop_exp_1sig = new TGraphAsymmErrors (*plots.getExpLimitStop1Sig());
  stop_xs.xsec2mass (stop_exp_1sig);
  TGraphAsymmErrors* stop_exp_2sig = new TGraphAsymmErrors (*plots.getExpLimitStop2Sig());
  stop_xs.xsec2mass (stop_exp_2sig);


  TGraph* mchamp_obs     = new TGraph (*plots.getLimitMchamp());
  mchamp_xs.xsec2mass (mchamp_obs);

  TGraph* mchamp_exp      = new TGraph (*plots.getExpLimitMchamp());
  mchamp_xs.xsec2mass (mchamp_exp);
  TGraphAsymmErrors* mchamp_exp_1sig = new TGraphAsymmErrors (*plots.getExpLimitMchamp1Sig());
  mchamp_xs.xsec2mass (mchamp_exp_1sig);
  TGraphAsymmErrors* mchamp_exp_2sig = new TGraphAsymmErrors (*plots.getExpLimitMchamp2Sig());
  mchamp_xs.xsec2mass (mchamp_exp_2sig);

  
  TCanvas *canvas = new TCanvas("allMassLifetime", "allMassLifetime", 800, 600);
  
  canvas->SetLogx();
  canvas->SetGridy();

  
  TH1F* h = new TH1F ("h", "", 1,  7.5e-8, 1e6);
  h->SetStats (0);
  //h->SetMinimum (300);
  h->SetMinimum (0);
  //h->SetMaximum (1500);
  h->SetMaximum (600);
  h->SetTitle("Beamgap Expt");
  //  h->GetXaxis()->SetTitle("#tau_{#tilde{g},#tilde{t},#tilde{#tau}} [s]");
  h->GetXaxis()->SetTitle("#tau [s]");
  h->GetYaxis()->SetTitle("m [GeV]  ");
  h->Draw ("");

  
  
  // limit arrows
  double* x = g_obs->GetX();
  for (int i = 0; i < g_obs->GetN(); ++i) {
    if (x[i] > 0.5) {
      double y =  g_obs->GetY()[i];
      TArrow* arrow = new TArrow (x[i], y, h->GetXaxis()->GetXmin(), y, 0.02);
      arrow->SetLineColor (kRed);
      arrow->SetLineWidth (2);
      //arrow->Draw();
      cout << "GLUINO mass limit @ " << x[i] << "sec is found: " << y << endl;
      break;
    }
  }
  x = g_obs->GetX();
  for (int i = 0; i < stop_obs->GetN(); ++i) {
    if (x[i] > 0.5) {
      double y =  stop_obs->GetY()[i];
      TArrow* arrow = new TArrow (x[i], y, h->GetXaxis()->GetXmin(), y, 0.02);
      arrow->SetLineColor (kBlue);
      arrow->SetLineWidth (2);
      //arrow->Draw();
      cout << "STOP mass limit @ " << x[i] << "sec is found: " << y << endl;
      break;
    }
  }
  x = mchamp_obs->GetX();
  for (int i = 0; i < mchamp_obs->GetN(); ++i) {
    if (x[i] > 0.5) {
      double y =  mchamp_obs->GetY()[i];
      TArrow* arrow = new TArrow (x[i], y, h->GetXaxis()->GetXmin(), y, 0.02);
      arrow->SetLineColor (kBlack);
      arrow->SetLineWidth (2);
      arrow->Draw();
      cout << "MCHAMP mass limit @ " << x[i] << "sec is found: " << y << endl;
      break;
    }
  }
 
  // gluino  
  // 2 sigma band
  if (g_exp_2sig) {
    g_exp_2sig->SetLineColor(0);
    g_exp_2sig->SetLineStyle(0);
    g_exp_2sig->SetLineWidth(0);
    g_exp_2sig->SetFillColor(kYellow);
    g_exp_2sig->SetFillStyle(1001);
    //g_exp_2sig->Draw("3");
  }
  
  // 1 sigma band
  if (g_exp_1sig) {
    // g_exp_1sig->SetLineColor(8);
    g_exp_1sig->SetLineColor(0);
    g_exp_1sig->SetLineStyle(0);
    g_exp_1sig->SetLineWidth(0);
    // g_exp_1sig->SetFillColor(8);
    g_exp_1sig->SetFillColor(kGreen);
    g_exp_1sig->SetFillStyle(1001);
    // g_exp_1sig->SetFillStyle(3005);
    //g_exp_1sig->Draw("3");
    // g_exp_1sig->Draw("lX");
  }
  
  
  // epxected limit
  if (g_exp) {
    g_exp->SetLineColor(kRed);
    g_exp->SetLineStyle(4);
    g_exp->SetLineWidth(2);
    //g_exp->Draw("l3");
  }
  

  // observed limit
  if (g_obs) {
    g_obs->SetLineColor(kRed);
    g_obs->SetLineStyle(1);
    g_obs->SetLineWidth(2);
    //g_obs->Draw("l");
  }
  
  // stop  
  // 2 sigma band
  if (stop_exp_2sig) {
    stop_exp_2sig->SetLineColor(0);
    stop_exp_2sig->SetLineStyle(0);
    stop_exp_2sig->SetLineWidth(0);
    stop_exp_2sig->SetFillColor(kYellow);
    stop_exp_2sig->SetFillStyle(1001);
    //stop_exp_2sig->Draw("3");
  }
  
  // 1 sigma band
  if (stop_exp_1sig) {
    // stop_exp_1sig->SetLineColor(8);
    stop_exp_1sig->SetLineColor(0);
    stop_exp_1sig->SetLineStyle(0);
    stop_exp_1sig->SetLineWidth(0);
    // stop_exp_1sig->SetFillColor(8);
    stop_exp_1sig->SetFillColor(kGreen);
    stop_exp_1sig->SetFillStyle(1001);
    // stop_exp_1sig->SetFillStyle(3005);
    //stop_exp_1sig->Draw("3");
    // stop_exp_1sig->Draw("lX");
  }
  
  
  // epxected limit
  if (stop_exp) {
    stop_exp->SetLineColor(kBlue);
    stop_exp->SetLineStyle(3);
    stop_exp->SetLineWidth(2);
    //stop_exp->Draw("l3");
  }
  

  // observed limit
  if (stop_obs) {
    stop_obs->SetLineColor(kBlue);
    stop_obs->SetLineStyle(2);
    stop_obs->SetLineWidth(2);
    //stop_obs->Draw("l");
  }


  //mchamp
  // 2 sigma band
  if (mchamp_exp_2sig) {
    mchamp_exp_2sig->SetLineColor(0);
    mchamp_exp_2sig->SetLineStyle(0);
    mchamp_exp_2sig->SetLineWidth(0);
    mchamp_exp_2sig->SetFillColor(kYellow);
    mchamp_exp_2sig->SetFillStyle(1001);
    mchamp_exp_2sig->Draw("3");
  }
  
  // 1 sigma band
  if (mchamp_exp_1sig) {
    // mchamp_exp_1sig->SetLineColor(8);
    mchamp_exp_1sig->SetLineColor(0);
    mchamp_exp_1sig->SetLineStyle(0);
    mchamp_exp_1sig->SetLineWidth(0);
    // mchamp_exp_1sig->SetFillColor(8);
    mchamp_exp_1sig->SetFillColor(kGreen);
    mchamp_exp_1sig->SetFillStyle(1001);
    // mchamp_exp_1sig->SetFillStyle(3005);
    mchamp_exp_1sig->Draw("3");
    // mchamp_exp_1sig->Draw("lX");
  }
  
  
  // epxected limit
  if (mchamp_exp) {
    mchamp_exp->SetLineColor(kBlack);
    mchamp_exp->SetLineStyle(3);
    mchamp_exp->SetLineWidth(2);
    mchamp_exp->Draw("l3");
  }
  

  // observed limit
  if (mchamp_obs) {
    mchamp_obs->SetLineColor(kBlack);
    mchamp_obs->SetLineStyle(2);
    mchamp_obs->SetLineWidth(2);
    mchamp_obs->Draw("l");
  }

  
  

  TPaveText* blurb = new TPaveText(0.20, 0.63, 0.60, 0.90, "NDC");
  blurb->AddText("CMS Preliminary 2012");
  //blurb->AddText("CMS 2012");
  blurb->AddText("#int L dt = 19.7 fb^{-1}"); //,  #int L_{eff} dt = 935 pb^{-1}");
  //blurb->AddText("L^{max}_{inst} = 3.5 #times 10^{33} cm^{-2}s^{-1}");

  // std::stringstream label;
  // label<<"#int L dt = "<<lumi<<" pb^{-1}";
  // blurb->AddText(label.str().c_str());
  // double peakInstLumi=maxInstLumi;
  // int exponent=30;
  // while (peakInstLumi>10) {
  //   peakInstLumi/=10;
  //   ++exponent;
  // }
  // std::stringstream label2;
  // label2<<"L^{max}_{inst} = "<<peakInstLumi<<" x 10^{"<<exponent<<"} cm^{-2}s^{-1}";
//  blurb->AddText(label2.str().c_str());
  blurb->AddText("#sqrt{s} = 8 TeV");
  //blurb->AddText("E_{gluon} > 120 GeV, E_{top} > 150 GeV");
  blurb->SetTextFont(42);
  blurb->SetBorderSize(0);
  blurb->SetFillColor(0);
  blurb->SetShadowColor(0);
  blurb->SetTextAlign(12);
  blurb->SetTextSize(0.033);
  blurb->Draw();

  TLegend* leg = new TLegend(0.6, 0.62, 0.87, 0.90,"95% CL Limits:","NDC");
  leg->SetTextSize(0.033);
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetFillColor(0);

  //leg->AddEntry(g_obs, " #tilde{g} observed", "l");
  //leg->AddEntry(stop_obs, " #tilde{t} observed", "l");
  leg->AddEntry(mchamp_obs, "mchamp observed", "l");

  TGraph* expectedStyle1 = new TGraph (*g_exp);
  expectedStyle1->SetFillColor (g_exp_1sig->GetFillColor());
  TGraph* expectedStyle2 = new TGraph (*g_exp);
  expectedStyle2->SetFillColor (g_exp_2sig->GetFillColor());
  //leg->AddEntry(expectedStyle1, " #tilde{g} expected #pm1#sigma", "lf");
  //leg->AddEntry(expectedStyle2, " #tilde{g} expected #pm2#sigma", "lf");

  expectedStyle1 = new TGraph (*stop_exp);
  expectedStyle1->SetFillColor (stop_exp_1sig->GetFillColor());
  expectedStyle2 = new TGraph (*stop_exp);
  expectedStyle2->SetFillColor (stop_exp_2sig->GetFillColor());
  //leg->AddEntry(expectedStyle1, " #tilde{t} expected #pm1#sigma", "lf");
  //leg->AddEntry(expectedStyle2, " #tilde{t} expected #pm2#sigma", "lf");

  expectedStyle1 = new TGraph (*mchamp_exp);
  expectedStyle1->SetFillColor (mchamp_exp_1sig->GetFillColor());
  expectedStyle2 = new TGraph (*mchamp_exp);
  expectedStyle2->SetFillColor (mchamp_exp_2sig->GetFillColor());
  leg->AddEntry(expectedStyle1, "mchamp expected #pm1#sigma", "lf");
  leg->AddEntry(expectedStyle2, "mchamp expected #pm2#sigma", "lf");

  leg->Draw();

  h->Draw("sameaxis");

  canvas->Print("gluinostopmchampMassLifetime.png");
  canvas->Print("gluinostopmchampMassLifetime.pdf");
}
void CCProtonPi0_SideBandTool::Plot_NoRatio(int ind, std::string sb_name, std::string var_name, MnvH1D* data, MnvH1D* mc_total, MnvH1D* signal, MnvH1D* WithPi0, MnvH1D* QELike, MnvH1D* SinglePiPlus, MnvH1D* Other)
{
    (void) mc_total;
    std::string type;
    if (ind == 0) type = "Nominal";
    else type = "Fitted";

    std::string norm = "POT";
    std::string plot_title = "Side Band: " + sb_name + " " + type + " " + norm + " Normalized";

    // Get Histograms -- Use new Histograms not to change originals
    MnvH1D* h_data = new MnvH1D(*data);
    h_data->GetYaxis()->CenterTitle();
    h_data->GetXaxis()->SetNdivisions(5,5,0);
    h_data->GetYaxis()->SetNdivisions(5,5,0);

    MnvH1D* h_signal = new MnvH1D(*signal);
    h_signal->GetYaxis()->CenterTitle();
    h_signal->SetFillColor(kGreen+1);
    h_signal->SetLineColor(kGreen+1);
    h_signal->SetFillStyle(3002);
    h_signal->SetLineWidth(2);
    h_signal->GetXaxis()->SetNdivisions(5,5,0);
    h_signal->GetYaxis()->SetNdivisions(5,5,0);

    MnvH1D* h_WithPi0 = new MnvH1D(*WithPi0);
    h_WithPi0->GetYaxis()->CenterTitle();
    h_WithPi0->SetFillColor(kRed);
    h_WithPi0->SetLineColor(kRed);
    h_WithPi0->SetFillStyle(3002);
    h_WithPi0->SetLineWidth(2);
    h_WithPi0->GetXaxis()->SetNdivisions(5,5,0);
    h_WithPi0->GetYaxis()->SetNdivisions(5,5,0);
  
    MnvH1D* h_QELike = new MnvH1D(*QELike);
    h_QELike->GetYaxis()->CenterTitle();
    h_QELike->SetFillColor(kOrange-1);
    h_QELike->SetLineColor(kOrange-1);
    h_QELike->SetFillStyle(3002);
    h_QELike->SetLineWidth(2);
    h_QELike->GetXaxis()->SetNdivisions(5,5,0);
    h_QELike->GetYaxis()->SetNdivisions(5,5,0);
 
    MnvH1D* h_SinglePiPlus = new MnvH1D(*SinglePiPlus);
    h_SinglePiPlus->GetYaxis()->CenterTitle();
    h_SinglePiPlus->SetFillColor(kBlue);
    h_SinglePiPlus->SetLineColor(kBlue);
    h_SinglePiPlus->SetFillStyle(3002);
    h_SinglePiPlus->SetLineWidth(2);
    h_SinglePiPlus->GetXaxis()->SetNdivisions(5,5,0);
    h_SinglePiPlus->GetYaxis()->SetNdivisions(5,5,0);

    MnvH1D* h_Other = new MnvH1D(*Other);
    h_Other->GetYaxis()->CenterTitle();
    h_Other->SetFillColor(kGray+2);
    h_Other->SetLineColor(kGray+2);
    h_Other->SetFillStyle(3002);
    h_Other->SetLineWidth(2);
    h_Other->GetXaxis()->SetNdivisions(5,5,0);
    h_Other->GetYaxis()->SetNdivisions(5,5,0);
  
    // Clear Error Bars
    h_signal->ClearAllErrorBands();
    h_WithPi0->ClearAllErrorBands();
    h_QELike->ClearAllErrorBands();
    h_SinglePiPlus->ClearAllErrorBands();
    h_Other->ClearAllErrorBands();

    TObjArray* mc_hists = new TObjArray;
    mc_hists->Add(h_Other);
    mc_hists->Add(h_SinglePiPlus);
    mc_hists->Add(h_QELike);
    mc_hists->Add(h_WithPi0);
    mc_hists->Add(h_signal);
 
    // ------------------------------------------------------------------------
    // Plot 
    // ------------------------------------------------------------------------
    MnvPlotter* plotter = new MnvPlotter();
    plotter->SetRootEnv();
 
    gStyle->SetCanvasDefW(640);
    gStyle->SetCanvasDefH(480); // 4x3 aspect ratio
    gStyle->SetPadRightMargin(0.05);
    gStyle->SetEndErrorSize(2);
    gStyle->SetStripDecimals(false);

    plotter->axis_minimum = 0.01;
    plotter->legend_text_size  = 0.04;
    plotter->legend_text_font = 42; // default 62 (bold)
    plotter->data_marker_size = 0.8;
    plotter->axis_title_font_x   = 42;
    plotter->axis_title_size_x   = 0.06;
    plotter->axis_title_offset_x = 1.1;
    plotter->axis_title_font_y   = 42;
    plotter->axis_title_size_y   = 0.06;
    plotter->axis_title_offset_y = 1.0;
    plotter->axis_label_size = 0.05;
    plotter->axis_label_font = 42;
    plotter->headroom = 1.75;

    plotter->mc_line_width = 2;
    
    TCanvas* c = new TCanvas("c");

    /*
       void MnvPlotter::DrawDataStackedMC(
            const MnvH1D *  dataHist,
            const TObjArray *    mcHists,
            const Double_t   mcScale = 1.0,
            const std::string &  legPos = "L",
            const std::string &  dataName = "Data",
            const Int_t  mcBaseColor = 2,
            const Int_t  mcColorOffset = 1,
            const Int_t  mcFillStyle = 3001,
            const char *     xaxislabel = "",
            const char *     yaxislabel = "",
            bool     cov_area_normalize = false   
       )    
    */
    plotter->DrawDataStackedMC(h_data, mc_hists, POT_ratio, "N", "Data (3.33e20 POT)", 0, 0, 3002);

    // Add Legend
    double leg_x_min = 0.55;
    double leg_x_max = 0.90;
    double leg_y_min = 0.55;
    double leg_y_max = 0.85;

    h_data->SetMarkerStyle(plotter->data_marker);
    h_data->SetMarkerSize(plotter->data_marker_size);
    h_data->SetMarkerColor(plotter->data_color);
    h_data->SetLineColor(plotter->data_color);
    h_data->SetLineWidth(plotter->data_line_width);

    TLegend *legend = new TLegend(leg_x_min, leg_y_min, leg_x_max, leg_y_max);
    legend->SetBorderSize(0);
    legend->SetFillColor(-1);
    legend->SetFillStyle(0);
    legend->SetTextFont(42);
    legend->SetTextSize(0.04);
    legend->AddEntry(h_data, "Data", "lep");
    legend->AddEntry(h_signal, "Signal", "f");
    legend->AddEntry(h_WithPi0, "Bkgrd: #pi^{0} + meson(s)", "f");
    legend->AddEntry(h_QELike, "Bkgrd: zero meson", "f");
    legend->AddEntry(h_SinglePiPlus, "Bkgrd: charged meson(s)", "f");
    legend->AddEntry(h_Other, "Bkgrd: other", "f");
    legend->SetTextSize(0.04);
    legend->SetTextFont(42);
    legend->Draw();

    // Add Alines if Original Side Band
    //if (false) {
    if (sb_name.compare("Original") == 0) {
        double max_bin = h_data->GetMaximumBin();
        double hist_max = h_data->GetBinContent(max_bin)*1.2;

        TLine line;
        TArrow arrow;
        // Cut Line at 60 MeV
        line.SetLineWidth(2);
        line.SetLineStyle(2);
        line.SetLineColor(kBlack);
        arrow.SetLineWidth(2);
        arrow.SetLineColor(kBlack);
        line.DrawLine(60.0, 0.0, 60.0, hist_max);
        arrow.DrawArrow(60.0, hist_max, 50.0, hist_max, 0.01);

        line.DrawLine(200.0, 0.0, 200.0, hist_max);
        arrow.DrawArrow(200.0, hist_max, 210.0, hist_max, 0.01);

        arrow.SetLineColor(kBlue);
        arrow.DrawArrow(134.98,hist_max/8,134.98,0, 0.01); 
    } 

    // Add Normalization Label
    TLatex norm_text;
    norm_text.SetNDC();
    norm_text.SetTextColor(kBlue);
    norm_text.SetTextSize(0.03);
    norm_text.SetTextAlign(22);
    norm_text.DrawLatex(0.35,0.85,"POT Normalized");

    double info_text_x = 0.85;
    double info_text_y = 0.85;
    TLatex info_text;
    info_text.SetNDC();
    info_text.SetTextColor(kBlack);
    info_text.SetTextFont(62);
    info_text.SetTextAlign(12);
    info_text.SetTextSize(0.04);
    if ( ind == 0) info_text.DrawLatex(info_text_x, info_text_y, "(a)");
    else info_text.DrawLatex(info_text_x, info_text_y, "(b)");

    // Plot Output
    c->Update();
    std::string plotDir = Folder_List::plotDir_Paper;
    std::string out_name;
    out_name = plotDir + var_name + "_" + sb_name + "_" + type + "_" + norm + ".pdf"; 

    c->Print(out_name.c_str(),"pdf");

    delete h_data;
    delete h_signal;
    delete h_WithPi0;
    delete h_QELike;
    delete h_SinglePiPlus;
    delete h_Other;
    delete legend;
    delete c;
    delete plotter;
}
int extractSignificanceStats(){

  const float lumi7TeV=5.051;
  const float lumi8TeV=5.261;

  char fileName[128];
  sprintf(fileName,"qmu.root");
  TFile *fq=new TFile(fileName,"READ");
  TTree *t=(TTree*)fq->Get("q");

  float q,m,w;
  int type;
  t->SetBranchAddress("q",&q);
  t->SetBranchAddress("mh",&m);
  t->SetBranchAddress("weight",&w);
  t->SetBranchAddress("type",&type);

  TH1F *hSM=new TH1F("hSM;S = -2 #times ln(L_{1}/L_{2});Number of Toys","",8000,-15,15);
  TH1F *hPS=new TH1F("hPS;S = -2 #times ln(L_{1}/L_{2});Number of Toys","",8000,-15,15);
  TH1F *hObs=new TH1F("hObserved","",8000,-15,15);
  cout<<"Start to lopp on tree in file "<<fileName<<endl;

  std::vector<float> v_SM, v_PS,v_Obs;

  for(int i=0;i<t->GetEntries();i++){
    t->GetEntry(i);
    if(i==0)cout<<"MASS in the TREE = "<<m<<endl<<endl;

    if(type<0){ //SM hypothesis 
      hSM->Fill(-q);
      v_SM.push_back(-q);
    }
    else if(type>0){//ALT hypothesis
      hPS->Fill(-q);
      v_PS.push_back(-q);
    }
    else{
      hObs->Fill(q);
      v_Obs.push_back(q);
    }
  }//end loop on tree entries
  cout<<"Finished to loop, sorting vectors "<<v_SM.size()<<" "<<v_PS.size()<<" "<<v_Obs.size()<<endl;
  sort(v_SM.begin(),v_SM.end());//sort in ascending order
  sort(v_PS.begin(),v_PS.end()); 
  sort(v_Obs.begin(),v_Obs.end());
  int ntoysSM= hSM->GetEntries();
  int ntoysPS= hPS->GetEntries();

  //we assume that SM is on the right and PS on the left of zero
  if(v_PS.at(0)>v_SM.at(ntoysSM-1)){
    cout<<"Swapped distributions !!! The alternative model shouldstay on the negative side of the significance."<<endl;
    cout<<"Please edit the code and change the sign of q when filling histos and vectors in the loop on tree entries"<<endl;
    return 1;
  }
  float medianSM=v_SM.at(int(ntoysSM/2));
  float medianPS=v_PS.at(int(ntoysPS/2));
  cout<<"Toys generated "<<ntoysSM<<"\t"<<ntoysPS<<endl;
  cout<<"Mean of SM/PS hypothesis: "<<hSM->GetMean()<<"\t"<<hPS->GetMean()<<endl;
  cout<<"RMS  of SM/PS hypothesis: "<<hSM->GetRMS()<<"\t"<<hPS->GetRMS()<<endl;
  cout<<"Median of SM/PS hypothesis: "<<medianSM<<"\t"<<medianPS<<endl;

  const float step=0.05;
  float coverage=0.0;
  float diff=10.0;
  float cut=v_PS.at(0)-step;
  float crosspoint=-99.0;
  int startSM=ntoysSM-1, startPS=0;
  cout<<"Starting to loop with cut at "<<cut<<endl;

  /*
  while(cut<=v_SM.at(ntoysSM-1)+step){
    //    if(int(cut*100)%100==0)
cout<<"Cutting at "<<cut<<endl;
    for(int iSM=startSM;iSM>=0;iSM--){
      
      if(v_SM.at(iSM)<cut){
	startSM=ntoysSM-iSM;
	//break;
      }
      else cout<<"SM "<<v_SM.at(iSM)<<" > "<<cut<<endl;
    }

    for(int iPS=startPS;iPS<ntoysPS;iPS++){
      if(v_PS.at(iPS)>cut){
	startPS=iPS;
	//break;
      }
      else cout<<v_PS.at(iPS)<<" < "<<cut<<endl;
  
    }
    float fracSM=(ntoysSM-startSM)/ntoysSM;
    float fracPS=startPS/ntoysPS;
    cout<<"Frac "<<fracSM<<" "<<fracPS<<endl;
    if(fabs(fracSM-fracPS)<diff){
      diff=fabs(fracSM-fracPS);
      coverage=fabs(fracSM-fracPS)/2.0;
      crosspoint=cut;
      cout<<"New coverage="<<coverage<<" at xpoint="<<crosspoint<<"  "<<startSM<<endl;
    }
    cut+=step;
  }//end while loop
  */
  cout<<"Finished loop on vector elements, min is "<<diff<<" cut is at "<<cut<<endl;
  cout<<"q value where SM and ALT distributions have same area on opposite sides: "<<crosspoint<<endl;
  cout<<"Coverage "<<coverage<<endl;
  float separation=2*ROOT::Math::normal_quantile_c(1.0 - coverage, 1.0);
  cout<<"Separation: "<<separation<<endl<<endl<<endl;

  float integralSM=hSM->Integral();
  float integralPS=hPS->Integral();
 
  float tailSM=hSM->Integral(1,hSM->FindBin(medianPS))/integralSM;
  float tailPS=hPS->Integral(hPS->FindBin(medianSM),hPS->GetNbinsX())/integralPS;
  cout<<"Tail prob SM: "<<tailSM<<"  ("<<ROOT::Math::normal_quantile_c(tailSM,1.0) <<" sigma)"<<endl;
  cout<<"Tail prob PS: "<<tailPS<<"  ("<<ROOT::Math::normal_quantile_c(tailPS,1.0) <<" sigma)"<<endl;

  diff=10.0;
  coverage=0.0;
  for(int i=1;i<hSM->GetNbinsX();i++){
    
    float fracSM=hSM->Integral(1,i) / integralSM;
    float fracPS=hPS->Integral(i,hPS->GetNbinsX()) / integralPS;
    if(fabs(fracSM-fracPS)<diff){
      diff=fabs(fracSM-fracPS);
      coverage=(fracSM+fracPS)/2.0;
    }

  }

  float sepH= 2*ROOT::Math::normal_quantile_c(1.0 - coverage, 1.0);
  cout<<"Separation from histograms = "<<sepH<<" with coverage "<<coverage<<endl;


  cout << "OBSERVED SIGNIFICANCE" << endl;

  cout << "observation: " << v_Obs[0] << endl;
  cout << "bin: " << hObs->GetMaximumBin() << endl;
  
  cout << " --------------- " << endl;
  double obsPval_SM = 1-hSM->Integral(0,hObs->GetMaximumBin())/hSM->Integral();
  cout << "pvalue SM: " << obsPval_SM << endl;
  cout << "signif SM: " << ROOT::Math::normal_quantile_c(obsPval_SM,1.0) << endl;;
  double obsPval_PS =  hPS->Integral(0,hObs->GetMaximumBin())/hPS->Integral();
  cout << "pvalue PS: " << obsPval_PS << endl;
  cout << "signif PS: " << ROOT::Math::normal_quantile_c(obsPval_PS,1.0) << endl;;


  gStyle->SetOptStat(0);
  TCanvas *c1=new TCanvas("c1","c1",500,500);
  c1->cd();
  hSM->Rebin(50);
  hPS->Rebin(50);
  float maxhSM=hSM->GetBinContent(hSM->GetMaximumBin());
  float maxhPS=hPS->GetBinContent(hPS->GetMaximumBin());
  if(maxhPS>maxhSM){
    hSM->SetMaximum(maxhPS*1.15);
    hPS->SetMaximum(maxhPS*1.15);
  }
  else{
    hSM->SetMaximum(maxhSM*1.15);
    hPS->SetMaximum(maxhSM*1.15);
  }
  hSM->SetXTitle("S = -2 #times ln(L_{1}/L_{2})");
  hSM->SetYTitle("Generated experiments");
  hPS->SetXTitle("S = -2 #times ln(L_{1}/L_{2})");
  hPS->SetYTitle("Generated experiments");
  hSM->SetLineColor(kMagenta-3);
  hSM->SetFillColor(kMagenta-3);
  hSM->SetLineWidth(2);
  hSM->SetFillStyle(3605);
  hPS->SetLineColor(kBlue+1);
  hPS->SetFillColor(kBlue+1);
  hPS->SetLineWidth(2);
  hPS->SetFillStyle(3695);
  hObs->SetLineColor(kGreen+3);
  hObs->SetLineWidth(2);
  hSM->Draw();
  hPS->Draw("sames");
  
  TArrow *obsArrow  = new TArrow(v_Obs[0],hSM->GetMaximum()/2.,v_Obs[0],0.0,.05,"|>");
  obsArrow->SetLineWidth(3);
  obsArrow->Draw("same");
  //hObs->Draw("sames");

  TLegend *leg = new TLegend(0.7,0.6,0.9,0.9);
  leg->SetFillColor(0);
  leg->SetBorderSize(0);
  leg->AddEntry(hSM,"  PS, 0-","f");
  leg->AddEntry(hPS,"  SM, 0+","f");
  leg->Draw();


  TPaveText pt(0.16,0.95,0.45,0.99,"NDC");
  pt.SetFillColor(0);
  pt.AddText("CMS Expected");
  pt.SetBorderSize(0);
  TPaveText pt2(0.55,0.95,0.99,0.99,"NDC");
  pt2.SetFillColor(0);
  pt2.AddText(Form(" #sqrt{s} = 7 TeV, L = %.3f fb^{-1}; #sqrt{s} = 8 TeV, L = %.3f fb^{-1}",lumi7TeV,lumi8TeV));
  pt2.SetBorderSize(0);
  pt.Draw();
  pt2.Draw();
  c1->SaveAs("sigsep_combine.eps");
  c1->SaveAs("sigsep_combine.root");

  return 0;
}//end main
Beispiel #24
0
void fildir(){


   TCanvas *c1 = new TCanvas("c1","ROOT FilDir description",700,900);
   c1->Range(1,1,19,24.5);
   TPaveLabel *title = new TPaveLabel(4,23,16,24.2,"ROOT File/Directory/Key description");
   title->SetFillColor(16);
   title->Draw();

   Int_t keycolor = 42;
   Int_t dircolor = 21;
   Int_t objcolor = 46;
   TPaveText *file = new TPaveText(2,19,6,22);
   file->SetFillColor(39);
   file->Draw();
   file->SetTextSize(0.04);
   file->AddText("TFile");
   file->AddText("Header");
   TArrow *arrow = new TArrow(6,20.5,17,20.5,0.02,"|>");
   arrow->SetFillStyle(1001);
   arrow->SetLineWidth(2);
   arrow->Draw();
   TPaveText *free1 = new TPaveText(8,20,11,21);
   free1->SetFillColor(18);
   free1->Draw();
   free1->AddText("First:Last");
   TPaveText *free2 = new TPaveText(12,20,15,21);
   free2->SetFillColor(18);
   free2->Draw();
   free2->AddText("First:Last");
   TText *tfree = new TText(6.2,21.2,"fFree = TList of free blocks");
   tfree->SetTextSize(0.02);
   tfree->Draw();
   TText *tkeys = new TText(5.2,18.2,"fKeys = TList of Keys");
   tkeys->SetTextSize(0.02);
   tkeys->Draw();
   TText *tmemory = new TText(3.2,15.2,"fListHead = TList of Objects in memory");
   tmemory->SetTextSize(0.02);
   tmemory->Draw();

   arrow->DrawArrow(5,17,17,17,0.02,"|>");
   TLine *line = new TLine(5,19,5,17);
   line->SetLineWidth(2);
   line->Draw();
   TPaveText *key0 = new TPaveText(7,16,10,18);
   key0->SetTextSize(0.04);
   key0->SetFillColor(keycolor);
   key0->AddText("Key 0");
   key0->Draw();
   TPaveText *key1 = new TPaveText(12,16,15,18);
   key1->SetTextSize(0.04);
   key1->SetFillColor(keycolor);
   key1->AddText("Key 1");
   key1->Draw();
   line->DrawLine(3,19,3,14);
   line->DrawLine(3,14,18,14);
   TPaveText *obj0 = new TPaveText(5,13,8,15);
   obj0->SetFillColor(objcolor);
   obj0->AddText("Object");
   obj0->Draw();
   TPaveText *dir1 = new TPaveText(10,13,13,15);
   dir1->SetFillColor(dircolor);
   dir1->AddText("SubDir");
   dir1->Draw();
   TPaveText *obj1 = new TPaveText(15,13,18,15);
   obj1->SetFillColor(objcolor);
   obj1->AddText("Object");
   obj1->Draw();
   arrow->DrawArrow(12,11,17,11,0.015,"|>");
   arrow->DrawArrow(11,9,17,9,0.015,"|>");
   line->DrawLine(12,13,12,11);
   line->DrawLine(11,13,11,9);
   TPaveText *key2 = new TPaveText(14,10.5,16,11.5);
   key2->SetFillColor(keycolor);
   key2->AddText("Key 0");
   key2->Draw();
   TPaveText *obj2 = new TPaveText(14,8.5,16,9.5);
   obj2->SetFillColor(objcolor);
   obj2->AddText("Object");
   obj2->Draw();
   TLine *ldot = new TLine(10,15,2,11);
   ldot->SetLineStyle(2);
   ldot->Draw();
   ldot->DrawLine(13,15,8,11);
   ldot->DrawLine(13,13,8,5);
   TPaveText *dirdata = new TPaveText(2,5,8,11);
   dirdata->SetTextAlign(12);
   dirdata->SetFillColor(dircolor);
   dirdata->Draw();
   dirdata->SetTextSize(0.015);
   dirdata->AddText("fModified: True if directory is modified");
   dirdata->AddText("fWritable: True if directory is writable");
   dirdata->AddText("fDatimeC: Creation Date/Time");
   dirdata->AddText("fDatimeM: Last mod Date/Time");
   dirdata->AddText("fNbytesKeys: Number of bytes of key");
   dirdata->AddText("fNbytesName : Header length up to title");
   dirdata->AddText("fSeekDir: Start of Directory on file");
   dirdata->AddText("fSeekParent: Start of Parent Directory");
   dirdata->AddText("fSeekKeys: Pointer to Keys record");
   TPaveText *keydata = new TPaveText(10,2,17,7);
   keydata->SetTextAlign(12);
   keydata->SetFillColor(keycolor);
   keydata->Draw();
   ldot->DrawLine(14,11.5,10,7);
   ldot->DrawLine(16,11.5,17,7);
   keydata->SetTextSize(0.015);
   keydata->AddText("fNbytes: Size of compressed Object");
   keydata->AddText("fObjLen: Size of uncompressed Object");
   keydata->AddText("fDatime: Date/Time when written to store");
   keydata->AddText("fKeylen: Number of bytes for the key");
   keydata->AddText("fCycle : Cycle number");
   keydata->AddText("fSeekKey: Pointer to Object on file");
   keydata->AddText("fSeekPdir: Pointer to directory on file");
   keydata->AddText("fClassName: 'TKey'");
   keydata->AddText("fName: Object name");
   keydata->AddText("fTitle: Object Title");
   c1->Print("fildir.png");
}
Beispiel #25
0
void toyplotsge1btight() {

    gStyle->SetPadBottomMargin(0.15) ;
    gStyle->SetPadLeftMargin(0.15) ;
    gStyle->SetOptTitle(0) ;


    TCanvas* c1 = new TCanvas("c1","c1") ;

    TArrow* arrow = new TArrow() ;
    arrow->SetLineWidth(3) ;


    TChain toyns("toytt") ;
    toyns.Add("output-files/toy-data-ge1btight.root") ;


    //--- extract true values from TTree.

    double fit_tru_ttwj ;
    TBranch* b_fit_tru_ttwj ;
    toyns.SetBranchAddress("fit_tru_ttwj", &fit_tru_ttwj, &b_fit_tru_ttwj ) ;
    toyns.GetEntry() ;
    printf("\n\n true value for ttwj : %8.2f\n", fit_tru_ttwj ) ;

    double fit_tru_qcd ;
    TBranch* b_fit_tru_qcd ;
    toyns.SetBranchAddress("fit_tru_qcd", &fit_tru_qcd, &b_fit_tru_qcd ) ;
    toyns.GetEntry() ;
    printf("\n\n true value for qcd : %8.2f\n", fit_tru_qcd ) ;

    double fit_tru_znn ;
    TBranch* b_fit_tru_znn ;
    toyns.SetBranchAddress("fit_tru_znn", &fit_tru_znn, &b_fit_tru_znn ) ;
    toyns.GetEntry() ;
    printf("\n\n true value for znn : %8.2f\n", fit_tru_znn ) ;


    //============ fit values

    gStyle->SetOptStat("emr") ;

    TH1F* httwjfit = new TH1F("httwjfit","ttwj",40, 0., 40. ) ;
    TH1F* hqcdfit  = new TH1F("hqcdfit" ,"qcd" ,40, 0., 15. ) ;
    TH1F* hznnfit  = new TH1F("hznnfit" ,"znn" ,40, 0., 25. ) ;

    toyns.Draw("fit_val_ttwj>>httwjfit","fit_cov_qual==3") ;
    toyns.Draw("fit_val_qcd>>hqcdfit","fit_cov_qual==3") ;
    toyns.Draw("fit_val_znn>>hznnfit","fit_cov_qual==3") ;

    httwjfit->SetLineWidth(2) ;
    hqcdfit->SetLineWidth(2) ;
    hznnfit->SetLineWidth(2) ;

    httwjfit->SetFillColor(11) ;
    hqcdfit->SetFillColor(11) ;
    hznnfit->SetFillColor(11) ;

    httwjfit->SetXTitle("Fit ttwj SIG events") ;
    hqcdfit->SetXTitle("Fit QCD SIG events") ;
    hznnfit->SetXTitle("Fit Znn SIG events") ;

    httwjfit->SetYTitle("Toy experiments") ;
    hqcdfit->SetYTitle("Toy experiments") ;
    hznnfit->SetYTitle("Toy experiments") ;

    httwjfit->Draw() ;
    arrow->DrawArrow(fit_tru_ttwj, 0.4*(httwjfit->GetMaximum()), fit_tru_ttwj, 0) ;
    c1->SaveAs("output-files/toymc-ttwj-sig-fit-ge1btight.png") ;
    hqcdfit->Draw() ;
    arrow->DrawArrow(fit_tru_qcd, 0.4*(hqcdfit->GetMaximum()), fit_tru_qcd, 0) ;
    c1->SaveAs("output-files/toymc-qcd-sig-fit-ge1btight.png") ;
    hznnfit->Draw() ;
    arrow->DrawArrow(fit_tru_znn, 0.4*(hznnfit->GetMaximum()), fit_tru_znn, 0) ;
    c1->SaveAs("output-files/toymc-znn-sig-fit-ge1btight.png") ;


    //============ fit uncertainty

    TH1F* httwjerr = new TH1F("httwjerr","ttwj",40, 0., 15. ) ;
    TH1F* hqcderr  = new TH1F("hqcderr" ,"qcd" ,40, 0., 10. ) ;
    TH1F* hznnerr  = new TH1F("hznnerr" ,"znn" ,40, 0., 15. ) ;

    toyns.Draw("fit_err_ttwj>>httwjerr","fit_cov_qual==3") ;
    toyns.Draw("fit_err_qcd>>hqcderr","fit_cov_qual==3") ;
    toyns.Draw("fit_err_znn>>hznnerr","fit_cov_qual==3") ;

    httwjerr->SetLineWidth(2) ;
    hqcderr->SetLineWidth(2) ;
    hznnerr->SetLineWidth(2) ;

    httwjerr->SetFillColor(11) ;
    hqcderr->SetFillColor(11) ;
    hznnerr->SetFillColor(11) ;

    httwjerr->SetXTitle("err ttwj SIG events") ;
    hqcderr->SetXTitle("err QCD SIG events") ;
    hznnerr->SetXTitle("err Znn SIG events") ;

    httwjerr->SetYTitle("Toy experiments") ;
    hqcderr->SetYTitle("Toy experiments") ;
    hznnerr->SetYTitle("Toy experiments") ;

    httwjerr->Draw() ;
    c1->SaveAs("output-files/toymc-ttwj-sig-err-ge1btight.png") ;
    hqcderr->Draw() ;
    c1->SaveAs("output-files/toymc-qcd-sig-err-ge1btight.png") ;
    hznnerr->Draw() ;
    c1->SaveAs("output-files/toymc-znn-sig-err-ge1btight.png") ;






}
Beispiel #26
0
   void toyplotsge1btight() {

      gStyle->SetPadBottomMargin(0.15) ;
      gStyle->SetPadLeftMargin(0.15) ;
      gStyle->SetOptTitle(0) ;


      TCanvas* c1 = new TCanvas("c1","c1") ;

      TArrow* arrow = new TArrow() ;
      arrow->SetLineWidth(3) ;


      TChain toyns("tt_toy_nosusyfit") ;
      toyns.Add("an-11-257-v3-files/output-files/toyge1btight-smonly-mctest.root") ;

      TChain bgo("tt_cls_bgonly") ;
      TChain spb("tt_cls_splusb") ;

      bgo.Add("an-11-257-v3-files/output-files/toyge1btight-smonly-mctest.root") ;
      spb.Add("an-11-257-v3-files/output-files/toyge1btight-smonly-mctest.root") ;



     //============ fit values

      gStyle->SetOptStat("emr") ;

      TH1F* httwjfit = new TH1F("httwjfit","ttwj",40, 0., 45. ) ;
      TH1F* hqcdfit  = new TH1F("hqcdfit" ,"qcd" ,40, 0., 10. ) ;
      TH1F* hznnfit  = new TH1F("hznnfit" ,"znn" ,40, 0., 20. ) ;

      toyns.Draw("ttwj_sig_fit>>httwjfit","") ;
      toyns.Draw("qcd_sig_fit>>hqcdfit","") ;
      toyns.Draw("znn_sig_fit>>hznnfit","") ;

      httwjfit->SetLineWidth(2) ;
      hqcdfit->SetLineWidth(2) ;
      hznnfit->SetLineWidth(2) ;

      httwjfit->SetFillColor(11) ;
      hqcdfit->SetFillColor(11) ;
      hznnfit->SetFillColor(11) ;

      httwjfit->SetXTitle("Fit ttwj SIG events") ;
      hqcdfit->SetXTitle("Fit QCD SIG events") ;
      hznnfit->SetXTitle("Fit Znn SIG events") ;

      httwjfit->SetYTitle("Toy experiments") ;
      hqcdfit->SetYTitle("Toy experiments") ;
      hznnfit->SetYTitle("Toy experiments") ;

      httwjfit->Draw() ;
      arrow->DrawArrow(19.6,40,19.6,0) ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-ttwj-sig-fit-ge1btight.png") ;
      hqcdfit->Draw() ;
      arrow->DrawArrow(1.3,60,1.3,0) ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-qcd-sig-fit-ge1btight.png") ;
      hznnfit->Draw() ;
      arrow->DrawArrow(4.25,40,4.25,0) ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-znn-sig-fit-ge1btight.png") ;


     //============ fit uncertainty

      TH1F* httwjerr = new TH1F("httwjerr","ttwj",40, 0., 10. ) ;
      TH1F* hqcderr  = new TH1F("hqcderr" ,"qcd" ,40, 0., 8. ) ;
      TH1F* hznnerr  = new TH1F("hznnerr" ,"znn" ,40, 0., 10. ) ;

      toyns.Draw("ttwj_sig_err>>httwjerr","") ;
      toyns.Draw("qcd_sig_err>>hqcderr","") ;
      toyns.Draw("znn_sig_err>>hznnerr","") ;

      httwjerr->SetLineWidth(2) ;
      hqcderr->SetLineWidth(2) ;
      hznnerr->SetLineWidth(2) ;

      httwjerr->SetFillColor(11) ;
      hqcderr->SetFillColor(11) ;
      hznnerr->SetFillColor(11) ;

      httwjerr->SetXTitle("err ttwj SIG events") ;
      hqcderr->SetXTitle("err QCD SIG events") ;
      hznnerr->SetXTitle("err Znn SIG events") ;

      httwjerr->SetYTitle("Toy experiments") ;
      hqcderr->SetYTitle("Toy experiments") ;
      hznnerr->SetYTitle("Toy experiments") ;

      httwjerr->Draw() ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-ttwj-sig-err-ge1btight.png") ;
      hqcderr->Draw() ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-qcd-sig-err-ge1btight.png") ;
      hznnerr->Draw() ;
      c1->SaveAs("an-11-257-v3-files/output-files/toymc-znn-sig-err-ge1btight.png") ;


     //============ q value distributions.

      gStyle->SetOptStat(0) ;

      TH1F* hbgo = new TH1F("hbgo","BG only", 50, 0., 15.) ;
      TH1F* hspb = new TH1F("hspb","SIG + BG", 50, 0., 15.) ;

      hbgo->SetLineWidth(2) ;
      hspb->SetLineWidth(2) ;
      hbgo->SetLineColor(2) ;
      hspb->SetLineColor(4) ;

      bgo.Draw("testStat>>hbgo","") ;
      spb.Draw("testStat>>hspb","") ;

      hspb->SetXTitle("q value") ;
      hspb->SetYTitle("Toy experiments") ;

      hspb->Draw() ;
      hbgo->Draw("same") ;


    //+++ X value below is hardwired to 2.44.
    //    If inputs are changed, grep the string "Data value of test statistic"
    //    in the runtoyge1btight log file to find the new value.
    //
      arrow->DrawArrow(1.13,150,1.13,0.,0,">") ;

      TLegend* legend = new TLegend(0.4,0.5,0.8,0.8) ;
      legend->AddEntry( hbgo, "BG-only hypothesis") ;
      legend->AddEntry( hspb, "SUSY+BG hypothesis") ;
      legend->SetFillColor(kWhite) ;

      legend->Draw() ;


      c1->SaveAs("an-11-257-v3-files/output-files/toymc-qvalue-distributions-ge1btight.png") ;




   }
Beispiel #27
0
// draw the same thing but after reco
void genPlots02(std::string fullPath, int nOverlay = 500, bool custBinning = false)
{
    const int fVerbose(1);
    setTDRStyle();
    gStyle->SetOptStat(112211);
    gStyle->SetPalette(1);
    // Canvas
    c = new TCanvas("c2","c2",1000,600);
    const unsigned int nPadX = 1;
    const unsigned int nPadY = 1;
    c->Divide(nPadX,nPadY);
    const unsigned int nPads=nPadX*nPadY;
    for(unsigned int i=1; i<=nPads; i++)
    {
	TPad* pad= (TPad*)c->cd(i);
	pad->SetTopMargin(0.10);
	pad->SetRightMargin(0.20);
	pad->SetLeftMargin(0.15);
    }
    // Open file
    TFile *f = TFile::Open(fullPath.c_str());
    if (f==0)
    {
	cout << "File " << fullPath << " not found -- exiting" << endl;
	return;
    }
    if(fVerbose>0)
	cout << "Succesfully opened file " << fullPath << endl;
    // Get TTree
    TTree* t = (TTree*) f->Get("events");
    if(fVerbose>0) cout << "Got TTree with " << t->GetEntries() << " entries" << endl;
    // Do a cut, if needed
    //t->Draw(">>lst","chi2lb>.1&&mlb>5.61&&mlb<5.63");
    //t->Draw(">>lst","chi2lb>.1&&isSig==1");
    t->Draw(">>lst","(rid1m&4)==4&&(rid2m&4)==4&&mjp>2.895&&mjp<3.295&&prob1m>0.1&&prob2m>0.1&&ptjp>2&&probjp>0.005&&ml0>1.101&&ml0<1.129&&probpr>0.02&&probpi>0.02&&rptpr>rptpi&&ptl0>3&&rptpr>1&&rptpi>0.5&&probl0>0.02&&alphal0<0.3&&d3l0>1&&d3l0/d3El0>10&&problb>0.001&&alphalb<0.3");
    TEventList *lst;
    lst = (TEventList*)gDirectory->Get("lst");
    t->SetEventList(lst);
    if(fVerbose>0) cout << "Got TTree with " << t->GetEntries() << " entries" << endl;

    // Do plots
    c->cd(1);
    //doPlot2d(t,"hrzL0vtx", "vrl0:TMath::Abs(vzl0)",30,0,300,30,0,120,"Tit","|z|","r","cm","cm");
    if (custBinning)
    {
	double newbinsX[]={0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50};
	const int newbinsX_size = sizeof(newbinsX)/sizeof(double);
	std::vector<double> binvecX(newbinsX,newbinsX+newbinsX_size);
	//double newbinsY[]={0,1,2,3,4,5,6,7,8,9,10};
	double newbinsY[]={0,0.5,1,2,4,8,16,32};
	const int newbinsY_size = sizeof(newbinsY)/sizeof(double);
	std::vector<double> binvecY(newbinsY,newbinsY+newbinsY_size);
	doPlot2d(t,"hrzL0vtxreco", "vrl0:TMath::Abs(vzl0)",binvecX, binvecY,"#Lambda vertices","|z|","r","cm","cm");
    }
    else
    {
	doPlot2d(t,"hrzL0vtxreco", "vrl0:TMath::Abs(vzl0)",30,0,50,30,0,30,"#Lambda vertices","|z|","r","cm","cm");
    }

    // add tracker
    TPad* pad;
    pad = (TPad*)c->cd(1);
    pad->Modified();
    pad->Update();
    repositionPalette("hrzL0vtxreco");
    pad->Update();
    pad->SetLogz();
    drawTracker(pad);

    if (nOverlay<=0) return;
    int maxN = nOverlay;
    if (maxN > t->GetEntries()) maxN = t->GetEntries();
    double vrl0,vzl0,ppr,ppi,etapr,etapi;
    t->SetBranchAddress("vrl0",&vrl0);
    t->SetBranchAddress("vzl0",&vzl0);
    t->SetBranchAddress("ppr",&ppr);
    t->SetBranchAddress("etapr",&etapr);
    t->SetBranchAddress("ppi",&ppi);
    t->SetBranchAddress("etapi",&etapi);
    double scalepr = 4;
    double scalepi = 8;

    { // reference indicator
	const double x1pr = 0; const double y1pr = -3;
	const double x2pr = scalepr; const double y2pr = y1pr;
	const double versatz = 14;
	const double x1pi = x1pr+versatz; const double y1pi = -3;
	const double x2pi = x2pr+versatz+scalepi; const double y2pi = y1pi;
	TArrow *a;
	a = new TArrow(x1pr,y1pr,x2pr,y2pr,.01,">");
	a->SetLineColor(24);
	a->Draw();
	TLatex tl;
	tl.SetTextSize(20);
	tl.SetTextFont(4);
	tl.DrawLatex(x1pr,y2pr-1.2,"p(p) / 1 GeV");
	a = new TArrow(x1pi,y1pi,x2pi,y2pi,.01,">");
	a->SetLineColor(20);
	a->Draw();
	tl.SetTextSize(20);
	tl.SetTextFont(4);
	tl.DrawLatex(x1pi,y2pi-1.2,"p(#pi) / 1 GeV");
    }
    for (int i = 0; i!=maxN; i++)
    {
	t->GetEntry(i);
	const double thetapr = 2*TMath::ATan(TMath::Exp(-TMath::Abs(etapr)));
	const double thetapi = 2*TMath::ATan(TMath::Exp(-TMath::Abs(etapi)));
	const double x1=TMath::Abs(vzl0);
	const double y1=vrl0;
	const double x2pr=x1+scalepr*ppr*TMath::Cos(thetapr);
	const double y2pr=y1+scalepr*ppr*TMath::Sin(thetapr);
	const double x2pi=x1+scalepi*ppi*TMath::Cos(thetapi);
	const double y2pi=y1+scalepi*ppi*TMath::Sin(thetapi);
	TArrow *a;
        a = new TArrow(x1,y1,x2pr,y2pr,.01,">");
	a->SetLineColor(24);
	a->Draw();
        a = new TArrow(x1,y1,x2pi,y2pi,.01,">");
	a->SetLineColor(20);
	a->Draw();
	TMarker *m = new TMarker(x1,y1,7);
	m->SetMarkerColor(28);
	m->Draw();
    }
}
Beispiel #28
0
void analyze() {
   TCanvas *c1 = new TCanvas("c1","Analyze.mac",620,790);
   c1->Range(-1,0,19,30);
   TPaveLabel *pl1 = new TPaveLabel(0,27,3.5,29,"Analyze");
   pl1->SetFillColor(42);
   pl1->Draw();
   TPaveText *pt1 = new TPaveText(0,22.8,4,25.2);
   TText *t1  = pt1->AddText("Parenthesis matching");
   TText *t2  = pt1->AddText("Remove unnecessary");
   TText *t2a = pt1->AddText("parenthesis");
   pt1->Draw();
   TPaveText *pt2 = new TPaveText(6,23,10,25);
   TText *t3 = pt2->AddText("break of");
   TText *t4 = pt2->AddText("Analyze");
   pt2->Draw();
   TPaveText *pt3 = new TPaveText(0,19,4,21);
   t4=pt3->AddText("look for simple");
   TText *t5 = pt3->AddText("operators");
   pt3->Draw();
   TPaveText *pt4 = new TPaveText(0,15,4,17);
   TText *t6 = pt4->AddText("look for an already");
   TText *t7 = pt4->AddText("defined expression");
   pt4->Draw();
   TPaveText *pt5 = new TPaveText(0,11,4,13);
   TText *t8 = pt5->AddText("look for usual");
   TText *t9 = pt5->AddText("functions :cos sin ..");
   pt5->Draw();
   TPaveText *pt6 = new TPaveText(0,7,4,9);
   TText *t10 = pt6->AddText("look for a");
   TText *t11 = pt6->AddText("numeric value");
   pt6->Draw();
   TPaveText *pt7 = new TPaveText(6,18.5,10,21.5);
   TText *t12 = pt7->AddText("Analyze left and");
   TText *t13 = pt7->AddText("right part of");
   TText *t14 = pt7->AddText("the expression");
   pt7->Draw();
   TPaveText *pt8 = new TPaveText(6,15,10,17);
   TText *t15 = pt8->AddText("Replace expression");
   pt8->Draw();
   TPaveText *pt9 = new TPaveText(6,11,10,13);
   TText *t16 = pt9->AddText("Analyze");
   pt9->SetFillColor(42);
   pt9->Draw();
   TPaveText *pt10 = new TPaveText(6,7,10,9);
   TText *t17 = pt10->AddText("Error");
   TText *t18 = pt10->AddText("Break of Analyze");
   pt10->Draw();
   TPaveText *pt11 = new TPaveText(14,22,17,24);
   pt11->SetFillColor(42);
   TText *t19  = pt11->AddText("Analyze");
   TText *t19a = pt11->AddText("Left");
   pt11->Draw();
   TPaveText *pt12 = new TPaveText(14,19,17,21);
   pt12->SetFillColor(42);
   TText *t20  = pt12->AddText("Analyze");
   TText *t20a = pt12->AddText("Right");
   pt12->Draw();
   TPaveText *pt13 = new TPaveText(14,15,18,18);
   TText *t21 = pt13->AddText("StackNumber++");
   TText *t22 = pt13->AddText("operator[StackNumber]");
   TText *t23 = pt13->AddText("= operator found");
   pt13->Draw();
   TPaveText *pt14 = new TPaveText(12,10.8,17,13.2);
   TText *t24 = pt14->AddText("StackNumber++");
   TText *t25 = pt14->AddText("operator[StackNumber]");
   TText *t26 = pt14->AddText("= function found");
   pt14->Draw();
   TPaveText *pt15 = new TPaveText(6,7,10,9);
   TText *t27 = pt15->AddText("Error");
   TText *t28 = pt15->AddText("break of Analyze");
   pt15->Draw();
   TPaveText *pt16 = new TPaveText(0,2,7,5);
   TText *t29 = pt16->AddText("StackNumber++");
   TText *t30 = pt16->AddText("operator[StackNumber] = 0");
   TText *t31 = pt16->AddText("value[StackNumber] = value found");
   pt16->Draw();
   TArrow *ar = new TArrow(2,27,2,25.4,0.012,"|>");
   ar->SetFillColor(1);
   ar->Draw();
   ar->DrawArrow(2,22.8,2,21.2,0.012,"|>");
   ar->DrawArrow(2,19,2,17.2,0.012,"|>");
   ar->DrawArrow(2,15,2,13.2,0.012,"|>");
   ar->DrawArrow(2,11,2, 9.2,0.012,"|>");
   ar->DrawArrow(2, 7,2, 5.2,0.012,"|>");
   ar->DrawArrow(4,24,6,24,0.012,"|>");
   ar->DrawArrow(4,20,6,20,0.012,"|>");
   ar->DrawArrow(4,16,6,16,0.012,"|>");
   ar->DrawArrow(4,12,6,12,0.012,"|>");
   ar->DrawArrow(4, 8,6, 8,0.012,"|>");
   ar->DrawArrow(10,20,14,20,0.012,"|>");
   ar->DrawArrow(12,23,14,23,0.012,"|>");
   ar->DrawArrow(12,16.5,14,16.5,0.012,"|>");
   ar->DrawArrow(10,12,12,12,0.012,"|>");
   TText *ta = new TText(2.2,22.2,"err = 0");
   ta->SetTextFont(71);
   ta->SetTextSize(0.015);
   ta->SetTextColor(4);
   ta->SetTextAlign(12);
   ta->Draw();
   ta->DrawText(2.2,18.2,"not found");
   ta->DrawText(2.2,6.2,"found");
   TText *tb = new TText(4.2,24.1,"err != 0");
   tb->SetTextFont(71);
   tb->SetTextSize(0.015);
   tb->SetTextColor(4);
   tb->SetTextAlign(11);
   tb->Draw();
   tb->DrawText(4.2,20.1,"found");
   tb->DrawText(4.2,16.1,"found");
   tb->DrawText(4.2,12.1,"found");
   tb->DrawText(4.2, 8.1,"not found");
   TLine *l1 = new TLine(12,16.5,12,23);
   l1->Draw();
}
void gluinostopMassLifetime(double lumi=4560., double maxInstLumi=5000.) {

  ExtraLimitPlots plots(lumi);
  plots.calculateCrossSections(4,6,3,39,9);

  // xsecs as extracted from nllfast http://web.physik.rwth-aachen.de/service/wiki/bin/view/Main/SquarksandGluinos
  // gluino (m_squark=m_gluino):  "nllfast gg mstw <mass> <mass>"
  // gluino (m_squark>>m_gluino): "nllfast gdcpl mstw <mass>"
  // stop: "nllfast st mstw <mass>"
  // the xsec of gluino and stop are updated for 13TeV analysis, the xsecs are extracted from:
  // https://twiki.cern.ch/twiki/bin/view/LHCPhysics/SUSYCrossSections#Cross_sections_for_various_S_AN2
  double g_mass [21] = {  
    200 ,     250 ,     300 ,     350 ,     400 ,   
    450 ,     500 ,     550 ,     600 ,     650 ,   
    700 ,     750 ,     800 ,     850 ,     900 ,   
    950 ,    1000 ,    1050 ,    1100 ,    1150 ,   
    1200 };
  double g_xsec [21] = {  
    3574,      1190,     462,     202,     98.0,
    50.4,      27.4,    15.6,     9.20,    5.60,
    3.53,      2.27,     1.49,   0.996,   0.677,
    0.466,     0.325,  0.229,   0.163,  0.118,
    0.0856
  };
  double g_xsecdcpl [21] = {  
    3574,      1190,     462,     202,     98.0,
    50.4,      27.4,    15.6,     9.20,    5.60,
    3.53,      2.27,     1.49,   0.996,   0.677,
    0.466,     0.325,  0.229,   0.163,  0.118,
    0.0856
  };
  double s_mass [21] = {  
    100 ,     150 ,     200 ,     250 ,     300 ,   
    350 ,     400 ,     450 ,     500 ,     550 ,   
    600 ,     650 ,     700 ,     750 ,     800 ,   
    850 ,     900 ,     950 ,    1000 ,    1050 ,   
    1100 };
  double s_xsec [21] = {  
    1521,       249.4,     64.5,     21.6,     8.51,
    3.79,        1.84,    0.948,   0.518,   0.296,
    0.175,      0.107,  0.067,  0.0431,  0.0283,
    0.0190,    0.0129, 0.00883, 0.00615, 0.00432,
    0.00307
  };

  //gluino xsec
  vector<double> masses;
  for (int i = 0; i < 21; ++i)  {
    masses.push_back(g_mass[i]);
    g_xsec [i] = log10 (g_xsec [i]*1e3) * 20.;
    g_xsecdcpl [i] = log10 (g_xsecdcpl [i]*1e3) * 20.;
  }
  //  Xsection gluino_xs (masses, g_xsec);
  Xsection gluino_xs (masses, g_xsecdcpl);
  
  //stop xsec
  masses.clear();
  for (int i = 0; i < 19; ++i)  {
    masses.push_back(s_mass[i]);
    s_xsec [i] = log10 (s_xsec [i]*1e3) * 20.;
  }
  Xsection stop_xs (masses, s_xsec);
  
  // graphs
  TGraph* g_obs     = new TGraph (*plots.getLimitGluino());
  gluino_xs.xsec2mass (g_obs);

  TGraph* g_exp      = new TGraph (*plots.getExpLimitGluino());
  gluino_xs.xsec2mass (g_exp);
  TGraphAsymmErrors* g_exp_1sig = new TGraphAsymmErrors (*plots.getExpLimitGluino1Sig());
  gluino_xs.xsec2mass (g_exp_1sig);
  TGraphAsymmErrors* g_exp_2sig = new TGraphAsymmErrors (*plots.getExpLimitGluino2Sig());
  gluino_xs.xsec2mass (g_exp_2sig);

  TGraph* stop_obs     = new TGraph (*plots.getLimitStop());
  stop_xs.xsec2mass (stop_obs);

  TGraph* stop_exp      = new TGraph (*plots.getExpLimitStop());
  stop_xs.xsec2mass (stop_exp);
  TGraphAsymmErrors* stop_exp_1sig = new TGraphAsymmErrors (*plots.getExpLimitStop1Sig());
  stop_xs.xsec2mass (stop_exp_1sig);
  TGraphAsymmErrors* stop_exp_2sig = new TGraphAsymmErrors (*plots.getExpLimitStop2Sig());
  stop_xs.xsec2mass (stop_exp_2sig);

  
  TCanvas *canvas = new TCanvas("allMassLifetime", "allMassLifetime", 800, 600);
  
  canvas->SetLogx();
//  canvas->SetGridy();

  
  TH1F* h = new TH1F ("h", "", 1,  7.5e-8, 1e6);
  h->SetStats (0);
  h->SetMinimum (300);
  h->SetMaximum (2000);
  h->SetTitle("Beamgap Expt");
  //  h->GetXaxis()->SetTitle("#tau_{#tilde{g},#tilde{t},#tilde{#tau}} [s]");
  h->GetXaxis()->SetTitle("#tau [s]");
  h->GetYaxis()->SetTitle("m [GeV]  ");
  h->Draw ("");

  
  
  // limit arrows
  double* x = g_obs->GetX();
  for (int i = 0; i < g_obs->GetN(); ++i) {
    if (x[i] > 0.5) {
      double y =  g_obs->GetY()[i];
      TArrow* arrow = new TArrow (x[i], y, h->GetXaxis()->GetXmin(), y, 0.02);
      arrow->SetLineColor (kRed);
      arrow->SetLineWidth (2);
      //arrow->Draw();
      cout << "GLUINO mass limit @ " << x[i] << "sec is found: " << y << endl;
      break;
    }
  }
  x = g_obs->GetX();
  for (int i = 0; i < stop_obs->GetN(); ++i) {
    if (x[i] > 0.5) {
      double y =  stop_obs->GetY()[i];
      TArrow* arrow = new TArrow (x[i], y, h->GetXaxis()->GetXmin(), y, 0.02);
      arrow->SetLineColor (kBlue);
      arrow->SetLineWidth (2);
      //arrow->Draw();
      cout << "STOP mass limit @ " << x[i] << "sec is found: " << y << endl;
      break;
    }
  }
 
  // gluino  
  // 2 sigma band
  if (g_exp_2sig) {
    g_exp_2sig->SetLineColor(0);
    g_exp_2sig->SetLineStyle(0);
    g_exp_2sig->SetLineWidth(0);
    g_exp_2sig->SetFillColor(kYellow);
    g_exp_2sig->SetFillStyle(1001);
    g_exp_2sig->Draw("3");
  }
  
  // 1 sigma band
  if (g_exp_1sig) {
    // g_exp_1sig->SetLineColor(8);
    g_exp_1sig->SetLineColor(0);
    g_exp_1sig->SetLineStyle(0);
    g_exp_1sig->SetLineWidth(0);
    // g_exp_1sig->SetFillColor(8);
    g_exp_1sig->SetFillColor(kGreen);
    g_exp_1sig->SetFillStyle(1001);
    // g_exp_1sig->SetFillStyle(3005);
    g_exp_1sig->Draw("3");
    // g_exp_1sig->Draw("lX");
  }
  
  
  // epxected limit
  if (g_exp) {
    g_exp->SetLineColor(kRed);
    g_exp->SetLineStyle(4);
    g_exp->SetLineWidth(2);
    g_exp->Draw("l3");
  }
  

  // observed limit
  if (g_obs) {
    g_obs->SetLineColor(kRed);
    g_obs->SetLineStyle(1);
    g_obs->SetLineWidth(2);
    g_obs->Draw("l");
  }
  
  // stop  
  // 2 sigma band
  if (stop_exp_2sig) {
    stop_exp_2sig->SetLineColor(0);
    stop_exp_2sig->SetLineStyle(0);
    stop_exp_2sig->SetLineWidth(0);
    stop_exp_2sig->SetFillColor(kYellow);
    stop_exp_2sig->SetFillStyle(1001);
    stop_exp_2sig->Draw("3");
  }
  
  // 1 sigma band
  if (stop_exp_1sig) {
    // stop_exp_1sig->SetLineColor(8);
    stop_exp_1sig->SetLineColor(0);
    stop_exp_1sig->SetLineStyle(0);
    stop_exp_1sig->SetLineWidth(0);
    // stop_exp_1sig->SetFillColor(8);
    stop_exp_1sig->SetFillColor(kGreen);
    stop_exp_1sig->SetFillStyle(1001);
    // stop_exp_1sig->SetFillStyle(3005);
    stop_exp_1sig->Draw("3");
    // stop_exp_1sig->Draw("lX");
  }
  
  
  // epxected limit
  if (stop_exp) {
    stop_exp->SetLineColor(kBlue);
    stop_exp->SetLineStyle(3);
    stop_exp->SetLineWidth(2);
    stop_exp->Draw("l3");
  }
  

  // observed limit
  if (stop_obs) {
    stop_obs->SetLineColor(kBlue);
    stop_obs->SetLineStyle(2);
    stop_obs->SetLineWidth(2);
    stop_obs->Draw("l");
  }
  
  

  TPaveText* blurb = new TPaveText(0.20, 0.63, 0.60, 0.90, "NDC");
  blurb->AddText("CMS Preliminary 2015");
  //blurb->AddText("CMS 2012");
  blurb->AddText("#int L dt = 2.46 fb^{-1}"); //,  #int L_{eff} dt = 935 pb^{-1}");
  //blurb->AddText("L^{max}_{inst} = 3.5 #times 10^{33} cm^{-2}s^{-1}");

  // std::stringstream label;
  // label<<"#int L dt = "<<lumi<<" pb^{-1}";
  // blurb->AddText(label.str().c_str());
  // double peakInstLumi=maxInstLumi;
  // int exponent=30;
  // while (peakInstLumi>10) {
  //   peakInstLumi/=10;
  //   ++exponent;
  // }
  // std::stringstream label2;
  // label2<<"L^{max}_{inst} = "<<peakInstLumi<<" x 10^{"<<exponent<<"} cm^{-2}s^{-1}";
//  blurb->AddText(label2.str().c_str());
  blurb->AddText("#sqrt{s} = 13 TeV");
  blurb->AddText("E_{g} > 120 GeV, E_{t} > 150 GeV");
  blurb->AddText("E_{jet} > 70 GeV");
  blurb->SetTextFont(42);
  blurb->SetBorderSize(0);
  blurb->SetFillColor(0);
  blurb->SetShadowColor(0);
  blurb->SetTextAlign(12);
  blurb->SetTextSize(0.033);
  blurb->Draw();

  TLegend* leg = new TLegend(0.6, 0.62, 0.87, 0.90,"95% CL Limits:","NDC");
  leg->SetTextSize(0.033);
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetFillColor(0);

  leg->AddEntry(g_obs, " #tilde{g} observed", "l");
  leg->AddEntry(stop_obs, " #tilde{t} observed", "l");

  TGraph* expectedStyle1 = new TGraph (*g_exp);
  expectedStyle1->SetFillColor (g_exp_1sig->GetFillColor());
  TGraph* expectedStyle2 = new TGraph (*g_exp);
  expectedStyle2->SetFillColor (g_exp_2sig->GetFillColor());
  leg->AddEntry(expectedStyle1, " #tilde{g} expected #pm1#sigma", "lf");
  leg->AddEntry(expectedStyle2, " #tilde{g} expected #pm2#sigma", "lf");

  expectedStyle1 = new TGraph (*stop_exp);
  expectedStyle1->SetFillColor (stop_exp_1sig->GetFillColor());
  expectedStyle2 = new TGraph (*stop_exp);
  expectedStyle2->SetFillColor (stop_exp_2sig->GetFillColor());
  leg->AddEntry(expectedStyle1, " #tilde{t} expected #pm1#sigma", "lf");
  leg->AddEntry(expectedStyle2, " #tilde{t} expected #pm2#sigma", "lf");
  leg->Draw();

  h->Draw("sameaxis");

  canvas->Print("gluinostopMassLifetime.png");
  canvas->Print("gluinostopMassLifetime.pdf");
}
Beispiel #30
0
/// \file
/// \ingroup tutorial_tree
/// \notebook
/// Playing with a Tree containing variables of type character
/// \macro_image
/// \macro_code
/// \author Rene Brun
void cernstaff () {
   TString dir = gROOT->GetTutorialsDir();
   dir.Append("/tree/cernstaff.C");
   if (gSystem->AccessPathName("cernstaff.root")) {
      gROOT->SetMacroPath(dir);
      gROOT->ProcessLine(".x cernbuild.C");
   }
   TFile *f = new TFile("cernstaff.root");
   TTree *T = (TTree*)f->Get("T");
   TCanvas *c1 = new TCanvas("c1","CERN staff",10,10,1000,750);
   c1->Divide(2,2);
   // make table of number of people per Nation & Division
   c1->cd(1); gPad->SetGrid();
   T->Draw("Nation:Division>>hN","","text");
   TH2F *hN = (TH2F*)gDirectory->Get("hN");
   hN->SetMarkerSize(1.6);
   hN->SetStats(0);

   //make profile of Average cost per Nation
   c1->cd(2); gPad->SetGrid();
   gPad->SetLeftMargin(0.12);
   T->Draw("Cost:Nation>>hNation","","prof,goff");
   TH1F *hNation = (TH1F*)gDirectory->Get("hNation");
   hNation->SetTitle("Average Cost per Nation");
   hNation->LabelsOption(">"); //sort by decreasing bin contents
   hNation->SetMaximum(13000);
   hNation->SetMinimum(7000);
   hNation->SetStats(0);
   hNation->SetMarkerStyle(21);
   hNation->Draw();

   //make stacked plot of Nations versus Grade
   c1->cd(3); gPad->SetGrid();
   THStack *hGrades = new THStack("hGrades","Nations versus Grade");
   TH1F *hFR = new TH1F("hFR","FR",12,3,15);
    hFR->SetFillColor(kCyan);
    hGrades->Add(hFR);
    T->Draw("Grade>>hFR","Nation==\"FR\"");
   TH1F *hCH = new TH1F("hCH","CH",12,3,15);
    hCH->SetFillColor(kRed);
    hGrades->Add(hCH);
    T->Draw("Grade>>hCH","Nation==\"CH\"");
   TH1F *hIT = new TH1F("hIT","IT",12,3,15);
    hIT->SetFillColor(kGreen);
    hGrades->Add(hIT);
    T->Draw("Grade>>hIT","Nation==\"IT\"");
   TH1F *hDE = new TH1F("hDE","DE",12,3,15);
    hDE->SetFillColor(kYellow);
    hGrades->Add(hDE);
    T->Draw("Grade>>hDE","Nation==\"DE\"");
   TH1F *hGB = new TH1F("hGB","GB",12,3,15);
    hGB->SetFillColor(kBlue);
    hGrades->Add(hGB);
    T->Draw("Grade>>hGB","Nation==\"GB\"");
   hGrades->Draw();
   TLegend *legend = new TLegend(0.7,0.65,0.86,0.88);
   legend->AddEntry(hGB,"GB","f");
   legend->AddEntry(hDE,"DE","f");
   legend->AddEntry(hIT,"IT","f");
   legend->AddEntry(hCH,"CH","f");
   legend->AddEntry(hFR,"FR","f");
   legend->Draw();

   //make histogram of age distribution
   c1->cd(4); gPad->SetGrid();
   T->Draw("Age");
   T->Draw("Age>>hRetired","Age>(65-2002+1988)","same");
   TH1F *hRetired = (TH1F*)gDirectory->Get("hRetired");
   hRetired->SetFillColor(kRed);
   hRetired->SetFillStyle(3010);

   TArrow *arrow = new TArrow(32,169,55,74,0.03,"|>");
   arrow->SetFillColor(1);
   arrow->SetFillStyle(1001);
   arrow->Draw();

   TPaveText *pt = new TPaveText(0.12,0.8,0.55,0.88,"brNDC");
   pt->SetFillColor(kWhite);
   pt->AddText("People at CERN in 1988");
   pt->AddText("and retired in 2002");
   pt->Draw();

   c1->cd();
}