00001 /*************************************************************************** 00002 * $Id: RichEventReader.hh,v 1.3 2003/12/24 21:55:57 perev Exp $ 00003 * Author: Zhangbu Xu 00004 *************************************************************************** 00005 * Description: definition for Rich Standalone event reader 00006 * 00007 * 00008 * change log 00009 * 06-June-99 MJL added EventInfo struct, changed method getEventInfo() 00010 * 06-June-99 MJL added printEventInfo() 00011 * 17-June-99 Herb Ward changed the dimension of errstr0 from 50 to 250 00012 * 23-Jun-99 MJL add verbose flag and setVerbose() method 00013 * 25-Jun-99 MJL added TPCV2P0_CPP_SR::getAsicParams(ASIC_params *); 00014 * 09-Jul-99 MJL added EventReader::findBank() 00015 * 20-Jul-99 MJL added EventReader::fprintError() 00016 * 20-Jul-99 MJL add alternate getEventReader with name of logfile 00017 * 20-Jul-99 MJL add overloaded printEventInfo(FILE *) 00018 * 28-Dec-99 MJL add alternate InitEventReaders, mapped and unmapped 00019 * 31-Jan-00 MJL change to #if !defined ST_NO_NAMESPACES 00020 * 21-Apr-00 Adopted by Z. Xu to read Rich standalone events 00021 * 00022 *************************************************************************** 00023 * $Log: RichEventReader.hh,v $ 00024 * Revision 1.3 2003/12/24 21:55:57 perev 00025 * Cleanup 00026 * 00027 * Revision 1.2 2003/09/02 17:55:32 perev 00028 * gcc 3.2 updates + WarnOff 00029 * 00030 * Revision 1.1 2000/04/25 14:55:28 xzb 00031 * Clean up RICH_Reader array, add RichEventReader for standalone data file 00032 * 00033 * Revision 1.10 2000/02/15 23:24:27 fisyak 00034 * Force to compile StPadMonitorMaker 00035 * 00036 * Revision 1.9 2000/01/31 19:38:51 levine 00037 * chamge to #if !defined ST_NO_NAMESPACES 00038 * 00039 * Revision 1.8 2000/01/11 22:04:40 levine 00040 * EventReader.hh // change the header file to include std::string 00041 * EventReader.cxx // convert string to char* via c_str() member 00042 * (changes from Brian Lasiuk) 00043 * 00044 * Revision 1.7 2000/01/04 20:54:47 levine 00045 * Implemented memory-mapped file access in EventReader.cxx. Old method 00046 * (via seeks) is still possible by setting mmapp=0 in 00047 * 00048 * getEventReader(fd,offset,(const char *)logfile,mmapp); 00049 * 00050 * 00051 * but memory-mapped access is much more effective. 00052 * 00053 * Revision 1.6 1999/07/26 17:00:03 levine 00054 * changes to RICH file organization 00055 * 00056 * Revision 1.5 1999/07/21 21:33:08 levine 00057 * 00058 * 00059 * changes to include error logging to file. 00060 * 00061 * There are now 2 constructors for EventReader: 00062 * 00063 * EventReader(); 00064 * EventReader(const char *logfilename); 00065 * 00066 * Constructed with no argument, there is no error logging. Supplying a file name 00067 * sends all diagnostic output to the named file (N.B. opens in append mode) 00068 * 00069 * See example in client.cxx for constructing a log file name based on the 00070 * datafile name. 00071 * 00072 * It is strongly advised to use the log file capability. You can grep it for 00073 * instances of "ERROR:" to trap anything noteworthy (i.e., corrupted data files). 00074 * 00075 * Revision 1.4 1999/07/10 21:31:17 levine 00076 * Detectors RICH, EMC, TRG now have their own (defined by each detector) interfaces. 00077 * Existing user code will not have to change any calls to TPC-like detector 00078 * readers. 00079 * 00080 * Revision 1.3 1999/07/02 04:37:41 levine 00081 * Many changes - see change logs in individual programs 00082 * 00083 * 00084 **************************************************************************/ 00085 #ifndef RICHEVENTREADER_HH 00086 #define RICHEVENTREADER_HH 00087 00088 #include <Stiostream.h> 00089 00090 #include <sys/types.h> 00091 00092 #include <string> 00093 #if !defined ST_NO_NAMESPACES 00094 using std::string; 00095 #endif 00096 00097 #include "StDaqLib/GENERIC/RecHeaderFormats.hh" 00098 #include "StDaqLib/GENERIC/Error.hh" 00099 00100 #define TRUE 1 00101 #define FALSE 0 00102 00103 00104 00105 // Event Reader header files 00106 // This file is included by Offline programs 00107 00108 class RichEventReader; 00109 00110 // Support Structures 00111 00112 00113 // Event Reader Class 00114 class RichEventReader 00115 { 00116 public: 00117 RichEventReader(); 00118 00119 void InitEventReader(int fd, long offset, int mmap); 00120 // takes open file descripter-offset 00121 // works on MAPPED file 00122 void InitEventReader(int fd, long offset); 00123 00124 long NextEventOffset(); 00125 void setVerbose(int); // 0 turns off all internal printout 00126 char * findBank(char *bankid); // navigates to pointer bnk below DATAP 00127 int verbose; 00128 00129 ~RichEventReader(); 00130 00131 char *getDATAP() { return DATAP; }; 00132 struct EventInfo getEventInfo(); 00133 void printEventInfo(FILE *fd = stdout); 00134 void fprintError(int err, char *file, int line, char *userstring); 00135 00136 int runno() { return runnum; } 00137 int errorNo() { return errnum; }; 00138 string errstr() { return string(errstr0); }; 00139 FILE *logfd; //file handle for log file 00140 char err_string[MX_MESSAGE][30]; 00141 00142 int MemUsed(); 00143 00144 protected: 00145 char *DATAP; // Pointer to the memory mapped buffer 00146 int event_size; 00147 00148 private: 00149 int fd; // -1 if the event is in memory 00150 char *MMAPP; // Begining of memory mapping 00151 00152 long next_event_offset; 00153 00154 int errnum; 00155 char errstr0[250]; 00156 int runnum; 00157 // later storage for detector buffers 00158 }; 00159 00160 00161 // Declaration for the factories 00162 RichEventReader *getRichEventReader(int fd, long offset, int MMap=1); 00163 00164 #endif
1.5.9