コード例 #1
0
ファイル: Background_order.C プロジェクト: Y--/root
void Background_order() {
   Int_t i;
   const Int_t nbins = 4096;
   Double_t xmin     = 0;
   Double_t xmax     = 4096;
   Double_t source[nbins];
   gROOT->ForceStyle();

   TH1F *d1 = new TH1F("d1","",nbins,xmin,xmax);
   TH1F *d2 = new TH1F("d2","",nbins,xmin,xmax);
   TH1F *d3 = new TH1F("d3","",nbins,xmin,xmax);
   TH1F *d4 = new TH1F("d4","",nbins,xmin,xmax);

   TString dir  = gROOT->GetTutorialsDir();
   TString file = dir+"/spectrum/TSpectrum.root";
   TFile *f     = new TFile(file.Data());
   TH1F *back = (TH1F*) f->Get("back2");
   back->SetTitle("Influence of clipping filter difference order on the estimated background");
   back->SetAxisRange(1220,1460);
   back->SetMaximum(3000);
   back->Draw("L");

   TSpectrum *s = new TSpectrum();

   for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
   s->Background(source,nbins,40,TSpectrum::kBackDecreasingWindow,
                 TSpectrum::kBackOrder2,kFALSE,
                 TSpectrum::kBackSmoothing3,kFALSE);
   for (i = 0; i < nbins; i++) d1->SetBinContent(i + 1,source[i]);
   d1->SetLineColor(kRed);
   d1->Draw("SAME L");

   for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
   s->Background(source,nbins,40,TSpectrum::kBackDecreasingWindow,
                 TSpectrum::kBackOrder4,kFALSE,
                 TSpectrum::kBackSmoothing3,kFALSE);
   for (i = 0; i < nbins; i++) d2->SetBinContent(i + 1,source[i]);
   d2->SetLineColor(kBlue);
   d2->Draw("SAME L");

   for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
   s->Background(source,nbins,40,TSpectrum::kBackDecreasingWindow,
                 TSpectrum::kBackOrder6,kFALSE,
                 TSpectrum::kBackSmoothing3,kFALSE);
   for (i = 0; i < nbins; i++) d3->SetBinContent(i + 1,source[i]);
   d3->SetLineColor(kGreen);
   d3->Draw("SAME L");

   for (i = 0; i < nbins; i++) source[i]=back->GetBinContent(i + 1);
   s->Background(source,nbins,40,TSpectrum::kBackDecreasingWindow,
                 TSpectrum::kBackOrder8,kFALSE,
                 TSpectrum::kBackSmoothing3,kFALSE);
   for (i = 0; i < nbins; i++) d4->SetBinContent(i + 1,source[i]);
   d4->SetLineColor(kMagenta);
   d4->Draw("SAME L");
}
コード例 #2
0
void setPlottingStyle(TH1F& hsig){
  
  hsig.SetStats(kFALSE);
  
  hsig.SetAxisRange(80,750,"Y");
  hsig.SetAxisRange(0,520,"X");
  hsig.SetAxisRange(200,520,"X");

  hsig.GetXaxis()->SetTitle("m_{0} (GeV)");
  hsig.GetYaxis()->SetTitle("m_{1/2} (GeV)");
  hsig.GetYaxis()->SetTitleOffset(0.8);
  hsig.GetYaxis()->SetTitleSize(0.06);
  hsig.GetYaxis()->SetLabelSize(0.06);
  hsig.GetXaxis()->SetTitleOffset(0.9);
  hsig.GetXaxis()->SetTitleSize(0.06);
  hsig.GetXaxis()->SetLabelSize(0.06);

  hsig.SetLineWidth(1);  
  hsig.SetLineColor(kBlue);  
  
}
コード例 #3
0
void trackingStudyAroundJet(char *infname = "skim_jet_ptha120.root")
{
   HiForest *c = new HiForest(infname);
   c->tree->AddFriend("nt");

   TCut trackSelection = "(mtrkQual||mtrkAlgo<4)&&pNRec>0";
   TCut dijetSelection = "leadingJetPt>120&&subleadingJetPt>50&&acos(cos(leadingJetPhi-subleadingJetPhi))>7./8.*3.141593";
   TCut genParticleCut = "abs(pEta)<2.4";
   
   TCanvas *cleadingJetPt = new TCanvas ("cleadingJetPt","",600,600);
   
   TH1F *hEffleadingJetPt = new TH1F("hEffleadingJetPt","",10,0,0.3);
   
   makeHistTitle(hEffleadingJetPt,"","Leading Jet p_{T} (GeV/c)","Tracking Efficiency");
   
   TGraphAsymmErrors *g = getEfficiency(c->tree,"acos(cos(pPhi-leadingJetPhi))",10,0,0.3,trackSelection,TCut("pPt>20")&&dijetSelection&&genParticleCut);
   TGraphAsymmErrors *g2 = getEfficiency(c->tree,"acos(cos(pPhi-leadingJetPhi))",10,0,0.3,trackSelection,TCut("pPt>8")&&dijetSelection&&genParticleCut);
   TGraphAsymmErrors *g3 = getEfficiency(c->tree,"acos(cos(pPhi-leadingJetPhi))",10,0,0.3,trackSelection,TCut("pPt>0")&&dijetSelection&&genParticleCut);

   hEffleadingJetPt->SetAxisRange(0.6,0.9,"Y");
   hEffleadingJetPt->Draw();
   
   g->Draw("p same");
   g2->SetLineColor(2);
   g2->SetMarkerColor(2);
   g2->Draw("p same");
   
   g3->SetLineColor(4);
   g3->SetMarkerColor(4);
   g3->Draw("p same");

   TLegend *legleadingJetPt = myLegend(0.5,0.7,0.9,0.9);
   legleadingJetPt->AddEntry(g,"#hat{p}_{T} 170 GeV/c, Dijet selection","");
   legleadingJetPt->AddEntry(g,"simTrack p_{T} > 20 GeV/c","pl");
   legleadingJetPt->AddEntry(g2,"simTrack p_{T} > 8 GeV/c","pl");
   legleadingJetPt->AddEntry(g3,"simTrack p_{T} > 0 GeV/c","pl");
   
   legleadingJetPt->Draw();
   cleadingJetPt->SaveAs("effFig/EffVsleadingJetDphi-DijetSelection.gif");
   cleadingJetPt->SaveAs("effFig/EffVsleadingJetDphi-DijetSelection.C");

   
}
コード例 #4
0
void plotInclusiveMass(  FileList fileList  , float Lumi_ = 30) {

  for(int i = 0; i<fileList.size(); i++){
    (fileList[i].first)->Close();
    delete (fileList[i].first);
  }

  TFile* fVBF115 = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_VBFH115.root","READ");
  TFile* fVBF135 = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_VBFH135.root","READ");
  TFile* fDYJets = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_DYJets-madgraph-50-PU.root","READ");
  TFile* fTT     = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_TT-madgraph-PU.root","READ");
  TFile* fWJets  = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_WJets-madgraph-PU.root","READ");
  TFile* fT      = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_TToBLNu-tW-madhraph-PU.root","READ");
  TFile* fQCD    = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_QCD-pythia-PU.root","READ");

  FileList fileList_;
  fileList_.push_back( make_pair(fT,      make_pair("tW",        10.6      )  ));
  fileList_.push_back( make_pair(fQCD,    make_pair("QCD",   349988.0      )  ));
  fileList_.push_back( make_pair(fWJets,  make_pair("Wjets",  31314.0      )  ));
  fileList_.push_back( make_pair(fTT,     make_pair("ttbar",    157.5      )  ));
  fileList_.push_back( make_pair(fDYJets, make_pair("Zjets",   3048.0      )  ));
  fileList_.push_back( make_pair(fVBF115, make_pair("qqH115",       0.1012 )  ));
  fileList_.push_back( make_pair(fVBF135, make_pair("qqH135",       0.05049)  ));
 

  TCanvas *c1 = new TCanvas("c1InclusiveMass","",5,30,650,600);
  c1->SetGrid(0,0);
  c1->SetFillStyle(4000);
  c1->SetFillColor(10);
  c1->SetTicky();
  c1->SetObjectStat(0);
  c1->SetLogy(1);


  TPad* pad1 = new TPad("pad1InclusiveMass","",0.05,0.27,0.96,0.97);
  TPad* pad2 = new TPad("pad2InclusiveMass","",0.05,0.02,0.96,0.26);
  pad1->SetFillColor(0);
  pad2->SetFillColor(0);
  pad1->Draw();
  pad2->Draw();

  pad1->cd();
  pad1->SetLogy(1);

  TLegend* leg = new TLegend(0.60,0.47,0.90,0.85,NULL,"brNDC");
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(0.04);
  leg->SetHeader( "#mu+#tau Inclusive" );
  
  THStack* aStack = new THStack("aStack",Form("CMS Preliminary 2010    #sqrt{s}=7 TeV L=%.0f pb^{-1}",Lumi_));
  TH1F* hqqH115 = new TH1F();
  TH1F* hqqH135 = new TH1F();
  TH1F* hSiml   = new TH1F();

  float signalScale = 1;

  for(unsigned int i = 0 ; i < fileList_.size() ; i++){

    TFile* currentFile = (TFile*)fileList_[i].first ;
    if( currentFile->IsZombie() ) continue;
    TH1F* allEvents = (TH1F*)currentFile->Get("allEventsFilter/totalEvents");
    float totalEvents = allEvents->GetBinContent(1);

    TTree* currentTree = (TTree*)currentFile->Get("muTauStreamAnalyzer/tree");
    string h1Name = "h1_"+(fileList_[i].second).first;
    TH1F* h1 = new TH1F( h1Name.c_str() ,"", 28 , 20, 300);

    if( ((fileList_[i].second).first).find("Zjets")!=string::npos ) {
      h1->SetFillColor(kRed);
      leg->AddEntry(h1,"MadGraph Z+jets","F");
    }
    if( ((fileList_[i].second).first).find("ttbar")!=string::npos ) {
      h1->SetFillColor(kBlue);
      leg->AddEntry(h1,"MadGraph t#bar{t}+jets","F");
    }
    if( ((fileList_[i].second).first).find("Wjets")!=string::npos ) {
      h1->SetFillColor(kGreen);
      leg->AddEntry(h1,"MadGraph W+jets","F");
    }
    if( ((fileList_[i].second).first).find("tW")!=string::npos ){
      h1->SetFillColor( 44 );
      leg->AddEntry(h1,"MadGraph single-top","F");
    }
    if( ((fileList_[i].second).first).find("QCD")!=string::npos ) {
      h1->SetFillColor(11);
      leg->AddEntry(h1,"Pythia QCD","F");
    }
    if( ((fileList_[i].second).first).find("qqH115")!=string::npos ) {
      h1->SetLineColor(kBlack);
      h1->SetLineStyle(kDashed);
      h1->SetLineWidth(3.0);
      leg->AddEntry(h1,"VBF H(115)#rightarrow#tau#tau X 100","l");
      signalScale = 100;
    }
    if( ((fileList_[i].second).first).find("qqH135")!=string::npos ) {
      h1->SetLineColor(kBlack);
      h1->SetLineStyle(kDotted);
      h1->SetLineWidth(3.0);
      leg->AddEntry(h1,"VBF H(135)#rightarrow#tau#tau X 100","l");
      signalScale = 100;
    }

    int nEntries = currentTree->GetEntries() ;
    
    std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >* diTauSVfit3;
    currentTree->SetBranchAddress("diTauSVfit3P4",&diTauSVfit3);

    for (int n = 0; n < nEntries ; n++) {
      currentTree->GetEntry(n);
      if( diTauSVfit3->size() < 1) continue;
      h1->Fill( (*diTauSVfit3)[0].M() ) ;
    }

    h1->Scale( Lumi_ / (totalEvents/((fileList_[i].second).second * signalScale)) );

    if(((fileList_[i].second).first).find("qqH115")!=string::npos){
      hqqH115=(TH1F*)h1->Clone("hqqH115");
      hqqH115 = h1;
      hqqH115->Sumw2();
      continue;
    }
    if(((fileList_[i].second).first).find("qqH135")!=string::npos){
      hqqH135=(TH1F*)h1->Clone("hqqH135");
      hqqH135 = h1;
      hqqH135->Sumw2();
      continue;
    }

    if(i==0) hSiml=(TH1F*)h1->Clone("hSiml");
    else hSiml->Add(h1);

    aStack->Add(h1);

  }

  //float numData = hData->GetEntries();
  //float numSiml = hSiml->Integral();
  //float dataToSimlRatio = numData/numSiml;
  //cout << "data " << numData << "  ---  simul " << numSiml << endl;  

  aStack->Draw("HIST");
  hqqH115->Draw("HISTSAME");
  hqqH135->Draw("HISTSAME");
  TH1F* hStack = (TH1F*)aStack->GetHistogram();
  hStack->SetXTitle("SVfit #tau#tau mass");
  hStack->SetYTitle(Form("Number of events/%.0f GeV",hStack->GetBinWidth(1)));
  hStack->SetTitleSize(0.05,"X");
  hStack->SetTitleSize(0.05,"Y");
  hStack->SetTitleOffset(0.75,"Y");
  leg->Draw();

  pad2->cd();
  TH1F* hRatio = new TH1F("hRatio", " ; ; purity",
			  hStack->GetNbinsX(), 
			  hStack->GetXaxis()->GetXmin(), hStack->GetXaxis()->GetXmax());
  hRatio->SetLineStyle(kDashed);
  hRatio->SetLineWidth(1.0);
  hRatio->SetLabelSize(0.12,"X");
  hRatio->SetLabelSize(0.10,"Y");
  hRatio->SetTitleSize(0.12,"Y");
  hRatio->SetTitleOffset(0.36,"Y");
  TH1F* hqqH115Clone = (TH1F*)hqqH115->Clone("hqqH115Clone");
  TH1F* hqqH135Clone = (TH1F*)hqqH135->Clone("hqqH135Clone");
  hqqH115Clone->Divide( hqqH115 ,hSiml,1./signalScale,1.0);
  hqqH135Clone->Divide( hqqH135 ,hSiml,1./signalScale,1.0);
  hRatio->SetAxisRange(0.,0.001,"Y");

  hRatio->Draw();
  hqqH115Clone->Draw("HISTSAME");
  hqqH135Clone->Draw("HISTSAME");

  if(SAVE) c1->SaveAs("Zmm_InclusiveMass.png");

}
コード例 #5
0
void geugd_riordan() {
	gROOT->SetStyle("HALLA");
	TCanvas *cn = new TCanvas("cn");
	cn->Draw();
	cn->UseCurrentStyle();
	TH1F *frm = new TH1F("frm","",100,0.,12.);
	frm->GetXaxis()->SetTitle("Q^{2}  [GeV^{2}]");
	frm->GetXaxis()->CenterTitle();
	frm->GetYaxis()->SetTitle("G_{E}^{u}/G_{D}");
	frm->GetYaxis()->CenterTitle();
	frm->SetMinimum(.40);
	frm->SetMaximum(2.4);
	//frm->SetMaximum(0.3);
	frm->UseCurrentStyle();
	frm->Draw();
	frm->SetAxisRange(0.10,12.,"X");

	TF1* galster = new TF1("galster",
			"x/(4.*0.938*.938)*1.91/(1.+x/.71)^2/(1.+5.6*x/(4.*.938*.938))",
			0.,4.);
	galster->SetLineColor(kBlack);
	galster->SetLineStyle(kBlack);
	galster->SetLineWidth(2);

	TF1* gen0 = new TF1("gen0", f1dugen0, 0.,12.);
	gen0->SetLineColor(kBlack);
	gen0->SetLineStyle(kBlack);
	gen0->SetLineWidth(1);



	TF1 *genf = new TF1("genf",genff,1.,10.,1);
	genf->SetLineColor(kBlue);
	genf->SetLineStyle(1);
	genf->SetParameter(0,1.);
	// match to Madey point just below 1.5
	// genf->SetParameter(0,.0411/genf->Eval(1.45));
	//  genf->SetParameter(0,-0.558645);
	genf->SetParameter(0,-0.182645);

	TF1 *roberts_curve = new TF1("roberts",roberts_gen,0.035,12.344,1);
	roberts_curve->SetLineColor(kRed);
	roberts_curve->SetLineStyle(9);

	TF1 *ourfit = new TF1("ourfit",gen_ourfit,0.,10.,0);
	ourfit->SetLineColor(kBlue);
	ourfit->SetLineStyle(0);

	/*
	   TF1 *bbba05 = new TF1("BBBA05",gen_bbba05,0.,10.,0);
	   bbba05->SetLineColor(kGreen);
	   bbba05->SetLineStyle(3);
	   */

	//  TF1 *lomon = new TF1("Lomon",Lomon_GEn,0.,10.,0);
	// lomon->SetLineColor(7);
	// lomon->SetLineStyle(4);




	TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}");
	//TLegend *legDta = new TLegend(.3448,.6123,.6810,.9110,"","brNDC");
	TLegend *legDta = new TLegend(.6020,.4004,.9382,.9089,"","brNDC");

	TMultiGraph* wgr = mgrDta;
	TLegend *wlg = legDta;

	// the data
	legDta->SetBorderSize(0); // turn off border
	legDta->SetFillStyle(0);

	datafile_t *f = datafiles;
	TGraph* gr=0;
	TGraph* ogr=0;
	while ( f && f->filename ) {
		ogr=OneGraph(f);
		if (ogr) {
			gr = fromGEntransform(ogr);
			gr->SetLineStyle(0);
			if (f->lnpt) {
				mgrDta->Add(gr,f->lnpt);
				if( f->label[0] != 'x' )
					legDta->AddEntry(gr,f->label,f->lnpt);
			}
			mgrDta->Add(gr,"p");
			if( f->label[0] != 'x' )
				legDta->AddEntry(gr,f->label,"p");

			/*
			   else if (gr->GetMarkerStyle()>=20) {
			   mgrDta->Add(gr,"p");
			   if( f->label[0] != 'x' )
			   legDta->AddEntry(gr,f->label,"p");
			   }	
			   else {
			   mgrDta->Add(gr,"l");
			   if( f->label[0] != 'x' )
			   legDta->AddEntry(gr,f->label,"l");
			   }
			   */
		}
		f++;
	}


	mgrDta->Draw("p");
	legDta->Draw();

	TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}");
	//  TLegend *legThry = new TLegend(.546,.6208,.8822,.9195,"","brNDC");
	//	TLegend *legThry = new TLegend(.2055,.7013,.6020,.8893,"","brNDC");
	TLegend *legThry = new TLegend(.4267,.8453,.6236,.8962,"","brNDC");

	wgr = mgrThry;
	wlg = legThry;

	// the theory
	wlg->SetBorderSize(0); // turn off border
	wlg->SetFillStyle(0);

	f = theoryfiles1;
	gr=0;
	Bool_t isfill;
	while ( f && f->filename ) {
		gr=OneGraph(f);
		gr->SetLineWidth(2);
		isfill = kFALSE;
		if (gr) {
			TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
			if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
				gr = toerror_band(egr);
				gr->SetFillStyle(3000+f->style);
				gr->SetFillStyle(1);
				gr->SetFillColor(gr->GetLineColor());
				isfill = kTRUE;
			}
			if (f->lnpt) {
				wgr->Add(gr,f->lnpt);
				if( f->label[0] != 'x' )
					wlg->AddEntry(gr,f->label,f->lnpt);
			}
			else if (gr->GetMarkerStyle()>=20) {
				wgr->Add(gr,"p");
				if( f->label[0] != 'x' )
					wlg->AddEntry(gr,f->label,"p");
			}	
			else {
				if( isfill ){
					gr->SetLineStyle(0);
					wgr->Add(gr,"f");
					//				  wgr->Add( new TGraph(*egr),"l");
					if( f->label[0] != 'x' )
						wlg->AddEntry(gr,f->label,"lf");
				} else {
					wgr->Add(gr,"l");
					if( f->label[0] != 'x' )
						wlg->AddEntry(gr,f->label,"l");
				}
			}

		}
		f++;
	}


	TPaveLabel *prelim = new TPaveLabel( 0.3204, 0.1886, 0.9310, 0.4643, "PRELIMINARY", "NDC" );
	prelim->SetTextAngle(0);
	TColor *pink = new TColor(300, 1.0, 0.7, 0.7, "pink");
	prelim->SetTextColor(300);
	prelim->SetFillStyle(0);
	prelim->SetBorderSize(0);


#ifdef FAKE_SCHIAVILLA
	TGraph *schiagraph = draw_schiavilla();
	schiagraph->Draw("F");
	schiagraph = draw_schiavilla(1);
	schiagraph->Draw("C");
	legThry->AddEntry(schiagraph, "d(e,e'd) T_{20} - Schiavilla & Sick", "LF");
#endif

#ifdef PRELIMINARY
	prelim->Draw("same");
#endif

	TPaveLabel *nofsilab = new TPaveLabel( 0.4569, 0.1674, 0.7514, 0.2415, "No FSI Corrections", "NDC" );
	nofsilab->SetFillStyle(0);
	nofsilab->SetBorderSize(0);
	nofsilab->SetTextColor(kRed);

#ifdef NOFSI
	//  nofsilab->Draw("same");
#endif

#ifdef PQCD
	genf->Draw("same");
#endif
	mgrThry->Draw("c");
#ifdef GALSTER
	galster->Draw("same");
#endif
//	gen0->Draw("same");

#ifdef NEW_ROBERTS
	roberts_curve->Draw("same");
#endif
	//  ourfit->Draw("same");
	//  bbba05->Draw("same");
	//lomon->Draw("same");
	// bandi->Draw("same");
#ifdef PQCD  
	legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
#endif
#ifdef GALSTER
	legThry->AddEntry(galster,"Galster fit (1971)","l");
#endif
//	legThry->AddEntry(gen0,"G_{E}^{n} = 0","l");
#ifdef NEW_ROBERTS
	legThry->AddEntry(roberts_curve,"q(qq) Faddeev -  I. Cloet, ANL","l");
#endif
	//  legThry->AddEntry(bbba05,"BBBA05","l");
	//  legThry->AddEntry(lomon, "Lomon", "l");
	// legThry->AddEntry(ourfit, "Our Fit", "l");
	legThry->Draw();
	legDta->Draw();

	mgrDta->Draw("p");
	legDta->Draw();

	TEllipse *cir1 = new TEllipse(1.31, 0.0, 0.17, 0.0065);
	TEllipse *cir2 = new TEllipse(2.4, 0.0, 0.17, 0.0065);
	cir1->SetFillStyle(0);
	cir2->SetFillStyle(0);

#ifdef PLOTKIN1
	cir1->Draw("same");
	//  cir2->Draw("same");

	//  TPaveLabel *exacc = new TPaveLabel( 0.3779, 0.2691, 0.5963, 0.3114, "Expected Accuracy", "NDC");
	TPaveLabel *exacc = new TPaveLabel( 0.2716, 0.2733, 0.4899, 0.3136, "Expected Accuracy", "NDC");
	exacc->SetFillStyle(0);
	exacc->SetBorderSize(0);
	exacc->Draw("same");
#endif


	// draw a line at 1
	cn->Modified();

	cn->Update();
	cn->SaveAs(Form("%s.pdf",psfile));
	cn->SaveAs(Form("%s.eps",psfile));
	//  cn->SaveAs(Form("%s.root",psfile));
	//  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));

	//  cn->SaveAs("bogdan_gen.eps");
	return;  // LEAVING HERE

	// now an overlay, hopefully matching dimensions

	// remove everything but the graph
	cn->Update();
	TList *clist = cn->GetListOfPrimitives();
	TFrame* frame = cn->GetFrame();
	for (int i=0; i<clist->GetSize(); ) {
		if (clist->At(i) != frame) {
			clist->RemoveAt(i);
		} else i++;
	}
	// draw markers in the corners
	TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
	mkr->Draw();
	mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
	mkr->Draw();
	mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
	mkr->Draw();
	mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
	mkr->Draw();
	frame->SetLineColor(10);
	cn->Update();

	datafile_t miller = { "figure_input/Miller/lattice.GEn.rtf","Miller",
		"[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" };

	gr = OneGraph(&miller);
	TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
	if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
		gr = toerror_band(egr);
		gr->SetLineStyle(1);
		gr->SetFillColor(gr->GetLineColor());
		gr->SetFillStyle(3000+miller.style);
	}

	gr->Draw("F");

	cn->Update();
	cn->SaveAs("gen_Miller_Overlay.pdf");
	cn->SaveAs("gen_Miller_Overlay.root");

}
コード例 #6
0
void JetResponseMacro_Pt(){
    
    
    TH1::SetDefaultSumw2();
    TH2::SetDefaultSumw2();
    
    //  gROOT->ProcessLine(".x rootlogon.C");
    gROOT->ProcessLine(".L format1Dhisto.C");
    gROOT->ProcessLine(".L formatTGraph.C");
    //  gROOT->ProcessLine(".x betterColors.C");
    //TFile *FileA = TFile::Open(Form("correctedFileForBtag.root"));
    TFile *FileA = TFile::Open(Form("../corrected_dijet_pp_mergedpthatbins_2013MCV3.root"));
    //  TFile *FileA = TFile::Open(Form("/Users/ymao/group/CMS/anaOutputs/pPb/JEC/dijet_pp_mergedpthatbins_2012MC.root"));
    TString outname = "JetResponse_Plots.root";
    //  TFile* outf = new TFile(outname,"recreate");
    TString plotsdir = "/Users/ymao/group/CMS/plots/pA";
    
    TString canv_name = "c1";
    const Double_t kw = 1300;
    const Double_t kh = 480;
    c1 = new TCanvas(canv_name," ",10,10,kw,kh);
    makeMultiPanelCanvas(c1,nBin/2,2,0.0,0.0,0.1,0.2,0.05);
    
    gStyle->SetOptStat(0);
    gStyle->SetPadBottomMargin(0.12);
    gStyle->SetPadTopMargin   (0.025);
    gStyle->SetPadLeftMargin  (0.15);
    gStyle->SetPadRightMargin (0.025);
    gStyle->SetPadTickX       (1);
    gStyle->SetPadTickY       (1);
    
    
    TLegend *t1=new TLegend(0.2,0.75,0.8,0.92);
    //   TLegend *t1=new TLegend(0.25,0.6,0.8,0.92);
    t1->SetFillColor(0);
    t1->SetBorderSize(0);
    t1->SetFillStyle(0);
    t1->SetTextFont(63);
    t1->SetTextSize(15);
    TLegend *t2=new TLegend(0.20,0.45,0.35,0.6);
    t2->SetFillColor(0);
    t2->SetBorderSize(0);
    t2->SetFillStyle(0);
    t2->SetTextFont(63);
    t2->SetTextSize(17);
    
    TH1F * dummy = new TH1F("dummy", "dummy", 500, 0., 500.);
    dummy->SetAxisRange(0., 500., "X") ;
    dummy->GetXaxis()->SetTitle("p_{T}^{ref} (GeV/c)");
    
    //    const char* AlgoNames[] = {"ak3PF"};
    //  TCanvas *c1 = new TCanvas("c1","c1",1100,700);
    //makeMultiPanelCanvas(c1,3,2,0.0,0.0,0.2,0.15,0.07);
    //TCanvas *c1B = new TCanvas("c1B","c1B",1100,700);
    //makeMultiPanelCanvas(c1B,3,2,0.0,0.0,0.2,0.15,0.07);
    //TCanvas *c1C = new TCanvas("c1C","c1C",1100,700);
    //makeMultiPanelCanvas(c1C,3,2,0.0,0.0,0.2,0.15,0.07);
    const int cCanDiv = nBin;
    //  makeMultiPanelCanvas(c1,cCanDiv,2,0.0,0.0,0.2,0.15,0.07);
    int nCanvDiv = cCanDiv;
    const int CnXbins = nJetPtBin;
    int nXbins = CnXbins;
    
    TH2D* iHistoCorrPt[cCanDiv];
    TH2D* iHistoRefPt[cCanDiv];
    TH2D* iHistoJtPt[cCanDiv];
    TH2D* iHistoRawPt[cCanDiv];
    TH1D* h1[cCanDiv][CnXbins];
    
    TF1* Gauss6[cCanDiv][CnXbins];
    double mean[cCanDiv][CnXbins];
    double sigma[cCanDiv][CnXbins];
    double meanErr[cCanDiv][CnXbins];
    double sigmaErr[cCanDiv][CnXbins];
    double xPoint[cCanDiv][CnXbins];
    double xPointErr[cCanDiv][CnXbins];
    TLegend*  leg[cCanDiv];
    
    //   Int_t i = 2 ;
    for(int i =0; i<nCanvDiv; i++)
        //  for(int i =1; i<nCanvDiv-1; i++)
    {
        c1->cd(i+1);
        
        TTree* t      = (TTree*)FileA->Get(Form("%sJetAnalyzer/t", AlgoNames[i]));
        
        leg[i]= new TLegend(0.22,0.63,0.45,0.90);//top right
        leg[i]->SetFillColor(0);
        leg[i]->SetTextSize(0.05);
        leg[i]->SetBorderSize(0);
        
        iHistoCorrPt[i] = new TH2D(Form("%s_CorrPt",AlgoNames[i]),Form("%s_CorrPt",AlgoNames[i]),nXbins,0,500,500,0,5);
        iHistoCorrPt[i]->Sumw2();
        t->Draw(Form("corrpt/refpt:refpt>>%s_CorrPt",AlgoNames[i]),"weight*(refpt>-99 && corrpt>0 && fabs(jteta)<3.0 && rawpt>15.)","goff");
        //    t->Draw(Form("corrpt/refpt:refpt>>%s_CorrPt",AlgoNames[i]),Form("corrpt>0 && fabs(jteta)<3.0"),"goff");
        iHistoCorrPt[i]->Draw("colz");
        leg[i]->AddEntry(iHistoCorrPt[i],Form("%s |#eta|<3.0",AlgoNames[i]),"");
        leg[i]->AddEntry(iHistoCorrPt[i],Form("Jet p_{T}^{corrected}/p_{T}^{ref}"),"");
        format1Dhisto(*iHistoCorrPt[i],250,-1,2,20,2,1,"Jet p_{T}^{ref} (GeV/c)","Corrected p_{T}/ ref p_{T}");//Red
        leg[i]->Draw();
        for(int iX=iHistoCorrPt[i]->GetXaxis()->GetFirst(); iX<iHistoCorrPt[i]->GetXaxis()->GetLast(); iX++ )
            //        for(int iX=0; iX<nJetPtBin; iX++ )
        {
            //cout<<"bin ( "<<iX<<" ) --limits ["<<iHistoCorrPt[i]->GetXaxis()->GetBinLowEdge(iX)<<" , "<<iHistoCorrPt[i]->GetXaxis()->GetBinUpEdge(iX)<<" ] "<<endl;
            h1[i][iX] = new TH1D(Form("h1_%d_%d_py",i,iX),Form("h1_%d_%d_py",i,iX),500,0,5);
            h1[i][iX] =(TH1D*)iHistoCorrPt[i]->ProjectionY(Form("h1_%d_%d_py",i,iX),iX,iX,"e");
            //    h1[i][iX] =(TH1D*)iHistoCorrPt[i]->ProjectionY(Form("h1_%s_Pt%f_%f_py",AlgoNames[i],jetPtBin[iX],jetPtBin[iX+1]),iHistoCorrPt[i]->GetXaxis()->FindBin(jetPtBin[iX]),iHistoCorrPt[i]->GetXaxis()->FindBin(jetPtBin[iX+1])-1,"e");
            
            Gauss6[i][iX] = new TF1(Form("F6_c%d_d%d",i,iX),"gaus",0,3);
            Gauss6[i][iX]->SetParLimits(1,0.7,1.5);
            h1[i][iX]->Fit(Form("F6_c%d_d%d",i,iX),"R0WL", "", 0.7, 1.5);
            //   h1[i][iX]->Fit(Gauss6[i][iX],"0Q");
            if(DoGausFit){
                mean[i][iX] = Gauss6[i][iX]->GetParameter(1);
                sigma[i][iX] = Gauss6[i][iX]->GetParameter(2);
                meanErr[i][iX] = Gauss6[i][iX]->GetParError(1);
                sigmaErr[i][iX] = Gauss6[i][iX]->GetParError(2);
            }
            else {
                mean[i][iX] = h1[i][iX]->GetMean();
                sigma[i][iX]= h1[i][iX]->GetRMS();
                meanErr[i][iX] = h1[i][iX]->GetMeanError();
                sigmaErr[i][iX] =h1[i][iX]->GetRMSError();
            }
            xPoint[i][iX] =iHistoCorrPt[i]->GetXaxis()->GetBinCenter(iX);
            xPointErr[i][iX] = 0;
            
            
            if(i==2 && iX==3)//Just to test
            {
                cout<<"bin ( "<<iX<<" ) --limits ["<<iHistoCorrPt[i]->GetXaxis()->GetBinLowEdge(iX)<<" , "<<iHistoCorrPt[i]->GetXaxis()->GetBinUpEdge(iX)<<" ] "<<endl;
                TCanvas *c11 = new TCanvas("c11","c11",500,500);
                c11->cd();
                h1[i][iX]->Draw();
                Gauss6[i][iX]->Draw("same");
            }
        }
        
    }
    if(SavePlot){
        c1->Print(Form("CorrectedOverRefJet.pdf"));
    }
    
    c1->Update();
    
    TLegend*  leg2B[cCanDiv];
    TLegend*  leg2A[cCanDiv];
    TGraphErrors *CorrPt_Mean[cCanDiv];
    TCanvas *c2 = new TCanvas("c2","c2",10,10,kw,kh);
    makeMultiPanelCanvas(c2,nBin/2,2,0.0,0.0,0.1,0.2,0.05);
    
    //makeMultiPanelCanvas(c2,3,2,0.0,0.0,0.2,0.15,0.07);
    //TCanvas *c2B = new TCanvas("c2B","c2B",1100,700);
    //makeMultiPanelCanvas(c2B,3,2,0.0,0.0,0.2,0.15,0.07);
    //TCanvas *c2C = new TCanvas("c2C","c2C",1100,700);
    //makeMultiPanelCanvas(c2C,3,2,0.0,0.0,0.2,0.15,0.07);
    
    TGraphErrors *CorrPt_Sigma[cCanDiv];
    TCanvas *c3 = new TCanvas("c3","c3",10,10,kw,kh);
    makeMultiPanelCanvas(c3,nBin/2,2,0.0,0.0,0.1,0.2,0.05);
    //makeMultiPanelCanvas(c3,3,2,0.0,0.0,0.2,0.15,0.07);
    //TCanvas *c3B = new TCanvas("c3B","c3B",1100,700);
    //makeMultiPanelCanvas(c3B,3,2,0.0,0.0,0.2,0.15,0.07);
    //TCanvas *c3C = new TCanvas("c3C","c3C",1100,700);
    //makeMultiPanelCanvas(c3C,3,2,0.0,0.0,0.2,0.15,0.07);
    
    for(int i2 =0; i2<nCanvDiv; i2++)
    {
        leg2A[i2]= new TLegend(0.22,0.73,0.45,0.95);//top right
        leg2A[i2]->SetFillColor(0);
        leg2A[i2]->SetTextSize(0.05);
        leg2A[i2]->SetBorderSize(0);
        
        leg2B[i2]= new TLegend(0.22,0.73,0.45,0.95);//top right
        leg2B[i2]->SetFillColor(0);
        leg2B[i2]->SetTextSize(0.05);
        leg2B[i2]->SetBorderSize(0);
        
        double xLoc[CnXbins];
        double y2Loc[CnXbins];
        double y3Loc[CnXbins];
        double xLocErr[CnXbins];
        double y2LocErr[CnXbins];
        double y3LocErr[CnXbins];
        for(int iBin=0; iBin<nXbins; iBin++)
        {
            xLoc[iBin] = xPoint[i2][iBin];
            xLocErr[iBin] = xPointErr[i2][iBin];
            y2Loc[iBin] = mean[i2][iBin];
            y2LocErr[iBin] = meanErr[i2][iBin];
            y3Loc[iBin] = sigma[i2][iBin];
            y3LocErr[iBin] = sigmaErr[i2][iBin];
        }
        
        //     if(i2<=5)c2->cd(i2+1);
        //     if(i2>5 && i2<12)c2B->cd(i2-5);
        //     if(i2>=12)c2C->cd(i2-12);
        c2->cd(i2+1);
        CorrPt_Mean[i2] = new TGraphErrors(nXbins,xLoc,y2Loc,xLocErr,y2LocErr);
        formatTGraph(*CorrPt_Mean[i2],250,-1,1,20,1,1,"p_{T}^{ref} (GeV/c)","#mu ");
        leg2A[i2]->AddEntry(CorrPt_Mean[i2],Form("%s |#eta|<2.0",AlgoNames[i2]),"");
        leg2A[i2]->AddEntry(CorrPt_Mean[i2],Form("p_{T}^{corrected}/p_{T}^{ref}"),"lp");
        CorrPt_Mean[i2]->SetMaximum(1.1);
        CorrPt_Mean[i2]->SetMinimum(0.9);
        CorrPt_Mean[i2]->Draw("AP");
        leg2A[i2]->Draw();
        regSun(20.,1.,400.,1.,1, 1);
        
        //     if(i2<=5)c3->cd(i2+1);
        //     if(i2>5 && i2<12)c3B->cd(i2-5);
        //     if(i2>=12)c3C->cd(i2-12);
        c3->cd(i2+1);
        CorrPt_Sigma[i2] = new TGraphErrors(nXbins,xLoc,y3Loc,xLocErr,y3LocErr);
        formatTGraph(*CorrPt_Sigma[i2],250,-1,1,20,1,1,"p_{T}^{ref} (GeV/c)","#sigma ");
        leg2B[i2]->AddEntry(CorrPt_Sigma[i2],Form("%s |#eta|<2.0",AlgoNames[i2]),"");
        leg2B[i2]->AddEntry(CorrPt_Sigma[i2],Form("p_{T}^{corrected}/p_{T}^{ref}"),"lp");
        CorrPt_Sigma[i2]->SetMaximum(0.4);
        CorrPt_Sigma[i2]->SetMinimum(0.);
        CorrPt_Sigma[i2]->Draw("AP");
        leg2B[i2]->Draw();
        regSun(20.,1.,400.,1.,1, 1);
        
    }
    if(SavePlot){
        c2->Print(Form("CorrectedOverRefJetMean.pdf"));
        c3->Print(Form("CorrectedOverRefJetSigma.pdf")) ;
    }
    c2->Update();
    c3->Update();
}
コード例 #7
0
ファイル: printBfraction.C プロジェクト: kurtejung/bJetTools
void printBfraction(char *tagger="discr_ssvHighEff", Double_t workingPoint=2, char *taggerName="ssvHighEff", int doCent=2, int do3bin=1) {

  gROOT->ForceStyle(1);

  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);


  gStyle->SetTextFont(42);
  gStyle->SetLabelFont(42,"XYZ");
  gStyle->SetTitleFont(42,"XYZ");

  // hack
  if(doCent)gStyle->SetErrorX(0);
  gStyle->SetLabelSize(0.05,"xy");
  gStyle->SetTitleSize(0.05,"xy");
  gStyle->SetTitleOffset(1.5,"xy");
  gStyle->SetPadLeftMargin(0.15);
  gStyle->SetPadBottomMargin(0.12);
  gStyle->SetNdivisions(408,"y");


  TFile *fin1, *fin2;
  if(doCent){
    if(doCent==1){
      fin1 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL1_centDep_80_100.root");
      fin2 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL0_centDep_80_100.root");
    }
    if(doCent==2){
      fin1 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL1_centDep_100_120.root");
      fin2 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL0_centDep_100_120.root");
    }
    // broken
    //fin1 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL1_centDep_80_100.root");
    //fin2 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL0_centDep_80_100.root");
  }
  else{
    // try to smear by 2 sigma
    //fin1 = new TFile("output/bFractionMerged_Smear2Sigma_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root");
    //fin2 = new TFile("output/bFractionMerged_Smear2Sigma_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root");
    // with reg tracks in reco jets
    //fin1 = new TFile("output/bFractionMerged_regPFJets_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root");
    //fin2 = new TFile("output/bFractionMerged_regPFJets_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root");
    if(do3bin){
      fin1 = new TFile("output/bFractionMerged_3bins_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root");
      fin2 = new TFile("output/bFractionMerged_3bins_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root");
    }
    else{
      fin1 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root");
      fin2 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root");
      // old naming convention
    //fin1 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL1_bin_0_40_eta_0_2.root");
    //fin2 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL0_bin_0_40_eta_0_2.root");

    }
  }

  TH1F *hBFractionMC = (TH1F*) fin1->Get("hBFractionMC");

  TH1F *hBFractionData = (TH1F*) fin1->Get("hBFractionData");
  TH1F *hBFractionDataLTJP = (TH1F*) fin1->Get("hBFractionDataLTJP");
  TH1F *hBFractionJPdirect = (TH1F*) fin1->Get("hBFractionJPdirect");

  TH1F *hBFractionDataFixC = (TH1F*) fin2->Get("hBFractionData");
  TH1F *hBFractionDataLTJPFixC = (TH1F*) fin2->Get("hBFractionDataLTJP");
  TH1F *hBFractionJPdirectFixC = (TH1F*) fin2->Get("hBFractionJPdirect");

  


  /*  --- correction due to Jet Energy Scale (calcul) ---
  correct(hBFractionMC);
  correct(hBFractionData);
  correct(hBFractionDataMoreC);
  correct(hBFractionDataLessC);
  correct(hBFractionDataLTJP);
  correct(hBFractionDataLTJPMoreC);
  correct(hBFractionDataLTJPLessC);
  correct(hBFractionJPdirect);
  correct(hBFractionJPdirectMoreC);
  correct(hBFractionJPdirectLessC);
  //*/

  //*  --- correction due to Jet Energy Scale (by hand) ---
  if(doCent){
    correctByCent(hBFractionMC,doCent);
    correctByCent(hBFractionData,doCent);
    correctByCent(hBFractionDataFixC,doCent);
    correctByCent(hBFractionDataLTJP,doCent);
    correctByCent(hBFractionDataLTJPFixC,doCent);
    correctByCent(hBFractionJPdirect,doCent);
    correctByCent(hBFractionJPdirectFixC,doCent);
  }
  else{
    //*
    correct2(hBFractionMC,do3bin);
    correct2(hBFractionData,do3bin);
    correct2(hBFractionDataFixC,do3bin);
    correct2(hBFractionDataLTJP,do3bin);
    correct2(hBFractionDataLTJPFixC,do3bin);
    correct2(hBFractionJPdirect,do3bin);
    correct2(hBFractionJPdirectFixC,do3bin);
    //*/
  }
  //*/

  //  --- plots with variation of charm ---


  TCanvas *cBFraction1 = new TCanvas("cBFraction1","b-jet fraction",600,600);
  hBFractionMC->SetLineColor(2);
  hBFractionMC->SetLineWidth(2);
  hBFractionMC->SetMarkerColor(2);
  //hBFractionMC->SetMarkerStyle(4);
  if(!doCent)hBFractionMC->SetAxisRange(80,200,"X");
  hBFractionMC->SetAxisRange(0,0.06,"Y");
  hBFractionMC->SetTitleOffset(1,"X");  
  hBFractionMC->GetYaxis()->SetTitle("b-jet fraction");;
  //hBFractionMC->Draw("e1"); 
  
  //hBFractionMC->GetYaxis()->SetNdivisions(505);
  
  TH1F *hBFractionMC_dummy= (TH1F*)hBFractionMC->Clone("hBFractionMC_dummy");
  hBFractionMC_dummy->SetLineWidth(0);
  hBFractionMC_dummy->SetLineColor(0);
  hBFractionMC_dummy->SetMarkerSize(0);
  hBFractionMC_dummy->Draw(); 
  //  hBFractionMC->Draw("hist"); 

  hBFractionData->SetMarkerStyle(8);
  hBFractionData->Draw("e1,same");  
  hBFractionDataLTJP->SetLineColor(kGreen-2); 
  hBFractionDataLTJP->SetMarkerColor(kGreen-2); 
  hBFractionDataLTJP->SetMarkerStyle(8); 
  hBFractionDataLTJP->Draw("e1,same");
  hBFractionJPdirect->SetMarkerStyle(8); 
  hBFractionJPdirect->SetMarkerColor(kBlue);
  hBFractionJPdirect->SetLineColor(kBlue);
  hBFractionJPdirect->Draw("e1,same");

  
  hBFractionDataFixC->SetLineStyle(2);
  //hBFractionDataFixC->Draw("e1same");   
  hBFractionDataLTJPFixC->SetLineColor(kGreen-2);
  hBFractionDataLTJPFixC->SetMarkerColor(kGreen-2);
  hBFractionDataLTJPFixC->SetMarkerStyle(4);
  hBFractionDataLTJPFixC->SetLineStyle(2);
  hBFractionDataLTJPFixC->Draw("e1same");
  hBFractionJPdirectFixC->SetLineStyle(2);
  //hBFractionJPdirectFixC->Draw("e1same");

  
  TLegend *legFrac1 = new TLegend(0.15,0.65,0.87,0.95);

  legFrac1->SetBorderSize(0);
  legFrac1->SetFillStyle(0);
  legFrac1->SetHeader("PbPb, #sqrt{s_{NN}} = 2.76 TeV");
  legFrac1->AddEntry(hBFractionDataLTJP,Form("SSVHE, LT method",taggerName,workingPoint),"pl");
  legFrac1->AddEntry(hBFractionDataLTJPFixC,Form("SSVHE, LT method, Floating Charm Norm.",taggerName,workingPoint),"pl");
  legFrac1->AddEntry(hBFractionData,Form("SSVHE, MC eff.",taggerName,workingPoint),"pl");
  legFrac1->AddEntry(hBFractionJPdirect,"Jet Probability","pl");
  //legFrac1->AddEntry(hBFractionMC,"MC Input (reconstructed)","l");

  legFrac1->Draw();




  //  --- plots of LT method with syst. uncertainty ---

  TCanvas *cBFraction2 = new TCanvas("cBFraction2","b-jet fraction",600,600);

  TH1F *hBFractionMC2 = hBFractionMC->Clone("hBFractionMC2");
  if(!doCent)hBFractionMC2->GetXaxis()->SetRangeUser(80,200);
  hBFractionMC2->SetMarkerSize(0);
  hBFractionMC2->SetMaximum(0.06);
  hBFractionMC2->SetMinimum(0.0);
  hBFractionMC2->Draw("hist");


  TGraphAsymmErrors *gBFractionMC2 = new TGraphAsymmErrors(hBFractionMC);
  if(!doCent){
    setMeanPt(gBFractionMC2,hBFractionMC,0,do3bin);
    gBFractionMC2->GetXaxis()->SetRangeUser(80,200);
  }



  TLatex *prel;
  if(doCent)prel= new TLatex(10,0.0615,"CMS preliminary");
  else prel= new TLatex(85,0.0615,"CMS preliminary");
  prel->Draw();

  TLatex *roots = new TLatex(147,0.0615,"#sqrt{s_{NN}} = 2.76 TeV");
  roots->Draw();

  if(!doCent){
    TLatex *csel = new TLatex(90,0.05,"Centrality 0-100%");
    csel->Draw();
  }
  TLatex *ptlabel;
  if(doCent==1) ptlabel= new TLatex(20,0.005,"80 < Jet p_{T} < 100 GeV/c");
  if(doCent==2) ptlabel= new TLatex(20,0.005,"100 < Jet p_{T} < 120 GeV/c");
  if(doCent)ptlabel->Draw();

  // to be precise we should evaluate mcStatErr for 3 bins seperately
  float mcStatErr[4] = {0.03,0.06,0.07,0.15};

  
  //TGraphAsymmErrors *gSyst = new TGraphAsymmErrors(3);
  TGraphErrors *gSyst;
  if(do3bin) gSyst= new TGraphErrors(3);
  else gSyst= new TGraphErrors(4);
  Double_t errCLratio, errMethod, totalSystErr;

  for(Int_t i=1;i<=hBFractionDataLTJP->GetNbinsX();i++) {
    gSyst->SetPoint(i-1,hBFractionDataLTJP->GetBinCenter(i),hBFractionDataLTJP->GetBinContent(i));
    cout<<" central value "<<hBFractionDataLTJP->GetBinContent(i)<<endl;
    errCLratio = abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionDataLTJPFixC->GetBinContent(i));
    errMethod = max(abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionData->GetBinContent(i)),abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionJPdirect->GetBinContent(i)));
    double errJES = 0.14*hBFractionDataLTJP->GetBinContent(i);
    
    totalSystErr = norm(errCLratio,errMethod,errJES);
    gSyst->SetPointError(i-1,hBFractionDataLTJP->GetBinWidth(i)/2,totalSystErr);
    cout<<" sys error "<<totalSystErr<<endl;
    // add in MC template uncertainties
    float origStatErr = hBFractionDataLTJP->GetBinError(i);
    int statBin=i-1;
    if(doCent==1) statBin=0;
    if(doCent==2) statBin=1;
    float extraStatErr = mcStatErr[statBin]*hBFractionDataLTJP->GetBinContent(i);
    float totalStatErr = sqrt(origStatErr*origStatErr + extraStatErr*extraStatErr);
    hBFractionDataLTJP->SetBinError(i,totalStatErr);
    cout<<" total error "<<sqrt(totalSystErr*totalSystErr+totalStatErr*totalStatErr)<<endl;

  }

  gSyst->SetFillColor(5);
  gSyst->Draw("2");


  gBFractionMC2->Draw("Z,p,same");
  hBFractionMC2->Draw("hist,same");


  TGraphAsymmErrors *gBFractionDataLTJP2 = new TGraphAsymmErrors(hBFractionDataLTJP);
  if(!doCent)setMeanPt(gBFractionDataLTJP2,hBFractionDataLTJP,1,do3bin);
  gBFractionDataLTJP2->SetLineColor(1);
  gBFractionDataLTJP2->SetMarkerColor(1);
  gBFractionDataLTJP2->SetMarkerSize(1.5);
  gBFractionDataLTJP2->Draw("p,e1,same");


  TLegend *legFrac2 = new TLegend(0.2,0.15,0.8,0.34);
  if(doCent){
    legFrac2->SetX1(0.365);
    legFrac2->SetY1(0.657);
    legFrac2->SetX2(0.965);
    legFrac2->SetY2(0.848);
  }

  legFrac2->SetHeader("#int L dt = 150 #mub^{-1}");
  legFrac2->SetBorderSize(0);
  legFrac2->SetFillStyle(0);
  legFrac2->AddEntry(gBFractionDataLTJP2,"PbPb data","p");
  legFrac2->AddEntry(gBFractionMC2,"PYTHIA+HYDJET 1.8","lp");
  legFrac2->AddEntry(gSyst,"Exp. uncertainty","f");
  legFrac2->Draw();

 
  cBFraction2->RedrawAxis();

}
コード例 #8
0
void plot(
	  const string tnp_      = "elecTnP",
	  const string category_ = "elecID80",
	  const string ptRange_  = "pt>15 && pt<20",
	  const string bin_      = "15to20",
	  float ymax             = 1.0,
	  double cutValue_       = 0.5,
	  const float xLow_      = 70,
	  const float xHigh_     = 120,
	  const float nBins_     = 24,
	  bool doBinned_         = true,
	  float deltaAlpha_      = 0.0,
	  float deltaN_          = 0.0,
	  float scale_           = 0.0
	  )
{
 
  std::ofstream out(("elecTnP_"+category_+"_"+bin_+".txt").c_str());
  out.precision(4);

  vector<float*> bin1 = simFit(tnp_,category_,cutValue_,"(abseta<1.5 && "+ptRange_+")", 0.75,0.75,xLow_,xHigh_,nBins_,doBinned_,deltaAlpha_,deltaN_,scale_);
  vector<float*> bin2 = simFit(tnp_,category_,cutValue_,"(abseta>1.5 && "+ptRange_+")", 1.90,0.4, xLow_,xHigh_,nBins_,doBinned_,deltaAlpha_,deltaN_,scale_);

  float truthMC_x[2]   = {(bin1[0])[0], (bin2[0])[0]};
  float truthMC_xL[2]  = {(bin1[0])[1], (bin2[0])[1]};
  float truthMC_xH[2]  = {(bin1[0])[2], (bin2[0])[2]};
  float truthMC_y[2]   = {(bin1[0])[3], (bin2[0])[3]};
  float truthMC_yL[2]  = {(bin1[0])[4], (bin2[0])[4]};
  float truthMC_yH[2]  = {(bin1[0])[5], (bin2[0])[5]};

  float tnpData_x[2]   = {(bin1[1])[0], (bin2[1])[0]};
  float tnpData_xL[2]  = {(bin1[1])[1], (bin2[1])[1]};
  float tnpData_xH[2]  = {(bin1[1])[2], (bin2[1])[2]};
  float tnpData_y[2]   = {(bin1[1])[3], (bin2[1])[3]};
  float tnpData_yL[2]  = {(bin1[1])[4], (bin2[1])[4]};
  float tnpData_yH[2]  = {(bin1[1])[5], (bin2[1])[5]};

  out<<"%Tag&probe measurement :" << category_ << ", bin: " << ptRange_ << endl;
  out<<"\\begin{tabular}[!htbp]{|c|c|c|}" << endl;
  out << "\\hline" << endl;
  out << "Bin & MC & Data \\\\" << endl;
  out << "\\hline" << endl;
  out << "|\\eta|<1.5 & " << truthMC_y[0] << " \\pm " << truthMC_yL[0] << " & " << tnpData_y[0] << " \\pm_{" << tnpData_yL[0] << "}^{" 
      << tnpData_yH[0] << "} \\\\" << endl;
  out << "\\hline" << endl;
  out << "|\\eta|>1.5 & " << truthMC_y[1] << " \\pm " << truthMC_yL[1] << " & " << tnpData_y[1] << " \\pm_{" << tnpData_yL[1] << "}^{" 
      << tnpData_yH[1] << "} \\\\" << endl;
  out << "\\hline" << endl;
  out<<"\\end{tabular}"<<endl;

  TCanvas *c2 = new TCanvas("results","canvas",10,30,650,600);
  c2->SetGrid(0,0);
  c2->SetFillStyle(4000);
  c2->SetFillColor(10);
  c2->SetTicky();
  c2->SetObjectStat(0);

  TLegend* leg = new TLegend(0.18,0.20,0.45,0.45,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.03);
  leg->SetFillColor(0);

  TH1F* hMaster = new TH1F("hMaster","CMS Preliminary 2011  #sqrt{s}=7 TeV L=XXX pb^{-1}; |#eta^{probe}|; electron ID",1,0,2.3);

  hMaster->SetAxisRange(0,ymax,"Y");
  hMaster->SetXTitle( "|#eta^{probe}|" );
  string YTitle="efficiency";
  hMaster->SetYTitle( YTitle.c_str() );
  hMaster->GetYaxis()->SetTitleOffset(1.4);

  TGraphAsymmErrors* graph_truthMC = new TGraphAsymmErrors(2,truthMC_x,truthMC_y, truthMC_xL,truthMC_xH,truthMC_yL,truthMC_yH);
  graph_truthMC->SetMarkerColor(kBlue);
  graph_truthMC->SetMarkerStyle(kOpenCircle);
  graph_truthMC->SetMarkerSize(1.5);

  TGraphAsymmErrors* graph_tnpData = new TGraphAsymmErrors(2,tnpData_x, tnpData_y, tnpData_xL,tnpData_xH,tnpData_yL,tnpData_yH);
  graph_tnpData->SetMarkerColor(kBlack);
  graph_tnpData->SetMarkerStyle(kFullCircle);
  graph_tnpData->SetMarkerSize(1.5);

  string header = "";
  if(category_.find("ID95")!=string::npos)  header = "Eff. of WP95 for "+ptRange_ ;
  if(category_.find("ID80")!=string::npos)  header = "Eff. of WP80 for "+ptRange_ ;
  if(category_.find("Iso")!=string::npos) header = "Eff. of Iso(#Delta#beta) for "+ptRange_ ;
  if(category_.find("HLT")!=string::npos) header = "Eff. of HLT for "+ptRange_ ;
  leg->SetHeader(header.c_str());
  leg->AddEntry(graph_truthMC,"MC-truth","P");
  leg->AddEntry(graph_tnpData,"DATA","P");

  c2->cd();
  hMaster->Draw();
  graph_truthMC->Draw("PSAME");
  graph_tnpData->Draw("PSAME");

  leg->Draw();

  gPad->SaveAs( ("efficiencyElecTnP"+category_+"_"+bin_+".png").c_str() );
  
}
コード例 #9
0
void plotPPBalance_Ratio(){

  bool isPF = true;

  TString data_tag;
  TString mc_tag;
  TString jetfinder, jetfinder_tag;

  if(!isPF){
    data_tag = "hdata_ak5calo_DijetBalance";
    mc_tag = "hmc_ak5calo_DijetBalance_histonly";
    jetfinder_tag = "calo";
  }else{
    data_tag = "hdata_ak5pf_DijetBalance";
    mc_tag = "hmc_ak5pf_DijetBalance_histonly";
    jetfinder_tag ="pf";
  }

  TFile *fDATA = new TFile(Form("./%s.root",data_tag.Data()));
  TFile *fMC = new TFile(Form("./%s.root",mc_tag.Data()));

  TH1F *hDijetBal_data = (TH1F*) fDATA->Get("hDataDijetBalance");
  TH1F *hDijetBal_mc = (TH1F*) fMC->Get("hQCDDijetBalance");


  // normalization should be matched with what's in ANA
  hDijetBal_data->Scale(1./hDijetBal_data->Integral());
  hDijetBal_data->Rebin(2);

  hDijetBal_mc->Scale(1./hDijetBal_mc->Integral());
  hDijetBal_mc->Rebin(2);

  cout<<"Bin Width = "<<hDijetBal_data->GetBinWidth(1)<<endl;


  // canvas setting ---
  TCanvas *c1 = new TCanvas("c1","",550,600);

  // dum styling ----
  TH1F *hDum = new TH1F("hDum","",10,0,1.0);
  hDum->SetLineColor(kBlue);
  hDum->SetFillColor(kAzure-8);
  hDum->SetFillStyle(3005);

  hDum->SetStats(0);
  hDum->SetXTitle("A_{J} = (p_{T}^{j1}-p_{T}^{j2})/(p_{T}^{j1}+p_{T}^{j2})");
  hDum->SetYTitle("Data/PYTHIA");

  hDum->GetXaxis()->SetLabelSize(30);
  hDum->GetXaxis()->SetLabelFont(43);
  hDum->GetXaxis()->SetTitleSize(30);
  hDum->GetXaxis()->SetTitleFont(43);
  hDum->GetXaxis()->SetTitleOffset(1.3);
  hDum->GetXaxis()->CenterTitle();

  hDum->GetXaxis()->SetNdivisions(905,true);
  
  hDum->GetYaxis()->SetLabelSize(30);
  hDum->GetYaxis()->SetLabelFont(43);
  hDum->GetYaxis()->SetTitleSize(30);
  hDum->GetYaxis()->SetTitleFont(43);
  hDum->GetYaxis()->SetTitleOffset(1.7);
  hDum->GetYaxis()->CenterTitle();

  hDum->SetAxisRange(0,5,"Y");


  // data, mc styling
  hDijetBal_mc->SetLineColor(kBlue);
  hDijetBal_mc->SetFillColor(kAzure-8);
  hDijetBal_mc->SetFillStyle(3005);

  hDum->Draw("hist");

  hDijetBal_data->SetMarkerSize(2.0);
  hDijetBal_data->SetMarkerSize(2.0);
  hDijetBal_data->Sumw2();
  hDijetBal_mc->Sumw2();
  hDijetBal_data->Divide(hDijetBal_mc);
  hDijetBal_data->Draw("pzsame"); 

  // Legend
  TLegend *t3=new TLegend(0.20,0.54,0.58,0.79);
  //t3->SetHeader("ant-k_{T} (R=0.5) CaloJets");
  t3->AddEntry(hDijetBal_data,"p + p  #sqrt{s}=7.0 TeV","pl");
  //t3->AddEntry(hDijetBal_mc,"PYTHIA","lf");
  t3->SetFillColor(0);
  t3->SetBorderSize(0);
  t3->SetFillStyle(0);
  t3->SetTextFont(63);
  t3->SetTextSize(20);
  t3->Draw();


  // other labeling
  TLatex *cms = new TLatex(0.06,4.5,"CMS");
  cms->SetTextFont(63);
  cms->SetTextSize(20);
  cms->Draw();

  TLatex *lumi = new TLatex(0.3,4.5,"#intL dt = 35.1 pb^{-1}");
  lumi->SetTextFont(63);
  lumi->SetTextSize(18);
  lumi->Draw();

  
  TLatex *jetf;
  if(!isPF) jetf = new TLatex(0.06,4.0,"anti-k_{T} (R=0.5) CaloJets");
  else jetf = new TLatex(0.06,4.0,"anti-k_{T} (R=0.5) PFJets");
  jetf->SetTextFont(63);
  jetf->SetTextSize(20);
  jetf->Draw();

  c1->Print(Form("./fig/ratio_%s_%s_v1.gif",data_tag.Data(),jetfinder_tag.Data()));
  c1->Print(Form("./fig/ratio_%s_%s_v1.pdf",data_tag.Data(),jetfinder_tag.Data()));
  c1->Print(Form("./fig/ratio_%s_%s_v1.eps",data_tag.Data(),jetfinder_tag.Data()));

}
コード例 #10
0
ファイル: trigEffMB.C プロジェクト: CmsHI/CVS_SavedFMa
void trigEffMB(char* infile="~/scratch02/data/HIAllPhysics/r151058/OpenHLT*.root")
{
   TChain * oh = new TChain("hltanalysis/HltTree");
   oh->Add(infile);

   // Pre-firing study:
   // * Make sure use an enabled bit, but with wide bx accept
   // * then probe a un-enabled bit
   TCut evtSel("L1_ZdcCaloPlus_ZdcCaloMinus_BptxAND_5bx&&recoVrtNtrk>0");

   TH1D * hBptx5Bx = new TH1D("hBptx5Bx","hBptx5Bx",31,0,31);
   TH1D * hBsc5Bx = new TH1D("hBsc5Bx","hBsc5Bx",31,0,31);
   TH1D * hHf5Bx = new TH1D("hHf5Bx","hHf5Bx",31,0,31);
   TH1D * hZdc5Bx = new TH1D("hZdc5Bx","hZdc5Bx",31,0,31);

   TCanvas *cBx = new TCanvas("cBx","cBx",500,500);
   //cBx->SetLogy();
   oh->Draw("L1Tech_BPTX_plus_AND_minus.v0_5bx>>hBptx5Bx",evtSel,"E");
   oh->Draw("L1_BscMinBiasInnerThreshold1_5bx>>hBsc5Bx",evtSel,"Esame");
   oh->Draw("L1_HcalHfCoincidencePm_5bx>>hHf5Bx",evtSel,"Esame");
   oh->Draw("L1_ZdcCaloPlus_ZdcCaloMinus_5bx>>hZdc5Bx",evtSel,"Esame");

   TCanvas *c = new TCanvas("c","",600,600);
   const int nBin=20;
   Float_t bin[nBin+1]={0,5,10,15,30,60,80,100,120,160,200,300,400,500,2000,4000,8000,12000,20000,40000,160000};
   TH1F *hTmp = new TH1F("hTmp","",nBin,bin);

   TGraphAsymmErrors *g = eff(oh,evtSel,"L1_HcalHfCoincidencePm_5bx");
   //TGraphAsymmErrors *g = eff(oh,evtSel,"HLT_HIMinBiasHfOrBSC");
   //TGraphAsymmErrors *g2 = eff(oh,evtSel,"L1Tech_BSC_HighMultiplicity.v0");
   TGraphAsymmErrors *g3 = eff(oh,evtSel,"L1_BscMinBiasThreshold1_5bx");
   TGraphAsymmErrors *g4 = eff(oh,evtSel,"L1_ZdcCaloPlus_ZdcCaloMinus_5bx");
   //TGraphAsymmErrors *g5 = eff(oh,evtSel,"HLT_HIMinBiasPixel_SingleTrack");
   //TGraphAsymmErrors *g5 = eff(oh,evtSel,"HLT_HIMinBiasZDCPixel_SingleTrack");

   //g2->SetLineColor(2);
   //g2->SetMarkerColor(2);
   //g2->SetMarkerStyle(kOpenStar);
   g3->SetLineColor(4);
   g3->SetMarkerColor(4);
   g3->SetMarkerStyle(4);
   g4->SetLineColor(kGreen+2);
   g4->SetMarkerColor(kGreen+2);
   g4->SetMarkerStyle(4);
   //g5->SetMarkerStyle(kOpenSquare);
   //g5->SetMarkerColor(kMagenta);
   hTmp->SetAxisRange(0,1.3,"Y");
   hTmp->SetXTitle("HF (GeV)");
   hTmp->SetYTitle("Firing rate");
   hTmp->Draw();
   TLine *l = new TLine(0,1,bin[nBin],1);
   l->SetLineStyle(2);
   //g5->Draw("p same");
   g->Draw("p same");
   g3->Draw("p same");
   g4->Draw("p same");
   //g2->Draw("p same");
   l->Draw();
   TLegend *t = new TLegend(0.34,0.78,0.94,0.91);
   t->SetBorderSize(0);
   t->SetFillStyle(0);
   t->AddEntry(g,"L1_HcalHfCoincidencePm_5bx","pl");
   //t->AddEntry(g2,"L1Tech_BSC_HighMultiplicity.v0","pl");
   t->AddEntry(g3,"L1_BscMinBiasThreshold1_5bx","pl");
   t->AddEntry(g4,"HLT_HIMinBiasZDC_Calo","pl");
   //t->AddEntry(g5,"HLT_HIMinBiasPixel_SingleTrack","pl");
   t->Draw();
}
コード例 #11
0
ファイル: ppb_merge.C プロジェクト: rkunnawa/RpPb
void ppb_merge(){
	
	TStopwatch timer;
	timer.Start();
	
	
	//Float_t N_mb = Lumi_ppb*sigma_inelastic*1000;
	//Float_t Lumi_ppb = 30.9;// inverse micro barns
	//Float_t sigma_inelastic = 70.0;//milli barns

	TH1::SetDefaultSumw2();
	
	
	
	TString inname1 = "root://eoscms//eos/cms/store/group/phys_heavyions/yjlee/pPb2013/promptReco/PA2013_HiForest_PromptReco_JSonPPb_forestv77.root";
	TString inname2 = "root://eoscms//eos/cms/store/group/phys_heavyions/krajczar/inbound/mnt/hadoop/cms/store/user/krajczar/pPb_Jet40Jet60_Full_v1/mergedJet40Jet60_KK.root";
	
	TFile *f1 = TFile::Open(inname1);
	TFile *f2 = TFile::Open(inname2);
	
	cout<<" File for HLT_100 HLT_80 = "<<inname1<<endl;
	cout<<" File for HLT_60 HLT_40 = "<<inname2<<endl;
	
	TFile *outfile = new TFile("pPbmerged_output.root","RECREATE");
	
	TTree* jet_80 = (TTree*)f1->Get("akPu3PFJetAnalyzer/t");
	TTree* jet_80_hlt = (TTree*)f1->Get("hltanalysis/HltTree");
	TTree* jet_80_skim = (TTree*)f1->Get("skimanalysis/HltTree");
	TTree* jet_80_evt = (TTree*)f1->Get("hiEvtAnalyzer/HiTree");
	jet_80->AddFriend(jet_80_hlt);
	jet_80->AddFriend(jet_80_skim);
	jet_80->AddFriend(jet_80_evt);
	
	TTree* jet_60 = (TTree*)f2->Get("akPu3PFJetAnalyzer/t");
	TTree* jet_60_hlt = (TTree*)f2->Get("hltanalysis/HltTree");
	TTree* jet_60_skim = (TTree*)f2->Get("skimanalysis/HltTree");
	TTree* jet_60_evt = (TTree*)f2->Get("hiEvtAnalyzer/HiTree");
	jet_60->AddFriend(jet_60_hlt);
	jet_60->AddFriend(jet_60_skim);
	jet_60->AddFriend(jet_60_evt);
	
	TCut Sel = "abs(vz)<15&&pHBHENoiseFilter&&pPAcollisionEventSelectionPA";
	TCut Trig_100 = "HLT_PAJet100_NoJetID_v1";
	TCut Trig_80 = "HLT_PAJet80_NoJetID_v1";
	TCut Trig_60 = "HLT_PAJet60_NoJetID_v1";
	TCut eta = "abs(jteta)<1";

	Float_t N_mb = 7.71e13;
	
	Float_t prescl3 = (Float_t)jet_80->GetEntries()/jet_80->GetEntries(Trig_60);
	Float_t prescl3_test = (Float_t)jet_80->GetEntries(Sel&&eta&&Trig_100)/jet_80->GetEntries(Sel&&eta&&Trig_60);

	
	const Int_t nbins = 16;
	const Double_t bound[nbins+1] = {30., 40., 50., 60., 70., 80., 90., 100., 110., 120., 140., 150., 160., 200., 220., 260., 300.};
	
	TH1F *hMeas_100 = new TH1F("hMeas_100","PPb HLT_100 Measured histo",nbins,bound);
	TH1F *hMeas_80 = new TH1F("hMeas_80","PPb HLT_80 Measured histo",nbins,bound);
	TH1F *hMeas_60 = new TH1F("hMeas_60","PPb HLT_60 Measured histo",nbins,bound);
	TH1F *hCombined = new TH1F("hCombined","PPb Combined spectra",nbins,bound);
	
	hMeas_100->Sumw2();
	hMeas_60->Sumw2();
	hMeas_80->Sumw2();
	
	jet_80->Draw("jtpt>>hMeas_100",Sel&&Trig_100&&eta);
	jet_80->Draw("jtpt>>hMeas_80",Sel&&!Trig_100&&Trig_80&&eta);
	jet_60->Draw("jtpt>>hMeas_60","1.58606"*Sel&&eta&&Trig_60&&!Trig_80&&!Trig_100);
	
	
	divideBinWidth(hMeas_100);
	divideBinWidth(hMeas_80);
	divideBinWidth(hMeas_60);
	
	hMeas_100->Scale(1./2); //scaling by d eta  - from -1 to +1 is 2. 
	hMeas_80->Scale(1./2);
	hMeas_60->Scale(1./2);
	
	hCombined->Add(hMeas_100,1);
	hCombined->Add(hMeas_80,1);
	hCombined->Add(hMeas_60,1);
	
	hCombined->Scale(1./N_mb);
	hMeas_100->Scale(1./N_mb);
	hMeas_80->Scale(1./N_mb);
	hMeas_60->Scale(1./N_mb);
	
	TCanvas *cMerged = new TCanvas("cMerged","Merged PPb spectra",800,600);
	cMerged->SetLogy();

	hCombined->SetXTitle("Jet p_{T} [GeV/c]");
	hCombined->SetYTitle("1/N_mb d^2N/dp_t d eta");
	hCombined->SetMarkerColor(kBlack);
	hCombined->SetMarkerStyle(20);
	hCombined->SetAxisRange(30,300,"X");
	hCombined->Draw();
	hMeas_100->SetMarkerColor(kRed);
	hMeas_100->SetMarkerStyle(21);
	hMeas_100->Draw("same");
	hMeas_80->SetMarkerColor(kBlue);
	hMeas_80->SetMarkerStyle(22);
	hMeas_80->Draw("same");
	hMeas_60->SetMarkerColor(kGreen);
	hMeas_60->SetMarkerStyle(23);
	hMeas_60->Draw("same");
	
	TLegend *leg_PPb = myLegend(0.6,0.65,0.95,0.9);
	leg_PPb->SetTextSize(0.05);
	leg_PPb->AddEntry(hCombined,"Merged PPb spectra ","pl");
	leg_PPb->AddEntry(hMeas_100,"HLT_100 spectra","pl");
	leg_PPb->AddEntry(hMeas_80,"HLT_80 spectra","pl");
	leg_PPb->AddEntry(hMeas_60,"HLT_60 spectra","pl");
	leg_PPb->Draw();
	
	putCMSPrel(0.2,0.83,0.06);
	drawText("PPb AKPu3PF |eta|<1 |vz|<15",0.2,0.23,20);
	
	cMerged->SaveAs("pPb_merged.pdf","RECREATE");
	
	hMeas_100->Write();
	hCombined->Write();
	hMeas_80->Write();
	hMeas_60->Write();
	

	TFile *fYaxian = TFile::Open("AkPu3PFJetRpA.root");
	TH1F *Yaxian = (TH1F*)fYaxian->Get("DataJetWideBin;3");
	TH1F *test = (TH1F*)Yaxian->Clone("test");

	cout<<"hi"<<endl;
	//outfile->cd();
	Yaxian->Print("base");
	test->Print("base");
	Yaxian->Divide(hCombined);
	TCanvas *yaxian = new TCanvas("yaxian","",800,600);
	yaxian->Divide(2,1);
	yaxian->cd(1);
	Yaxian->SetTitle("ratio of Yaxian's measured pPb spectra to Mine");
	Yaxian->SetXTitle("Jet p_{T} [GeV/c]");
	Yaxian->SetMarkerColor(kBlack);
	Yaxian->SetMarkerStyle(23);
	Yaxian->Draw();
	
	yaxian->cd(2);
	yaxian->cd(2)->SetLogy();
	test->SetMarkerStyle(22);
	test->SetMarkerColor(kBlack);
	test->SetXTitle("Jet p_{T} [GeV/c]");
	test->SetYTitle("1/N_mb d^2N/dp_t d eta");
	test->Draw();
	hCombined->Draw("same");
	
	TLegend *leg = myLegend(0.6,0.65,0.95,0.9);
	leg->SetTextSize(0.05);
	leg->AddEntry(hCombined,"Merged PPb spectra ","pl");
	leg->AddEntry(test,"Yaxian's spectra","pl");
	leg->Draw();
	
	putCMSPrel(0.2,0.83,0.06);
	drawText("PPb AKPu3PF |eta|<1 |vz|<15",0.2,0.23,20);
	
	yaxian->SaveAs("Yaxian_Comparison_pPb_pt_spectra.root","RECREATE");
	
	outfile->cd();
	Yaxian->Write();
	test->Write();
	
	outfile->Write();
	outfile->Close();
	
	timer.Stop();
    float rtime  = timer.RealTime();
    float ctime  = timer.CpuTime();
    
    std::cout<<"\t"<<std::endl;
    std::cout<<Form("RealTime=%f seconds, CpuTime=%f seconds",rtime,ctime)<<std::endl;
    std::cout<<"\t"<<std::endl;
    std::cout<<"Good bye : " <<"\t"<<std::endl;
    
	//define the required histograms
	//static const Int_t nbins = 22;
	//static const Double_t bound[nbins+1] = {30.,40.,50.,60.,70.,80.,90.,100.,110.,120.,130.,140.,150.,160.,180.,200.,220.,260.,300.,350.,400.,450.,500.};
	
}
コード例 #12
0
ファイル: gen5.C プロジェクト: ellie-long/analysis-scripts
void gen5() {
  gROOT->SetStyle("HALLA");
  TCanvas *cn = new TCanvas("cn");
  cn->Draw();
  cn->UseCurrentStyle();
  TH1F *frm = new TH1F("frm","",100,0.,10.);
  frm->GetXaxis()->SetTitle("Q^{2}  [GeV^{2}]");
  frm->GetYaxis()->SetTitle("G_{E}^{n}/Gd");
  frm->SetMinimum(-.1);
  frm->SetMaximum(1.);
  frm->UseCurrentStyle();
  frm->Draw();
  frm->SetAxisRange(0.,5.,"X");

  TF1* galstergd = new TF1("galstergd",
			 "(1.+x/.71)*(1.+x/.71)*x/(4.*0.938*.938)*1.91/(1.+x/.71)^2/(1.+5.6*x/(4.*.938*.938))",
			 0.,4.);
  galstergd->SetLineColor(6);
  galstergd->SetLineStyle(3);
  galstergd->SetLineWidth(2);


  TF1 *genf = new TF1("genf",genff,1.,10.,1);
  genf->SetLineColor(2);
  genf->SetLineStyle(2);
  genf->SetParameter(0,1.);
  // match to Madey point just below 1.5
  // genf->SetParameter(0,.0411/genf->Eval(1.45));
  genf->SetParameter(0,-0.558645);

  TF1 *bbba05 = new TF1("BBBA05",gen_bbba05,0.,10.,0);
  bbba05->SetLineColor(7);
  bbba05->SetLineStyle(3);

 
  TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}/Gd");
  TLegend *legDta = new TLegend(.54,.6,.875,.90,"","brNDC");

  TMultiGraph* wgr = mgrDta;
  TLegend *wlg = legDta;

   // the data
  legDta->SetBorderSize(0); // turn off border
  legDta->SetFillStyle(0);
  
  datafile_t *f = datafiles;
  TGraph* gr=0;
  TGraph* ogr=0;
  while ( f && f->filename ) {
    ogr=OneGraph(f);
    if (ogr) {
      gr=fromGEntoGEnGd(ogr);
      if (f->lnpt) {
	mgrDta->Add(gr,f->lnpt);
	legDta->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	mgrDta->Add(gr,"p");
	legDta->AddEntry(gr,f->label,"p");
      }	
      else {
	mgrDta->Add(gr,"l");
	legDta->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }
    

  mgrDta->Draw("p");
  //  legDta->Draw();   don't draw the data legend
  
  TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}/Gd");
  TLegend *legThry = new TLegend(.54,.6,.875,.9,"","brNDC");

  wgr = mgrThry;
  wlg = legThry;

  // the theory
  wlg->SetBorderSize(0); // turn off border
  wlg->SetFillStyle(0);
  
  f = theoryfiles1;
  ogr=0;
  gr=0;
  while ( f && f->filename ) {
    ogr=OneGraph(f);
    if (ogr) {
      gr=fromGEntoGEnGd(ogr);
      TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
      if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
	gr = toerror_band(egr);
	gr->SetFillStyle(3000+f->style);
      }
      if (f->lnpt) {
	wgr->Add(gr,f->lnpt);
	wlg->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	wgr->Add(gr,"p");
	wlg->AddEntry(gr,f->label,"p");
      }	
      else {
	wgr->Add(gr,"l");
	wlg->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }

  genf->Draw("same");
  mgrThry->Draw("c");
  galstergd->Draw("same");
  bbba05->Draw("same");
  legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
  legThry->AddEntry(galstergd,"Galster fit","l");
  legThry->AddEntry(bbba05,"BBBA05","l");
  legThry->Draw();
  legDta->Draw();
  
  // draw a line at 1
  cn->Modified();

  cn->Update();
  cn->SaveAs(Form("%s.eps",psfile));
  cn->SaveAs(Form("%s.root",psfile));
  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));

  return;  // LEAVING HERE
}
コード例 #13
0
void PP_MC_normResponseMatrix(int radius = 3){

  gStyle->SetOptStat(0);
  
  bool printDebug = true;
  
  TFile * fin = TFile::Open(Form("pp_MC_new_ak%d_20_eta_20.root",radius));
  
  TH2F * mPP_Matrix;
  TH2F * mPP_Response;
  TH2F * mPP_ResponseNorm;
  TH2F * mPP_ResponseNorm_recoTrunc;

  // TH2F * mPbPb_Matrix_recoTrunc[nbins_cent];
  // TH2F * mPbPb_Response_recoTrunc[nbins_cent];
  // TH2F * mPbPb_ResponseNorm_recoTrunc[nbins_cent];

  TFile fout(Form("PP_kineticEfficiency_correctionFactors_R%d.root",radius),"RECREATE");
  fout.cd();
  
  TH1F * hGen_Projection;
  TH1F * hGen_Projection_recoTrunc;
  TH1F * hKineticEfficiency;

  TCanvas * cGenProj = new TCanvas("cGenProj","",800,600);
  TCanvas * cKineticEfficiency = new TCanvas("cKineticEfficiency","",800,600);  

  TCanvas * cMatrix = new TCanvas("cMatrix","",800,600);
  TCanvas * cMatrix_recoTrunc = new TCanvas("cMatrix_recoTrunc","",800,600);
  
  mPP_Matrix = (TH2F*)fin->Get(Form("hpp_matrix_HLT_R%d_20_eta_20",radius));
  mPP_Matrix->Rebin2D(10, 10);

  for (int y=1;y<=mPP_Matrix->GetNbinsY();y++) {
    double sum=0;
    for (int x=1;x<=mPP_Matrix->GetNbinsX();x++) {
      if (mPP_Matrix->GetBinContent(x,y)<=1*mPP_Matrix->GetBinError(x,y)) {
	mPP_Matrix->SetBinContent(x,y,0);
	mPP_Matrix->SetBinError(x,y,0);
      }
      sum+=mPP_Matrix->GetBinContent(x,y);
    }
    
    for (int x=1;x<=mPP_Matrix->GetNbinsX();x++) {	   
      double ratio = 1;
      // if (hGenSpectraCorrPP->GetBinContent(x)!=0) ratio = 1e5/hGenSpectraCorrPP->GetBinContent(x);
      mPP_Matrix->SetBinContent(x,y,mPP_Matrix->GetBinContent(x,y)*ratio);
      mPP_Matrix->SetBinError(x,y,mPP_Matrix->GetBinError(x,y)*ratio);
    }
  }
  // mPbPb_Matrix[i]->Smooth(0);
  
  // Ok major differences here between my code and Kurt in b-jet Tools under Unfold - lines 469 and above.  

  if(printDebug) cout<<"getting the response matrix"<<endl;

  mPP_Response = (TH2F*)mPP_Matrix->Clone("mPP_Response");
  TH1F *hProjPP = (TH1F*)mPP_Response->ProjectionY()->Clone("hProjPP");
  
  
  for (int y=1;y<=mPP_Response->GetNbinsY();y++) {
    double sum=0;
    for (int x=1;x<=mPP_Response->GetNbinsX();x++) {
      if (mPP_Response->GetBinContent(x,y)<=1*mPP_Response->GetBinError(x,y)) {
	// in the above if statement, kurt has 1*error and my old has 0*error
	mPP_Response->SetBinContent(x,y,0);
	mPP_Response->SetBinError(x,y,0);
      }
      sum+=mPP_Response->GetBinContent(x,y);
    }
    
    for (int x=1;x<=mPP_Response->GetNbinsX();x++) {  	
      if (sum==0) continue;
      double ratio = 1;
      //if(dPbPb_TrgComb[i]->GetBinContent(y)==0) ratio = 1e-100/sum;
      // else ratio = dPbPb_TrgComb[i]->GetBinContent(y)/sum
      ratio = 1./sum;
      if (hProjPP->GetBinContent(y)==0) ratio = 1e-100/sum;
      else ratio = hProjPP->GetBinContent(y)/sum;
      mPP_Response->SetBinContent(x,y,mPP_Response->GetBinContent(x,y)*ratio);
      mPP_Response->SetBinError(x,y,mPP_Response->GetBinError(x,y)*ratio);
    }
  }
  if(printDebug) cout<<"getting the normalized response matrix"<<endl;
  mPP_ResponseNorm = (TH2F*)mPP_Matrix->Clone("mPP_ResponseNorm");
  for (int x=1;x<=mPP_ResponseNorm->GetNbinsX();x++) {
    double sum=0;
    for (int y=1;y<=mPP_ResponseNorm->GetNbinsY();y++) {
      if (mPP_ResponseNorm->GetBinContent(x,y)<=1*mPP_ResponseNorm->GetBinError(x,y)) {
	mPP_ResponseNorm->SetBinContent(x,y,0);
	mPP_ResponseNorm->SetBinError(x,y,0);
      }
      sum+=mPP_ResponseNorm->GetBinContent(x,y);
    }
    
    for (int y=1;y<=mPP_ResponseNorm->GetNbinsY();y++) {  	
      if (sum==0) continue;
      double ratio = 1./sum;
      mPP_ResponseNorm->SetBinContent(x,y,mPP_ResponseNorm->GetBinContent(x,y)*ratio);
      mPP_ResponseNorm->SetBinError(x,y,mPP_ResponseNorm->GetBinError(x,y)*ratio);
    }
    
    
  }

  
  hGen_Projection = (TH1F*)mPP_ResponseNorm->ProjectionX();
  hGen_Projection->SetName("hGen_Projection");
  // hGen_Projection->Rebin(10);

  cout<<"Finished getting histograms for full untruncated response matrix"<<endl;

  mPP_ResponseNorm_recoTrunc = (TH2F*)mPP_ResponseNorm->Clone("mPP_ResponseNorm_recoTrunc");

  for(int x = 0; x < mPP_ResponseNorm->GetNbinsX(); ++x){

    for(int y = 0; y < mPP_ResponseNorm->GetNbinsY(); ++y){

      if(y < mPP_ResponseNorm->GetYaxis()->FindBin(50) || y > mPP_ResponseNorm->GetYaxis()->FindBin(350)){
	mPP_ResponseNorm_recoTrunc->SetBinContent(x, y, 0.0);
	mPP_ResponseNorm_recoTrunc->SetBinError(x, y, 0.0);
      }
	
    }
      
  }
    
  hGen_Projection_recoTrunc = (TH1F*)mPP_ResponseNorm_recoTrunc->ProjectionX();
  hGen_Projection_recoTrunc->SetName("hGen_Projection_recoTrunc");
  // hGen_Projection_recoTrunc->Rebin(10);

  cout<<"finished getting histograms for truncted response matrix"<<endl;
    
  hKineticEfficiency = (TH1F*)hGen_Projection_recoTrunc->Clone("hKineticEfficiency");
  hKineticEfficiency->Divide(hGen_Projection);

  for(int bin = 1; bin<=hKineticEfficiency->GetNbinsX(); ++bin){
    double val = hKineticEfficiency->GetBinContent(bin);
    val = 1./val;
    hKineticEfficiency->SetBinContent(bin, val);
  }

  cout<<"Plotting kinetic efficiency"<<endl;
    
  cKineticEfficiency->cd();

  hKineticEfficiency->SetTitle(" ");
  hKineticEfficiency->SetXTitle("Gen p_{T} (GeV/c)");
  hKineticEfficiency->SetYTitle("Kinetic Efficiency");

  hKineticEfficiency->SetMarkerStyle(20);
  hKineticEfficiency->SetMarkerColor(kBlack);
  hKineticEfficiency->SetAxisRange(60, 299, "X");
  hKineticEfficiency->SetAxisRange(0.98, 1.05, "Y");
  hKineticEfficiency->Draw();

  drawText("PYTHIA, Kinetic Efficiency", 0.25,0.7,14);
  drawText(Form("ak%dPF Jets",radius), 0.25, 0.65, 14);
    
  cout<<"Finished plotting kinetic efficiency"<<endl;

  cGenProj->cd();
  hGen_Projection->SetTitle(" ");
  hGen_Projection->SetXTitle("Gen p_{T} (GeV/c)");
  hGen_Projection->SetYTitle("GenProjection of Normalized Response Matrix");
  hGen_Projection->Scale(1./10);
  hGen_Projection->SetMarkerStyle(33);
  hGen_Projection->SetMarkerColor(kBlack);
  hGen_Projection->SetAxisRange(20, 350, "X");
  hGen_Projection->SetAxisRange(0.6, 1.4, "Y");
  hGen_Projection->Draw();

  hGen_Projection_recoTrunc->Scale(1./10);
  hGen_Projection_recoTrunc->SetMarkerStyle(25);
  hGen_Projection_recoTrunc->SetMarkerColor(kRed);
  hGen_Projection_recoTrunc->Draw("same");

  drawText("PYTHIA, Projection onto Gen axis", 0.25,0.7,14);
  drawText(Form("ak%dPF Jets",radius), 0.25, 0.65, 14);
    
  TLegend * leg = myLegend(0.3,0.6,0.7,0.7);
  leg->AddEntry(hGen_Projection,"No Truncation in Reco pT","pl");
  leg->AddEntry(hGen_Projection_recoTrunc,"reco pT truncated 40 to 350 GeV","pl");
  leg->SetTextSize(0.04);
  leg->Draw();


  cMatrix->cd();
  // mPP_ResponseNorm->Rebin2D(10, 10);
  // mPP_ResponseNorm->Scale(1./TMath::Sqrt(10));
  makeHistTitle(mPP_ResponseNorm," ","Gen p_{T} (GeV/c)","Reco p_{T} (GeV/c)");
  mPP_ResponseNorm->SetAxisRange(0, 500, "X");
  mPP_ResponseNorm->SetAxisRange(0, 500, "Y");
  mPP_ResponseNorm->SetAxisRange(0.001, 1, "Z");
  mPP_ResponseNorm->Draw("colz");  
  drawText("PYTHIA", 0.15,0.8,14);
  drawText(Form("ak%dPF Jets",radius), 0.15, 0.75, 14);

  
  cMatrix_recoTrunc->cd();
  // mPP_ResponseNorm_recoTrunc->Rebin2D(10, 10);
  // mPP_ResponseNorm_recoTrunc->Scale(1./TMath::Sqrt(10));
  makeHistTitle(mPP_ResponseNorm_recoTrunc," ","Gen p_{T} (GeV/c)","Reco p_{T} (GeV/c)");
  mPP_ResponseNorm_recoTrunc->SetAxisRange(0, 500, "X");
  mPP_ResponseNorm_recoTrunc->SetAxisRange(0, 500, "Y");
  mPP_ResponseNorm_recoTrunc->SetAxisRange(0.001, 1, "Z");
  mPP_ResponseNorm_recoTrunc->Draw("colz");  
  drawText("PYTHIA, reco p_{T} truncated", 0.15,0.8,14);
  drawText(Form("ak%dPF Jets",radius), 0.15, 0.75, 14);
  
  cKineticEfficiency->SaveAs(Form("KineticEfficiency_R%d_PPMC.pdf",radius),"RECREATE");
  cGenProj->SaveAs(Form("GenProjection_R%d_PPMC.pdf",radius),"RECREATE");
  cMatrix->SaveAs(Form("ResponseMatrix_R%d_PPMC.pdf",radius),"RECREATE");
  cMatrix_recoTrunc->SaveAs(Form("ResponseMatrix_recoTrunc_R%d_PPMC.pdf",radius),"RECREATE");
  
  
  fout.Write();
  fout.Close();
  
}
コード例 #14
0
void makeRisetimeDistributionT9(string filename, string plotname, string plotTitle,
			      double ampCutOnMCP, double ampCutOnLYSO, double ampCutOnTrigger,
			    double beamXMin, double beamXMax, double beamYMin, double beamYMax,
			    int nbins, double xmin, double xmax, double fitmin, double fitmax) {


  TFile *inputfile = TFile::Open(filename.c_str(),"READ");
  
  TTree *tree = (TTree*)inputfile->Get("t1065");

  // get the variables from the ntuple
  float amp[36];
  float risetime[36];
  float gauspeak[36];
  float linearTime30[36];
  float beamX;
  float beamY;

  tree->SetBranchStatus("*",0);
  tree->SetBranchStatus("gauspeak",1);
  tree->SetBranchStatus("amp",1);
  tree->SetBranchStatus("risetime",1);
  tree->SetBranchStatus("linearTime30",1);
  tree->SetBranchStatus("TDCx",1);
  tree->SetBranchStatus("TDCy",1);
  tree->SetBranchAddress("gauspeak",gauspeak);
  tree->SetBranchAddress("amp",amp);
  tree->SetBranchAddress("risetime",risetime);
  tree->SetBranchAddress("linearTime30",linearTime30);
  tree->SetBranchAddress("TDCx",&beamX);
  tree->SetBranchAddress("TDCy",&beamY);

  //create histograms
  TH1F *histRisetime;
  histRisetime = new TH1F("histRisetime","; Integrated Charge [pC];Number of Events", nbins, xmin, xmax);

  
  //read all entries and fill the histograms
  Long64_t nentries = tree->GetEntries();

  std::cout<<"Number of events in Sample: "<<nentries<<std::endl;  
  for (Long64_t iEntry=0;iEntry<nentries;iEntry++) {
    if (iEntry %1000 == 0) 
      cout << "Processing Event " << iEntry << "\n";
    tree->GetEntry(iEntry);    
    // cout << "here1\n";
    float MCPTimeGauss = gauspeak[0];
    float CdTeTime = linearTime30[1];
    float MCPAmp = amp[0];
    float LYSOAmp = amp[2];
    float TriggerAmp = amp[3];
    float CherenkovAmp = amp[7];
    float CdTeAmp = amp[1]*(1.0/63.0957);
    float CdTeRisetime = risetime[1];
    // cout << "here2\n";
       
    //use MCP amplitude cut for electron ID
    //cout << "test: " << MCPAmp << " " << siliconIntegral << "\n";
    if( !(MCPAmp > ampCutOnMCP)) continue;
    if( !(TriggerAmp > ampCutOnTrigger)) continue;
    if( !(LYSOAmp > ampCutOnLYSO)) continue;
    if(!(beamX > beamXMin && beamX < beamXMax)) continue;
    if(!(beamY > beamYMin && beamY < beamYMax)) continue;
     // cout << "here3\n";

    //don't fill overflow bins
    //if (1000* siliconIntegral * attenuationFactor / amplificationFactor > xmax) continue;
    
    histRisetime->Fill( CdTeRisetime );

    //cout << CdTeRisetime << " " << beamX << " " << beamY << " " << CdTeAmp << "\n";

    //cout << 1000* amp[21] << " : " << amplificationFactor << " : " << siliconIntegral * attenuationFactor / amplificationFactor << "\n";
 
  }


  TCanvas * c = 0;


  //Energy plot
  c = new TCanvas("c","c",600,600);  
  c->SetRightMargin(0.05);
  c->SetLeftMargin(0.17);
  histRisetime->SetAxisRange(xmin,xmax,"X");
  histRisetime->SetTitle("");
  histRisetime->GetXaxis()->SetTitle("Risetime [ns]");
  histRisetime->GetXaxis()->SetTitleSize(0.045);
  histRisetime->GetXaxis()->SetLabelSize(0.045);
  histRisetime->GetYaxis()->SetTitle("Number of Events");
  histRisetime->GetYaxis()->SetTitleOffset(1.3);
  histRisetime->GetYaxis()->SetTitleSize(0.05);
  histRisetime->GetYaxis()->SetLabelSize(0.045);
  histRisetime->GetYaxis()->SetLabelOffset(0.015);
  histRisetime->GetYaxis()->SetTitleOffset(1.7);
  histRisetime->SetMaximum(1.2*histRisetime->GetMaximum());
  histRisetime->Draw();
  histRisetime->SetStats(0);
  histRisetime->Fit("gaus","","",fitmin,fitmax);
  TVirtualFitter * fitter = TVirtualFitter::GetFitter();
  
  TLatex *tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSize(0.050);
  tex->SetTextFont(42);
  tex->SetTextColor(kBlack);
  tex->DrawLatex(0.45, 0.85, Form("Mean = %.2f %s",fitter->GetParameter(1),"ns"));
  tex->DrawLatex(0.45, 0.80, Form("#sigma = %.2f %s",fitter->GetParameter(2),"ns"));

  tex->DrawLatex(0.18, 0.93, Form("%s", plotTitle.c_str()));

  c->SaveAs( Form("%s_risetime.gif", plotname.c_str()) );
  c->SaveAs( Form("%s_risetime.pdf", plotname.c_str()) );
 

}
コード例 #15
0
//--------------------------------------------------------------------------------------------------
// Make plots of fake rates for different charges
//--------------------------------------------------------------------------------------------------
void compareChargeDependantFakeRates(char *FakeRateFilename , string sampleName, int denominatortype, int faketype, 
                                     int onlychargetype = -1000, int onlyeventType = -1000 ) {

  string fakeTypeString = "";
  if (faketype == 11) {
    fakeTypeString = "Electron";
  } else if (faketype == 13) {
    fakeTypeString = "Muon";
  } else {
    cerr << "Error: faketype = " << faketype << " not recognized.\n";
    assert(false);
  }

  string denominatorTypeString = "";
  if (denominatortype == 1) {
    denominatorTypeString = "TrackDenominator";
  }

  string plotname = "ChargeDependant" + fakeTypeString + denominatorTypeString + "FakeRateComparison_" + sampleName;

  TCanvas *cv = MakeCanvas("cv", plotname.c_str(), 800, 600);
  TLegend *leg1=0;
  leg1 = new TLegend(0.65,0.6,0.9,0.8);   
  leg1->SetBorderSize(1);
  leg1->SetTextSize(0.03);

  int color = 0;
  for (int chargetype = -1; chargetype <= 1; chargetype += 2) {
    for (int eventType= -1; eventType <= 1; eventType ++) {

      if (!(onlychargetype == chargetype || onlychargetype == -1000))
        continue;

      if (onlyeventType == 0) {
        if (eventType != 0)
          continue;
      } else {
        if (eventType == 0)
          continue;
      }

      //different charges
      string chargeTypeName = "";
      string LegendString = sampleName + " ";

      string eventTypeName = "";
      if (eventType == -1) {
        eventTypeName = "MinusW";
        LegendString += "-";
      } else if (eventType == 1) {
          eventTypeName = "PlusW";
          LegendString += "+";
      } else if (eventType == 0)
        LegendString += "Fake";
        
      if (chargetype == -1) {
        chargeTypeName = "Minus";
        LegendString += "-";
      } else if (chargetype == 1) {
        chargeTypeName = "Plus";
        LegendString += "+";
      }
           
      TFile *file = new TFile(FakeRateFilename, "READ");
      file->cd();
      
      TH1F *tmp = (TH1F*)file->FindObjectAny((chargeTypeName + fakeTypeString + eventTypeName + denominatorTypeString + "FakeRate_Pt_" + sampleName).c_str());
      if (!tmp) {
        cerr << "can't find :"  << chargeTypeName + fakeTypeString + eventTypeName + denominatorTypeString + "FakeRate_Pt_" + sampleName << endl;
        assert(tmp);
      }
      tmp->SetLineColor(COLORS[color]);
      tmp->SetMarkerColor(COLORS[color]);    
      tmp->SetAxisRange(0,100);

      color++;
      leg1->AddEntry(tmp, LegendString.c_str(), "LP");
      if (chargetype == -1 && eventType == -1)
        tmp->Draw();
      else 
        tmp->Draw("same");
    }
  }
  
  leg1->Draw();

  string filename = plotname + ".gif";
  cv->SaveAs(filename.c_str());
  cv->Delete();
}
コード例 #16
0
void plotCutFlowNotStaggered(  FileList fileList , float Lumi_ = 30, 
		   float pt1_ = 20., float pt2_ = 15, float DEta_ = 1.0, float Mjj_ = 300. , float jetVeto_ = 15,
		   float signalScale_ = 1.0) {
  
  for(int i = 0; i<fileList.size(); i++){
    (fileList[i].first)->Close();
    delete (fileList[i].first);
  }

  TFile* fVBF115 = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_VBFH115.root","READ");
  TFile* fVBF135 = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_VBFH135.root","READ");
  TFile* fDYJets = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_DYJets-madgraph-50-PU.root","READ");
  TFile* fTT     = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_TT-madgraph-PU.root","READ");
  TFile* fWJets  = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_WJets-madgraph-PU.root","READ");
  TFile* fT      = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_TToBLNu-tW-madhraph-PU.root","READ");
  TFile* fQCD    = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_QCD-pythia-PU.root","READ");

  FileList fileList_;
  fileList_.push_back( make_pair(fT,      make_pair("tW",        10.6      )  ));
  fileList_.push_back( make_pair(fTT,     make_pair("ttbar",    157.5      )  ));
  fileList_.push_back( make_pair(fDYJets, make_pair("Zjets",   3048.0      )  ));
  fileList_.push_back( make_pair(fWJets,  make_pair("Wjets",  31314.0      )  ));
  fileList_.push_back( make_pair(fQCD,    make_pair("QCD",   349988.0      )  ));
  fileList_.push_back( make_pair(fVBF115, make_pair("qqH115",       0.1012 )  ));
  fileList_.push_back( make_pair(fVBF135, make_pair("qqH135",       0.05049)  ));
 

  TCanvas *c1 = new TCanvas("c1CutFlowNotStaggeredMass","",5,30,650,600);
  c1->SetGrid(0,0);
  c1->SetFillStyle(4000);
  c1->SetFillColor(10);
  c1->SetTicky();
  c1->SetObjectStat(0);
  c1->SetLogy(1);


  TPad* pad1 = new TPad("pad1CutFlowNotStaggeredMass","",0.05,0.27,0.96,0.97);
  TPad* pad2 = new TPad("pad2CutFlowNotStaggeredMass","",0.05,0.02,0.96,0.26);
  pad1->SetFillColor(0);
  pad2->SetFillColor(0);
  pad1->Draw();
  pad2->Draw();

  pad1->cd();
  pad1->SetLogy(1);

  TLegend* leg = new TLegend(0.60,0.47,0.90,0.85,NULL,"brNDC");
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(0.04);
  leg->SetHeader( "Cut Flow" );
  
  vector<TH1F*> histos;
  histos.clear();

  TH1F* hqqH115 = new TH1F();
  TH1F* hqqH135 = new TH1F();
  TH1F* hSiml   = new TH1F();

  vector< pair<string,string> > cutList;
  cutList.push_back(make_pair("vertexScarpingFilter/totalEvents","good vertex"));
  cutList.push_back(make_pair("oneMuonFilter/totalEvents","one gl. muon p_{T}>15 GeV"));
  cutList.push_back(make_pair("noElecFilter/totalEvents","electron veto"));
  cutList.push_back(make_pair("muonLegFilter/totalEvents","#mu cuts"));
  cutList.push_back(make_pair("tauLegFilter/totalEvents","#tau cuts"));
  cutList.push_back(make_pair("atLeastOneDiTauFilter/totalEvents","OS + m_{T} cut"));
  vector<float> cutFlow; 

  float signalScale = 1;

  for(unsigned int i = 0 ; i < fileList_.size() ; i++){

    signalScale = 1;

    TFile* currentFile = (TFile*)fileList_[i].first ;
    if( currentFile->IsZombie() ) continue;
    TH1F* allEvents = (TH1F*)currentFile->Get("allEventsFilter/totalEvents");
    float totalEvents = allEvents->GetBinContent(1);

    cutFlow.clear();
    for(int m = 0; m<cutList.size(); m++){
      TH1F* tmph1 =  (TH1F*)currentFile->Get( (cutList[m].first).c_str() );
      if(tmph1!=0){
	cutFlow.push_back( tmph1->GetBinContent(1) );
	//cout << tmph1->GetBinContent(1) << endl;
      }
    }

    TTree* currentTree = (TTree*)currentFile->Get("muTauStreamAnalyzer/tree");
    string h1Name = "h1_"+(fileList_[i].second).first;
    TH1F* h1 = new TH1F( h1Name.c_str() ,"", (int)(cutFlow.size()+3) ,0 , cutFlow.size()+3);

    if( ((fileList_[i].second).first).find("Zjets")!=string::npos ) {
      h1->SetLineColor(kRed);
      leg->AddEntry(h1,"MadGraph Z+jets","F");
    }
    if( ((fileList_[i].second).first).find("ttbar")!=string::npos ) {
      h1->SetLineColor(kBlue);
      leg->AddEntry(h1,"MadGraph t#bar{t}+jets","F");
    }
    if( ((fileList_[i].second).first).find("Wjets")!=string::npos ) {
      h1->SetLineColor(kGreen);
      leg->AddEntry(h1,"MadGraph W+jets","F");
    }
    if( ((fileList_[i].second).first).find("tW")!=string::npos ){
      h1->SetLineColor( 44 );
      leg->AddEntry(h1,"MadGraph single-top","F");
    }
    if( ((fileList_[i].second).first).find("QCD")!=string::npos ) {
      h1->SetLineColor(11);
      leg->AddEntry(h1,"Pythia QCD","F");
    }
    if( ((fileList_[i].second).first).find("qqH115")!=string::npos ) {
      h1->SetLineColor(kBlack);
      h1->SetLineStyle(kDashed);
      h1->SetLineWidth(3.0);
      signalScale = signalScale_;
      leg->AddEntry(h1,Form("VBF H(115)#rightarrow#tau#tau X %.0f",signalScale),"l");
    }
    if( ((fileList_[i].second).first).find("qqH135")!=string::npos ) {
      h1->SetLineColor(kBlack);
      h1->SetLineStyle(kDotted);
      h1->SetLineWidth(3.0);
      signalScale = signalScale_;
      leg->AddEntry(h1,Form("VBF H(135)#rightarrow#tau#tau X %.0f",signalScale),"l");
    }

    h1->SetBinContent(1,totalEvents);
    h1->GetXaxis()->SetBinLabel(1,"#sigma*BR*#int L");  
    for(int m = 0; m<cutFlow.size(); m++){
      h1->SetBinContent(m+2,cutFlow[m]);
      h1->GetXaxis()->SetBinLabel(m+2, (cutList[m].second).c_str() ); 
    }
    h1->GetXaxis()->SetBinLabel(cutFlow.size()+2,"VBF 1%");
    h1->GetXaxis()->SetBinLabel(cutFlow.size()+3,"CJV (15 GeV)");
   
    int nEntries = currentTree->GetEntries() ;    
    
    std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >* diTauSVfit3;
    std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >* jets;
    
    currentTree->SetBranchAddress("diTauSVfit3P4",&diTauSVfit3);
    currentTree->SetBranchAddress("jetsIDP4",&jets);
    
    for (int n = 0; n < nEntries ; n++) {
      
      currentTree->GetEntry(n);
   

      if( diTauSVfit3->size() < 1) continue;
      bool vbfCut = false;
      bool jetVeto = false;
      if( jets->size()>1 && 
	  (*jets)[0].Et()>pt1_ && (*jets)[1].Et()>pt2_ && 
	  abs((*jets)[0].Eta()-(*jets)[1].Eta())>DEta_ && 
	  ((*jets)[0]+(*jets)[1]).M()>Mjj_ ) vbfCut = true;
      for(unsigned k=0; k < jets->size(); k++){
	if(k>1 && 
	   (  ((*jets)[k].Eta()>(*jets)[1].Eta()+0.5 &&  (*jets)[k].Eta()<(*jets)[0].Eta()-0.5) || 
	      ((*jets)[k].Eta()>(*jets)[0].Eta()+0.5 &&  (*jets)[k].Eta()<(*jets)[1].Eta()-0.5) ) &&
	   (*jets)[k].Et()>jetVeto_ ) jetVeto=true;  
      }
      
      if(vbfCut)  h1->Fill( cutFlow.size()+1.5 ) ;      
      if(vbfCut && !jetVeto)  h1->Fill( cutFlow.size()+2.5 ) ;      
    
    }
   

    h1->Scale( Lumi_ / (totalEvents/((fileList_[i].second).second * signalScale)) );

    if(((fileList_[i].second).first).find("qqH115")!=string::npos){
      hqqH115=(TH1F*)h1->Clone("hqqH115");
      hqqH115 = h1;
      hqqH115->Sumw2();
      continue;
    }
    if(((fileList_[i].second).first).find("qqH135")!=string::npos){
      hqqH135=(TH1F*)h1->Clone("hqqH135");
      hqqH135 = h1;
      hqqH135->Sumw2();
      continue;
    }

    if(i==0) hSiml=(TH1F*)h1->Clone("hSiml");
    else hSiml->Add(h1);

    histos.push_back(h1);

  }

  //float numData = hData->GetEntries();
  //float numSiml = hSiml->Integral();
  //float dataToSimlRatio = numData/numSiml;
  //cout << "data " << numData << "  ---  simul " << numSiml << endl;  

  hqqH115->SetTitle(Form("CMS Preliminary 2010    #sqrt{s}=7 TeV L=%.0f pb^{-1}",Lumi_));
  hqqH115->SetXTitle("");
  hqqH115->SetYTitle("Number of events");
  hqqH115->SetTitleSize(0.05,"X");
  hqqH115->SetTitleSize(0.05,"Y");
  hqqH115->SetTitleOffset(0.75,"Y");
  hqqH115->SetAxisRange(0.1,hSiml->GetMaximum()*1.2,"Y");

  hqqH115->Draw("HIST");
  hqqH135->Draw("HISTSAME");
  for(int p = 0; p<histos.size(); p++){
    histos[p]->Draw("HISTSAME");
  }


  leg->Draw();

  pad2->cd();
  TH1F* hRatio = new TH1F("hRatio", " ; ; purity",
			  hqqH115->GetNbinsX(), 
			  hqqH115->GetXaxis()->GetXmin(), hqqH115->GetXaxis()->GetXmax());
  hRatio->SetLineStyle(kDashed);
  hRatio->SetLineWidth(1.0);
  hRatio->SetLabelSize(0.12,"X");
  hRatio->SetLabelSize(0.10,"Y");
  hRatio->SetTitleSize(0.12,"Y");
  hRatio->SetTitleOffset(0.36,"Y");
  TH1F* hqqH115Clone = (TH1F*)hqqH115->Clone("hqqH115Clone");
  TH1F* hqqH135Clone = (TH1F*)hqqH135->Clone("hqqH135Clone");
  hqqH115Clone->Divide( hqqH115 ,hSiml,1./signalScale,1.0);
  hqqH135Clone->Divide( hqqH135 ,hSiml,1./signalScale,1.0);
  hRatio->SetAxisRange(0.,0.1,"Y");

  hRatio->Draw();
  hqqH115Clone->Draw("HISTSAME");
  hqqH135Clone->Draw("HISTSAME");

  if(SAVE) c1->SaveAs("Zmm_CutFlowNotStaggeredMass.png");

}
コード例 #17
0
ファイル: trackingStudyTrkEta.C プロジェクト: yenjie/pPbAna
void trackingStudyTrkEta(char *infname = "skim_jet_pthat80Sim05.root")
{
   HiForest *c = new HiForest(infname);
   c->tree->AddFriend("nt");

   TCut trackSelection = "(mtrkQual||mtrkAlgo<4)&&pNRec>0";
   TCut genParticleCut = "abs(pEta)<2.8&&pPt>0";

   TCut weightCent = "1";//"(0.64661/(0.64661+0.00279303*hiBin+(-3.89902e-5)*hiBin*hiBin)*(hiBin<34)+(hiBin>=34)*0.64661/(-1.38822+0.123182*hiBin-0.0018135*hiBin*hiBin))";

   TCut weight = "1";//"1./(0.757356-0.030163*pEta-0.0769554*pEta**2+0.0176546*pEta**3+0.0200791*pEta**4-0.00256533*pEta**5-0.00304287*pEta**6)";    
   TCanvas *cpPt = new TCanvas ("cpPt","",600,600);
   
   TH1F *hEffpPt = new TH1F("hEffpPt","",28,-2.8,2.8);
   
   makeHistTitle(hEffpPt,"","SimTrack #eta","Tracking Efficiency");
   
   TGraphAsymmErrors *g = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>0.5")&&genParticleCut,weight*weightCent);
   TGraphAsymmErrors *g1 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>0.5&&pPt<1")&&genParticleCut,weight*weightCent);
   TGraphAsymmErrors *g2 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>1&&pPt<2")&&genParticleCut,weight*weightCent);
   TGraphAsymmErrors *g3 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>2&&pPt<4")&&genParticleCut,weight*weightCent);
   TGraphAsymmErrors *g4 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>4&&pPt<8")&&genParticleCut,weight*weightCent);
   TGraphAsymmErrors *g5 = getEfficiency(c->tree,"pEta",28,-2.8,2.8,trackSelection,TCut("pPt>8")&&genParticleCut,weight*weightCent);

   hEffpPt->SetAxisRange(0.,1,"Y");
   hEffpPt->Draw();
   
   g->Draw("p same");
   g1->SetLineColor(2);
   g1->SetMarkerColor(2);
   g1->Draw("p same");
   g2->SetLineColor(3);
   g2->SetMarkerColor(3);
   g2->Draw("p same");
   
   g3->SetLineColor(4);
   g3->SetMarkerColor(4);
   g3->Draw("p same");

   g4->SetLineColor(46);
   g4->SetMarkerColor(46);
   g4->Draw("p same");

   g5->SetLineColor(kOrange);
   g5->SetMarkerColor(kOrange);
   g5->Draw("p same");

   TLegend *legpPt = myLegend(0.2,0.7,0.6,0.9);
   legpPt->AddEntry(g,"#hat{p}_{T} 80 GeV/c, No selection","");
   legpPt->AddEntry(g,"Simtrack p_{T} > 0.5 GeV/c","pl");
   legpPt->AddEntry(g1,"Simtrack 0.5 > p_{T} > 1 GeV/c","pl");
   legpPt->AddEntry(g2,"Simtrack 1 > p_{T} > 2 GeV/c","pl");
   legpPt->AddEntry(g3,"Simtrack 2 > p_{T} > 4 GeV/c","pl");
   legpPt->AddEntry(g4,"Simtrack 4 > p_{T} > 8 GeV/c","pl");
   legpPt->AddEntry(g5,"Simtrack p_{T} > 8 GeV/c","pl");
   
   legpPt->Draw();
   cpPt->SaveAs("effFig/EffVsTrackPt.gif");
   cpPt->SaveAs("effFig/EffVsTrackPt.C");

   g->Fit("pol6")   ;
}
コード例 #18
0
void quickPhotonPurity_yj_multiTreeUtil(const TString configFile, const TString inputData, const TString inputMC, const TString outputName, const TString coll="pbpb")
{
  TH1::SetDefaultSumw2();
  CutConfiguration config = CutConfigurationParser::Parse(configFile.Data());
  TTree *configTree = setupConfigurationTreeForWriting(config);
   const char* photreeSt="";
   const char* hitreeSt="";
  if(coll=="pbpb") {
      photreeSt="EventTree";
      hitreeSt="HiTree";
  } else {
      photreeSt="ggHiNtuplizer/EventTree";
      hitreeSt="hiEvtAnalyzer/HiTree";
  } 

  TFile *dataFile = TFile::Open(pbpbDatafname);
  //TFile *dataFile = TFile::Open(inputData);
  TTree *dataTree = (TTree*)dataFile->Get(photreeSt);
  TTree *dataEvtTree = (TTree*)dataFile->Get(hitreeSt);
//  TTree *dataTree = (TTree*)dataFile->Get("ggHiNtuplizer/EventTree");
//  TTree *dataEvtTree = (TTree*)dataFile->Get("hiEvtAnalyzer/HiTree");
  //TTree *dataTree = (TTree*)dataFile->Get("photonSkimTree");

  dataTree->AddFriend(dataEvtTree);
  TFile *mcFile = TFile::Open(pbpbMCfname);
  //TFile *mcFile = TFile::Open(inputMC);
  TTree *mcTree = (TTree*)mcFile->Get("ggHiNtuplizer/EventTree");
  TTree *mcEvtTree = (TTree*)mcFile->Get("hiEvtAnalyzer/HiTree");
  //TTree *mcTree = (TTree*)mcFile->Get("photonSkimTree");
    mcTree->AddFriend(mcEvtTree);
  TFile *outFile = new TFile(outputName,"RECREATE");

  const TCut sidebandIsolation = "((pho_ecalClusterIsoR4 + pho_hcalRechitIsoR4 + pho_trackIsoR4PtCut20)>10) && ((pho_ecalClusterIsoR4 + pho_hcalRechitIsoR4 + pho_trackIsoR4PtCut20)<20) && phoHoverE<0.1";
  const TCut mcIsolation = "(pho_genMatchedIndex!= -1) && mcCalIsoDR04[pho_genMatchedIndex]<5 && abs(mcPID[pho_genMatchedIndex])<=22";
    cout << "JJ" << endl;
  //TCanvas *cPurity[nPTBINS];
  //TCanvas *cPurity = new TCanvas("c1","c1",337*nPTBINS,300*nCENTBINS/**2*/);
  TCanvas *cPurity = new TCanvas("c1","c1",400*nPTBINS,400*nCENTBINS);
  //cPurity->Divide(nPTBINS,2*nCENTBINS,0,0);
  //cPurity->Divide(nPTBINS,nCENTBINS,0,0);
  makeMultiPanelCanvas(cPurity, nPTBINS, nCENTBINS, 0.0, 0.0 , 0.2, 0.15, 0.005);
  cout << "nPTBINS = " << nPTBINS << ", nCENTBINS = " << nCENTBINS << ", nETABINS = " << nETABINS << endl;
  for(Int_t i = 0; i < nPTBINS; ++i) {
    cout << "i : " << i << endl;
    //cPurity[i] = new TCanvas(Form("c1_%d",i),"",1920,1000);
    //cPurity[i]->Divide(nETABINS,2,0,0);
    for(Int_t j = 0; j < nCENTBINS; ++j) {
    cout << "j : " << j << endl;
      for(Int_t k = 0; k< nETABINS; ++k) {
    cout << "k : " << k << endl;
	TString ptCut = Form("(phoEt >= %f) && (phoEt < %f)",
			     PTBINS[i], PTBINS[i+1]);
	TString centCut = Form("((hiBin) >= %i) && ((hiBin) < %i)",
			     CENTBINS[j], CENTBINS[j+1]);
	TString etaCut = Form("(phoEta >= %f) && (phoEta < %f)",
			      ETABINS[k], ETABINS[k+1]);

	//TString pPbflipetaCut = Form("(eta*((run>211257)*-1+(run<211257)) >=%f) && (eta*((run>211257)*-1+(run<211257)) <%f)",
	//			     ETABINS[k], ETABINS[k+1]);

	TCut dataCandidateCut = sampleIsolation && etaCut && ptCut && centCut;
	TCut sidebandCut =  sidebandIsolation && etaCut && ptCut && centCut;
	TCut mcSignalCut = dataCandidateCut && mcIsolation;

	// if(nETABINS != 1)
	// {
	//   dataCandidateCut = sampleIsolation && pPbflipetaCut && ptCut && centCut;
	//   sidebandCut =  sidebandIsolation && pPbflipetaCut && ptCut && centCut;
	//   mcSignalCut =  sampleIsolation && etaCut && ptCut && centCut && mcIsolation;
	// }

	PhotonPurity fitr = getPurity(config, dataTree, mcTree,
				      dataCandidateCut, sidebandCut,
				      mcSignalCut);

	//cPurity[i*nCENTBINS+j] = new TCanvas(Form("cpurity%d",i*nCENTBINS+j),
	// 					 "",500,500);
    cout << "centBin = " << centCut << ", ptBin : " << ptCut << ",,,, canvas # : "<<2*(k+j)*nPTBINS+i+1 << endl;
    cout << "k = " << k << ", j = " << j << ", i = " << i << endl;
    //cPurity->cd(2*(k+j)*nPTBINS+i+1);
	cPurity->cd((k+j)*nPTBINS+i+1);
	//cPurity[i]->cd(k+1);

	TH1F *hSigPdf = fitr.sigPdf;
	TH1F *hBckPdf = fitr.bckPdf;
	TH1D *hData1  = fitr.data;
	hSigPdf->Add(hBckPdf);

	TString name = "mcfit_total_ptbin";
	name += i;

	// outFile->cd();
	// hSigPdf->SetName(name);
	// hSigPdf->Write();


	// TH1D *err = (TH1D*)hSigPdf->Clone("error");
	// TH1D *tempErr[4];
	// err->Reset();
	// for(int s = 0; s < 4; s++)
	// {
	//   if(s == 0)
	//     tempErr[s] = (TH1D*)TFile::Open("photonPurity_sys_loose.root")->Get(name);
	//   else if(s ==1)
	//     tempErr[s] = (TH1D*)TFile::Open("photonPurity_sys_tight.root")->Get(name);
	//   else if(s ==2)
	//     tempErr[s] = (TH1D*)TFile::Open("photonPurity_sys_sigshift.root")->Get(name);
	//   else if(s ==3)
	//     tempErr[s] = (TH1D*)TFile::Open("photonPurity_sys_bkgshift.root")->Get(name);
	//   tempErr[s]->Divide(hSigPdf);
	//   for (Int_t l=1; l<=tempErr[s]->GetNbinsX();l++)
	//   {
	//     tempErr[s]->SetBinContent(l, TMath::Abs(tempErr[s]->GetBinContent(l))-1);
	//   }
	// }
	// for (Int_t l=1; l<=err->GetNbinsX();l++)
	// {
	//   Double_t errVal = TMath::Sqrt(tempErr[0]->GetBinContent(l)*tempErr[0]->GetBinContent(l) +
	// 				tempErr[1]->GetBinContent(l)*tempErr[1]->GetBinContent(l) +
	// 				tempErr[2]->GetBinContent(l)*tempErr[2]->GetBinContent(l) +
	// 				tempErr[3]->GetBinContent(l)*tempErr[3]->GetBinContent(l)
	//     );
	//   err->SetBinContent(l, errVal);
	// }

	// plot stacked histos
	handsomeTH1(hSigPdf);
	mcStyle(hSigPdf);
	sbStyle(hBckPdf);
	cleverRange(hSigPdf,1.5);
	hSigPdf->SetAxisRange(0.001,0.024,"X");
	hSigPdf->SetNdivisions(505);
	hSigPdf->GetYaxis()->SetTitleOffset(1.75);
	hSigPdf->SetYTitle("Entries");
	hSigPdf->SetXTitle("#sigma_{#eta #eta}");

	hSigPdf->DrawCopy("hist");
	//drawSys(hSigPdf, err, kRed, -1, 0.001);
	hBckPdf->DrawCopy("same hist");
	hData1->DrawCopy("same");

	Float_t xpos = 0.44;
	if(2*(k+j)*nPTBINS+i+1 == 1)
	  xpos = 0.54;

	TLegend *t3=new TLegend(xpos, 0.45, 0.92, 0.71);
	t3->AddEntry(hData1,LABEL,"pl");
	t3->AddEntry(hSigPdf,"Signal","lf");
	t3->AddEntry(hBckPdf,"Background","lf");
	t3->SetFillColor(0);
	t3->SetBorderSize(0);
	t3->SetFillStyle(0);
	t3->SetTextFont(43);
	t3->SetTextSize(20);
	//if(i == 0)
	// TH1D *dummyHist = new TH1D("dummyHist","",10,0,10);
	// dummyHist->Fill(1);
	// dummyHist->SetFillColor(kRed);
	// dummyHist->SetLineColor(kRed);
	// dummyHist->SetFillStyle(1001);
	// t3->AddEntry(dummyHist,"MC Sys. Error","f");
	// if(i == 0)
	//   t3->Draw();

	if(i == 3)
	{
	  drawText("CMS Preliminary", xpos, 0.68,1,20);
	  drawText("PbPb #sqrt{s}_{_{NN}}=5.02 TeV", xpos, 0.60,1,20);
	  drawText("#intL = 404 #ub^{-1}", xpos, 0.50,1,20);
	}



	//drawText("|#eta_{#gamma}| < 1.479",0.5680963,0.9);
	//drawText(Form("%f shift",fitr.sigMeanShift),0.57,0.82);
	//drawText("Background Correction",0.57,0.82);
	//drawText("bkg Tighter",0.57,0.82);
	//if(nPTBINS != 1)
	drawText(Form("%.0f GeV < p_{T}^{#gamma} < %.0f GeV",
		      PTBINS[i], PTBINS[i+1]),
		 xpos, 0.90,1,20);
	// if(/*nCENTBINS != 1 && */i ==0)
	drawText(Form("%.0f - %.0f%c",
		      CENTBINS[j]/2., CENTBINS[j+1]/2.,'%'),
		 xpos, 0.82,1,20);
	// if(nETABINS != 1)
	//   drawText(Form("%.3f < #eta_{#gamma} < %.3f",
	// 		ETABINS[k], ETABINS[k+1]),
	// 	   xpos, 0.82,1,20);
	drawText(Form("Purity (#sigma_{#eta#eta} < 0.01) : %.2f", (Float_t)fitr.purity),
		 xpos, 0.76,1,20);
	drawText(Form("#chi^{2}/ndf : %.2f", (Float_t)fitr.chisq),
		 xpos, 0.45,1,20);


	// //plot ratio
	// cPurity->cd((2*(j+k)+1)*nPTBINS+i+1);
	// //cPurity[i]->cd(nETABINS + k+ 1);
	// TH1D* ratio = (TH1D*)hData1->Clone("ratio");
	// ratio->Divide(hData1, hSigPdf, 1, 1);
	// ratio->SetMinimum(0);
	// ratio->SetMaximum(3);
	// ratio->SetXTitle("#sigma_{#eta #eta}");
	// ratio->GetXaxis()->CenterTitle();
	// ratio->SetYTitle("Data/Fit");
	// ratio->GetYaxis()->CenterTitle();
	// ratio->DrawCopy("E");
	// TLine *line = new TLine(0,1,maxSIGMA,1);
	// line->SetLineStyle(2);
	// line->Draw("same");

	// TString savename = Form("purity_pA_barrel_pt%.0f_hf%.0f_plot",
	// 			PTBINS[i], CENTBINS[j]);
	// cPurity[i*nCENTBINS+j]->SaveAs(savename+".C");
	// cPurity[i*nCENTBINS+j]->SaveAs(savename+".pdf");
	// cPurity[i*nCENTBINS+j]->SaveAs(savename+".png");

      }
    }
    //cPurity[i]->SaveAs(Form("pPb_purity_etadep_wshift_ptbin%.0f.png",PTBINS[i]));
    //cPurity[i]->SaveAs(Form("pPb_purity_etadep_noshift_inclusive.png"));
  }
  outFile->cd();
  configTree->Write();
  cPurity->Write();
  outFile->Close();
  //cPurity->SaveAs(SAVENAME+".C");
  //cPurity->SaveAs(SAVENAME+".png");
  //cPurity->SaveAs(SAVENAME+".pdf");
}
コード例 #19
0
ファイル: plotPPDPhiAll.C プロジェクト: mandrenguyen/usercode
void plotPPDPhiAll(){

  bool isPF = false;

  TString data_tag;
  TString mc_tag;
  TString jetfinder, jetfinder_tag;

  if(!isPF){
    data_tag = "hdata_ak5calo_DijetDPhi";
    mc_tag = "hmc_ak5calo_DijetDPhi_histonly";
    jetfinder_tag = "calo";
  }else{
    data_tag = "hdata_ak5pf_DijetDPhi";
    mc_tag = "hmc_ak5pf_DijetDPhi_histonly";
    jetfinder_tag ="pf";
  }

  TFile *fDATA = new TFile(Form("./%s.root",data_tag.Data()));
  TFile *fMC = new TFile(Form("./%s.root",mc_tag.Data()));

  TH1F *hDijetBal_data = (TH1F*) fDATA->Get("hDataDijetDPhi");
  TH1F *hDijetBal_mc = (TH1F*) fMC->Get("hQCDDijetDPhi");


  // normalization should be matched with what's in ANA
  hDijetBal_data->Scale(1./hDijetBal_data->Integral());
  //hDijetBal_data->Rebin(2);

  hDijetBal_mc->Scale(1./hDijetBal_mc->Integral());
  //hDijetBal_mc->Rebin(2);

  cout<<"Bin Width = "<<hDijetBal_data->GetBinWidth(1)<<endl;


  // canvas setting ---
  TCanvas *c1 = new TCanvas("c1","",490,550);
  c1->SetLogy();

  // dum styling ----
  TH1F *hDum = new TH1F("hDum","",10,0,3.142);
  hDum->SetLineColor(kBlue);
  //hDum->SetFillColor(kAzure-8);
  //hDum->SetFillStyle(3005);

  hDum->SetStats(0);
  hDum->SetXTitle("#Delta#phi (rad)");
  hDum->SetYTitle("Event Fraction");

  hDum->GetXaxis()->SetLabelSize(30);
  hDum->GetXaxis()->SetLabelFont(43);
  hDum->GetXaxis()->SetTitleSize(30);
  hDum->GetXaxis()->SetTitleFont(43);
  hDum->GetXaxis()->SetTitleOffset(1.2);
  hDum->GetXaxis()->CenterTitle();

  hDum->GetXaxis()->SetNdivisions(905,true);
  
  hDum->GetYaxis()->SetLabelSize(30);
  hDum->GetYaxis()->SetLabelFont(43);
  hDum->GetYaxis()->SetTitleSize(30);
  hDum->GetYaxis()->SetTitleFont(43);
  hDum->GetYaxis()->SetTitleOffset(1.6);
  hDum->GetYaxis()->CenterTitle();

  hDum->SetAxisRange(3E-3,0.5,"Y");


  // data, mc styling
  hDijetBal_mc->SetLineColor(kBlue);
  hDijetBal_mc->SetFillColor(kAzure-8);
  hDijetBal_mc->SetFillStyle(3352);

  hDum->Draw("hist");

  hDijetBal_mc->SetMarkerSize(2.0);
  hDijetBal_mc->Draw("histsame");
  hDijetBal_data->SetMarkerSize(2.0);
  hDijetBal_data->Draw("pzsame");


  // Legend
  TLegend *t3=new TLegend(0.21,0.56,0.8,0.81);
  //t3->SetHeader("ant-k_{T} (R=0.5) CaloJets");
  t3->AddEntry(hDijetBal_data,"p + p  #sqrt{s}=7.0 TeV","pl");
  t3->AddEntry(hDijetBal_mc,"PYTHIA","lf");
  t3->SetFillColor(0);
  t3->SetBorderSize(0);
  t3->SetFillStyle(0);
  t3->SetTextFont(63);
  t3->SetTextSize(20);
  t3->Draw();


  // other labeling
  TLatex *cms = new TLatex(0.24,0.33,"CMS");
  cms->SetTextFont(63);
  cms->SetTextSize(20);
  cms->Draw();

  TLatex *lumi = new TLatex(1.54,0.33,"#intL dt = 35.1 pb^{-1}");
  lumi->SetTextFont(63);
  lumi->SetTextSize(18);
  lumi->Draw();

  
  TLatex *jetf;
  if(!isPF) jetf = new TLatex(0.24,0.23,"anti-k_{T} (R=0.5) CaloJets");
  else jetf = new TLatex(0.24,0.23,"anti-k_{T} (R=0.5) PFJets");
  jetf->SetTextFont(63);
  jetf->SetTextSize(20);
  jetf->Draw();

  c1->Print(Form("./fig/dphi_%s_%s_v1.gif",data_tag.Data(),jetfinder_tag.Data()));
  c1->Print(Form("./fig/dphi_%s_%s_v1.pdf",data_tag.Data(),jetfinder_tag.Data()));
  c1->Print(Form("./fig/dphi_%s_%s_v1.eps",data_tag.Data(),jetfinder_tag.Data()));
}
コード例 #20
0
void draw_centEff_fitResults(string cutname = "hiHF_hfCoinc3_pVtx") {

    ifstream in;
    //in.open("temp.txt");
    in.open(Form("centEff_fitResults_%s.txt",cutname.data()));

    string run;
    int runtemp;
    Float_t eff, chi2;
    Int_t nlines = 0;
    //TFile *f = new TFile("hist_effcon_runDep.root","RECREATE");
    TCanvas *c1 = new TCanvas("c1","",10,10,900,500);
    c1->SetGrid();
    TH1F *h = new TH1F("h1","Eff+Contamination vs. run",1,0,1);
    h->SetStats(0);
    h->SetTitle("Eff+Contamination vs. run; Run number;Efficiency+Contamination (%)");
    h->SetAxisRange(95,105,"Y");
    h->SetCanExtend(TH1::kAllAxes);
    h->SetLineColor(2);
    TH1F *hgaus = new TH1F("hgaus","Eff+Contamination",20,99,101);

    while (1) {
        in >> run>> eff >> chi2;
        //run = itoa(runtemp);
        if (!in.good()) break;
        if (nlines < 5) printf("run=%s, eff+contamination=%3f, reduced chi2=%3f\n",run.data(),eff,chi2);
        h->Fill(run.data(),eff);
        hgaus->Fill(eff);
        nlines++;
    }
    in.close();
    printf(" found %d points\n",nlines);
    c1->cd();
    h->LabelsDeflate();
    h->Draw("hist");
    c1->SaveAs(Form("figures/centEff_runDep_%s.png",cutname.data()));
 
    TCanvas *c2 = new TCanvas("c2","",500,500);
    double gausMean, gausResol;
    double histMean, histResol;
    TF1* fgaus = cleverGaus(hgaus);
    gausMean = fgaus->GetParameter(1);
    gausResol = fgaus->GetParameter(2);
    hgaus->SetTitle(";Efficiency+Contamination (%);");
    hgaus->SetNdivisions(504);
    hgaus->Draw("hist");
    fgaus->Draw("same");
    histMean = hgaus->GetMean();
    histResol= hgaus->GetRMS();// GetRMS()=GetStdDev() only in ROOT!
    float xpos(0.62), ypos(0.76);
    float dy=0.05;
    drawText(Form("from historgam"),xpos,ypos,kBlack,18);
    drawText(Form("mean = %.3f",histMean),xpos,ypos-dy,kBlack,18);
    drawText(Form("sigma = %.3f",histResol),xpos,ypos-2*dy,kBlack,18);
    ypos=0.55;
    drawText(Form("from gaus fit"),xpos,ypos,kBlack,18);
    drawText(Form("mean = %.3f",gausMean),xpos,ypos-dy,kBlack,18);
    drawText(Form("sigma = %.3f",gausResol),xpos,ypos-2*dy,kBlack,18);
    xpos=0.62-0.21;
    drawText("Dataset : HIMinimumBias2", xpos, 0.18+2*dy);
    drawText("Trig : HLT_HIL1MinimumBiasHF1AND_v1", xpos, 0.18+dy);
    drawText("Evt. sel. filter : hfCoinc3 && pVtx", xpos, 0.18);
    c2->SaveAs(Form("figures/centEff_runDep_gaus_%s.png",cutname.data()));

}
コード例 #21
0
ファイル: compare.C プロジェクト: chrosa/RandS
int compare(){
	
    gROOT->SetStyle("Plain");

    // For the canvas:
    gStyle->SetCanvasColor(0);

    // For the Pad:
    gStyle->SetPadColor(0);
    gStyle->SetPadTickX(1);
    gStyle->SetPadTickY(1);
    gStyle->SetPadBorderSize(2);

    // For the frame:
    gStyle->SetFrameBorderMode(0);


    // For the statistics box:
    gStyle->SetOptStat(0);

    // Margins:
    gStyle->SetPadBottomMargin(0.25);
    gStyle->SetPadTopMargin(0.15);
    gStyle->SetPadLeftMargin(0.15);
    gStyle->SetPadRightMargin(0.1);

    // For the Global title:
    gStyle->SetOptTitle(0);
    gStyle->SetTitleColor(1);
    gStyle->SetTitleFillColor(10);
    gStyle->SetTitleTextColor(1);
    gStyle->SetTitleFont(42);
    gStyle->SetTitleFontSize(0.05);
    gStyle->SetTitleBorderSize(0);

    // For the axis
    gStyle->SetNdivisions(510, "X");
    gStyle->SetNdivisions(510, "Y");
    gStyle->SetTickLength(0.03);

    // For the axis titles:
    gStyle->SetTitleOffset(1.4, "X");
    gStyle->SetTitleOffset(1.2, "Y");
    gStyle->SetTitleOffset(0.5, "Z");
    gStyle->SetTitleSize(0.061, "XYZ");
    gStyle->SetTitleFont(42, "XYZ");

    // For the axis labels:
    gStyle->SetLabelSize(0.04, "XYZ");
    gStyle->SetLabelOffset(0.01, "XYZ");
    gStyle->SetLabelFont(42, "XYZ");

    // For the legend
    gStyle->SetLegendBorderSize(0);

    gROOT->ForceStyle();

    ////////////////////////////////////////

	TFile *f1 = new TFile("output_GetPrediction/prediction_histos_MyTest_data_METsoftSmeared_noAngSmear_N20_CR_v3.root", "READ", "", 0);
    TFile *f2 = new TFile("output_GetPrediction/bkg.root", "READ", "", 0);
	selection = (TH1F*) f1->FindObjectAny("VBF_MET_presel_4JV_dPhiSide_selection");
	prediction = (TH1F*) f1->FindObjectAny("VBF_MET_presel_4JV_dPhiSide_prediction_px");
	background2 = (TH1F*) f2->FindObjectAny("met_check_inVR_rebin");
	TH1F* background = new TH1F(*prediction);
	background->Reset();
	for (int i = 1; i <= background->GetXaxis()->GetNbins(); ++i) {
		float x = background->GetXaxis()->GetBinCenter(i);
		int j = background2->GetXaxis()->FindBin(x);
		float value = background2->GetBinContent(j);
		float error = background2->GetBinError(j);
		background->SetBinContent(i,value);
		background->SetBinError(i,error);
	}
	
	//double MinX = selection->GetXaxis()->GetBinLowEdge(1);
    //double MaxX = selection->GetXaxis()->GetBinUpEdge(selection->GetXaxis()->GetNbins());
	double MinX = 150;
    double MaxX = 500;
    double BinWidth = selection->GetXaxis()->GetBinWidth(selection->GetXaxis()->GetNbins());
    double MaxY = prediction->GetBinContent(prediction->GetMaximumBin());
    double MaxYsel = selection->GetBinContent(selection->GetMaximumBin());
    if (MaxY < MaxYsel) MaxY = MaxYsel;
    double YRangeMax = 2.*pow(10., int(log10(MaxY))+2);
    double MinY = prediction->GetBinContent(prediction->GetMinimumBin());
    double MinYsel = selection->GetBinContent(selection->GetMinimumBin());
    if (MinY > MinYsel) MinY = MinYsel;
    if (MinY < 0.001) MinY = 0.001;
    double YRangeMin = 0.5*pow(10., int(log10(MinY))-2);
    TString titlePrediction;
    TString titleSelection;
    TString titleBackground;
    TString RatioTitle;
    TString LumiTitle;
    TString Title;
    TString xTitle;
    TString yTitle;

	LumiTitle = "ATLAS internal, L = 36.1 fb^{  -1}, #sqrt{s} = 13 TeV";

    Title = "3 jets, 1.8<#Delta#phi(jj)<2.7, MET>150 GeV, M(jj)>0.6 TeV, p_{T}^{3rd}<50 GeV";
    xTitle = "#slash{E}_{T} (GeV)";
    yTitle = "Events";

    titlePrediction = "Data-driven Pred.";
    titleSelection = "Data";
    titleBackground = "non-QCD background";

    RatioTitle = "(Pred-Data)/Data";

    static Int_t c_LightBrown = TColor::GetColor( "#D9D9CC" );
    static Int_t c_LightGray  = TColor::GetColor( "#DDDDDD" );

    selection->SetAxisRange(MinX, MaxX, "X");
    selection->GetYaxis()->SetRangeUser(YRangeMin, YRangeMax);
    selection->SetMarkerStyle(20);
    selection->SetMarkerSize(0.9);
    selection->SetMarkerColor(kBlack);
    selection->SetXTitle(xTitle);
    selection->SetYTitle(yTitle);

    prediction->SetAxisRange(MinX, MaxX, "X");
    prediction->GetYaxis()->SetRangeUser(YRangeMin, YRangeMax);
    prediction->SetFillColor(c_LightGray);
    prediction->SetTitle("");
    prediction->SetXTitle(xTitle);
    prediction->SetYTitle(yTitle);

    background->SetAxisRange(MinX, MaxX, "X");
    background->GetYaxis()->SetRangeUser(YRangeMin, YRangeMax);
    background->SetTitle("");
    background->SetLineColor(kRed);
    background->SetLineWidth(2);
    background->SetXTitle(xTitle);
    background->SetYTitle(yTitle);

    TCanvas *c = new TCanvas("ca", "Comparison and ratio of two histos", 700, 700);

    TPad *pad1 = new TPad("pad1a", "pad1a", 0, 0.35, 1, 1);
    pad1->SetLogy();
    pad1->SetBottomMargin(0);
    pad1->Draw();
    pad1->cd();

    prediction->DrawCopy("hist");
    selection->Draw("same");
    prediction->SetFillColor(kAzure-3);
    prediction->SetFillStyle(3354);
    prediction->DrawCopy("e2same");
    background->Scale(36.1/32.6);
    background->Draw("same");

    prediction->SetFillStyle(1001);
    //prediction->SetFillColor(c_LightBrown);
    prediction->SetFillColor(c_LightGray);

    //TLegend* leg1 = new TLegend(0.48, 0.63, 0.95, 0.83);
    TLegend* leg1 = new TLegend(0.44, 0.63, 0.91, 0.83);
    leg1->SetFillStyle(0);
    leg1->SetLineStyle(1);
    leg1->SetTextFont(42);
    //leg1->SetTextSize(0.04);
    leg1->SetTextSize(0.045);
    leg1->AddEntry(prediction, titlePrediction, "lf");
    leg1->AddEntry(selection, titleSelection, "lep");
    leg1->AddEntry(background, titleBackground, "l");
    leg1->Draw("same");

    TPaveText* pt = new TPaveText(0.11, 0.98, 0.95, 0.86, "NDC");
    pt->SetBorderSize(0);
    pt->SetFillStyle(0);
    pt->SetTextAlign(12);
    pt->SetTextSize(0.045);
    pt->AddText(Title);
    pt->AddText(LumiTitle);
    pt->Draw();

    c->cd();
    TPad *pad2 = new TPad("pad2a", "pad2a", 0, 0, 1, 0.35);
    pad2->SetTopMargin(0);
    pad2->Draw();
    pad2->cd();
    TH1F* r = new TH1F(*prediction);
    r->SetTitle("");
    r->SetLabelSize(0.08, "XYZ");
    r->SetLabelOffset(0.01, "XYZ");
    // r->SetTitleSize(0.09, "XYZ");
    r->SetTitleSize(0.125, "XYZ");
    r->SetTitleOffset(0.95, "X");
    r->SetTitleOffset(0.53, "Y");
    // r->SetTitleOffset(0.65, "Y");
    r->SetTickLength(0.05);
    r->SetYTitle(RatioTitle);
    r->SetStats(0);
    r->SetMarkerStyle(20);
    r->SetMarkerSize(0.9);
    r->SetMarkerColor(kBlack);
    r->Reset();
    r->Add(prediction, 1);
    r->Add(background, 1);
    r->Add(selection, -1);
    r->Divide(selection);
    r->SetMaximum(2.2);
    r->SetMinimum(-2.2);
    r->Draw("ep");
    TLine l;
    l.DrawLine(MinX, 0., MaxX+BinWidth, 0.);
    c->cd();
    
    c->SaveAs("compare.pdf");
	
	return 0;
}
コード例 #22
0
ファイル: Merged.C プロジェクト: yenjie/usercode
void Merged()
{
   TH1F *hTracklet = new TH1F("hTracklet","",12,-3,3);

   hTracklet->SetBinContent(2,6.251);
   hTracklet->SetBinContent(11,6.251);
   hTracklet->SetBinContent(3,6.314);
   hTracklet->SetBinContent(10,6.314);
   hTracklet->SetBinContent(4,6.222);
   hTracklet->SetBinContent(9,6.222);
   hTracklet->SetBinContent(5,5.976);
   hTracklet->SetBinContent(8,5.976);
   hTracklet->SetBinContent(6,5.75);
   hTracklet->SetBinContent(7,5.75);
   hTracklet->SetAxisRange(0,8,"Y");
   hTracklet->SetXTitle("#eta");
   hTracklet->SetYTitle("dN/d#eta");

   TH1F *hCluster = new TH1F("hCluster","",12,-3,3);

   hCluster->SetBinContent(3,6.53);
   hCluster->SetBinContent(4,6.25);
   hCluster->SetBinContent(5,6.09);
   hCluster->SetBinContent(6,5.73);
   hCluster->SetBinContent(7,5.73);
   hCluster->SetBinContent(8,6.11);
   hCluster->SetBinContent(9,6.29);
   hCluster->SetBinContent(10,6.55);
   hCluster->SetMarkerStyle(4);

   TH1F *h = new TH1F("h","",40,-10,10);
   h->SetBinContent(0,0.07195663);
   h->SetBinContent(1,0.1089206);
   h->SetBinContent(2,0.2419911);
   h->SetBinContent(3,0.4864465);
   h->SetBinContent(4,0.8314441);
   h->SetBinContent(5,1.224248);
   h->SetBinContent(6,1.54066);
   h->SetBinContent(7,1.773287);
   h->SetBinContent(8,2.302119);
   h->SetBinContent(9,2.786102);
   h->SetBinContent(10,3.409561);
   h->SetBinContent(11,3.827994);
   h->SetBinContent(12,4.253327);
   h->SetBinContent(13,4.371119);
   h->SetBinContent(14,4.529325);
   h->SetBinContent(15,4.641202);
   h->SetBinContent(16,4.679152);
   h->SetBinContent(17,4.618039);
   h->SetBinContent(18,4.389847);
   h->SetBinContent(19,4.233613);
   h->SetBinContent(20,4.05175);
   h->SetBinContent(21,4.100049);
   h->SetBinContent(22,4.364712);
   h->SetBinContent(23,4.435683);
   h->SetBinContent(24,4.593889);
   h->SetBinContent(25,4.614588);
   h->SetBinContent(26,4.524396);
   h->SetBinContent(27,4.514539);
   h->SetBinContent(28,4.350912);
   h->SetBinContent(29,4.185806);
   h->SetBinContent(30,3.950222);
   h->SetBinContent(31,3.432725);
   h->SetBinContent(32,2.915722);
   h->SetBinContent(33,2.364712);
   h->SetBinContent(34,1.825037);
   h->SetBinContent(35,1.494332);
   h->SetBinContent(36,1.25382);
   h->SetBinContent(37,0.8669295);
   h->SetBinContent(38,0.501725);
   h->SetBinContent(39,0.2138985);
   h->SetBinContent(40,0.1059635);
   h->SetBinContent(41,0.07343519);
   h->SetBinError(0,0.005955173);
   h->SetBinError(1,0.007326796);
   h->SetBinError(2,0.01092091);
   h->SetBinError(3,0.01548376);
   h->SetBinError(4,0.02024303);
   h->SetBinError(5,0.0245637);
   h->SetBinError(6,0.02755576);
   h->SetBinError(7,0.029563);
   h->SetBinError(8,0.03368394);
   h->SetBinError(9,0.03705591);
   h->SetBinError(10,0.04099286);
   h->SetBinError(11,0.04343548);
   h->SetBinError(12,0.04578501);
   h->SetBinError(13,0.04641467);
   h->SetBinError(14,0.04724716);
   h->SetBinError(15,0.04782712);
   h->SetBinError(16,0.04802226);
   h->SetBinError(17,0.04770762);
   h->SetBinError(18,0.046514);
   h->SetBinError(19,0.04567878);
   h->SetBinError(20,0.04468691);
   h->SetBinError(21,0.04495247);
   h->SetBinError(22,0.04638064);
   h->SetBinError(23,0.0467562);
   h->SetBinError(24,0.04758271);
   h->SetBinError(25,0.0476898);
   h->SetBinError(26,0.04722145);
   h->SetBinError(27,0.04716998);
   h->SetBinError(28,0.04630726);
   h->SetBinError(29,0.04542014);
   h->SetBinError(30,0.04412348);
   h->SetBinError(31,0.04113188);
   h->SetBinError(32,0.0379081);
   h->SetBinError(33,0.03413879);
   h->SetBinError(34,0.02999127);
   h->SetBinError(35,0.02713829);
   h->SetBinError(36,0.02485859);
   h->SetBinError(37,0.02067049);
   h->SetBinError(38,0.01572504);
   h->SetBinError(39,0.01026746);
   h->SetBinError(40,0.007226653);
   h->SetBinError(41,0.006016045);
   h->SetEntries(237505);
   h->SetFillColor(1);
   h->SetFillStyle(0);
   h->SetLineStyle(0);
   h->SetMarkerStyle(21);
   h->SetMarkerColor(4);
   h->SetMarkerSize(1.25);
   h->GetXaxis()->SetTitle("#eta");
   h->GetXaxis()->SetLabelFont(42);
   h->GetXaxis()->SetLabelOffset(0.01);
   h->GetXaxis()->SetLabelSize(0.045);
   h->GetXaxis()->SetTitleSize(0.055);
   h->GetXaxis()->SetTitleFont(42);
   h->GetYaxis()->SetTitle("dN/d#eta");
   h->GetYaxis()->SetLabelFont(42);
   h->GetYaxis()->SetLabelOffset(0.01);
   h->GetYaxis()->SetLabelSize(0.045);
   h->GetYaxis()->SetTitleSize(0.055);
   h->GetYaxis()->SetTitleOffset(1.3);
   h->GetYaxis()->SetTitleFont(42);
   h->GetZaxis()->SetLabelFont(42);
   h->GetZaxis()->SetLabelSize(0.045);
   h->GetZaxis()->SetTitleFont(42);


   TH1F *hATLAS = new TH1F("hATLAS","",40,-10,10);
   hATLAS->SetBinContent(0,0.08524267);
   hATLAS->SetBinContent(1,0.1512688);
   hATLAS->SetBinContent(2,0.3321015);
   hATLAS->SetBinContent(3,0.6415373);
   hATLAS->SetBinContent(4,0.9425967);
   hATLAS->SetBinContent(5,1.193397);
   hATLAS->SetBinContent(6,1.452082);
   hATLAS->SetBinContent(7,1.836413);
   hATLAS->SetBinContent(8,2.275437);
   hATLAS->SetBinContent(9,2.840108);
   hATLAS->SetBinContent(10,3.400838);
   hATLAS->SetBinContent(11,4.043853);
   hATLAS->SetBinContent(12,4.521803);
   hATLAS->SetBinContent(13,5.043114);
   hATLAS->SetBinContent(14,5.39591);
   hATLAS->SetBinContent(15,5.757083);
   hATLAS->SetBinContent(16,6.010347);
   hATLAS->SetBinContent(17,6.007884);
   hATLAS->SetBinContent(18,5.883715);
   hATLAS->SetBinContent(19,5.838877);
   hATLAS->SetBinContent(20,5.451097);
   hATLAS->SetBinContent(21,5.490022);
   hATLAS->SetBinContent(22,5.663464);
   hATLAS->SetBinContent(23,5.971914);
   hATLAS->SetBinContent(24,6.058635);
   hATLAS->SetBinContent(25,5.969944);
   hATLAS->SetBinContent(26,5.797487);
   hATLAS->SetBinContent(27,5.353043);
   hATLAS->SetBinContent(28,4.894802);
   hATLAS->SetBinContent(29,4.5085);
   hATLAS->SetBinContent(30,4.00542);
   hATLAS->SetBinContent(31,3.448633);
   hATLAS->SetBinContent(32,2.883469);
   hATLAS->SetBinContent(33,2.337029);
   hATLAS->SetBinContent(34,1.805863);
   hATLAS->SetBinContent(35,1.42104);
   hATLAS->SetBinContent(36,1.205223);
   hATLAS->SetBinContent(37,0.9795516);
   hATLAS->SetBinContent(38,0.6228135);
   hATLAS->SetBinContent(39,0.3261887);
   hATLAS->SetBinContent(40,0.1547179);
   hATLAS->SetBinContent(41,0.09608278);
   hATLAS->SetBinError(0,0.00648088);
   hATLAS->SetBinError(1,0.008633366);
   hATLAS->SetBinError(2,0.01279207);
   hATLAS->SetBinError(3,0.01777937);
   hATLAS->SetBinError(4,0.02155105);
   hATLAS->SetBinError(5,0.02424923);
   hATLAS->SetBinError(6,0.0267486);
   hATLAS->SetBinError(7,0.03008089);
   hATLAS->SetBinError(8,0.03348404);
   hATLAS->SetBinError(9,0.03740873);
   hATLAS->SetBinError(10,0.04093534);
   hATLAS->SetBinError(11,0.04463784);
   hATLAS->SetBinError(12,0.0472021);
   hATLAS->SetBinError(13,0.04984882);
   hATLAS->SetBinError(14,0.05156296);
   hATLAS->SetBinError(15,0.05326068);
   hATLAS->SetBinError(16,0.05441959);
   hATLAS->SetBinError(17,0.05440843);
   hATLAS->SetBinError(18,0.05384325);
   hATLAS->SetBinError(19,0.0536377);
   hATLAS->SetBinError(20,0.05182597);
   hATLAS->SetBinError(21,0.05201068);
   hATLAS->SetBinError(22,0.05282586);
   hATLAS->SetBinError(23,0.05424532);
   hATLAS->SetBinError(24,0.05463776);
   hATLAS->SetBinError(25,0.05423637);
   hATLAS->SetBinError(26,0.05344725);
   hATLAS->SetBinError(27,0.05135773);
   hATLAS->SetBinError(28,0.04911035);
   hATLAS->SetBinError(29,0.04713261);
   hATLAS->SetBinError(30,0.04442521);
   hATLAS->SetBinError(31,0.04122199);
   hATLAS->SetBinError(32,0.03769321);
   hATLAS->SetBinError(33,0.03393419);
   hATLAS->SetBinError(34,0.02982963);
   hATLAS->SetBinError(35,0.02646114);
   hATLAS->SetBinError(36,0.02436908);
   hATLAS->SetBinError(37,0.02196945);
   hATLAS->SetBinError(38,0.017518);
   hATLAS->SetBinError(39,0.01267768);
   hATLAS->SetBinError(40,0.008731237);
   hATLAS->SetBinError(41,0.006880631);
   hATLAS->SetEntries(280271);
   hATLAS->SetFillColor(1);
   hATLAS->SetFillStyle(0);
   hATLAS->SetLineStyle(0);
   hATLAS->SetMarkerStyle(22);
   hATLAS->SetMarkerColor(4);
   hATLAS->SetMarkerSize(1.25);
   hATLAS->GetXaxis()->SetTitle("#eta");
   hATLAS->GetXaxis()->SetLabelFont(42);
   hATLAS->GetXaxis()->SetLabelOffset(0.01);
   hATLAS->GetXaxis()->SetLabelSize(0.045);
   hATLAS->GetXaxis()->SetTitleSize(0.055);
   hATLAS->GetXaxis()->SetTitleFont(42);
   hATLAS->GetYaxis()->SetTitle("dN/d#eta");
   hATLAS->GetYaxis()->SetLabelFont(42);
   hATLAS->GetYaxis()->SetLabelOffset(0.01);
   hATLAS->GetYaxis()->SetLabelSize(0.045);
   hATLAS->GetYaxis()->SetTitleSize(0.055);
   hATLAS->GetYaxis()->SetTitleOffset(1.3);
   hATLAS->GetYaxis()->SetTitleFont(42);
   hATLAS->GetZaxis()->SetLabelFont(42);
   hATLAS->GetZaxis()->SetLabelSize(0.045);
   hATLAS->GetZaxis()->SetTitleFont(42);
   
   TCanvas *MyCanvas = new TCanvas("MyCanvas", "Final result",1,360,550,600);

   hTracklet->Draw("p");
   hCluster->Draw("p same");
   hATLAS->Draw("same");
   h->Draw("same");
   Float_t ywidth = 0.25;
   //TLegend *leg2 = new TLegend(0.38,0.27,0.81,0.27+ywidth2,"","brNDC");
   TLegend *leg2 = new TLegend(0.39,0.21,0.82,0.21+ywidth,NULL,"brNDC");

   leg2->SetMargin(0.5);
   leg2->SetBorderSize(0);
   leg2->SetTextFont(62);
   leg2->SetLineColor(1);
   leg2->SetLineStyle(1);
   leg2->SetLineWidth(1);
   leg2->SetFillColor(0);
   //leg->SetFillStyle(1001);
   leg2->SetFillStyle(0);
   leg2->SetTextSize(0.033);
   leg2->SetHeader("     7.0 TeV");
   leg2->AddEntry(hTracklet,"CMS Preliminary Tracklet","p");
   leg2->AddEntry(hCluster,"CMS Preliminary Cluster","p");
   leg2->AddEntry(hATLAS,"ATLAS Tune","p");
   leg2->AddEntry(h,"D6T Tune","p");


   leg2->Draw();
}
コード例 #23
0
void RAA_plot_JetID_CutEfficiency(  Int_t radius = 4,
				    char * etaWidth = (char*)"20_eta_p20"){

  TH1::SetDefaultSumw2();
  gStyle->SetOptStat(0);

  char * Coll = "PbPb";
  //char * Coll = "Pp";

  TDatime date;

  Int_t trigger[3]; 

  if(Coll == "PbPb") {trigger[0] = 55; trigger[1] = 65; trigger[2] = 80;}
  if(Coll == "Pp") {trigger[0] = 40; trigger[1] = 60; trigger[2] =  80;}

  char * jetType; 

  if(Coll == "PbPb") jetType = Form("akPu%dPF",radius);
  if(Coll == "Pp") jetType = Form("ak%dPF",radius);

  const int nbins_pt = 38;
  const double boundaries_pt[nbins_pt+1] = {
    3, 4, 5, 7, 9, 12, 
    15, 18, 21, 24, 28,
    32, 37, 43, 49, 56,
    64, 74, 84, 97, 114,
    133, 153, 174, 196,
    220, 245, 300, 
    330, 362, 395, 430,
    468, 507, 548, 592,
    638, 686, 1000 
  };
  
  // Pawan's files:
  TFile * fIn = TFile::Open(Form("/export/d00/scratch/rkunnawa/rootfiles/RAA/Pawan_ntuple_PbPb_data_MC_subid0_spectra_JetID_CutA_finebins_%s_R0p%d.root",etaWidth,radius));
  TFile * fPP_in = TFile::Open(Form("/export/d00/scratch/rkunnawa/rootfiles/RAA/Pawan_ntuple_PP_data_MC_spectra_residualFactor_finebins_%s_R0p%d.root",etaWidth, radius));
  
  // get the histograms, the Cut Efficiency is plotted from the MC histograms 
  TH1F * hMC_noCut[3], * hMC_Cut[3], * hMC_unm_noCut[3], * hMC_unm_Cut[3]; 

  TH1F * hMC_Denominator, *hMC_Numerator;

  for(int i = 0; i<3; i++){

    hMC_noCut[i] = (TH1F*)fIn->Get(Form("hMC_Jet%d_noCut", trigger[i]));
    hMC_Cut[i] = (TH1F*)fIn->Get(Form("hMC_Jet%d_CutA", trigger[i]));
    hMC_unm_noCut[i] = (TH1F*)fIn->Get(Form("hMC_unmatched_Jet%d_noCut", trigger[i]));
    hMC_unm_Cut[i] = (TH1F*)fIn->Get(Form("hMC_unmatched_Jet%d_CutA", trigger[i]));

  }

  hMC_Denominator = (TH1F*)hMC_noCut[0]->Clone("hMC_Denominator");
  hMC_Denominator->Add(hMC_noCut[1]);
  hMC_Denominator->Add(hMC_noCut[2]);
  hMC_Denominator->Add(hMC_unm_noCut[0]);
  hMC_Denominator->Add(hMC_unm_noCut[1]);
  hMC_Denominator->Add(hMC_unm_noCut[2]);
  
  hMC_Numerator = (TH1F*)hMC_Cut[0]->Clone("hMC_Numerator");
  hMC_Numerator->Add(hMC_Cut[1]);
  hMC_Numerator->Add(hMC_Cut[2]);
  hMC_Numerator->Add(hMC_unm_Cut[0]);
  hMC_Numerator->Add(hMC_unm_Cut[1]);
  hMC_Numerator->Add(hMC_unm_Cut[2]);

  TH1F * hCutEff = (TH1F*)hMC_Numerator->Clone("hCutEff");
  hCutEff->Divide(hMC_Denominator);
  hCutEff = (TH1F*)hCutEff->Rebin(nbins_pt, "hCutEff", boundaries_pt);
  divideBinWidth(hCutEff);

  // line at 1

  
  TCanvas * cCutEff = new TCanvas("cCutEff","",800,600);
  hCutEff->SetXTitle(Form("%s Gen p_{T} (GeV/c)",jetType));
  hCutEff->SetYTitle("Jet ID Cut Efficiency");
  hCutEff->SetTitle(" ");
  hCutEff->SetAxisRange(40, 300, "X");
  hCutEff->SetAxisRange(0.9, 1.05, "Y");
  hCutEff->SetMarkerStyle(20);
  hCutEff->SetMarkerColor(kBlack);
  hCutEff->Draw();

  putCMSPrel();
  drawText("|#eta|<2, |vz|<15", 0.6, 0.31, 20);
  drawText(Form("%s",Coll), 0.6, 0.21, 20);

  cCutEff->SaveAs(Form("May20/%s_Combined_CutEfficiency_R0p%d_%s_%d.pdf",Coll,radius,etaWidth,date.GetDate()),"RECREATE");
  


  // plot the curves for the different centrality classes. get the combined spectra and do the ratio 
  
  const int nbins_cent = 6; 

  TH1F * hMC_Denominator[nbins_cent];
  TH1F * hMC_Numerator[nbins_cent]; 

  TH1F * hData_Denominator[nbins_cent];
  TH1F * hData_Numerator[nbins_cent]; 

  TH1F * hCutEff[nbins_cent];
  TH1F * hCutEff_Data[nbins_cent];

  TH1F * hPP_MC_Denominator = (TH1F*)fIn_PP->Get("hpp_MC_Comb_noCut");
  TH1F * hPP_MC_Numerator = (TH1F*)fIn_PP->Get(Form("hpp_JetComb_gen_R%d_%s",radius,etaWidth)); 

  TH1F * hPP_Data_Denominator = (TH1F*)fIn_PP->Get("hpp_Data_Comb_noCut");
  TH1F * hPP_Data_Numerator = (TH1F*)fIn_PP->Get(Form("hpp_HLTComb_R%d_%s",radius,etaWidth)); 

  TH1F * hPP_CutEff = (TH1F*)hPP_MC_Numerator->Clone("hPP_CutEff");
  hPP_CutEff->Divide(hPP_MC_Denominator);
  hPP_CutEff->Rebin(10);
  hPP_CutEff->Scale(1./10);
  TH1F * hPP_CutEff_Data = (TH1F*)hPP_Data_Numerator->Clone("hPP_CutEff_Data");
  hPP_CutEff_Data->Divide(hPP_Data_Denominator);
  hPP_CutEff_Data->Rebin(10);
  hPP_CutEff_Data->Scale(1./10);
  
  TLine *line = new TLine(60,1,299,1);
  line->SetLineStyle(2);
  line->SetLineWidth(2);

  for(int i = 0; i<nbins_cent; ++i){
    
    hMC_Denominator[i] = (TH1F*)fIn->Get(Form("hpbpb_MC_noCut_cent%d",i));
    hMC_Numerator[i] = (TH1F*)fIn->Get(Form("hpbpb_gen_R%d_%s_cent%d",radius,etaWidth, i));
    hData_Denominator[i] = (TH1F*)fIn->Get(Form("hpbpb_Data_Comb_noCut_cent%d",i));
    hData_Numerator[i] = (TH1F*)fIn->Get(Form("hpbpb_HLTComb_R%d_%s_cent%d",radius,etaWidth,i));

    hCutEff[i] = (TH1F*)hMC_Numerator[i]->Clone(Form("CutEff_cent%d",i));
    hCutEff[i]->Divide(hMC_Denominator[i]);
    hCutEff[i]->Rebin(20);
    hCutEff[i]->Scale(1./20);

    hCutEff_Data[i] = (TH1F*)hData_Numerator[i]->Clone(Form("CutEff_Data_cent%d",i));
    hCutEff_Data[i]->Divide(hData_Denominator[i]);
    hCutEff_Data[i]->Rebin(20);
    hCutEff_Data[i]->Scale(1./20);

  }

  TCanvas * cCutEff = new TCanvas("cCutEff","",800,600);
  makeMultiPanelCanvas(cCutEff,3,2,0.0,0.0,0.2,0.15,0.07);

  for(int i = 0; i<nbins_cent; ++i){
    cCutEff->cd(nbins_cent-i);
    hCutEff[i]->SetXTitle(Form("akPu%dPF Gen p_{T} (GeV/c)", radius));
    hCutEff[i]->SetYTitle("Jet ID Cut Efficiency");
    hCutEff[i]->SetTitle(" ");
    hCutEff[i]->SetAxisRange(50, 299, "X");
    hCutEff[i]->SetAxisRange(0.95, 1.05, "Y");
    hCutEff[i]->SetMarkerStyle(20);
    hCutEff[i]->SetMarkerColor(kBlack);
    hCutEff[i]->Draw();
    line->Draw();
  }

  putCMSPrel();
  drawText("|#eta|<2, |vz|<15", 0.6, 0.31, 20);
  drawText(Form("%s",Coll), 0.6, 0.21, 20);

  cCutEff->SaveAs(Form("May20/%s_Combined_CutEfficiency_centralityClass_R0p%d_%s_%d.pdf",Coll,radius,etaWidth,date.GetDate()),"RECREATE");

  TCanvas * cCutEff_Data = new TCanvas("cCutEff_Data","",800,600);
  makeMultiPanelCanvas(cCutEff_Data,3,2,0.0,0.0,0.2,0.15,0.07);

  for(int i = 0; i<nbins_cent; ++i){
    cCutEff_Data->cd(nbins_cent-i);
    hCutEff_Data[i]->SetXTitle(Form("akPu%dPF Data reco p_{T} (GeV/c)", radius));
    hCutEff_Data[i]->SetYTitle("Jet ID Cut Efficiency");
    hCutEff_Data[i]->SetTitle(" ");
    hCutEff_Data[i]->SetAxisRange(60, 299, "X");
    hCutEff_Data[i]->SetAxisRange(0.2, 1.1, "Y");
    hCutEff_Data[i]->SetMarkerStyle(20);
    hCutEff_Data[i]->SetMarkerColor(kBlack);
    hCutEff_Data[i]->Draw();
    line->Draw();
  }

  putCMSPrel();
  drawText("|#eta|<2, |vz|<15", 0.6, 0.31, 20);
  drawText(Form("%s",Coll), 0.6, 0.21, 20);

  cCutEff_Data->SaveAs(Form("May20/%s_Combined_CutEfficiency_Data_centralityClass_R0p%d_%s_%d.pdf",Coll,radius,etaWidth,date.GetDate()),"RECREATE");

  
  TCanvas * cPP_CutEff = new TCanvas("cPP_CutEff","",800,600);
  hPP_CutEff->SetXTitle(Form("ak%dPF Gen p_{T} (GeV/c)", radius));
  hPP_CutEff->SetYTitle("Jet ID Cut Efficiency");
  hPP_CutEff->SetTitle(" ");
  hPP_CutEff->SetAxisRange(60, 299, "X");
  hPP_CutEff->SetAxisRange(0.8,1.1,"Y");
  hPP_CutEff->SetMarkerStyle(20);
  hPP_CutEff->Draw();

  cPP_CutEff->SaveAs(Form("May20/PP_Combined_CutEfficiency_R0p%d_%d.pdf",radius, date.GetDate()));

  TCanvas * cPP_CutEff_Data = new TCanvas("cPP_CutEff_Data","",800,600);
  hPP_CutEff_Data->SetXTitle(Form(" ak%dPF Data reco p_{T} (GeV/c)", radius));
  hPP_CutEff_Data->SetYTitle("Jet ID Cut Efficiency");
  hPP_CutEff_Data->SetTitle(" ");
  hPP_CutEff_Data->SetAxisRange(60, 299, "X");
  hPP_CutEff_Data->SetAxisRange(0.8,1.1,"Y");
  hPP_CutEff_Data->SetMarkerStyle(20);
  hPP_CutEff_Data->Draw();

  cPP_CutEff_Data->SaveAs(Form("May20/PP_Combined_CutEfficiency_Data_R0p%d_%s_%d.pdf",radius,etaWidth, date.GetDate()));
  
}
コード例 #24
0
void kees_gen() {
  gROOT->SetStyle("HALLA");
  TCanvas *cn = new TCanvas("cn");
  cn->Draw();
  cn->UseCurrentStyle();
  TH1F *frm = new TH1F("frm","",100,0.,10.);
  frm->GetXaxis()->SetTitle("Q^{2}  [GeV^{2}]");
  frm->GetYaxis()->SetTitle("G_{E}^{n}");
  frm->SetMinimum(-.02);
  frm->SetMaximum(0.1);
  frm->UseCurrentStyle();
  frm->Draw();
  frm->SetAxisRange(0.,5.,"X");

  TF1 *genf = new TF1("genf",genff,1.,10.,1);
  genf->SetLineColor(2);
  genf->SetLineStyle(2);
  genf->SetParameter(0,1.);
  genf->SetParameter(1,.3);
  genf->SetParameter(0,-0.632);
  // match to Madey point just below 1.5
  //  genf->SetParameter(0,.0411/genf->Eval(1.45));
  
  TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}");
  TLegend *legDta = new TLegend(.54,.6,.875,.90,"","brNDC");

  TMultiGraph* wgr = mgrDta;
  TLegend *wlg = legDta;

   // the data
  legDta->SetBorderSize(0); // turn off border
  legDta->SetFillStyle(0);
  
  datafile_t *f = datafiles;
  TGraph* gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      if (f->lnpt) {
	mgrDta->Add(gr,f->lnpt);
	legDta->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	mgrDta->Add(gr,"p");
	legDta->AddEntry(gr,f->label,"p");
      }	
      else {
	mgrDta->Add(gr,"l");
	legDta->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }
    

  mgrDta->Draw("p");
  //  legDta->Draw();   don't draw the data legend
  
  TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}");
  TLegend *legThry = new TLegend(.54,.6,.875,.9,"","brNDC");

  wgr = mgrThry;
  wlg = legThry;

  // the theory
  wlg->SetBorderSize(0); // turn off border
  wlg->SetFillStyle(0);
  
  f = theoryfiles1;
  gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
      if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
	gr = toerror_band(egr);
	gr->SetFillStyle(3000+f->style);
      }
      if (f->lnpt) {
	wgr->Add(gr,f->lnpt);
	wlg->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	wgr->Add(gr,"p");
	wlg->AddEntry(gr,f->label,"p");
      }	
      else {
	wgr->Add(gr,"l");
	wlg->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }

  genf->Draw("same");
  mgrThry->Draw("c");
  legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
  legThry->Draw();

  // draw a line at 1
  cn->Modified();

  cn->Update();
  cn->SaveAs(Form("%s.eps",psfile));
  cn->SaveAs(Form("%s.root",psfile));
  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));
  // now an overlay, hopefully matching dimensions

  // remove everything but the graph
  cn->Update();
  TList *clist = cn->GetListOfPrimitives();
  TFrame* frame = cn->GetFrame();
  for (int i=0; i<clist->GetSize(); ) {
    if (clist->At(i) != frame) {
      clist->RemoveAt(i);
    } else i++;
  }
  // draw markers in the corners
  TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
  mkr->Draw();
  frame->SetLineColor(10);
  cn->Update();

  datafile_t miller = { "figure_input/Miller/lattice.GEn.rtf","Miller",
			"[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" };

  gr = OneGraph(&miller);
  TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
  if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
    gr = toerror_band(egr);
    gr->SetLineStyle(1);
    gr->SetFillColor(gr->GetLineColor());
    gr->SetFillStyle(3000+miller.style);
  }
  
  gr->Draw("F");

  cn->Update();
  cn->SaveAs("gen_Miller_Overlay.eps");
  cn->SaveAs("gen_Miller_Overlay.root");
  
}
コード例 #25
0
ファイル: DYNJ.C プロジェクト: anikiten/Nikitenko
void Draw()
{

   /*
   TLatex *t = new TLatex();
   t->SetTextSize(0.042);
   t->DrawLatex(1.5,0.80,"CMSSW_1_6_12, |#eta|< 1.3");
   t->DrawLatex(1.5,0.75,"no ZSP in HCAL");
   t->DrawLatex(1.5,0.70,"no SR in ECAL");
   */

  /*
   setTDRStyle(0,1);
   TCanvas* c0 = new TCanvas("X","Y",1);
   // data
   TFile* file = new TFile("DYDataA_29Feb.root");
   hnvtx0->GetXaxis()->SetTitle("N reco vertices");
   hnvtx0->GetYaxis()->SetTitle("");
   hnvtx0->SetLineStyle(1);
   hnvtx0->SetLineWidth(3);
   hnvtx0->SetMarkerStyle(24);
   hnvtx0->SetMarkerSize(1.0);
   hnvtx0->SetMaximum(200000.);
   hnvtx0->SetMinimum(0.5);
   hnvtx0->Draw("PE");
   TLegend *leg = new TLegend(0.35,0.75,0.9,0.85,NULL,"brNDC");
   leg->SetFillColor(10);
   leg->AddEntry(hnvtx0,"data: p_{T}^{#mu}> 20 GeV, |#eta|<2.4","P");
   // MC
   TFile* file = new TFile("DYMC18novPUW.root");
   hnvtx0->SetLineStyle(1);
   hnvtx0->SetLineWidth(3);
   hnvtx0->Draw("same");
   leg->AddEntry(hnvtx0,"MC, DY#rightarrowll","L");
   leg->Draw();
   c0->SaveAs("nvtx0.png");
  */

  // normalization
  //
  Double_t xsection=3048.;
  Double_t luminosity=5061;
  Double_t nmcevents=15000000.;
  Double_t datamcratio=2925.44;
  Double_t normalization=(xsection*luminosity)/(nmcevents*datamcratio);

  setTDRStyle(0,1);
  // data
  TFile* file = new TFile("DataAB.root");
  cout <<" ============= Data =============================" << endl;
  cout <<" ===> Zmumu = " << hZY->Integral() << endl;
  cout <<" ===> 2jets = " << hZY2J->Integral() << endl;
  cout <<" ===> y*    = " << hZY2JY->Integral() << endl;
  cout <<" ===> Mjj   = " << hZY2JYMjj->Integral() << endl;
  TCanvas* c1 = new TCanvas("X","Y",1);
  TH1F *hNjetsData = (TH1F*)hNjets->Clone();
  // MC events
  TFile* file = new TFile("DYMCAB.root");
  cout <<" ============= MC =============================" << endl;
  cout <<" ===> Zmumu = " << hZY->Integral()*normalization << endl;
  cout <<" ===> 2jets = " << hZY2J->Integral()*normalization << endl;
  cout <<" ===> y*    = " << hZY2JY->Integral()*normalization << endl;
  cout <<" ===> Mjj   = " << hZY2JYMjj->Integral()*normalization << endl;
  TH1F *hNjetsMC = (TH1F*)hNjets->Clone();
  TH1F *hNjetsRatio = (TH1F*)hNjets->Clone();
  TH1F *hNjetsRatio_JESUP = (TH1F*)hNjets->Clone();
  TH1F *hNjetsRatio_JESDN = (TH1F*)hNjets->Clone();
  //
  // MC events JESUP
  TFile* file = new TFile("DYMCAB_JESUP.root");
  TH1F *hNjetsMC_JESUP = (TH1F*)hNjets->Clone();
  // MC events JESDN
  TFile* file = new TFile("DYMCAB_JESDN.root");
  TH1F *hNjetsMC_JESDN = (TH1F*)hNjets->Clone();
  //
  hNjetsData->GetXaxis()->SetTitle("N jets");
  hNjetsData->GetYaxis()->SetTitle("N events");
  hNjetsData->SetMaximum(5000000.);
  hNjetsData->SetMinimum(100.);
  hNjetsData->SetLineStyle(1.);
  hNjetsData->SetLineWidth(2);
  hNjetsData->SetMarkerStyle(24);
  hNjetsData->SetMarkerSize(0.7);
  hNjetsData->Draw("PE");
  //  Double_t mcevents= hNjetsMC->Integral();
  //  Double_t dataevents=hNjetsData->Integral();
  //  Double_t expected=mcevents*normalization;
  hNjetsMC->Scale(normalization);
  hNjetsMC_JESUP->Scale(normalization);
  hNjetsMC_JESDN->Scale(normalization);
  hNjetsMC->SetLineStyle(1);
  hNjetsMC->SetLineWidth(2);
  hNjetsMC->Draw("same");

  TLegend *leg = new TLegend(0.5,0.8,0.9,0.9,NULL,"brNDC");
  leg->SetFillColor(10);
  leg->AddEntry(hNjetsData,"Data 2011, L=5.06 fb^{-1} ","P");
  leg->AddEntry(hNjetsMC,"Z+jets MC","L");
  leg->Draw();

  TLatex *t = new TLatex();
  t->SetTextSize(0.042);
  t->DrawLatex(3.0,200000,"Z#rightarrow#mu#mu + jets");
  t->DrawLatex(3.0,80000,"p_{T}^{j}>50 GeV, |#eta|<2.5");
  c1->SaveAs("dy_njets.png");

  setTDRStyle(0,0);
  TCanvas* c2 = new TCanvas("X","Y",1);
  hNjetsData->Sumw2();
  Int_t nbins = hNjetsMC->GetNbinsX();
  for (Int_t ib = 1; ib <= nbins; ib++) {
    hNjetsMC->SetBinError(ib,0.1);
    hNjetsMC->SetBinError(ib,0.1);
  }
  hNjetsRatio->Divide(hNjetsData,hNjetsMC,1.,1.,"");
  hNjetsRatio->GetXaxis()->SetTitle("N jets");
  hNjetsRatio->GetYaxis()->SetTitle("Data / MC");
  hNjetsRatio->SetMaximum(1.3);
  hNjetsRatio->SetMinimum(0.7);
  hNjetsRatio->SetLineStyle(1.);
  hNjetsRatio->SetLineWidth(2);
  hNjetsRatio->SetMarkerStyle(24);
  hNjetsRatio->SetMarkerSize(1.0);
  hNjetsRatio->SetAxisRange(0,3,"X");
  hNjetsRatio->Draw("PE");
  hNjetsRatio_JESUP->Divide(hNjetsMC_JESUP,hNjetsMC,1.,1.,"");
  hNjetsRatio_JESUP->SetLineStyle(2);
  hNjetsRatio_JESUP->SetLineWidth(2);
  hNjetsRatio_JESUP->Draw("histsame");
  hNjetsRatio_JESDN->Divide(hNjetsMC_JESDN,hNjetsMC,1.,1.,"");
  hNjetsRatio_JESDN->SetLineStyle(3);
  hNjetsRatio_JESDN->SetLineWidth(2);
  hNjetsRatio_JESDN->Draw("histsame");
  TLatex *t = new TLatex();
  t->SetTextSize(0.042);
  t->DrawLatex(1.0,1.20,"Z#rightarrow#mu#mu + jets");
  t->DrawLatex(1.0,1.14,"p_{T}^{j}>50 GeV, |#eta|<2.5");

  TLegend *leg = new TLegend(0.2,0.2,0.6,0.35,NULL,"brNDC");
  leg->SetFillColor(10);
  leg->AddEntry(hNjetsRatio,"Data 2011, L=5.06 fb^{-1} ","P");
  leg->AddEntry(hNjetsRatio_JESUP,"Z+jets MC, JES +1#sigma","L");
  leg->AddEntry(hNjetsRatio_JESDN,"Z+jets MC, JES -1#sigma","L");
  leg->Draw();

  c2->SaveAs("dy_ratio_njets_jes.png");
}
コード例 #26
0
void Draw()
{
    
  setTDRStyle(0,1,0);

  // Type 1 MET. Signal area
  TCanvas* c1 = new TCanvas("X","Y",1);

  TLegend *leg = new TLegend(0.20,0.80,0.50,0.90,NULL,"brNDC");

  // data in signal region
  TFile* file = new TFile("VBFHinvisQCDAnalysisMy_Type1MET.root");

  TH1F * hPfMetDphiJJSDataClone = (TH1F*)hPfMetDphiJJSData->Clone();
  hPfMetDphiJJSDataClone->Sumw2();

  TH1F *hrD = (TH1F*)hPfMetDphiJJSData->Clone();
  TH1F *hD_EW_S = (TH1F*)hPfMetDphiJJSData->Clone();
  TH1F *hD_EW_B = (TH1F*)hPfMetDphiJJSData->Clone();
  TH1F *hrD_EW = (TH1F*)hPfMetDphiJJSData->Clone();


  hPfMetDphiJJSData->GetXaxis()->SetTitle("E_{T}^{miss}, GeV");
  hPfMetDphiJJSData->GetYaxis()->SetTitle("Nev");
  hPfMetDphiJJSData->SetMinimum(1.);
  hPfMetDphiJJSData->SetMaximum(10000.);
  hPfMetDphiJJSData->SetMarkerStyle(20);
  hPfMetDphiJJSData->Draw("E1P");
  leg->SetFillColor(10);
  leg->AddEntry(hPfMetDphiJJSData,"Data","PL");

  // EW MC in signal region
  TFile* file = new TFile("AnneMarieEWK_METType1_My.root");

  TH1F *metRangeTotal_DPhiSIGNALClone = (TH1F*)metRangeTotal_DPhiSIGNAL->Clone();
  metRangeTotal_DPhiSIGNALClone->Sumw2();

  metRangeTotal_DPhiSIGNAL->SetLineWidth(2);
  metRangeTotal_DPhiSIGNAL->SetLineStyle(1);
  metRangeTotal_DPhiSIGNAL->Draw("SAMEE1");
  leg->AddEntry(metRangeTotal_DPhiSIGNAL,"EW MC","PL");
  leg->Draw();

  TLatex *t = new TLatex();
  t->SetTextSize(0.042);
  t->DrawLatex(80.,10.,"#Delta#phi_{jj} < 1.0");
  t->DrawLatex(80.,4.,"Type 1 MET");
  t->DrawLatex(60.,2.,"tag.jets with no #mu's");

  c1->SaveAs("met_type1_s_my.gif");

  // Type 1 MET. Bkg area
  TCanvas* c2 = new TCanvas("X","Y",1);

  TLegend *leg = new TLegend(0.60,0.40,0.90,0.50,NULL,"brNDC");

  // data in Bkg region
  TFile* file = new TFile("VBFHinvisQCDAnalysisMy_Type1MET.root");

  TH1F * hPfMetDphiJJBDataClone = (TH1F*)hPfMetDphiJJBData->Clone();
  hPfMetDphiJJBDataClone->Sumw2();

  hPfMetDphiJJBData->GetXaxis()->SetTitle("E_{T}^{miss}, GeV");
  hPfMetDphiJJBData->GetYaxis()->SetTitle("Nev");
  hPfMetDphiJJBData->SetMinimum(1.);
  //  hPfMetDphiJJBData->SetMaximum(100000.);
  hPfMetDphiJJBData->SetMarkerStyle(20);
  hPfMetDphiJJBData->Draw("E1P");
  leg->SetFillColor(10);
  leg->AddEntry(hPfMetDphiJJBData,"Data","PL");

  // EW MC in signal region
  TFile* file = new TFile("AnneMarieEWK_METType1_My.root");

  TH1F *metRangeTotal_DPhiQCDClone = (TH1F*)metRangeTotal_DPhiQCD->Clone();
  metRangeTotal_DPhiQCDClone->Sumw2();

  metRangeTotal_DPhiQCD->SetLineWidth(2);
  metRangeTotal_DPhiQCD->SetLineStyle(1);
  metRangeTotal_DPhiQCD->Draw("SAMEE1");
  leg->AddEntry(metRangeTotal_DPhiQCD,"EW MC","PL");
  leg->Draw();

  TLatex *t = new TLatex();
  t->SetTextSize(0.042);
  t->DrawLatex(80.,10.,"#Delta#phi_{jj} > 2.6");
  t->DrawLatex(80.,4.,"Type 1 MET");
  t->DrawLatex(60.,2.,"tag.jets with no #mu's");

  c2->SaveAs("met_type1_b_my.gif");

  setTDRStyle(0,0,0);

  TCanvas* c3 = new TCanvas("X","Y",1);

  TLegend *leg = new TLegend(0.20,0.80,0.80,0.90,NULL,"brNDC");

  hrD->GetXaxis()->SetTitle("E_{T}^{miss}, GeV");
  hrD->GetYaxis()->SetTitle("multijet extrapolation factor r");
  hrD->Divide(hPfMetDphiJJSDataClone,hPfMetDphiJJBDataClone,1.,1.,"");
  hrD->SetMinimum(0.);
  hrD->SetMaximum(0.07);
  hrD->SetMarkerStyle(24);
  hrD->SetAxisRange(20.,120.,"X");
  hrD->SetTitleOffset(1.5, "Y");
  hrD->Draw("EP");

  hD_EW_S->Add(hPfMetDphiJJSDataClone,metRangeTotal_DPhiSIGNALClone,1.,-1.); 
  hD_EW_B->Add(hPfMetDphiJJBDataClone,metRangeTotal_DPhiQCDClone,1.,-1.);
  hrD_EW->Divide(hD_EW_S,hD_EW_B,1.,1.,"");
  hrD_EW->SetMarkerStyle(20);
  hrD_EW->Draw("SAMEEP");

  leg->AddEntry(hrD,"Data with no EW subtraction","PL");
  leg->AddEntry(hrD_EW,"Data with MC EW subtraction","PL");
  leg->Draw();

  TLatex *t = new TLatex();
  t->SetTextSize(0.042);
  t->DrawLatex(80.,0.015,"Type 1 MET");
  t->DrawLatex(60.,0.010,"tag.jets with no #mu's");


  c3->SaveAs("rD_type1_my.gif");

}
コード例 #27
0
void long_Ay_nu_05() {
  gROOT->SetStyle("HALLA");
  TCanvas *cn = new TCanvas("cn","cn",540,360);
  cn->Draw();
  cn->UseCurrentStyle();
  TH1F *frm = new TH1F("frm","",100,0.,10.);
  frm->GetXaxis()->SetTitle("#nu (GeV)");
  frm->GetYaxis()->SetTitle("Ay for Q2=0.456 (GeV/c)2");
  frm->SetMinimum(0);
//  frm->SetMinimum(0);
//  frm->SetMaximum(1.0);
  frm->SetMaximum(0.35);
  frm->UseCurrentStyle();
  frm->Draw();
  frm->SetAxisRange(0.120,0.350,"X");
//  frm->SetAxisRange(0.5,1.1,"X");

//  TF1* galster = new TF1("galster","x/(4.*0.938*.938)*1.91/(1.+x/.71)^2/(1.+5.6*x/(4.*.938*.938))",0.,4.);
//  galster->SetLineColor(6);
//  galster->SetLineStyle(3);
//  galster->SetLineWidth(2);


  TF1 *genf = new TF1("genf",genff,1.,10.,1);
  genf->SetLineColor(2);
  genf->SetLineStyle(2);
  genf->SetParameter(0,1.);
  // match to Madey point just below 1.5
  // genf->SetParameter(0,.0411/genf->Eval(1.45));
  genf->SetParameter(0,-0.558645);

//  TF1 *bbba05 = new TF1("BBBA05",gen_bbba05,0.,10.,0);
//  bbba05->SetLineColor(7);
//  bbba05->SetLineStyle(3);

  
  TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}");
  TLegend *legDta = new TLegend(.54,.6,.875,.90,"","brNDC");

  TMultiGraph* wgr = mgrDta;
  TLegend *wlg = legDta;

   // the data
  legDta->SetBorderSize(0); // turn off border
  legDta->SetFillStyle(0);
  
  datafile_t *f = datafiles;
  TGraph* gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      if (f->lnpt) {
	mgrDta->Add(gr,f->lnpt);
	legDta->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	mgrDta->Add(gr,"p");
	legDta->AddEntry(gr,f->label,"p");
      }	
      else {
	mgrDta->Add(gr,"l");
	legDta->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }
    

  mgrDta->Draw("p");
//  legDta->Draw();
  TF1 *theFit = new TF1("theFit","pol0");
  gr->Fit(theFit);
  theFit->Draw("same");  
  TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}");
  TLegend *legThry = new TLegend(.54,.3,.875,.6,"","brNDC");

  wgr = mgrThry;
  wlg = legThry;

  // the theory
  wlg->SetBorderSize(0); // turn off border
  wlg->SetFillStyle(0);
  
  f = theoryfiles1;
  gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
      if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
	gr = toerror_band(egr);
	gr->SetFillStyle(3000+f->style);
      }
      if (f->lnpt) {
	wgr->Add(gr,f->lnpt);
	wlg->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	wgr->Add(gr,"p");
	wlg->AddEntry(gr,f->label,"p");
      }	
      else {
	wgr->Add(gr,"l");
	wlg->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }

//  genf->Draw("same");
  mgrThry->Draw("c");
//  galster->Draw("same");
//  bbba05->Draw("same");
//  legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
//  legThry->AddEntry(galster,"Galster fit","l");
//  legThry->AddEntry(bbba05,"BBBA05","l");
//  legThry->Draw();
//  legDta->Draw();
  
  // draw a line at 1
  cn->Modified();

  cn->Update();
  cn->SaveAs(Form("%s.eps",psfile));
  cn->SaveAs(Form("%s.root",psfile));
  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));

  return;  // LEAVING HERE

  // now an overlay, hopefully matching dimensions

  // remove everything but the graph
  cn->Update();
  TList *clist = cn->GetListOfPrimitives();
  TFrame* frame = cn->GetFrame();
  for (int i=0; i<clist->GetSize(); ) {
    if (clist->At(i) != frame) {
      clist->RemoveAt(i);
    } else i++;
  }
  // draw markers in the corners
  TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
  mkr->Draw();
  frame->SetLineColor(10);
  cn->Update();

  datafile_t miller = { "figure_input/Miller/lattice.GEn.rtf","Miller",
			"[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" };

  gr = OneGraph(&miller);
  TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
  if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
    gr = toerror_band(egr);
    gr->SetLineStyle(1);
    gr->SetFillColor(gr->GetLineColor());
    gr->SetFillStyle(3000+miller.style);
  }
  
  gr->Draw("F");

  cn->Update();
  cn->SaveAs("gen_Miller_Overlay.eps");
  cn->SaveAs("gen_Miller_Overlay.root");
  
}
コード例 #28
0
ファイル: graphicHistos.C プロジェクト: jmhardin/FastDIRC
double runGraphicHistos(TString ifile = "tmpfitdirc.root", bool verbose_out=true, double ienergy = 5, int iupdown = 0)
{
	TCanvas *c1 = new TCanvas("myc1","myc1",1000,1200);

	if (verbose_out == false)
	{
		//supresses canvas message 
		//gErrorIgnoreLevl=kInfo;
		gROOT->ProcessLine( "gErrorIgnoreLevel = kWarning;");
	}

	double hmin = -100;
	double hmax = 100;

	hmin = -25;
	hmax = 25;

	double energy = ienergy;

	double pi_mass = .13957;
	double k_mass = .49367;

	double pi_beta = sqrt(1-pi_mass*pi_mass/(energy*energy));
	double k_beta = sqrt(1-k_mass*k_mass/(energy*energy));

	double quartz_index = 1.47;

	double pi_mrad = 1000*acos(1/(pi_beta*quartz_index));
	double k_mrad = 1000*acos(1/(k_beta*quartz_index));

	//double seperation = 5.2;
	double seperation = pi_mrad - k_mrad;
	double mean_pion = 0;
	double mean_kaon = mean_pion + seperation;
	if (verbose_out == true)
	{
		printf("Energy: %4.02f\n",energy);
		printf("Mrad Seperation: %8.03f\n",seperation);
	}
	//denominator pf spread

	TRandom3* randgen = new TRandom3();

	TFile *f1 = new TFile(ifile);
	TH1F *hpion;
	TH1F *hkaon;
	TH1F *phots_pion;
	if (iupdown == 0)
	{
		hpion = (TH1F*) f1->Get("ll_diff_pion");
		hkaon = (TH1F*) f1->Get("ll_diff_kaon");
		phots_pion = (TH1F*) f1->Get("phot_found_pion");
	}
	else if (iupdown == 1)
	{
		hpion = (TH1F*) f1->Get("ll_diff_pion_up");
		hkaon = (TH1F*) f1->Get("ll_diff_kaon_up");
		phots_pion = (TH1F*) f1->Get("phot_found_pion_up");
	}
	else if (iupdown == -1)
	{
		hpion = (TH1F*) f1->Get("ll_diff_pion_down");
		hkaon = (TH1F*) f1->Get("ll_diff_kaon_down");
		phots_pion = (TH1F*) f1->Get("phot_found_pion_down");
	}
	else
	{
		printf("Unrecognize updown arguement: %d \nFailing....\n",iupdown);
		return -1;
	}
	if (verbose_out == true)
	{
		printf("pion_ll mean, spread: %12.04f, %12.04f\n",hpion->GetMean(),hpion->GetRMS());
		printf("kaon_ll mean, spread: %12.04f, %12.04f\n",hkaon->GetMean(),hkaon->GetRMS());
	}
	double spread = seperation/2;
	double spreadsq2 = 2*spread*spread;
	//Swap kaon and pion numbers

	for (int i = 1; i < hpion->GetNbinsX()/2; i++)
	{
		double t_swap = hpion->GetBinContent(i);
		hpion->SetBinContent(i,hpion->GetBinContent(hpion->GetNbinsX() - i + 1));
		hpion->SetBinContent(hpion->GetNbinsX() - i + 1, t_swap);
	}
	for (int i = 1; i < hkaon->GetNbinsX()/2; i++)
	{
		double t_swap = hkaon->GetBinContent(i);
		hkaon->SetBinContent(i,hkaon->GetBinContent(hkaon->GetNbinsX() - i + 1));
		hkaon->SetBinContent(hkaon->GetNbinsX() - i + 1, t_swap);
	}

	double titlesize=1.2*.04;

	int rebin = 20;
	rebin = 160;
	hpion->Rebin(rebin);
	hkaon->Rebin(rebin);

	hpion->SetAxisRange(hmin,hmax);
	hkaon->SetAxisRange(hmin,hmax);

	hkaon->GetXaxis()->SetTitle("Loglikelihood difference");
	hkaon->GetYaxis()->SetTitle("A.U.");
	hkaon->GetXaxis()->SetTitleSize(titlesize);
	hkaon->GetYaxis()->SetTitleSize(titlesize);

	hpion->SetStats(false);
	hkaon->SetStats(false);

	hpion->SetLineColor(kCyan);
	//hpion->SetFillColorAlpha(kRed,.5);

	hkaon->SetLineColor(kBlue);
	//hkaon->SetFillColorAlpha(kBlue,.5);

	TLegend *leg_ll = new TLegend(.6,.6,.8,.8);
	leg_ll->AddEntry(hpion,"Pion");
	leg_ll->AddEntry(hkaon,"Kaon");
	leg_ll->SetBorderSize(0);


	hkaon->SetTitle("log(P(Pi)/P(K)) for actual Pi (red) and K (blue) at 5 GeV");



	TH1F *pion_veto_eff = new TH1F(*hpion);
	TH1F *kaon_missid = new TH1F(*hkaon);

	pion_veto_eff->SetName("pion_veto_eff");
	pion_veto_eff->SetTitle("");

	kaon_missid->SetName("kaon_missid");
	kaon_missid->SetTitle("");



	for (int i = 0; i < pion_veto_eff->GetNbinsX(); i++)
	{
		pion_veto_eff->SetBinContent(i,hpion->Integral(0,i));
		kaon_missid->SetBinContent(i,hkaon->Integral(i,kaon_missid->GetNbinsX()));
		//	printf("%12.04f %12.04f %d\n",1,1,i);
	}

	pion_veto_eff->SetAxisRange(0,10000,"Y");

	double scale_int = 1/hpion->Integral(0,pion_veto_eff->GetNbinsX());
	pion_veto_eff->Scale(scale_int);
	scale_int = 1/hkaon->Integral(0,kaon_missid->GetNbinsX());
	kaon_missid->Scale(scale_int);

	hkaon->SetTitle("");
	hpion->SetTitle("");


	if (verbose_out == true)
	{
		hkaon->Draw();
		hpion->Draw("SAME H");
		leg_ll->Draw("SAME");
		c1->SetWindowSize(1000,800);

		c1->Print("overlap.pdf");
	}

	if (verbose_out == true)
	{
		pion_veto_eff->Draw("");
		kaon_missid->Draw("SAME H");

		c1->SetWindowSize(1000,800);
		c1->Print("overlap_integral.pdf");
	}

	double linewidth=6;
	TGraph* roc_graph;
	int roc_n = pion_veto_eff->GetNbinsX();
	TVectorF xr(roc_n);//gross
	TVectorF yr(roc_n);
	double ival = 0;

	for (int i = 0; i < pion_veto_eff->GetNbinsX(); i++)
	{
		xr[i] = pion_veto_eff->GetBinContent(i);
		yr[i] = kaon_missid->GetBinContent(i);

		//	printf("%8.04f %8.04f\n",xr[i],yr[i]);	
	}

	double y1,y2,x1,x2;
	x1 = pion_veto_eff->GetBinContent(0);
	double last_x = pion_veto_eff->GetBinContent(0);
	double last_y = kaon_missid->GetBinContent(0);

	for (int i = 0; i < pion_veto_eff->GetNbinsX()-1; i++)
	{
		ival += (yr[i]+last_y)*(xr[i] - last_x)/2;
                //printf("%6d %12.09f %12.04f %12.04f %12.04f %12.04f\n",i,ival,xr[i],yr[i],last_x,last_y);
		last_x = xr[i];
		last_y = yr[i];
		
	}

	if (verbose_out == true)
	{
		printf("ROC integral: %12.04f\n",ival);
	}

	roc_graph = new TGraph(xr,yr);
	roc_graph->SetLineColor(2);
	roc_graph->SetLineWidth(4);
	//roc_graph->SetMarkerColor(4);
	//roc_graph->SetMarkerStyle(21);
	roc_graph->SetTitle("");
	roc_graph->GetXaxis()->SetTitle("Kaon Efficiency");
	roc_graph->GetYaxis()->SetTitle("Pion Rejection");
	roc_graph->GetXaxis()->SetTitleSize(titlesize);
	roc_graph->GetYaxis()->SetTitleSize(titlesize);
	roc_graph->GetXaxis()->SetLimits(0,1.01);
	roc_graph->SetMinimum(0);
	roc_graph->SetMaximum(1.01);
	roc_graph->SetLineWidth(linewidth);

	if (verbose_out == true)
	{
		roc_graph->Draw("ACP");
		c1->Print("roc_curve.gif");
	}
	spread = find_sig_val(seperation,ival,spread); 


	//FAKE version stuff below
	/*---------------------------------------------------------------------------------------------------------------------------*/




	TH1F *fhpion = (TH1F*) f1->Get("ll_diff_pion");
	TH1F *fhkaon = (TH1F*) f1->Get("ll_diff_kaon");

	fhpion->Reset();
	fhkaon->Reset();

	fhpion->SetBins(1000,hmin,hmax);
	fhkaon->SetBins(1000,hmin,hmax);

	double pion_obs, kaon_obs;
	double pion_ll_diff, kaon_ll_diff;

	for (int ii = 0; ii < 10000; ii++)
	{
		pion_obs = randgen->Gaus(mean_pion,spread);
		kaon_obs = randgen->Gaus(mean_kaon,spread);

		pion_ll_diff = -1*(pion_obs - mean_pion)*(pion_obs - mean_pion);
		pion_ll_diff += (pion_obs - mean_kaon)*(pion_obs - mean_kaon);
		pion_ll_diff /= spreadsq2;

		kaon_ll_diff = - (kaon_obs - mean_pion)*(kaon_obs - mean_pion);
		kaon_ll_diff += (kaon_obs - mean_kaon)*(kaon_obs - mean_kaon);
		kaon_ll_diff /= spreadsq2;

		fhpion->Fill(pion_ll_diff);
		fhkaon->Fill(kaon_ll_diff);
	}


	fhpion->SetAxisRange(hmin,hmax);
	fhkaon->SetAxisRange(hmin,hmax);

	fhpion->SetLineColor(kRed);
	//hpion->SetFillColorAlpha(kRed,.5);

	fhkaon->SetLineColor(kBlue);
	//hkaon->SetFillColorAlpha(kBlue,.5);

	fhkaon->SetTitle("");

	TH1F *fpion_veto_eff = new TH1F(*fhpion);
	TH1F *fkaon_missid = new TH1F(*fhkaon);

	fpion_veto_eff->SetName("pion_veto_eff");
	fpion_veto_eff->SetTitle("");

	fkaon_missid->SetName("kaon_missid");
	fkaon_missid->SetTitle("");

	for (int i = 0; i < fpion_veto_eff->GetNbinsX(); i++)
	{
		fpion_veto_eff->SetBinContent(i,fhpion->Integral(i,fpion_veto_eff->GetNbinsX()));
		fkaon_missid->SetBinContent(i,fhkaon->Integral(0,i));
	}

	fpion_veto_eff->SetAxisRange(0,10000,"Y");

	double fscale_int = 1/fhpion->Integral(0,fpion_veto_eff->GetNbinsX());
	fpion_veto_eff->Scale(fscale_int);
	fscale_int = 1/fhkaon->Integral(0,fkaon_missid->GetNbinsX());
	fkaon_missid->Scale(fscale_int);




	TGraph* froc_graph;
	int froc_n = fpion_veto_eff->GetNbinsX();
	TVectorF fxr(froc_n);
	TVectorF fyr(froc_n);

	double fival = 0;
	double flast_x = fpion_veto_eff->GetBinContent(0);
	double flast_y = fkaon_missid->GetBinContent(0);
	for (int i = 0; i < fpion_veto_eff->GetNbinsX(); i++)
	{
		fxr[i] = fpion_veto_eff->GetBinContent(i);
		fyr[i] = fkaon_missid->GetBinContent(i);


		fival -= (fyr[i]+flast_y)*(fxr[i] - flast_x)/2;
		flast_x = fxr[i];
		flast_y = fyr[i];
	}
	ival = 0;
	flast_x = fpion_veto_eff->GetBinContent(0);
	flast_y = fkaon_missid->GetBinContent(0);
	for (int i = 0; i < fpion_veto_eff->GetNbinsX(); i++)
	{

		//Why oh why is Erf not the standard definition
		double t = hmin + i*(hmax-hmin)/fpion_veto_eff->GetNbinsX();
		fxr[i] = .5 + TMath::Erf(t/(sqrt(2)*spread))/2;
		fyr[i] = .5 - TMath::Erf((t-seperation)/(sqrt(2)*spread))/2;

		fival -= (fyr[i]+flast_y)*(fxr[i] - flast_x)/2;
		flast_x = fxr[i];
		flast_y = fyr[i];
	}	
	//printf("Fake ROC integral: %12.04f\n",fival);


	froc_graph = new TGraph(fxr,fyr);
	if (verbose_out == true)
	{
		froc_graph->SetLineColor(4);
		froc_graph->SetLineWidth(linewidth);
		froc_graph->SetLineStyle(2);
		froc_graph->SetTitle("");
		froc_graph->GetXaxis()->SetTitle("\"Kaon Efficiency\"");
		froc_graph->GetYaxis()->SetTitle("\"Pion Rejection\"");
		froc_graph->GetXaxis()->SetTitleSize(titlesize);
		froc_graph->GetYaxis()->SetTitleSize(titlesize);
		froc_graph->GetXaxis()->SetLimits(0,1.01);
		froc_graph->SetMinimum(0);
		froc_graph->SetMaximum(1.01);


		roc_graph->SetFillColorAlpha(kWhite,1);
		froc_graph->SetFillColorAlpha(kWhite,1);
		TLegend *leg_roc = new TLegend(.3,.5,.7,.7);
		leg_roc->AddEntry(roc_graph,"ROC Curve");
		leg_roc->AddEntry(froc_graph,"Matched Gaussian ROC Curve");
		leg_roc->SetBorderSize(0);
		leg_roc->SetTextSize(0.04*1.1);

		froc_graph->Draw("SAME");
		leg_roc->Draw("SAME");
		c1->Print("roc_curve_overlay.pdf");
	}



	if (verbose_out == true)
	{
		printf("Matching resolution: %6.03f\n",spread);
		printf("Matching resolution per photon: %6.03f\n",spread*sqrt(phots_pion->GetMean()));
	}
	else
	{
		printf("%6.04f\n",spread);
	}
	return spread;

}