Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

RawLIAdcSummary.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawLIAdcSummary.cxx,v 1.19 2005/08/26 19:04:53 rhatcher Exp $
00003 // 
00004 // RawLIAdcSummary
00005 // 
00006 // RawLITimingSummary is the unpacked Adc summary for one channel
00007 //
00008 // Author:  R. Hatcher 2000.04.19
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    // Default constructor
00031 
00032    // MSG("RawData",Msg::kWarning) << "RawLIAdcSummary default ctor" << endl;
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    // this is where the everything is actually unpacked
00043 
00044    // version 0:
00045    // 1st 32-bit word: no of entries (16); Chadd (16)
00046    // 2nd 32-bit word: RMS (16); Mean (16)
00047    // Mean and RMS are both scaled by a factor of 4, so that they have a
00048    // two-binal resolution.
00049 
00050    // version 1:
00051    // 1st 32-bit word: Chadd (16); no of entries (16)
00052    // 2nd 32-bit word: Mean (16);  RMS (16)
00053    // Mean and RMS are both scaled by a factor of 4, so that they have a
00054    // two-binal resolution.
00055 
00056    // version 2:
00057    // 1st 32-bit word: Chadd (16); no of entries (16)
00058    // 2nd 32-bit word: Mean (17);  RMS (15)
00059    // Mean is scaled by a factor of 4 and RMS scaled by 2.
00060    // Mean is a 2's complement # (ie. when unpacking high order bit
00061    // of the field must be sign extended).
00062 
00063    // version 3:
00064    // Same as 2 for VA electronics, but different for QIE electronics
00065    // 2nd 32-bin word: Mean (16); RMS (16) for QIE electronics
00066    // Mean is unscaled (positive int), RMS is unscaled
00067  
00068    // version 4:
00069    // Same as v3, but QIE Means have 50 counts added.
00070    // Put change in GetMean() only.
00071 
00072    // version 5:
00073    // Same as v4, but QIE Means use 17 bits and RMS only 15
00074 
00075    const Int_t maskShort = 0xffff;
00076 
00077    switch (minorVersion) {
00078    case 0:
00079    {
00080       // note this version had upper/lower swapped from v1, v2...
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       // advance pointer by amount it eats up
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       // advance pointer by amount it eats up
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       // advance pointer by amount it eats up
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         // don't break, fall through to VA
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       } // end ElecType case
00167 
00168       // advance pointer by amount it eats up
00169       p += 2;
00170       break;
00171    }
00172    default:  // minor version #
00173    {
00174      MAXMSG("RawData",Msg::kWarning,10)
00175        << "RawLIAdcSummary::ctor with minor id "
00176        << cstat->GetRawBlockId().GetMinor()
00177        << " unknown layout" << endl;
00178      // don't break, fall through to latest
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         // don't break, fall through to VA
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       } // end ElecType case
00222 
00223       // advance pointer by amount it eats up
00224       p += 2;
00225       break;
00226    }
00227    } // end minor version number switch
00228 
00229 }
00230 
00231 //_____________________________________________________________________________
00232 RawLIAdcSummary::~RawLIAdcSummary()
00233 {
00234    // delete all owned sub-objects
00235 
00236 }
00237 
00238 //_____________________________________________________________________________
00239 Float_t RawLIAdcSummary::GetMean() const
00240 {
00241    // return unscaled mean
00242    
00243    switch (fCrateStatus->GetRawBlockId().GetMinor()) {
00244    case 0:
00245    case 1:
00246       return fIntMean * 0.25;  // scale factor of 4
00247       break;
00248    case 2:
00249       return fIntMean * 0.25;  // scale factor of 4
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       // don't break, fall through to latest
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    // return unscaled RMS
00276    
00277    switch (fCrateStatus->GetRawBlockId().GetMinor()) {
00278    case 0:
00279    case 1:
00280       return fIntRms * 0.25;  // scale factor of 4
00281       break;
00282    case 2:
00283       return fIntRms * 0.5;   // scale factor of 2
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       // don't break, fall through to latest
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 * /* option */) 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 //_____________________________________________________________________________

Generated on Mon Nov 23 05:28:10 2009 for loon by  doxygen 1.3.9.1