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

DbuVaChipSpars.cxx

Go to the documentation of this file.
00001 
00002 // $Id: DbuVaChipSpars.cxx,v 1.7 2007/02/15 14:15:48 rhatcher Exp $
00003 //
00004 // DbuVaChipSpars
00005 //
00006 // Package: DatabaseUpdater
00007 //
00008 // R. Hatcher  2002-04-19
00009 //
00010 // Concept:
00011 //   
00012 // Purpose:
00013 //
00015 
00016 #include "DatabaseUpdater/DbuVaChipSpars.h"
00017 #include "MessageService/MsgService.h"
00018 #include "DatabaseInterface/DbiOutRowStream.h"
00019 #include "DatabaseInterface/DbiResultSet.h"
00020 #include "DatabaseInterface/DbiValidityRec.h"
00021 #include <iostream>
00022 
00023 #include <cassert>
00024 
00025 ClassImp(DbuVaChipSpars)
00026 
00027 //   Definition of static data members
00028 //   *********************************
00029 
00030 CVSID("$Id: DbuVaChipSpars.cxx,v 1.7 2007/02/15 14:15:48 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00031 
00032 //  Instantiate associated Result Pointer class.
00033 //  *******************************************
00034 
00035 #include "DatabaseInterface/DbiResultPtr.tpl"
00036 template class  DbiResultPtr<DbuVaChipSpars>;
00037 
00038 #include "DatabaseInterface/DbiWriter.tpl"
00039 template class  DbiWriter<DbuVaChipSpars>;
00040 
00041 const Int_t  maskPedMode   = 0x00200000;
00042 const Int_t  maskSparsMode = 0x00400000;
00043 const Int_t  maskComMode   = 0x00800000;
00044 const Int_t  maskModes     = maskPedMode | maskSparsMode | maskComMode;
00045 const Int_t  shiftModes    = 21;
00046 
00047 //.....................................................................
00048 
00049 std::ostream& operator<<(std::ostream& os, const DbuVaChipSpars& drs)
00050 {
00051    os << drs.GetName() 
00052       << " " << drs.fRawChannelId.AsString("e");
00053    for (int i=0; i<22; ++i) {
00054       if (0==i || 11==i) os << endl << " | ";
00055       os << setw(5) << drs.fChanPed[i];
00056    }
00057    os << endl;
00058 
00059    return os;
00060 }
00061 
00062 //.....................................................................
00063 
00064 // Definition of member functions (alphabetical order)
00065 // ***************************************************
00066 
00067 //.....................................................................
00068 
00069 void DbuVaChipSpars::Fill(DbiResultSet& rs,
00070                                       const DbiValidityRec* vrec) {
00071 //
00072 //
00073 //  Purpose:  Fill object from Result Set
00074 //
00075 //  Arguments: 
00076 //    rs           in    Result Set used to fill object
00077 //    vrec         in    Associated validity record (or 0 if filling
00078 //                                                    DbiValidityRec)
00079 //
00080 //  Return:    
00081 //
00082 //  Contact:   R. Hatcher
00083 //
00084 //  Specification:-
00085 //  =============
00086 //
00087 //  o Fill object from current row of Result Set.
00088 
00089 //  Program Notes:-
00090 //  =============
00091 
00092 //  None.
00093 
00094    Detector::Detector_t det =
00095       (Detector::Detector_t) 
00096       ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00097    
00098    ElecType::Elec_t elec = ElecType::kVA;
00099 
00100    UInt_t       crate, varc, vmm, adcsel, vachip;
00101    const UInt_t vachan = 0;
00102    Int_t        modeflags;
00103 
00104    rs >> crate
00105       >> modeflags
00106       >> varc
00107       >> vmm
00108       >> adcsel
00109       >> vachip;
00110    for (int i=0; i<22; ++i) rs >> fChanPed[i];
00111    
00112    modeflags  = modeflags << shiftModes;
00113    Bool_t pedMode    = modeflags & maskPedMode;
00114    Bool_t sparsMode  = modeflags & maskSparsMode;
00115    Bool_t commonMode = modeflags & maskComMode;
00116 
00117    fRawChannelId = RawChannelId(det,elec,crate,varc,vmm,adcsel,vachip,vachan);
00118    fRawChannelId.SetModeBits(commonMode,sparsMode,pedMode);
00119 
00120 }
00121 
00122 //.....................................................................
00123 
00124 void DbuVaChipSpars::Store(DbiOutRowStream& ors,
00125                            const DbiValidityRec* /* vrec */) const {
00126 //
00127 //
00128 //  Purpose:  Stream object to output row stream
00129 //
00130 //  Arguments: 
00131 //    ors          in     Output row stream.
00132 //    vrec         in     Associated validity record (or 0 if filling
00133 //                                                    DbiValidityRec)
00134 //
00135 //  Return:    
00136 //
00137 //  Contact:   R. Hatcher
00138 //
00139 //  Specification:-
00140 //  =============
00141 //
00142 //  o  Stream object to output row stream.
00143 
00144 //  Program Notes:-
00145 //  =============
00146 
00147 //  None.
00148 
00149    Int_t modeflags = 
00150       (fRawChannelId.GetEncoded() & maskModes) >> shiftModes;
00151 
00152    ors << fRawChannelId.GetCrate()
00153        << modeflags
00154        << fRawChannelId.GetVarcId()
00155        << fRawChannelId.GetVmm()
00156        << fRawChannelId.GetVaAdcSel()
00157        << fRawChannelId.GetVaChip();
00158    for (int i=0; i<22; ++i) ors << fChanPed[i];
00159 
00160 }
00161 
00162 //.....................................................................
00163 
00164 const char* DbuVaChipSpars::GetTableDescr()
00165 {
00166 //
00167 //
00168 //  Purpose:  Return a string describing rows in the table
00169 //            Used in creating temporary tables
00170 //
00171 //  Return:   const char* to parenthesized comma separated list
00172 //            of column name and type pairs
00173 //
00174 //  Contact:   R. Hatcher
00175 //
00176 //  Specification:-
00177 //  =============
00178 //
00179 
00180 //  Program Notes:-
00181 //  =============
00182 
00183 //  None.
00184 
00185    const char* const_tabledescr = "(\
00186        SEQNO             int,      \
00187        ROW_COUNTER       int,      \
00188        CRATE             smallint, \
00189        MODEFLAGS         tinyint,  \
00190        VARC              tinyint,  \
00191        VMM               tinyint,  \
00192        VAADCSEL          tinyint,  \
00193        VACHIP            tinyint,  \
00194        CHAN00            smallint, \
00195        CHAN01            smallint, \
00196        CHAN02            smallint, \
00197        CHAN03            smallint, \
00198        CHAN04            smallint, \
00199        CHAN05            smallint, \
00200        CHAN06            smallint, \
00201        CHAN07            smallint, \
00202        CHAN08            smallint, \
00203        CHAN09            smallint, \
00204        CHAN10            smallint, \
00205        CHAN11            smallint, \
00206        CHAN12            smallint, \
00207        CHAN13            smallint, \
00208        CHAN14            smallint, \
00209        CHAN15            smallint, \
00210        CHAN16            smallint, \
00211        CHAN17            smallint, \
00212        CHAN18            smallint, \
00213        CHAN19            smallint, \
00214        CHAN20            smallint, \
00215        CHAN21            smallint, \
00216        primary key (SEQNO,ROW_COUNTER) \
00217        )";
00218 
00219    return const_tabledescr;
00220 }
00221 
00222 
00223 /*    Template for New Member Function
00224 
00225 //.....................................................................
00226 
00227 DbuVaChipSpars:: {
00228 //
00229 //
00230 //  Purpose:  
00231 //
00232 //  Arguments: 
00233 //    xxxxxxxxx    in    yyyyyy
00234 //
00235 //  Return:    
00236 //
00237 //  Contact:   R. Hatcher
00238 //
00239 //  Specification:-
00240 //  =============
00241 //
00242 //  o 
00243 
00244 //  Program Notes:-
00245 //  =============
00246 
00247 //  None.
00248 
00249 
00250 }
00251 
00252 */
00253 

Generated on Mon Feb 15 11:06:36 2010 for loon by  doxygen 1.3.9.1