00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "RawData/RawLITimingSummary.h"
00013
00014 #include "MessageService/MsgService.h"
00015 CVSID("$Id: RawLITimingSummary.cxx,v 1.16 2005/08/26 19:04:53 rhatcher Exp $");
00016
00017 #include "MessageService/MsgFormat.h"
00018 #include "MessageService/MsgStream.h"
00019
00020 ClassImp(RawLITimingSummary)
00021
00022
00023 std::ostream& operator<<(std::ostream& os, const RawLITimingSummary& s)
00024 { return s.FormatToOStream(os); }
00025
00026
00027 RawLITimingSummary::RawLITimingSummary()
00028 : fCrateStatus(0), fRawChannelId(0), fEntries(-1), fIntMean(-1), fIntRms(-1)
00029 {
00030
00031
00032
00033 }
00034
00035
00036 RawLITimingSummary::RawLITimingSummary(const Int_t *&p,
00037 const RawCrateStatus* cstat,
00038 Int_t minorVersion)
00039 : fCrateStatus(cstat), fRawChannelId(0), fEntries(-1),
00040 fIntMean(-1), fIntRms(-1)
00041 {
00042
00043
00044
00045
00046
00047
00048
00049
00050 const Int_t maskShort = 0xffff;
00051
00052 switch (minorVersion) {
00053 case 0:
00054 {
00055
00056 Int_t chadd = p[0] & maskShort;
00057 BuildRawChannelId(cstat,chadd);
00058
00059 fEntries = ( p[0] >> 16 ) & maskShort;
00060
00061 fIntMean = p[1];
00062 fIntRms = p[2];
00063
00064
00065 p += 3;
00066 break;
00067 }
00068 default:
00069 {
00070 MAXMSG("RawData",Msg::kWarning,10)
00071 << "RawLITimingSummary::ctor with minor id "
00072 << cstat->GetRawBlockId().GetMinor()
00073 << " unknown layout" << endl;
00074
00075 }
00076 case 1:
00077 case 2:
00078 case 3:
00079 case 4:
00080 case 5:
00081 {
00082 Int_t chadd = ( p[0] >> 16) & maskShort;
00083 BuildRawChannelId(cstat,chadd);
00084
00085 fEntries = p[0] & maskShort;
00086
00087 fIntMean = p[1];
00088 fIntRms = p[2];
00089
00090
00091 p += 3;
00092 break;
00093 }
00094 }
00095
00096 }
00097
00098
00099 RawLITimingSummary::~RawLITimingSummary()
00100 {
00101
00102
00103 }
00104
00105
00106 Float_t RawLITimingSummary::GetMean() const
00107 {
00108
00109
00110 switch (fCrateStatus->GetRawBlockId().GetMinor()) {
00111 default:
00112 {
00113 MAXMSG("RawData",Msg::kWarning,100)
00114 << "RawLITimingSummary::GetMean() with minor id "
00115 << fCrateStatus->GetRawBlockId().GetMinor()
00116 << " assumes default scale factor" << endl;
00117 }
00118
00119 case 5:
00120 return fIntMean * 0.0625;
00121 break;
00122 case 0:
00123 case 1:
00124 case 2:
00125 case 3:
00126 case 4:
00127 return fIntMean * 0.25;
00128 break;
00129 }
00130 }
00131
00132
00133 Float_t RawLITimingSummary::GetRms() const
00134 {
00135
00136
00137 switch (fCrateStatus->GetRawBlockId().GetMinor()) {
00138 default:
00139 {
00140 MAXMSG("RawData",Msg::kWarning,100)
00141 << "RawLITimingSummary::GetRms() with minor id "
00142 << fCrateStatus->GetRawBlockId().GetMinor()
00143 << " assumes default scale factor" << endl;
00144 }
00145
00146 case 5:
00147 return fIntRms * 0.0625;
00148 break;
00149 case 0:
00150 case 1:
00151 case 2:
00152 case 3:
00153 case 4:
00154 return fIntRms * 0.25;
00155 break;
00156 }
00157 }
00158
00159
00160 void RawLITimingSummary::Print(Option_t *option) const
00161 {
00162 FormatToOStream(cout,option);
00163 }
00164
00165
00166 std::ostream& RawLITimingSummary::FormatToOStream(std::ostream& os,
00167 Option_t * ) const
00168 {
00169 MsgFormat ffmt("%9.2f");
00170 MsgFormat ifmt("%7d");
00171
00172 os << " " << fRawChannelId
00173 << " " << setw(5) << fEntries
00174 << " " << ffmt(GetMean())
00175 << " (" << ifmt(fIntMean) << ")"
00176 << " " << ffmt(GetRms())
00177 << " (" << ifmt(fIntRms) << ")"
00178 << endl;
00179
00180 return os;
00181 }
00182
00183
00184 void RawLITimingSummary::BuildRawChannelId(const RawCrateStatus *cstat, Int_t chadd)
00185 {
00186 Detector::Detector_t detector =
00187 cstat->GetRawBlockId().GetDetector();
00188 ElecType::Elec_t etype = cstat->GetElecType();
00189 Bool_t pedMode = cstat->GetPedMode();
00190 Bool_t sparsMode = cstat->GetSparsMode();
00191 Bool_t commonMode = cstat->GetCommonMode();
00192 Int_t crate = cstat->GetCrate();
00193
00194 fRawChannelId = RawChannelId(detector,etype,crate,chadd);
00195 fRawChannelId.SetModeBits(commonMode,sparsMode,pedMode);
00196 }
00197