StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
JanEvent.cxx
1 //
2 // Pibero Djawotho <pibero@iucf.indiana.edu>
3 // Indiana University
4 // Feb 18, 2006
5 //
6 
7 #include "JanEvent.h"
8 #include <cstring>
9 
10 JanEvent::JanEvent()
11 {
12  memset(mLength, 0, sizeof(mLength));
13  memset(mHeader, 0, sizeof(mHeader));
14  memset(mTriggerData, 0, sizeof(mTriggerData));
15  memset(mBemcData, 0, sizeof(mBemcData));
16  memset(mEemcData, 0, sizeof(mEemcData));
17 }
18 
19 void JanEvent::setHeader(const char* header)
20 {
21  if (header) {
22  mLength[0] = strlen(header);
23  strcpy(mHeader, header);
24  }
25 }
26 
27 void JanEvent::setTriggerData(char* trgData)
28 {
29  if (trgData) {
30  mLength[1] = sizeof(mTriggerData);
31  memcpy(mTriggerData, trgData, sizeof(mTriggerData));
32  }
33 }
34 
35 void JanEvent::setBemcData(unsigned short* bemcData)
36 {
37  if (bemcData) {
38  mLength[2] = sizeof(mBemcData);
39  memcpy(mBemcData, bemcData, sizeof(mBemcData));
40  }
41 }
42 
43 void JanEvent::setEemcData(unsigned short* eemcData)
44 {
45  if (eemcData) {
46  mLength[3] = sizeof(mEemcData);
47  memcpy(mEemcData, eemcData, sizeof(mEemcData));
48  }
49 }
50 
51 istream& operator>>(istream& in, JanEvent& event)
52 {
53  in.read((char*)event.mLength, sizeof(event.mLength));
54  in.read(event.mHeader, event.mLength[0]);
55  in.read(event.mTriggerData, event.mLength[1]);
56  in.read((char*)event.mBemcData, event.mLength[2]);
57  in.read((char*)event.mEemcData, event.mLength[3]);
58  return in;
59 }
60 
61 ostream& operator<<(ostream& out, const JanEvent& event)
62 {
63  out.write((char*)event.mLength, sizeof(event.mLength));
64  out.write(event.mHeader, event.mLength[0]);
65  out.write(event.mTriggerData, event.mLength[1]);
66  out.write((char*)event.mBemcData, event.mLength[2]);
67  out.write((char*)event.mEemcData, event.mLength[3]);
68  return out;
69 }