StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEvtHddr.cxx
1 #include <stdio.h>
2 #include <time.h>
3 #include <assert.h>
4 #include "StEvtHddr.h"
5 #include "StarRoot/TUnixTime.h"
6 #include "StMessMgr.h"
7 
8 ClassImp(StEvtHddr)
9 //_____________________________________________________________________________
10 StEvtHddr::StEvtHddr(TDataSet *parent):TDataSet("EvtHddr",parent)
11 {
12  SetDateTime(20330101,0);
13  SetEventType("NONE");
14  memset(&mRunNumber,0,(char*)(&mEventNumber)-(char*)&mRunNumber);
15  mRunNumber=-1;mOldRunNumber=-2;mEventNumber=-1;
16 }
17 //_____________________________________________________________________________
18 StEvtHddr &StEvtHddr::operator=(const StEvtHddr &hddr)
19 {
20  if (!GetName() [0]) SetName (hddr.GetName ());
21  if (!GetTitle()[0]) SetTitle(hddr.GetTitle());
22  memcpy(&mRunNumber,&hddr.mRunNumber,(char*)((&mEventNumber)+1)-(char*)&mRunNumber);
23  mEventTime = hddr.mEventTime;
24  mProdTime = hddr.mProdTime;
25  mEventType = hddr.mEventType;
26  return *this;
27 }
28 //_____________________________________________________________________________
29 void StEvtHddr::FillTag(EvtHddr_st *tag)
30 {
31 
32  assert((char*)&mEventNumber -(char*)&mRunNumber
33  ==(char*)&tag->mEventNumber-(char*)&tag->mRunNumber);
34 
35  memcpy(tag,&mRunNumber,(char*)(&mEventNumber+1)-(char*)&mRunNumber);
36  tag->mEventTime = mEventTime.GetDate() + mEventTime.GetTime()/1000000.;
37  tag->mProdTime = mProdTime.GetDate() + mProdTime.GetTime()/1000000. ;
38  tag->mEventType[0] = 0;
39  strncat(tag->mEventType,mEventType,15);
40 }
41 //_____________________________________________________________________________
42  void StEvtHddr::SetGMTime(UInt_t ut)
43 {
44  TUnixTime unixTime(ut);
45  Int_t dat=0,tim=0;
46  unixTime.GetGTime(dat,tim);
47  mEventTime.Set(dat,tim);
48 }
49 //_____________________________________________________________________________
50  void StEvtHddr::SetProdDateTime(UInt_t ut)
51 {
52  TUnixTime unixTime(ut);
53  Int_t dat=0,tim=0;
54  unixTime.GetGTime(dat,tim);
55  mProdTime.Set(dat,tim);
56 }
57 //_____________________________________________________________________________
58  UInt_t StEvtHddr::GetUTime() const
59 {
60  TUnixTime unixTime;
61  unixTime.SetGTime(mEventTime.GetDate(),mEventTime.GetTime());
62  return unixTime.GetUTime();
63 }
64 //_____________________________________________________________________________
65  void StEvtHddr::Print(Option_t *option) const
66 {
67  LOG_INFO << Form
68  /* printf*/ ("*********** Event Info **********************")
69  << endm;
70  LOG_INFO << Form
71  /* printf*/ ("\tRun: \t%5d Event %5d TimeStamp %8d.%6d Bunch %d:%d"
72  ,mRunNumber,mEventNumber,mEventTime.GetDate(),mEventTime.GetTime()
73  ,mBunchCrossingNumber[0],mBunchCrossingNumber[1])
74  << endm;
75  LOG_INFO << Form
76  /* printf*/ ("\t EvtSize: %d \tInpTrig: %4x OutTrig: %4x"
77  ,mEventSize,mInputTriggerMask,mTriggerMask)
78  << endm;
79  LOG_INFO << Form
80  /* printf*/ ("*********************************************")
81  << endm;
82 }