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


C++ TGraphErrors::RemovePoint方法代码示例

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


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

示例1: if

TGraphErrors *ReadMWGraph(const char *name, Int_t flag)
{
  Double_t xreject = 0.49;

  TGraphErrors *g = new TGraphErrors(name);
  if (g->IsZombie()) return 0;
  while (g->GetX()[0] < xreject)
    g->RemovePoint(0);

  TGraphErrors *g2 = new TGraphErrors(name);
  if (g2->IsZombie()) return 0;
  while (g2->GetX()[0] < xreject)
    g2->RemovePoint(0);
  g2->SetMarkerStyle(4);
  g2->SetMarkerSize(1.00);
  g2->SetMarkerColor(kBlack);
  g2->SetLineColor(kBlack);

  TGraphErrors *gsys = new TGraphErrors(name, "%lg %lg %lg %*lg %lg");
  if (gsys->IsZombie()) return 0;
  while (gsys->GetX()[0] < xreject)
    gsys->RemovePoint(0);
  for (Int_t i = 0; i < gsys->GetN(); i++)
    gsys->SetPointError(i, gsys->GetErrorX(i)*0.75, gsys->GetErrorY(i));
  gsys->SetFillColor(kGray+2);
  gsys->SetLineColor(kGray+2);
  gsys->SetFillStyle(3000);

  if (flag == 1 || flag == 3) {
    TGraphErrors *gt = new TGraphErrors(Form("%s_%s", name, "trues"));
    if (gt->IsZombie()) return 0;
    while (gt->GetX()[0] < xreject)
      gt->RemovePoint(0);
    gt->SetMarkerStyle(20);
    gt->SetMarkerSize(0.75);
    gt->SetMarkerColor(kGreen+1);
    gt->SetLineColor(kGreen+1);

    TGraphErrors *gbw = new TGraphErrors(Form("%s_%s", name, "gen"));
    if (gbw->IsZombie()) return 0;
    while (gbw->GetX()[0] < xreject)
      gbw->RemovePoint(0);
    gbw->SetMarkerStyle(20);
    gbw->SetMarkerSize(0.75);
    gbw->SetMarkerColor(kBlue+1);
    gbw->SetLineColor(kBlue+1);

    for (Int_t i = 0; i < g->GetN(); i++) {
      g->SetPointError(i, g->GetEX()[i], 0.);
      gt->SetPointError(i, gt->GetEX()[i], 0.);
      gbw->SetPointError(i, gbw->GetEX()[i], 0.);
    }

    for (Int_t i = 0; i < g2->GetN(); i++) {
      g2->SetPoint(i, g2->GetX()[i], g2->GetY()[i] - gt->GetY()[i] + gbw->GetY()[i]);
      g2->SetPointError(i, g2->GetEX()[i], TMath::Sqrt(g2->GetEY()[i]*g2->GetEY()[i] + gt->GetEY()[i]*gt->GetEY()[i] +
                                                       gbw->GetEY()[i]*gbw->GetEY()[i]));

      //      g2->SetPoint(i, g2->GetX()[i], g2->GetY()[i] - gt->GetY()[i] + 1.01947);
      //      g2->SetPointError(i, g2->GetEX()[i], TMath::Sqrt(g2->GetEY()[i]*g2->GetEY()[i] + gt->GetEY()[i]*gt->GetEY()[i] +
      //                                                       7.78680e-06*7.78680e-06));

      gsys->SetPoint(i, gsys->GetX()[i], g2->GetY()[i]);
    }
  }

  g->SetTitle();
  g->SetName(name);
  g->GetXaxis()->SetTitle("p_{T}, GeV/c");
  g->SetMarkerStyle(20);
  g->SetMarkerSize(0.95);
  g->SetMarkerColor(kRed+1);
  g->SetLineColor(kRed+1);

  const Double_t mass = 1.019455;
  const Double_t mass_delta = 0.000020;
  const Double_t width = 0.00426;
  const Double_t width_delta = 0.00004;
  if (flag == 1) { // mass
    g->GetYaxis()->SetTitleOffset(1.50);
    g->GetYaxis()->SetTitle("mass, GeV/c^{2}");
    g->SetMaximum(mass+0.0015);
    g->SetMinimum(mass-0.0015);
    TBox *box = new TBox(g->GetXaxis()->GetXmin(), mass - mass_delta, g->GetXaxis()->GetXmax(), mass + mass_delta);
    box->SetFillColor(kGray+1);
    box->SetFillStyle(3001);
    g->GetListOfFunctions()->Add(box);
    g->GetListOfFunctions()->Add(g2, "CP");
    g->GetListOfFunctions()->Add(gt, "CP");
    g->GetListOfFunctions()->Add(gbw, "CP");
  }
  else if (flag == 3) { // mass simple
    g2->SetTitle();
    g2->SetName(Form("%s_only", name));
    g2->GetXaxis()->SetTitle("p_{T}, GeV/c");
    g2->SetMarkerStyle(20);
    g2->SetMarkerSize(0.75);
    g2->SetMarkerColor(kBlack);
    g2->SetLineColor(kBlack);
    g2->GetYaxis()->SetTitleOffset(1.50);
//.........这里部分代码省略.........
开发者ID:musinsky,项目名称:bordel,代码行数:101,代码来源:spectra_mw.C

示例2: DrawKinvarPlot

void DrawKinvarPlot(TString filename="kinvarset/FMSOR_Pt_vs_run.root",
                    TString classname="pi0") {
  TFile * infile = new TFile(filename.Data(),"READ");

  char trig[32];
  char typ[32];
  char tmp[128];
  TString tmpstr = filename;
  tmpstr.ReplaceAll("_"," ");
  TRegexp re("^.*\/");
  tmpstr(re) = "";
  cout << tmpstr << endl;
  sscanf(tmpstr.Data(),"%s %s",trig,typ);
  printf("%s %s\n",trig,typ);

  TString hname = "h2_"+classname;
  TH2D * h = (TH2D*)infile->Get(hname.Data());
  TString gname = "g_"+classname;
  TGraphErrors * g = (TGraphErrors*)infile->Get(gname.Data());
  TString gtname = "gt_"+classname;
  TGraphErrors * gt;
  if(!strcmp(typ,"Pt")) gt = (TGraphErrors*)infile->Get(gtname.Data());
  
  char htitle[256];
  char hnewtitle[512];
  strcpy(htitle,h->GetTitle());
  sprintf(hnewtitle,"%s -- %s triggers",htitle,trig);
  h->SetTitle(hnewtitle);

  h->SetMinimum(0.001);

  if(!strcmp(typ,"Pt")) {
    gt->SetLineWidth(2);
    gt->SetLineColor(kBlack);
  };

  // temporary hack to cut out fluctuations of pt_thresh vs. run to 0
  Double_t xx,yy;
  Int_t gtn = gt->GetN();
  for(int ii=0; ii<gtn; ii++) {
    gt->GetPoint(ii,xx,yy);
    printf("xx=%f yy=%f\n",xx,yy);
    if(yy<0.001) gt->RemovePoint(ii);
  };
   
  // drawing range
  Float_t xmin = h->GetXaxis()->GetXmin();
  Float_t xmax = h->GetXaxis()->GetXmax();
  xmax = 515;
  if(xmax<gtn) { 
    fprintf(stderr,"\nWARNING: xmax < gt->GetN(); graphs will be cut off!\n\n");
  };
  
  TCanvas * c = new TCanvas("c","c",1500,700);
  c->Divide(1,2);
  gStyle->SetOptStat(0);
  for(int x=1; x<=2; x++) c->GetPad(x)->SetGrid(1,1);
  c->cd(1);
  c->GetPad(1)->SetLogz();
  h->GetXaxis()->SetRangeUser(xmin,xmax);
  h->Draw("colz");
  if(!strcmp(typ,"Pt")) gt->Draw("LX");
  c->cd(2);
  g->SetFillColor(kGray);
  printf("%f %f\n",xmin,xmax);
  g->GetXaxis()->SetLimits(xmin,xmax);
  g->GetXaxis()->SetRangeUser(xmin,xmax);
  /*
  g->Draw("A3");
  g->Draw("PLX");
  */
  g->Draw("APLX");
  
  TString outname = filename.ReplaceAll(".root"," "+classname);
  outname = outname+".png";
  c->Print(outname.Data(),"png");
};
开发者ID:c-dilks,项目名称:spinlong,代码行数:77,代码来源:DrawKinvarPlot.C

示例3: softrad


//.........这里部分代码省略.........

  cout << "Reading in data" << endl << flush;
  // Read in plots vs pT (and alpha)
  map<string, map<string, map<string, map<int, TGraphErrors*> > > > gemap;
  map<string, map<string, map<string, map<int, TGraphErrors*> > > > gamap;
  for (int itype = 0; itype != ntypes; ++itype) {
    for (int  imethod = 0; imethod != nmethods; ++imethod) {
      for (int  isample = 0; isample != nsamples; ++isample) {

	for (int  ialpha = 0; ialpha != nalphas; ++ialpha) {

	  fin->cd();
	  assert(gDirectory->cd(types[itype]));
	  assert(gDirectory->cd(bin));
	  TDirectory *d = gDirectory;

	  const char *ct = types[itype];
	  const char *cm = methods[imethod];
	  const char *cs = samples[isample];
	  const int a = alphas[ialpha];
	  // Get graph made vs pT
	  string s = Form("%s/%s/%s_%s_a%d",types[itype],bin,cm,cs,a);
	  TGraphErrors *g = (TGraphErrors*)fin->Get(s.c_str());
	  if (!g) cout << "Missing " << s << endl << flush;
	  assert(g);

	  // Clean out empty points
	  // as well as trigger-biased ones for dijets
	  // as well as weird gamma+jet high pT point
	  for (int i = g->GetN()-1; i != -1; --i) {
	    if (g->GetY()[i]==0 || g->GetEY()[i]==0 ||
		(string(cs)=="dijet" && g->GetX()[i]<70.) ||
		(string(cs)=="gamjet" && g->GetX()[i]>600. && etamin!=0))
	      g->RemovePoint(i);
	  }

	  gemap[ct][cm][cs][a] = g;
	  
	  // Sort points into new graphs vs alpha
	  TH1D *hpt = (isample==0 ? hpt2 : hpt1);
	  TProfile *ppt = (isample==0 ? ppt2 : ppt1);
	  if (isample==3) { hpt = hpt4; ppt = ppt4; } // pas-v6
	  for (int i = 0; i != g->GetN(); ++i) {
	    
	    double pt = g->GetX()[i];
	    ppt->Fill(pt, pt);
	    int ipt = int(hpt->GetBinLowEdge(hpt->FindBin(pt))+0.5);
	    //int ipt = int(pt+0.5);
	    TGraphErrors *ga = gamap[ct][cm][cs][ipt];
	    if (!ga) {
	      ga = new TGraphErrors(0);
	      ga->SetMarkerStyle(g->GetMarkerStyle());
	      ga->SetMarkerColor(g->GetMarkerColor());
	      ga->SetLineColor(g->GetLineColor());
	      gamap[ct][cm][cs][ipt] = ga;
	    }
	    int n = ga->GetN();
	    ga->SetPoint(n, 0.01*a, g->GetY()[i]);
	    ga->SetPointError(n, 0, g->GetEY()[i]);
	  } // for i 

	} // for ialpha

      } // for isample
    } // for imethod
  } // for itype
开发者ID:cihar29,项目名称:jecsys,代码行数:67,代码来源:softrad.C

示例4: main


//.........这里部分代码省略.........
      //cout << endl;   
      
     
      float slewRate = A[ihit][imax-1];
      hSlewRate -> Fill(slewRate); 

      // graphs
      gsample = new TGraphErrors();
      sprintf(gtitle,"shape_Run%d_Evt%d",runId,eventId);
      sprintf(gname,"shape_%d",ievt);
      gsample->SetName(gname);
      gsample->SetTitle(gtitle);
      gsample->GetXaxis()->SetTitle("Time (ns)");
      gsample->GetYaxis()->SetTitle("ADC counts");
      
      for (int isample = 0; isample < 10 ; isample++)
      	{
      	  gsample->SetPoint(isample, double(isample)*25., A[ihit][isample]);      
      	  gsample->SetPointError(isample,0.,0.9);      
      	}



      
      // fit function            
      TF1 *fpulseShape = new TF1("fpulseShape", pulseShape,0.,240.,3);
      fpulseShape->SetLineColor(kBlue);
      fpulseShape->SetParName(0,"Ped");
      fpulseShape->SetParName(1,"A");
      fpulseShape->SetParName(2,"T0");
      fpulseShape->FixParameter(0,0); // ped
      fpulseShape->SetParameter(1,A[ihit][imax]); // ampl
      fpulseShape->SetParameter(2,imax*25.); // T0
      gsample->RemovePoint(imax-1);
      gsample->Fit("fpulseShape","QSR+") ;
      //re-set dei punti, altrimenti root non li plotta!
      for (int isample = 0; isample < 10 ; isample++)
      	{
      	  gsample->SetPoint(isample, double(isample)*25., A[ihit][isample]);      
      	  gsample->SetPointError(isample,0.,0.9);      
      	}
      ievt++;
      

      float measuredAmpl = A[ihit][imax-1] ;
      float expectedAmpl = A[ihit][imax] * fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.);
                  
      hAmplitude  -> Fill(expectedAmpl,measuredAmpl);
      hAmplitude2 -> Fill( A[ihit][imax] * 0.774,measuredAmpl);
 

      float t0 = fpulseShape->GetParameter(2);
      
      hAmpl_vs_Time -> Fill(t0-125.,expectedAmpl);
      hRatio_vs_Time -> Fill(t0-125., fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.));
      
      if (expectedAmpl > 3000) {
	hr2->Fill( fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.));
	hTfit2->Fill(t0-125.);
	hAmax2->Fill(A[ihit][imax]);
      }
      else {
	hr1->Fill( fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.));
	hTfit1->Fill(t0-125.);
	hAmax1->Fill(A[ihit][imax]);
      }
开发者ID:Bicocca,项目名称:UserCode,代码行数:67,代码来源:SlewRateAnalysis.cpp

示例5: plot_cent_allQQ


//.........这里部分代码省略.........
  TGraphErrors *gPromptJpsiCent = new TGraphErrors(7, promptNpart, promptJpsiCent, promptNpartError, promptJpsiCentError);
  TGraphErrors *gNonPromptJpsiCent = new TGraphErrors(3, nonPromptNpart, nonPromptJpsiCent, nonPromptNpartError, nonPromptJpsiCentError);
  TGraphErrors *gUpsCent = new TGraphErrors(4, upsNpart, upsCent, upsNpartError, upsCentError);

  TGraphErrors *gInclJpsiCentSyst = new TGraphErrors(7, promptNpart, inclJpsiCent, promptSystX, inclJpsiCentSyst);
  TGraphErrors *gPromptJpsiCentSyst = new TGraphErrors(7, promptNpart, promptJpsiCent, promptSystX, promptJpsiCentSyst);
  TGraphErrors *gNonPromptJpsiCentSyst = new TGraphErrors(3, nonPromptNpart, nonPromptJpsiCent, nonPromptSystX, nonPromptJpsiCentSyst);
  TGraphErrors *gUpsCentSyst = new TGraphErrors(4, upsNpart, upsCent, upsSystX, upsCentSyst);

  TGraphErrors *gInclJpsiCentP = new TGraphErrors(7, promptNpart, inclJpsiCent, promptNpartError, promptNpartError);
  TGraphErrors *gPromptJpsiCentP = new TGraphErrors(7, promptNpart, promptJpsiCent, promptNpartError, promptNpartError);
  TGraphErrors *gNonPromptJpsiCentP = new TGraphErrors(3, nonPromptNpart, nonPromptJpsiCent, nonPromptNpartError, nonPromptNpartError);
  TGraphErrors *gUpsCentP = new TGraphErrors(4, upsNpart, upsCent, upsNpartError, upsNpartError);


  TGraphErrors *gInclJpsiMB = new TGraphErrors(1, promptNpart, inclJpsiCent, promptNpartError, inclJpsiCentError);
  TGraphErrors *gPromptJpsiMB = new TGraphErrors(1, promptNpart, promptJpsiCent, promptNpartError, promptJpsiCentError);
  TGraphErrors *gNonPromptJpsiMB = new TGraphErrors(1, nonPromptNpart, nonPromptJpsiCent, nonPromptNpartError, nonPromptJpsiCentError);
  TGraphErrors *gUpsMB = new TGraphErrors(1, upsNpart, upsCent, upsNpartError, upsCentError);

  TGraphErrors *gInclJpsiMBSyst = new TGraphErrors(1, promptNpart, inclJpsiCent, promptSystX, inclJpsiCentSyst);
  TGraphErrors *gPromptJpsiMBSyst = new TGraphErrors(1, promptNpart, promptJpsiCent, promptSystX, promptJpsiCentSyst);
  TGraphErrors *gNonPromptJpsiMBSyst = new TGraphErrors(1, nonPromptNpart, nonPromptJpsiCent, nonPromptSystX, nonPromptJpsiCentSyst);
  TGraphErrors *gUpsMBSyst = new TGraphErrors(1, upsNpart, upsCent, upsSystX, upsCentSyst);  


  TGraphErrors *gInclJpsiCent2 = new TGraphErrors(3, nonPromptNpart, inclJpsiCent2, nonPromptNpartError, inclJpsiCent2Error);
  TGraphErrors *gPromptJpsiCent2 = new TGraphErrors(3, nonPromptNpart, promptJpsiCent2, nonPromptNpartError, promptJpsiCent2Error);
  TGraphErrors *gInclJpsiCent2Syst = new TGraphErrors(3, nonPromptNpart, inclJpsiCent2, nonPromptSystX, inclJpsiCent2Syst);
  TGraphErrors *gPromptJpsiCent2Syst = new TGraphErrors(3, nonPromptNpart, promptJpsiCent2, nonPromptSystX, promptJpsiCent2Syst);


  // Remove MB point
  gInclJpsiCent->RemovePoint(0);
  gPromptJpsiCent->RemovePoint(0);
  gNonPromptJpsiCent->RemovePoint(0);
  gUpsCent->RemovePoint(0);

  gInclJpsiCentP->RemovePoint(0);
  gPromptJpsiCentP->RemovePoint(0);
  gNonPromptJpsiCentP->RemovePoint(0);
  gUpsCentP->RemovePoint(0);

  gInclJpsiCentSyst->RemovePoint(0);
  gPromptJpsiCentSyst->RemovePoint(0);
  gNonPromptJpsiCentSyst->RemovePoint(0);
  gUpsCentSyst->RemovePoint(0);

  gInclJpsiCent2->RemovePoint(0);
  gPromptJpsiCent2->RemovePoint(0);
  gInclJpsiCent2Syst->RemovePoint(0);
  gPromptJpsiCent2Syst->RemovePoint(0);


  gInclJpsiCent->SetName("gInclJpsiCent");
  gPromptJpsiCent->SetName("gPromptJpsiCent");
  gNonPromptJpsiCent->SetName("gNonPromptJpsiCent");

  gInclJpsiMB->SetName("gInclJpsiMB");
  gPromptJpsiMB->SetName("gPromptJpsiMB");
  gNonPromptJpsiMB->SetName("gNonPromptJpsiMB");

  gUpsCent->SetName("gUpsCent");
  gUpsMB->SetName("gUpsMB");

  gInclJpsiCent2->SetName("gInclJpsiCent2");
开发者ID:CMS-HIN-dilepton,项目名称:DimuonCADIs,代码行数:67,代码来源:plot_cent_allQQ.C

示例6: drawAvsB


//.........这里部分代码省略.........
  for (unsigned int im = 0; im != methods.size(); ++im) {
    const char *cm = methods[im].c_str();

    tex->DrawLatex(0.20,0.75-0.06*im,cm);
    s += "_" + methods[im];

  for (unsigned int is = 0; is != samples.size(); ++is) {

    const char *cs = samples[is].c_str();
    TGraphErrors *gg = (TGraphErrors*)fg->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
    cout << cm << " " << cs << endl << flush;
    assert(gg);
    if (fg2) {
      TGraphErrors *gg2 = (TGraphErrors*)fg2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
      assert(gg2);
      gg = addGraph(gg,gg2);
    }
    
    TGraphErrors *gf = (TGraphErrors*)ff->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
    assert(gf);
    if (ff2) {
      TGraphErrors *gf2 = (TGraphErrors*)ff2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
      assert(gf2);
      gf = addGraph(gf,gf2);
    }
    
    if (!(gf->GetN()==gg->GetN())) {

      // Remove highest pT point is that is the offender (BCD vs GH)
      if (gg->GetN()>gf->GetN() &&
	  fabs(gg->GetX()[gg->GetN()-1]/gf->GetX()[gf->GetN()-1]-1)>0.1 &&
	  fabs(gg->GetX()[gg->GetN()-2]/gf->GetX()[gf->GetN()-1]-1)<0.1) {
	cout << "Remove point B(N-1)" << endl;
	gg->RemovePoint(gg->GetN()-1);
      }
      else {
	cout << "sample " << samples[is] << " method " << methods[im]
	     << " gf->N: " << gf->GetN() << " gg->N: " << gg->GetN() << endl;
	cout << " x_gf(N-1)=" << gf->GetX()[gf->GetN()-1]
	     << " x_gg(N-1)=" << gg->GetX()[gg->GetN()-1]
	     << " x_gg(N-2)=" << gg->GetX()[gg->GetN()-2] << endl;
      }

      assert(gf->GetN()==gg->GetN());
    }

    TGraphErrors *g = (TGraphErrors*)gg->Clone(Form("ge_%s_%s",cm,cs));
    for (int i = 0; i != g->GetN(); ++i) {
      double yg = gg->GetY()[i];
      double yf = gf->GetY()[i];
      g->SetPoint(i, gg->GetX()[i], yf / yg);
      double ex = gg->GetEX()[i];
      double eg = gg->GetEY()[i];
      double ef = gf->GetEY()[i];
      g->SetPointError(i, ex, yf/yg*sqrt(pow(eg/yg,2)+pow(ef/yf,2)));
    }
    //g->Draw(is==0 ? "AP" : "SAMEP");
    g->SetLineWidth(1+is);
    g->Draw("SAMEPZ");

    if (samples[is]=="gamjet" && methods[im]=="mpfchs1" && nogjmpf) {
      tex->SetTextColor(kBlue);
      tex->DrawLatex(0.20,0.63,"#gamma+jet MPF excl. from fit");
      tex->SetTextColor(kBlack);
    }
    else if (samples[is]=="gamjet" && methods[im]=="ptchs" && nogjptb) {
开发者ID:miquork,项目名称:jecsys,代码行数:67,代码来源:drawAvsB.C


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