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


C++ TString::Clear方法代码示例

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


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

示例1: analysis_variables

Fit3D::Fit3D(
    TString input_ntuple_file,
    TString analysis_name,
    TString x_axis_label,
    TString x_axis_unit,
    double min_x_bin_edge,
    double max_x_bin_edge,
    TString y_axis_label,
    TString y_axis_unit,
    double min_y_bin_edge,
    double max_y_bin_edge,
    TString z_axis_label,
    TString z_axis_unit,
    double min_z_bin_edge,
    double max_z_bin_edge)
  : DileptonEvents(input_ntuple_file, analysis_name)
{
  std::cout << "Initiliazing Fit3D class." << std::endl;
  
  output_path_
      = "/home/matt/research/belle/adcab/analysis/DileptonEvents/Fit3D/output/"
      + analysis_name + "/";
  
  boost::filesystem::path output_dir(output_path_);
  
  if (boost::filesystem::exists(output_dir)) {
    cout << "Output path exists. Overwriting directory contents!\n";
  } else {
    cout << "Output path does not exist. Creating new directory.\n";
    boost::filesystem::create_directories(output_dir);
  }
  
  // Remove information about moving files. Really, all RooMsgService streams
  //   should be sent to a debug log.
  RooMsgService::instance().getStream(1).removeTopic(RooFit::ObjectHandling);
  RooMsgService::instance().getStream(1).removeTopic(RooFit::Plotting);
  RooMsgService::instance().getStream(0).removeTopic(RooFit::Minimization);
  RooMsgService::instance().getStream(1).removeTopic(RooFit::Minimization);

  // Define the data set elements and add them to the dataset.
  x_variable_ = new RooRealVar(
      "x_variable", x_axis_label, min_x_bin_edge, max_x_bin_edge, x_axis_unit);
  y_variable_ = new RooRealVar(
      "y_variable", y_axis_label, min_y_bin_edge, max_y_bin_edge, y_axis_unit);
  z_variable_ = new RooRealVar(
      "z_variable", z_axis_label, min_z_bin_edge, max_z_bin_edge, z_axis_unit);
  x_variable_->setBins(20);
  y_variable_->setBins(20);
  z_variable_->setBins(20);
  std::cout << "Adding new columns to dataset." << std::endl;
  RooArgSet analysis_variables(*x_variable_, *y_variable_, *z_variable_);
  data_set_->printArgs(cout);
  std::cout << std::endl;
  recreateDataSet(analysis_variables);
  data_set_->printArgs(cout);
  std::cout << std::endl;
  
  // Construct the histograms.
  TString name;
  name.Clear();
  histograms_.clear();

  for (int i = 0; i < tags_.species_.size(); ++i) {
    HistogramListOverEventSigns event_sign_histograms;
    event_sign_histograms.clear();
    for (int j = 0; j < tags_.signs_.size(); ++j) {
      HistogramListOverComponents component_histograms;
      component_histograms.clear();
      for (int k = 0; k < tags_.components_.size(); ++k) {
        name.Append(tags_.species_[i]);
        name.Append("_");
        name.Append(tags_.signs_[j]);
        name.Append("_");
        name.Append(tags_.components_[k]);
        TH3D component_histogram(name, name, 
            x_variable_->getBins(), min_x_bin_edge, max_x_bin_edge,
            y_variable_->getBins(), min_y_bin_edge, max_y_bin_edge, 
            z_variable_->getBins(), min_z_bin_edge, max_z_bin_edge);
        component_histograms.push_back(component_histogram);
        name.Clear();
      }
      event_sign_histograms.push_back(component_histograms);
    }
    histograms_.push_back(event_sign_histograms);
  }
}
开发者ID:mpbelhorn,项目名称:adcab_analysis,代码行数:86,代码来源:Fit3D.cpp

示例2: Store

//============================================================
// <T>将一行保存至文件。</T>
//
// @param out 文件输出流。
//============================================================
void FCsvLine::Store(TDataOutput& out){
   TString csvCell;
   TString csvLine;
   TInt count = _pCells->Count();
   for(TInt n = 0; n < count; n++){
      csvCell.Clear();
      TString tempCell;
      TStringRefer cell = _pCells->Get(n);
      TInt cellLength = cell.Length();
      // 不允许空的格
      MO_ASSERT( 0 != cellLength);
      // 处理双引号
      TInt start = 0;
      TInt index = cell.IndexOf('"');
      if(ENotFound != index){
         while(ENotFound != index){
            index++;
            tempCell.Append(cell.SubStrC(start, index));
            // 不以引号开头或结尾
            if(index != 1 && index != cellLength){
               tempCell.Append('"');
            }else{
               tempCell.Append('"');
               tempCell.Append('"');
            }
            start = index;
            if(start < cellLength){
               index = cell.IndexOf('"', start);
            }else{
               break;
            }
         }
         // 拷贝余下内容
         if(start < cellLength - 1){
            tempCell.Append(cell.SubStrC(start, cell.Length()));
         }
      }else{
         tempCell = cell;
      }
      // 处理逗号
      TInt tempCellLen = tempCell.Length();
      if(tempCell.Contains(',')){
         // 不以“开头
         if(tempCell[0] != '"'){
            csvCell.Append('"');
         }
         csvCell.Append(tempCell);
         // 不以“结尾
         if(tempCell[tempCellLen  -1] != '"'){
            csvCell.Append('"');
         }
      }else{
         csvCell = tempCell;
      }
      // 处理换行符
      TInt csvCellLen = csvCell.Length();
      TInt lfStart = 0;
      TInt lfIndex = csvCell.IndexOf('\n');
      if(ENotFound != lfIndex){
         while(ENotFound != lfIndex){
            //  拷贝换行符前面的内容
            if(lfStart < lfIndex){
               TString sub = csvCell.SubStrC(lfStart, lfIndex);
               csvLine.Append(sub);
            }
            csvLine.Append('\\');
            csvLine.Append('n');
            // 跳过换行符
            lfIndex++;
            lfStart = lfIndex;
            if(lfStart < csvCellLen){
               lfIndex = csvCell.IndexOf('\n', lfStart);
            }else{
               break;
            }  
         }
         if(lfStart < csvCellLen - 1){
            TString sub = csvCell.SubStrC(lfStart, csvCell.Length());
            csvLine.Append(sub);
         }
      }else{
         csvLine.Append(csvCell);
      }
      // 一格格式化结束
      if((count - 1) == n){
         csvLine.Append('\n');
      }else{
         csvLine.Append(',');
      }  
   }
   out.Write((TCharC*)csvLine, csvLine.Length());
}
开发者ID:liveqmock,项目名称:MoCross,代码行数:97,代码来源:FCsvLine.cpp


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