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


C++ TNtuple::SaveAs方法代码示例

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


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

示例1: CutTree

void CutTree(){

	int NMin=300000;

/*	char outputfilename[200];
	sprintf(outputfilename,"Results/ProblemBin.txt");
	printf("output filename is: %s\n", outputfilename);
	FILE *outputFile = fopen(outputfilename,"w");
*/
	TFile* fInData = new TFile(fileNameData);

	TTree *treeData = (TTree*)fInData->Get("data");

	treeData->Print();


	TTree *fChain;
	fChain=treeData;

	Long64_t nentries = fChain->GetEntries();
	cout<<nentries<<endl;
	Long64_t nb = 0;

	Double_t        JpsiMass;
	Double_t        JpsiPt;
	Double_t        JpsiRap;
	Double_t        Jpsict;
	Int_t        JpsiType_idx;
	Int_t        MCType_idx;
	Double_t        costh_CS;
	Double_t        phi_CS;
	Double_t        costh_HX;
	Double_t        phi_HX;

	TBranch        *b_JpsiMass;   //!
	TBranch        *b_JpsiPt;   //!
	TBranch        *b_JpsiRap;   //!
	TBranch        *b_Jpsict;   //!
	TBranch        *b_JpsiType_idx;   //!
	TBranch        *b_MCType_idx;   //!
	TBranch        *b_costh_CS;   //!
	TBranch        *b_phi_CS;   //!
	TBranch        *b_costh_HX;   //!
	TBranch        *b_phi_HX;   //!

	fChain->SetBranchAddress("JpsiMass", &JpsiMass, &b_JpsiMass);
	fChain->SetBranchAddress("JpsiPt", &JpsiPt, &b_JpsiPt);
	fChain->SetBranchAddress("JpsiRap", &JpsiRap, &b_JpsiRap);
	fChain->SetBranchAddress("Jpsict", &Jpsict, &b_Jpsict);
	fChain->SetBranchAddress("JpsiType_idx", &JpsiType_idx, &b_JpsiType_idx);
	fChain->SetBranchAddress("MCType_idx", &MCType_idx, &b_MCType_idx);
	fChain->SetBranchAddress("costh_CS", &costh_CS, &b_costh_CS);
	fChain->SetBranchAddress("phi_CS", &phi_CS, &b_phi_CS);
	fChain->SetBranchAddress("costh_HX", &costh_HX, &b_costh_HX);
	fChain->SetBranchAddress("phi_HX", &phi_HX, &b_phi_HX);


//	Long64_t jentry=NMin;

    TNtuple* pseudodata = new TNtuple("data","data","JpsiMass:JpsiPt:JpsiRap:Jpsict:costh_CS:phi_CS:costh_HX:phi_HX:JpsiType_idx:MCType_idx");
    TNtuple* data = new TNtuple("data","data","JpsiMass:JpsiPt:JpsiRap:Jpsict:costh_CS:phi_CS:costh_HX:phi_HX:JpsiType_idx:MCType_idx");

    for (Long64_t jentry=0; jentry<NMin;jentry++) {
       		    	 if(jentry % 1000 == 0) printf("event %d\n", (Int_t) jentry);

       	   nb = fChain->GetEntry(jentry);   //nbytes += nb;

       	pseudodata->Fill(JpsiMass,JpsiPt,JpsiRap,Jpsict,costh_CS,phi_CS,costh_HX,phi_HX,JpsiType_idx,MCType_idx);

        }

    for (Long64_t jentry=0; jentry<nentries;jentry++) {
   		    	 if(jentry % 1000 == 0) printf("event %d\n", (Int_t) jentry);

   	   nb = fChain->GetEntry(jentry);   //nbytes += nb;

// 	  fprintf(outputFile, "%f\n",Jpsict);


   	data->Fill(JpsiMass,JpsiPt,JpsiRap,Jpsict,costh_CS,phi_CS,costh_HX,phi_HX,JpsiType_idx,MCType_idx);

    }

    pseudodata->Print();

    pseudodata->SaveAs("/scratch/knuenz/Polarization/RootInput/TNtuple_red_PR_pseudo.root");

	data->Print();

	data->SaveAs("/scratch/knuenz/Polarization/RootInput/TNtuple_red_PR.root");

//	RooDataSetData.Print();


//	fclose(outputFile);


//	treeData.Print();

	return;
//.........这里部分代码省略.........
开发者ID:zhlinl,项目名称:usercode,代码行数:101,代码来源:CutTree.C


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