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


C++ TH1::IntegralAndError方法代码示例

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


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

示例1: fill_data

void fill_data(double e_min, double e_max, int mask)
{
	const char name_pattern[] = "danss_report_v4n-sect%d-calc.root";
	const char pos[3][20] = {"hUp_%d", "hMid_%d", "hDown_%d"};
	char fname[1024];
	char cpos[32];
	int i, j;
	TFile *f;
	TH1* h;
	double val, err;
	
	for (i=0; i<3; i++) {
		sprintf(fname, name_pattern, 3-i);
		f = new TFile(fname);
		if (!f->IsOpen()) return;
		for (j=0; j<3; j++) {
			sprintf(cpos, pos[j], mask);
			h = (TH1*) f->Get(cpos);
			if (!h) {
				printf("Something is wrong: %d %d %s.\n", i, j, cpos);
				return;
			}
			val = h->IntegralAndError(h->FindBin(e_min), h->FindBin(e_max), err);
			DataArray.cnt[3*i+j] = val;
			DataArray.ecnt[3*i+j] = err;
			printf("%d %d %f +- %f\n", i, j, val, err);
		}
		f->Close();
	}
}
开发者ID:lab305itep,项目名称:digi,代码行数:30,代码来源:draw_R2m.C

示例2: setDisplayQuantitiesForHist

void RDK2AnalysisPlotter::drawPlotDets(CoDet detType, PlotVarType plotVarType)
{
    gROOT->cd();

    int numDets;

    TString histTitleString;
    if(detType == DET_EPG)
    {
        numDets=12;
        histTitleString="Individual BGO Detectors;Detector Number;% Difference From Mean";
    }
    else
    {
        numDets=3;
        histTitleString="Individual BAPD Detectors;Detector Number;% Difference From Mean";
    }
    const int numHists=numExp+numMC;
    TH1* tempHist;
    double integral;
    double error;

    TH1** detsHists=new TH1*[numHists];
    TString histName;
    double max=-REALLY_BIG_DBL;
    double min=REALLY_BIG_DBL;

    for (int i = 0;i< numHists;i++)  //Set loop (either exp or mc)
    {
        histName="hist"+int2str(plotHists.size());
        detsHists[i]=new TH1D(histName,histTitleString,numDets,.5,numDets+.5);
        detsHists[i]->Sumw2();
        plotHists.push_back(detsHists[i]);

        for (int j = 0;j< numDets;j++)
        {
            if(i<numExp)
            {
                tempHist=getExpHist( i, detType, plotVarType,j+1);
            }
            else
            {
                tempHist=getMCHist( i-numExp, detType, plotVarType,j+1);
            }
            if(tempHist != nullptr)
            {
                integral = tempHist->IntegralAndError(1,tempHist->GetNbinsX(),error);
                detsHists[i]->SetBinContent(j+1,integral);
                detsHists[i]->SetBinError(j+1,error);
            }
        }

        if(i<numExp)
            setDisplayQuantitiesForHist(i,1,detsHists[i],detType,PLOT_DETS,plotVarType);
        else
            setDisplayQuantitiesForHist(-(i-numExp)-1,1,detsHists[i],detType,PLOT_DETS,plotVarType);

        double mean=detsHists[i]->Integral()/numDets; // Mean for the set
        detsHists[i]->Scale(100./mean);
        for (int j = 0;j< numDets;j++)
        {
            detsHists[i]->SetBinContent(j+1,detsHists[i]->GetBinContent(j+1)-100. );
        }
        if(detsHists[i]->GetMaximum() > max)
            max=detsHists[i]->GetMaximum()+detsHists[i]->GetBinError(detsHists[i]->GetMaximumBin());
        if(detsHists[i]->GetMinimum() < min)
            min=detsHists[i]->GetMinimum()-detsHists[i]->GetBinError(detsHists[i]->GetMinimumBin());
    }

    detsHists[0]->GetYaxis()->SetRangeUser(min-.05*abs(min),max+.05*abs(max));
    drawHist(numHists, detsHists, 0, nullptr);
    delete[] detsHists;

}
开发者ID:mjbales,项目名称:rdk2analysis,代码行数:74,代码来源:RDK2AnalysisPlotter.cpp

示例3: EMuSigEff

void EMuSigEff() {

    vector <int> masses;
    masses.push_back(40);
    masses.push_back(50);
    masses.push_back(60);
    masses.push_back(70);
    masses.push_back(80);
    masses.push_back(90);
    masses.push_back(100);
    masses.push_back(125);
    masses.push_back(150);
    masses.push_back(175);
    masses.push_back(200);
    masses.push_back(250);
    masses.push_back(300);
    masses.push_back(350);
    masses.push_back(400);
    masses.push_back(500);

    vector <TString> smasses;
    smasses.push_back("40");
    smasses.push_back("50");
    smasses.push_back("60");
    smasses.push_back("70");
    smasses.push_back("80");
    smasses.push_back("90");
    smasses.push_back("100");
    smasses.push_back("125");
    smasses.push_back("150");
    smasses.push_back("175");
    smasses.push_back("200");
    smasses.push_back("250");
    smasses.push_back("300");
    smasses.push_back("350");
    smasses.push_back("400");
    smasses.push_back("500");


    for(unsigned int i = 0 ; i < masses.size(); ++i) {

        TString im = smasses.at(i);

        TFile * file1 = new TFile(("/home/jalmond/HeavyNeutrino/Analysis/LQanalyzer/data/output/SSElectronMuon/HNEMu_SKHNmue" + im + "_nocut_5_3_14.root").Data());
        TFile * file2 = new TFile(("/home/jalmond/HeavyNeutrino/Analysis/LQanalyzer/data/output/SSElectronMuon/HNEMu_SKHNemu" + im + "_nocut_5_3_14.root").Data());

        TString cut = "SS_highmass_exc";// + im;
        //cut = "SS_highmass";
        //    if(i < 5) cut = "SS_lowmass_" + im;
        //if(i < 5) cut = "SS_lowmass_80_2";
        TString hist = (cut + "/h_Nelectrons_"+cut);

        TH1* hnsig =   (TH1F*)file1->Get(("CutFlow/_eventcutflow"));

        TH1* hnsig2 =   (TH1F*)file2->Get(("CutFlow/_eventcutflow"));

        float nsig = float(hnsig->GetBinContent(2));
        float nsig2= float(hnsig2->GetBinContent(2));

        TH1*  hpass = (TH1F*)file1->Get(hist);
        TH1*  hpass2 = (TH1F*)file2->Get(hist);

        cout  << " \n ------- " << endl;
        cout  << " Mass = " << masses.at(i) << endl;
        cout << "mu eacceptance = " << hpass->Integral()/nsig << endl;
        cout << "emu acceptance = " << hpass2->Integral()/nsig2 << endl;

        hpass->Add(hpass2,1.);
        double err ;
        hpass->IntegralAndError(1, hpass->GetNbinsX()+1, err    , "");
        cout << "Average = " << hpass->Integral()/(nsig + nsig2) << endl;
        cout << "%err = " << 100*err/(hpass->Integral())<< endl;;

    }
}
开发者ID:jbhyun,项目名称:LQanalyzer,代码行数:75,代码来源:EMuSigEff.C


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