StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTRGReader.cxx
1 /***************************************************************************
2  *
3  * $Id: StTRGReader.cxx,v 1.11 2009/11/25 20:50:08 fisyak Exp $
4  *
5  * Author: Herbert Ward, Dec 28 1999, 13:10 EST.
6  ***************************************************************************
7  *
8  * Description: Offline Wrapper for TRG reader class
9  *
10  ***************************************************************************
11  *
12  * $Log: StTRGReader.cxx,v $
13  * Revision 1.11 2009/11/25 20:50:08 fisyak
14  * Fix the broken logic for the DAQ file with NO trigger data
15  *
16  * Revision 1.10 2009/11/02 21:42:52 fine
17  * allow the Akio DAT file to be read in 1999-2008 format
18  *
19  * Revision 1.9 2007/11/19 19:40:10 akio
20  * Change fro run8
21  *
22  * Revision 1.8 2007/05/29 22:12:19 fine
23  * Introduce logger-based output
24  *
25  * Revision 1.7 2007/02/22 22:18:41 akio
26  * Update for 2007
27  *
28  * Revision 1.6 2004/11/03 17:55:28 akio
29  * update for fy05 run
30  *
31  * Revision 1.5 2004/08/07 02:39:00 perev
32  * Traditional Clear added
33  *
34  * Revision 1.4 2003/12/23 23:17:10 akio
35  * Update for Fy04 run
36  *
37  * Revision 1.3 2003/07/16 19:58:29 perev
38  * Cleanup of StTriggerData2003 at all
39  *
40  * Revision 1.2 2000/06/12 15:04:02 perev
41  * SVT + cleanup
42  *
43  * Revision 1.1 2000/01/24 20:35:37 ward
44  * Access trigger data.
45  *
46  *
47  **************************************************************************/
48 #include "StTRGReader.h"
49 #include "Stypes.h"
50 #include "StDaqLib/GENERIC/EventReader.hh"
51 #include "StDAQReader.h"
52 #include "StStreamFile.h"
53 
54 #include <string.h>
55 #include <stdio.h>
56 #include <errno.h>
57 #include <unistd.h>
58 #include <assert.h>
59 #include <sys/types.h>
60 #include <sys/stat.h>
61 #include <fcntl.h>
62 #define PP LOG_INFO <<
63 
64 //_____________________________________________________________________________
65 StTRGReader::StTRGReader(StDAQReader *daqr) {
66  fDAQReader = daqr;
67  fTRGImpReader = 0;
68  Update();
69 }
70 //_____________________________________________________________________________
71 void StTRGReader::Update() {
72  delete fTRGImpReader; fTRGImpReader = 0;
73  fTRGImpReader = ::getTRGReader(fDAQReader->getEventReader());
74 //VP assert(fTRGImpReader);
75 }
76 //_____________________________________________________________________________
77 StTRGReader::~StTRGReader() {
78  close();
79 }
80 //_____________________________________________________________________________
81 int StTRGReader::close() {
82  delete fTRGImpReader; fTRGImpReader=0;
83  return 0;
84 }
85 //_____________________________________________________________________________
86 char StTRGReader::thereIsTriggerData() {
87  if(fTRGImpReader ||
88  ( fDAQReader->getDatFileReader() && OldFormat(fDAQReader->getDatFileReader()->Version()) )) return 7; // TRUE
89  return 0; // FALSE
90 }
91 //_____________________________________________________________________________
92 const char *StTRGReader::getData() const
93 {
94  const char *data = 0;
95  if(fTRGImpReader) {
96  data = (const char*)(fTRGImpReader->pBankTRGD)+40;
97  } else if ( fDAQReader->getDatFileReader() ) {
98  data = fDAQReader->getDatFileReader()->Record();
99  }
100  return data;
101 }
102 //_____________________________________________________________________________
103 int StTRGReader::getYear() const
104 {
105  char *dat = (char*)getData();
106  if(!dat) return 0;
107  return fTRGImpReader->YearOfData(dat);
108 }
109 //_____________________________________________________________________________
110 const TrgDataType2000 *StTRGReader::getDataType2000() const
111 {return 0;}
112 //_____________________________________________________________________________
113 const TrgDataType2003 *StTRGReader::getDataType2003() const
114 {
115  if (getYear()!=2003) return 0;
116  return (const TrgDataType2003*)getData();
117 }
118 //_____________________________________________________________________________
119 const TrgDataType2004 *StTRGReader::getDataType2004() const
120 {
121  if (getYear()!=2004) return 0;
122  return (const TrgDataType2004*)getData();
123 }
124 //_____________________________________________________________________________
125 const TrgDataType2005 *StTRGReader::getDataType2005() const
126 {
127  if (getYear()!=2005) return 0;
128  return (const TrgDataType2005*)getData();
129 }
130 //_____________________________________________________________________________
131 const TrgDataType2007 *StTRGReader::getDataType2007() const
132 {
133  if (getYear()!=2007) return 0;
134  return (const TrgDataType2007*)getData();
135 }
136 //_____________________________________________________________________________
137 const TrgDataType2008 *StTRGReader::getDataType2008() const
138 {
139  if (getYear()!=2008) return 0;
140  return (const TrgDataType2008*)getData();
141 }
142 
int YearOfData(char *)
This routine also exists in St_trg_Maker.
Definition: TRG_Reader.cxx:55