本文整理汇总了C++中TNamed::SetNameTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ TNamed::SetNameTitle方法的具体用法?C++ TNamed::SetNameTitle怎么用?C++ TNamed::SetNameTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TNamed
的用法示例。
在下文中一共展示了TNamed::SetNameTitle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
titles.push_back(first_line.substr(index+1));
}
else{
std::stringstream stream;
if(i < 9){ stream << "line00" << i+1; }
else if(i < 99){ stream << "line0" << i+1; }
else{ stream << "line" << i+1; }
names.push_back(stream.str());
titles.push_back(first_line);
}
}
}
/*for(int i = 0; i < names.size(); i++){
char *cstr1 = new char[names[i].length()+1];
for(int j = 0; j < names[i].length(); j++){
cstr1[j] = names[i].at(j);
//std::cout << names[i][j] << "\t" << cstr1[j] << std::endl;
}
cstr1[names[i].length()] = '\0';
std::cout << names[i].length() << "\t" << strlen(cstr1) << std::endl;
printf("cstr1: %s\n", cstr1);
char *cstr2 = new char[titles[i].length()+1];
for(int j = 0; j < titles[i].length(); j++){
cstr2[j] = titles[i][j];
}
cstr2[titles[i].length()] = '\0';
delete[] cstr1;
delete[] cstr2;
}*/
// Get the number of columns
std::getline(input_file, first_line);
if(input_file.eof() || !input_file.good()){
input_file.close();
output_file->Close();
return 1;
}
std::vector<std::string> column_names;
num_columns = count_columns(first_line, column_names, delimiter);
std::cout << " Found " << num_columns << " columns of data\n";
std::string bname;
float *vars = new float[num_columns];
for(int i = 0; i < num_columns; i++){
vars[i] = 0.0;
}
if(!use_column_names){
input_file.seekg(-first_line.size(), std::ios::cur);
for(int i = 0; i < num_columns; i++){
std::stringstream stream;
if(i < 10){ stream << "Col0" << i; }
else{ stream << "Col" << i; }
tree->Branch(stream.str().c_str(),&vars[i]);
}
}
else{ // Extract column names from data
for(int i = 0; i < num_columns; i++){
tree->Branch(column_names[i].c_str(),&vars[i]);
}
}
while(true){
// Get a line of data
if(count % 10000 == 0 && count != 0){ std::cout << " Line " << count << " of data file\n"; }
if(count+1 <= last_skip_line && is_in(skip_lines, ++count)){ continue; }
for(int i = 0; i < num_columns; i++){
input_file >> vars[i];
}
if(input_file.eof() || !input_file.good()){ break; }
// Fill all branches
tree->Fill();
count++;
}
output_file->cd();
TNamed *named = new TNamed();
std::vector<std::string>::iterator iter1, iter2;
for(iter1 = names.begin(), iter2 = titles.begin(); iter1 != names.end() && iter2 != titles.end(); iter1++, iter2++){
named->SetNameTitle(iter1->c_str(), iter2->c_str());
named->Write();
}
tree->Write();
std::cout << " Found " << count << " entries in " << num_columns << " columns\n";
std::cout << " Generated file " << fname << ".root\n";
input_file.close();
output_file->Close();
delete[] vars;
return 0;
}