Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventSourceGenerator_EVIOpp.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventSourceGenerator_EVIOpp.cc
4 // Created: Tue Mar 29 08:14:42 EDT 2016
5 // Creator: davidl (on Darwin harriet.jlab.org 13.4.0 i386)
6 //
7 
8 #include <string>
9 using std::string;
10 
11 
13 using namespace jana;
14 
15 
16 //---------------------------------
17 // Description
18 //---------------------------------
20 {
21  return "EVIOpp - Reads EVIO formatted data from file or ET system";
22 }
23 
24 //---------------------------------
25 // CheckOpenable
26 //---------------------------------
28 {
29  // First, check if the source starts with "ET:". If so,
30  // return 0.0 immediately. If it does not start with this,
31  // test open the file and see if we can read a block
32  // from it. If we can, then return 0.75 which will likely
33  // win us the right to open it. If we can't, but the file
34  // ends in ".evio" then return 0.01 which will win us
35  // the right to open it if no other source claims it. This
36  // will allow the program to print an appropriate error
37  // message/
38 
39  if(source.find("ET:")==0) return 0.6;
40 
41  HDEVIO *hdevio = new HDEVIO(source, false);
42  bool is_good_evio = false;
43  bool opened = hdevio->is_open;
44  if(opened){
45  is_good_evio = hdevio->ReadBlock();
46  }
47  delete hdevio;
48 
49  if(is_good_evio) return 0.6;
50  if(source.find(".evio") != source.npos) return 0.01;
51 
52  return 0.0;
53 }
54 
55 //---------------------------------
56 // MakeJEventSource
57 //---------------------------------
59 {
60  return new JEventSource_EVIOpp(source.c_str());
61 }
62 
char string[256]
bool is_open
Definition: HDEVIO.h:166
jana::JEventSource * MakeJEventSource(string source)
How this Event Source Works
Definition: HDEVIO.h:45
bool ReadBlock(void)
Definition: HDEVIO.cc:240