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


C++ TDirectoryFile::cd方法代码示例

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


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

示例1: processJpsi2eeQAplots

//______________________________________________________________________________
void processJpsi2eeQAplots(const Char_t* filename="jpsi_Default.root", 
			   TString suffix = "eps",
			   const Char_t* outfile="Jpsi2eeQAplots_output.root") {
  //
 
  //  
  TFile* file = TFile::Open(filename);
  
  // event wise histograms 
  TH1F* zDistrib = (TH1F*)GetHistogram(file, "default", "Event", "Z");
  
  // electron candidate histograms
  TH2F* tpcDedx = (TH2F*)GetHistogram(file, "default", "Track_ev1+", "P_InnerParam_TPC_signal");
  tpcDedx->Add((TH2F*)GetHistogram(file, "default", "Track_ev1-", "P_InnerParam_TPC_signal"));
  TH2F* tpcNsigmaEle = (TH2F*)GetHistogram(file, "default", "Track_ev1+", "P_InnerParam_TPC_nSigma_Electrons");
  tpcNsigmaEle->Add((TH2F*)GetHistogram(file, "default", "Track_ev1-", "P_InnerParam_TPC_nSigma_Electrons"));
  
  // pair candidate histograms
  TH1F* invmass_pp = (TH1F*)GetHistogram(file, "default", "Pair_ev1+_ev1+", "pM");
  TH1F* invmass_pm = (TH1F*)GetHistogram(file, "default", "Pair_ev1+_ev1-", "pM");
  TH1F* invmass_mm = (TH1F*)GetHistogram(file, "default", "Pair_ev1-_ev1-", "pM");
    
  // draw stuff
  TLatex* latex=new TLatex();
  latex->SetNDC();
  latex->SetTextSize(0.04);
  latex->SetTextFont(42);
  TCanvas* c1=new TCanvas("fig_dq_tpcDedx", "");
  if(tpcDedx) {
    tpcDedx->SetStats(kFALSE);
    tpcDedx->GetXaxis()->SetRangeUser(0.0,10.0);
    tpcDedx->GetYaxis()->SetRangeUser(40.0,120.0);
    tpcDedx->SetTitle("");
    tpcDedx->Draw("colz");
    latex->DrawLatex(0.12, 0.83, "J/#psi electron candidates");
  }
  
  TCanvas* c2=new TCanvas("fig_dq_tpcNsigmaElectron", "");
  if(tpcNsigmaEle) {
    tpcNsigmaEle->SetStats(kFALSE);
    tpcNsigmaEle->GetYaxis()->SetRangeUser(-5.0,5.0);
    tpcNsigmaEle->GetXaxis()->SetRangeUser(0.0,10.0);
    tpcNsigmaEle->SetTitle("");
    tpcNsigmaEle->Draw("colz");
    latex->DrawLatex(0.12, 0.83, "J/#psi electron candidates");
  }
  
  TCanvas* c3=new TCanvas("fig_dq_eeInvMass", "");
  if(invmass_pm) {
    invmass_pm->SetStats(kFALSE);
    invmass_pm->SetTitle("");
    invmass_pm->SetLineColor(1);
    invmass_pm->GetYaxis()->SetTitle(Form("Pairs per %.0f MeV/c^{2}", 1000.0*invmass_pm->GetXaxis()->GetBinWidth(1)));
    invmass_pm->GetXaxis()->SetTitle("m_{e^{+}e^{-}} (GeV/c^{2})");
    invmass_pm->Draw();
  }
  if(invmass_pp) {
    invmass_pp->SetLineColor(2);
    invmass_pp->Draw((invmass_pm ? "same" : ""));
  }
  if(invmass_mm) {
    invmass_mm->SetLineColor(4);
    invmass_mm->Draw((invmass_mm ? "same" : ""));
  }
  if(invmass_pm || invmass_mm || invmass_pp)
    latex->DrawLatex(0.12, 0.85, "J/#psi candidates");
  if(invmass_pm && zDistrib && zDistrib->Integral()>1.);
    latex->DrawLatex(0.12, 0.80, Form("candidates / event = %.3f", invmass_pm->Integral() / zDistrib->Integral()));
  TLegend* legend=new TLegend(0.7,0.7,0.89,0.89);
  legend->SetTextFont(42);
  legend->SetBorderSize(0);
  legend->SetFillColor(0);
  if(invmass_pm) legend->AddEntry(invmass_pm, "+- pairs", "l");
  if(invmass_pp) legend->AddEntry(invmass_pp, "++ pairs", "l");
  if(invmass_mm) legend->AddEntry(invmass_mm, "-- pairs", "l");
  if(invmass_mm || invmass_pm || invmass_pp) legend->Draw();
  
  c1->SaveAs(Form("fig_dq_tpcDedx.%s",suffix.Data()));
  c2->SaveAs(Form("fig_dq_tpcNsigmaElectron.%s",suffix.Data()));
  c3->SaveAs(Form("fig_dq_eeInvMass.%s",suffix.Data()));


  //  TFile* save=new TFile(outputName, "RECREATE");
  // c1->Write();
  // c2->Write();
  // c3->Write();
  // save->Close();


  // Added by jsatya

  TFile *fout = TFile::Open(outfile,"UPDATE");
  fout->ls();
  
  TDirectoryFile *cdd = NULL;
  cdd = (TDirectoryFile*)fout->Get("DQ");
  if(!cdd) {
    Printf("Warning: DQ <dir> doesn't exist, creating a new one");
    cdd = (TDirectoryFile*)fout->mkdir("DQ");
//.........这里部分代码省略.........
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:processJpsi2eeQAplots.C

示例2: make2Droot_total_noPtWeight


//.........这里部分代码省略.........
	h2D_corrY_PR_pPb->Divide(h2D_Acc_pt_y_PRMC_pPb);
	h2D_corrY_PR_pPb->Divide(h2D_Eff_pt_y_PRMC_pPb);
	TH2D* h2D_corrY_NP_pPb = (TH2D*)h2D_fit_pt_y_NP_pPb->Clone("h2D_corrY_NP_pPb");
	h2D_corrY_NP_pPb->SetName("h2D_corrY_NP_pPb");
	h2D_corrY_NP_pPb->Divide(h2D_Acc_pt_y_NPMC_pPb);
	h2D_corrY_NP_pPb->Divide(h2D_Eff_pt_y_NPMC_pPb);
	
	////////////////////////////////////////////////
	////// MC corrected yield RECO/(Acc*Eff)
	TH2D* h2D_MCcorrY_PR_Pbp = (TH2D*)h2D_Eff_Num_pt_y_PRMC_Pbp->Clone("h2D_MCcorrY_PR_Pbp");
	h2D_MCcorrY_PR_Pbp->SetName("h2D_MCcorrY_PR_Pbp");
	h2D_MCcorrY_PR_Pbp->Divide(h2D_Acc_pt_y_PRMC_Pbp);
	h2D_MCcorrY_PR_Pbp->Divide(h2D_Eff_pt_y_PRMC_Pbp);
	TH2D* h2D_MCcorrY_NP_Pbp = (TH2D*)h2D_Eff_Num_pt_y_NPMC_Pbp->Clone("h2D_MCcorrY_NP_Pbp");
	h2D_MCcorrY_NP_Pbp->SetName("h2D_MCcorrY_NP_Pbp");
	h2D_MCcorrY_NP_Pbp->Divide(h2D_Acc_pt_y_NPMC_Pbp);
	h2D_MCcorrY_NP_Pbp->Divide(h2D_Eff_pt_y_NPMC_Pbp);
	TH2D* h2D_MCcorrY_PR_pPb = (TH2D*)h2D_Eff_Num_pt_y_PRMC_pPb->Clone("h2D_MCcorrY_PR_pPb");
	h2D_MCcorrY_PR_pPb->SetName("h2D_MCcorrY_PR_pPb");
	h2D_MCcorrY_PR_pPb->Divide(h2D_Acc_pt_y_PRMC_pPb);
	h2D_MCcorrY_PR_pPb->Divide(h2D_Eff_pt_y_PRMC_pPb);
	TH2D* h2D_MCcorrY_NP_pPb = (TH2D*)h2D_Eff_Num_pt_y_NPMC_pPb->Clone("h2D_MCcorrY_NP_pPb");
	h2D_MCcorrY_NP_pPb->SetName("h2D_MCcorrY_NP_pPb");
	h2D_MCcorrY_NP_pPb->Divide(h2D_Acc_pt_y_NPMC_pPb);
	h2D_MCcorrY_NP_pPb->Divide(h2D_Eff_pt_y_NPMC_pPb);
	
	
	////////////////////////////////////////////////
	////// save as a root file
	TFile *outFile = new TFile(Form("total2Dhist_%s_noPtWeight.root",dirName),"RECREATE");
	std::cout << "dirName: " << dirName << std::endl;
	cout << "total2Dhist_"<<dirName<<"_noPtWeight.root has been created :) " <<endl;	

	outFile->cd();
	//Acc	
	h2D_Acc_pt_y_PRMC_Pbp->Write();
	h2D_Acc_pt_y_PRMC_pPb->Write();
	h2D_Acc_pt_y_NPMC_Pbp->Write();
	h2D_Acc_pt_y_NPMC_pPb->Write();
	//Eff
	h2D_Eff_pt_y_PRMC_Pbp->Write();
	h2D_Eff_pt_y_PRMC_pPb->Write();
	h2D_Eff_pt_y_NPMC_Pbp->Write();
	h2D_Eff_pt_y_NPMC_pPb->Write();
	//raw yield
	h2D_fit_pt_y_PR_Pbp->Write();	
	h2D_fit_pt_y_PR_pPb->Write();	
	h2D_fit_pt_y_NP_Pbp->Write();	
	h2D_fit_pt_y_NP_pPb->Write();	
	//corrYield
	h2D_corrY_PR_Pbp->Write();	
	h2D_corrY_PR_pPb->Write();	
	h2D_corrY_NP_Pbp->Write();	
	h2D_corrY_NP_pPb->Write();	
	
	// DIRECTORY : num, den distributions for acc & eff
	TDirectoryFile *otherMCInfo = new TDirectoryFile("otherMCInfo","otherMCInfo");
	otherMCInfo->cd();
	// acc den & num
	h2D_Acc_Den_pt_y_PRMC_Pbp->Write();
	h2D_Acc_Den_pt_y_PRMC_pPb->Write();
	h2D_Acc_Den_pt_y_NPMC_Pbp->Write();
	h2D_Acc_Den_pt_y_NPMC_pPb->Write();
	h2D_Acc_Num_pt_y_PRMC_Pbp->Write();
	h2D_Acc_Num_pt_y_PRMC_pPb->Write();
	h2D_Acc_Num_pt_y_NPMC_Pbp->Write();
开发者ID:CmsHI,项目名称:pPbJPsiAnalysis,代码行数:67,代码来源:make2Droot_total_noPtWeight.C

示例3: Slimmer


//.........这里部分代码省略.........
  chainB->SetBranchStatus("jets_AK5PF_photonEnergy",1);	
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT10_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT15_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT20_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT25_nconstituents",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_px",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_py",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_pz",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_energy",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_phi",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_eta",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_index",1);
  chainB->SetBranchStatus("fastjets_AK5PFclean_R1p2_R0p5pT30_nconstituents",1);
  

  chainB->SetBranchStatus("pfmets_et",1);
  chainB->SetBranchStatus("pfmets_ex",1);
  chainB->SetBranchStatus("pfmets_ey",1);
  chainB->SetBranchStatus("pfmets_phi",1);
  chainB->SetBranchStatus("pfmets_sumEt",1);
  chainB->SetBranchStatus("pfmets_gen_et",1);
  chainB->SetBranchStatus("pfmets_gen_phi",1);

  chainB->SetBranchStatus("pfTypeImets_et",1);
  chainB->SetBranchStatus("pfTypeImets_ex",1);
  chainB->SetBranchStatus("pfTypeImets_ey",1);
  chainB->SetBranchStatus("pfTypeImets_phi",1);
  chainB->SetBranchStatus("pfTypeImets_sumEt",1);
  chainB->SetBranchStatus("pfTypeImets_gen_et",1);
  chainB->SetBranchStatus("pfTypeImets_gen_phi",1);

  chainB->SetBranchStatus("pv_x",1);
  chainB->SetBranchStatus("pv_y",1);
  chainB->SetBranchStatus("pv_z",1);
  chainB->SetBranchStatus("pv_tracksSize",1);
  chainB->SetBranchStatus("pv_ndof",1);
  chainB->SetBranchStatus("pv_isFake",1);
  chainB->SetBranchStatus("Npv",1);

  chainB->SetBranchStatus("run",1);
  chainB->SetBranchStatus("event",1);
  chainB->SetBranchStatus("lumiblock",1);
  chainB->SetBranchStatus("bunchCrossing",1);

  chainB->SetBranchStatus("beamSpot_y",1);
  chainB->SetBranchStatus("beamSpot_x",1);

  chainB->SetBranchStatus("weight",1);
  chainB->SetBranchStatus("model_params",1);

  // Make the new file
  TFile *newFile = new TFile(output_filename.Data(),"RECREATE");
  TDirectoryFile *dir = new TDirectoryFile("configurableAnalysis","configurableAnalysis");
  dir->cd();
  TTree *newtreeA = chainA->CloneTree(0);
  TTree *newtreeB = chainB->CloneTree(0);

  Int_t nentries = (Int_t)chainB->GetEntries();

  for (int iEnt = 0; iEnt<nentries; iEnt++) {
    chainA->GetEntry(iEnt);
    chainB->GetEntry(iEnt);
    newtreeA->Fill();
    newtreeB->Fill();
  }

  newtreeA->AutoSave();
  newtreeB->AutoSave();
  newFile->Write();
  newFile->Close();

}
开发者ID:RohanBhandari,项目名称:MJ,代码行数:101,代码来源:Slimmer.C

示例4: plotROC

void plotROC(TString input1, TString label1, TString input2 , TString label2,  TString input3,  TString label3, TString input4, TString label4,  TString input5,  TString label5  ){


	gROOT->SetStyle("Plain");
	gStyle->SetPadGridX(0);
	gStyle->SetPadGridY(0);
	gStyle->SetOptStat(0);
	TCanvas *cROC = new TCanvas("cROC","cROC", 700, 700);

	cROC->SetTickx(1);
	cROC->SetTicky(1);
	TLegend *leg = new TLegend(0.15625,0.321654,0.4765625,0.603839,NULL,"brNDC");
	leg->SetBorderSize(0);
	leg->SetTextSize(0.035);
	leg->SetLineColor(1);
	leg->SetLineStyle(1);
	leg->SetLineWidth(1);
	leg->SetFillColor(0);
	leg->SetFillStyle(0);




	//TFile * _file0 = new TFile("TMVA_sL_optimized.root");
	//TFile * _file1 = new TFile ("TMVA_QCD_BBvsGSP_fat.root");
	TFile * file1 = new TFile(input1);
	file1->cd();
	TDirectoryFile * d = (TDirectoryFile *)file1->Get("Method_BDT/BDTG");
	d->cd();
	//cROC->cd();
	MVA_BDTG_rejBvsS->SetTitle("");
	MVA_BDTG_rejBvsS->SetLineColor(kBlue+1);
        MVA_BDTG_rejBvsS->SetLineWidth(3);
        MVA_BDTG_rejBvsS->Draw();
	leg->AddEntry(MVA_BDTG_rejBvsS, label1);
	if(input2!=""){
		TFile * file2 = new TFile(input2);
		file2->cd();
		TDirectoryFile * d2 = file2->Get("Method_BDT/BDTG");
		d2->cd();
		MVA_BDTG_rejBvsS->SetLineColor(kGreen+2);
		MVA_BDTG_rejBvsS->SetLineWidth(3);
		MVA_BDTG_rejBvsS->Draw("same");
		leg->AddEntry(MVA_BDTG_rejBvsS, label2);

	}
	if(input3!=""){
		TFile * file3 = new TFile(input3);
		file3->cd();
		TDirectoryFile * d3 = file3->Get("Method_BDT/BDTG");
		d3->cd();
		MVA_BDTG_rejBvsS->SetLineColor(kRed+2);
		MVA_BDTG_rejBvsS->SetLineWidth(3);
		MVA_BDTG_rejBvsS->Draw("same");
		leg->AddEntry(MVA_BDTG_rejBvsS, label3);
	
	}
	if(input4!=""){
		TFile * file4 = new TFile(input4);
		file4->cd();
		TDirectoryFile * d4 = file4->Get("Method_BDT/BDTG");
		d4->cd();
		MVA_BDTG_rejBvsS->SetLineColor(kOrange+2);
		MVA_BDTG_rejBvsS->SetLineWidth(3);
		MVA_BDTG_rejBvsS->Draw("same");
		leg->AddEntry(MVA_BDTG_rejBvsS, label4);
	
	}
	if(input5!=""){
		TFile * file5 = new TFile(input5);
		file5->cd();
		MVA_BDTG_rejBvsS->SetLineColor(kPink+2);
		MVA_BDTG_rejBvsS->SetLineWidth(3);	
		TDirectoryFile * d5 = file5->Get("Method_BDT/BDTG");
		d5->cd();
		MVA_BDTG_rejBvsS->Draw("same");
		leg->AddEntry(MVA_BDTG_rejBvsS, label5);

	}
	leg->Draw();
	cROC->Print("roc_.png");
}
开发者ID:cvernier,项目名称:Double-b-tagging,代码行数:82,代码来源:plotROC.C


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