12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <string>
- #include <TChain.h>
- #include <TString.h>
- int main(int argc, char** argv)
- {
- TString iFileName, iTreeName;
- if (argc < 5){
- std::cerr << "./get_dca -i filelist --tree-name TreeName" << std::endl;
- return 1;
- }
- for (int i=1; i<argc; i++){
- if(std::string(argv[i]) != "-i" &&
- std::string(argv[i]) != "--tree-name"){
- std::cerr << "\n[ERROR]: Unknown parameter " << i << ": " << argv[i] << std::endl;
- return 1;
- } else {
- if(std::string(argv[i]) == "-i" && i!=argc-1) {
- iFileName = argv[++i];
- continue;
- }
- if(std::string(argv[i]) == "-i" && i==argc-1) {
- std::cerr << "\n[ERROR]: Input file name was not specified " << std::endl;
- return 1;
- }
- if(std::string(argv[i]) == "--tree-name" && i!=argc-1) {
- iTreeName = argv[++i];
- continue;
- }
- if(std::string(argv[i]) == "--tree-name" && i==argc-1) {
- std::cerr << "\n[ERROR]: Tree name was not specified " << std::endl;
- return 1;
- }
- }
- }
- std::cout << "Processing count-data..." << std::endl;
- std::ifstream infile(iFileName.Data());
- std::string line;
- TChain *chain = new TChain(iTreeName.Data());
- int iFiles = 0;
- while (std::getline(infile, line))
- {
- chain->Add(line.c_str());
- iFiles++;
- }
- std::cout << iFiles << " files were processed." << std::endl;
- std::cout << "Total number of events:" << std::endl;
- Long64_t nEntries = chain->GetEntries();
- std::cout << nEntries << std::endl;
- std::cout << std::endl;
- return 0;
- }
|