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

PlexRawChannelReadoutType.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PlexRawChannelReadoutType.cxx,v 1.14 2005/08/26 18:47:03 rhatcher Exp $
00003 //
00004 // PlexRawChannelReadoutType
00005 //
00006 // Package: Plex
00007 //
00008 // R. Hatcher  2001-07-16
00009 //
00010 // Concept:
00011 //   
00012 // Purpose:
00013 //
00015 
00016 #include "Plex/PlexRawChannelReadoutType.h"
00017 #include "MessageService/MsgService.h"
00018 #include "DatabaseInterface/DbiOutRowStream.h"
00019 #include "DatabaseInterface/DbiResultSet.h"
00020 #include "DatabaseInterface/DbiValidityRec.h"
00021 
00022 ClassImp(PlexRawChannelReadoutType)
00023 
00024 //   Definition of static data members
00025 //   *********************************
00026 
00027 CVSID("$Id: PlexRawChannelReadoutType.cxx,v 1.14 2005/08/26 18:47:03 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00028 Bool_t PlexRawChannelReadoutType::fgDefensiveUnpkg = kFALSE;
00029 
00030 //  Instantiate associated Result Pointer class.
00031 //  *******************************************
00032 
00033 #include "DatabaseInterface/DbiResultPtr.tpl"
00034 template class  DbiResultPtr<PlexRawChannelReadoutType>;
00035 
00036 #include "DatabaseInterface/DbiWriter.tpl"
00037 template class  DbiWriter<PlexRawChannelReadoutType>;
00038 
00039 // Definition of member functions (alphabetical order)
00040 // ***************************************************
00041 
00042 
00043 //.....................................................................
00044 
00045 void PlexRawChannelReadoutType::Fill(DbiResultSet& rs,
00046                                       const DbiValidityRec* vrec) {
00047 //
00048 //
00049 //  Purpose:  Fill object from Result Set
00050 //
00051 //  Arguments: 
00052 //    rs           in    Result Set used to fill object
00053 //    vrec         in    Associated validity record (or 0 if filling
00054 //                                                    DbiValidityRec)
00055 //
00056 //  Return:    
00057 //
00058 //  Contact:   R. Hatcher
00059 //
00060 //  Specification:-
00061 //  =============
00062 //
00063 //  o Fill object from current row of Result Set.
00064 
00065 //  Program Notes:-
00066 //  =============
00067 
00068 //  None.
00069 
00070    Detector::Detector_t det =
00071       (Detector::Detector_t) 
00072       ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00073 
00074    char   elecName = '?';
00075    char   elecType = ElecType::kUnknown;
00076    int    crate=0, chadd=0;
00077    int    varc, vmm, adcsel, vachip, vachan;
00078    int    geoaddr, master, minder;
00079 
00080    fDescript = "Unknown";
00081 
00082    if (fgDefensiveUnpkg) {
00083 
00084       // unpack allowing for various column names and ordering
00085 
00086       Int_t numCol = rs.NumCols();
00087       //  The first column (SeqNo) has already been processed.
00088       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00089          string colName = rs.CurColName();
00090          if      ( colName == "ELECNAME"    ) rs >> elecName;
00091          else if ( colName == "CRATE"       ) rs >> crate;
00092          else if ( colName == "CHADD"       ) rs >> chadd;
00093          else if ( colName == "VARC"        ) rs >> varc;
00094          else if ( colName == "VMM"         ) rs >> vmm;
00095          else if ( colName == "VAADCSEL"    ) rs >> adcsel;
00096          else if ( colName == "VACHIP"      ) rs >> vachip;
00097          else if ( colName == "VACHAN"      ) rs >> vachan;
00098          else if ( colName == "GEOADDR"     ) rs >> geoaddr;
00099          else if ( colName == "MASTER"      ) rs >> master;
00100          else if ( colName == "MINDER"      ) rs >> minder;
00101          else if ( colName == "READOUTNAME" ) rs >> fDescript;
00102          else {
00103             static int nmsg = 25;
00104             if (nmsg-- > 0) MSG("Plex",Msg::kWarning) 
00105                << "Ignoring column " << rs.CurColNum()
00106                << " (of " << rs.NumCols() << ")"
00107                << " \""<< colName << "\"; not part of "
00108                << ClassName() << endl;
00109             rs.IncrementCurCol();
00110          }
00111       }
00112    } // end defensive unpacking
00113    else {
00114 //       SeqNo         int,
00115 //       ElecName      tinytext,
00116 //       Crate         tinyint,
00117 //       VARC          tinyint,
00118 //       VMM           tinyint,
00119 //       VaAdcSel      tinyint,
00120 //       VaChip        tinyint,
00121 //       VaChan        tinyint,
00122 //       GeoAddr       tinyint,
00123 //       Master        tinyint,
00124 //       Minder        tinyint,
00125 //       ReadoutName   tinytext
00126 
00127       rs >> elecName
00128          >> crate
00129          >> varc
00130          >> vmm
00131          >> adcsel
00132          >> vachip
00133          >> vachan
00134          >> geoaddr
00135          >> master
00136          >> minder
00137          >> fDescript;
00138    }
00139 
00140    ElecType::Elec_t elec = ElecType::CharToEnum(elecName);
00141    if (ElecType::kUnknown == elec)  elec = (ElecType::Elec_t) elecType;
00142 
00143    fReadoutType = ReadoutType::StringToEnum(fDescript.c_str());
00144 
00145    if (chadd) {
00146      fRawChannelId = RawChannelId(det,elec,crate,chadd);
00147    } 
00148    else if (ElecType::kVA == elec) {
00149      fRawChannelId = RawChannelId(det,elec,crate,varc,vmm,adcsel,vachip,vachan);
00150    }
00151    else if (ElecType::kQIE == elec) {
00152      fRawChannelId = RawChannelId(det,elec,crate,geoaddr,master,minder);
00153    } else {
00154       MSG("Plex",Msg::kWarning) 
00155          << " bad electronics type \"" << elecName << "\"" << endl;
00156    }
00157 
00158    MSG("Plex",Msg::kDebug)
00159      << "PlexRawChannelReadoutType::Fill "
00160      << fRawChannelId << " is " << ReadoutType::AsString(fReadoutType)
00161      << " '" << fDescript << "'"
00162      << endl;
00163 
00164 }
00165 //.....................................................................
00166 
00167 void PlexRawChannelReadoutType::Store(DbiOutRowStream& ors,
00168                                       const DbiValidityRec* /* vrec */) const {
00169 //
00170 //
00171 //  Purpose:  Stream object to output row stream
00172 //
00173 //  Arguments: 
00174 //    ors          in     Output row stream.
00175 //    vrec         in     Associated validity record (or 0 if filling
00176 //                                                    DbiValidityRec)
00177 //
00178 //  Return:    
00179 //
00180 //  Contact:   R. Hatcher
00181 //
00182 //  Specification:-
00183 //  =============
00184 //
00185 //  o  Stream object to output row stream.
00186 
00187 //  Program Notes:-
00188 //  =============
00189 
00190 //  None.
00191 
00192    ElecType::Elec_t etype = fRawChannelId.GetElecType();
00193    unsigned int chadd = fRawChannelId.GetChAdd();
00194    unsigned int varc=0, vmm=0, adcsel=0, vachip=0, vachan=0;
00195    unsigned int geoaddr=0, master=0, minder=0;
00196 
00197    if (ElecType::kVA == etype) {
00198      RawChannelId::DecompChAdd(chadd,varc,vmm,adcsel,vachip,vachan);
00199    }
00200    else if (ElecType::kQIE == etype) {
00201      RawChannelId::DecompChAdd(chadd,geoaddr,master,minder);
00202    }
00203 
00204    ors << ElecType::AsString(etype)
00205        << fRawChannelId.GetCrate()
00206        << varc << vmm << adcsel << vachip << vachan
00207        << geoaddr << master << minder
00208        << fDescript;   
00209 }
00210 
00211 /*    Template for New Member Function
00212 
00213 //.....................................................................
00214 
00215 PlexRawChannelReadoutType:: {
00216 //
00217 //
00218 //  Purpose:  
00219 //
00220 //  Arguments: 
00221 //    xxxxxxxxx    in    yyyyyy
00222 //
00223 //  Return:    
00224 //
00225 //  Contact:   R. Hatcher
00226 //
00227 //  Specification:-
00228 //  =============
00229 //
00230 //  o 
00231 
00232 //  Program Notes:-
00233 //  =============
00234 
00235 //  None.
00236 
00237 
00238 }
00239 
00240 */
00241 

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