Created
August 1, 2016 21:15
-
-
Save jdbrice/f79eda8e17b50022c01766a98dfae4f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <map> | |
| #include <unordered_map> | |
| #include <vector> | |
| map<int, bool> runNumbers; | |
| vector<int> runNumbersInFile( string fn ) { | |
| TFile * f = new TFile( fn.c_str(), "READ" ); | |
| TTreeReader reader( "tof", f ); | |
| TTreeReaderValue<Int_t> runId( reader, "run" ); | |
| unordered_map< Int_t, bool > unqRuns; | |
| while( reader.Next() ) { | |
| unqRuns[ *runId ] = true; | |
| } | |
| f->Close(); | |
| vector<int> runNums; | |
| for ( auto kv : unqRuns ){ | |
| runNums.push_back( kv.first ); | |
| } | |
| return runNums; | |
| } | |
| void runMapMaker( string filelist = "filelist_period1.lis" ){ | |
| ifstream inf( filelist.c_str() ); | |
| std::string line =""; | |
| while( getline( inf, line ) ){ | |
| // cout << "filename : " << line << endl; | |
| vector<int> rns = runNumbersInFile( line ); | |
| for ( int rn : rns ){ | |
| runNumbers[ rn ] = true; | |
| } | |
| } | |
| int iRun = 0; | |
| for ( auto kv : runNumbers ){ | |
| cout << "runMap[ " << kv.first << " ] = " << iRun << ";" << endl; | |
| iRun++; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment