20 #include "StHbtMaker/Infrastructure/StHbtEvent.hh"
21 #include "StHbtMaker/Base/StHbtEventCut.h"
22 #include "StHbtMaker/Base/StHbtTrackCut.h"
23 #include "StHbtMaker/Base/StHbtV0Cut.h"
24 #include "StHbtMaker/Base/StHbtKinkCut.h"
25 #include "StHbtMaker/Reader/StHbtAsciiReader.h"
33 StHbtAsciiReader::StHbtAsciiReader() : mInputStream(0), mOutputStream(0){
34 mFileName =
"HbtAsciiFile";
36 mStHbtEventVersion = mStHbtTrackVersion = mStHbtV0Version = 1;
40 StHbtAsciiReader::StHbtAsciiReader(
char* file) : mInputStream(0), mOutputStream(0), mFileName(file)
43 mStHbtEventVersion = mStHbtTrackVersion = mStHbtV0Version = 1;
47 StHbtAsciiReader::~StHbtAsciiReader(){
59 StHbtEvent* StHbtAsciiReader::ReturnHbtEvent(){
61 cout <<
"StHbtAsciiReader::ReturnHbtEvent() - there is no input stream!";
65 if (!(*mInputStream)){
66 cout <<
"StHbtAsciiReader::ReturnHbtEvent() - input stream in bad state!" << endl;
67 cout <<
"State is " << mInputStream->rdstate() << endl;
72 (*mInputStream) >> (*event);
73 if (!(mInputStream->good())){
74 cout <<
"StHbtAsciiReader::ReturnHbtEvent() - input stream in bad state!" <<endl;
75 cout <<
"State is " << mInputStream->rdstate() << endl;
83 int StHbtAsciiReader::WriteHbtEvent(
StHbtEvent* event){
86 cout <<
"\n StHbtAsciiReader::WriteHbtEvent() - There is no Output Stream -- I am NOT writing !!! \n\n";
90 if (!(*mOutputStream)){
91 cout <<
"\n StHbtAsciiReader::WriteHbtEvent() - Output Stream in bad state -- I am NOT writing !!! \n\n";
96 if ( !mEventCut || mEventCut->Pass(event) ) {
97 cout <<
"StHbtAsciiReader: eventCut passed" << endl;
98 StHbtEvent newEvent(*event, mTrackCut, mV0Cut);
99 (*mOutputStream) << (newEvent);
112 cout <<
" *\n *\n *\n StHbtAsciiReader::Init() being called*\n *\n";
115 if (((*ReadWrite)==
'r')|| ((*ReadWrite)==
'R')){
116 mInputStream =
new ifstream;
117 mInputStream->open(mFileName);
118 if (!(*mInputStream)){
119 cout <<
"StHbtAsciiReader::Init() - Cannot open input file! " << endl;
122 cout <<
"StHbtAsciiReader::Init() - being configured as a Reader" << ReadWrite << endl;
129 mInputStream->getline(temp,200);
131 }
while (stemp !=
"-*-*-*-* End of Input Reader Report");
132 cout <<
"Here is the message that was at the beginning of the file...\n";
133 cout << Message.c_str();
134 (*mInputStream) >> mStHbtEventVersion >> mStHbtTrackVersion >> mStHbtV0Version;
135 cout <<
" StHbtEventVersion=" << mStHbtEventVersion;
136 cout <<
" StHbtTrackVersion=" << mStHbtTrackVersion;
137 cout <<
" StHbtV0Version=" << mStHbtV0Version << endl;
140 mOutputStream =
new ofstream;
143 mOutputStream->open(mFileName);
144 if (!(*mOutputStream)){
145 cout <<
"StHbtAsciiReader::Init() - Cannot open output file! " << endl;
148 cout <<
"StHbtAsciiReader::Init() - being configured as a Writer" << ReadWrite << endl;
149 (*mOutputStream) << Message.c_str();
150 (*mOutputStream) << endl;
151 (*mOutputStream) <<
"-*-*-*-* End of Input Reader Report" << endl;
152 (*mOutputStream) << mStHbtEventVersion <<
" " << mStHbtTrackVersion <<
" " << mStHbtV0Version << endl;
158 void StHbtAsciiReader::Finish(){
159 if (mInputStream) mInputStream->close();
160 if (mOutputStream) mOutputStream->close();
int Init(const char *ReadWrite, StHbtString &Message)
temp += this->Report();