Commit 6ef7e04f authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Adapt BasicAFP to be able to take conf files with a list of input files

parent 8b9082ad
...@@ -68,6 +68,12 @@ Bool_t BasicAFP::NewFile() ...@@ -68,6 +68,12 @@ Bool_t BasicAFP::NewFile()
std::cout << " -BasicAFP: the input file has just been closed " << fCurrentFileName << std::endl; std::cout << " -BasicAFP: the input file has just been closed " << fCurrentFileName << std::endl;
} }
if(fListOfIndividualFiles.size()) {
if(fCurrentFileNumber<fListOfIndividualFiles.size()) fCurrentFileName = fListOfIndividualFiles.at(fCurrentFileNumber);
else fCurrentFileName.clear();
fCurrentFileNumber++;
}
else {
// open the first file to be ready to be run // open the first file to be ready to be run
std::string tmp = fPath; std::string tmp = fPath;
if ( tmp.size() > 0 && !(tmp.at(tmp.size()-1) == '/') ) if ( tmp.size() > 0 && !(tmp.at(tmp.size()-1) == '/') )
...@@ -78,6 +84,7 @@ Bool_t BasicAFP::NewFile() ...@@ -78,6 +84,7 @@ Bool_t BasicAFP::NewFile()
<< std::setfill('0') << std::setw(4) << fCurrentFileNumber++ << std::setfill(' ') << std::setfill('0') << std::setw(4) << fCurrentFileNumber++ << std::setfill(' ')
<< ".adf"; << ".adf";
fCurrentFileName = filename.str(); fCurrentFileName = filename.str();
}
fCurrentFile = ::fopen(fCurrentFileName.c_str(),"rb"); fCurrentFile = ::fopen(fCurrentFileName.c_str(),"rb");
if ( fCurrentFile != 0x0 ) { if ( fCurrentFile != 0x0 ) {
...@@ -93,7 +100,7 @@ Bool_t BasicAFP::NewFile() ...@@ -93,7 +100,7 @@ Bool_t BasicAFP::NewFile()
ok = true; ok = true;
} }
else { else {
Log << "Could not open input file " << fCurrentFileName << nline; if(fCurrentFileName.length()) Log << "Could not open input file " << fCurrentFileName << nline;
GetFrameIO().SetStatus(BaseFrameIO::kFinished); GetFrameIO().SetStatus(BaseFrameIO::kFinished);
ok = false; ok = false;
} }
...@@ -182,6 +189,22 @@ void BasicAFP::process_initialise (UInt_t *error_code) ...@@ -182,6 +189,22 @@ void BasicAFP::process_initialise (UInt_t *error_code)
std::ifstream filein(conffile.data()); std::ifstream filein(conffile.data());
if ( filein.is_open() == true ) { if ( filein.is_open() == true ) {
// check with the first line if the files are given one by one
std::string line;
std::getline(filein,line);
int nblank = std::count(line.begin(), line.end(),' ');
filein.seekg(0);
// case where a list of files is given
if(nblank==0) {
while(filein.good()) {
std::getline(filein,line);
if(line.length()) fListOfIndividualFiles.push_back(line);
}
fCurrentFileNumber = 0;
std::cout << "BasicAFP::process_initialise => list of files to process:" << std::endl;
for(auto &i: fListOfIndividualFiles) std::cout << " -- " << i << std::endl;
}
else {
std::string pathforfiles, basename; std::string pathforfiles, basename;
UInt_t starting_number; UInt_t starting_number;
...@@ -193,6 +216,7 @@ void BasicAFP::process_initialise (UInt_t *error_code) ...@@ -193,6 +216,7 @@ void BasicAFP::process_initialise (UInt_t *error_code)
std::cout << "BasicAFP::process_initialise " << pathforfiles << " " << basename << " " << starting_number << std::endl; std::cout << "BasicAFP::process_initialise " << pathforfiles << " " << basename << " " << starting_number << std::endl;
} }
} }
}
filein.close(); filein.close();
// open the first file // open the first file
......
...@@ -48,6 +48,8 @@ private: ...@@ -48,6 +48,8 @@ private:
std::string fPath; std::string fPath;
//! base for all the files produced //! base for all the files produced
std::string fBaseForName; std::string fBaseForName;
//! in case files are given one by one
std::vector<std::string> fListOfIndividualFiles;
//! current file //! current file
FILE *fCurrentFile; FILE *fCurrentFile;
//! current file number //! current file number
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment