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

RawLITimingSummary.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RawLITimingSummary.cxx,v 1.16 2005/08/26 19:04:53 rhatcher Exp $
00003 // 
00004 // RawLITimingSummary
00005 // 
00006 // RawLITimingSummary is the unpacked Timing summary for one channel
00007 //
00008 // Author:  R. Hatcher 2000.04.19
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    // Default constructor
00031 
00032    // MSG("RawData",Msg::kWarning) << "RawLITimingSummary default ctor" << endl;
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    // this is where the everything is actually unpacked
00043 
00044    // version 0,1,2:
00045    // 1st 32-bit word: Chadd (16); no of entries (16)   (v0 U/L swapped)
00046    // 2nd 32-bit word: Mean 
00047    // 3rd 32-bit word: RMS
00048    // Mean and RMS are both scaled by a factor of 4
00049 
00050    const Int_t maskShort = 0xffff;
00051 
00052    switch (minorVersion) {
00053    case 0:
00054    {
00055       // note this version had upper/lower swapped from v1, v2...
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       // advance pointer by amount it eats up
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      // don't break, fall through to latest
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       // advance pointer by amount it eats up
00091       p += 3;
00092       break;
00093    }  
00094    } // end minor version number switch
00095 
00096 }
00097 
00098 //_____________________________________________________________________________
00099 RawLITimingSummary::~RawLITimingSummary()
00100 {
00101    // delete all owned sub-objects
00102 
00103 }
00104 
00105 //_____________________________________________________________________________
00106 Float_t RawLITimingSummary::GetMean() const
00107 {
00108    // return unscaled mean
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       // don't break, fall through to latest
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    // return unscaled RMS
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       // don't break, fall through to latest
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 * /* option */) 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 //_____________________________________________________________________________

Generated on Mon Feb 15 11:07:28 2010 for loon by  doxygen 1.3.9.1