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


C++ TH1D::GetEntries方法代码示例

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


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

示例1: processFile

TH1* processFile(TString fname, double scaleFactor){

  static int hcounter=0;

  cout<<"Doing fname="<<fname<<endl;
  TFile *_file2 = TFile::Open(fname);
  PS->cd();
  TString plot =  "lLV[0].lpfIso:lLV[0].fP.Eta()";
  TString hname = Form("h%i",hcounter);
  jets2p->Draw(plot +" >> " + hname+"(24,-3,3,100,0,2)","","qn");
  TH2D *aux = (TH2D*)gDirectory->Get(hname);
  //aux->Scale(scaleFactor);
  TH1D * ss = aux->ProjectionX(hname+"ss",1,10); // signal region 
  TH1D * ni = aux->ProjectionX(hname+"ni",16,100);// nonIso region (use 11
  //cout<<"h="<<hcounter<<" ss="<<ss->GetEntries()<<" ni="<<ni->GetEntries()<<endl;

  TString statis = Form("( %i / %i )",(int)ss->GetEntries(),(int)ni->GetEntries());
  ss->Divide(ni);
  ss->GetYaxis()->SetTitle(TString("N_{signal}/N_{nonIso}")+statis);
  ss->GetXaxis()->SetTitle("#eta");
  
  hcounter++;

  return ss;

}
开发者ID:aperloff,项目名称:TAMUWW,代码行数:26,代码来源:QCD_MC_test.C

示例2: Terminate

  /** 
   * End of job processing 
   */
  void Terminate(Option_t*)
  {
    fList = dynamic_cast<TList*>(GetOutputData(1));
    if (!fList) {
      AliError(Form("No output list defined (%p)", GetOutputData(1)));
      if (GetOutputData(1)) GetOutputData(1)->Print();
      return;
    }


    TList* output = new TList;
    output->SetName("triggerResults");
    output->SetOwner();

    fVertexMC = static_cast<TH1D*>(fList->FindObject("vertexMC"));
    fVertexESD = static_cast<TH1D*>(fList->FindObject("vertexESD"));
    fM         = static_cast<TH1D*>(fList->FindObject("m"));
    if (fVertexMC) { 
      TH1D* vtxMC = static_cast<TH1D*>(fVertexMC->Clone("vertexMC"));
      vtxMC->SetDirectory(0);
      if (vtxMC->GetEntries() > 0)
	vtxMC->Scale(1. / vtxMC->GetEntries());
      else 
	vtxMC->Scale(0);
      output->Add(vtxMC);
    }
    if (fVertexESD) { 
      TH1D* vtxESD = static_cast<TH1D*>(fVertexESD->Clone("vertexESD"));
      vtxESD->SetDirectory(0);
      if (vtxESD->GetEntries() > 0)
	vtxESD->Scale(1. / vtxESD->GetEntries());
      else 
	vtxESD->Scale(0);
      output->Add(vtxESD);
    }
    if (fM) { 
      TH1D* m = static_cast<TH1D*>(fM->Clone("m"));
      m->SetDirectory(0);
      m->SetYTitle("P(N_{ch}|_{|#eta|<1} < X)");
      if (m->GetBinContent(1) > 0)
	m->Scale(1. / m->GetBinContent(1));
      else 
	m->Scale(0);
      output->Add(m);
    }      

    TString vtxReq;
    if (fVertexRequirement & kMC)  vtxReq.Append("MC ");
    if (fVertexRequirement & kESD) vtxReq.Append("ESD ");
    output->Add(new TNamed("vtxReq", vtxReq.Data()));
    output->Add(new TNamed("trkReq",
			   fTrackletRequirement == kMC ? "MC" : "ESD"));

    fInel.Finish(fList, output);
    fInelGt0.Finish(fList, output);
    fNSD.Finish(fList, output);
    fNClusterGt0.Finish(fList, output);

    PostData(2, output);
  }
开发者ID:ktf,项目名称:AliPhysics,代码行数:63,代码来源:MakeEvaluateTriggers.C

示例3: testFile

int testFile(TString fileName){
	TFile *fd = TFile::Open(fileName);

	TH1D* cuts = (TH1D*)fd->Get("Cuts");
	TH1D* x = (TH1D*)fd->Get("xDistrib");
	cout << (int)cuts->GetEntries() << ":" << (int)x->GetEntries() << endl;

	return 0;
}
开发者ID:nlurkin,项目名称:Other,代码行数:9,代码来源:testFile.C

示例4: setNumbersInSamplesInfo

void setNumbersInSamplesInfo(SamplesInfo& s, string histNameEta, string histHt){
	std::map<string, double>::iterator it = s.Xsections.begin();
	for(; it != s.Xsections.end(); it++){
		TFile* f = TFile::Open(string("Wshape/Wshape_"+it->first+"_plots.root").c_str());
		TH1D * h = (TH1D*)f->Get(histNameEta.c_str());
		s.NFwdEta[it->first] = h->GetEntries();
		h = (TH1D*)f->Get(histHt.c_str());
		s.NHt[it->first] = h->GetEntries();
	}
}
开发者ID:nadjieh,项目名称:work,代码行数:10,代码来源:Plotter.C

示例5: testIntegration

void testIntegration(){
	
	
	
	TFile* infile = new TFile("/Users/keithlandry/Desktop/testPtHist.root");

	TH1D * h = infile->Get("Pt");
	
	
	int bmin = 751;
	int bmax = bmin+1;
	
  double binval = 0;
	int numberOfPairs = 0;
	
	cout << "starting at bmin = " << bmin << "  bmax = " << bmax << endl;
	
	cout << (double)h->GetEntries()/9.0 << endl;
	
	for (int i=0; i < h->GetNbinsX()-bmin; i++)
	{
		bmax++;

		cout << " i = " << i << " bmax = " << bmax << endl;
		
		int integ = h->Integral(bmin,bmax);
		
		cout << bmax << "   " << integ << endl;
		
		binval += h->GetBinContent(bmax)*h->GetBinCenter(bmax);
		numberOfPairs += h->GetBinContent(bmax);

		if (integ > (double)h->GetEntries()/9.0)
		{
			cout << bmax << "   " << integ << endl;
			lastI = i;
			break;
		}
		
		if (bmax == 1000)
		{
			break;
		}
		
		
	}
	
	
	cout << "avg val of bin " << (double)binval/numberOfPairs << endl;
	
	cout << " Pt = " << h->GetBinCenter(bmax) << endl;
	
	
	
}
开发者ID:keithdlandry,项目名称:2012IFF,代码行数:55,代码来源:testIntegration.C

示例6: calcAcceptance

void calcAcceptance(TFile *f, TString chan, Int_t n, vector<Double_t> &scale, TString sname) {
  char hname[100];
  
  for (Int_t i=0; i<n; i++) {
    Bool_t prnt = kFALSE;
    if (sname=="MMHT2014nlo68cl" && i==0) prnt = kTRUE;
    //cout << sname << ", i = " << i << endl;

    if (prnt) cout << chan << " ";
    sprintf(hname, "dTot_%s_%i", sname.Data(), i);
    TH1D *tot = (TH1D*) f->Get(hname);
    Double_t s = tot->Integral()/tot->GetEntries();

    Double_t accept;
    if (chan=="wmm" || chan=="wme" || chan=="wpe" || chan=="wpm") {
      sprintf(hname, "dPostB_%s_%i", sname.Data(), i);
      TH1D *bar = (TH1D*) f->Get(hname);
      accept=bar->Integral()/(tot->Integral());
      //cout << "Barrel Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      sprintf(hname, "dPostE_%s_%i", sname.Data(), i);
      TH1D *end = (TH1D*) f->Get(hname);
      accept=end->Integral()/(tot->Integral());
      //cout << "Endcap Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      accept=(bar->Integral()+end->Integral())/(tot->Integral());
    }
    else if (chan=="zmm" || chan=="zee") {
      sprintf(hname, "dPostBB_%s_%i", sname.Data(), i);
      TH1D *bb = (TH1D*) f->Get(hname);
      accept=bb->Integral()/(tot->Integral());
      //cout << "Bar-bar Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      sprintf(hname, "dPostBE_%s_%i", sname.Data(), i);
      TH1D *be = (TH1D*) f->Get(hname);
      accept=be->Integral()/(tot->Integral());
      //cout << "Bar-end Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      sprintf(hname, "dPostEE_%s_%i", sname.Data(), i);
      TH1D *ee = (TH1D*) f->Get(hname);
      accept=ee->Integral()/(tot->Integral());
      //cout << "End-end Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      accept=(bb->Integral()+be->Integral()+ee->Integral())/(tot->Integral());
    }
    if (prnt) cout << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

    //cout << "Scale: " << tot->Integral()/tot->GetEntries() << endl;

    //scale.push_back(s);
    scale.push_back(accept);
  }
}
开发者ID:cmedlock,项目名称:MitEwk13TeV,代码行数:53,代码来源:getMMHT2014uncertainties.C

示例7: FitCosTheta

  /*--------------------------------------------*/
 void FitCosTheta()
 /*--------------------------------------------*/
 {

//TH1F *brgauss = new TH1F("breitg","", 131, 0, 130);
TFile * file = new TFile("cosTheta_allnadjieh.root","READ");
 TH1D * h = (TH1D*)file->Get("cosThetaGen");
//h->Scale(1./h->Integral());

 h->Sumw2();
/*TFile * file= new TFile("WPol_SelectedTTBars.root","read");
TH1D* h = (TH1D*)file->Get("costheta_mm/hCosThetaPosLepton_Gen");*/
h->Rebin(10);
//h->Scale(1./h->Integral());
 TF1 *f = new TF1("f",cosTheta, -1, 1 ,3);
 Double_t par[3];
 par[0] = 1;
 par[1] = 1;
 par[2] = h->GetEntries();
 


 f->SetParameters(par);
 
 h->Fit(f, "RBO");
 h->Fit(f, "RBO");
 h->Fit(f, "RBO");
 h->Fit(f, "RBO");
 h->Fit(f, "RBO");

 }
开发者ID:nadjieh,项目名称:work,代码行数:32,代码来源:FitFunc.C

示例8: smartGausProfileXSQRTN

TH1D * smartGausProfileXSQRTN (TH2F * strip, double width){
 TProfile * stripProfile = strip->ProfileX () ;
 
 // (from FitSlices of TH2.h)
 
 double xmin = stripProfile->GetXaxis ()->GetXmin () ;
 double xmax = stripProfile->GetXaxis ()->GetXmax () ;
 int profileBins = stripProfile->GetNbinsX () ;
 
 std::string name = strip->GetName () ;
 name += "_smartGaus_X" ; 
 TH1D * prof = new TH1D(name.c_str (),strip->GetTitle (),profileBins,xmin,xmax) ;
 
 int cut = 0 ; // minimum number of entries per fitted bin
 int nbins = strip->GetXaxis ()->GetNbins () ;
 int binmin = 1 ;
 int ngroup = 1 ; // bins per step
 int binmax = nbins ;
 
 // loop over the strip bins
 for (int bin=binmin ; bin<=binmax ; bin += ngroup) 
 {
  TH1D *hpy = strip->ProjectionY ("_temp",bin,bin+ngroup-1,"e") ;
  if (hpy == 0) continue ;
  int nentries = Int_t (hpy->GetEntries ()) ;
  if (nentries == 0 || nentries < cut) {delete hpy ; continue ;} 
  
  Int_t biny = bin + ngroup/2 ;
  
  TF1 * gaussian = new TF1 ("gaussian","gaus", hpy->GetMean () - width * hpy->GetRMS (), hpy->GetMean () + width * hpy->GetRMS ()) ; 
  gaussian->SetParameter (1,hpy->GetMean ()) ;
  gaussian->SetParameter (2,hpy->GetRMS ()) ;
  hpy->Fit ("gaussian","RQL") ;           
  
  //       hpy->GetXaxis ()->SetRangeUser ( hpy->GetMean () - width * hpy->GetRMS (), hpy->GetMean () + width * hpy->GetRMS ()) ;         
  prof->Fill (strip->GetXaxis ()->GetBinCenter (biny), gaussian->GetParameter (1)) ;       
  prof->SetBinError (biny,gaussian->GetParameter (2) / sqrt(hpy->GetEntries())) ;
//   prof->SetBinError (biny,gaussian->GetParError (1)) ;
  
  delete gaussian ;
  delete hpy ;
 } // loop over the bins
 
 delete stripProfile ;
 return prof ;
}
开发者ID:amassiro,项目名称:usercode,代码行数:46,代码来源:EE_EnScale.cpp

示例9: pixelVariationLowRange

void pixelVariationLowRange(const char *filenameOld = "../rootFiles/LRLScanOldSettings.root", const char *filenameNew = "../rootFiles/LRLScanNewSettings.root", const char *filenameMedium = "../rootFiles/LRLScanOldSettings.root")
{

    TFile *f1 = new TFile(filenameOld);
    TFile *f2 = new TFile(filenameNew);
    TFile *f3 = new TFile(filenameMedium);

    Init();
        
    TLegend *legend = new TLegend(0.65,0.6,0.95,0.95);

    cout << "test" << endl;

    color = 4;
    TH1D *oldSettings = Analysis(f1);
    color = 1;
    TH1D *newSettings = Analysis(f2);
    color = 2;
    TH1D *mediumSettings = Analysis(f3);

    cout << "Entries old settings = " << oldSettings->GetEntries() << endl;
    cout << "Entries medium settings = " << mediumSettings->GetEntries() << endl;
    cout << "Entries new settings = " << newSettings->GetEntries() << endl;

    legend->AddEntry(oldSettings,"oldSettings","L");
    legend->AddEntry(mediumSettings,"mediumSettings","L");
    legend->AddEntry(newSettings,"newSettings","L");

    newSettings->GetYaxis()->SetTitleOffset(1.2);

    canvas->Clear();
    newSettings->Draw();
    oldSettings->Draw("same");
    mediumSettings->Draw("same");

    legend->Draw();    
    
    canvas->SaveAs("aoverb.png");
    canvas->SaveAs("aoverb.root");
}
开发者ID:chwissing,项目名称:psi46expert,代码行数:40,代码来源:pixelVariationLowRange.C

示例10: calcAcceptance

void calcAcceptance(TFile *f, TString chan, Int_t as, Int_t n, vector<Double_t> &scale) {
  char hname[100];
  
  for (Int_t i=0; i<n; i++) {

    Bool_t prnt=kTRUE;
    if (as==18 && i==0) cout << "Nominal ";
    if (prnt) cout << "A (" << chan << "): ";

    sprintf(hname, "dTot_NNPDF30_nlo_as_01%i_%i", as, i);
    TH1D *tot = (TH1D*) f->Get(hname);

    Double_t accept;
    if (chan=="wmm" || chan=="wme" || chan=="wpe" || chan=="wpm") {
      sprintf(hname, "dPostB_NNPDF30_nlo_as_01%i_%i", as, i);
      TH1D *bar = (TH1D*) f->Get(hname);
      accept=bar->Integral()/(tot->Integral());
      //if (prnt) cout << "Barrel Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      sprintf(hname, "dPostE_NNPDF30_nlo_as_01%i_%i", as, i);
      TH1D *end = (TH1D*) f->Get(hname);
      accept=end->Integral()/(tot->Integral());
      //if (prnt) cout << "Endcap Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      accept=(bar->Integral()+end->Integral())/(tot->Integral());
    }
    else if (chan=="zmm" || chan=="zee") {
      sprintf(hname, "dPostBB_NNPDF30_nlo_as_01%i_%i", as, i);
      TH1D *bb = (TH1D*) f->Get(hname);
      accept=bb->Integral()/(tot->Integral());
      //if (prnt) cout << "Bar-bar Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      sprintf(hname, "dPostBE_NNPDF30_nlo_as_01%i_%i", as, i);
      TH1D *be = (TH1D*) f->Get(hname);
      accept=be->Integral()/(tot->Integral());
      //if (prnt) cout << "Bar-end Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      sprintf(hname, "dPostEE_NNPDF30_nlo_as_01%i_%i", as, i);
      TH1D *ee = (TH1D*) f->Get(hname);
      accept=ee->Integral()/(tot->Integral());
      //if (prnt) cout << "End-end Acceptance: " << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

      accept=(bb->Integral()+be->Integral()+ee->Integral())/(tot->Integral());
    }
    if (prnt) cout << accept << " +/- " << sqrt(accept*(1-accept)/tot->GetEntries()) << endl;

    scale.push_back(accept);
  }
}
开发者ID:kfiekas,项目名称:MitEwk13TeV,代码行数:49,代码来源:getNNPDF30uncertainties.C

示例11: checkdead

void checkdead(const char *run="19020_19035") {
  TString inname;
  TFile *file;
  TH1D *out;
  for(int arm=0; arm!=2; ++arm)
    for(int lyr=0; lyr!=8; ++lyr)
      for(int sen=0; sen!=24; ++sen)
	for(int mpd=0; mpd!=128; ++mpd) {
	  inname = Form("%s/adc/HI_ARM%d_LYR%d_S%d_M%d.root",run,arm,lyr,sen,mpd);
	  file = TFile::Open( inname.Data() );
	  out = (TH1D*) file->Get("out");
	  if(out->GetEntries()==0) printf("%d %d %d %d\n",arm,lyr,sen,mpd);
	  file->Close();
	}
  return;
}
开发者ID:carlosperezlara,项目名称:FitLandaus,代码行数:16,代码来源:checkdead.C

示例12: AdjustDensityForBinWidth

void AdjustDensityForBinWidth(TH1D &h) {
    double entries = h.GetEntries();
    int nbins = h.GetNbinsX();
    double low = h.GetBinLowEdge(1);
    double high = h.GetBinLowEdge(nbins+1);
    double width = (high-low)/nbins;
    for(int bin = 1; bin <= nbins; ++bin) {
        double content = h.GetBinContent(bin);
        double error = h.GetBinError(bin);
        double this_width = h.GetBinWidth(bin);
        double scale = width/this_width;
        h.SetBinContent(bin, content*scale);
        h.SetBinError(bin, error*scale);
    }
    h.SetEntries(entries);
}
开发者ID:ald77,项目名称:ra4_draw,代码行数:16,代码来源:utilities.cpp

示例13: getInputValues

inputValues getInputValues(TString fileName, double pw, string cutString) {

    TFile * file = new TFile(fileName, "READ");
    TTree * tree = (TTree*)file->Get("Channel_1");
    tree->Draw("(-1)*Min>>hist(300, 0, 30)");
    TH1D * hist = (TH1D*)gDirectory->Get("hist");
    
    inputValues inVal;
    
    inVal.pw = pw;
    inVal.n = hist->GetEntries();
    inVal.v = pow(hist->GetStdDev(), 2);
    inVal.e = hist->GetMean(); 
    inVal.a = tree->Draw("Min", (TString)cutString);
    inVal.h = hist;
    
    return inVal;
}
开发者ID:btcardwell,项目名称:milliqAnalysis,代码行数:18,代码来源:singlePeCalMin.cpp

示例14: addPolarizationHists

void addPolarizationHists(){
	
	
	

	TFile* infile = new TFile("/star/u/klandry/ucladisk/2012IFF/results_5_19/5_19Full.root");
	
	
	TH1D* polHist = new TH1D("polHist","polHist",25,0,1);
	
	
	
	for (int i=0; i<5; i++)
	{
		for (int j=0; j<32; j++)
		{
			
			char name[50];
			sprintf(name, "hPolOfBin_Ptbin_%d_phiSRbin_%d",i,j);
			
			cout << name << endl;
			
			TH1D* tempHist = infile->Get(name);
			
			cout << tempHist->GetEntries() << endl;
			
			polHist->Add(tempHist, 1);
			
			
		}
	}
	
	
	
	polHist->Draw();
	
	
	
	
	
	
}
开发者ID:keithdlandry,项目名称:2012IFF,代码行数:42,代码来源:addPolarizationHists.C

示例15: GetTotalEvents

int GetTotalEvents(TChain *chain) {

  int numevents = 0;

  TObjArray *files = chain->GetListOfFiles();
  for (int i=0; i<files->GetEntries(); ++i) {    
    TFile *file = TFile::Open(files->At(i)->GetTitle(),"READ");

    TDirectory *fwkdir = (TDirectory*)file->FindObjectAny("AnaFwkMod");
    TH1D *hevents = (TH1D*)fwkdir->Get("hDAllEvents");

    numevents += hevents->GetEntries();

    file->Close();

  }

  return numevents;

}
开发者ID:michelif,项目名称:usercode,代码行数:20,代码来源:trainElectronEnergyRegression_ECAL.C


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