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


C++ TChain::CloneTree方法代码示例

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


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

示例1: KeepOnlyGain

void KeepOnlyGain()
{
   TChain* tree = new TChain("SiStripCalib/APVGain");
   tree->Add("Gains_Tree.root");


   TFile* out_file = new TFile("Gains.root","recreate");
   TDirectory* out_dir = out_file->mkdir("SiStripCalib","SiStripCalib");
   out_dir->cd();


   TTree* out_tree = tree->CloneTree(0);
   out_tree->SetName("APVGain");
   out_tree->Write();

   int TreeStep = tree->GetEntries()/50;if(TreeStep==0)TreeStep=1;
   for (unsigned int ientry = 0; ientry < tree->GetEntries(); ientry++) {
      if(ientry%TreeStep==0){printf(".");fflush(stdout);}
      tree->GetEntry(ientry);
      out_tree->Fill();
   }printf("\n");

   out_file->Write();
   out_file->Close();

}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:26,代码来源:KeepOnlyGain.C

示例2: morestrict

void morestrict()
{
    const Int_t Ncha = 6;

    Float_t N[Ncha]  = {0};
    Float_t dN[Ncha] = {0};

    Float_t ADC[Ncha]  = {0};
    Float_t dADC[Ncha] = {0};

    Float_t ADCw[Ncha]  = {0};
    Float_t dADCw[Ncha] = {0};

    ifstream dat;
    dat.open("Run4Nseg.txt");
    cout<<"channel \t ADC \t dADC \t ADCw \t dADCw \t N \t dN"<<endl;
    for (Int_t i=1; i<Ncha; i++) {
        dat>>ADC[i]>>dADC[i]>>ADCw[i]>>dADCw[i]>>N[i]>>dN[i];
        cout<<i<<" \t "<<ADC[i]<<" \t "<<dADC[i]<<" \t "
            <<ADCw[i]<<" \t "<<dADCw[i]<<" \t "
            <<N[i]<<" \t "<<dN[i]<<endl;
    }
    dat.close();

    TChain* pstr = new TChain("pstree","root");
    pstr->AddFile("Run4selected.root");

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    TFile* foutput = new TFile("Run4smaller.root","recreate");
    TTree *newtree = pstr->CloneTree(0);

    Int_t Nevt = pstr->GetEntries();
    cout<<"total events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"now event: "<<i<<endl;

        pstr->GetEntry(i);

        Int_t Nseg=0;
        for (Int_t j=1; j<Ncha; j++) {
            if (Cha_MCAEnergy[j]>ADC[j]-ADCw[j] &&
                    Cha_MCAEnergy[j]<ADC[j]+ADCw[j]) {
                Nseg++;
            }
        }

        if (Nseg==1) {
            newtree->Fill();
        }
    }

    newtree->Write();
    foutput->Close();
}
开发者ID:jintonic,项目名称:gerdalinchenII,代码行数:58,代码来源:Run4select.C

示例3: Save_sWeights

int Fitter::Save_sWeights()
{
	struct NameValTuple {string name; double val;};
	TFile* pFile = new TFile(outputSweights.c_str(), "RECREATE");
	TChain* pChain = new TChain;
	TTree* pTree = NULL;
	Long64_t nEntries = 0, iEntry=0;
	BranchProxy<double> bp;
	vector<NameValTuple> nameValTuples;
	
	if(!pFile){ cerr << "Error creating file" << endl; return 1; }
	if(InitChain(pChain)) return 1;	
	
	// Deactivate branches that would have the same name as the added branches
	for(auto& pVec_pdfs : {&sigPdfs, &bkgPdfs})
	for(auto& pdf : *pVec_pdfs)
	{
		NameValTuple nv = {pdf.GetYld().GetName()};
		string swBranchName = nv.name+"_sw";
		if(pChain->GetBranch(swBranchName.c_str()))
			pChain->SetBranchStatus(swBranchName.c_str(), 0);
		nameValTuples.push_back(nv);
	}
	
	pTree = pChain->CloneTree(0);
	bp.Connect(pChain, branchName.c_str());
	nEntries = pChain->GetEntries();
	
	for(auto& nv : nameValTuples)
	{
		string swBranchName = nv.name + "_sw";
		string branchTitle = swBranchName + "/D";
		
		pTree->Branch(swBranchName.c_str(), &nv.val, branchTitle.c_str());	
	}
	
	for(Long64_t i=0; i<nEntries; ++i)
	{
		pChain->GetEntry(i);
		if(!range.In(bp)) continue;
		
		for(auto& nv : nameValTuples) 
			nv.val = pSPlot->GetSWeight(iEntry, (nv.name+"_sw").c_str());
		
		++iEntry;
		pTree->Fill();
	}
	pTree->AutoSave();
	
	delete pFile;
	delete pChain;
	
	return 0;
}
开发者ID:Burney222,项目名称:Master-Make-Based,代码行数:54,代码来源:Fitter.cpp

示例4: mergetree

void mergetree(TString file1 = "/afs/cern.ch/work/s/shuai/public/diboson/trees/test/testnewsh/fullsig/treeEDBR_TTBAR_xww.root", TString file2 = "/afs/cern.ch/work/s/shuai/public/diboson/trees/test/testnewsh/fullsideband/treeEDBR_TTBAR_xww.root",TString outfile = "mergetreeTest.root")
{
	cout<<"file1 :"<<file1<<endl;
	cout<<"file2 :"<<file2<<endl;
	TChain * chain = new TChain("SelectedCandidates");
	chain->Add(file1);
	int nsig = chain->GetEntries();
	chain->Add(file2);
	int ntotal = chain->GetEntries();
	int nside = ntotal-nsig;
	cout<<"file1 entries: "<<nsig<<endl;
	cout<<"file2 entries: "<<nside<<endl;
	cout<<"file1+file2 entries: "<<ntotal<<endl;	
	
    TFile * outputfile = new TFile(outfile,"RECREATE");
	TTree * outTree = chain->CloneTree(0);

    int nCands;
	//int nEvt;
    chain->SetBranchAddress("nCands",&nCands);
    //chain->SetBranchAddress("nEvt",&nEvt);

	vector <int> sideEvent;

	//save events with signal region candidate for filesig
	for(int i =0; i<nsig; i++)
	{
		//if(i%10000==0)cout<<i<<endl;
		//if(i>200000)break;
		chain->GetEntry(i);
		//cout<<nEvt<<endl;
		//chain->GetEntry(nsig+i);
		//cout<<nEvt<<endl;
		
		if(nCands>0)outTree->Fill();//this event have signal region candidate ( 2 means there are Wmunu and Welenu. This will be filtered by loose lepton veto  )
		else sideEvent.push_back(nsig+i);	
	}
	
	for(int j=0; j<sideEvent.size(); j++ )
	{
		//if(j%10000==0)cout<<j<<endl;
		//if(j>200000)break;
		int n = sideEvent.at(j);
		chain->GetEntry(n);
		if(nCands>0)outTree->Fill();
	}
	
	cout<<"outTree entries: "<<outTree->GetEntries()<<endl;
	
	outputfile->cd();
	outTree->Write();
	outputfile->Close();
}
开发者ID:CesarBernardes,项目名称:ExoDiBosonResonances,代码行数:53,代码来源:mergetree.C

示例5: pre

void pre(Int_t setID)
{
    TChain* pstr = new TChain("PSTree","root");
    if (setID==1) {
        for (Int_t i=1; i<10; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS000%d.root",i));
        for (Int_t i=70; i<85; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));
    }
    else if (setID==2)
        for (Int_t i=10; i<30; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));
    else if (setID==3)
        for (Int_t i=30; i<50; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));
    else if (setID==4)
        for (Int_t i=50; i<70; i++)
            pstr->AddFile(Form("/remote/pclg-10/SIEGFRIED_II/Cd_SII_PS/Cd_In_SII_PS00%d.root",i));

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    TFile* foutput = new TFile(Form("Run4pre%d.root",setID),"recreate");
    TTree *newtree = pstr->CloneTree(0);

    const Int_t Ncha = 7;

    Int_t Nevt = pstr->GetEntries();
    cout<<"Total Events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"Now event: "<<i<<endl;

        pstr->GetEntry(i);

        Int_t Nseg=0;
        for (Int_t j=1; j<Ncha-1; j++) {
            if (Cha_MCAEnergy[j]>1000 && Cha_MCAEnergy[j]<7000) {
                Nseg++;
            }
        }
        if (Nseg==1) {
            newtree->Fill();
        }
        if (i%10000==0) newtree->Write();
    }

    newtree->Write();
    foutput->Close();
}
开发者ID:jintonic,项目名称:gerdalinchenII,代码行数:51,代码来源:Run4select.C

示例6: again

void again()
{
    TChain* pstr = new TChain("PSTree","root");
    for (Int_t i=1; i<5; i++) pstr->AddFile(Form("Run4pre%d.root",i));

    Int_t Cha_MCAEnergy[8];
    pstr->SetBranchAddress("Cha_MCAEnergy",Cha_MCAEnergy);

    TFile* foutput = new TFile("Run4selected.root","recreate");
    TTree *newtree = pstr->CloneTree(0);

    Int_t Nevt = pstr->GetEntries();
    cout<<"Total Events: "<<Nevt<<endl;

    for (Int_t i=0; i<Nevt; i++) {
        if (i%10000==0)
            cout<<"Now event: "<<i<<endl;

        pstr->GetEntry(i);

        Int_t Nseg=0;
        if (Cha_MCAEnergy[1]>3800 && Cha_MCAEnergy[1]<5200) {
            Nseg++;
        }
        for (Int_t j=2; j<=3; j++) {
            if (Cha_MCAEnergy[j]>2200 && Cha_MCAEnergy[j]<3200) {
                Nseg++;
            }
        }
        for (Int_t j=4; j<=5; j++) {
            if (Cha_MCAEnergy[j]>3000 && Cha_MCAEnergy[j]<4400) {
                Nseg++;
            }
        }

        if (Nseg==1) {
            newtree->Fill();
        }
    }

    newtree->Write();
    foutput->Close();

}
开发者ID:jintonic,项目名称:gerdalinchenII,代码行数:44,代码来源:Run4select.C

示例7: mergeDATA

void mergeDATA(TString Tree="/afs/cern.ch/work/s/shuai/public/diboson/trees/productionv7_newMJ/fullallrange")
{

	TFile * outputfile = new TFile(Tree+"/treeEDBR_data_xww.root","RECREATE");

	TString treename;
	treename = "SelectedCandidates";

	TChain * chain_SingleEle = new TChain(treename);
	TChain * chain_SingleMu = new TChain(treename);
/*
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012A_13Jul2012_xww.root");
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012A_recover_xww.root");
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012B_13Jul2012_xww.root");
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012C_24Aug2012_xww.root");
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012C_EcalRecove_xww.root");
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012C_PromptReco_xww.root");
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012D_PromptReco_xww.root");

	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012A_13Jul2012_xww.root");
	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012A_recover_xww.root");
	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012B_13Jul2012_xww.root");
	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012C_24Aug2012_xww.root");
	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012C_EcalRecove_xww.root");	
	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012C_PromptReco_xww.root");	
	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012D_PromptReco_xww.root");
*/

	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012A-22Jan2013_xww.root");
	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012B-22Jan2013_xww.root");
	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012C-22Jan2013_xww.root");
	chain_SingleMu->Add(Tree+"/"+"treeEDBR_SingleMu_Run2012D-22Jan2013_xww.root");	

	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012A-22Jan2013_xww.root");
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012B-22Jan2013_xww.root");
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012C-22Jan2013_xww.root");
	chain_SingleEle->Add(Tree+"/"+"treeEDBR_SingleElectron_Run2012D-22Jan2013_xww.root");



	TChain * chain = new TChain(treename);
	chain->Add(chain_SingleEle);
	int nele = chain->GetEntries();
	chain->Add(chain_SingleMu);
	int ntotal = chain->GetEntries();
	int nmu  = ntotal - nele;
	cout<<"ele entries: "<<nele<<endl;
	cout<<"mu entries: "<<nmu<<endl;
	cout<<"ele+mu entries: "<<ntotal<<endl;

	TTree * outTree = chain->CloneTree(0);

	double lep[99];
	int nLooseEle;
	int nLooseMu;
	chain->SetBranchAddress("lep", lep);
	chain->SetBranchAddress("nLooseMu", &nLooseMu);
	chain->SetBranchAddress("nLooseEle",&nLooseEle);

	//fill only lep==0 for SingEle
	for(int i=0; i<nele; i++)
	{
		chain->GetEntry(i);
		if(nLooseEle+nLooseMu!=1)continue;
		if(lep[0]==0)outTree->Fill();
	}
	//fill only lep==1 for SingMu
	
	for(int i=nele; i<ntotal; i++)
	{
		chain->GetEntry(i);
		if(nLooseEle+nLooseMu!=1)continue;
		if(lep[0]==1)outTree->Fill();
	}
	

	cout<<"output entries:  "<<outTree->GetEntries()<<endl;

	outputfile->cd();
	outTree->Write();
	outputfile->Close();

}
开发者ID:acaudron,项目名称:ExoDiBosonResonances,代码行数:83,代码来源:mergeDATA.C

示例8: CCInclusiveEventSelection


//.........这里部分代码省略.........
    double beammin = 3.55/*-0.36*/; //us. Beam window start
    double beammax = 5.15/*-0.36*/; //us. Beam window end
    double PEthresh = 50; //PE
    double MCTrackToMCVtxDist = 0.5; //cm. distance between mc track start and mc vertex
    double TrackToMCDist = 5; //cm. Distance track start/end to mcvertex

    if(GeneratorName == "data_bnb" || GeneratorName == "data_onbeam_bnb")
    {
        std::cout << "Changed beam gate window for on-beam data" << std::endl;
        beammin = 3.3;
        beammax = 4.9;
    }
    if(GeneratorName == "data_offbeam_bnbext")
    {
        std::cout << "Changed beam gate window for off-beam data" << std::endl;
        beammin = 3.65;
        beammax = 5.25;
    }
    if(GeneratorName == "prodcosmics_corsika_inTime")
    {
        std::cout << "Changed beam gate window for Corsika sample" << std::endl;
        beammin = 3.2;
        beammax = 4.8;
    }

    // Loop over all product names
    for(const auto& TrackingName : TrackProdNameVec)
    {
        for(const auto& VertexingName : VertexProdNameVec)
        {
            // Open output file
            TFile* OutputFile = new TFile(("rootfiles/Hist_Track_"+TrackingName+ "_Vertex_" + VertexingName + "_"+GeneratorName+"_"+Version+FileNumberStr+"_Old.root").c_str(),"RECREATE");
            // Make a clone tree which gets filled
            TTree *SelectionTree = treenc->CloneTree(0);

            treenc -> SetBranchAddress("event", &event);
            treenc -> SetBranchAddress("potbnb", &potbnb);
            treenc -> SetBranchAddress("no_flashes", &no_flashes);
            treenc -> SetBranchAddress("flash_time", flash_time);
            treenc -> SetBranchAddress("flash_pe", flash_pe);
            treenc -> SetBranchAddress("flash_zcenter", flash_zcenter);
            treenc -> SetBranchAddress("flash_ycenter", flash_ycenter);
            treenc -> SetBranchAddress("mcevts_truth", &mcevts_truth);
            treenc -> SetBranchAddress("nuvtxx_truth", nuvtxx_truth);
            treenc -> SetBranchAddress("nuvtxy_truth", nuvtxy_truth);
            treenc -> SetBranchAddress("nuvtxz_truth", nuvtxz_truth);
            treenc -> SetBranchAddress("ccnc_truth", ccnc_truth);
            treenc -> SetBranchAddress("nuPDG_truth", nuPDG_truth);
            treenc -> SetBranchAddress("pdg", PDG_truth);
            treenc -> SetBranchAddress("mode_truth", mode_truth);
            treenc -> SetBranchAddress("geant_list_size", &NumberOfMCTracks);
            treenc -> SetBranchAddress("StartPointx", XMCTrackStart);
            treenc -> SetBranchAddress("StartPointy", YMCTrackStart);
            treenc -> SetBranchAddress("StartPointz", ZMCTrackStart);
            treenc -> SetBranchAddress("EndPointx", XMCTrackEnd);
            treenc -> SetBranchAddress("EndPointy", YMCTrackEnd);
            treenc -> SetBranchAddress("EndPointz", ZMCTrackEnd);
            treenc -> SetBranchAddress("TrackId", MCTrackID);
            treenc -> SetBranchAddress("MCTruthIndex", MCTrueIndex);

            // Product specific stuff
            treenc -> SetBranchAddress(("ntracks_"+TrackingName).c_str(),&ntracks_reco);
            treenc -> SetBranchAddress(("trkstartx_"+TrackingName).c_str(),trkstartx);
            treenc -> SetBranchAddress(("trkstarty_"+TrackingName).c_str(),trkstarty);
            treenc -> SetBranchAddress(("trkstartz_"+TrackingName).c_str(),trkstartz);
            treenc -> SetBranchAddress(("trkendx_"+TrackingName).c_str(),trkendx);
开发者ID:chrigulix,项目名称:CCInclusive,代码行数:67,代码来源:CCInclusiveEventSelection.C

示例9: TreeFiller

void TreeFiller(string inFiles, string outFile, string histName) {

	
	TChain *origFiles = new TChain("treeVars", "treeVars");
	origFiles->Add(inFiles.c_str());
	
	int nEntries = origFiles->GetEntries();
	cout << "The old chain contains " << nEntries << " entries." << endl;
	
	
	float puWeight, jet1Eta, jet2Eta, deltaY, genTopPt1, genTopPt2, jet1Mass, jet2Mass, jet1MinMass, jet2MinMass, jet1BDisc, jet2BDisc, jet1SubjetMaxBDisc, jet2SubjetMaxBDisc,
			jet1tau32, jet2tau32, jet1Pt, jet2Pt, jet1bSF, jet2bSF, jet1bSFErrUp, jet2bSFErrUp, jet1bSFErrDn, jet2bSFErrDn, jetPtForMistag, mttMass, mttMassPred, mistagWt, mistagWtErr, mistagWtAll, mistagWtNsubAll, mistagWtNsub, NNoutput, ptReweight, cutflow, index, trigWt;
	int jet1NSubjets, jet2NSubjets, jet1Parton, jet2Parton, npv;
		
	origFiles->SetBranchAddress("npv", &npv);
	origFiles->SetBranchAddress("jet1Eta", &jet1Eta);
	origFiles->SetBranchAddress("jet2Eta", &jet2Eta);
	origFiles->SetBranchAddress("deltaY", &deltaY);
	origFiles->SetBranchAddress("jet1Mass", &jet1Mass);
	origFiles->SetBranchAddress("jet2Mass", &jet2Mass);
	origFiles->SetBranchAddress("jet1minMass", &jet1MinMass);
	origFiles->SetBranchAddress("jet2minMass", &jet2MinMass);
	origFiles->SetBranchAddress("jet1Nsubj", &jet1NSubjets);
	origFiles->SetBranchAddress("jet2Nsubj", &jet2NSubjets);
	origFiles->SetBranchAddress("jet1BDisc", &jet1BDisc);
	origFiles->SetBranchAddress("jet2BDisc", &jet2BDisc);
	origFiles->SetBranchAddress("jet1SubjetMaxBDisc", &jet1SubjetMaxBDisc);
	origFiles->SetBranchAddress("jet2SubjetMaxBDisc", &jet2SubjetMaxBDisc);
	origFiles->SetBranchAddress("jet1tau32", &jet1tau32);
	origFiles->SetBranchAddress("jet2tau32", &jet2tau32);
	origFiles->SetBranchAddress("jet1Pt", &jet1Pt);
	origFiles->SetBranchAddress("jet2Pt", &jet2Pt);
	origFiles->SetBranchAddress("jetPtForMistag", &jetPtForMistag);
	origFiles->SetBranchAddress("mttMass", &mttMass);
	origFiles->SetBranchAddress("mttMassPred", &mttMassPred);
	origFiles->SetBranchAddress("index", &index);
	origFiles->SetBranchAddress("cutflow", &cutflow);
	origFiles->SetBranchAddress("NNoutput", &NNoutput);
	origFiles->SetBranchAddress("mistagWt", &mistagWt);
	origFiles->SetBranchAddress("genTopPt1", &genTopPt1);	
	origFiles->SetBranchAddress("genTopPt2", &genTopPt2);
	origFiles->SetBranchAddress("jet1Parton", &jet1Parton);
	origFiles->SetBranchAddress("jet2Parton", &jet2Parton);	
	origFiles->SetBranchAddress("trigWt", &trigWt);
	
	TFile *newFile = new TFile(outFile.c_str(), "RECREATE");
	TTree *newTree = origFiles->CloneTree(0);
	newTree->Branch("mistagWtNsub", &mistagWtNsub, "mistagWtNsub/F");
	newTree->Branch("mistagWtNsubAll", &mistagWtNsubAll, "mistagWtNsubAll/F");
	newTree->Branch("mistagWtAll", &mistagWtAll, "mistagWtAll/F");
	newTree->Branch("ptReweight", &ptReweight, "ptReweight/F");
	newTree->Branch("puWeight", &puWeight, "puWeight/F");
	newTree->Branch("jet1bSF", &jet1bSF, "jet1bSF/F");
	newTree->Branch("jet2bSF", &jet2bSF, "jet2bSF/F");
	newTree->Branch("jet1bSFErrUp", &jet1bSFErrUp, "jet1bSFErrUp/F");
	newTree->Branch("jet2bSFErrUp", &jet2bSFErrUp, "jet2bSFErrUp/F");
	newTree->Branch("jet1bSFErrDn", &jet1bSFErrDn, "jet1bSFErrDn/F");
	newTree->Branch("jet2bSFErrDn", &jet2bSFErrDn, "jet2bSFErrDn/F");
	newTree->Branch("mistagWtErr", &mistagWtErr, "mistagWtErr/F");

	newTree->SetBranchAddress("mistagWtNsub", &mistagWtNsub);
	newTree->SetBranchAddress("misagWtNsubAll", &mistagWtNsubAll);
	newTree->SetBranchAddress("mistagWtAll", &mistagWtAll);
	newTree->SetBranchAddress("ptReweight", &ptReweight);
	newTree->SetBranchAddress("puWeight", &puWeight);
	newTree->SetBranchAddress("mistagWtErr", &mistagWtErr);

/*	
	TMVA::Reader* reader = new TMVA::Reader();
	reader->AddVariable("jet1Eta", &jet1Eta);
	reader->AddVariable("jet2Eta", &jet2Eta);
	reader->AddVariable("deltaY", &deltaY);
	reader->AddVariable("jet1Mass", &jet1Mass);
	reader->AddVariable("jet2Mass", &jet2Mass);
	reader->AddVariable("jet1BDisc", &jet1BDisc);
	reader->AddVariable("jet2BDisc", &jet2BDisc);
	reader->AddVariable("jet1SubjetMaxBDisc", &jet1SubjetMaxBDisc);
	reader->AddVariable("jet2SubjetMaxBDisc", &jet2SubjetMaxBDisc);
	reader->AddVariable("jet1tau32", &jet1tau32);
	reader->AddVariable("jet2tau32", &jet2tau32);
	reader->AddVariable("jet1Pt", &jet1Pt);
	reader->AddVariable("jet2Pt", &jet2Pt);
	reader->AddVariable("mttMass", &mttMass);

	reader->BookMVA("MLP", "weights/TMVA_tt_Zp_MLP.weightsZp10_cut4.xml");
*/	
	//TFile *mistagFileLow = new TFile("notCSVL_notCSVM_mistag.root");
	//TFile *mistagFileMed = new TFile("CSVL_notCSVM_mistag.root");
	//TFile *mistagFileHi = new TFile("CSVM_mistag.root");
	TFile *mistagFile = new TFile("Jul3_mistag.root");//data_AllBscore_mistag_Dec16.root");
	histName = "MISTAG_RATE_SUB_TTBAR_Inclusive";
	TFile *triggerFile = new TFile("trigger_weights.root");
	TH1F *triggerHist = (TH1F *) triggerFile->Get("triggerHist");
	TH3F *mistagRateHistAll = (TH3F *) mistagFile->Get( histName.c_str() )->Clone();	
	cout << histName << endl;
	cout << "Entries " << mistagRateHistAll->Integral() << endl;	
	TFile *puFile = new TFile("puHists.root");
	TH1F *puWeightsHist = (TH1F *) puFile->Get("weightsH");
	
	for (int i = 0; i < origFiles->GetEntries(); i++){
//.........这里部分代码省略.........
开发者ID:justinrpilot,项目名称:ZprimeAllHad,代码行数:101,代码来源:TreeFiller3D.C

示例10: 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

示例11: main

int main(int argc, char* argv[]) {

  //ROOT::Cintex::Cintex::Enable();
  if(argc<2){
      std::cout << "Input parameters: 1) W,Z,TAU,QCD,DATA" << std::endl;
      exit(EXIT_SUCCESS);
  }
  bool doTruthW = false;
  bool doTruthZ = false;
  bool doTruthTau = false;
  bool doTruthQCD = false;
  bool doTruth = false;
  if(strcmp(argv[1],"W")==0) doTruthW=true;
  else if(strcmp(argv[1],"Z")==0) doTruthZ=true;
  else if(strcmp(argv[1],"TAU")==0) doTruthTau=true;
  else if(strcmp(argv[1],"QCD")==0) doTruthQCD=true;
  if(doTruthW||doTruthZ||doTruthTau||doTruthQCD) doTruth=true;
  int mother=-1;
  int child1=-1;
  int child2=-1;
  bool doMinBias = false;
  bool doMu = true;
  bool doMuid = false;
  bool doStaco = false;
  if(doTruthW) { 
      mother=24; // W
      child1=13; // muon
      child2=14; // neutrino
      std::cout << "======> Running on W-->munu Monte Carlo simulation. <======" << std::endl; 
  }
  else if(doTruthZ) { 
      mother=23; // Z
      child1=13; // muon
      child2=13; // muon 
      std::cout << "======> Running on Z-->mumu Monte Carlo simulation. <======" << std::endl; 
  }
  else if(doTruthTau) { 
      mother=15; // tau
      child1=13; // muon
      child2=14; // neutrino(s) 
      std::cout << "======> Running on W-->taunu-->mununu Monte Carlo simulation. <======" << std::endl; 
  }
  else if(doTruthQCD) { 
      child1=13; // muon
      std::cout << "======> Running on QCD Monte Carlo simulation. <======" << std::endl; 
  }
  else if(doMinBias) { std::cout << "======> Running on Minimum Bias Data. <======" << std::endl; }
  else { std::cout << "======> Running on Data. <======" << std::endl; }
  if(doTruth&&doMinBias){

      std::cout << "PLEASE CHOOSE TO RUN ON EITHER MC OR DATA." << std::endl;
      exit(0);
  }
  std::string argStr;
  std::ifstream ifs;
  ifs.open("input.txt");

  // split by ','
  std::vector<std::string> fileList;
  
  std::getline(ifs,argStr);
  for (size_t i=0,n; i <= argStr.length(); i=n+1)
  {
      n = argStr.find_first_of(',',i);
      if (n == std::string::npos)
          n = argStr.length();
      std::string tmp = argStr.substr(i,n-i);
      fileList.push_back(tmp);
  }

  cout << fileList.size() << " files used for processing." << endl;
  // open input files
  TChain* fChain = new TChain("HeavyIonD3PD");

  for (int iFile=0; iFile<fileList.size(); ++iFile)
    {
      std::cout << "open " << fileList[iFile].c_str() << std::endl;
      // Add each file to the TChain
      fChain->Add(fileList[iFile].c_str());
    }
  int entries = fChain->GetEntries();
  std::cout << "entries=" << fChain->GetEntries() << std::endl;

  TFile* fout=0;
  fout=new TFile("skimmed.root","RECREATE");
  TTree* outputTree = new TTree("MuonD3PD","MuonD3PD");
  TTree* outputTallTree = fChain->CloneTree(0);

  // Handle to D3PD
  EventAnalysis* EvtAna = new EventAnalysis(fChain, doTruth, doMinBias);
  EvtAna->SetOutputBranches(outputTree);

  MuonAnalysis* muMuonAna = NULL, *muidMuonAna = NULL, *stacoMuonAna = NULL; 
  if(doMu){
    std::cout << "USING MUON RECONSTRUCTION CHAIN." << std::endl;
    muMuonAna = new MuonAnalysis("mu", doTruth, doMinBias);
    muMuonAna->SetOutputBranches(outputTree);
  }
  if(doMuid){
    std::cout << "USING MUID RECONSTRUCTION CHAIN." << std::endl;
//.........这里部分代码省略.........
开发者ID:Feynman27,项目名称:HipMuonSkimming,代码行数:101,代码来源:SkimMain.cpp

示例12: dimuonSkim


//.........这里部分代码省略.........
               std::cout<<"could not get branch : pPAprimaryVertexFilter"<<std::endl;
               std::cout<<"set to default value : pPAprimaryVertexFilter = "<<pPAprimaryVertexFilter<<std::endl;
           }
       }
       else {
           pPAprimaryVertexFilter = 0;      // default value if the collision is not PP, will not be used anyway.
       }
       Int_t pBeamScrapingFilter;   // this filter is used for PP.
       if (isPP) {
           treeSkim->SetBranchStatus("pBeamScrapingFilter",1);
           if (treeSkim->GetBranch("pBeamScrapingFilter")) {
               treeSkim->SetBranchAddress("pBeamScrapingFilter",&pBeamScrapingFilter);
           }
           else {   // overwrite to default
               pBeamScrapingFilter = 1;
               std::cout<<"could not get branch : pBeamScrapingFilter"<<std::endl;
               std::cout<<"set to default value : pBeamScrapingFilter = "<<pBeamScrapingFilter<<std::endl;
           }
       }
       else {
           pBeamScrapingFilter = 0;     // default value if the collision is not PP, will not be used anyway.
       }

       ggHiNtuplizer ggHi;
       ggHi.setupTreeForReading(treeggHiNtuplizer);
       
       hiEvt hiEvt;
       hiEvt.setupTreeForReading(treeHiEvt);

       TFile* output = new TFile(outputFile,"RECREATE");
       TTree *configTree = setupConfigurationTreeForWriting(configCuts);

       // output tree variables
       TTree *outputTreeHLT           = treeHLT->CloneTree(0);
       outputTreeHLT->SetName("hltTree");
       outputTreeHLT->SetTitle("subbranches of hltanalysis/HltTree");
       TTree *outputTreeggHiNtuplizer = treeggHiNtuplizer->CloneTree(0);
       TTree *outputTreeHiEvt = treeHiEvt->CloneTree(0);
       outputTreeHiEvt->SetName("HiEvt");
       outputTreeHiEvt->SetTitle("subbranches of hiEvtAnalyzer/HiTree");
       TTree* outputTreeSkim  = treeSkim->CloneTree(0);
       outputTreeSkim->SetName("skim");
       outputTreeSkim->SetTitle("subbranches of skimanalysis/HltTree");
       TTree* outputTreeHiForestInfo = treeHiForestInfo->CloneTree(0);
       outputTreeHiForestInfo->SetName("HiForestInfo");
       outputTreeHiForestInfo->SetTitle("first entry of HiForest/HiForestInfo");
       
       outputTreeHLT->SetMaxTreeSize(MAXTREESIZE);
       outputTreeggHiNtuplizer->SetMaxTreeSize(MAXTREESIZE);
       outputTreeHiEvt->SetMaxTreeSize(MAXTREESIZE);
       outputTreeHiForestInfo->SetMaxTreeSize(MAXTREESIZE);

       // write HiForestInfo
       treeHiForestInfo->GetEntry(0);
       outputTreeHiForestInfo->Fill();

       TTree *diMuonTree = new TTree("dimuon","muon pairs");
       diMuonTree->SetMaxTreeSize(MAXTREESIZE);

       dimuon diMu;
       diMu.branchDiMuonTree(diMuonTree);

       EventMatcher* em = new EventMatcher();
       Long64_t duplicateEntries = 0;

       Long64_t entries = treeggHiNtuplizer->GetEntries();
开发者ID:CmsHI,项目名称:ElectroWeak-Jet-Track-Analyses,代码行数:67,代码来源:dimuonSkim.C

示例13: main


//.........这里部分代码省略.........
	Qmin = meanQ[p];
    }

    vgraph.push_back(new TGraphErrors(Npoint, DAC, meanQ, 0, meanQerr));
    vsigma.push_back(sigma);
    vQmin.push_back(Qmin);
  }

  TFile* fout = new TFile(output_name.c_str(), "RECREATE");

  // write xADCBase tree to outputfile
  //TChain* base_tree = new TChain("xADC_data");
  //base_tree->AddFile(inputFileName);
  //TTree* new_base_tree = base_tree->CloneTree();
  //fout->cd();
  //new_base_tree->Write();

  // add plots of charge v DAC for each
  // MMFE8+VMM combo to output file
  fout->mkdir("xADCfit_plots");
  fout->cd("xADCfit_plots");
  for(int i = 0; i < Nindex; i++){
    char stitle[50];
    sprintf(stitle, "Board #%d, VMM #%d", vMMFE8[i], vVMM[i]);
    char scan[50];
    sprintf(scan, "c_xADXfit_Board%d_VMM%d", vMMFE8[i], vVMM[i]);
    TCanvas* can = Plot_Graph(scan, vgraph[i], "Test Pulse DAC", "Input Charge (fC)", stitle);
    can->Write();
    delete can;
  }
  fout->cd("");

  // write xADCfitBase tree to outputfile
  TTree* newtree = tree->CloneTree();
  fout->cd();
  newtree->Write();
  delete newtree;
  delete base;
  delete tree;

  // Output xADC calib tree
  double calib_MMFE8;
  double calib_VMM;
  double calib_sigma;
  double calib_c0;
  double calib_A2;
  double calib_t02;
  double calib_d21;
  double calib_chi2;
  double calib_prob;
  
  TTree* calib_tree = new TTree("xADC_calib", "xADC_calib");
  calib_tree->Branch("MMFE8", &calib_MMFE8);
  calib_tree->Branch("VMM", &calib_VMM);
  calib_tree->Branch("sigma", &calib_sigma);
  calib_tree->Branch("c0", &calib_c0);
  calib_tree->Branch("A2", &calib_A2);
  calib_tree->Branch("t02", &calib_t02);
  calib_tree->Branch("d21", &calib_d21);
  calib_tree->Branch("chi2", &calib_chi2);
  calib_tree->Branch("prob", &calib_prob);

  // Perform fits on each vector of 
  // charge v DACMMFE8+VMM graphs
  fout->mkdir("xADCcalib_plots");
  fout->cd("xADCcalib_plots");
开发者ID:crogan,项目名称:VMM2_Calibration,代码行数:67,代码来源:Calibrate_xADC.C

示例14: filter

int filter(TString inputDir, long n_evt=100,bool is11=false,bool isFR=false)
{
	long TotalEvents=n_evt;
	
	//options
	bool is2011=is11;
    int N_ALL=4;
    int N_ELMU=-3;
    if(isFR){
		N_ALL=-4;
		N_ELMU=3;
	}
           
    double cut_mu_pt=9.0;
    double cut_mu_eta=2.4; 
    double cut_el_pt=9.0;
    double cut_el_eta=2.5;
    double cut_tau_pt=19.0;
    double cut_tau_eta=2.3;
    
    if(isFR) cut_tau_pt=0.0;
    
    double cut_dR=-0.09;
    double lepton_mass_min=50.0;
    double lepton_mass_max=150.0;
    
	std::string doubEle="HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v";
	std::string doubEle2="HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v";
	
    std::string doubMu="HLT_Mu17_Mu8_v";
    std::string doubMu2="HLT_Mu17_TkMu8_v"; // "HLT_Mu13_Mu8_v" in 2011
    if(is2011) doubMu2="HLT_Mu13_Mu8_v";
    std::string doubMu3="HLT_DoubleMu7_v";
    
    bool debug = false;
    

	
	TChain *chain = new TChain("t");
	chain->Add(inputDir+"*root*");
	
	
	
	//////////////////////// end of modular part ////////////////////////////////////////
	/////////////////////////COMMON part //////////////////////////////////////////
	myevent* in = new myevent();
	chain->SetBranchAddress("myevent",&in);
	
	long MaxEvents = chain->GetEntries();
	if(TotalEvents > MaxEvents || TotalEvents < 0) TotalEvents=MaxEvents;
	
	std::cout << "There are " << MaxEvents << " entries." << std::endl;
	
	
	//bookkeeping
	ofstream lumi;
	long current_run=-1;
	long current_lumi=-1;
    long m_allEvents=0;
	lumi.open("lumi.csv");
	
	//output definition
	
	 TFile *newFile = new TFile("output.root","recreate");
	TChain *newchain = (TChain*)chain->CloneTree(0);
	 TTree *tree = newchain->GetTree();
	
	
	for(uint i =0; i < TotalEvents; i++)
	{
		chain->GetEntry(i);
		m_allEvents++;
		
		if(debug) std::cout << "Processing entry " << i << " event: " << in->eventNumber << std::endl;
		if(i%1000==0)std::cout << "Analyzing entry no. " << i << std::endl;
		
		// storing lumis
		if(in->runNumber!=current_run || in->lumiNumber!=current_lumi){
			lumi << in->runNumber << " " << in->lumiNumber << std::endl;
			current_run=in->runNumber;
			current_lumi=in->lumiNumber;
		}
		
		if(PassFilter(in, debug, doubEle, doubEle2, doubMu, doubMu2, doubMu3,
			         is2011, N_ALL, N_ELMU, 
			         cut_mu_pt, cut_mu_eta, cut_el_pt, cut_el_eta, cut_tau_pt, cut_tau_eta,		    
			         cut_dR, lepton_mass_min, lepton_mass_max)
		   ) tree->Fill();
	}
	
	newFile->cd();
	newFile->Write();
	newFile->Close();
	
	 ofstream log1;       
     log1.open("total.txt");
     log1 << m_allEvents << std::endl;
     log1.close();
     
	return 0;
//.........这里部分代码省略.........
开发者ID:abdollah110,项目名称:53xNtupleProducer,代码行数:101,代码来源:filter.C

示例15: photonRaaSkim


//.........这里部分代码省略.........
        else {   // overwrite to default
            pBeamScrapingFilter = 1;
            std::cout<<"could not get branch : pBeamScrapingFilter"<<std::endl;
            std::cout<<"set to default value : pBeamScrapingFilter = "<<pBeamScrapingFilter<<std::endl;
        }
    }
    else {
        pBeamScrapingFilter = 0;     // default value if the collision is not PP, will not be used anyway.
    }

    // objects for z-jet correlations
    ggHiNtuplizer ggHi;
    ggHi.setupTreeForReading(treeggHiNtuplizer);    // treeggHiNtuplizer is input
    treeggHiNtuplizer->SetBranchStatus("*",0);
    treeggHiNtuplizer->SetBranchStatus("run",1);
    treeggHiNtuplizer->SetBranchStatus("event",1);
    treeggHiNtuplizer->SetBranchStatus("lumis",1);
    treeggHiNtuplizer->SetBranchStatus("nPho",1);
    treeggHiNtuplizer->SetBranchStatus("pho*",1);
    treeggHiNtuplizer->SetBranchStatus("pf*",1);
    //treeggHiNtuplizer->SetBranchStatus("tower*",1);
    if(isMC) treeggHiNtuplizer->SetBranchStatus("mc*",1);



    TFile* output = TFile::Open(outputFile,"RECREATE");
    TTree* configTree = setupConfigurationTreeForWriting(configCuts);

    // output tree variables
    TTree *outputTreeHLT=0, *outputTreeggHiNtuplizer=0, 
          *outputTreeHiEvt=0, *outputTreeSkim=0, *outputTreeHiForestInfo=0, *outputTreeGen=0;

    // output tree variables
    outputTreeHLT    = treeHLT->CloneTree(0);
    outputTreeggHiNtuplizer = treeggHiNtuplizer->CloneTree(0);
    outputTreeHiEvt = treeHiEvt->CloneTree(0);
    outputTreeSkim   = treeSkim->CloneTree(0);
    outputTreeHiForestInfo = treeHiForestInfo->CloneTree(0);
    if(isMC) outputTreeGen = treeGen ->CloneTree(0);

    outputTreeSkim->SetName("skimTree");
    outputTreeHLT->SetMaxTreeSize(MAXTREESIZE);
    outputTreeggHiNtuplizer->SetMaxTreeSize(MAXTREESIZE);
    outputTreeHiEvt->SetMaxTreeSize(MAXTREESIZE);
    outputTreeSkim->SetMaxTreeSize(MAXTREESIZE);
    outputTreeHiForestInfo->SetMaxTreeSize(MAXTREESIZE);
    if(isMC) outputTreeGen->SetMaxTreeSize(MAXTREESIZE);

    if(isMC) outputTreeHiEvt->Branch("pthatWeight", &pthatWeight, "pthatWeight/F");
  

    /////// Event Matching for DATA ///////
    EventMatcher* em = new EventMatcher();
    Long64_t duplicateEntries = 0;
    Long64_t entriesPassedEventSelection =0;
    Long64_t entriesAnalyzed =0;
    Long64_t entriesSpikeRejected=0;
    Long64_t entries = treeggHiNtuplizer->GetEntries();
    std::cout << "entries = " << entries << std::endl;
    std::cout<< "Loop : ggHiNtuplizer/EventTree" <<std::endl;
    //for (Long64_t j_entry=10000; j_entry<10100; ++j_entry)
    for (Long64_t j_entry=0; j_entry<entries; ++j_entry)
    {
        if (j_entry % 2000 == 0)  {
            std::cout << "current entry = " <<j_entry<<" out of "<<entries<<" : "<<std::setprecision(2)<<(double)j_entry/entries*100<<" %"<<std::endl;
        }
开发者ID:ttrk,项目名称:ElectroWeak-Jet-Track-Analyses,代码行数:67,代码来源:photonRaaSkim.C


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