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


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

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


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

示例1: readmcsample

void readmcsample(TH1D &nom, TH1D &rw, TH1D &nomratio, bool doGen){
 cout<<"reading data for "<<File_Signal_reco<<endl;
  TChain* t;
  if (!doGen) t= new TChain(reco_name.c_str(),reco_name.c_str());
  else t= new TChain(gen_name.c_str(),gen_name.c_str());
  int nfiles;
  if (!doGen) nfiles=t->Add(File_Signal_reco.c_str());
  else nfiles=t->Add(File_Signal_gen.c_str());

  TBranch *b_reco=t->GetBranch("reco");
  TBranch *b_truth=t->GetBranch("truth");
  TLeaf *l_mass=b_reco->GetLeaf("z_y");
  if (doMass) l_mass=b_reco->GetLeaf("z_m");
  if (doGen) {
    l_mass=b_truth->GetLeaf("z_y");
    if (doMass) l_mass=b_truth->GetLeaf("z_m");
  }
  TLeaf *l_phistar=b_reco->GetLeaf("z_phistar_dressed");
  TLeaf *l_phistar_true=b_truth->GetLeaf("z_phistar_dressed");
  int nweights;
  t->SetBranchAddress("weight_size",&nweights);
  t->GetEntry(0);
  cout<<"The sample has nweights: "<<nweights<<endl;
  double weights[nweights];
  int weightid[nweights];
  t->SetBranchAddress("weights",&weights);
  t->SetBranchAddress("weight_ids",&weightid);
  
  // TFile f_zy("ratio_y.root");
  // ratio = (TH1F*)f_zy.Get("ratio");
  // f_zy.Close();
  TFile f_zm("ratio_zmass.root");
  TH1F *ratio = (TH1F*)f_zm.Get("ratio_histo");
  cout<<"Entries: "<<t->GetEntries()<<endl;
  for (int i=0; i<t->GetEntries();i++){
    t->GetEntry(i);
    double phistar=l_phistar->GetValue();
    double mass=l_mass->GetValue();
    double phistar_true=l_phistar_true->GetValue();
    double weight =1;
    for (int w=0; w<nweights;w++){
      if (weightid[w]==1 || weightid[w]==2 || weightid[w]==12 || weightid[w]==13 || weightid[w]==20 || weightid[w]==30) {weight=weight*weights[w];}
    }
    int idx=ratio->GetXaxis()->FindBin(mass);
    if (ratio->GetBinContent(idx)!=0){
     if (!doGen){
	nom.Fill(phistar,weight);
	nomratio.Fill(phistar,weight);
	weight=weight*ratio->GetBinContent(idx);
	rw.Fill(phistar,weight);
     }
      else{
	nom.Fill(phistar_true,weight);
	nomratio.Fill(phistar_true,weight);
	weight=weight*ratio->GetBinContent(idx);
	rw.Fill(phistar_true,weight);
      }
    }
  }
}
开发者ID:UMN-CMS,项目名称:ZFinder-Analysis-Scripts,代码行数:60,代码来源:NTuple_ZY.C

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

示例3: mca

void mca()
{
    TChain* pstr = new TChain("PSTree","root");
    pstr->AddFile("Run4selected.root");

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

    const Int_t Ncha = 7;
    TH1F *MCA[Ncha];
    MCA[0] = new TH1F("MCA0","MCA Spectrum for the core",3000,1000,7000);
    MCA[1] = new TH1F("MCA1","MCA Spectrum for segment 1",700,3800,5200);
    for (Int_t i=2; i<=3; i++)
        MCA[i] = new TH1F(Form("MCA%d",i),Form("MCA Spectrum for segment %d",i),500,2200,3200);
    for (Int_t i=4; i<=5; i++)
        MCA[i] = new TH1F(Form("MCA%d",i),Form("MCA Spectrum for segment %d",i+12),700,3000,4400);
    MCA[6] = new TH1F("MCA6","MCA Spectrum for segment 18",10000,1000,21000);

    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);

        for (Int_t j=0; j<Ncha; j++)
            MCA[j]->Fill((Float_t) Cha_MCAEnergy[j]);
    }

    TFile* foutput = new TFile("Run4mca.root","recreate");
    for (Int_t i=0; i<Ncha; i++) MCA[i]->Write();
    foutput->Close();
}
开发者ID:jintonic,项目名称:gerdalinchenII,代码行数:35,代码来源:Run4select.C

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

示例5: LoadData

int Fitter::LoadData()
{
	TChain* pChain = new TChain;
	Long64_t nEntries = 0;
	BranchProxy<double> bp;

	pFitVar = new RooRealVar(branchName.c_str(), plotAxisLabel.c_str(), range.minimum, range.maximum, branchUnit.c_str());
	pData = new RooDataSet("data", "data", *pFitVar);
	
	cout << "Loading data" << endl;
	
	if(InitChain(pChain)) return 1;	
	pChain->SetBranchStatus("*", 0);
	bp.Connect(pChain, branchName.c_str());
	nEntries = pChain->GetEntries();
	
	for(Long64_t i=0; i<nEntries; ++i)
	{
		pChain->GetEntry(i);
		if(!range.In(bp)) continue;
		*pFitVar = bp;
		pData->add(*pFitVar);
	}
	
	delete pChain;
	
	return 0;
}
开发者ID:Burney222,项目名称:Master-Make-Based,代码行数:28,代码来源:Fitter.cpp

示例6: GetDataPhiStar

TH1D* GetDataPhiStar() {
    cout << "reading data" << endl;
    vector<std::string> File_Data = Get_File_Data();
    TH1D* h_phistar = new TH1D("phistar", "phistar", nphistar, phistarBins);
    //TH1D *h_phistar= new TH1D("phistar","phistar",160,50,130);
    h_phistar->Sumw2();
    TChain* t = new TChain(reco_name.c_str(), reco_name.c_str());
    int nfiles;
    for (int i = 0; i < File_Data.size(); i++) {
        nfiles = t->Add(File_Data[i].c_str());
    }
    TBranch* b_reco = t->GetBranch("reco");
    TLeaf* l_m = b_reco->GetLeaf("z_m");
    TLeaf* l_phistar = b_reco->GetLeaf("z_phistar_dressed");
    TLeaf* l_e0_q = b_reco->GetLeaf("e_charge0");
    TLeaf* l_e1_q = b_reco->GetLeaf("e_charge1");
    cout << "Entries: " << t->GetEntries() << endl;
    for (int i = 0; i < t->GetEntries(); i++) {
        t->GetEntry(i);
        double E0_q = l_e0_q->GetValue();
        double E1_q = l_e1_q->GetValue();
        //if (E0_q!=E1_q) continue;
        h_phistar->Fill(l_phistar->GetValue(), 1);
        //h_phistar->Fill(l_m->GetValue(),1);
    }
    cout << "filled data phistar histogram" << endl;
    return h_phistar;
}
开发者ID:Spudmeister,项目名称:tuningAna,代码行数:28,代码来源:NTupleSS.C

示例7: AssembleSingleFile

void AssembleSingleFile(std::string FileList, std::string BaseDirectory, std::string OutputName)
{
  
  TFile *f = TFile::Open(OutputName.c_str(),"RECREATE");
  TChain * ch = CreateChainFromList_opt(FileList.c_str(),BaseDirectory.c_str(),"pmtresponse/PhotonLibraryData",false);
  
  Int_t Voxel, OpChannel;
  Float_t Visibility;
  ch->SetBranchAddress("Voxel",      &Voxel);
  ch->SetBranchAddress("OpChannel",  &OpChannel);
  ch->SetBranchAddress("Visibility", &Visibility);

  TTree * tt = new TTree("PhotonLibraryData","PhotonLibraryData");
  tt->Branch("Voxel",      &Voxel,      "Voxel/I");
  tt->Branch("OpChannel",  &OpChannel,  "OpChannel/I");
  tt->Branch("Visibility", &Visibility, "Visibility/F");
  
  for(int i=0; i!=ch->GetEntries(); ++i)
    {
      ch->GetEntry(i);
      tt->Fill();
    }
  
  f->Write();
  f->Close();
}
开发者ID:gartung,项目名称:larsim,代码行数:26,代码来源:AssembleSingleFile.C

示例8: GetBGPhiStar

TH1D* GetBGPhiStar(std::string FileName, double sampleweight) {
    TH1D* phistartemp = new TH1D("phistar", "phistar", nphistar, phistarBins);
    //TH1D *phistartemp= new TH1D("phistar","phistar",160,50,130);
    phistartemp->Sumw2();

    gErrorIgnoreLevel = kError;
    cout << "reading data for " << FileName << endl;
    TChain* t = new TChain(reco_name.c_str(), reco_name.c_str());
    int nfiles;
    nfiles = t->Add(FileName.c_str());

    TBranch* b_reco = t->GetBranch("reco");
    TLeaf* l_phistar = b_reco->GetLeaf("z_phistar_dressed");
    TLeaf* l_m = b_reco->GetLeaf("z_m");
    TLeaf* l_e0_q = b_reco->GetLeaf("e_charge0");
    TLeaf* l_e1_q = b_reco->GetLeaf("e_charge1");
    int nweights;
    t->SetBranchAddress("weight_size", &nweights);
    t->GetEntry(0);
    cout << "The sample has nweights: " << nweights << endl;
    double weights[nweights];
    int weightid[nweights];
    t->SetBranchAddress("weights", &weights);
    t->SetBranchAddress("weight_ids", &weightid);

    cout << "reading data for " << FileName << endl;
    cout << "Entries: " << t->GetEntries() << endl;
    for (int i = 0; i < t->GetEntries(); i++) {
        t->GetEntry(i);
        double E0_q = l_e0_q->GetValue();
        double E1_q = l_e1_q->GetValue();
        //cout<<E0_q<<" "<<E1_q<<endl;
        //if (E0_q!=E1_q) continue;
        double phistar = l_phistar->GetValue();
        double weight = sampleweight;
        for (int w = 0; w < nweights; w++) {
            if (weightid[w] == 1 || weightid[w] == 2 || weightid[w] == 12
                    || weightid[w] == 13 || weightid[w] == 20 || weightid[w] == 30) {
                weight = weight * weights[w];
            }
        }
        phistartemp->Fill(phistar, weight);
        //phistartemp->Fill(l_m->GetValue(),weight);
    }
    cout << "done reading data for " << FileName << endl;
    return phistartemp;
}
开发者ID:Spudmeister,项目名称:tuningAna,代码行数:47,代码来源:NTupleSS.C

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

示例10: drawPtSpectrum

void drawPtSpectrum() {

  TStyle *simpleStyle = new TStyle("simpleStyle","");
  simpleStyle->SetCanvasColor(0);
  simpleStyle->SetFrameFillColor(0);
  simpleStyle->SetStatColor(0);
  simpleStyle->SetOptStat(0);
  simpleStyle->SetTitleFillColor(0);
  simpleStyle->SetCanvasBorderMode(0);
  simpleStyle->SetPadBorderMode(0);
  simpleStyle->SetFrameBorderMode(0);
  simpleStyle->cd();

  TChain* chain = new TChain("jetTree");

  chain->Add("2ndLevelOutputFile_PhotonJet15.root");
  chain->Add("2ndLevelOutputFile_PhotonJet30.root");
  chain->Add("2ndLevelOutputFile_PhotonJet80.root");
  chain->Add("2ndLevelOutputFile_PhotonJet170.root");
  chain->Add("2ndLevelOutputFile_PhotonJet300.root");
  chain->Add("2ndLevelOutputFile_PhotonJet470.root");
  chain->Add("2ndLevelOutputFile_PhotonJet800.root");

  Float_t eventWeight;
  chain->SetBranchAddress("eventWeight", &eventWeight);

  Float_t ptHat;
  chain->SetBranchAddress("ptHat", &ptHat);

  TH1F* h1_ptSpectrum = new TH1F("ptSpectrum", "", 100, 0., 1000.);
  h1_ptSpectrum->SetXTitle("#hat{p}_{T} [GeV/c]");
  h1_ptSpectrum->SetMarkerStyle(20);
  h1_ptSpectrum->SetMarkerSize(1.4);



  Int_t nEntries = chain->GetEntries();


  for( Int_t iEntry = 0; iEntry<nEntries; ++iEntry) {
 
    if( (iEntry%100000) == 0 ) std::cout << "Entry: " << iEntry << "/" << nEntries << std::endl;
    chain->GetEntry(iEntry);

    h1_ptSpectrum->Fill(ptHat, eventWeight);

  }

  TCanvas* c1 = new TCanvas("c1", "c1", 800, 600);
  c1->cd();
  c1->SetLogy();
  h1_ptSpectrum->Draw("P");
  c1->SaveAs("ptSpectrum.eps");

}
开发者ID:amarini,项目名称:pandolf,代码行数:55,代码来源:drawPtSpectrum.C

示例11: selectevents

long selectevents(const TString &fileName) {
    TChain* chain = new TChain("MVATree");
    if( fileName.EndsWith(".root") ) {
        chain->Add(fileName);
    }

    int N_Jets;
    chain->SetBranchAddress("N_Jets",&N_Jets);
    float* Jet_Pt = new float[120];
    chain->SetBranchAddress("Jet_Pt",Jet_Pt);
    float* Jet_Phi = new float[120];
    chain->SetBranchAddress("Jet_Phi",Jet_Phi);
    float DeltaPhi;
    chain->SetBranchAddress("DeltaPhi",&DeltaPhi);
    float PtAve;
    chain->SetBranchAddress("PtAve",&PtAve);
    float* Jet_Eta = new float[120];
    chain->SetBranchAddress("Jet_Eta",Jet_Eta);
    float* Jet_CSV = new float[120];
    chain->SetBranchAddress("Jet_CSV",Jet_CSV);
    float* Jet_HadFlav = new float[120];
    chain->SetBranchAddress("Jet_HadronFlav",Jet_HadFlav);
    float* Jet_PartFlav = new float[120];
    chain->SetBranchAddress("Jet_PartonFlav",Jet_PartFlav);
    float Weight_XS;
    chain->SetBranchAddress("Weight_XS",&Weight_XS);

    long nentries=0;
    long n_selected=0;
    float dphicut=2.7;
    float pt3cut=0.1;
    float etamin=2.1;

    nentries = chain->GetEntries();
    cout <<"counting events in "<< fileName << endl;
    cout << "total number of MC events: " << nentries << endl;
    for (long iEntry=0; iEntry<nentries; iEntry++) {
        if(iEntry%100000==0) cout << "analyzing event " << iEntry << endl;
//     if(iEntry>1000000) break;
        chain->GetEntry(iEntry);
        double ptave=PtAve;
        if(N_Jets >=2) {
            if (DeltaPhi> dphicut ) {
                if (abs(Jet_Eta[0])<etamin && abs(Jet_Eta[1])<etamin) {
                    if (N_Jets >=3) {
                        if (Jet_Pt[2]/ptave < pt3cut) n_selected++;
                    }
                    else if (N_Jets==2) n_selected++;
                }
            }
        }
    }
    cout << n_selected<< " Events selected" << endl;
    return n_selected;
}
开发者ID:sebwieland,项目名称:qcd_dijets,代码行数:55,代码来源:yieldstudy.C

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

示例13: Master_test

void Master_test( ){//main programme
    TChain* t = new TChain("rd51tbgeo");
    t->Add("../CRC-Run0308_Muon_10k_MSPL4_HVScan_710pt7_710pt1_710pt0_T20_T20_T20_Lat21-141010_224141-0.root");
    
    ClassReadTree CRC(t);

    TCanvas * c1 = new TCanvas("c1","",1);
    TGraphErrors *gr1 = new TGraphErrors(t->GetEntries());
    TGraphErrors *gr2 = new TGraphErrors(t->GetEntries());
    TGraphErrors *gr3 = new TGraphErrors(t->GetEntries());

    //for( int iEv = 0 ; iEv < t->GetEntries() ; iEv++){//
    for( int iEv = 0 ; iEv < 8 ; iEv++){//	Event Loop Starts
	t->GetEntry(iEv);

	//cout<<"===>  "<<CRC.g1xcl_geoposX[0]<<endl;
	//cout<<"===>  "<<CRC.g2xcl_geoposX[0]<<endl;
	//cout<<"===>  "<<CRC.g3xcl_geoposX[0]<<endl;
	if (CRC.g1xcl_geoposX[0]>0)
	    gr1->SetPoint(iEv*3, 100, CRC.g1xcl_geoposX[0]);
//	else
//	    gr1->SetPoint(iEv*3, 100, -10);
	if (CRC.g2xcl_geoposX[0]>0)
	    gr1->SetPoint(iEv*3+1, 380, CRC.g2xcl_geoposX[0]);
//	else
//	    gr1->SetPoint(iEv*3+1, 380, -10);
	if (CRC.g3xcl_geoposX[0]>0)
	    gr1->SetPoint(iEv*3+2, 830, CRC.g3xcl_geoposX[0]);
//	else
//	    gr1->SetPoint(iEv*3+2, 830, -10);

	
    }// End Event Loop
    gr1->SetMarkerColor(kBlue);
    gr1->SetMarkerStyle(21);
    gr2->SetMarkerColor(kRed);
    gr2->SetMarkerStyle(21);
    gr3->SetMarkerColor(kGreen);
    gr3->SetMarkerStyle(21);
    gr1->GetXaxis()->SetRangeUser(50., 900.);
    gr2->GetXaxis()->SetRangeUser(50., 900.);
    gr3->GetXaxis()->SetRangeUser(50., 900.);
    gr1->Draw("AP");
    //gr3->Draw("AP");
    //gr2->Draw("samesP*");
    //gr3->Draw("samesP*");
    TMultiGraph *mg = new TMultiGraph();
    mg->Add(gr1);
    mg->Add(gr2);
    mg->Add(gr3);
    //mg->Draw("APL");
    c1->SaveAs("Hit_Distribution.pdf");
}
开发者ID:ram1123,项目名称:TestBeamGeneralMacro,代码行数:53,代码来源:Master_test.C

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

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


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