00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "RawData/RawBlockId.h"
00013
00014 #include "RawData/RawBlockRegistry.h"
00015 #include "RawData/RawBlockProxy.h"
00016
00017 #include "MessageService/MsgService.h"
00018
00019
00020 #include <iomanip>
00021 #include <string>
00022
00023 #ifndef ASSERT_H
00024 #include <cassert>
00025 #define ASSERT_H
00026 #endif
00027
00028 ClassImp(RawBlockId)
00029
00030
00031 std::ostream& operator<<(std::ostream& os, const RawBlockId& rbid)
00032 { return rbid.FormatToOStream(os); }
00033
00034
00035 RawBlockId::RawBlockId(Int_t major, Int_t minor, Bool_t isDCS,
00036 Detector::Detector_t detector,
00037 SimFlag::SimFlag_t simflag)
00038 : fEncoded(0)
00039 {
00040
00041
00042 Int_t cmptSimFlag = SimFlag::Compact(simflag);
00043
00044 fEncoded =
00045 ((cmptSimFlag << shiftRawBlkIdCSimFlag) & maskRawBlkIdCSimFlag) |
00046 (( detector << shiftRawBlkIdDetector) & maskRawBlkIdDetector) |
00047 ((isDCS) ? maskRawBlkIdIsDCS : 0) |
00048 (( major << shiftRawBlkIdMajor) & maskRawBlkIdMajor) |
00049 (( minor << shiftRawBlkIdMinor) & maskRawBlkIdMinor);
00050
00051 }
00052
00053
00054 const Char_t* RawBlockId::AsString(Option_t *option) const
00055 {
00056
00057
00058
00059
00060
00061
00062 const int nbuffers = 8;
00063 static char newstring[nbuffers][128];
00064 static int ibuffer = nbuffers;
00065 ibuffer = (ibuffer+1)%nbuffers;
00066
00067 switch (option[0]) {
00068 case 'c':
00069
00070 sprintf(newstring[ibuffer],"%3s:%3.3d;%3.3d(%1.1s+%1.1s)"
00071 ,(IsDCS() ? "DCS" : "DAQ")
00072 ,GetMajor(),GetMinor()
00073 ,Detector::AsString(GetDetector())
00074 ,SimFlag::AsString(GetSimFlag())
00075 );
00076 break;
00077 default:
00078
00079 sprintf(newstring[ibuffer],"%3s:%s;%3.3d(%s+%s)"
00080 ,(IsDCS() ? "DCS" : "DAQ")
00081 ,GetMajorAsString(),GetMinor()
00082 ,Detector::AsString(GetDetector())
00083 ,SimFlag::AsString(GetSimFlag())
00084 );
00085 break;
00086 }
00087
00088 return newstring[ibuffer];
00089 }
00090
00091
00092 const Char_t* RawBlockId::GetMajorAsString() const
00093 {
00094
00095
00096 RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00097 RawBlockProxy* rbp = rbr.LookUp(IsDCS(),GetMajor());
00098
00099 static char unknownstring[128];
00100
00101 if (rbp) {
00102 return rbp->GetName();
00103 }
00104 else {
00105 sprintf(unknownstring,"Unknown%3sBlock0x%2.2x",
00106 (IsDCS() ? "DCS" : "DAQ"),GetMajor());
00107 return unknownstring;
00108 }
00109
00110 }
00111
00112
00113 void RawBlockId::Print(Option_t *option) const
00114 {
00115
00116 FormatToOStream(cout,option);
00117 }
00118
00119
00120 std::ostream& RawBlockId::FormatToOStream(std::ostream& os,
00121 Option_t *option) const
00122 {
00123 if (os.good()) {
00124 if (os.tie()) os.tie()->flush();
00125 os << AsString(option);
00126 }
00127
00128 if (os.flags() & std::ios::unitbuf) os.flush();
00129 return os;
00130 }
00131
00132
00133