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


C++ TNtuple::Clone方法代码示例

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


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

示例1: newData

DataFile::GetData(){
  stringstream convert;
  int nameVal = 0;
  convert.str(filename);
  convert >> nameVal;
  bool success = false;
  //Find file type
  string type = "";
  size_t pos = filename.find_last_of('.');
  if(gType.compare("XS")==0){
    TNtuple newData ("newData","", cols.c_str() );
    newData.ReadFile(name.c_str());
    cout<<"TNtuple created"<<endl;
    dataTuple = (TNtuple*) newData.Clone();
    cout<<name.c_str()<<endl;
    cout<<dataTuple<<endl;
    success = true;
  }
  else{
    if(pos != string::npos){
      if(filename[pos+1] == 'r'){
        if(filename[pos-1] == 'e'){
          type.assign("ginuke");
        }
        else{
          type.assign("gst");
        }
      }
      else{
        type.assign("txt");
      }
    }
    else{
      type.assign("chain");
    }
    if(type[0]!='t'){
      if(type[0]=='g'){
        //Normal .ginuke file, Easy
        file = new TFile(name.c_str());
        if(file->IsOpen()){
          TTree* dummy = file->Get(type.c_str());
          dataTree = (TTree*)dummy->Clone(); 
          delete dummy;
          success=true;
        }
        else{
          cout<<name.c_str()<<" was not found. Skipping [GENIE] tag."<<endl;
          success=false;
        }
      }
      //Chaining together some files
      else{
        TChain chain("ginuke");
        TChain* dummy = &chain;
        //Need to have name separate from directory in order to properly construct this filename.
        string n = dir+"/gntp.*"+filename+"*.ginuke.root";
        cout<<"Making a chain called "<<n<<endl;
        chain.Add(n.c_str());
        cout<<"Chain created."<<endl;
        dataTree = (TTree*)dummy->Clone();
        cout<<"dummy cloned"<<endl;
        success=true;
      }
    }
    else{
      //Grabbing simple data from the text file
      dataTree = new TTree("textData",title.c_str());
      int nCol = this->analyzeTextFile();
      success = true;
      if(gType.compare("Energy")==0){
        if(nCol==3){dataTree->ReadFile(name.c_str(),"E/D:xsec:err1");}
        else if(nCol==2){dataTree->ReadFile(name.c_str(),"E/D:xsec");}
        else{cout<<"Published data file has an unrecognized format."<<endl;
             success=false;}
      }
      if(gType.compare("Momentum")==0){
        if(nCol==3){dataTree->ReadFile(name.c_str(),"ph/D:xsec:err1");}
        else if(nCol==2){dataTree->ReadFile(name.c_str(),"ph/D:xsec");}
        else{cout<<"Published data file has an unrecognized format."<<endl;
             success=false;}
      }
      if(gType.compare("Angle")==0){
        if(nCol==3){dataTree->ReadFile(name.c_str(),"cth/D:xsec:err1");}
        else if(nCol==2){dataTree->ReadFile(name.c_str(),"cth/D:xsec");}
        else{cout<<"Published data file has an unrecognized format."<<endl;
             success=false;}
      }
    }
  }

  return success;
}
开发者ID:JJones99,项目名称:GENIE,代码行数:92,代码来源:rootgINukeVal.C


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