TVldContext.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "TVldContext.hxx"
00014
00015 #include <TSK_DBI_Log.hxx>
00016 #include <MsgFormat.h>
00017 using std::endl;
00018
00019
00020 ClassImp(TVldContext)
00021
00022
00023 std::ostream& operator<<(std::ostream& os, const TVldContext& vldc)
00024 {
00025 if (os.good()) {
00026 if (os.tie()) os.tie()->flush();
00027 os << vldc.AsString();
00028 }
00029
00030 if (os.flags() & std::ios::unitbuf) os.flush();
00031 return os;
00032 }
00033
00034
00035 TVldContext::TVldContext(const TSK_DBI_Context& context)
00036 : fDetector(DbiDetector::kNear), fSimFlag(DbiSimFlag::kData), fTimeStamp(context.GetTimeStamp(),0)
00037 {
00038
00039 if(context.IsMC())
00040 fSimFlag = DbiSimFlag::kMC;
00041 }
00042
00043
00044 TVldContext::TVldContext(const DbiDetector::Detector_t &detector,
00045 const DbiSimFlag::SimFlag_t mcFlag,
00046 const TVldTimeStamp &tstamp)
00047 : fDetector(detector), fSimFlag(mcFlag), fTimeStamp(tstamp)
00048 {
00049
00050 }
00051
00052
00053 const char* TVldContext::AsString(Option_t *option) const
00054 {
00055
00056
00057
00058
00059 static char newstring[80] = " ";
00060
00061 switch (option[0]) {
00062 case 'c':
00063 case 'C':
00064 sprintf(newstring,"{%c%c %s}",
00065 DbiDetector::AsString(GetDetector())[0],
00066 DbiSimFlag::AsString(GetSimFlag())[0],
00067 fTimeStamp.AsString("c"));
00068 break;
00069 default:
00070 sprintf(newstring,"{%6.6s|%6.6s|%s}",
00071 DbiDetector::AsString(GetDetector()),
00072 DbiSimFlag::AsString(GetSimFlag()),
00073 fTimeStamp.AsString("c"));
00074 }
00075
00076 return newstring;
00077 }
00078
00079
00080 void TVldContext::Print(Option_t *option) const
00081 {
00082
00083
00084 printf("%s\n",AsString(option));
00085
00086 }
00087
00088
00089 Bool_t TVldContext::IsNull() const
00090 {
00091
00092
00093 return fDetector==DbiDetector::kUnknown && fSimFlag == DbiSimFlag::kUnknown;
00094
00095 }
00096
00097
00098
00099