testEventFile.cc
Go to the documentation of this file.
1 
9 #include <io/EventFile.h>
10 #include <evt/Event.h>
11 #include <utl/AugerException.h>
12 #include <iostream>
13 
14 using io::EventFile;
15 using evt::Event;
16 using namespace std;
17 
18 int main(int argc, char * argv[]){
19 
20  int errors =0;
21 
22  Event event;
23 
24  EventFile dummyfile(io::eCDas);
25  cout << "Now trying to open a non existent file " << endl;
26 
27  try{
28  dummyfile.Open("IDoNotExist.root",io::eRead);
29  } catch (utl::IOFailureException& ex) {
30  cout << ex.GetMessage();
31  }
32 
33  EventFile cdasfile(io::eCDas);
34 
35  try{
36  cdasfile.Open("CDAS/CDASInputTest_IoSd.root",io::eRead);
37 
38  } catch (utl::IOFailureException& ex) {
39  cout << ex.GetMessage();
40  errors ++;
41  }
42 
43  io::Status status = cdasfile.Read(event);
44  if (status != io::eSuccess) errors++;
45  cdasfile.Close();
46 
47 //#warning something goes wrong when allocated on the stack. To be investigated
48  EventFile * fdasfile = new EventFile(io::eFDas);
49 
50  try{
51  fdasfile->Open("FDas/TestEyeEvent.root",io::eRead);
52 
53  } catch (utl::IOFailureException& ex) {
54  cout << ex.GetMessage();
55  errors ++;
56  }
57 
58  status = fdasfile->Read(event);
59  if (status != io::eSuccess)
60  errors++;
61  fdasfile->Close();
62 
63  return errors;
64 
65  delete fdasfile;
66 }
67 
68 
69 // Configure (x)emacs for this file ...
70 // Local Variables:
71 // mode:c++
72 // compile-command: "make -C .. testEventFile -k"
73 // End:
FDas file format.
Definition: IoCodes.h:36
void Open(const std::string &filename, const Mode mode=eRead, utl::Branch *const b=nullptr)
Definition: EventFile.cc:119
Base class to report exceptions in IO.
Offline native file format.
Definition: IoCodes.h:35
Status
Return code for seek operation.
Definition: IoCodes.h:24
int main(int argc, char *argv[])
Definition: DBSync.cc:58
Status Read(evt::Event &event)
read current event, advance cursor by 1
Definition: EventFile.cc:148
void Close()
Definition: EventFile.cc:129
Interface to file I/O objects.
Definition: EventFile.h:34
const std::string & GetMessage() const
Retrieve the message from the exception.

, generated on Tue Sep 26 2023.