Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventSourceGenerator_EVIO.cc
Go to the documentation of this file.
1 // $Id$
2 // $HeadURL$
3 //
4 // File: JEventSourceGenerator_EVIO.cc
5 // Created: Tue May 21 14:05:48 EDT 2013
6 // Creator: davidl (on Darwin harriet.jlab.org 11.4.2 i386)
7 //
8 
9 #include <string>
10 using std::string;
12 using namespace jana;
13 
14 #include "HDEVIO.h"
15 
16 //---------------------------------
17 // Description
18 //---------------------------------
20 {
21  return "EVIO - 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.5 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.5;
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.5;
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_EVIO(source.c_str());
61 }
62 
char string[256]
bool is_open
Definition: HDEVIO.h:166
Definition: HDEVIO.h:45
jana::JEventSource * MakeJEventSource(string source)
bool ReadBlock(void)
Definition: HDEVIO.cc:240
The JEventSource_EVIO class implements a JEventSource capable of reading in EVIO data from raw data f...