void vertex_distribution_dataMC() {

  bool print = false;

  TFile *file0 = TFile::Open("results/RecoRoutines_W-selection_WJetsMGZ238PU.root");
  TFile *file1 = TFile::Open("results/RecoRoutines_W-selection_dataskimnov4rereco_newJetColl.root");

  TCanvas * canvas = makeCanvas("vertexDistribution_dataMC");
  TH1D * mc = (TH1D*)file0->Get("RECO_PolPlots_50toinf/RECO_NumVerticesPerEvent");
  TH1D * data = (TH1D*)file1->Get("RECO_PolPlots_50toinf/RECO_NumVerticesPerEvent");

  mc->GetXaxis()->SetTitle("Vertex Multiplicity");
  mc->GetXaxis()->SetTitleSize(0.06);
  mc->GetXaxis()->SetLabelOffset(0.015);
  mc->GetXaxis()->SetTitleOffset(1.2);
  mc->GetXaxis()->SetRangeUser(0,10);
  mc->GetYaxis()->SetRangeUser(0,0.35);

  mc->GetYaxis()->SetTitle("Normalised");
  mc->GetYaxis()->SetTitleSize(0.06);
  mc->GetYaxis()->SetTitleOffset(0.85);

  mc->SetLineColor(kRed);
  data->SetLineColor(kBlack);

  mc->SetLineWidth(4);
  mc->SetLineStyle(2);
  data->SetLineWidth(4);
  data->SetLineStyle(1);

  leg = new TLegend(0.6426174,0.8074324,0.9010067,0.9273649,NULL,"brNDC");
  leg->AddEntry(mc,"MC","l");
  leg->AddEntry(data,"Data","l");
  leg->SetFillColor(kWhite);
  leg->SetBorderSize(0);
  leg->SetTextFont(62);

  canvas->cd();
  mc->DrawNormalized("h");
  data->DrawNormalized("sameh");
  leg->DrawClone();

  if(print) {
    canvas->Write();
  }

  file1->Close();
  file0->Close();
  return;
}
Esempio n. 2
0
File: plotgvsr.C Progetto: XuQiao/HI
void plotgvsr(){
    gStyle->SetOptStat(kFALSE);
TCanvas *c1 = new TCanvas();
c1->SetLogy();
TH1D* hFrame = new TH1D("","",1000,0,1);
hFrame->GetYaxis()->SetRangeUser(1e-10,1e-2);
hFrame->GetXaxis()->SetRangeUser(0.06,0.35);
hFrame->GetXaxis()->SetTitle("r");
hFrame->GetYaxis()->SetTitle("|G^{#theta}(ir)|^{2}");
hFrame->SetTitle("");
hFrame->Draw();
TGraph *gr[nnu];
double r0_theta[nnu];
double G2_theta[nnu];
TLine *l[nnu];
for(int itheta=0;itheta<nnu;itheta++){
gr[itheta]=plotGF(isSum,plotnu[itheta],r0_theta+itheta,G2_theta+itheta,marker[itheta],color[itheta]);
gr[itheta]->Draw("Psame");
}
TLegend *tg = new TLegend(0.75,0.70-0.10*nnu,0.90,0.70);
tg->SetFillColor(0);
tg->SetBorderSize(0);
tg->SetTextSize(0.04);
for(int itheta=0;itheta<nnu;itheta++)
tg->AddEntry(gr[itheta],Form("#theta = #frac{%d}{%d}*#frac{#pi}{%d}",plotnu[itheta],ntheta,nn),"lp");
tg->Draw("same");
TLatex *t= new TLatex();
t->SetNDC();
t->SetTextSize(0.04);
t->SetTextFont(42);
t->DrawLatex(0.3,0.7,Form("PF candidiate, %d < mult <%d, %.1f < p_{T} < %.1f", trkbin[xbin+1],trkbin[xbin],ptmin,ptmax));
if(isSum)
t->DrawLatex(0.5,0.6,Form("LYZ Sum method"));
else
t->DrawLatex(0.5,0.6,Form("LYZ Prod method"));

for(int itheta=0;itheta<nnu;itheta++){
l[itheta] = new TLine(r0_theta[itheta],0,r0_theta[itheta],G2_theta[itheta]);
l[itheta]->SetLineStyle(2);
l[itheta]->SetLineColor(color[itheta]);
l[itheta]->Draw("same");
}
if(isSum)
c1->Print("gvsr_thetas_Sum.png");
else
c1->Print("gvsr_thetas_Prod.png");


}
TH1D* readHist(TString nameHist,TString nameFile, int rebin)
{
 TFile* file = new TFile(nameFile);

 TH1D* hist = (TH1D*)file->Get(nameHist);
 hist->GetSumw2();
 // hist->SetLineWidth(2);
 if(rebin>0) hist->Rebin(rebin);
 hist->GetXaxis()->SetTitleSize(.055);
 hist->GetYaxis()->SetTitleSize(.055);
 hist->GetXaxis()->SetLabelSize(.05);
 hist->GetYaxis()->SetLabelSize(.05);
 hist->SetStats(kFALSE);
 return hist;
}
Esempio n. 4
0
/**
 * The main function.
 */
int main(int argc, char **argv){

  std::cout << "  ComPWA Copyright (C) 2013  Mathias Michel " << std::endl;
  std::cout << "  This program comes with ABSOLUTELY NO WARRANTY; for details see license.txt" << std::endl;
  std::cout << std::endl;

    cout << "DataIF Root 2Particles started " << endl << endl;

    string file = "test/2Part-4vecs.root";
    RootReader myReader(file,"data");
    unsigned int maxEvents = myReader.getNEvents();
    double masssq;
    TH1D* bw = new TH1D("bw","inv. mass of 2 particles",1000,0.,2.4);
    bw->GetXaxis()->SetTitle("m_{12} / GeV");
    bw->GetXaxis()->CenterTitle();
    bw->GetYaxis()->SetTitle("#");
    bw->GetYaxis()->CenterTitle();
    TH1D* bw2 = new TH1D("bw2","inv. mass-sq of 2 particles",1000,0.,4.);
    bw2->GetXaxis()->SetTitle("m_{12}^{2} / GeV^{2}");
    bw2->GetXaxis()->CenterTitle();
    bw2->GetYaxis()->SetTitle("#");
    bw2->GetYaxis()->CenterTitle();

    for(unsigned int i = 0; i < maxEvents; i++){
        Event event(myReader.getEvent(i));
        const Particle &a(event.getParticle(0));
        const Particle &b(event.getParticle(1));

    	//myReader.getEvent(-1, a, b, masssq);
    	//if(!myReader.getEvent(i, event)) continue; TODO: try read exception
    	//if(!event) continue;
    	//cout << "Event: \t" << i << "\t NParticles: \t" << event.getNParticles() << endl;
    	masssq = pow(a.E+b.E,2) - pow(a.px+b.px ,2) - pow(a.py+b.py ,2) - pow(a.pz+b.pz ,2);

        bw->Fill(sqrt(masssq));
    	bw2->Fill(masssq);
    }

    TFile output("test/InputTest.root","RECREATE","ROOT_Tree");
    bw->Write();
    bw2->Write();
    output.Write();
    output.Close();

    cout << "DataIF Root 2Particles finished " <<endl;

  return 0;
}
Esempio n. 5
0
void pixelHistos(const char *filenames = "/export/data1/dambach/hardware/ntpls/gradeC/*.root", const char *cuts =  "defects == 0")
{

  Init();      // do not forget to load the Utilities.C

  TH1D *gainH = new TH1D("gainH", "Gain", 1000, 0., 10.);
  TH1D *pedH = new TH1D("pedH", "Pedestal", 1000, -1000., 1000.);
  TH1D *noiseH = new TH1D("noiseH", "Noise", 1100, -100., 1000.);
  TH1D *tthrH = new TH1D("tthrH", "Trimmed Threshold", 100, 0., 100.);
  
  TChain *c = new TChain("mod");
  c->Add(filenames);
  
  canvas->Clear();
  canvas->Divide(2,2);

  canvas->cd(1);
  InitPad("log");
  gainH->GetXaxis()->SetTitle("ADC units/DAC units");
  gainH->GetYaxis()->SetTitle("# pixels");
  gainH->GetXaxis()->SetTitleSize(0.055);
  gainH->GetYaxis()->SetTitleSize(0.055);
  c->Draw("gain>>gainH", cuts);

  TBox *box = new TBox();

  canvas->cd(2);
  InitPad("log");
  pedH->GetXaxis()->SetTitle("DAC units");
  pedH->GetYaxis()->SetTitle("# pixels");
  pedH->GetXaxis()->SetTitleSize(0.055);
  pedH->GetYaxis()->SetTitleSize(0.055);
  c->Draw("ped>>pedH", cuts);

  canvas->cd(3);
  InitPad("log");
  noiseH->GetXaxis()->SetTitle("e^{-}");
  noiseH->GetYaxis()->SetTitle("# pixels");
  noiseH->GetYaxis()->SetRangeUser(0.1,400000);
  noiseH->GetXaxis()->SetTitleSize(0.055);
  noiseH->GetYaxis()->SetTitleSize(0.055);
  c->Draw("noise>>noiseH", cuts);
  noiseH->Fit("gaus");
//   box->SetFillStyle(3003);
//   box->SetFillColor(kBlue);
//   box->DrawBox(0.1,0.,500.,400000.);
//   box->SetFillColor(kRed);
//   box->DrawBox(500.,0.,1000.,400000.);

  canvas->cd(4);
  tthrH->GetXaxis()->SetTitle("DAC units");
  tthrH->GetYaxis()->SetTitle("# pixels");
  tthrH->GetXaxis()->SetTitleSize(0.055);
  tthrH->GetYaxis()->SetTitleSize(0.055);
  InitPad("log");
  c->Draw("tthr>>tthrH", cuts);

}
Esempio n. 6
0
void plotter::draw_bias(TH1* output_, TH1D* truth_, TH1* bias_, TString file_name){
  TH1D* bias = (TH1D*) bias_->Clone("bias");
  TH1D* truth = (TH1D*) truth_->Clone("truth");
  TH1D* output = (TH1D*) output_->Clone("output");

  double ymax_temp = 0;
  if(truth->GetMaximum() > ymax_temp) ymax_temp = truth->GetMaximum();
  if(bias->GetMaximum() > ymax_temp) ymax_temp = bias->GetMaximum();
  if(output->GetMaximum() > ymax_temp) ymax_temp = output->GetMaximum();
  double ymax = 1.5 * ymax_temp;

  TCanvas *c= new TCanvas("Bias Distribution","",600,600);
  TGaxis::SetMaxDigits(3);
  gPad->SetLeftMargin(0.15);
  truth->SetTitle(file_name);
  truth->GetYaxis()->SetRangeUser(0., ymax);
  truth->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
  truth->GetYaxis()->SetTitle("events");
  truth->GetYaxis()->SetTitleOffset(1.1);
  truth->GetXaxis()->SetTitleOffset(0.9);
  truth->GetYaxis()->SetTitleSize(0.05);
  truth->GetXaxis()->SetTitleSize(0.05);
  truth->GetYaxis()->SetNdivisions(505);

  truth->SetLineWidth(4);
  truth->SetLineColor(kRed);
  bias->SetLineWidth(4);
  bias->SetLineColor(kAzure+7);
  output->SetLineColor(kBlack);
  output->SetMarkerColor(kBlack);
  output->SetMarkerStyle(8);
  output->SetMarkerSize(1);

  truth->Draw("HIST SAME");
  bias->Draw("HIST SAME");
  output->Draw("E1 SAME");
  TLegend *l=new TLegend(0.55,0.6,0.85,0.85);
  l->SetBorderSize(0);
  l->SetFillStyle(0);
  l->AddEntry(output,"unfolded result","pl");
  l->AddEntry(truth,"truth","pl");
  l->AddEntry(bias,"bias distribution","pl");
  l->SetTextSize(0.04);
  l->Draw();
  gPad->RedrawAxis();
  c->SaveAs(directory + file_name + ".pdf");
  delete c;
}
Esempio n. 7
0
void SAS_RaTPlot(TTree *t1, TTree *t2, TCut flow, TString point, TString set){
gROOT->SetStyle("Plain");
  gStyle->SetOptStat(0);
  SetStyle();



  TH1D *s = RaT(t1,kRed,flow,point,"S",set);
  TH1D *as = RaT(t2,kBlack,flow,point,"AS",set);

TCanvas *c7 = new TCanvas ("SAS"+point+set,"SAS"+point+set);
 TLegend *leg = new TLegend(0.7,0.7,0.99,0.99);
 leg->AddEntry(s,"Selected","LP");
 leg->AddEntry(as,"Anti-Selected","LP");
 s->Draw("E");
 gPad->SetGridx(); gPad->SetGridy();
 as->Draw("ESAME");
 s->SetTitle();
 s->GetXaxis()->SetTitle("|#eta | leading jet");
 s->GetYaxis()->SetTitle("N(above aT"+s_aT+") / N(all)");
 s->GetYaxis()->SetTitleOffset(1.2);
 leg->Draw("SAME");
 c7->Update();
 c7->SaveAs(plotting+"ELEC_RaT_"+set+"_"+point+".png");

}
Esempio n. 8
0
void RunTest(const char* name, int numentries, int BufferSize) {
   char title[200];
   sprintf(title, "%d events, 10 branches, 10 floats in brunch, Basket size = %d", numentries, BufferSize*sizeof(Float_t)*10);

   TH1D* histoRes = new TH1D(name, title, 10, 0.5, 10.5);
   histoRes->GetXaxis()->SetTitle("Number of active branches");
   histoRes->GetYaxis()->SetTitle("Real time (s)");
   histoRes->SetDirectory(0);
   histoRes->SetStats(kFALSE);
   ProduceTree("TreeFile.root","TestTree", numentries, 0, 10, 10, BufferSize);

   Float_t RealTime, CpuTime;
    
   for(int ActiveBranches=1;ActiveBranches<=10;ActiveBranches++) {
      ReadDummyTree();
      cout << "Buffer size = " << BufferSize*sizeof(Float_t)*10 << " ActiveBranches = " << ActiveBranches << endl;
      MakeDelay(10);
      TestTree("TreeFile.root","TestTree", 10, 10, ActiveBranches, &RealTime, &CpuTime);
      histoRes->SetBinContent(ActiveBranches, RealTime);
   } 
   
   TCanvas* c1 = new TCanvas(TString(name)+"_canvas", title);
   histoRes->Draw();
   c1->SaveAs(TString(name)+".gif");
}
Esempio n. 9
0
TH1D* getSimplePlot(TString INPUTDIR_PREFIX, TString SCENARIO, TString dataMC, TString vartype, TString SCEN_TRIG, TString RR) {

   TString DENOM = "_Glb_pass_&_Tight2012_pass"; //"_&_Glb_pass_&_Tight2012_pass";
   if (SCENARIO == "Glb_Tight2012") DENOM = "";
   else if (SCENARIO == "Glb_Tight2012_IsolPFRelCombNoEGammaR03PU_"+SCEN_TRIG) DENOM = "_Glb_pass_&_IsolPFRelCombNoEGammaR03PU_pass_&_Tight2012_pass";
   else if (SCENARIO == "Glb_Tight2012_IsolPFRelCombNoEGammaR03_"+SCEN_TRIG) DENOM = "_Glb_pass_&_IsolPFRelCombNoEGammaR03_pass_&_Tight2012_pass";

   TString POSTFIX = "";
   if (vartype == "vtx") POSTFIX = ""; //"_vtx";
   else if (vartype == "run") POSTFIX = ""; //"_rrr";
   else if (vartype == "rrr2") POSTFIX = "_rrr2";
   else if (vartype == "rrr3") POSTFIX = "_rrr3";

   if (dataMC == "datalike_mc") {
     RR = "";
   } else {
     RR = "_"+RR;
   }
   TFile *thisf = new TFile(INPUTDIR_PREFIX+"TnP_2011_MuonID_item_"+dataMC+"_"+SCENARIO+POSTFIX+"_"+vartype+RR+".root");
   cout << "HERE " << INPUTDIR_PREFIX+"TnP_2011_MuonID_item_"+dataMC+"_"+SCENARIO+POSTFIX+"_"+vartype+RR+".root" << endl;
   thisf->cd();
   gDirectory->cd("tpTree/"+SCENARIO+"_"+vartype+"/fit_eff_plots");
   cout << "tpTree/"+SCENARIO+"_"+vartype+"/fit_eff_plots" << endl;

   TCanvas* c = (TCanvas*)gDirectory->Get(getFolder(vartype)+DENOM);
   cout << getFolder(vartype)+DENOM << endl;
   c->GetListOfPrimitives();
   RooHist* hpt = (RooHist*)c->GetPrimitive("hxy_fit_eff");

   TH1D* test = rooHist_to_TH1D(hpt,vartype,SCENARIO);
   for (int ibin = 0; ibin < test->GetXaxis()->GetNbins();ibin++) {
       cout << "AFTER " << test->GetBinContent(ibin+1) << endl;
    }
   return rooHist_to_TH1D(hpt,vartype,SCENARIO);
}
Esempio n. 10
0
void RunTest(const char* name, const char* uselesstitle, int numentries, int BufferSize) {
   TString title;
   title += numentries;
   title.Append(" events, 10 branches, 10 floats in brunch, Basket size = ");
   title += ( BufferSize*10*10*4 );
   TH1D* histoRes = new TH1D(name, title, 10, 0.5, 10.5);
   histoRes->GetXaxis()->SetTitle("Number of active branches");
   histoRes->GetYaxis()->SetTitle("Real time (s)");
   histoRes->SetDirectory(0);
   histoRes->SetStats(kFALSE);
   ProduceTree("TreeFile.root","TestTree", numentries, 0, 10, 10, BufferSize);

   Float_t RealTime, CpuTime;
    
   for(int ActiveBranches=1;ActiveBranches<=10;ActiveBranches++) {
      PurgeMemory();  
      cout << "Buffer size = " << BufferSize*sizeof(Float_t)*10 << " ActiveBranches = " << ActiveBranches << endl;
      MakeDelay(5);
      TestTree("TreeFile.root","TestTree", 10, 10, ActiveBranches, RealTime, CpuTime);
      histoRes->SetBinContent(ActiveBranches, RealTime);
   } 
    
   TCanvas* c1 = new TCanvas(TString(name)+"_canvas",title);
   histoRes->Draw();
   c1->SaveAs(TString(name)+".gif");
}
Esempio n. 11
0
void tofQAMaker( string file, int xRange = 10 ){

	TFile * f = new TFile( file.c_str(), "READ" );


	TH1D * tpc = (TH1D*)f->Get( "zvertex" );
	TH1D * vpd = (TH1D*)f->Get( "zvertexVPD" );
	TH1D * delta = (TH1D*)f->Get( "zvertexDelta" );

	Reporter rp( "vertexQA.pdf" );

	TF1* gaus = new TF1( "g", "gaus" );
	gaus->SetRange( -xRange, xRange );

	rp.newPage();
	tpc->Draw();
	rp.savePage();
	rp.newPage();
	vpd->Draw();
	rp.savePage();
	rp.newPage();
	delta->GetXaxis()->SetRangeUser( -25, 25 );
	gStyle->SetOptFit( 111 );
	delta->Draw();
	delta->Fit( gaus, "R" );
	rp.savePage();

}
Esempio n. 12
0
// ----------------------------------------------------------------------
void plotRatio(string era = "2016BF") {
  gStyle->SetOptStat(0);

  if (era == "all") {
    plotRatio("2011");
    plotRatio("2012");
    plotRatio("2016BF");
    plotRatio("2016GH");
    return;
  }


  TH1D *hresult = new TH1D("hresult", Form("n(gauss(5.28))/n(gauss(5.37)) %s", era.c_str()), 40, 0., 0.4);
  hresult->GetXaxis()->SetTitle("BDT > ");
  TH1D *hbdtcut = new TH1D("hbdtcut", Form("n(gauss(5.28))/n(gauss(5.37)) %s", era.c_str()), 40, 0., 0.4);
  hbdtcut->SetMarkerColor(kBlue);
  invertedMuonID(era, 0.15, hresult);
  invertedMuonID(era, 0.20, hresult);
  invertedMuonID(era, 0.25, hresult);
  invertedMuonID(era, 0.30, hresult);
  invertedMuonID(era, -99., hbdtcut);

  c0->Clear();
  double ymax(50.);
  if (hresult->GetMaximum() < 5.)  ymax = 10.;
  if (hresult->GetMaximum() < 0.5) ymax = 1.0;
  hresult->SetMinimum(-ymax);
  hresult->SetMaximum(ymax);
  hresult->Draw();
  hbdtcut->Draw("same");
  pl->DrawLine(0., 0., 0.4, 0.);
  c0->SaveAs(Form("invertedMuonID-%s-result.pdf", era.c_str()));
}
Esempio n. 13
0
TH1* processFile(TString fname, double scaleFactor){

  static int hcounter=0;

  cout<<"Doing fname="<<fname<<endl;
  TFile *_file2 = TFile::Open(fname);
  PS->cd();
  TString plot =  "lLV[0].lpfIso:lLV[0].fP.Eta()";
  TString hname = Form("h%i",hcounter);
  jets2p->Draw(plot +" >> " + hname+"(24,-3,3,100,0,2)","","qn");
  TH2D *aux = (TH2D*)gDirectory->Get(hname);
  //aux->Scale(scaleFactor);
  TH1D * ss = aux->ProjectionX(hname+"ss",1,10); // signal region 
  TH1D * ni = aux->ProjectionX(hname+"ni",16,100);// nonIso region (use 11
  //cout<<"h="<<hcounter<<" ss="<<ss->GetEntries()<<" ni="<<ni->GetEntries()<<endl;

  TString statis = Form("( %i / %i )",(int)ss->GetEntries(),(int)ni->GetEntries());
  ss->Divide(ni);
  ss->GetYaxis()->SetTitle(TString("N_{signal}/N_{nonIso}")+statis);
  ss->GetXaxis()->SetTitle("#eta");
  
  hcounter++;

  return ss;

}
Esempio n. 14
0
// Merge same modes
int dmMerge(TObject *a1, TObject *b1,TList *keys)
{
	TDecayMode *a=(TDecayMode*)a1;
	TDecayMode *b=(TDecayMode*)b1;
	TIter  nexthist(keys);
	TKey  *key_hist=0;
	while(key_hist=(TKey*)nexthist())
	{
		int cycle=-10;
		if(strcmp(key_hist->GetClassName(),"TH1D")==0)
		{
			TH1D  *h=0;
			int cycleh=key_hist->GetCycle();
			if(cycleh<cycle) { cout<<"Skipping..."<<endl; continue; }
			if(cycle<cycleh) cycle=cycleh;
			h=(TH1D*)key_hist->ReadObj();
			if(!h)
			{
				cout<<"Cannot read: "<<key_hist->GetName()<<endl;
				exit(-2);
			}
			TH1D *eh = (TH1D*) a->histograms->FindObject(h->GetName());
			if(!eh) continue;
			if(eh->GetNbinsX()!=h->GetNbinsX() ||
			   eh->GetXaxis()->GetXmax()!=h->GetXaxis()->GetXmax())
			   return -1;
			eh->Add(h);
		}
	}
        a->SetNEntries(a->GetNEntries()+b->GetNEntries());
        a->SetSumw(a->GetSumw()+b->GetSumw());
        a->SetSumw2(a->GetSumw2()+b->GetSumw2());
	return 0;
}
Esempio n. 15
0
// ----------------------------------------------------------------------
void plotRatio2Comb(string era = "2016BF") {
  gStyle->SetOptStat(0);

  if (era == "all") {
    plotRatio2Comb("2011");
    plotRatio2Comb("2012");
    plotRatio2Comb("2016BF");
    plotRatio2Comb("2016GH");
    return;
  }

  double eps(0.00001);
  TH1D *hresultBd = new TH1D("hresultBd", era.c_str(), 80, 0., 0.4);
  TH1D *hresultBs = new TH1D("hresultBs", era.c_str(), 80, 0.+eps, 0.4+eps);
  hresultBd->GetYaxis()->SetTitle("a.u.");
  hresultBd->GetXaxis()->SetTitle("BDT > "); hresultBd->SetMarkerStyle(24); hresultBd->SetLineColor(kRed+2); hresultBd->SetMarkerColor(kRed+2);
  hresultBs->GetXaxis()->SetTitle("BDT > "); hresultBs->SetMarkerStyle(25); hresultBs->SetLineColor(kBlue);  hresultBs->SetMarkerColor(kBlue);
  TH1D *hbdtcutBd = new TH1D("hbdtcutbd", "", 80, 0., 0.4);
  TH1D *hbdtcutBs = new TH1D("hbdtcutBs", "", 80, 0.+eps, 0.4+eps);
  hbdtcutBs->SetMarkerColor(kBlue);  hbdtcutBd->SetMarkerStyle(24); hbdtcutBs->SetLineColor(kBlue);
  hbdtcutBd->SetMarkerColor(kRed+2); hbdtcutBd->SetMarkerStyle(25); hbdtcutBd->SetLineColor(kRed+2);

  invertedMuonID2Comb(era, 0.15, hresultBd, hresultBs);
  invertedMuonID2Comb(era, 0.20, hresultBd, hresultBs);
  invertedMuonID2Comb(era, 0.25, hresultBd, hresultBs);
  invertedMuonID2Comb(era, 0.30, hresultBd, hresultBs);
  invertedMuonID2Comb(era, -99., hbdtcutBd, hbdtcutBs);

  c0->Clear();
  double ymax(5.);
  hresultBd->SetMinimum(-ymax);
  hresultBd->SetMaximum(ymax);
  hresultBd->Draw();
  hbdtcutBd->Draw("same");
  pl->DrawLine(0., 0., 0.4, 0.);

  tl->SetTextSize(0.035);
  tl->SetTextColor(kRed+2); tl->DrawLatexNDC(0.2, 0.85, "n(gauss(5.28))/combinatorial");
  tl->SetTextColor(kBlue);  tl->DrawLatexNDC(0.2, 0.81, "n(gauss(5.37))/combinatorial");
  tl->SetTextColor(kBlack);

  hresultBs->Draw("same");
  hbdtcutBs->Draw("same");

  c0->SaveAs(Form("invertedMuonID2Comb-%s-result.pdf", era.c_str()));

}
Esempio n. 16
0
void loglikdistrib(Int_t ntrials = 10000, Bool_t print = kFALSE)
{
  // compute distribution of log likelihood value
  TH1D * hmc   = gStack[gPadNr][gOrder[gPadNr][0]];
  TH1D * hdata = gStack[gPadNr][gMaxProcess-1];
  Int_t nbins = hmc->GetNbinsX();
  Double_t loglik = loglikelihood(hmc, hdata, 1, nbins);
  TH1D * htest = new TH1D(*hdata);
  TH1D * lldistrib = new TH1D("lldistrib", "log(Likelihood) distribution", 
			      1000, loglik-200, loglik+200);
  setopt(lldistrib);
  for (Int_t n = 0; n < ntrials; n++) {
    // generate poisson around theorie
    for (Int_t i = 1; i <= nbins; i++) {
      htest->SetBinContent(i, gRandom->Poisson(hmc->GetBinContent(i)));
    }
    lldistrib->Fill(loglikelihood(hmc, htest, 1, nbins));
  }
  TCanvas * llcanvas = new TCanvas("llcanvas", "Log(Likelihood) distribution", 
				   40, 40, 800, 600);
  setopt(llcanvas);
  lldistrib->SetFillColor(kYellow);
  lldistrib->Draw();
  lldistrib->GetYaxis()->SetTitle("Anzahl Ereignisse");
  lldistrib->GetXaxis()->SetTitle("-ln L");
  // autozoom
  Int_t lowbin = 1;
  while (lldistrib->GetBinContent(lowbin) == 0)
    lowbin++;
  Int_t highbin = lldistrib->GetNbinsX();
  while (lldistrib->GetBinContent(highbin) == 0)
    highbin--;
  lldistrib->SetAxisRange(lldistrib->GetBinLowEdge(lowbin), 
			  lldistrib->GetBinLowEdge(highbin));
  TH1D * hworse = (TH1D *) lldistrib->Clone();
  for (Int_t nbin = 1; nbin < 501; nbin++) {
    hworse->SetBinContent(nbin, 0);
  }
  hworse->SetFillColor(95);
  hworse->Draw("same");
  Double_t pvalue = lldistrib->Integral(501,1000) / lldistrib->Integral();
  TLatex * tex = new TLatex(0.18, 0.96, Form("-ln L_{obs} = %5.2f", loglik));
  tex->SetNDC();
  tex->SetTextAlign(13);
  tex->Draw();
  tex = new TLatex(0.18, 0.86, Form("CL_{obs} = %.3f", pvalue));
  tex->SetNDC();
  tex->SetTextAlign(13);
  tex->Draw();
  TLine * l = new TLine(loglik, 0, loglik, lldistrib->GetMaximum());
  l->SetLineWidth(3);
  l->SetLineColor(kBlue);
  l->Draw();
  llcanvas->Modified();
  llcanvas->Update();
  if (print)
    llcanvas->Print("lldistrib.pdf");
  cd(gPadNr+1);
}
Esempio n. 17
0
// Convert plots to paper format - no title, bigger fonts etc
void combineHists( TFile* fSig, TFile* fBg, TFile* fBg2, std::string histName, std::string plotOpt, std::string outputName, std::vector<double> scalingFactors, std::string label, std::string yTitle="DEFAULT"){
    TH1::SetDefaultSumw2();

    // for 3 hists - sig and 2 bg
    TCanvas c1;
    TH1D* hSig = fSig->Get(histName.c_str());
    hSig->SetLineColor(kRed);
    hSig->SetMarkerSize(0);
    doSignalHist(hSig);
    
    // Make combined BG hist
    // Need to rescale carefully
    std::vector<TFile*> files;
    files.push_back(fBg);
    files.push_back(fBg2);
    // TH1D* hBg = combine(files, histName, scalingFactors);
    TH1D* hBgA = fBg->Get(histName.c_str());
    TH1D* hBgB =  fBg2->Get(histName.c_str());
    TH1D* hBg = (TH1D*) hBgA->Clone();
    double total = scalingFactors[0]+scalingFactors[1];
    hBg->Scale(scalingFactors[0]/total);
    hBg->Add(hBgB, scalingFactors[1]/total);
    hBg->SetMarkerSize(0);
    doAltBGHist(hBg);
    
    THStack st("h","");
    st.Add(hSig);
    st.Add(hBg);
    st.Draw((plotOpt+"NOSTACK").c_str());
    st.GetXaxis()->SetTitle(hSig->GetXaxis()->GetTitle());
    if (yTitle == "DEFAULT") {
        st.GetYaxis()->SetTitle(hSig->GetYaxis()->GetTitle());
    } else {
        st.GetYaxis()->SetTitle(yTitle.c_str());
    }
    setAltTitleLabelSizes(&st.GetHistogram());
    st.SetTitle("");
    st.Draw((plotOpt+"NOSTACK").c_str());

    TLegend* l_all = new TLegend(0.65,0.6,0.89,0.89);
    l_all->AddEntry(hBg,"Gen. level QCD MC","lp");
    l_all->AddEntry((TObject*)0,"(b#bar{b} + q-g scatter,",""); //null pointers for blank entries
    l_all->AddEntry((TObject*)0,"q = b, #bar{b}, c, #bar{c})","");
    l_all->AddEntry(hSig, "Signal MC", "lp");
    l_all->AddEntry((TObject*)0,"m_{#phi} = 8 GeV", "");
    doStandardLegend(l_all);
    l_all->Draw();

    TPaveText t(0.15, 0.75, 0.5, 0.85, "NDC");
    t.AddText(label.c_str());
    doStandardText(&t);
    if (label != "") {
        t.Draw();
    }
    c1.SaveAs(outputName.c_str());

    if (!hSig) delete hSig;
    if (!hBg) delete hBg;
}
Esempio n. 18
0
void plotCentrality(){

  
  TFile* f4 = new TFile("histogram_test_MB_2760GeV.root");
  TH1D* cent  = f4->Get("demo/centhist");
  TCanvas* cd = new TCanvas("cd","",600,500);
  cd->SetLeftMargin(0.12);
  cd->SetRightMargin(0.02);
  cd->SetTopMargin(0.02);
  cd->SetBottomMargin(0.12);
  cd->SetTicks(1);
  cent->SetTitle("");
  cent->SetXTitle("Centrality (200 bins)");
  cent->SetYTitle("# of Events");
  cent->GetYaxis()->SetTitleOffset(1.2);
  cent->GetXaxis()->SetTitleOffset(1.2);
  cent->GetXaxis()->CenterTitle(1);
  cent->GetYaxis()->CenterTitle(1);
  cent->GetXaxis()->SetTitleSize(0.046);
  cent->GetYaxis()->SetTitleSize(0.046);
  cent->GetXaxis()->SetTitleFont(62);
  cent->GetYaxis()->SetTitleFont(62);
  cent->SetAxisRange(0,209,"Y");
  cent->SetAxisRange(0,203,"X");
  cent->SetMarkerStyle(20);
  cent->Sumw2();
  cent->SetMarkerSize(1);
  cent->SetMarkerColor(1);
  cent->SetLineColor(1);
  //cent->SetStats(0);
  cent->Draw("Pez");

    TLatex *tex1= new TLatex(55.5,125.060,"Hydjet 2.76TeV MB");
    tex1->SetTextColor(1);
    tex1->SetTextSize(0.05);
    tex1->SetTextFont(42);
    tex1->Draw();

    TLatex *tex2= new TLatex(55.5,99.054,"CMSSW_7_5_0_pre5");
    tex2->SetTextColor(1);
    tex2->SetTextSize(0.05);
    tex2->SetTextFont(42);
    //tex2->Draw();
  cd->SaveAs("centralityDist750x2760GeV.png");

}
Esempio n. 19
0
TH1D * rootstuff::newTH1D(char *name,char *comment,__int32 bins,double xmin,double xmax,char *titelx,char *option)
{
   TH1D * hist;
   hist = new TH1D(name,comment,bins,xmin,xmax);
   hist->SetOption(option);
   hist->GetXaxis()->SetTitle(titelx);
   return hist;
}
Esempio n. 20
0
// ----------------------------------------------------------------------
void plotRatioRaw(string era = "2016BF") {
  gStyle->SetOptStat(0);

  if (era == "all") {
    plotRatioRaw("2011");
    plotRatioRaw("2012");
    plotRatioRaw("2016BF");
    plotRatioRaw("2016GH");
    return;
  }


  double eps(0.00001);
  TH1D *hresult = new TH1D("hresult", Form("%s", era.c_str()), 80, 0., 0.4);
  hresult->GetXaxis()->SetTitle("BDT > ");
  hresult->SetMarkerStyle(24); hresult->SetLineColor(kRed+2); hresult->SetMarkerColor(kRed+2);
  TH1D *hsresult = new TH1D("hsresult", Form("%s", era.c_str()), 80, 0.+eps, 0.4+eps);
  hsresult->SetMarkerStyle(25); hsresult->SetLineColor(kBlue);  hsresult->SetMarkerColor(kBlue);

  TH1D *hbdtcut = new TH1D("hbdtcut", Form("%s", era.c_str()), 80, 0., 0.4);
  hbdtcut->SetMarkerColor(kRed+2);  hbdtcut->SetMarkerStyle(20);
  TH1D *hsbdtcut = new TH1D("hsbdtcut", Form("%s", era.c_str()), 80, 0.+eps, 0.4+eps);
  hsbdtcut->SetMarkerColor(kBlue);  hsbdtcut->SetMarkerStyle(21);

  invertedMuonIDRaw(era, 0.15, hresult, hsresult);
  invertedMuonIDRaw(era, 0.20, hresult, hsresult);
  invertedMuonIDRaw(era, 0.25, hresult, hsresult);
  invertedMuonIDRaw(era, 0.30, hresult, hsresult);
  invertedMuonIDRaw(era, -99., hbdtcut, hsbdtcut);

  c0->Clear();
  double ymax(50.);
  double smax = hresult->GetMaximum();
  double dmax = hsresult->GetMaximum();
  double themax = (smax>dmax? smax: dmax);
  if (themax < 50.)  ymax = 50.;
  if (themax < 20.)  ymax = 30.;
  if (themax < 5.)  ymax = 10.;
  if (themax < 0.5) ymax = 1.0;
  hresult->SetMinimum(-ymax);
  hresult->SetMaximum(ymax);
  hresult->Draw();
  hsresult->Draw("same");
  hbdtcut->Draw("same");
  hsbdtcut->Draw("same");
  pl->DrawLine(0., 0., 0.4, 0.);

  TLegend *tle = new TLegend(0.25, 0.2, 0.50, 0.5);
  tle->SetFillStyle(0);
  tle->SetBorderSize(0);
  tle->SetHeader(era.c_str());
  tle->AddEntry(hresult, "yield at B0", "p");
  tle->AddEntry(hsresult, "yield at Bs", "p");
  tle->Draw();

  c0->SaveAs(Form("invertedMuonIDRaw-%s-result.pdf", era.c_str()));
}
Esempio n. 21
0
TH1D* GetDummyHist(Float_t xmax, Float_t min, Float_t max,Char_t *xttl,Char_t *yttl) {

    TH1D *dum;
    dum = new TH1D("dum","",100,0.0,xmax);
    //dum = new TH1D("dum","",100,0.2,xmax);

    dum->SetMinimum(min);
    dum->SetMaximum(max);
    dum->SetStats(0);

    dum->GetYaxis()->SetTitle(yttl);
    dum->GetYaxis()->CenterTitle();
    dum->GetXaxis()->SetTitle(xttl);
    dum->GetXaxis()->CenterTitle();

    return dum;

}
Esempio n. 22
0
// Draw 1D histos
TH1D *plot1Dhisto(double intLumi,TFile *fileName,TString folderName,TString histoName,int color,int rebin,float xMin,float xMax,TString xName, TString yName,TString sampleName,bool mc) {  
  
  TH1D *hTemp = (TH1D*)fileName->Get(folderName+"/"+histoName);
  hTemp->SetName(histoName+"_"+sampleName);
  if (mc){ 
    hTemp->Scale(intLumi/100.);
  }
  hTemp->Rebin(rebin);
  hTemp->SetLineColor(color);
  hTemp->SetLineWidth(5);
  hTemp->GetXaxis()->SetRangeUser(xMin,xMax);
  hTemp->GetXaxis()->SetTitle(xName);
  hTemp->GetXaxis()->SetTitleSize(0.06);
  hTemp->GetXaxis()->SetLabelSize(0.06);
  hTemp->GetYaxis()->SetTitle(yName);
  hTemp->GetYaxis()->SetTitleSize(0.06);
  hTemp->GetYaxis()->SetLabelSize(0.06);
  hTemp->SetTitleOffset(1.5, "Y");
  // last/first bin: put over/underflow
  hTemp->SetBinContent(hTemp->FindBin(xMax),hTemp->Integral(hTemp->FindBin(xMax),hTemp->GetNbinsX()+1));
  hTemp->SetBinContent(hTemp->FindBin(xMin),hTemp->Integral(-1,hTemp->FindBin(xMin)));  

  hTemp->SetBinError(hTemp->FindBin(xMax),sqrt(hTemp->Integral(hTemp->FindBin(xMax),hTemp->GetNbinsX()+1)));
  hTemp->SetBinError(hTemp->FindBin(xMin),sqrt(hTemp->Integral(-1,hTemp->FindBin(xMin))));
  //fileName->Close();

  /*
  if (histoName != "LP_tot") {
    if (histoName != "SumLepPt_tot") {
      if ((folderName == "ANplots150_NOLP")) { hTemp->GetXaxis()->SetRangeUser(0.,300.); } 
      if ((folderName == "ANplots250_NOLP")) { hTemp->GetXaxis()->SetRangeUser(0.,400.); }
      if ((folderName == "ANplots350_NOLP")) { hTemp->GetXaxis()->SetRangeUser(0.,500.); }
      if ((folderName == "ANplots450_NOLP")) { hTemp->GetXaxis()->SetRangeUser(0.,1000.); }
    }
    else {
      if ((folderName == "ANplots150_NOLP")) { hTemp->GetXaxis()->SetRangeUser(100.,300.); } 
      if ((folderName == "ANplots250_NOLP")) { hTemp->GetXaxis()->SetRangeUser(200.,400.); }
      if ((folderName == "ANplots350_NOLP")) { hTemp->GetXaxis()->SetRangeUser(300.,500.); }
      if ((folderName == "ANplots450_NOLP")) { hTemp->GetXaxis()->SetRangeUser(400.,1000.); }
    }
  } 
  */ 
  return hTemp;
} // ~ end of plot1Dhisto function
Esempio n. 23
0
void dmesondecaylength()
{


    //gStyle->SetOptStat("nemruoi");
    gStyle->SetTitleSize(.04,"S");
    gStyle->SetOptTitle(1);
    gStyle->SetTitleOffset(1.0,"X");
    gStyle->SetTitleOffset(.88,"Y");
    gStyle->SetTitleSize(.04,"X");
    gStyle->SetTitleSize(.04,"Y");
    gStyle->SetLabelSize(.035,"X");
    gStyle->SetLabelSize(.035,"Y");
    gStyle->SetHistLineWidth(2);
    gStyle->SetOptFit(1);
    gStyle->SetOptStat(0);
// -----   Timer   --------------------------------------------------------
    TStopwatch timer;
    timer.Start();
    // ------------------------------------------------------------------------
    double c= 3* std::pow(10.,8.);
    double mt= 1040*std::pow(10.,-15.); // mean decay time
    double mass= 1.869; // rest mass in GeV/c^2
//TCanvas* can = new TCanvas("can","Radiation Length for start detector",0,0,100,100);
    TCanvas *c1 = new TCanvas("c1", "c1",0,52,1191,692);
    TH1D* h = new TH1D("hist","D-meson, D-meson decay length",24,0,24);
    h->SetTitle("D^{+} meson decay length = c#tau#sqrt{(#gamma_{D^{+}}^{2}-1)};Momentum (GeV/c); Decay length (mm)");
    Int_t ci;   // for color index setting
    ci = TColor::GetColor("#000099");
    for (int p=1; p<=24; p++)
    {
        double E = p*p + mass*mass;
        E= std:: sqrt(E);

        double gamma = E/mass;
        double decaylength = c* std::sqrt(gamma*gamma -1)*mt*1000;
        std:: cout<<" Decay length=" <<decaylength<<std::endl;
        h->SetLineColor(ci);
        h->GetXaxis()->CenterTitle(true);
        h->GetYaxis()->CenterTitle(true);
        h->SetMarkerColor(2);
        h->SetMarkerStyle(20);
        h->SetBinContent(p,decaylength);
        h->Draw("E2-text");
    }
// -----  Finish   -------------------------------------------------------
    timer.Stop();
    Double_t rtime = timer.RealTime();
    Double_t ctime = timer.CpuTime();
    cout << endl << endl;
    cout << "Macro finished succesfully." << endl;
    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
    cout << endl;
    // ------------------------------------------------------------------------

}
Esempio n. 24
0
//----------------------------------------//
// Make ratio plot
//----------------------------------------//
void plotRatio(TProfile* p0,
	       TProfile* p1,
	       TLegend* leg,
	       TCanvas* c,
	       string title,
	       TString append)
{

  // Make TPad object
  TPad* p_top;
  TPad* p_bot;
  makePads(c,p_top,p_bot);

  // Plot stuff on top
  c->cd();
  p_top->Draw();
  p_top->cd();
  p_top->SetLogy();
  
  // Set Some attributes
  p1->SetLabelSize(0.0,"X");
  p1->SetLabelSize(0.06, "Y");
  p1->GetYaxis()->SetTitleSize(0.06);
  p1->GetYaxis()->SetTitleOffset(0.85);

  // Draw Top
  p1->Draw();
  p0->Draw("same");
  leg->Draw("same");
  p_top->Update();

  // Get Bottom objects
  TH1D* ratio = getRatio(p0,p1,title);
  float xmax  = ratio->GetXaxis()->GetXmax();
  TLine* mid  = makeLine(0,xmax,1.0,1.0);
  TLine* u50  = makeLine(0,xmax,1.5,1.5,kBlack,2);
  TLine* d50  = makeLine(0,xmax,0.5,0.5,kBlack,2);


  // Draw bottom
  c->cd();
  p_bot->Draw();
  p_bot->cd();

  // Draw bottom objects
  ratio->Draw("ep");
  mid->Draw("same");
  u50->Draw("same");
  d50->Draw("same");
  ratio->Draw("sameep");
  p_bot->Update();


  //c->SaveAs(savedir+append+".png");

}
Esempio n. 25
0
TH1D * rootstuff::newTH1D(__int32 number,char *comment,__int32 bins,double xmin,double xmax,char *titelx,char *option)
{
   char name[200];
   TH1D * hist;
   sprintf(name,"%i",number);
   hist = new TH1D(name,comment,bins,xmin,xmax);
   hist->SetOption(option);
   hist->GetXaxis()->SetTitle(titelx);
   return hist;
}
Esempio n. 26
0
void DrawNcollNpartdis(){
        int Gth=0;
	TFile *fGlauber = TFile::Open(stdGlaulist[Gth]);
	TTree *t = (TTree*)fGlauber->Get("nt_Pb_Pb");
        Float_t Ncoll, Npart, B;	Long_t Nevent;
	t->SetBranchAddress("Ncoll",&Ncoll);
	t->SetBranchAddress("Npart",&Npart);
	t->SetBranchAddress("B",&B);
        Nevent = (Long_t) t->GetEntries();
    	Long_t Ev;	Int_t Bino;	Double_t Para, Bi_Para;
        TH1D* hNcoll = new TH1D("","",4000,0,4000);
        TH1D* hNpart = new TH1D("","",4000,0,4000);
	for (Ev=0; Ev<Nevent; Ev++){
	//if(Ev%100000==0)	cout<<"\t"<<"Have run "<<Ev<<" events"<<endl;
        	t->GetEntry(Ev);
                hNcoll->Fill(Ncoll);
                hNpart->Fill(Npart);
        }
	TString name;
        if(Gth==0)
                name = "G0";
        else if(Gth<nGlau)
                name = Form("Glau_%d",Gth);
        else
                name = Form("bin_%d",Gth-nGlau+1);
        TCanvas *c1 = new TCanvas();
        c1->SetLogy();
        hNcoll->Scale(1./hNcoll->Integral());
        hNcoll->GetXaxis()->SetRangeUser(0,3000);
        hNcoll->GetXaxis()->SetTitle("Ncoll");
        hNcoll->GetYaxis()->SetTitle("Event Fraction");
        hNcoll->Draw();
        c1->Print(Form("%s_Ncoll.png",name.Data()));
        TCanvas *c2 = new TCanvas();
        c2->SetLogy();
        hNpart->Scale(1./hNpart->Integral());
        hNpart->GetXaxis()->SetRangeUser(0,500);
        hNpart->GetXaxis()->SetTitle("Npart");
        hNpart->GetYaxis()->SetTitle("Event Fraction");
        hNpart->Draw();
        c2->Print(Form("%s_Npart.png",name.Data()));
}
Esempio n. 27
0
TH1D* GetRawSignal1D(int itrg, int jass)
{
		    TH2D* hsignal = GetRawSignal2D(itrg,jass); 
		    TH1D* hsignalphi = (TH1D*)hsignal->ProjectionY(Form("signalphi_trg%d_ass%d",itrg,jass),hsignal->GetXaxis()->FindBin(detaprojmin),hsignal->GetXaxis()->FindBin(detaprojmax),"e");
		    hsignalphi->Scale(hsignal->GetXaxis()->GetBinWidth(1));
		    hsignalphi->GetXaxis()->CenterTitle();
		    hsignalphi->GetYaxis()->CenterTitle();  
	            hsignalphi->SetYTitle("S(#Delta#phi)");	    
                    hsignalphi->SetName(Form("signalphi_scale_trg%d_ass%d",itrg,jass));      
                    return hsignalphi;
}
Esempio n. 28
0
TH1D* GetRawBackground1D(int itrg, int jass)
{
		    TH2D* hbackground = (TH2D*) GetRawBackground2D(itrg,jass);
		    TH1D* hbackphi = (TH1D*)hbackground->ProjectionY(Form("backphi_trg%d_ass%d",itrg,jass),hbackground->GetXaxis()->FindBin(detaprojmin),hbackground->GetXaxis()->FindBin(detaprojmax),"e");
		    hbackphi->Scale(hbackground->GetXaxis()->GetBinWidth(1));              
                    hbackphi->GetXaxis()->CenterTitle();
		    hbackphi->GetYaxis()->CenterTitle();
                    hbackphi->SetYTitle("B(#Delta#phi)");
                    hbackphi->SetName(Form("backphi_scale_trg%d_ass%d",itrg,jass));          
		    return hbackphi;
}
Esempio n. 29
0
TCanvas* Com(TString plot,TString plot_dir,UInt_t rbin, TString xtitle, Double_t max, TString title){
  gROOT->SetStyle("Plain");
  gStyle->SetTitleFontSize(0.07);
 TH1D *Sig = ((TH1D*)Sig->Get(plot_dir+"/"+plot))->Clone();
 TH1D *Bkgd= ((TH1D*)Bkgd->Get(plot_dir+"/"+plot))->Clone();
 Sig->Rebin(rbin);
 Bkgd->Rebin(rbin);
 Sig->Scale(1/(Sig->Integral()));
 Bkgd->Scale(1/(Bkgd->Integral()));
 //TLine *li =new TLine(0.55,0.,0.55,100000);
TCanvas* c = new TCanvas(plot_dir+plot,plot_dir+plot);
 c->SetLogy();

 TLegend *leg = new TLegend(0.5,0.8,0.99,0.99);
 leg->SetFillColor(0);
 leg->AddEntry(Sig,"Selected events","L");
 leg->AddEntry(Bkgd,"Anti-selected events","L");
 Sig->SetLineColor(kRed);
 Sig->SetLineWidth(2);
 Bkgd->SetLineColor(kBlue);
 Bkgd->SetLineWidth(2);
 Sig->Draw("EHIST");
 Bkgd->Draw("HISTSAME");
 leg->Draw("SAME");
 //      li->Draw("SAME");
 Sig->SetTitle(title);

Sig->SetStats(kFALSE);
 Sig->GetXaxis()->SetTitle(xtitle);
 if (max == 999999){

 }
 else{
   Sig->GetXaxis()->SetRangeUser(0.2,max);}
 Sig->GetYaxis()->SetTitle("");
 c->Update();
 c->SaveAs(saving+"IDinv_Delta_"+plot_dir+plot+".png");
 return c;


}
Esempio n. 30
0
void makeplot(const char *name, TTree *tree, TCut weight, const char *drawstring, const char *xlabel, int nbins, double xlow, double xhigh) {
  
  //this is for NLO with FXFX merging
//    TCut mult0 = "LHEEvent.npNLO()==0";
//    TCut mult1 = "LHEEvent.npNLO()==1";
//    TCut mult2 = "LHEEvent.npNLO()==2";
//    TCut mult3 = "LHEEvent.npNLO()==3";
  
  //this is for LO with MLM
   TCut mult0 = "GenEvent.nMEPartons()==0";
   TCut mult1 = "GenEvent.nMEPartons()==1";
   TCut mult2 = "GenEvent.nMEPartons()==2";
   TCut mult3 = "GenEvent.nMEPartons()==3";

  //this is for LO with MLM (plotting partons after excluding non-matched partons in wbb/vbf type processes)
  //   TCut mult0 = "GenEvent.nMEPartonsFiltered()==0";
  //   TCut mult1 = "GenEvent.nMEPartonsFiltered()==1";
  //   TCut mult2 = "GenEvent.nMEPartonsFiltered()==2";
  
  TH1D *hall = new TH1D(TString::Format("hall_%s",name),"",nbins,xlow,xhigh);
  TH1D *hmult0 = new TH1D(TString::Format("hmult0_%s",name),"",nbins,xlow,xhigh);
  TH1D *hmult1 = new TH1D(TString::Format("hmult1_%s",name),"",nbins,xlow,xhigh);
  TH1D *hmult2 = new TH1D(TString::Format("hmult2_%s",name),"",nbins,xlow,xhigh);
  TH1D *hmult3 = new TH1D(TString::Format("hmult3_%s",name),"",nbins,xlow,xhigh);
  
  hmult0->SetLineColor(kBlue);
  hmult1->SetLineColor(kRed);
  hmult2->SetLineColor(kMagenta);
  hmult3->SetLineColor(kGreen+1);
  
  tree->Draw(TString::Format("%s>>%s",drawstring,hall->GetName()),weight,"goff");
  tree->Draw(TString::Format("%s>>%s",drawstring,hmult0->GetName()),weight*mult0,"goff");
  tree->Draw(TString::Format("%s>>%s",drawstring,hmult1->GetName()),weight*mult1,"goff");
  tree->Draw(TString::Format("%s>>%s",drawstring,hmult2->GetName()),weight*mult2,"goff");
  tree->Draw(TString::Format("%s>>%s",drawstring,hmult3->GetName()),weight*mult3,"goff");
  
  hall->GetXaxis()->SetTitle(xlabel);
  
  TCanvas* c = new TCanvas(name,name);
  c->cd();
  hall->SetLineWidth(2);
  hall->Draw("EHIST");
  hmult0->SetLineWidth(2);
  hmult0->Draw("EHISTSAME");
  hmult1->SetLineWidth(2);
  hmult1->Draw("EHISTSAME");
  hmult2->SetLineWidth(2);
  hmult2->Draw("EHISTSAME");
  hmult3->SetLineWidth(2);
  hmult3->Draw("EHISTSAME");
  c->SetLogy();
  c->SaveAs(TString::Format("%s.pdf",name));
}