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


C++ TMultiGraph::Write方法代码示例

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


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

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

示例2: getSlopeRatio

vector<float> getSlopeRatio(char slice, const float MAX1, const float MAX2, const float STEP, float xmin, float xmax, float ymin, float ymax){
  
//   TString fitFilename;
//   
//   fitFilename.Form("goodFits/Fit_%c_%g_%g_%g_%g.root", slice, xmin, xmax, ymin, ymax);
//   TFile *goodFits = new TFile(fitFilename.Data(), "RECREATE");
//   
//   fitFilename.Form("badFits/Fit_%c_%g_%g_%g_%g.root", slice, xmin, xmax, ymin, ymax);
//   TFile *badFits = new TFile(fitFilename.Data(), "RECREATE");
//   
//   fitFilename.Form("allFits/Fit_%c_%g_%g_%g_%g.root", slice, xmin, xmax, ymin, ymax);
//   TFile *allFits = new TFile(fitFilename.Data(), "RECREATE");
  
  float meanAmp1[5] = {0}, meanAmp2[5] = {0}, eX1[5] = {0}, eX2[5] = {0}, eY1[5] = {0}, eY2[5] = {0};
  float energy[5] = {20, 50, 100, 150, 200}; //Different beam energies
  int runs[5] = {5651, 5654, 5655, 5659, 5661}; //Runs used at different gains
  
  vector<float> point(2); //Vector to be returned

  point.at(0) = 0;
  point.at(1) = 0;
  
  TFile *file = new TFile("myfile.root", "RECREATE");
  
  TH1F *hist1 = new TH1F("hist1", "hist1", 10000, -3000, 3000); //Histograms for APDs 1 and 2
  TH1F *hist2 = new TH1F("hist2", "hist2", 10000, -3000, 3000);
  
  TFile *f;
  TTree *h4;
  TF1 *g1, *g2, *f1, *f2;
  TString filename, plot1, plot2, cut, histname, newName;
  
  newName.Form("Resolution%c/%g_%g_%g/%c_%g_%g_%g_%g.root", slice, MAX1, MAX2, STEP, slice, xmin, xmax, ymin, ymax);
  
  TFile *newFile = new TFile(newName.Data(), "RECREATE"); //File that stores the two histograms for each slice
  
  for(int i = 0; i < 5; i++){
    
    filename.Form("./ntuples_v1/analysis_%d.root", runs[i]);
    f = TFile::Open(filename.Data());
    h4 = (TTree*) f->Get("h4");
    
    file->cd(); //Need this so the histograms have a place to "live"
    
    float xOffset = 2.5; //Difference between X[0] and X[1]. Determined by Draw("X[0]:X[1]"). There is no Y offset
    
    //Plot the fit_ampl of all the runs
    plot1.Form("fit_ampl[XTAL_C0_APD1] >> hist1");
    plot2.Form("fit_ampl[XTAL_C0_APD2] >> hist2"); //tag
    
    //Cut to look only within the specified slice 
    cut.Form("(X[0] > %f) && (X[1] > %f) && (X[0] < %f) && (X[1] < %f) && (Y[0] > %f) && (Y[1] > %f) && (Y[0] < %f) && (Y[1] < %f)", xmin, xmin + xOffset, xmax, xmax + xOffset, ymin, ymin, ymax, ymax);
    
    h4->Draw(plot1.Data(), cut.Data());
    h4->Draw(plot2.Data(), cut.Data());
    
    allFits->cd();
    hist1->Write("hist1");
    hist2->Write("hist2");
    
    float cutoff = hist1->GetMean() - 3*hist1->GetRMS(); //Designate a cutoff value for fit_ampl based on the previous plot
    cut.Form("(X[0] > %f) && (X[1] > %f) && (X[0] < %f) && (X[1] < %f) && (Y[0] > %f) && (Y[1] > %f) && (Y[0] < %f) && (Y[1] < %f) && (fit_ampl[XTAL_C0_APD1] > %f)", xmin, xmin + xOffset, xmax, xmax + xOffset, ymin, ymin, ymax, ymax, cutoff);
    long int entries1 = h4->Draw(plot1.Data(), cut.Data()); //Replot with fit_ampl restriction
    
    //Fit the plot with a Gaussian
    g1 = new TF1("g1", "gaus", hist1->GetMean() - 2*hist1->GetRMS(), hist1->GetMean() + 2*hist1->GetRMS());
    g1->SetParameters(1, hist1->GetMean(), hist1->GetRMS());
    g1->SetParLimits(1, hist1->GetMean() - hist1->GetRMS()/2, hist1->GetMean() + hist1->GetRMS()/2);
    g1->SetParLimits(2, hist1->GetRMS()/10, hist1->GetRMS()/2);
    hist1->Fit(g1, "RQME");
    
    //Fit the plot with a crystalball based on the Gaussian
    f1 = new TF1("f1","crystalball", hist1->GetMean() - 2*hist1->GetRMS(), hist1->GetMean() + 2*hist1->GetRMS());
    f1->SetParameters(1, g1->GetParameter(1), g1->GetParameter(2)/3, 1, .5);
    f1->SetParLimits(1, g1->GetParameter(1) - g1->GetParameter(2), g1->GetParameter(1) + g1->GetParameter(2));
    f1->SetParLimits(4, 0.1, 4);
    f1->SetParLimits(3, 0.1, 10);
    f1->SetParLimits(2, (g1->GetParameter(2))/10, g1->GetParameter(2)/2);
    hist1->Fit(f1, "RQME");
    
    //Attempt to refit if the first failed for some reason, such as a bad Gaussian fit
    if((f1->GetChisquare()/entries1 - 0.2132) > 1*0.03559){ //Using values from chi2 distribution on 6 6 2 run
      
      f1->SetParameter(1, hist1->GetMean());
      f1->SetParameter(2, hist1->GetRMS()/3);
      f1->SetParLimits(1, hist1->GetMean() - hist1->GetRMS()/2, hist1->GetMean() + hist1->GetRMS()/2);
      f1->SetParLimits(2, hist1->GetRMS()/10, hist1->GetRMS()/2);
      hist1->Fit(f1, "RQME");
      
      if((f1->GetChisquare()/entries1 - 0.2132) > 1*0.03559){
	badFits->cd();
	histname.Form("APD1_%d_%g_%g_%g_%g", i, xmin, xmax, ymin, ymax); //tag
	hist1->Write(histname.Data());
      }
      else{
      goodFits->cd();
      histname.Form("APD1_%d_%g_%g_%g_%g", i, xmin, xmax, ymin, ymax); //tag
      hist1->Write(histname.Data());
      }
    }
//.........这里部分代码省略.........
开发者ID:H4VFE,项目名称:PlotTools,代码行数:101,代码来源:resolution.cpp

示例3: main


//.........这里部分代码省略.........
    gSpec[a-START+(i)*NoChannels] = new TGraph(window_size/2, freq, spectrum[a-START+(i)*NoChannels]);
    gSpec[a-START+(i)*NoChannels]->SetTitle(title);
    gSpec[a-START+(i)*NoChannels]->GetXaxis()->SetTitle(" frequency / MHz ");
    gSpec[a-START+(i)*NoChannels]->GetYaxis()->SetTitle(" Amp ");
    canSpec[a-START+(i)*NoChannels] = new TCanvas();
    canSpec[a-START+(i)*NoChannels]->SetTitle(name);
    canSpec[a-START+(i)*NoChannels]->SetName(name);
    
   } //end over START STOP
  }//end for over kwindwo_size

  if(debug) cout << "end of loop over kwindow_size" << endl;
  
  TMultiGraph *mg = new TMultiGraph();
  mg->SetTitle("optimal window size");
  mg->SetName("mg");
  TLegend leg = TLegend(0.87,0.7,0.99,0.99);

  TMultiGraph *mg3 = new TMultiGraph();
  mg3->SetTitle("optimal window size");
  mg3->SetName("mg3");
  TLegend leg3 = TLegend(0.655779, 0.807692, 0.981156, 0.972028);
  
  for(int i=0; i<NoChannels; i++){
   sprintf(name,"gd_mean%02i",i+min_channel_id);
   gd_mean[i] = new TGraph(kwindow_size+1, d_ws, d_mean[i]);
   gd_mean[i]->SetTitle(name);
   gd_mean[i]->SetName(name);
   gd_mean[i]->SetLineColor(i+1);   
   gd_mean[i]->SetLineWidth(2);
   sprintf(title,"mean: channel %02i",i+min_channel_id);
   mg->Add(gd_mean[i]);
   leg.AddEntry(gd_mean[i],title,"L");
   gd_mean[i]->Write();
   
   sprintf(name,"gd_rms%02i",i+min_channel_id);
   gd_rms[i] = new TGraph(kwindow_size+1, d_ws, d_rms[i]);
   gd_rms[i]->SetTitle(name);
   gd_rms[i]->SetName(name);
   gd_rms[i]->SetLineColor(i+1);
   gd_rms[i]->SetLineStyle(2);
   gd_rms[i]->SetLineWidth(4);
   sprintf(title,"rms: channel %02i",i+min_channel_id);
   mg->Add(gd_rms[i]);
   leg.AddEntry(gd_rms[i],title,"L");
   gd_rms[i]->Write();
   
   sprintf(name,"gd_rms_wiht%02i",i+min_channel_id);
   gd_RMS_with[i] = new TGraph(kwindow_size+1, d_ws, d_RMS_with[i]);
   gd_RMS_with[i]->SetTitle(name);
   gd_RMS_with[i]->SetName(name);
   gd_RMS_with[i]->SetLineColor(i+1);
   gd_RMS_with[i]->SetLineStyle(2);
   gd_RMS_with[i]->SetLineWidth(4);
   sprintf(title,"RMS with RFISupp: channel %02i",i+min_channel_id);
   mg3->Add(gd_RMS_with[i]);
//   leg3.AddEntry(gd_RMS_with[i],title,"L");
   gd_RMS_with[i]->Write();

   sprintf(name,"gd_rms_wiht%02i",i+min_channel_id);
   gd_RMS_without[i] = new TGraph(kwindow_size+1, d_ws, d_RMS_without[i]);
   gd_RMS_without[i]->SetTitle(name);
   gd_RMS_without[i]->SetName(name);
   gd_RMS_without[i]->SetLineColor(i+1);
   gd_RMS_without[i]->SetLineWidth(2);
   sprintf(title,"RMS without RFISupp: channel %02i",i+min_channel_id);
开发者ID:lbaehren,项目名称:lofarsoft,代码行数:67,代码来源:OptWindowSize.cpp


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