1 #include <utl/ErrorLogger.h>
2 #include <utl/AugerException.h>
3 #include <utl/Branch.h>
5 #include <io/EventFileChain.h>
6 #include <io/EventFile.h>
7 #include <io/VEventFile.h>
11 #include <boost/process.hpp>
12 #include <boost/format.hpp>
26 if (fileTypeName ==
"Offline")
28 else if (fileTypeName ==
"FDAS")
30 else if (fileTypeName ==
"CDAS")
32 else if (fileTypeName ==
"CORSIKA")
35 else if (fileTypeName ==
"AIRES")
38 else if (fileTypeName ==
"IoAuger")
40 else if (fileTypeName ==
"CONEX")
42 else if (fileTypeName ==
"CONEXRandom")
44 else if (fileTypeName ==
"SENECA")
46 else if (fileTypeName ==
"Seneca")
48 else if (fileTypeName ==
"Artificial" || fileTypeName ==
"ARTIFICIAL")
50 else if (fileTypeName ==
"ZHAireS")
52 else if (fileTypeName ==
"REAS")
54 else if (fileTypeName ==
"REASH5")
58 else if (fileTypeName ==
"EVA")
60 else if (fileTypeName ==
"RadioAERA")
62 else if (fileTypeName ==
"RadioAERAroot")
64 else if (fileTypeName ==
"SELFAS")
68 std::stringstream err;
69 err <<
" Unknown file type '" << fileTypeName <<
"'.";
84 std::istringstream iss(filenames);
98 fFileIterator(fFileList.begin()),
117 if (filenames.empty())
137 std::ostringstream warn;
169 return *fFileIterator;
171 static const std::string empty(
"");
190 std::ostringstream err;
191 err <<
"File '" << *fFileIterator
192 <<
"' is not readable/corrupt: " << ex.
GetMessage()
219 const auto n = d.first.size();
220 for (std::string::size_type begin = 0, pos =
s.find(d.first, 0);
221 pos != std::string::npos; pos =
s.find(d.first, begin)) {
222 s.replace(pos, n, d.second);
229 for (
auto sIt = fFileList.begin(); sIt != fFileList.end(); ) {
231 const auto& line = *sIt;
232 if (line.length() < 2 ||
233 !(line[0] ==
'`' || (line[0] ==
'$' && line[1] ==
'('))) {
241 if (line[0] ==
'`') {
246 std::string assemble;
247 while (sIt != fFileList.end() && (*sIt)[sIt->length()-1] !=
'`') {
250 sIt = fFileList.erase(sIt);
252 if (sIt == fFileList.end())
255 sIt = fFileList.erase(sIt);
257 command = assemble.substr(1, assemble.length()-2);
259 if (command.find_first_of(
"`") != std::string::npos)
266 std::string assemble;
268 while (sIt != fFileList.end()) {
269 const auto& line = *sIt;
270 for (
const auto c : line)
271 bracket += (
c ==
'(') - (
c ==
')');
272 if (!assemble.empty())
275 sIt = fFileList.erase(sIt);
279 if (assemble.back() !=
')')
283 const int skipFront = 2;
284 const int skipBack = 1;
285 command = assemble.substr(skipFront, assemble.length()-(skipFront + skipBack));
289 INFO(
"executing command $(" + command +
")");
291 namespace bp = boost::process;
294 bp::child pipe(bp::search_path(
"sh"), std::vector<std::string>{
"-e",
"-c", command }, bp::std_out >
is);
297 sIt = fFileList.insert(sIt, word);
301 if (pipe.exit_code())
302 throw utl::IOFailureException(str(boost::format(
"file-list command `%1%` returned status %2%") % command % pipe.exit_code()));
306 if (fFileList.empty())
conex file, with random access (NOT sequencial, NO EOF)
Status Read(evt::Event &event)
read current event and advance cursor by 1
const std::string & GetCurrentFilename() const
Seneca File Format. Added by Jeff Allen (jda292@nyu.edu) on Dec. 5th, 2006.
bool is(const double a, const double b)
#define INFO(message)
Macro for logging informational messages.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
EventFileChain(utl::Branch &branch)
static std::map< std::string, std::string > fgXMLDictionary
Base class to report exceptions in IO.
Offline native file format.
air shower radio simulations generated with EVA
Class representing a document branch.
Status
Return code for seek operation.
air shower radio simulations generated with REAS
static void InitXMLDictionary()
void SetFileList(const std::vector< std::string > &filenames)
Status Read(evt::Event &event)
read current event, advance cursor by 1
#define WARNING(message)
Macro for logging warning messages.
std::string GetName() const
function to get the Branch name
air shower radio simulations generated with ZHAireS
Interface to file I/O objects.
Type
The type of file that we are acutally opening.
#define ERROR(message)
Macro for logging error messages.
const std::string & GetMessage() const
Retrieve the message from the exception.
air shower radio simulations generated with REAS