00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "RawData/RawLIAdcSummary.h"
00013
00014 #include "MessageService/MsgService.h"
00015 CVSID("$Id: RawLIAdcSummary.cxx,v 1.19 2005/08/26 19:04:53 rhatcher Exp $");
00016
00017 #include "MessageService/MsgFormat.h"
00018 #include "MessageService/MsgStream.h"
00019
00020 ClassImp(RawLIAdcSummary)
00021
00022
00023 std::ostream& operator<<(std::ostream& os, const RawLIAdcSummary& s)
00024 { return s.FormatToOStream(os); }
00025
00026
00027 RawLIAdcSummary::RawLIAdcSummary()
00028 : fCrateStatus(0), fRawChannelId(0), fEntries(-1), fIntMean(-1), fIntRms(-1)
00029 {
00030
00031
00032
00033 }
00034
00035
00036 RawLIAdcSummary::RawLIAdcSummary(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
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 const Int_t maskShort = 0xffff;
00076
00077 switch (minorVersion) {
00078 case 0:
00079 {
00080
00081 Int_t chadd = p[0] & maskShort;
00082 BuildRawChannelId(cstat,chadd);
00083
00084 fEntries = ( p[0] >> 16 ) & maskShort;
00085 fIntMean = p[1] & maskShort;
00086 fIntRms = ( p[1] >> 16 ) & maskShort;
00087
00088
00089 p += 2;
00090 break;
00091 }
00092 case 1:
00093 {
00094 Int_t chadd = ( p[0] >> 16 ) & maskShort;
00095 BuildRawChannelId(cstat,chadd);
00096
00097 fEntries = p[0] & maskShort;
00098 fIntMean = ( p[1] >> 16 ) & maskShort;
00099 fIntRms = p[1] & maskShort;
00100
00101
00102 p += 2;
00103 break;
00104 }
00105 case 2:
00106 {
00107 Int_t chadd = ( p[0] >> 16) & maskShort;
00108 BuildRawChannelId(cstat,chadd);
00109
00110 const Int_t maskMean1 = 0x0001ffff;
00111 const Int_t maskRMS1 = 0x00007fff;
00112 const Int_t mean1signbit = 0x00010000;
00113 const Int_t mean1signext = 0xffff0000;
00114
00115 fEntries = p[0] & maskShort;
00116 fIntMean = ( p[1] >> 15 ) & maskMean1;
00117 if (fIntMean & mean1signbit ) fIntMean |= mean1signext;
00118 fIntRms = p[1] & maskRMS1;
00119
00120
00121 p += 2;
00122 break;
00123 }
00124 case 3:
00125 case 4:
00126 {
00127 Int_t chadd = ( p[0] >> 16) & maskShort;
00128 BuildRawChannelId(cstat,chadd);
00129 fEntries = p[0] & maskShort;
00130
00131 ElecType::Elec_t elec = fCrateStatus->GetElecType();
00132
00133 switch (elec) {
00134 default:
00135 {
00136 static Int_t nmsg = 10;
00137 if (nmsg>0) {
00138 --nmsg;
00139 MSG("RawData",Msg::kWarning)
00140 << "RawLIAdcSummary::ctor with unhandled electronics type "
00141 << (int)elec << " " << ElecType::AsString(elec) << endl;
00142 }
00143
00144 }
00145 case ElecType::kVA:
00146 {
00147 const Int_t maskVAMean = 0x0001ffff;
00148 const Int_t maskVARMS = 0x00007fff;
00149 const Int_t meanVAsignbit = 0x00010000;
00150 const Int_t meanVAsignext = 0xffff0000;
00151
00152 fIntMean = ( p[1] >> 15 ) & maskVAMean;
00153 if (fIntMean & meanVAsignbit ) fIntMean |= meanVAsignext;
00154 fIntRms = p[1] & maskVARMS;
00155 break;
00156 }
00157 case ElecType::kQIE:
00158 {
00159 const Int_t maskQIEMean = 0x0000ffff;
00160 const Int_t maskQIERMS = 0x0000ffff;
00161
00162 fIntMean = ( p[1] >> 16 ) & maskQIEMean;
00163 fIntRms = p[1] & maskQIERMS;
00164 break;
00165 }
00166 }
00167
00168
00169 p += 2;
00170 break;
00171 }
00172 default:
00173 {
00174 MAXMSG("RawData",Msg::kWarning,10)
00175 << "RawLIAdcSummary::ctor with minor id "
00176 << cstat->GetRawBlockId().GetMinor()
00177 << " unknown layout" << endl;
00178
00179 }
00180 case 5:
00181 {
00182 Int_t chadd = ( p[0] >> 16) & maskShort;
00183 BuildRawChannelId(cstat,chadd);
00184 fEntries = p[0] & maskShort;
00185
00186 ElecType::Elec_t elec = fCrateStatus->GetElecType();
00187
00188 switch (elec) {
00189 default:
00190 {
00191 static Int_t nmsg = 10;
00192 if (nmsg>0) {
00193 --nmsg;
00194 MSG("RawData",Msg::kWarning)
00195 << "RawLIAdcSummary::ctor with unhandled electronics type "
00196 << (int)elec << " " << ElecType::AsString(elec) << endl;
00197 }
00198
00199 }
00200 case ElecType::kVA:
00201 {
00202 const Int_t maskVAMean = 0x0001ffff;
00203 const Int_t maskVARMS = 0x00007fff;
00204 const Int_t meanVAsignbit = 0x00010000;
00205 const Int_t meanVAsignext = 0xffff0000;
00206
00207 fIntMean = ( p[1] >> 15 ) & maskVAMean;
00208 if (fIntMean & meanVAsignbit ) fIntMean |= meanVAsignext;
00209 fIntRms = p[1] & maskVARMS;
00210 break;
00211 }
00212 case ElecType::kQIE:
00213 {
00214 const Int_t maskQIEMean = 0x0001ffff;
00215 const Int_t maskQIERMS = 0x00007fff;
00216
00217 fIntMean = ( p[1] >> 15 ) & maskQIEMean;
00218 fIntRms = p[1] & maskQIERMS;
00219 break;
00220 }
00221 }
00222
00223
00224 p += 2;
00225 break;
00226 }
00227 }
00228
00229 }
00230
00231
00232 RawLIAdcSummary::~RawLIAdcSummary()
00233 {
00234
00235
00236 }
00237
00238
00239 Float_t RawLIAdcSummary::GetMean() const
00240 {
00241
00242
00243 switch (fCrateStatus->GetRawBlockId().GetMinor()) {
00244 case 0:
00245 case 1:
00246 return fIntMean * 0.25;
00247 break;
00248 case 2:
00249 return fIntMean * 0.25;
00250 break;
00251 case 3:
00252 return fIntMean *
00253 ( (fCrateStatus->GetElecType() == ElecType::kQIE) ? 1.0 : 0.25 );
00254 break;
00255 default:
00256 {
00257 MAXMSG("RawData",Msg::kWarning,100)
00258 << "RawLIAdcSummary::GetMean() with minor id "
00259 << fCrateStatus->GetRawBlockId().GetMinor()
00260 << " assumes default scale factor" << endl;
00261 }
00262
00263 case 4:
00264 case 5:
00265 return fIntMean *
00266 ( (fCrateStatus->GetElecType() == ElecType::kQIE) ? 1.0 : 0.25 )
00267 + ((fCrateStatus->GetElecType() == ElecType::kQIE) ? -50 : 0 );
00268 break;
00269 }
00270 }
00271
00272
00273 Float_t RawLIAdcSummary::GetRms() const
00274 {
00275
00276
00277 switch (fCrateStatus->GetRawBlockId().GetMinor()) {
00278 case 0:
00279 case 1:
00280 return fIntRms * 0.25;
00281 break;
00282 case 2:
00283 return fIntRms * 0.5;
00284 break;
00285 default:
00286 {
00287 MAXMSG("RawData",Msg::kWarning,100)
00288 << "RawLIAdcSummary::GetRms() with minor id "
00289 << fCrateStatus->GetRawBlockId().GetMinor()
00290 << " assumes default scale factor" << endl;
00291 }
00292
00293 case 3:
00294 case 4:
00295 case 5:
00296 return fIntRms *
00297 ( (fCrateStatus->GetElecType() == ElecType::kQIE) ? 1.0 : 0.5 );
00298 break;
00299 }
00300 }
00301
00302
00303 void RawLIAdcSummary::Print(Option_t *option) const
00304 {
00305 FormatToOStream(cout,option);
00306 }
00307
00308
00309 std::ostream& RawLIAdcSummary::FormatToOStream(std::ostream& os,
00310 Option_t * ) const
00311 {
00312 MsgFormat ffmt("%9.2f");
00313 MsgFormat ifmt("%7d");
00314
00315 os << " " << fRawChannelId
00316 << " " << setw(5) << fEntries
00317 << " " << ffmt(GetMean())
00318 << " (" << ifmt(fIntMean) << ")"
00319 << " " << ffmt(GetRms())
00320 << " (" << ifmt(fIntRms) << ")"
00321 << endl;
00322
00323 return os;
00324 }
00325
00326
00327 void RawLIAdcSummary::BuildRawChannelId(const RawCrateStatus *cstat, Int_t chadd)
00328 {
00329 Detector::Detector_t detector =
00330 cstat->GetRawBlockId().GetDetector();
00331 ElecType::Elec_t etype = cstat->GetElecType();
00332 Bool_t pedMode = cstat->GetPedMode();
00333 Bool_t sparsMode = cstat->GetSparsMode();
00334 Bool_t commonMode = cstat->GetCommonMode();
00335 Int_t crate = cstat->GetCrate();
00336
00337 fRawChannelId = RawChannelId(detector,etype,crate,chadd);
00338 fRawChannelId.SetModeBits(commonMode,sparsMode,pedMode);
00339 }
00340