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


C++ TTree::ReadFile方法代码示例

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


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

示例1: r_sig

double r_sig(const char* f_inner, const char* f_outer)
{
  TTree *TDiIn = new TTree();
  TDiIn->ReadFile(f_inner, "di/D");
  TH1D *h_din = new TH1D("h_din", "", 10000, 0, 100);
  TDiIn->Draw("di>>h_din", "", "goff");
  Double_t d_inner = h_din->GetMean(1);
  Double_t sig_inner = h_din->GetMeanError(1);
  //  cout << "Mean Inner Diameter: " << d_inner  << " +/- " << sig_inner << endl;

  //  cout<< "Reading Outer Diameters..." << f_outer <<endl;
  TTree *TDiOut = new TTree();
  TDiOut->ReadFile(f_outer, "do/D");
  TH1D *h_dout = new TH1D("h_dout", "", 10000, 0, 100);
  TDiOut->Draw("do>>h_dout", "", "goff");
  Double_t d_outer = h_dout->GetMean(1);
  Double_t sig_outer = h_dout->GetMeanError(1);
  //  cout << "Mean Outer Diameter: " << d_outer << " +/- " << sig_outer << endl;

  double Ratio = d_inner/d_outer;
  double Sigma = Ratio*sqrt( pow((sig_inner/d_inner),2) + pow((sig_outer/d_outer),2)  );
  //  cout << Sigma << endl;
  h_din->Delete();
  h_dout->Delete();

  return Sigma;
}
开发者ID:tkrahulik,项目名称:analysis-ferromagnet,代码行数:27,代码来源:makePlot_uvB.C

示例2: treegraph

void treegraph(TString filename) {
   gROOT->SetStyle("Plain");
   gStyle->SetOptDate();


   Double_t x, y;
   Int_t nlines = 0;
   TFile *f = new TFile("graph.root","RECREATE");

   TCanvas *canvas_graph = new TCanvas("canvas_graph", "y vs x",467,89,400,700);

   TTree t;
   t.ReadFile(filename,"x:y");
   t.Draw("x:y","","goff");

   TGraph *g = new TGraph(t.GetSelectedRows(),t.GetV1(),t.GetV2());
   g->SetTitle(filename+": Y vs X");
   g->GetXaxis()->SetTitle("x[a.u.]");
   g->GetYaxis()->SetTitle("y[a.u.]");

   g->SetMarkerStyle(21);
   g->Draw("AP");

   f->Write();
}
开发者ID:bdorney,项目名称:TurboSoftware,代码行数:25,代码来源:treegraph.C

示例3: histogram

void histogram() {
	// Read data from ASCII file and create histogram/ntuple combo
	ifstream in;
 	in.open("/users/ronnie/git/Journal-Analysis/data.txt");

	Text_t month;
 	Float_t date, day, words;
	TFile *file = new TFile("histogramTest.root", "CREATE");
	TH1F *histo = new TH1F("histo", "writing distribution", 100, 0, 2);
	TTree *Tree = new TTree("ntuple", "data from file");
					
	Tree->ReadFile(Form("/users/ronnie/git/Journal-Analysis/Daily Journals/data.txt"), "month:date:day:words");
	graph = new TGraph(200, &words, &day);
	// Get the total number of words written and print out to CLI
	Tree->Print();
	Int_t numEntries = (Int_t)(Tree->GetEntries());
	TBranch *wordsBranch = Tree->GetBranch("words");
	for(Int_t i = 0; i < numEntries; i++) {
		Tree->GetEntry(i, 0);
	}
	// Draw the Tree (words vs. day) on canvas
	Tree->SetEstimate(Tree->GetEntries());
	Tree->Draw("words:day");
	// Have to loop back through drawn tree to get values and count number of words total
	Float_t numWords = 0.0;
	Double_t *array = Tree->GetV1();
	for (Int_t i = 0; i < numEntries; i++) {
		numWords += array[i];
	}
	cout << numWords << endl;
}
开发者ID:RonnieNigash,项目名称:Journal-Analysis,代码行数:31,代码来源:histogram.C

示例4: analyseFitToystudiesB0

void analyseFitToystudiesB0(string filename, bool justTau = false)
{
    fileprefix = "fitToyStudiesB0";
    TTree *t = new TTree;
    t->ReadFile(filename.c_str(),"tau:tau_err:mass_peak:mass_peak_err:m_sigma1:m_sigma1_err:m_sigma2:m_sigma2_err:frac_m_gauss:frac_m_gauss_err:core_frac:core_frac_err:tau_bk:tau_bk_err:n_nonprompt:n_nonprompt_err:n_prompt:n_prompt_err:n_signal:n_signal_err:prompt_p1:prompt_p1_err:prompt_sigma_core:prompt_sigma_core_err:prompt_sigma_tail:prompt_sigma_tail_err");

    if (!justTau)
    {
	plotPulls(t, "tau_pulls", "#tau(B^{0})", "tau", 1.529, 100, 5.0);
	plotPulls(t, "mass_pulls", "m(B^{0})", "mass_peak", 5.27950, 100, 5.0);
	plotPulls(t, "tau_bk_pulls", "#tau_{bgr}(B^{0})", "tau_bk", 0.750, 100, 5.0);
	plotPulls(t, "nsig_pulls", "n_{sig}", "n_signal", 6750, 100, 5.0);
	plotPulls(t, "npr_pulls", "n_{prompt}", "n_prompt", 3375, 100, 10);
	plotPulls(t, "nnpr_pulls", "n_{nonprompt}", "n_nonprompt", 1125, 100, 10);
    }

    plotHisto(t, "tau_histo", "#tau(B^{0})", "ps", "tau", 100, 1.30, 1.70);
    if (!justTau)
    {
	plotHisto(t, "mass_histo", "m(B^{0})", "GeV", "mass_peak", 100, 5.2785, 5.281);
	plotHisto(t, "tau_bk_histo", "#tau_{bgr}(B^{0})", "ps", "tau_bk", 100, 0.5, 0.9);
	plotHisto(t, "nsig_histo", "n_{sig}", "", "n_signal", 100, 6500, 7000);
	plotHisto(t, "npr_histo", "n_{prompt}", "", "n_prompt", 100, 2900, 3900);
	plotHisto(t, "nnpr_histo", "n_{nonprompt}", "", "n_nonprompt", 100, 950, 1450);
    }
}
开发者ID:frmeier,项目名称:usercode,代码行数:26,代码来源:analyseFitToystudies.C

示例5: plot_point

TGraphErrors* plot_point(
			     const TString infile,
			     double R,
			     double R_sig
			     )
{

  TTree *TData = new TTree();
  TData->ReadFile(infile, "t/D:x:y:z:B1:B1Range:B2:B2Range:B3:B3Range:V:T1:T2:T3:T4:T5:T6:T7:T8");

  TH1D *h = new TH1D("h", "", 10000, 0, 10000);
  TH1D *h2 = new TH1D("h2", "", 10000, 0, 10000);
  TData->Draw("TMath::Abs(B2)>>h", "", "goff");
  TData->Draw("TMath::Abs(B3)>>h2", "", "goff");

  vector<double> B_ext, B_in, Bratio, u, u_err, B_err;

  B_in.push_back(h2->GetMean(1));
  B_ext.push_back(h->GetMean(1));

  Bratio.push_back(B_in[0] / B_ext[0]);
  u.push_back( (Bratio[0]*(R**2) + Bratio[0] - 2 - 2*sqrt((Bratio[0]**2)*(R**2) - Bratio[0]*(R**2) - Bratio[0] + 1 ) ) / (Bratio[0]*(R**2) - Bratio[0]) );

  B_err.push_back( 0.00 );
  u_err.push_back( 0.00 );

  TGraphErrors *g_uvB = new TGraphErrors(u.size(), &B_ext[0], &u[0], &B_err[0], &u_err[0]);

  h->Delete();
  h2->Delete();

  return g_uvB;

}
开发者ID:SBU-NSL,项目名称:magcloak-analysis,代码行数:34,代码来源:makePlot_uvB_MRI.C

示例6: plot_uvB

/*
 * The Ferromagnet_Scan function reads in
 * a data file of magentic field scans
 * from within the ferromagnet and returns
 * a graph of the magnetic permeability
 * of the ferromagnet vs the external field
 * provided by the Helmholtz coil.
 */
TGraphErrors* plot_uvB(
			 const TString scan_file,
			 TF1* calib_fit,
			 double R,
			 double R_sig
)
{

  /*Read in Data File to ROOT Tree*/
  cout<< "processing file " << scan_file <<endl;
  TTree *TData = new TTree();
  TData->ReadFile(scan_file, "t/D:I:B");
  /*Use TTree Draw command to write branches to usable arrays*/
  int n = TData->Draw("I:TMath::Abs(B):0.0:0.005", "", "goff");

  vector<double> B_ext, B_in, Bratio, u;
  for(int i = 0; i < n; i++)
    {
      B_ext.push_back( calib_fit->Eval(TData->GetV1()[i]) );
      B_in.push_back( TData->GetV2()[i] );
      Bratio.push_back( B_in[i] / B_ext[i]);
      u.push_back( (Bratio[i]*(R**2) + Bratio[i] - 2 - 2*sqrt((Bratio[i]**2)*(R**2) - Bratio[i]*(R**2) - Bratio[i] + 1 ) ) / (Bratio[i]*(R**2) - Bratio[i]) );

    }

  TGraphErrors *g_uvB = new TGraphErrors(n, &B_ext[0], &u[0], TData->GetV3(), TData->GetV4());

  /*  
  g_uvB->Fit("pol1", "", "", 10, 60);
  cout << "Permeability at 50: " << g_uvB->GetFunction("pol1")->Eval(50) << endl;
  cout << "Permeability at 40: " << g_uvB->GetFunction("pol1")->Eval(40) << endl;
  cout << "Permeability at 30: " << g_uvB->GetFunction("pol1")->Eval(30) << endl;
  */
  return g_uvB;
}
开发者ID:tkrahulik,项目名称:analysis-ferromagnet,代码行数:43,代码来源:makePlot_uvB.C

示例7: DrawConsistency

void DrawConsistency()
{
  TFile * cons_file = new TFile("cons_file.root","RECREATE");
  TTree * tr = new TTree();
  // cons is run number or fill number, depending on what study you're doing
  tr->ReadFile("cons_study","cons/I:tbit/I:cbit/I:spinbit/I:p0/D:p0_err/D");
  tr->Write("tr");
}
开发者ID:c-dilks,项目名称:scalers11t,代码行数:8,代码来源:DrawConsistency.C

示例8: rads2Hist

void rads2Hist(){
  TFile * output_file = new TFile("RADS_Data.root", "RECREATE"); //Pointer to ROOT output file 
  TH1D * hist = new TH1D("hist", "Radiation Dosimetry with Altitude", 100, 0, 10000); //1D histogram of doubles
  TTree * t = new TTree("t", "RADS_Data"); //Pointer to tree to store data
  t->ReadFile("RADS_long.dat", "RAD_cpm/I"); // Add integer variable to tree called RAD_cpm
  t->Write(); //Write tree to ROOT file
  output_file->Close();
  
  
}
开发者ID:chroli1,项目名称:RADS_Data_Analysis,代码行数:10,代码来源:rads2Hist.C

示例9: basic2

void basic2() {
   TString dir = gROOT->GetTutorialsDir();
   dir.Append("/tree/");
   dir.ReplaceAll("/./","/");

   TFile *f = new TFile("basic2.root","RECREATE");
   TH1F *h1 = new TH1F("h1","x distribution",100,-4,4);
   TTree *T = new TTree("ntuple","data from ascii file");
   Long64_t nlines = T->ReadFile(Form("%sbasic.dat",dir.Data()),"x:y:z");
   printf(" found %lld points\n",nlines);
   T->Draw("x","z>2");
   T->Write();
}
开发者ID:Y--,项目名称:root,代码行数:13,代码来源:basic2.C

示例10: treeFromAscii

void treeFromAscii(const char* filen) {

//  Read data from an ascii file and create a root file with a tree

  std::string rFile( filen ) ;
  rFile += ".root" ;
  TFile *f = new TFile( rFile.c_str() ,"RECREATE");

  TTree*  ntuple = new TTree("ntuple","") ;
  ntuple->ReadFile( filen ) ;
  
  f->Write() ;
  f->Close() ;
}
开发者ID:iLCSoft,项目名称:GEAR,代码行数:14,代码来源:treeFromAscii.C

示例11: RampCorrellation_single

int RampCorrellation_single(std::string file_name, TGraphErrors &graph, TGraphErrors &graph2, vector<double> &vec_errors)
{

	TTree *t = new TTree();
	const std::string file_path = "/home/jlab/github/MagCloak_Analysis/calibration/data-calib/DATA_MegaVIEW/";
//	std::string file_name = "DataFile_2016-12-08_06-59-11.csv";
	std::string file = file_path+file_name;

	t->ReadFile(file.c_str());
//	t->Print();

	TCanvas *c = new TCanvas();
	t->Draw("TMath::Abs(B1/B2):time");
	TGraph *gh = (TGraph*)c->GetListOfPrimitives()->FindObject("Graph");
	double ratio_mean = gh->GetMean(2);
	double ratio_std = gh->GetRMS(2);

	t->Draw("Bnom:time");
	TGraph *gh1 = (TGraph*)c->GetListOfPrimitives()->FindObject("Graph");
	double nom_mean = gh1->GetMean(2);
	double nom_std = 0;

//	cout << "At " << nom_mean << " mT, B1/B2 is: " << ratio_mean << " +/- " << ratio_std << endl;
	
	c->Close();

	int n = graph.GetN();
	graph.SetPoint(n,nom_mean,ratio_mean);
	graph.SetPointError(n,nom_std,ratio_std);

//-------------------------------------------------------------------------------

	TCanvas *c2 = new TCanvas();
	t->Draw("B3:time");
	TGraph *gh2 = (TGraph*)c2->GetListOfPrimitives()->FindObject("Graph");
	double B3_mean = -1*(gh2->GetMean(2));
	double B3_std = gh2->GetRMS(2);
	
	int n2 = graph2.GetN();
	graph2.SetPoint(n2, nom_mean, B3_mean);
	graph2.SetPointError(n2, nom_std, B3_std);
	
	c2->Close();

	if(nom_mean < 500) vec_errors.push_back(B3_std);

	return 0;
}
开发者ID:SBU-NSL,项目名称:magcloak-analysis,代码行数:48,代码来源:SteadyStateCorrellation.C

示例12: TTree

plot_cluster_vs_run()
{

  TTree *tin = new TTree();
  tin->ReadFile("summaries/allruns_Run13pp510MinBias_cluster.txt","run/I:cluster/F");

  TCanvas *c1 = new TCanvas();
  tin->Draw("cluster");
  c1->Print("plots/cluster_per_event_hist.eps");
  c1->Print("plots/cluster_per_event_hist.png");

  TCanvas *c2 = new TCanvas();
  tin->Draw("cluster:Entry$");
  c2->Print("plots/cluster_per_event_graph.eps");
  c2->Print("plots/cluster_per_event_graph.png");

}
开发者ID:nfeege,项目名称:phenix-directphotons-pp,代码行数:17,代码来源:plot_cluster_vs_run.C

示例13: Calibrate

/*
 * The Calibration function reads in the
 * calibration file and returns a graph
 * that is used to find the relation
 * between current and magentic field
 * for the Helmholtz coil.
 */
TF1* Calibrate(
		    const char* f_calib
		    )
{
  /*Read in Calibration File*/
  cout<< "processing file " << f_calib <<endl;
  TTree *TCalib = new TTree();
  TCalib->ReadFile(f_calib, "t/D:I:B");
  int n = TCalib->Draw("I:TMath::Abs(B)", "", "goff");
  TGraph *g_calib = new TGraph(n, TCalib->GetV1(), TCalib->GetV2() );
  g_calib->SetTitle("");
  // g_calib->Draw("AP");
  g_calib->Fit("pol1", "q");
  TF1* calib_fit = g_calib->GetFunction("pol1");

  return calib_fit;

}
开发者ID:tkrahulik,项目名称:analysis-ferromagnet,代码行数:25,代码来源:makePlot_uvB.C

示例14: getTheoXSec

TGraphErrors* getTheoXSec(TString file) {
    TTree t;

    t.ReadFile(file);

    TGraphErrors *g = new TGraphErrors(t.GetEntries());

    float m,x,e;
    t.SetBranchAddress("mass",&m);
    t.SetBranchAddress("xsec",&x);
    t.SetBranchAddress("err",&e);


    int iEntry=-1;
    while(t.GetEntry(++iEntry)) {
        g->SetPoint(iEntry,m,x);
        g->SetPointError(iEntry,0,e);
    }
    return g;
}
开发者ID:RazorCMS,项目名称:HggApp,代码行数:20,代码来源:getTheoXSec.C

示例15: PlotFromMillepedeRes

void PlotFromMillepedeRes(TString strMillepedeRes, TString strOutdir, TString strVars, int plotType)
{
  // strPar = "u", "v", "w", "alpha", "beta", "gamma", "def1", "def2", "def3"
  TFile* f = new TFile(strOutdir+TString("fOut.root"),"recreate");
  TTree* tr = new TTree("tr","tr");
  tr->ReadFile(strMillepedeRes,strVars);

  if (plotType==PARSwithERRvsLABEL)
    PlotParValVsLabelWithErr(f, tr, strMillepedeRes, strOutdir);

  if (plotType==NHITS)
    PlotHistsNhitsPerModule(f, tr, strMillepedeRes, strOutdir);

  if (plotType==PULLS)
    PlotPullsDistr(f, tr, strMillepedeRes, strOutdir);

  if (plotType==PARS)
    PlotParsDistr(f, tr, strMillepedeRes, strOutdir);

}// end of PlotPars
开发者ID:ANSH0712,项目名称:cmssw,代码行数:20,代码来源:PlotFromMillepedeRes.C


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