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

PlexRawChannelToPinDiode.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PlexRawChannelToPinDiode.cxx,v 1.15 2005/08/26 18:47:03 rhatcher Exp $
00003 //
00004 // PlexRawChannelToPinDiode
00005 //
00006 // Package: Plex
00007 //
00008 // R. Hatcher  2001-07-16
00009 //
00010 // Concept:
00011 //   
00012 // Purpose:
00013 //
00015 
00016 #include "Plex/PlexRawChannelToPinDiode.h"
00017 #include "MessageService/MsgService.h"
00018 #include "DatabaseInterface/DbiOutRowStream.h"
00019 #include "DatabaseInterface/DbiResultSet.h"
00020 #include "DatabaseInterface/DbiValidityRec.h"
00021 
00022 ClassImp(PlexRawChannelToPinDiode)
00023 
00024 //   Definition of static data members
00025 //   *********************************
00026 
00027 CVSID("$Id: PlexRawChannelToPinDiode.cxx,v 1.15 2005/08/26 18:47:03 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00028 Bool_t PlexRawChannelToPinDiode::fgDefensiveUnpkg = kFALSE;
00029 
00030 //  Instantiate associated Result Pointer class.
00031 //  *******************************************
00032 
00033 #include "DatabaseInterface/DbiResultPtr.tpl"
00034 template class  DbiResultPtr<PlexRawChannelToPinDiode>;
00035 
00036 #include "DatabaseInterface/DbiWriter.tpl"
00037 template class  DbiWriter<PlexRawChannelToPinDiode>;
00038 
00039 // Definition of member functions (alphabetical order)
00040 // ***************************************************
00041 
00042 
00043 //.....................................................................
00044 
00045 void PlexRawChannelToPinDiode::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    char   rackEastWest='?', rackLevel='?';
00077    int    rackBay=0, muxboxInRack=0;
00078    int    crate=0, chadd=0, muxbox=0, inbox=0, gain=0;
00079    int    varc, vmm, adcsel, vachip, vachan;
00080    int    geoaddr, master, minder;
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 == "AGGREGATENO" ) rs >> fAggregate;
00091          else if ( colName == "ELECTYPE"    ) rs >> elecType;
00092          else if ( colName == "ELECNAME"    ) rs >> elecName;
00093          else if ( colName == "CRATE"       ) rs >> crate;
00094          else if ( colName == "CHADD"       ) rs >> chadd;
00095          else if ( colName == "VARC"        ) rs >> varc;
00096          else if ( colName == "VMM"         ) rs >> vmm;
00097          else if ( colName == "VFB"         ) rs >> adcsel;
00098          else if ( colName == "VAADCSEL"    ) rs >> adcsel;
00099          else if ( colName == "VACHIP"      ) rs >> vachip;
00100          else if ( colName == "VACHAN"      ) rs >> vachan;
00101          else if ( colName == "GEOADDR"     ) rs >> geoaddr;
00102          else if ( colName == "MASTER"      ) rs >> master;
00103          else if ( colName == "MINDER"      ) rs >> minder;
00104          else if ( colName == "MUXBOX"      ) rs >> muxbox;
00105          else if ( colName == "RACKEASTWEST") rs >> rackEastWest;
00106          else if ( colName == "RACKLEVEL"   ) rs >> rackLevel;
00107          else if ( colName == "RACKBAY"     ) rs >> rackBay;
00108          else if ( colName == "MUXBOXINRACK") rs >> muxboxInRack;
00109          else if ( colName == "INBOX"       ) rs >> inbox;
00110          else if ( colName == "DIODEINBOX"  ) rs >> inbox;
00111          else if ( colName == "GAIN"        ) rs >> gain;
00112          else {
00113             static int nmsg = 25;
00114             if (nmsg-- > 0) MSG("Plex",Msg::kWarning) 
00115                << "Ignoring column " << rs.CurColNum() 
00116                << " (of " << rs.NumCols() << ")"
00117                << " \""<< colName << "\"; not part of "
00118                << ClassName() << endl;
00119             rs.IncrementCurCol();
00120          }
00121       }
00122    } // end defensive unpacking
00123    else {
00124 //       SeqNo         int,
00125 //       AggregateNo   int,
00126 //       ElecName      tinytext,
00127 //       Crate         tinyint,
00128 //       VARC          tinyint,
00129 //       VMM           tinyint,
00130 //       VaAdcSel      tinyint,
00131 //       VaChip        tinyint,
00132 //       VaChan        tinyint,
00133 //       GeoAddr       tinyint,
00134 //       Master        tinyint,
00135 //       Minder        tinyint,
00136 //       RackEastWest  char(1),
00137 //       RackLevel     char(1),
00138 //       RackBay       tinyint,
00139 //       MuxBoxInRack  tinyint,
00140 //       DiodeInBox    tinyint,
00141 //       Gain          tinyint
00142 
00143       rs >> fAggregate
00144          >> elecName
00145          >> crate
00146          >> varc
00147          >> vmm
00148          >> adcsel
00149          >> vachip
00150          >> vachan
00151          >> geoaddr
00152          >> master
00153          >> minder
00154          >> rackEastWest
00155          >> rackLevel
00156          >> rackBay
00157          >> muxboxInRack
00158          >> inbox
00159          >> gain;
00160 
00161    }
00162 
00163    ElecType::Elec_t elec = ElecType::CharToEnum(elecName);
00164    if (ElecType::kUnknown == elec)  elec = (ElecType::Elec_t) elecType;
00165 
00166    if (chadd) {
00167      fRawChannelId = RawChannelId(det,elec,crate,chadd);
00168    } 
00169    else if (ElecType::kVA == elec) {
00170      fRawChannelId = RawChannelId(det,elec,crate,varc,vmm,adcsel,vachip,vachan);
00171    }
00172    else if (ElecType::kQIE == elec) {
00173      fRawChannelId = RawChannelId(det,elec,crate,geoaddr,master,minder);
00174    } else {
00175       MSG("Plex",Msg::kWarning) 
00176          << " bad electronics type \"" << elecName << "\"" << endl;
00177    }
00178 
00179    fPlexPinDiodeId = PlexPinDiodeId(det,elec,rackEastWest,rackLevel,
00180                                     rackBay,muxboxInRack,inbox,gain);
00181 
00182 }
00183 //.....................................................................
00184 
00185 void PlexRawChannelToPinDiode::Store(DbiOutRowStream& ors,
00186                                      const DbiValidityRec* /* vrec */) const {
00187 //
00188 //
00189 //  Purpose:  Stream object to output row stream
00190 //
00191 //  Arguments: 
00192 //    ors          in     Output row stream.
00193 //    vrec         in     Associated validity record (or 0 if filling
00194 //                                                    DbiValidityRec)
00195 //
00196 //  Return:    
00197 //
00198 //  Contact:   R. Hatcher
00199 //
00200 //  Specification:-
00201 //  =============
00202 //
00203 //  o  Stream object to output row stream.
00204 
00205 //  Program Notes:-
00206 //  =============
00207 
00208 //  None.
00209 
00210    Short_t varc=0, vmm=0, vaadcsel=0, vachip=0, vachan=0;
00211    Short_t geoaddr=0, master=0, minder=0;
00212 
00213    ElecType::Elec_t elec = fRawChannelId.GetElecType();
00214    switch (elec) {
00215    case ElecType::kVA:
00216       varc     = fRawChannelId.GetVarcId();
00217       vmm      = fRawChannelId.GetVmm();
00218       vaadcsel = fRawChannelId.GetVaAdcSel();
00219       vachip   = fRawChannelId.GetVaChip();
00220       vachan   = fRawChannelId.GetVaChannel();
00221       break;
00222    case ElecType::kQIE:
00223       geoaddr  = fRawChannelId.GetGeographicAddress();
00224       master   = fRawChannelId.GetMasterChannel();
00225       minder   = fRawChannelId.GetMinderChannel();
00226       break;
00227    default:
00228       MSG("Plex",Msg::kWarning)
00229          << "Store had badd electronics type "
00230          << ElecType::AsString(elec) << " (" << (int)elec << ")" << endl;
00231       break;
00232    }
00233 
00234    //   int  numeric      = fPlexPinDiodeId.GetNumericMuxBox();
00235    char rackEastWest = fPlexPinDiodeId.GetEastWest();
00236    char rackLevel    = fPlexPinDiodeId.GetRackLevel();
00237    int  rackBay      = fPlexPinDiodeId.GetRackBay();
00238    int  muxInRack    = fPlexPinDiodeId.GetInRack();
00239 
00240    ors << fAggregate
00241        << ElecType::AsString(elec)
00242        << fRawChannelId.GetCrate()
00243        << varc
00244        << vmm
00245        << vaadcsel
00246        << vachip
00247        << vachan
00248        << geoaddr
00249        << master
00250        << minder
00251        << rackEastWest
00252        << rackLevel
00253        << rackBay
00254        << muxInRack
00255        << fPlexPinDiodeId.GetInBox()
00256        << fPlexPinDiodeId.GetGain();
00257 }
00258 
00259 /*    Template for New Member Function
00260 
00261 //.....................................................................
00262 
00263 PlexRawChannelToPinDiode:: {
00264 //
00265 //
00266 //  Purpose:  
00267 //
00268 //  Arguments: 
00269 //    xxxxxxxxx    in    yyyyyy
00270 //
00271 //  Return:    
00272 //
00273 //  Contact:   R. Hatcher
00274 //
00275 //  Specification:-
00276 //  =============
00277 //
00278 //  o 
00279 
00280 //  Program Notes:-
00281 //  =============
00282 
00283 //  None.
00284 
00285 
00286 }
00287 
00288 */
00289 

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