Changeset 2e923bd in git for converters
- Timestamp:
- May 25, 2018, 1:29:32 PM (6 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 3874a9c
- Parents:
- 7d0eb75
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
converters/root2lhco.cpp
r7d0eb75 r2e923bd 107 107 //------------------------------------------------------------------------------ 108 108 109 LHCOWriter::LHCOWriter(ExRootTreeReader *treeReader, FILE *outputFile, string JetBranchName) :109 LHCOWriter::LHCOWriter(ExRootTreeReader *treeReader, FILE *outputFile, string jetBranchName) : 110 110 fTriggerWord(0), fEventNumber(1), fTreeReader(0), fOutputFile(0), 111 111 fBranchEvent(0), fBranchTrack(0), fBranchTower(0), fBranchPhoton(0), … … 128 128 fBranchMuon = fTreeReader->UseBranch("Muon"); 129 129 // reconstructed jets 130 fBranchJet = fTreeReader->UseBranch( JetBranchName.c_str());130 fBranchJet = fTreeReader->UseBranch(jetBranchName.c_str()); 131 131 // missing transverse energy 132 132 fBranchMissingET = fTreeReader->UseBranch("MissingET"); … … 436 436 //--------------------------------------------------------------------------- 437 437 438 pair<string,string> stringToOption(string s) { 439 440 string delimiter = "="; 441 442 vector<string> vs; 443 pair<string,string> res; 444 445 size_t pos = 0; 446 string token; 447 while ((pos = s.find(delimiter)) != std::string::npos) { 448 token = s.substr(0, pos); 449 //cout << token << std::endl; 450 vs.push_back(token); 451 s.erase(0, pos + delimiter.length()); 452 } 453 454 //std::cout << s << std::endl; 455 vs.push_back(s); 456 457 if (vs.size()==2){ 458 res.first=vs[0]; 459 res.second=vs[1]; 460 } 461 462 return res; 463 464 } 465 438 vector<string> ArgSplitter(char *arg) 439 { 440 string s = arg; 441 string delimiter = "="; 442 vector<string> result; 443 size_t first = 0, last = 0; 444 445 while((last = s.find(delimiter, first)) != string::npos) 446 { 447 result.push_back(s.substr(first, last - first)); 448 first = last + delimiter.length(); 449 } 450 451 result.push_back(s.substr(first, last)); 452 453 return result; 454 } 455 456 //--------------------------------------------------------------------------- 466 457 467 458 int main(int argc, char *argv[]) 468 459 { 460 int i, j; 469 461 char appName[] = "root2lhco"; 470 462 stringstream message; … … 474 466 ExRootTreeReader *treeReader = 0; 475 467 Long64_t entry, allEntries; 476 string JetBranchName="Jet"; 468 string jetBranchName = "Jet"; 469 vector<string> result; 477 470 478 471 if(argc < 2 || argc > 4) 479 472 { 480 cerr << " Usage: " << appName << " input_file" << " [output_file] 473 cerr << " Usage: " << appName << " input_file" << " [output_file] [--jet-branch=Jet]" << endl; 481 474 cerr << " input_file - input file in ROOT format," << endl; 482 475 cerr << " output_file - output file in LHCO format," << endl; 483 476 cerr << " with no output_file, or when output_file is -, write to standard output." << endl; 484 cerr << " in order to specify the jet-branch name the output_file cannot be omitted." << endl;485 477 return 1; 486 478 } 487 479 488 for(i nt iarg=3; iarg< argc ; iarg++){489 490 string argument=argv[iarg];491 pair<string,string> option; 492 option=stringToOption(argument); 493 494 if ( option.first == "--jet-branch" ) { 495 JetBranchName = option.second;496 cout << " Using the jet branch named " << JetBranchName << endl;497 }498 499 cout << " Using the default jet branch named " << JetBranchName << endl;500 480 for(i = 2; i < argc; ++i) 481 { 482 result = ArgSplitter(argv[i]); 483 484 if(result.size() == 2 && result[0] == "--jet-branch") 485 { 486 jetBranchName = result[1]; 487 for(j = i + 1; j < argc; ++j) argv[j - 1] = argv[j]; 488 --argc; 489 break; 490 } 491 } 492 cerr << "** Using the jet branch named " << jetBranchName << endl; 501 493 502 494 signal(SIGINT, SignalHandler); … … 539 531 { 540 532 // Create LHC Olympics converter: 541 writer = new LHCOWriter(treeReader, outputFile, JetBranchName);533 writer = new LHCOWriter(treeReader, outputFile, jetBranchName); 542 534 543 535 ExRootProgressBar progressBar(allEntries - 1);
Note:
See TracChangeset
for help on using the changeset viewer.