当前位置: 首页>>代码示例>>C++>>正文


C++ TH1::SetMarkerColor方法代码示例

本文整理汇总了C++中TH1::SetMarkerColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::SetMarkerColor方法的具体用法?C++ TH1::SetMarkerColor怎么用?C++ TH1::SetMarkerColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TH1的用法示例。


在下文中一共展示了TH1::SetMarkerColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: overlay_Merged_RecoSmeared

TCanvas* overlay_Merged_RecoSmeared(const vector<string>& folders, 
								const hist_t& h
								)
{

	TLegend *leg  = new TLegend(0.6,0.65,0.9,0.9);
	leg->SetTextFont(42);
	vector<TH1*> hists;
	
	vector<string> jetcoll;
	jetcoll.push_back("reco");
	jetcoll.push_back("gen");
	jetcoll.push_back("smeared");

	stringstream title;
	const string njets("3-5");
	//const string eta("2.5");
	const string eta("5.0");
	title << njets
			<< " Jets, MHT from Jets with P_{T}>30 GeV, |#eta |<" 
			<< eta << ", L = 10 fb^{-1}" << ";" << h.title ;

	for (unsigned j=0; j< jetcoll.size(); ++j)
	{
		TH1* Hist = 0;
		for (unsigned i = 0; i < folders.size(); ++i)
		{
			stringstream histname;
			histname << folders.at(i) << "/" << jetcoll.at(j) << h.name;
			cout << __LINE__ << ": Looking for hist: " << histname.str().c_str() << endl;
			TH1* htemp = GetHist(histname.str());
			
			if (Hist == 0) Hist = htemp;
			else Hist->Add(htemp);
		}
		
		Hist->Rebin(h.rebin);
		Hist->SetTitle(title.str().c_str());
		Hist->SetMarkerStyle(20+j);
		Hist->SetLineWidth(2);
		Hist->SetStats(0);

		stringstream legname;
		if (j==0) 
		{
			legname << "Reco"; 
		} else if (j==1) 
		{
			legname << "Gen"; 
			Hist->SetLineColor(kBlue);
			Hist->SetMarkerColor(kBlue);
		} else if (j==2)
		{
			legname << "Smeared"; 
			Hist->SetLineColor(kRed);
			Hist->SetMarkerColor(kRed);
		}

		const double sum = Hist->Integral(); 
		legname << " (" << sum << ")";
		if (j!=1) leg->AddEntry(Hist, legname.str().c_str());

		hists.push_back(Hist);

	} //end jetcoll
	
	TH1* ratio = dynamic_cast<TH1*> (hists.at(2)->Clone("ratio"));
	ratio->GetYaxis()->SetTitle("Smeared/Reco");
	ratio->SetTitle("");
	ratio->Divide(hists.at(0));
	ratio->GetYaxis()->SetRangeUser(-0.01,2.01);
	//ratio->SetTickLength (+0.01,"Y");

   //TCanvas *c1 = new TCanvas("c1", "c1",15,60,550,600);
   TCanvas *c1 = new TCanvas("c1");
   c1->Range(0,0,1,1);
   c1->SetBorderSize(2);
   c1->SetFrameFillColor(0);
  
// ------------>Primitives in pad: c1_1
   TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.30,0.99,0.99);
   c1_1->Draw();
   c1_1->cd();
   c1_1->SetBorderSize(2);
   c1_1->SetTickx(1);
   c1_1->SetTicky(1);
   c1_1->SetTopMargin(0.1);
   c1_1->SetBottomMargin(0.0);
   //c1_1->SetFrameFillColor(3);
	c1_1->SetLogy();
   
	hists.at(0)->GetYaxis()->CenterTitle(1);
	hists.at(0)->SetLabelFont(42,"XYZ");
	hists.at(0)->SetTitleFont(42,"XYZ");
	hists.at(0)->GetYaxis()->SetTitleOffset(0.8);
	hists.at(0)->SetLabelSize(0.05,"XYZ");
	hists.at(0)->SetTitleSize(0.06,"XYZ");
   hists.at(0)->Draw("P");
   hists.at(2)->Draw("same P");
	leg->Draw();
//.........这里部分代码省略.........
开发者ID:hkaushalya,项目名称:UserCode,代码行数:101,代码来源:overlay_Merged_RecoSmeared.C

示例2: check1SLimits

void check1SLimits(
                   const char* workDir, // workDir: usual tag where to look for files in Output
                   const char* lFileName="cLimits_683_NominalABCD_Asym_2SPL_woSyst.csv", // file name to save limits results
                   bool dosyst = false,
                   int mode = 1, // mode=0 -> pass, mode=1 -> prompt, mode=2 -> nonprompt
                   const char* workDirFail=""
)
{
  TString slFileName(lFileName);
  if ( dosyst && !slFileName.Contains("wSys") )
  {
    cout << "Comparison requires systematics but limits file does not contain them" << endl;
    return;
  }
  
  // list of files
  set<anabin> thebins = allbins();
  const char* ppp = "../Fitter";
  
  // systematic uncertainties for fit
  map<anabin, syst> syst_All;
  if ( dosyst )
  {
     if (mode==0) syst_All = readSyst_all_pass("",ppp,workDir);
     if (mode==1) syst_All = readSyst_all_prompt("",ppp,workDir,workDirFail);
     if (mode==2) syst_All = readSyst_all_nonprompt("",ppp,workDir,workDirFail);
  }
  
  // bin edges
  float ptmin, ptmax, ymin, ymax, centmin, centmax;
  
  // histo for 1sigma limits checks
  TH1* hCL = new TH1D("hOneSigmaCLComparison","",thebins.size(),0,thebins.size());
  hCL->GetYaxis()->SetTitle("CL_{1#sigma}/#sigma");
  hCL->GetYaxis()->SetTitleOffset(1.15);
  hCL->SetStats(0);
  hCL->SetDirectory(0);
  hCL->SetMarkerColor(1);
  hCL->SetMarkerStyle(20);
  hCL->SetMarkerSize(1);
  hCL->SetLineColor(1);
  
  TLine* l1 = new TLine(0.,1.,hCL->GetXaxis()->GetXmax(),1.);
  l1->SetLineWidth(3);
  
  hCL->GetListOfFunctions()->Add(l1);

  map<anabin,limits> maplim = readLimits(Form("csv/%s",slFileName.Data()));
  
  int cnt=1;
  for (set<anabin>::const_iterator it=thebins.begin(); it!=thebins.end(); it++)
  {
     cout << "Checking 1 sigma limits for analysis bin " << cnt << endl;

     anabin thebin = *it;
     ptmin = thebin.ptbin().low();
     ptmax = thebin.ptbin().high();
     ymin = thebin.rapbin().low();
     ymax = thebin.rapbin().high();
     centmin = thebin.centbin().low();
     centmax = thebin.centbin().high();

     double sigmaDoubleR = 0;
     double doubleR = 0;
     if (mode==0) {
        doubleR = doubleratio_pass_nominal(workDir,thebin,ppp);
        sigmaDoubleR = doubleratio_pass_stat(workDir,thebin,ppp);
     }
     if (mode==1) {
        doubleR = doubleratio_prompt_nominal(workDir,workDirFail,thebin,ppp);
        sigmaDoubleR = doubleratio_prompt_stat(workDir,workDirFail,thebin,ppp);
     }
     if (mode==2) {
        doubleR = doubleratio_nonprompt_nominal(workDir,workDirFail,thebin,ppp);
        sigmaDoubleR = doubleratio_nonprompt_stat(workDir,workDirFail,thebin,ppp);
     }

     double systAll=0;
     if ( dosyst )
     {
        systAll = syst_All[thebin].value_dR;
        sigmaDoubleR = sqrt(pow(sigmaDoubleR,2)+pow(systAll,2));
     }

     limits lim = maplim[thebin];

     TString binName(Form("Pt[%.1f,%.1f]-Y[%.1f,%.1f]-C[%.1f,%.1f]",ptmin,ptmax,ymin,ymax,centmin,centmax));

     double comp = -1.;
     if ( sigmaDoubleR != 0 ) comp = (lim.val.second-lim.val.first)/(2.*sigmaDoubleR);
     hCL->SetBinContent(cnt,comp);
     hCL->GetXaxis()->SetBinLabel(cnt,binName.Data());

     cnt++;
  } // loop on the files

  TFile* fSave = new TFile("oneSigmaCLComparison.root","RECREATE");
  
  TCanvas* c = new TCanvas("cOneSigmaCLComparison","",90,116,1265,535);
  c->Range(-3.690909,-0.01066472,33.30606,0.01252061);
//.........这里部分代码省略.........
开发者ID:CMS-HIN-dilepton,项目名称:DimuonCADIs,代码行数:101,代码来源:check1SLimits.C

示例3: TCanvas

TH1 *
UnfoldMe_MB2(const Char_t *data, const Char_t *mc, const Char_t *anatag, Int_t bin, Bool_t useMBcorr , Bool_t usecorrfit , Bool_t ismc , Float_t smooth , Int_t iter , Int_t regul , Float_t weight , Bool_t bayesian , Int_t nloop )
{

  // MF comments:
  // usedMBcorr: changes the matrix used for unfonding, from effMatrix to bin matrix (I think this is just to use mult dependent v s mb correction_)
  // usecorrfit: if I understand correctly, fits the response matrix and uses fit to extrapolate it

  
  TFile *fdt =0;
  if (ismc)
    fdt =  TFile::Open(data);
  else
    fdt = TFile::Open(data);
  TFile *fmc = TFile::Open(mc);

  TList *ldt = (TList *)fdt->Get(Form("%s", anatag));
  TList *lmc = (TList *)fmc->Get(Form("%s", anatag));
  
  TH2 *hmatdt = (TH2 *)ldt->FindObject(Form(responseMatrix, bin));
  TH2 *hmatmc = 0;
  if (useMBcorr){
     hmatmc = (TH2 *)lmc->FindObject("effMatrix");
     std::cout << "USING MB" << std::endl;
     
  }
  else {
    hmatmc = (TH2 *)lmc->FindObject(Form(responseMatrix, bin));
  }

  TH1 *hdata = hmatdt->ProjectionY("hdata");
//  TH1 *hdata = hmatdt->ProjectionY("htrue");  // For truth Only Calculations

  hdata->Sumw2();
  hdata->SetBinContent(1, 0.);
  hdata->SetBinError(1, 0.);
  //  hdata->Scale(1. / hdata->Integral());
  hdata->SetMarkerStyle(25);
  TH1 *htrue = hmatdt->ProjectionX("htrue");
  htrue->Sumw2();
  //  htrue->Scale(1. / htrue->Integral());
  htrue->SetMarkerStyle(7);
  htrue->SetMarkerColor(2);
  htrue->SetBinContent(1, 0.);
  htrue->SetBinError(1, 0.);

  TH2 *hcorr = (TH2 *)hmatmc->Clone("hcorr");
  TH1 *hinit = (TH1 *)hdata->Clone("hinit");
  TH1 *hresu = (TH1 *)hdata->Clone("hresu");
  TH1 *hbias = (TH1 *)hdata->Clone("hbias");
  hresu->SetMarkerStyle(20);
  hresu->SetMarkerColor(4);
  hresu->Reset();

  TH1 *hnum = hcorr->ProjectionY("hnum");
  TH1 *hden = hcorr->ProjectionY("hden");
  TH1 *heff = hcorr->ProjectionY("heff");
  hnum->Reset();
  hnum->Sumw2();
  hden->Reset();
  hden->Sumw2();
  heff->Reset();
  for (Int_t i = 0; i < heff->GetNbinsX(); i++) {
    Float_t int1 = hcorr->Integral(i + 1, i + 1, 0, -1);
    if (int1 <= 0.) continue;
    Float_t int2 = hcorr->Integral(i + 1, i + 1, 2, -1);
    hnum->SetBinContent(i + 1, int2);
    hnum->SetBinError(i + 1, TMath::Sqrt(int2));
    hden->SetBinContent(i + 1, int1);
    hden->SetBinError(i + 1, TMath::Sqrt(int1));
  }
  TCanvas *cEfficiency = new TCanvas("cEfficiency", "cEfficiency");
  cEfficiency->SetLogx();
  cEfficiency->SetLogy();

  heff->Divide(hnum, hden, 1., 1., "B");
  heff->Draw();
#if 0
  for (Int_t ii = 0; ii < heff->GetNbinsX(); ii++) {
    heff->SetBinContent(ii + 1, 1.);
    heff->SetBinError(ii + 1, 0.);
  }
#endif

  for (Int_t i = 0; i < hcorr->GetNbinsX(); i++) {
    hcorr->SetBinContent(i + 1, 1, 0.);
    hcorr->SetBinError(i + 1, 1, 0.);
  }
  for (Int_t i = 0; i < hcorr->GetNbinsY(); i++) {
    hcorr->SetBinContent(1, i + 1, 0.);
    hcorr->SetBinError(1, i + 1, 0.);
  }
  TH2 *hcorrfit = ReturnCorrFromFit(hcorr);
  // Docs from AliUnfolding
  //Int_t AliUnfolding::Unfold(TH2* correlation, TH1* efficiency, TH1* measured, TH1* initialConditions, TH1* result, Bool_t check)
  // unfolds with unfolding method fgMethodType
  //
  // parameters:
  //  correlation: response matrix as measured vs. generated
  //  efficiency:  (optional) efficiency that is applied on the unfolded spectrum, i.e. it has to be in unfolded variables. If 0 no efficiency is applied.
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:playV0M.C

示例4: makeHist


//.........这里部分代码省略.........
				}
				if (title.length()>0)
				{
					hreco->SetTitle(title.c_str());
					hsmear->SetTitle(title.c_str());
					hgen->SetTitle(title.c_str());
				}
				if (xmin != LargeNegNum || xmax != LargeNegNum)
				{
					hreco->GetXaxis()->SetRangeUser(xmin,xmax);
					hsmear->GetXaxis()->SetRangeUser(xmin,xmax);
					hgen->GetXaxis()->SetRangeUser(xmin,xmax);
				}

				const double reco_max_y  = hreco->GetBinContent(hreco->GetMaximumBin());
				const double smear_max_y = hsmear->GetBinContent(hsmear->GetMaximumBin());
				const double y_max = max(reco_max_y, smear_max_y);
				double y_min = 9999.0;
				for (unsigned bin=1; bin<hreco->GetNbinsX(); ++bin)
				{
					const double v1 = hreco->GetBinContent(bin);
					const double v2 = hsmear->GetBinContent(bin);
					const double minv = min(v1,v2);
					if (minv != 0 && minv < y_min) y_min = minv;
					
				}

				cout << hreco->GetName() << "->ymin/max = " << y_min << "(" << y_min/2.0 << ")/" << y_max << "(" << y_max*2.0 << ")" << endl;
				hreco->GetYaxis()->SetRangeUser(y_min/2.0, y_max*2.0);
				hsmear->GetYaxis()->SetRangeUser(y_min/2.0, y_max*2.0);


				hgen->SetLineColor(kBlue);
				hgen->SetMarkerColor(kBlue);
				hgen->SetMarkerStyle(24);
				hgen->SetLineWidth(2);
				hsmear->SetLineColor(kRed);
				hsmear->SetMarkerColor(kRed);
				hsmear->SetMarkerStyle(24);
				hsmear->SetLineWidth(2);
				hreco->SetLineWidth(2);
				hreco->SetMarkerStyle(kDot);
				hreco->SetLineColor(kBlack);
				hreco->SetMarkerColor(kBlack);
				//hreco->GetXaxis()->SetRangeUser(0,300);
				//hsmear->GetXaxis()->SetRangeUser(0,300);


				hreco->GetYaxis()->CenterTitle(1);
				hreco->SetLabelFont(42,"XYZ");
				hreco->SetTitleFont(42,"XYZ");
				hreco->GetYaxis()->SetTitleOffset(0.8);
				hreco->SetLabelSize(0.05,"XYZ");
				hreco->SetTitleSize(0.06,"XYZ");


				TH1 *hsmeartoreco_ratio = (TH1*) (hsmear->Clone("hsmear_copy"));
				hsmeartoreco_ratio->Divide(hreco);
				hsmeartoreco_ratio->SetTitle("");
				hsmeartoreco_ratio->GetYaxis()->SetTitle("Smear/Reco");
				hsmeartoreco_ratio->GetYaxis()->SetRangeUser(0,2.);

				hsmeartoreco_ratio->GetYaxis()->SetTitleOffset(0.4);
				hsmeartoreco_ratio->GetXaxis()->SetTitleOffset(0.9);
				hsmeartoreco_ratio->GetYaxis()->CenterTitle(1);
				hsmeartoreco_ratio->GetXaxis()->CenterTitle(1);
开发者ID:hkaushalya,项目名称:UserCode,代码行数:67,代码来源:makeHist.C

示例5: setHistStyle

//------------------------------------------------------------------------------
void  PlotAlignmentValidation::setHistStyle( TH1& hist,const char* titleX, const char* titleY, int color)
{
  std::stringstream titel_Xaxis;
  std::stringstream titel_Yaxis;
  TString titelXAxis=titleX;
  TString titelYAxis=titleY;
  
  if ( titelXAxis.Contains("Phi") )titel_Xaxis<<titleX<<"[rad]";
  else if( titelXAxis.Contains("meanX") )titel_Xaxis<<"#LTx'_{pred}-x'_{hit}#GT[cm]";
  else if( titelXAxis.Contains("meanY") )titel_Xaxis<<"#LTy'_{pred}-y'_{hit}#GT[cm]";
  else if( titelXAxis.Contains("rmsX") )titel_Xaxis<<"RMS(x'_{pred}-x'_{hit})[cm]";
  else if( titelXAxis.Contains("rmsY") )titel_Xaxis<<"RMS(y'_{pred}-y'_{hit})[cm]";
  else if( titelXAxis.Contains("meanNormX") )titel_Xaxis<<"#LTx'_{pred}-x'_{hit}/#sigma#GT";
  else if( titelXAxis.Contains("meanNormY") )titel_Xaxis<<"#LTy'_{pred}-y'_{hit}/#sigma#GT";
  else if( titelXAxis.Contains("rmsNormX") )titel_Xaxis<<"RMS(x'_{pred}-x'_{hit}/#sigma)";
  else if( titelXAxis.Contains("rmsNormY") )titel_Xaxis<<"RMS(y'_{pred}-y'_{hit}/#sigma)";
  else if( titelXAxis.Contains("meanLocalX") )titel_Xaxis<<"#LTx_{pred}-x_{hit}#GT[cm]";
  else if( titelXAxis.Contains("rmsLocalX") )titel_Xaxis<<"RMS(x_{pred}-x_{hit})[cm]";
  else if( titelXAxis.Contains("meanNormLocalX") )titel_Xaxis<<"#LTx_{pred}-x_{hit}/#sigma#GT[cm]";
  else if( titelXAxis.Contains("rmsNormLocalX") )titel_Xaxis<<"RMS(x_{pred}-x_{hit}/#sigma)[cm]";
  else if( titelXAxis.Contains("medianX") )titel_Xaxis<<"median(x'_{pred}-x'_{hit})[cm]";
  else if( titelXAxis.Contains("medianY") )titel_Xaxis<<"median(y'_{pred}-y'_{hit})[cm]";
  else titel_Xaxis<<titleX<<"[cm]";
  
  if (hist.IsA()->InheritsFrom( TH1F::Class() ) )hist.SetLineColor(color);
  if (hist.IsA()->InheritsFrom( TProfile::Class() ) ) {
    hist.SetMarkerStyle(20);
    hist.SetMarkerSize(0.8);
    hist.SetMarkerColor(color);
  }
  
  hist.GetXaxis()->SetTitle( (titel_Xaxis.str()).c_str() );
  hist.GetXaxis()->SetTitleSize  ( 0.05 );
  hist.GetXaxis()->SetTitleColor (    1 );
  hist.GetXaxis()->SetTitleOffset(  1.2   );
  hist.GetXaxis()->SetTitleFont  (   62 );
  hist.GetXaxis()->SetLabelSize  ( 0.05 );
  hist.GetXaxis()->SetLabelFont  (   62 );
  //hist.GetXaxis()->CenterTitle   (      );
  hist.GetXaxis()->SetNdivisions (  505 );

  if /*( titelYAxis.Contains("meanX") )titel_Yaxis<<"#LTx'_{pred}-x'_{hit}#GT[cm]";
  else if ( titelYAxis.Contains("rmsX") )titel_Yaxis<<"RMS(x'_{pred}-x'_{hit})[cm]";
  else if( titelYAxis.Contains("meanNormX") )titel_Yaxis<<"#LTx'_{pred}-x'_{hit}/#sigma#GT";
  else if( titelYAxis.Contains("rmsNormX") )titel_Yaxis<<"RMS(x_'{pred}-x'_{hit}/#sigma)";
  else if( titelYAxis.Contains("meanLocalX") )titel_Yaxis<<"#LTx_{pred}-x_{hit}#GT[cm]";
  else if( titelYAxis.Contains("rmsLocalX") )titel_Yaxis<<"RMS(x_{pred}-x_{hit})[cm]";
  else if*/ ( (titelYAxis.Contains("layer") && titelYAxis.Contains("subDetId"))
	      || titelYAxis.Contains("#modules") )titel_Yaxis<<"#modules";
  else if ( (titelYAxis.Contains("ring") && titelYAxis.Contains("subDetId"))
	    || titelYAxis.Contains("#modules") )titel_Yaxis<<"#modules";
  else titel_Yaxis<<titleY<<"[cm]";

  hist.GetYaxis()->SetTitle( (titel_Yaxis.str()).c_str()  );
  //hist.SetMinimum(1);
  hist.GetYaxis()->SetTitleSize  ( 0.05 );
  hist.GetYaxis()->SetTitleColor (    1 );
  if ( hist.IsA()->InheritsFrom( TH2::Class() ) ) hist.GetYaxis()->SetTitleOffset( 0.95 );
  else hist.GetYaxis()->SetTitleOffset( 1.2 );
  hist.GetYaxis()->SetTitleFont  (   62 );
  hist.GetYaxis()->SetLabelSize  ( 0.03 );
  hist.GetYaxis()->SetLabelFont  (   62 );

}
开发者ID:HeinerTholen,项目名称:cmssw,代码行数:65,代码来源:PlotAlignmentValidation.C

示例6: makePlot

void makePlot(TCanvas* canvas, const std::string& outputFileName, TTree* testTree, const std::string& varName, 
	      unsigned numBinsX, double xMin, double xMax)
{
  std::cout << "creating histogramTauIdPassed..." << std::endl;
  TString histogramTauIdPassedName = TString("histogramTauIdPassed").Append("_").Append(varName.data());
  TH1* histogramTauIdPassed = fillHistogram(testTree, varName, "type==1", "",
					    histogramTauIdPassedName.Data(), numBinsX, xMin, xMax);
  std::cout << "--> histogramTauIdPassed = " << histogramTauIdPassed << ":" 
	    << " integral = " << histogramTauIdPassed->Integral() << std::endl;

  std::cout << "creating histogramTauIdFailed..." << std::endl;
  TString histogramTauIdFailedName = TString("histogramTauIdFailed").Append("_").Append(varName.data());
  TH1* histogramTauIdFailed = fillHistogram(testTree, varName, "type==0", "",
					    histogramTauIdFailedName.Data(), numBinsX, xMin, xMax);
  std::cout << "--> histogramTauIdFailed = " << histogramTauIdFailed 
	    << " integral = " << histogramTauIdFailed->Integral() << std::endl;

  std::cout << "creating histogramTauIdDenominator..." << std::endl;
  TString histogramTauIdDenominatorName = TString("histogramTauIdDenominator").Append("_").Append(varName.data());
  TH1* histogramTauIdDenominator = new TH1F(histogramTauIdDenominatorName.Data(), 
					    histogramTauIdDenominatorName.Data(), numBinsX, xMin, xMax);
  histogramTauIdDenominator->Add(histogramTauIdPassed);
  histogramTauIdDenominator->Add(histogramTauIdFailed);
  std::cout << "--> histogramTauIdDenominator = " << histogramTauIdDenominator 
	    << " integral = " << histogramTauIdDenominator->Integral() << std::endl;

  std::cout << "creating histogramFakeRate..." << std::endl;
  TString histogramFakeRateName = TString("histogramFakeRate").Append("_").Append(varName.data());
  TH1* histogramFakeRate = new TH1F(histogramFakeRateName.Data(), 
				    histogramFakeRateName.Data(), numBinsX, xMin, xMax);
  histogramFakeRate->Add(histogramTauIdPassed);
  histogramFakeRate->Divide(histogramTauIdDenominator);
  std::cout << "--> histogramFakeRate = " << histogramFakeRate 
	    << " integral = " << histogramFakeRate->Integral() << std::endl;

  std::cout << "creating histogramFakeRateWeighted..." << std::endl;
  TString histogramFakeRateWeightedName = TString("histogramFakeRateWeighted").Append("_").Append(varName.data());
  TH1* histogramFakeRateWeighted = fillHistogram(testTree, varName, "", "MVA_KNN", 
						 histogramFakeRateWeightedName.Data(), numBinsX, xMin, xMax);
  histogramFakeRateWeighted->Divide(histogramTauIdDenominator);
  std::cout << "--> histogramFakeRateWeighted = " << histogramFakeRateWeighted 
	    << " entries = " << histogramFakeRateWeighted->GetEntries() << ","
	    << " integral = " << histogramFakeRateWeighted->Integral() << std::endl;
  // Scale the weighted fake rate histogram

  histogramFakeRate->SetTitle(varName.data());
  histogramFakeRate->SetStats(false);
  histogramFakeRate->SetMinimum(1.e-4);
  histogramFakeRate->SetMaximum(1.e+1);
  histogramFakeRate->SetLineColor(2);
  histogramFakeRate->SetLineWidth(2);
  histogramFakeRate->SetMarkerStyle(20);
  histogramFakeRate->SetMarkerColor(2);
  histogramFakeRate->SetMarkerSize(1);
  histogramFakeRate->Draw("e1p");

  histogramFakeRateWeighted->SetLineColor(4);
  histogramFakeRateWeighted->SetLineWidth(2);
  histogramFakeRateWeighted->SetMarkerStyle(24);
  histogramFakeRateWeighted->SetMarkerColor(4);
  histogramFakeRateWeighted->SetMarkerSize(1);
  histogramFakeRateWeighted->Draw("e1psame");

  TLegend legend(0.11, 0.73, 0.31, 0.89);
  legend.SetBorderSize(0);
  legend.SetFillColor(0);
  legend.AddEntry(histogramFakeRate, "Tau id. discr.", "p");
  legend.AddEntry(histogramFakeRateWeighted, "Fake-Rate weight", "p");
  legend.Draw();

  canvas->Update();
  canvas->Print(outputFileName.data());
}
开发者ID:akalinow,项目名称:TauAnalysis-TauIdEfficiency,代码行数:73,代码来源:validateTauFakeRateKNN.C

示例7: dNdEta_ThreeMethods_FullTrackingRebinned_DividedByMidRapidValue

void dNdEta_ThreeMethods_FullTrackingRebinned_DividedByMidRapidValue() {
//=========Macro generated from canvas: MyCanvas/MyCanvas
//=========  (Thu Dec 10 11:52:00 2009) by ROOT version5.22/00d

   gROOT->Reset();
   gROOT->ProcessLine(".x rootlogon.C");

   gStyle->SetTitleYOffset(1.4);


   TCanvas *MyCanvas = new TCanvas("MyCanvas", "Final result",1,360,550,600); 
   TH1 *corr_result_all = new TH1D("corr_result_all","",14,-3.5,3.5);
   corr_result_all->GetXaxis()->SetRange(2,13);

   // ========================= Cluster Counting =======================

   corr_result_all->SetBinContent(4,4.043821);  // -2.0 to -1.5
   corr_result_all->SetBinContent(5,3.821537);  // -1.5 to -1.0 
   corr_result_all->SetBinContent(6,3.611029); // -1.0 to -0.5
   corr_result_all->SetBinContent(7,3.501129); // -0.5 to 0.0
   corr_result_all->SetBinContent(8,3.51732);      
   corr_result_all->SetBinContent(9,3.632249);      
   corr_result_all->SetBinContent(10,3.747706);    
   corr_result_all->SetBinContent(11,4.01596);  

   corr_result_all->SetBinError(4,0.177928124);
   corr_result_all->SetBinError(5,0.168147628);
   corr_result_all->SetBinError(6,0.158885276);
   corr_result_all->SetBinError(7,0.154049676);
   corr_result_all->SetBinError(8,0.15476208);
   corr_result_all->SetBinError(9,0.159818956);
   corr_result_all->SetBinError(10,0.164899064);
   corr_result_all->SetBinError(11,0.17670224);

   /*
   corr_result_all->SetBinContent(4,3.954);  // -2.0 to -1.5    
   corr_result_all->SetBinContent(5,3.770);  // -1.5 to -1.0
   corr_result_all->SetBinContent(6,3.607); // -1.0 to -0.5
   corr_result_all->SetBinContent(7,3.548); // -0.5 to 0.0

   corr_result_all->SetBinContent(8,3.567); 
   corr_result_all->SetBinContent(9,3.681); 
   corr_result_all->SetBinContent(10,3.791); 
   corr_result_all->SetBinContent(11,4.025); 

   corr_result_all->SetBinError(4,0.1779);
   corr_result_all->SetBinError(5,0.1697);
   corr_result_all->SetBinError(6,0.1623);
   corr_result_all->SetBinError(7,0.1597);
   corr_result_all->SetBinError(8,0.1605);
   corr_result_all->SetBinError(9,0.1657);
   corr_result_all->SetBinError(10,0.1706);
   corr_result_all->SetBinError(11,0.1811);
   */

   corr_result_all->SetMarkerStyle(20);  
   //corr_result_all->SetMarkerSize(1.5); // use rootlogon size 
   corr_result_all->SetMarkerColor(kRed);
   corr_result_all->SetLineColor(2);

   corr_result_all->GetYaxis()->SetTitle("dN_{ch}/d#eta/dN_{ch,mid}/d#eta");
   corr_result_all->GetXaxis()->SetTitle("#eta"); 
   corr_result_all->GetXaxis()->CenterTitle();
   corr_result_all->GetYaxis()->CenterTitle();
   corr_result_all->GetXaxis()->SetNdivisions(405);
   //corr_result_all->GetYaxis()->SetNdivisions(1005);
   corr_result_all->GetYaxis()->SetNdivisions(506);

   Float_t midrapid = 0.5*(corr_result_all->GetBinContent(7)+corr_result_all->GetBinContent(8));
   cout<<"mid rapid value = "<<midrapid<<endl;

   corr_result_all->Scale(1/midrapid);

   corr_result_all->SetMinimum(0.95);
   corr_result_all->SetMaximum(1.3);

   corr_result_all->Draw("pz");

   // ======= YJ Tracklet three layer combination averaged (updated with dead modules..) ======
   //                        1     2   3     4   5     6  7    8  9   10 11   12
   Double_t xAxis5[13] = {-3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3}; 
   
   TH1 *hMeasuredFinal = new TH1D("hMeasuredFinal","",12, xAxis5);

   hMeasuredFinal->SetBinContent(3,3.7459);
   hMeasuredFinal->SetBinContent(4,3.65462);
   hMeasuredFinal->SetBinContent(5,3.55475);
   hMeasuredFinal->SetBinContent(6,3.45008);

   hMeasuredFinal->SetBinContent(7,3.44329);
   hMeasuredFinal->SetBinContent(8,3.5244);
   hMeasuredFinal->SetBinContent(9,3.59575);
   hMeasuredFinal->SetBinContent(10,3.6612);

   hMeasuredFinal->SetBinError(3,0.142344);
   hMeasuredFinal->SetBinError(4,0.138876);
   hMeasuredFinal->SetBinError(5,0.13508);
   hMeasuredFinal->SetBinError(6,0.131103);
   hMeasuredFinal->SetBinError(7,0.130845);
   hMeasuredFinal->SetBinError(8,0.133927);
//.........这里部分代码省略.........
开发者ID:CmsHI,项目名称:CVS_ASYoon,代码行数:101,代码来源:dNdEta_ThreeMethods_FullTrackingRebinned_DividedByMidRapidValue.C

示例8: moveDirHistsToStacks

void stackPlotter::moveDirHistsToStacks(TDirectory* tdir, TString histname, int color){
	if(debug)
		std::cout << "stackPlotter::moveDirHistsToStacks" << std::endl;

	// get metainfo from directory, else exit TODO
	metaInfo tMI;
	tMI.extractFrom(tdir);

	if(debug) {
		std::cout << "stackPlotter::moveDirHistsToStacks || metaInfo color=" << tMI.color << std::endl;
		std::cout << "stackPlotter::moveDirHistsToStacks || metaInfo legendname=" << tMI.legendname<< std::endl;
		std::cout << "stackPlotter::moveDirHistsToStacks || metaInfo legendorder=" << tMI.legendorder << std::endl;
	}


	TIter    histIter(tdir->GetListOfKeys());
	TObject* cHistObj;
	TKey*    cHistKey;

	if(debug)
		std::cout << "stackPlotter::moveDirHistsToStacks || Iterating through histograms." << std::endl;

	// loop through keys in the directory
	while((cHistKey = (TKey*) histIter())) {
        if(histname != cHistKey->GetName()) continue;
		cHistObj=tdir->Get(cHistKey->GetName());
		if(!cHistObj->InheritsFrom(TH1::Class())) continue;

		if(debug)
			std::cout << "stackPlotter::moveDirHistsToStacks || Found histogram "
			<< cHistKey->GetName() << std::endl;

		// prepare the histogram to be added to the stack
		TH1* cHist = (TH1*) cHistObj->Clone();
		cHist->SetDirectory(0);
		TString mapName = cHist->GetName();

		std::pair<Int_t,TH1*> newEntry(tMI.legendorder,cHist);

		// initialize the stack info if needed
		if(!stacksLegEntries_.count(mapName)) {
			std::vector<std::pair<Int_t,TH1*> > legInfo(0);
			legInfo.push_back(newEntry);
			stacksLegEntries_[mapName] = legInfo;
		}

		cHist->SetFillColor(color);
		cHist->SetFillStyle(1001);
		cHist->SetMarkerStyle(kNone);
		cHist->SetMarkerColor(kBlack);
		cHist->SetLineColor(kBlack);
		cHist->SetTitle(mapName);
		cHist->SetName(tMI.legendname);

		std::vector<std::pair<Int_t,TH1*> > legEntries = stacksLegEntries_[mapName];
		if(debug)
			std::cout << "stackPlotter::moveDirHistsToStacks || legEntries size is " << legEntries.size() << std::endl;
		for(size_t i=0; i < legEntries.size(); i++) {
			if(legEntries.at(i).second == cHist && legEntries.at(i).first == tMI.legendorder) break;

			if(legEntries.at(i).first >= tMI.legendorder) {
				if(debug)
					std::cout << "stackPlotter::moveDirHistsToStacks || i is " << i << std::endl;
				stacksLegEntries_[mapName].insert(stacksLegEntries_[mapName].begin()+i,newEntry);
				break;
			}

			if(i==legEntries.size()-1) {
				stacksLegEntries_[mapName].push_back(newEntry);
				break;
			}
		}

		if(debug)
			std::cout << "stackPlotter::moveDirHistsToStacks || legEntries size is " << legEntries.size() << std::endl;
	}

}
开发者ID:ssghosh,项目名称:Brown-FCNC2016-thcu,代码行数:78,代码来源:stackPlotter.cpp

示例9: makePlot


//.........这里部分代码省略.........
  bottomPad->SetBottomMargin(0.31);
  bottomPad->SetRightMargin(0.05);
  bottomPad->SetLogy(false);
  
  canvas->cd();
  topPad->Draw();
  topPad->cd();
  
  TAxis* xAxis_top = histogramData_density->GetXaxis();
  xAxis_top->SetTitle(xAxisTitle.data());
  xAxis_top->SetTitleOffset(xAxisOffset);
  xAxis_top->SetLabelColor(10);
  xAxis_top->SetTitleColor(10);
    
  TAxis* yAxis_top = histogramData_density->GetYaxis();
  yAxis_top->SetTitle(yAxisTitle.data());
  yAxis_top->SetTitleOffset(yAxisOffset);
  yAxis_top->SetTitleSize(0.085);
  yAxis_top->SetLabelSize(0.05);
  yAxis_top->SetTickLength(0.04);  
  
  TLegend* legend = new TLegend(0.66, 0.45, 0.94, 0.92, NULL, "brNDC");
  legend->SetFillStyle(0);
  legend->SetBorderSize(0);
  legend->SetFillColor(10);
  legend->SetTextSize(0.055);
  
  histogramData_density->SetTitle("");
  histogramData_density->SetStats(false);
  histogramData_density->SetMaximum(yMax);
  histogramData_density->SetMinimum(yMin);
  histogramData_density->SetMarkerStyle(20);
  histogramData_density->SetMarkerSize(2);
  histogramData_density->SetMarkerColor(kBlack);
  histogramData_density->SetLineColor(kBlack);
  legend->AddEntry(histogramData_density, "Observed", "p");    
  
  histogramData_density->Draw("ep");
  
  legend->AddEntry(histogramTTH_density, "t#bar{t}H", "l");

  histogramTT_density->SetTitle("");
  histogramTT_density->SetStats(false);
  histogramTT_density->SetMaximum(yMax);
  histogramTT_density->SetMinimum(yMin);
  histogramTT_density->SetFillColor(kMagenta - 10); 
  legend->AddEntry(histogramTT_density, "t#bar{t}+jets", "f");

  histogramTTV_density->SetFillColor(kOrange - 4);
  legend->AddEntry(histogramTTV_density, "t#bar{t}+V", "f");

  histogramEWK_density->SetFillColor(kRed + 2); 
  legend->AddEntry(histogramEWK_density, "EWK", "f");

  histogramRares_density->SetFillColor(kBlue - 8); 
  legend->AddEntry(histogramRares_density, "Rares", "f");

  THStack* histogramStack_density = new THStack("stack", "");
  histogramStack_density->Add(histogramRares_density);
  histogramStack_density->Add(histogramEWK_density);
  histogramStack_density->Add(histogramTTV_density);
  histogramStack_density->Add(histogramTT_density);
  histogramStack_density->Draw("histsame");
  
  histogramBgrUncertainty_density->SetFillColor(kBlack);
  histogramBgrUncertainty_density->SetFillStyle(3344);    
开发者ID:cms-analysis,项目名称:CombineHarvester,代码行数:67,代码来源:makePostFitPlots_1l_2tau.C

示例10: boostcontrolplots

void boostcontrolplots( TDirectory *boostdir ) {

   const Int_t nPlots = 4;

   Int_t width  = 900;
   Int_t height = 900;
   char cn[100];
   const TString titName = boostdir->GetName();
   sprintf( cn, "cv_%s", titName.Data() );
   TCanvas *c = new TCanvas( cn,  Form( "%s Control Plots", titName.Data() ),
                             width, height ); 
   c->Divide(2,3);


   const TString titName = boostdir->GetName();

   TString hname[nPlots]={"Booster_BoostWeight","Booster_MethodWeight","Booster_ErrFraction","Booster_OrigErrFraction"};

   for (Int_t i=0; i<nPlots; i++){
      Int_t color = 4; 
      TPad * cPad = (TPad*)c->cd(i+1);
      TH1 *h = (TH1*) boostdir->Get(hname[i]);
      TString plotname = h->GetName();
      h->SetMaximum(h->GetMaximum()*1.3);
      h->SetMinimum( 0 );
      h->SetMarkerColor(color);
      h->SetMarkerSize( 0.7 );
      h->SetMarkerStyle( 24 );
      h->SetLineWidth(2);
      h->SetLineColor(color);
      h->Draw();
      c->Update();
   }

   // draw combined ROC plots

   TString hname_roctest[2] ={"Booster_ROCIntegral_test",  "Booster_ROCIntegralBoosted_test"};
   TString hname_roctrain[2]={"Booster_ROCIntegral_train", "Booster_ROCIntegralBoosted_train"};
   TString htitle[2] = {"ROC integral of single classifier", "ROC integral of boosted method"}

   for (Int_t i=0; i<2; i++){
      Int_t color = 4; 
      TPad * cPad = (TPad*)c->cd(nPlots+i+1);
      TH1 *htest  = (TH1*) boostdir->Get(hname_roctest[i]);
      TH1 *htrain = (TH1*) boostdir->Get(hname_roctrain[i]);

      // check if filled 
      Bool_t histFilled = (htest->GetMaximum() > 0 || htrain->GetMaximum() > 0);

      htest->SetTitle(htitle[i]);
      htest->SetMaximum(1.0);
      htest->SetMinimum(0.0);
      htest->SetMarkerColor(color);
      htest->SetMarkerSize( 0.7 );
      htest->SetMarkerStyle( 24 );
      htest->SetLineWidth(2);
      htest->SetLineColor(color);
      htest->Draw();
      htrain->SetMaximum(1.0);
      htrain->SetMinimum(0.0);
      htrain->SetMarkerColor(color-2);
      htrain->SetMarkerSize( 0.7 );
      htrain->SetMarkerStyle( 24 );
      htrain->SetLineWidth(2);
      htrain->SetLineColor(color-2);
      htrain->Draw("same");

      if (histFilled) {
         TLegend *legend= new TLegend( cPad->GetLeftMargin(), 
                                       0.2 + cPad->GetBottomMargin(),
                                       cPad->GetLeftMargin() + 0.6, 
                                       cPad->GetBottomMargin() );
         legend->AddEntry(htest,  TString("testing sample"),  "L");
         legend->AddEntry(htrain, TString("training sample (orig. weights)"), "L");
         legend->SetFillStyle( 1 );
         legend->SetBorderSize(1);
         legend->SetMargin( 0.3 );
         legend->Draw("same");
      }
      else {
         TText* t = new TText();
         t->SetTextSize( 0.056 );
         t->SetTextColor( 2 );
         t->DrawText( 1, 0.6, "Use MethodBoost option: \"DetailedMonitoring\" " );        
         t->DrawText( 1, 0.51, "to fill this histograms" );        
      }

      c->Update();
   }

   // write to file
   TString fname = Form( "plots/%s_ControlPlots", titName.Data() );
   TMVAGlob::imgconv( c, fname );
   
}
开发者ID:CMSAachen3B,项目名称:RWTH3b,代码行数:95,代码来源:BoostControlPlots.C

示例11: makeEffToys

void makeEffToys(Int_t seed, TString veto="D") {
//	r.SetSeed(seed);
	r = RooRandom::randomGenerator();
	r->SetSeed(seed);

	TFile* fin = TFile::Open(veto+"veto_200.root");

	TString fName("toys/"); fName+=seed; fName+="/"+veto+"veto_200.root";

	TFile* fout = new TFile(fName,"RECREATE");

	for(Int_t j=0; j<21; ++j) {
		TString hName  = "efficiency_"; hName+=j;
		TString hName2 = "efficiencyHist_"; hName2+=j;
		TEfficiency* hin = dynamic_cast<TEfficiency*>(fin->Get(hName));

		TH1* hout = dynamic_cast<TH1*>(hin->GetTotalHistogram()->Clone(hName2));

		std::vector<Int_t> corrBins;

		Int_t n = hout->GetNbinsX();
		for(Int_t i=0; i<n; ++i) {
			Double_t eff = hin->GetEfficiency(i+1);
			Double_t erm = hin->GetEfficiencyErrorLow(i+1);
			Double_t erp = hin->GetEfficiencyErrorUp(i+1);

			Bool_t fluctuate = kTRUE;

			// don't fluctuate if the veto hasn't affected this bin
			// also ignore the odd missing entry - not sure what causes these but they don't seem reasonable
			if((eff > 0.99 && eff + erp > 0.999) //efficiency close to 1 and not significantly different
			|| ((i<1 || hin->GetEfficiency(i) == 1) && (i>n-1 || hin->GetEfficiency(i+2) == 1))) { //single bin dip (careful with this one)
				eff = 1;
				fluctuate = kFALSE;
			}
			if(eff < 0.01 && eff - erm < 0.001) {//efficiency close to 0 and not significantly different
				eff = 0;
				fluctuate = kFALSE;
			}

			//otherwise we're fluctuating the bin
			if(fluctuate) {
				//if the errors are roughly symmetric then we can symmetrise them and introduce some correlation between neighbouring bins
				//this is difficult to do with asymmetric errors so if asymmetry > 10% lets just ignore correlations
				//note that a large asymmetry in neighbouring bins will also lead to same-sign fluctuations anyway
				if((erm - erp) / (erm + erp) < 0.1) {
					//correlation is more important than asymmetry

					//add bin to the list to be fluctuated later
					corrBins.push_back(i+1);

				} else {
					//asymmetry is more important than correlation

					//first catch any cases on a limit (the previous checks for eff > 0.99 and eff < 0.01 should catch these but play it safe)
					if(erm <= 0) {
						//vary with a half Gaussian
						eff += TMath::Abs(r->Gaus(0.,erp));
					} else if(erp <= 0) {
						//vary with a half Gaussian
						eff -= TMath::Abs(r->Gaus(0.,erm));
					} else {
						//vary with a bifurcated Gaussian
						RooRealVar effVar( "effVar", "",-1.,2.);
						RooRealVar muVar(  "muVar",  "",eff);
						RooRealVar sigmVar("sigmVar","",erm);
						RooRealVar sigpVar("sigpVar","",erp);

						RooBifurGauss pdf("pdf","",effVar,muVar,sigmVar,sigpVar);
						RooDataSet* ds = pdf.generate(RooArgSet(effVar),1);
						eff = ds->get(0)->getRealValue("effVar");
						delete ds;
					}
				}
			}
			if(eff > 1.0) eff = 1.0; //std::cout << i << "\t" << eff << "\t" << erp << "\t" << erm << std::endl;
//			std::cout << hin->GetEfficiency(i+1) << "\t" << eff << std::endl;

			hout->SetBinContent(i+1, eff);
		}

		//now deal with the correlated efficiencies
		Double_t corrFactor(0.01);

		while(!doCorrelatedBinFluctuation(hin,hout,corrBins,corrFactor)) {
			corrFactor /= 2.;
		}

//		std::cout << std::endl;

		TCanvas c;
		hin->Draw();
		hout->SetMarkerColor(kRed);
		hout->SetMarkerStyle(4);
		hout->Draw("Psame");
		TString pName = "plots/toys/"; pName+=seed; pName+="/"+veto+"veto_Q"; pName+=j; pName+=".pdf";
		c.SaveAs(pName);
	}

	hout->Write();
//.........这里部分代码省略.........
开发者ID:dcraik,项目名称:lhcb,代码行数:101,代码来源:makeEffToys.C

示例12: MakePi0Analysis


//.........这里部分代码省略.........
	  TF1* fFitFinalRatio[binnum];
	  TF1* fFitFinalSignal[binnum];
	  TF1* fFitOnlyFitSignal[binnum];

	  for(Int_t i=0; i<binnum; i++){    
	    
	    Double_t bin_width = (bins[i+1]-bins[i]);
	    Double_t bin_mean  = (bins[i+1]+bins[i])/2;
	    
	    Int_t rebin = 1;
	    
	    if(bin_mean>5.0){
	      rebin=10;
	    }
	    else{
	      rebin=5;
	    }
	    
	    Int_t sproj_bin = hPi0A08->GetYaxis()->FindBin(bins[i]);
	    Int_t lproj_bin = hPi0A08->GetYaxis()->FindBin(bins[i+1])-1;
	    
	    TH1* fHistBasicSame = (TH1*)hPi0A08   ->ProjectionX(Form("fHistBasicSame_No%d",i+1),sproj_bin,lproj_bin,""); 
	    TH1* fHistBasicMix  = (TH1*)hMixPi0A08->ProjectionX(Form("fHistBasicMix_No%d",i+1),sproj_bin,lproj_bin,""); 
	    fHistBasicSame->Rebin(rebin);
	    fHistBasicMix->Rebin(rebin);
	    fHistBasicSame->Sumw2();
	    fHistBasicMix->Sumw2();
	    fHistBasicSame->GetYaxis()->SetTitle(Form("dN/dM per %.0f MeV/c^{2}",fHistBasicSame->GetBinWidth(1)*1000));
	    fHistBasicMix->GetYaxis()->SetTitle(Form("dN/dM per %.0f MeV/c^{2}",fHistBasicSame->GetBinWidth(1)*1000));
	    fHistBasicSame->GetXaxis()->SetRange(fHistBasicSame->GetXaxis()->FindBin(0.),fHistBasicSame->GetXaxis()->FindBin(0.3)-1);
	    fHistBasicMix->GetXaxis()->SetRange(fHistBasicSame->GetXaxis()->FindBin(0.),fHistBasicSame->GetXaxis()->FindBin(0.3)-1);
	    fHistBasicSame->SetMarkerStyle(20);
	    fHistBasicMix->SetMarkerStyle(24);
	    fHistBasicSame->SetMarkerColor(kBlack);
	    fHistBasicMix->SetMarkerColor(kBlue);
	    fHistBasicSame->SetLineColor(kBlack);
	    fHistBasicMix->SetLineColor(kBlue);
	    
	    fHistFinalSame[i]     = (TH1F*)fHistBasicSame->Clone();
	    fHistOnlyFitSignal[i] = (TH1F*)fHistBasicSame->Clone();
	    fHistOnlyFitSignal[i]->SetName(Form("fHistOnlyFitSignal_Pol%d_No%d",pol,i+1)+fitName[iFit]+tofName[itof]+modName[iMod]);


	    TH1F* fHistOnlyFit_Signal = (TH1F*)fHistOnlyFitSignal[i]->Clone();
	    TH1F* fHistOnlyFit_BG     = (TH1F*)fHistOnlyFitSignal[i]->Clone();
	    
	    TH1F* fHistRatio     = (TH1F*)fHistBasicSame->Clone();
	    fHistRatio->Divide(fHistBasicMix);
	    fHistRatio->SetName(Form("cRatioSameBG_Pol%d_No%d",pol,i+1)+fitName[iFit]+tofName[itof]+modName[iMod]);
	    
	    TH1F* fHistRatio_Signal = (TH1F*)fHistRatio->Clone();
	    TH1F* fHistRatio_BG     = (TH1F*)fHistRatio->Clone();
	    
	    Int_t ssignal_bin = fHistRatio_Signal->GetXaxis()->FindBin(signal_range_min);
	    Int_t lsignal_bin = fHistRatio_Signal->GetXaxis()->FindBin(signal_range_max);
	    Int_t sbg_bin = fHistRatio_BG->GetXaxis()->FindBin(bg_range_min);
	    Int_t lbg_bin = fHistRatio_BG->GetXaxis()->FindBin(bg_range_max);
	    
	    for(Int_t j=ssignal_bin; j<lsignal_bin; ++j){
	      fHistRatio_BG->SetBinContent(j,0);
	      fHistRatio_BG->SetBinError(j,0);
	      fHistOnlyFit_BG->SetBinContent(j,0);
	      fHistOnlyFit_BG->SetBinError(j,0);
	    }
	    for(Int_t j=sbg_bin; j<ssignal_bin; ++j){
	      fHistRatio_Signal->SetBinContent(j,0);
开发者ID:ktf,项目名称:AliPhysics,代码行数:67,代码来源:MakePi0Analysis.C

示例13: bdtcontrolplots

void bdtcontrolplots( TDirectory *bdtdir ) {

   const Int_t nPlots = 6;

   Int_t width  = 900;
   Int_t height = 600;
   char cn[100], cn2[100];
   const TString titName = bdtdir->GetName();
   sprintf( cn, "cv_%s", titName.Data() );
   TCanvas *c = new TCanvas( cn,  Form( "%s Control Plots", titName.Data() ),
                             width, height ); 
   c->Divide(3,2);




   TString hname[nPlots]={"BoostMonitor","BoostWeight","BoostWeightVsTree","ErrFractHist","NodesBeforePruning",titName+"_FOMvsIterFrame"};

   Bool_t BoostMonitorIsDone=kFALSE;

   for (Int_t i=0; i<nPlots; i++){
      Int_t color = 4; 
      TPad * cPad;
      cPad = (TPad*)c->cd(i+1);
      TH1 *h = (TH1*) bdtdir->Get(hname[i]);
      
      if (h){
         h->SetMaximum(h->GetMaximum()*1.3);
         h->SetMinimum( 0 );
         h->SetMarkerColor(color);
         h->SetMarkerSize( 0.7 );
         h->SetMarkerStyle( 24 );
         h->SetLineWidth(1);
         h->SetLineColor(color);
         if(hname[i]=="NodesBeforePruning")h->SetTitle("Nodes before/after pruning");
         h->Draw();
         if(hname[i]=="NodesBeforePruning"){
            TH1 *h2 = (TH1*) bdtdir->Get("NodesAfterPruning");
            h2->SetLineWidth(1);
            h2->SetLineColor(2);
            h2->Draw("same");
         }
         if(hname[i]=="BoostMonitor"){ // a plot only available in case DoBoostMontior option has bee set
            TGraph *g = (TGraph*) bdtdir->Get("BoostMonitorGraph");
            g->Draw("LP*");
            BoostMonitorIsDone = kTRUE;
         }
         if(hname[i]==titName+"_FOMvsIterFrame"){ // a plot only available in case DoBoostMontior option has bee set
            TGraph *g = (TGraph*) bdtdir->Get(titName+"_FOMvsIter");
            g->Draw();
         }
         c->Update();
      }
   }
   
   
   TCanvas *c2 = NULL;
   if (BoostMonitorIsDone){
      sprintf( cn2, "cv2_%s", titName.Data() );
      c2 = new TCanvas( cn2,  Form( "%s BoostWeights", titName.Data() ),
                                 1200, 1200 ); 
      c2->Divide(5,5);
      Int_t ipad=1;
      
      TIter keys( bdtdir->GetListOfKeys() );
      TKey *key;
      //      gDirectory->ls();
      while ( (key = (TKey*)keys.Next()) && ipad < 26) {
         TObject *obj=key->ReadObj();
         if (obj->IsA()->InheritsFrom(TH1::Class())){   
            TH1F *hx = (TH1F*)obj;
            TString hname(Form("%s",obj->GetTitle()));
            if (hname.Contains("BoostWeightsInTreeB")){ 
               c2->cd(ipad++);
               hx->SetLineColor(4);
               hx->Draw();
               hname.ReplaceAll("TreeB","TreeS");
               bdtdir->GetObject(hname.Data(),hx);
               if (hx) {
                  hx->SetLineColor(2);
                  hx->Draw("same");
               }
            }
            c2->Update();
         }
      }
               
   }

   // write to file
   TString fname = Form( "plots/%s_ControlPlots", titName.Data() );
   TMVAGlob::imgconv( c, fname );
   
   if (c2){
      fname = Form( "plots/%s_ControlPlots2", titName.Data() );
      TMVAGlob::imgconv( c2, fname );
   }

   TCanvas *c3 = NULL;
   if (BoostMonitorIsDone){
//.........这里部分代码省略.........
开发者ID:CeF3TB,项目名称:BTFAnalysis,代码行数:101,代码来源:BDTControlPlots.C

示例14: set

histoBook* histoBook::set( string param, double p1, double p2, double p3, double p4  ){


	transform(param.begin(), param.end(), param.begin(), ::tolower);

    TH1* h = get( styling );
    if ( h ){

	    if ( "linecolor" == param ){

	    	h->SetLineColor( (int) p1 );
	    } else if ( "domain" == param ){
	    	double min = p1;
	    	double max = p2;
		    h->GetXaxis()->SetRangeUser( min, max );
	    } else if ( "dynamicdomain" == param ){
	    	double thresh = p1;
	    	int min = (int)p2;
	    	int max = (int)p3;
	    	int axis = (int)p4;		// 1 = x, 2 = y

	    	if ( 1 != axis && 2 != axis )
	    		axis = 1;
	    	
	    	if ( thresh >= 0) {
	    		if ( -1 >= min )
	    			min = h->FindFirstBinAbove( thresh, axis );
	    		if ( -1 >= max )
	    			max = h->FindLastBinAbove( thresh, axis );
	    	}
	    	
	    	if ( 1 == axis )
		  	  h->GetXaxis()->SetRange( min, max );
		  	else if ( 2 == axis )
		  		h->GetYaxis()->SetRange( min, max );

	    }  else if ( "range" == param ){

	    	double min = p1;
	    	double max = p2;
	    	
	    	h->GetYaxis()->SetRangeUser( min, max );
	    } else if ( "markercolor" == param ) {
	    	h->SetMarkerColor( (int)p1 );
	    } else if ( "markerstyle" == param ) {
	    	h->SetMarkerStyle( (int)p1 );
	    } else if ( "legend" == param ){
	    	// p1 - alignmentX
	    	// p2 - alignmentY
	    	// p3 - width
	    	// p4 - height

	    	// make sure option is valid
	    	if ( !(legendAlignment::center == p1 || legendAlignment::left == p1 || legendAlignment::right == p1) )
	    		p1 = legendAlignment::best;
	    	if ( !(legendAlignment::center == p2 || legendAlignment::top == p2 || legendAlignment::bottom == p2) )
	    		p2 = legendAlignment::best;
	    	placeLegend( p1, p2, p3, p4 );
	    } else if ( "numberofticks" == param ){
	    	// p1 - # of primary divisions
	    	// p2 - # of secondary divisions
	    	// p3 - axis : 0 or 1 = x, 2 = y
	    	
	    	if ( p2 == -1 )
	    		p2 = 0;

		    if ( 2 == (int)p3 )
		    	h->GetYaxis()->SetNdivisions( (int) p1, (int) p2, 0, true );
		    else 
		    	h->GetXaxis()->SetNdivisions( (int) p1, (int) p2, 0, true );
	    }

    }
    
    
    


	return this;
}
开发者ID:jdbrice,项目名称:vpdCalibration,代码行数:80,代码来源:histoBook.cpp

示例15: draw_output_data

void plotter::draw_output_data(TH1* output_, TH1* stat_, std::vector<TH1D*> truth_, std::vector<TString> legnames, bool norm, TString file_name){

  TH1* output = (TH1*) output_->Clone("output");
  TH1* stat = (TH1*) stat_->Clone("stat");

  std::vector<TH1D*> truth;
  for(auto t: truth_){
    truth.push_back( (TH1D*) t->Clone() );
  }

  double max = output->GetMaximum();
  for(auto t: truth){
    if(t->GetMaximum() > max) max = t->GetMaximum();
  }
  double ymax = 1.5 * max;

  TCanvas *c = new TCanvas("c","",600,600);
  gPad->SetLeftMargin(0.15);
  TGaxis::SetMaxDigits(3);
  output->SetTitle(" ");
  output->GetYaxis()->SetRangeUser(0., ymax);
  output->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
  if(norm) output->GetYaxis()->SetTitle("#frac{1}{#sigma} #frac{d#sigma}{dm_{jet}} [#frac{1}{GeV}]");
  else output->GetYaxis()->SetTitle("#frac{d#sigma}{dm_{jet}} [#frac{fb}{GeV}]");
  output->GetYaxis()->SetTitleOffset(1.1);
  output->GetXaxis()->SetTitleOffset(0.9);
  output->GetYaxis()->SetTitleSize(0.05);
  output->GetXaxis()->SetTitleSize(0.05);
  output->GetYaxis()->SetNdivisions(505);
  output->SetLineColor(kBlack);
  output->SetMarkerColor(kBlack);
  output->SetMarkerStyle(8);
  output->SetMarkerSize(1);
  output->Draw("E1");
  stat->SetLineColor(kBlack);
  stat->SetMarkerColor(kBlack);
  stat->SetMarkerStyle(8);
  stat->SetMarkerSize(1);
  gStyle->SetEndErrorSize(5);
  Color_t color[] = {kRed-4, kAzure+7, kGreen, 798};
  Int_t style[] = {1, 2, 9, 7};
  for(unsigned int i=0; i<truth.size(); i++){
    truth[i]->SetLineWidth(3);
    truth[i]->SetLineColor(color[i]);
    truth[i]->SetLineStyle(style[i]);
    truth[i]->Draw("HIST SAME");
  }
  stat->Draw("E1 SAME");
  output->Draw("E1 SAME");

  TLegend *l=new TLegend(0.55,0.67,0.85,0.87);
  l->SetBorderSize(0);
  l->SetFillStyle(0);
  l->AddEntry(output,"data unfolded","pl");
  for(unsigned int i=0; i<truth.size(); i++){
    l->AddEntry(truth[i],legnames[i],"l");
  }
  l->SetTextSize(0.03);
  l->Draw();
  c->SaveAs(directory + file_name + ".pdf");
  delete c;
}
开发者ID:UHH2,项目名称:MTopJet,代码行数:62,代码来源:plotter.C


注:本文中的TH1::SetMarkerColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。