00001 #ifndef TSK_DBI_Context_hxx_seen 00002 #define TSK_DBI_Context_hxx_seen 00003 00004 #include <TROOT.h> 00005 #include <TObject.h> 00006 00007 00008 00009 /// Define the context of an event. The event context uniquely identifies an 00010 /// event within SK_DBI. Due to the way events are formed, not all event 00011 /// (or slow control data) will have all fields of the context information 00012 /// defined. Fields that do not contain valid data should be marked using the 00013 /// value TSK_DBI_Context::Invalid. 00014 class TSK_DBI_Context { 00015 public: 00016 typedef unsigned int Time; 00017 00018 /// A special field value that specifies that the field is invalid. 00019 static const int Invalid; 00020 00021 /// Construct an empty context. 00022 TSK_DBI_Context(); 00023 00024 /// Construct a context. 00025 TSK_DBI_Context(int run, int subRun, int event, int timestamp, int spill, int dataMC=1); 00026 00027 virtual ~TSK_DBI_Context(); 00028 00029 /// Get dataMC variable 00030 /// data = 1, MC = 4 00031 int GetDataMC() const { return fDataMC;} 00032 00033 /// Add a convenient check to see if this is MC data. 00034 bool IsMC() const; 00035 00036 /// Set dataMC variable 00037 /// data = 1, MC = 4 00038 void SetDataMC(int dm); 00039 00040 /// Return the run number for this context. 00041 int GetRun() const; 00042 00043 /// Set the run number for this context. 00044 void SetRun(int r); 00045 00046 /// Return the sub-run number for this context. 00047 int GetSubRun() const; 00048 00049 /// Set the sub-run number for this context. 00050 void SetSubRun(int s); 00051 00052 /// Return the event number for this context. 00053 int GetEvent() const; 00054 00055 /// Set the event number for this context. 00056 void SetEvent(int e); 00057 00058 /// Return the spill number for this context. 00059 int GetSpill() const; 00060 00061 /// Set the spill number for this context 00062 void SetSpill(int s); 00063 00064 /// Return the time stamp for this event (only valid to 1 sec) 00065 int GetTimeStamp() const; 00066 00067 /// Return the time stamp for this event as a MYSQL compatible time string. 00068 std::string GetTimeStampString() const; 00069 00070 /// Set the time stamp for this event. 00071 void SetTimeStamp(int t); 00072 00073 /// Return true if the context is valid. A valid context is defined as a 00074 /// context where one or more fields is valid. 00075 bool Valid() const; 00076 00077 private: 00078 00079 /// The run number associated with this context 00080 int fRun; 00081 00082 /// The sub-run number associated with this context 00083 int fSubRun; 00084 00085 /// The event number associated with this context. 00086 int fEvent; 00087 00088 /// The spill number associated with this context. 00089 int fSpill; 00090 00091 /// The unix time stamp associated with this context 00092 Time fTimeStamp; 00093 00094 /// data/MC flag. data = 1, MC = 4 00095 int fDataMC; 00096 ClassDef(TSK_DBI_Context,1); 00097 }; 00098 00099 std::ostream& operator<<(std::ostream& s, const TSK_DBI_Context& c); 00100 #endif