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


C++ TFile::ReadAll方法代码示例

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


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

示例1: openFile

void MainWindow::openFile() {
    int i;

    QString qstr;

    if(_filename.empty()) {
        qstr = QFileDialog::getOpenFileName(this,"Choose ROOT file","/","*.root");
        _filename = qstr.toStdString();
    }
    else {
        qstr = QFileDialog::getOpenFileName(this,"Choose ROOT file",QString::fromStdString(_filename),"*.root");
        _filename = qstr.toStdString();
    }

    if(_filename.empty()) {
        return;
    }

    setWindowTitle(QString::fromStdString("AmViewer (" + _filename + ")"));

    TFile *f = new TFile(_filename.c_str());
    f->ReadAll();

    TAmRun *amRun = NULL;

    amRun = AMBER::GetRunFromFile(f);

    // will use this as indicator for whether or not in 'analysis mode' in other parts of program
    _state->recon_tree = NULL;

    if(amRun == NULL) {
        // Means that this is a root file which contains candidate events. So we're in 'analysis mode'

        _analysisDrop->setEnabled(true);
        _saveMenu->setEnabled(true);

        _state->recon_tree = (TTree*)f->Get("recon_tree"); // cast might be superfluous
        _state->amevTree = (TAmEvTree*)f->Get("candidate_tree");

        int totalEvents = _state->amevTree->GetEntries();

        // clear tree widget
        _eventList->clear();

        // create a dynamic array based on upper bound of number of runs
        QTreeWidgetItem *run_source[totalEvents];

        // variables for putting events under the correct run number
        unsigned int prev_run = 0;
        int j = 0;

        QTreeWidgetItem *event;
        stringstream out,out2;

        string runtitle;

        for(i=0; i<totalEvents; i++) {
            // OK, SHIT. REMEMBER eventNum is the number according to the FILE **not** AMBER
            _state->eventNum = i;
            _state->update_recon();

            if(_state->run_num == prev_run) {
                event = new QTreeWidgetItem(run_source[j-1]);
                out.str("");
                out2.str("");
                out << setprecision(8) << setw(8) << _state->event_num;
                out2 << i;
                event->setText(0,QString::fromStdString(out.str()));
                event->setText(1,QString::fromStdString(out2.str()));
                prev_run = _state->run_num;
            }
            else {
                run_source[j] = new QTreeWidgetItem(_eventList);
                out.str("");
                out << setprecision(8) << setw(8) << _state->run_num;
                runtitle = "Run" + out.str();
                run_source[j]->setText(0,QString::fromStdString(runtitle));
                event = new QTreeWidgetItem(run_source[j]);
                out.str("");
                out2.str("");
                out << setprecision(8) << setw(8) << _state->event_num;
                out2 << i;
                event->setText(0,QString::fromStdString(out.str()));
                event->setText(1,QString::fromStdString(out2.str()));
                j++;
                prev_run = _state->run_num;
            }
        }

        _eventList->sortItems(0,Qt::AscendingOrder); //maybe check that 2nd arg
        _eventList->setColumnHidden(1,true);

        _eventList->setHeaderLabel("Candidate Events");

        connect(_eventList,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(getEvent(QTreeWidgetItem*)));

        // make an info window, if one doesn't exist
        if(_infoWindow==NULL) {
            _infoWindow = new InfoWindow(_state);
        }
//.........这里部分代码省略.........
开发者ID:nategri,项目名称:AMBER,代码行数:101,代码来源:MainWindow.cpp

示例2: main

int main(int argc, char** argv) {
  // first read in AMBER calibrations
  ifstream calibfile("amcalibration.dat");
  double amcalib[16][3];
  for(int i=0; i<16; i++) {
    calibfile >> amcalib[i][0] >> amcalib[i][1] >> amcalib[i][2];
  }
  calibfile.close();



  TFile *f = new TFile(argv[1]);
  f->ReadAll();

  TAmRun *amRun = NULL;

  amRun = AMBER::GetRunFromFile(f);

  //if(amRun == NULL) {
    //cout << "Incorrect filetype. Please select an AMBER candidate file as input." << endl;
    //return 1;
  //}

  TTree *recon_tree = (TTree*)f->Get("recon_tree"); 
  TAmEvTree *amev_tree = (TAmEvTree*)f->Get("candidate_tree");

  gFile = NULL;

  int total_events = amev_tree->GetEntries();

  // stuff we're gonna need to grab AMBER events later in the loop
  TAmEvent *amev = new TAmEvent;
  amev_tree->SetBranchStatus("*",1);
  amev_tree->SetBranchAddress("event",&amev);

  // whole lotta crap relevant to the reconstruction tree
  double phi;
  double theta;
  double psi;
  double time;
  double entry_time;
  double exit_time;
  double entry_gcmsq;
  double exit_gcmsq;
  double los_dist;
  double impact_param;
  double ntanks;
  unsigned int run_num;
  unsigned int event_num;

  double time_delta;

  double offset[17];
  double timecross[17];

  double phimin, phimax;
  double thetamin, thetamax;
  double psimin, psimax;
  double timemin, timemax;
  double time_deltamin, time_deltamax;
  double entry_gcmsqmin, entry_gcmsqmax;
  double exit_gcmsqmin, exit_gcmsqmax;
  double los_distmin, los_distmax;
  double impact_parammin, impact_parammax;
  int ntanksmin, ntanksmax;

  double alt, northing, easting;

  double energy;
  double p_lo_C[17];
  double gcmsq_entry_C[17];
  double gcmsq_exit_C[17];
  p_lo_C[0] = 0;

  recon_tree->SetBranchAddress("phi",&phi);
  recon_tree->SetBranchAddress("theta",&theta);
  recon_tree->SetBranchAddress("psi",&psi);
  recon_tree->SetBranchAddress("time",&time);
  recon_tree->SetBranchAddress("offsetC3",&offset[3]);
  recon_tree->SetBranchAddress("offsetC1",&offset[1]);
  recon_tree->SetBranchAddress("offsetC4",&offset[4]);
  recon_tree->SetBranchAddress("offsetC2",&offset[2]);
  recon_tree->SetBranchAddress("entry_time",&entry_time);
  recon_tree->SetBranchAddress("exit_time",&exit_time);
  recon_tree->SetBranchAddress("entry_gcmsq",&entry_gcmsq);
  recon_tree->SetBranchAddress("exit_gcmsq",&exit_gcmsq);
  recon_tree->SetBranchAddress("los_dist",&los_dist);
  recon_tree->SetBranchAddress("impact_param",&impact_param);
  recon_tree->SetBranchAddress("ntanks",&ntanks);
  recon_tree->SetBranchAddress("timecrossC3",&timecross[3]);
  recon_tree->SetBranchAddress("timecrossC1",&timecross[1]);
  recon_tree->SetBranchAddress("timecrossC4",&timecross[4]);
  recon_tree->SetBranchAddress("timecrossC2",&timecross[2]);

  recon_tree->SetBranchAddress("offsetC11",&offset[11]);
  recon_tree->SetBranchAddress("offsetC12",&offset[12]);
  recon_tree->SetBranchAddress("offsetC13",&offset[13]);
  recon_tree->SetBranchAddress("offsetC14",&offset[14]);
  recon_tree->SetBranchAddress("offsetC15",&offset[15]);
  recon_tree->SetBranchAddress("offsetC16",&offset[16]);
//.........这里部分代码省略.........
开发者ID:nategri,项目名称:AMBER,代码行数:101,代码来源:mu_estimator.cpp

示例3: tempnamestr


//.........这里部分代码省略.........
  }
  if(tempnamestr == "C10_temps.out") {
    horn_id = 14;
  }
  if(tempnamestr == "C11_temps.out") {
    horn_id = 20;
  }
  if(tempnamestr == "C12_temps.out") {
    horn_id = 21;
  }
  if(tempnamestr == "C13_temps.out") {
    horn_id = 22;
  }
  if(tempnamestr == "C14_temps.out") {
    horn_id = 28;
  }
  if(tempnamestr == "C15_temps.out") {
    horn_id = 29;
  }
  if(tempnamestr == "C16_temps.out") {
    horn_id = 30;
  }

  cout << "horn id: " << horn_id << endl;

  // open temperature file, load into arrays and create interpolation
  ifstream temps_input(temps_name);

  double toss1,toss2,toss3,toss4;

  int i,j;

  for(i=0;i<1;i++) {
    temps_input >> toss1;
    //cout << toss1 << endl;
    for(j=0;j<215;j++) {
      temps_input >> time_arr[i][j] >> toss2 >> toss3 >> temp_arr[i][j] >> toss4;
    }
  }

  // set up interpolation
  for(i=0;i<1;i++) {
    _acc[i] = gsl_interp_accel_alloc();
    _spline[i] = gsl_spline_alloc(gsl_interp_cspline,215);
    gsl_spline_init(_spline[i],time_arr[i],temp_arr[i],215);
  }

  // read in list of root files to use for fit
  string filename[N_HSK];
  ifstream flist("rootfiles.list");
  for(i=0;i<N_HSK;i++) {
    getline(flist,filename[i]);
    cout << filename[i] << endl;
    if(filename[i].find('#') != string::npos) {
      i--;
      cout << "Line ignored in list" << endl;
    }
  }

  // open AMBER housekeeping files, set histogram pointers
  for(i=0;i<N_HSK;i++) {
    
    TFile* f = new TFile(filename[i].c_str());

    f->ReadAll();
    TAmHskTree* amhsk = AMBER::GetHousekeepingFromFile(f);

    _amhsk_hist[i] = amhsk->GetPercentRfpRaw(0.0,100.0,(AMBER::eChannelId) horn_id);
    cout << setprecision(10) << "Starts at: " <<  _amhsk_hist[i]->GetXaxis()->GetBinCenter(1) << endl;

    // how many days is the offset from "orginal" day?
    int d_int;
    double day_diff = (_amhsk_hist[i]->GetXaxis()->GetBinCenter(1) - 1331618356/*_amhsk_hist[0]->GetXaxis()->GetBinCenter(1)*/)/86400;
    d_int = (int) (day_diff+0.5);
    //cout << day_diff << " " << d_int << " " << fabs(day_diff-d_int) << endl;
    if(i>=0) {
      if( fabs(day_diff-d_int) < 0.01 ) {
	      _n_days[i] = d_int;
      }
      else {
	      cout << "Error: " << filename[i] << ": Not an integer number of day offset from 'original' file" << endl;
	      cout << "File is this many days off from last: ";
	      cout << (_amhsk_hist[i]->GetXaxis()->GetBinCenter(1) - _amhsk_hist[i-1]->GetXaxis()->GetBinCenter(1))/86400 << endl;
	      exit(EXIT_FAILURE);
      }
    }
    //else {
    //n_days[0] = 0;
    //}

    //cout << "I worked!" << endl;

    //delete f;
    f->Close();
  }

  //for(int k=0; k<N_HSK; k++) {
  //  cout << _n_days[k] << endl;
  //}
}
开发者ID:nategri,项目名称:AMBER,代码行数:101,代码来源:amfitter.cpp


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