//////////////////////////////////////////////////////////////////////////// // $Id: IVldContext.cxx,v 1.1 2011/01/18 05:49:20 finch Exp $ // // COMET::IVldContext // // COMET::IVldContext is tag for identifying the required "context" when // interfacing with the DBI // // Author: R. Hatcher 2000.05.03 // //////////////////////////////////////////////////////////////////////////// #include "IVldContext.hxx" #include #include using std::endl; //CVSID("$Id: IVldContext.cxx,v 1.1 2011/01/18 05:49:20 finch Exp $"); ClassImp(COMET::IVldContext) //_____________________________________________________________________________ std::ostream& operator<<(std::ostream& os, const COMET::IVldContext& vldc) { if (os.good()) { if (os.tie()) os.tie()->flush(); // instead of opfx os << vldc.AsString(); } // instead of os.osfx() if (os.flags() & std::ios::unitbuf) os.flush(); return os; } //_____________________________________________________________________________ COMET::IVldContext::IVldContext(const COMET::ICOMETContext& context) : fDetector(COMET::DbiDetector::kNear), fSimFlag(COMET::DbiSimFlag::kData), fTimeStamp(context.GetTimeStamp(),0) { // constructor from T2K context if(context.GetPartition() & COMET::ICOMETContext::kMCData) fSimFlag = COMET::DbiSimFlag::kMC; } //_____________________________________________________________________________ COMET::IVldContext::IVldContext(const COMET::DbiDetector::Detector_t &detector, const COMET::DbiSimFlag::SimFlag_t mcFlag, const COMET::IVldTimeStamp &tstamp) : fDetector(detector), fSimFlag(mcFlag), fTimeStamp(tstamp) { // normal constructor } //_____________________________________________________________________________ const char* COMET::IVldContext::AsString(Option_t *option) const { // Return a formatted string of the contents of this object // User should copy result because it points to a // statically allocated string. static char newstring[80] = " "; switch (option[0]) { case 'c': case 'C': sprintf(newstring,"{%c%c %s}", COMET::DbiDetector::AsString(GetDetector())[0], COMET::DbiSimFlag::AsString(GetSimFlag())[0], fTimeStamp.AsString("c")); break; default: sprintf(newstring,"{%6.6s|%6.6s|%s}", COMET::DbiDetector::AsString(GetDetector()), COMET::DbiSimFlag::AsString(GetSimFlag()), fTimeStamp.AsString("c")); } return newstring; } //_____________________________________________________________________________ void COMET::IVldContext::Print(Option_t *option) const { // Print this object printf("%s\n",AsString(option)); } //_____________________________________________________________________________ Bool_t COMET::IVldContext::IsNull() const { // Return true if this was initialized by default ctor // we can only test detector type and simflag return fDetector==COMET::DbiDetector::kUnknown && fSimFlag == COMET::DbiSimFlag::kUnknown; } //_____________________________________________________________________________