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


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

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


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

示例1: g

TGraphErrors g(TTree *tree, TString alphaName, TString constTermName){
  Double_t alpha, constTerm;
  alphaName.ReplaceAll("-","_");
  constTermName.ReplaceAll("-","_");

  tree->SetBranchAddress(alphaName,&alpha);
  tree->SetBranchAddress(constTermName,&constTerm);

  //Long64_t nEntries=genTree->GetEntries();

  TGraphErrors graph;
  Int_t iPoint=0;

  tree->GetEntry(0);
  std::cout << alpha << "\t" << constTerm << std::endl;
  Double_t alpha2=alpha*alpha;
  Double_t const2=constTerm*constTerm;
  for(Double_t energy=20; energy<150; energy+=10){
    Double_t addSmearing = (sqrt(alpha2/energy+const2));
    
    graph.SetPoint(iPoint, energy, addSmearing);
    graph.SetPointError(iPoint,0, 0);
    iPoint++;
  }

  graph.Set(iPoint);
  tree->ResetBranchAddresses();
  graph.Draw("A L");
  graph.SetFillColor(kBlue);
  graph.SetLineColor(kYellow);
  graph.GetXaxis()->SetTitle("Energy [GeV]");
  graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
开发者ID:alexeyfinkel,项目名称:ECALELF,代码行数:34,代码来源:mcmcDraw.C

示例2: TGraphErrors

void ExpManager::GetExp1DGraphX(TString NameTitle, double zmin, double zmax, double ymin, double ymax, TString grid){   // do the same thing as for the polar interpolation

    TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez);
    fGraph->SetTitle("Experimental Data;X (mm);Magnetic Field (mT)");
    fGraph->SetMarkerSize(1.2);
    fGraph->SetMarkerStyle(20);
    fGraph->SetMarkerColor(kBlue);
    fGraph->SetLineColor(kBlue);
    fGraph->SetLineWidth(2);
       
    int graph_counter = 0 ; 
   for (unsigned i=0; i< fExpY.size(); i++)   {
    //cout <<  " X "  << fExpX.at(i) ;  
        if( (fExpY.at(i) >= ymin && fExpY.at(i) <= ymax) && (fExpZ.at(i) >= zmin && fExpZ.at(i) <= zmax)  && fGrid.at(i)== grid ){
            cout << "  < ----- " ; 
            fGraph->SetPoint(graph_counter,fExpX.at(i),fExpB.at(i));    // CHECK, add new the stuff for emag
            fGraph->SetPointError(graph_counter,fExpXErr.at(i),fExpBErr.at(i));   // CHECK, add new the stuff for emag
            graph_counter++;
        }
        cout << endl ; 
   }

    fGraph->SetTitle(NameTitle+Form(" Experimental Data : %.2f < Depth < %.2f mm  __  %.2f < Y < %.2f mm;X (mm);Magnetic Field (mT)",zmin,zmax,ymin,ymax));
    fGraph->SetName(NameTitle+Form("_Exp_Depth_%.2f_%.2fmm_Y_%.2f_%.2fmm",zmin,zmax,ymin,ymax));
    fGraph->Write();

}
开发者ID:moukaddam,项目名称:LensMapper,代码行数:27,代码来源:ExpManager.cpp

示例3: LSF

void LSF() {
  float x[100], y[100], ex[100], ey[100];
  char filename[80];
  printf("Enter filename.\n");
  scanf("%s",filename);

  FILE *f = fopen(filename,"r");
  if (f == NULL) {
    sprintf(line,"File %s not found.\n",filename);
    printf(line);
    return;
  }

  // Read data
  int i = 0;
  while (fscanf(f,"%f %f %f",&(x[i]),&(y[i]),&(ey[i])) == 3 ) {
    i++;
  }

  printf("Read %d data points.\n",i);

  TGraphErrors *tge = new TGraphErrors(i,x,y,ex,ey); 
  tge->SetMarkerStyle(20);
  tge->SetMarkerColor(kBlue);
  tge->SetLineColor(kBlue);

  c1 = new TCanvas("c1","c1",600,600);

  tge->Draw("AP");
  tge->Fit("pol1");
}
开发者ID:joshaw,项目名称:year3physics,代码行数:31,代码来源:LSF.C

示例4: DrawSame

void DrawSame(char* varToPlot, char* cond, Int_t kColor,TLegend* leg,char* cLeg)
{
  TGraphErrors *g;
  TIFTree->Draw(varToPlot,cond,"goff");
  
  Int_t nSel=TIFTree->GetSelectedRows();
  if ( nSel ) {
    
    Double_t *ErrX= new Double_t[nSel];
    for ( Int_t i=0; i<nSel; i++) ErrX[i]=0;
    
    g = new TGraphErrors(TIFTree->GetSelectedRows(), TIFTree->GetV1(),  TIFTree->GetV2(), ErrX, TIFTree->GetV3());
    
    g->SetMarkerStyle(21);
    g->SetMarkerSize(0.5);
    g->SetMarkerColor(kColor);
    g->SetLineColor(kColor);
    g->Draw("SP"); //draw graph in current pad
    
    //    g->GetYaxis()->SetRangeUser(40., 100.);
    leg->AddEntry(g,cLeg);
    leg->Draw();
    delete[] ErrX;
  }
  else {
    cout << "NO rows selected " << endl;
  }
}
开发者ID:aashaqshah,项目名称:cmssw-1,代码行数:28,代码来源:plotMacro_Off.C

示例5: RatioEmissionCorrection

/* Determine the correction to be applied to emission spectra by taking a ratio
 * of an accepted reference to data that was measured in the integrating sphere.
 */
void RatioEmissionCorrection() {
    double y[NUM_POINTS + 1];
    double corr[NUM_POINTS];

    FILE *data = fopen("data/ratio emcorr/POPOP_IS.txt", "r");
    FILE *ref = fopen("data/ratio emcorr/POPOPref.txt", "r");
    
    char line[LINE_SIZE];
    char* p;
    int index = 0;
    while(fgets(line, sizeof(line), data)) {
        strtok(line, "\n");
        double xval = strtod(line, &p);
        double yval = atof(p);
        y[index] = yval - 3424.978;
        index++;
    }
    
    index = 0;
    while(fgets(line, sizeof(line), ref)) {
        strtok(line, "\n");
        double xval = strtod(line, &p);
        double yval = atof(p);
        corr[index] = (yval - 3500) / y[index];
        index++;
        fgets(line, sizeof(line), ref);
        strtok(line, "\n");
    }
    
    FILE* result = fopen("correction/ratioCorrectionData.txt", "w");
    for (int k = 0; k < NUM_POINTS; k++) {
        printf("%dnm: %f\n", k + 350, corr[k]);
        sprintf(line, "%d %f\n", k + 350, corr[k]);
        fputs(line, result);
    }
    
    fclose(data);
    fclose(ref);
    fclose(result);
    
    /* VARIATION.C was used to calculate the average fraction of the
     * standard error over the mean photon count for each of the three
     * excitation corrections. This is the factor used for error bars.
     */
    double err[NUM_POINTS + 1];
    double w[NUM_POINTS + 1];
    double y_corr[NUM_POINTS + 1];
    for (int n = 0; n < NUM_POINTS; n++) {
        err[n] = 0.04148067 * corr[n];
        w[n] = n + 350;
        y_corr[n] = y[n] * corr[n];
    }
    
    
    TGraphErrors* g = new TGraphErrors(151, w, corr, NULL, err);
    g->SetTitle("Emission Corrections");
    g->SetLineColor(4);
    g->Draw();
} 
开发者ID:lbignell,项目名称:WbLS-Quantum-Yield,代码行数:62,代码来源:RatioEmissionCorrection.C

示例6: plot_mc

void plot_mc(string name="g", double q2=1.9, Int_t n=0)
{
//    SetAtlasStyle();
    TGraphErrors *p;

    TString nn;
    nn.Form("ave_%s_vs_x_for_Q2=%g",name.c_str(),q2);
    gDirectory->GetObject(nn,p);

//    p->Print();

    Double_t ratsize = 0.0;

    TCanvas *c = new TCanvas("PDF","pdf",600,600);
    TPad *pad1 = new TPad("pad1","pad1",0.,ratsize,1.,1.);
    pad1->SetLogx();
    pad1->Draw();
    pad1->cd();
    p->GetXaxis()->Set(101,0.0001,1.);
    p->SetFillColor(kRed-2);
    p->SetFillStyle(3001);
    p->SetLineWidth(1);
    p->SetLineColor(kRed);
    p->GetYaxis()->SetTitle(name.c_str());

    p->GetYaxis()->SetTitleSize(0.06);
    p->GetYaxis()->SetTitleOffset(1.);
    p->GetXaxis()->Set(101,0.0001,1.);
    p->Draw("ALE3");

    Double_t av = 0;
    Double_t av2 = 0;

    for (Int_t i = 1; i<n+1 ; i++) {
        nn.Form("%s_vs_x_for_Q^{2}=%g_%i",name.c_str(),q2,i);
        TGraph *pp = NULL;
        gDirectory->GetObject(nn,pp);
        if (pp != NULL) {
            pp->SetLineColor(kGreen);
            pp->Draw("L");

            av  += pp->GetY()[0];
            av2 += pp->GetY()[0]*pp->GetY()[0];
            cout << i << " "<<pp->GetY()[0] << endl;


        }
    }

    av  /= n;
    av2 = sqrt(av2/n - av*av);
//    cout << n << " "<<av << " "<< av2<<endl;


    p->Draw("E3C");


}
开发者ID:hep-mirrors,项目名称:h1fitter,代码行数:58,代码来源:plot_pdf.C

示例7: CmpNmuMCData

int CmpNmuMCData()
{
  double ene[21]    = {2.0,     2.05,    2.1,     2.15,   2.175, 
                       2.2,     2.2324,  2.3094,  2.3864, 2.396,  
	           2.5,     2.6444,  2.6464,  2.7,    2.8,
	           2.9,     2.95,    2.981,   3.0,    3.02,     3.08};
  double enee[21]   = {0.0};
  double Nmu_mc[21] = {73.4868, 24.4878, 106.242, 28.242, 123.445, 
                       171.389, 155.009, 336.687, 412.597, 1314.02,
	           26.2072, 1117.27, 1111.97, 37.838, 41.3881,
	           5159.19, 899.304, 924.003, 928.963, 1074.39, 8685.27};
  double Nmue_mc[21]; for (int i=0; i<21;i++) Nmue_mc[i] = sqrt(Nmu_mc[i]);
  double Nmu_da[21] = {91.9,    39.1,    143.0,   25.8,    129.5,
                       163.7,   159.6,   361.1,   443.5,   1240.1,
	           22.0,    1081.5,  1073.7,  53.1,    41.9,
	           5441.4,  894.8,   974.4,   977.4,   1172.0,  8805.7};
  double Nmue_da[21]= {11.9,    6.4,     13.5,    5.,      12.7,
                       13.2,    17.1,    24.9,    24.8,    50.5,
	           4.1,     35.2,    42.7,    7.5,     7.7,
	           124.6,   32.5,    32.4,    31.6,    35.6,    102.7};

  double Nmu_mc_s[21];
  double Nmue_mc_s[21];
  double Nmu_da_s[21];
  double Nmue_da_s[21];
  for (int i=0; i<21; i++){
    Nmu_mc_s[i] = Nmu_mc[i]/Nmu_da[i];
    Nmue_mc_s[i] = Nmue_mc[i]/Nmu_da[i];
    Nmu_da_s[i] = Nmu_da[i]/Nmu_da[i];
    Nmue_da_s[i] = Nmue_da[i]/Nmu_da[i];
    cout << "At "<< ene[i]<<" GeV, Nmu from data is "<< Nmu_da[i]<<", Nmu from MC is "<< Nmu_mc[i]<<endl;
  //cout << ene[i]<<"\t" << Nmu_da[i];
  //cout << "\t" << Nmu_mc[i] << " "<< Nmu_mc_s[i] ;
  //cout << "\t "<< Nmue_mc[i] << " "<< Nmue_mc_s[i] ;
  //cout << "\t "<< Nmu_da[i] <<" "<< Nmu_da_s[i];
  //cout <<"\t " << Nmue_da[i] <<" "<<  Nmue_da_s[i] << endl;
  }

  TGraphErrors *gdata = new TGraphErrors(21, ene, Nmu_da_s, enee, Nmue_da_s);
  TGraphErrors *gmcmu = new TGraphErrors(21, ene, Nmu_mc_s, enee, Nmue_mc_s);
  gdata->Draw("AP");
  gdata->SetFillColor(0);
  gmcmu->SetFillColor(0);
  gmcmu->SetLineColor(3);
  gmcmu->SetMarkerColor(3);
  gmcmu->Draw("P");
  TLegend *lg = new TLegend(0.5,0.5,0.9,0.9);
  lg->SetFillStyle(0);
  lg->AddEntry(gdata,"Nmu from data");
  lg->AddEntry(gmcmu,"Nmu from MC");
  lg->Draw();




}
开发者ID:dannielliu,项目名称:KKcross,代码行数:56,代码来源:CmpNmuMCData.C

示例8: plotter

void plotter(Int_t octant=1){

gROOT->Reset();
gROOT->SetStyle("Plain");

TString runNums[5] = {"14296","15736","16654","17635","18875"};

TCanvas *c1 = new TCanvas();

TGraphErrors *gPos = new TGraphErrors(Form("md%dpos.dat",octant),"%lg %lg %lg");
TGraphErrors *gNeg = new TGraphErrors(Form("md%dneg.dat",octant),"%lg %lg %lg");

gPos->SetMarkerColor(kBlue);
gNeg->SetMarkerColor(kRed);
gPos->SetLineColor(kBlue);
gNeg->SetLineColor(kRed);
gPos->SetFillStyle(0);
gNeg->SetFillStyle(0);
gPos->SetTitle(Form("MD%dPOS",octant));
gNeg->SetTitle(Form("MD%dNEG",octant));

TMultiGraph *gm = new TMultiGraph("gm",Form("1/Yield for MD%d",octant));
gm->Add(gPos);
gm->Add(gNeg);

gm->Draw("ap");

gm->GetYaxis()->SetTitle("1/Yield (uA/V)");
gm->GetXaxis()->SetTitle("Run Number");

gm->GetXaxis()->SetNdivisions(505,kTRUE);

for(Int_t i=0; i<5; i++){
	gm->GetXaxis()->SetBinLabel(gm->GetXaxis()->FindBin(150000+i*10000),runNums[i].Data());

}
gm->GetXaxis()->SetTitleOffset(1.4);

c1->BuildLegend();


}
开发者ID:sjmacewan,项目名称:Qweak,代码行数:42,代码来源:plotter.C

示例9: gerrors

void gerrors() {
   
   TCanvas *mycanvas = new TCanvas("mycanvs","A Simple Graph with error bars",200,10,700,500);

//   mycanvas->SetFillColor(42);
   mycanvas->SetGrid();
//   mycanvas->GetFrame()->SetFillColor(21);
//  mycanvas->GetFrame()->SetBorderSize(12);

 const int  n_points =10;
 #double x_vals [ n_points]= {1,2,3,4,5,6,7,8,9,10};
 double  y_vals [ n_points]= {6 ,12 ,14 ,20 ,22 ,24 ,35 ,45 ,44 ,53};
 double y_errs [ n_points]= {5 ,5 ,4.7 ,4.5 ,4.2 ,5.1,2.9,4.1,4.8,5.43};

   TGraphErrors *gr = new TGraphErrors(n_points,x_vals,y_vals,NULL,y_errs);
//   TGraphErrors graph(n_points,x_vals,y_vals,NULL,y_errs);
  gROOT -> SetStyle("Plain");
   gr->SetTitle("TGraphErrors Example; lengtht  [cm];Arb. Units");
   gr->SetMarkerColor(kBlue);
   gr->SetMarkerStyle(kOpenCircle);
   gr->SetLineColor ( kBlue ) ;
   gr->Draw("ALP");
 
 //Define a linear function
TF1 f("Linear law" ,"[0]+x*[1]" ,.5 ,10.5) ; 
 
// Let's make the funcion line nicer 
f.SetLineColor(kRed);
 f.SetLineStyle(2);

 // Fit it to the graph and draw it 
  gr->Fit(&f); 
      f.DrawClone("Same"); 

 // Build and Draw a legend 
      TLegend leg(.1 ,.7 ,.3 ,.9 ,"Lab. Lesson 1"); 
     leg.SetFillColor (0) ; 
    gr->SetFillColor (0) ; 
     leg.AddEntry(gr,"Exp. Points"); 
     leg.AddEntry(&f,"Th. Law"); 
     leg.DrawClone("Same"); 
         // Draw an arrow on the canvas 
       TArrow arrow(8,8,6.2,23,0.02,"----|>"); 
       arrow.SetLineWidth (2) ; 
       arrow.DrawClone ( ) ; 
         // Add some text to the plot 
 TLatex text(8.2,7.5,"#splitline{Maximum}{Deviation}"); 
         text.DrawClone ( ) ; 

   mycanvas->Update();
   mycanvas -> Print("example.pdf");
}
开发者ID:xueweiphy,项目名称:AMSfit,代码行数:52,代码来源:gerrors.cpp

示例10: DrawMap

void ExpManager::DrawMap(TString NameTitle, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) {

    TMultiGraph *mg = new TMultiGraph();
    
    //Draw a cross
    TGraphErrors *frame = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez);
    frame->SetPoint(0,+0,+100);
    frame->SetPoint(1,+0,-100);
    frame->SetPoint(2,0,0); 
    frame->SetPoint(3,-100,0); 
    frame->SetPoint(4,+100,0);
    frame->SetPoint(5,+0,+0); 
    frame->SetPoint(6,+0,-100);
    frame->SetMarkerColor(kWhite);
    frame->SetDrawOption("ap");
    
    //Draw the map 
    TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez);
    fGraph->SetMarkerSize(1.2);
    fGraph->SetMarkerStyle(20);
    fGraph->SetMarkerColor(kBlue);
    fGraph->SetLineColor(kBlue);
    fGraph->SetLineWidth(1);
    //fGraph->SetDrawOption("ap");
    
    int graph_counter = 0 ; 
   for (unsigned i=0; i< fExpY.size(); i++)   {
        if( (fExpX.at(i) >= xmin && fExpX.at(i) <= xmax) && (fExpY.at(i) >= ymin && fExpY.at(i) <= ymax) && (fExpZ.at(i) >= zmin && fExpZ.at(i) <= zmax) ) {
            fGraph->SetPoint(graph_counter,fExpX.at(i),fExpY.at(i));    
            fGraph->SetPointError(graph_counter,fExpXErr.at(i),fExpYErr.at(i)); 
            graph_counter++;
        } 
   }

    //fGraph->Write();
    mg->SetTitle(NameTitle+Form(" Map : %.2f < X < %.2f mm    %.2f < Y < %.2f mm    %.2f < Z < %.2f mm;X (mm);Y (mm)",xmin,xmax,ymin,ymax,zmin,zmax));
    mg->SetName(NameTitle+Form("_Map__X_%.2f_%.2fmm__Y_%.2f_%.2fmm__Z_%.2f_%.2fmm",xmin,xmax,ymin,ymax,zmin,zmax));
    mg->Add(frame); 
    mg->Add(fGraph);
    mg->Write();
}
开发者ID:moukaddam,项目名称:LensMapper,代码行数:41,代码来源:ExpManager.cpp

示例11: draw_single_spectra

TGraphErrors* draw_single_spectra( 	string energy="15", string plc="la", string iCen="0",
							int color = kRed, string draw_opt = "", double scaler = 1.0 ){

	Logger::setGlobalLogLevel( Logger::llAll );
	gStyle->SetOptStat( 0 );


	string fn = file_name( energy, plc, iCen );
	if ( !file_exists( fn ) )
		return new TGraphErrors();



	INFO( "Loading " << fn )
	SpectraLoader sl( fn );

	sl = sl * scaler;

	TGraphErrors* stat = sl.statGraph( );

	//stat->Scale( scaler );

	// if ( "la" == plc || "ala" == plc){
	// 	stat->SetBinContent( 1, 0 );
	// 	stat->SetBinError( 1, 0 );
	// }

	
	stat->SetTitle( " ; pT [GeV/c]; dN^{2} / ( N_{evt} 2 #pi pT dpT dy )" );
	stat->SetLineColor( color );
	stat->SetMarkerStyle( 8 );
	stat->SetMarkerColor( color );
	
	stat->Draw( draw_opt.c_str() );

	gPad->SetLogy(1);

	return stat;

}
开发者ID:jdbrice,项目名称:strange_hadrons,代码行数:40,代码来源:draw_single_spectra.C

示例12: getDataMcResponseRatio

TGraphErrors* getDataMcResponseRatio(TGraphErrors* gData, TGraphErrors* gMc, int aNumberOfPtBins, string XTitle) {
  Double_t x[aNumberOfPtBins];
  Double_t ex[aNumberOfPtBins];
  for(int j=0;j<aNumberOfPtBins; j++) {
    ex[j] = 0.;
  }
  Double_t xratio[aNumberOfPtBins];
  Double_t ydata[aNumberOfPtBins];
  Double_t ymc[aNumberOfPtBins];
  Double_t yr[aNumberOfPtBins];
  Double_t eydata[aNumberOfPtBins];
  Double_t eymc[aNumberOfPtBins];
  Double_t eyr[aNumberOfPtBins];

  int nBins = 0;
  for(int i=0; i<aNumberOfPtBins; i++) {
    gMc->GetPoint(i,x[i],ymc[i]);
    gData->GetPoint(i,x[i],ydata[i]);
    eymc[i] = gMc->GetErrorY(i);
    eydata[i] = gData->GetErrorY(i);
    if (ymc[i] == 0 || ydata[i] == 0)
      continue;
    xratio[nBins] = x[i];
    yr[nBins] = ydata[i]/ymc[i];
    std::cout << yr[nBins] << std::endl;
    eyr[nBins] = sqrt(pow(eydata[i]/ymc[i],2)+pow(eymc[i]*ydata[i]/(pow(ymc[i],2)),2));
    nBins++;
  }

  TGraphErrors *gDataMcResponseratio = new TGraphErrors(nBins,xratio,yr,ex,eyr);
  gDataMcResponseratio->SetMarkerStyle(20);
  gDataMcResponseratio->SetMarkerColor(1);
  gDataMcResponseratio->SetLineColor(1);
  gDataMcResponseratio->SetMarkerSize(1.0);
  //gDataMcResponseratio->SetMaximum(1.08);
  //gDataMcResponseratio->SetMinimum(0.90);
  gDataMcResponseratio->GetXaxis()->SetTitle(XTitle.c_str());

  return gDataMcResponseratio;
}
开发者ID:pequegnot,项目名称:multijetAnalysis,代码行数:40,代码来源:mergePlot.cpp

示例13: assert

TGraphErrors *tools::ratioGraphs(TGraphErrors *g1, TGraphErrors *g2,
				 double erry) {

  assert(g1); assert(g2);
  TGraphErrors *g = new TGraphErrors(0);
  g->SetName(Form("ratio_%s_%s",g1->GetName(),g2->GetName()));
  g->SetMarkerStyle(g1->GetMarkerStyle());
  g->SetMarkerColor(g1->GetMarkerColor());
  g->SetLineColor(g1->GetLineColor());

  // take ratio only of points that are closer to each other than any others
  for (int i = 0, j = 0; (i != g1->GetN() && j != g2->GetN());) {
    
    double x1m, x1p, x2m, x2p, y, ex, ey;
    GetPoint(g1, max(i-1,0), x1m, y, ex, ey);
    GetPoint(g1, min(i+1,g1->GetN()-1), x1p, y, ex, ey);
    GetPoint(g2, max(j-1,0), x2m, y, ex, ey);
    GetPoint(g2, min(j+1,g2->GetN()-1), x2p, y, ex, ey);
    double x1, y1, ex1, ey1;
    GetPoint(g1, i, x1, y1, ex1, ey1);
    double x2, y2, ex2, ey2;
    GetPoint(g2, j, x2, y2, ex2, ey2);

    if (fabs(x1-x2)<=fabs(x1-x2m) && fabs(x1-x2)<=fabs(x1-x2p) &&
	fabs(x1-x2)<=fabs(x2-x1m) && fabs(x1-x2)<=fabs(x2-x1p)) {

      int n = g->GetN();
      SetPoint(g, n, 0.5*(x1+x2), (y2 ? y1/y2 : 0.), 0.5*fabs(x1-x2),
	       oplus(ey1/y1, ey2/y2) * fabs(y2 ? y1/y2 : 0.) * erry); 
      ++i, ++j;
    }
    else
      (x1<x2 ? ++i : ++j);
  } // for i, j

  return g;
} // ratioGraphs
开发者ID:amanabhishk,项目名称:jecsys,代码行数:37,代码来源:tools.C

示例14: rateStudy


//.........这里部分代码省略.........
      stringstream filePath;
      filePath << "pmtratestudy/run" << data[0] << "*.root";
      cout << "opening file at " << filePath.str() << endl;
      cout << "file counter: " << fileCounter << " channel=" << ch << endl;
      //TFile* f = new TFile(filePath.str().c_str());
      //TTree* t = (TTree *)f->Get("eventtree");
      TChain* t = new TChain("eventtree");
      t->Add( filePath.str().c_str() );
      out->cd();

      x[fileCounter] = data[1];

      int nfires[NCH] = {0};
      int samples = 0;
      float chmax = 0.0;
      t->SetBranchAddress("nfires", &nfires);
      t->SetBranchAddress("samples", &samples);
      t->SetBranchAddress("chmax", &chmax);
      
      h->Reset();
      
      int nentries = t->GetEntries();
      for (int entry = 0; entry < nentries; ++entry) {
        t->GetEntry(entry);
        if (chmax < 100.0) {
          h->Fill(nfires[ch]);
        }
      }


      
      pois->SetParameter(0,1);
      pois->SetParameter(1, h->GetMean());

      h->Fit(pois,"RQ","",0,50);
      //TF1 *myfit = (TF1 *)h->GetFunction("pois");
      TF1 *myfit = (TF1 *)pois;
      Double_t lambda = myfit->GetParameter(1);  
      h->Draw();
      stringstream histFileName;
      histFileName << "hist/h" << data[0] << "_ch" << ch << ".png";
      c1->SaveAs(histFileName.str().c_str());
      //Graph with poisson method
#if 1
      y[fileCounter] = lambda / ((samples - 1) * 15.625E-6);
      errY[fileCounter] = myfit->GetParError(1) / ((samples - 1) * 15.625E-6);
#endif
      //Graph with mean method
#if 0
      y[fileCounter] = h->GetMean() / ((samples - 1) * 15.625E-6);
      errY[fileCounter] = h->GetMeanError() / ((samples - 1) * 15.625E-6);
#endif
      cout << x[fileCounter] << ", " << y[fileCounter] 
           << " | " << (samples - 1) << endl;
      delete t;
      //f->Close();
      fileCounter++;
    } 

    ppp->SetParameter(0,1);
    ppp->SetParameter(1,0.4);
     
    TGraphErrors* gr = new TGraphErrors(NRUNS, x, y, errX, errY);
    gr->SetLineColor(color[ch % NCOLORS]);
    cout << "color: " << color[ch % NCOLORS] << endl;
    gr->SetLineWidth(2);
    gr->SetMarkerStyle(7);
    gr->Fit("ppp","R0","Q0",0.045,2.0);
    TF1 *afit = (TF1 *)gr->GetFunction("ppp");
    Double_t aRate = 1/afit->GetParameter(1);  
    if (aRate > 0) {
      hRate->Fill(aRate);
    }
    gr->GetXaxis()->SetTitle("Run Date");
    gr->GetYaxis()->SetTitle("Rate [kHz]");

    stringstream entryName, fileName;
    entryName << "Channel" << ch;
    gr->SetTitle(entryName.str().c_str());
    fileName << "plots/" << ch << ".png";
    legend->AddEntry(gr, entryName.str().c_str());
    gr->Draw("alp");
    c1->SaveAs(fileName.str().c_str());
    mg->Add(gr);
    cout << "added plot to mg\n";
    fin.clear();
    fin.seekg(0, ios::beg);
  } // loop over channel
  hRate->Draw();
  hRate->Fit("gaus");
  c1->SaveAs("hrate.pdf");
  mg->Draw("alp");
  mg->GetXaxis()->SetTitle("Days since first run");
  mg->GetYaxis()->SetTitle("Rate [kHz]");
  mg->SetTitle("All channels: Rate vs. Days since first Run");

  legend->Draw();
  c1->SaveAs("mg.pdf");
  
}
开发者ID:twongjirad,项目名称:SubEventAnalysis,代码行数:101,代码来源:rateStudy.C

示例15: profileDistributions


//.........这里部分代码省略.........
	  TGraphErrors *DataProf = new TGraphErrors(Data->ProfileX());  DataProf->SetMarkerStyle(20); DataProf->SetFillStyle(0); DataProf->SetName(ch[ich]+profs[i]+"data");
	  
	  //build data/MC scale factors
	  std::vector<TGraphErrors *> data2mcProfs;
	  for(size_t isyst=0; isyst<=systMC.size(); isyst++)
	    {
	      TGraphErrors *prof= (isyst==0 ? MCProf : new TGraphErrors(systMC[isyst-1]->ProfileX()));
	      TString baseName(ch[ich]+profs[i]);
	      if(isyst) baseName += systList[isyst];
	      prof = (TGraphErrors *) prof->Clone(baseName+"data2mc");
	      for(int ip=0; ip<DataProf->GetN(); ip++)
		{
		  Double_t x,y,ydata,y_err,ydata_err;
		  prof->GetPoint(ip,x,y);         y_err=prof->GetErrorY(ip);
		  DataProf->GetPoint(ip,x,ydata); ydata_err=DataProf->GetErrorY(ip);
		  if(y<=0) continue;
		  prof->SetPoint(ip,x,ydata/y);
		  prof->SetPointError(ip,0,sqrt(pow(ydata*y_err,2)+pow(ydata_err*y,2))/pow(y,2));
		}
	      prof->SetFillColor(systColors[isyst]);
	      prof->SetFillStyle(3001+isyst%2);
	      prof->SetTitle( isyst==0 ? nomTTbarTitle : systLabels[isyst-1] );
	      //prof->SetMarkerStyle(24);   prof->SetFillStyle(3001); prof->SetMarkerColor(1+isyst); prof->SetMarkerColor(1+isyst); prof->SetLineColor(1+isyst);
	      data2mcProfs.push_back(prof);
	    }

	  
	  TH1D *MCProjY=MC->ProjectionY();
	  MCProjY->Scale(1./MCProjY->Integral()); 
	  TGraphErrors *MCProj   = new TGraphErrors(MCProjY);    MCProj->SetMarkerStyle(24); MCProj->SetFillStyle(0);  MCProj->SetName(ch[ich]+profs[i]+"projmc");
	  TH1D *DataProjY=Data->ProjectionY();
	  DataProjY->Scale(1./DataProjY->Integral());
	  TGraphErrors *DataProj = new TGraphErrors(DataProjY);  DataProj->SetMarkerStyle(20); DataProj->SetFillStyle(0); DataProj->SetName(ch[ich]+profs[i]+"projdata");
	  MCProj->SetLineColor(colors[i]);   MCProj->SetMarkerColor(colors[i]);   MCProj->SetFillColor(colors[i]); MCProj->SetFillStyle(1001);
	  DataProj->SetLineColor(colors[i]); DataProj->SetMarkerColor(colors[i]);   DataProj->SetFillColor(colors[i]);
	  
	  TPad *p=(TPad *)cproj->cd();
	  p->SetLeftMargin(0.15);
	  p->SetRightMargin(0.02);
	  p->SetTopMargin(0.05);
	  p->SetLogy();
	  MCProj->SetFillStyle(0);
	  MCProj->Draw(i==0 ? "al3" : "l3");
	  MCProj->GetYaxis()->SetRangeUser(1e-5,1.0);
	  MCProj->GetXaxis()->SetTitle( MC->GetYaxis()->GetTitle() );
	  MCProj->GetYaxis()->SetTitle( "1/N dN/dx" );
	  MCProj->GetYaxis()->SetTitleOffset(1.8);
	  DataProj->Draw("p");
	  std::pair<float,int> chi2=computeChiSquareFor(DataProj,MCProj);
	  char buf[200];
	  sprintf(buf,"#scale[0.7]{#chi^{2}/ndof=%3.1f}", chi2.first/chi2.second );
	  dataprojLeg->AddEntry(DataProj,buf,"p");
	  mcprojLeg->AddEntry(MCProj,cats[i],"l");
	  if(i==0) drawCMSHeader(ch[ich]);
	  

	  p=(TPad *)c->cd(i+1);
	  if(i<nprofs-1) p->SetBottomMargin(0.01);
	  if(i>0) p->SetTopMargin(0);
	  if(i==0)p->SetTopMargin(0.1);
	  if(i==nprofs-1) p->SetBottomMargin(0.15);
	  TGraphErrors *frame=DataProf;
	  frame->Draw("ap");
	  //frame->GetYaxis()->SetRangeUser(0.54,1.46);
	  frame->GetXaxis()->SetTitle(MC->GetXaxis()->GetTitle());
	  //frame->GetXaxis()->SetRangeUser(0,4.75);
开发者ID:tseva,项目名称:2l2v_fwk,代码行数:67,代码来源:profileUEdistributions.C


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