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

PlexPixelToRawChannel.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PlexPixelToRawChannel.cxx,v 1.14 2005/08/26 18:47:03 rhatcher Exp $
00003 //
00004 // PlexPixelToRawChannel
00005 //
00006 // Package: Plex
00007 //
00008 // R. Hatcher  2001-06-27
00009 //
00010 // Concept: 
00011 //   
00012 // Purpose: 
00013 //
00015 
00016 #include "Plex/PlexPixelToRawChannel.h"
00017 #include "MessageService/MsgService.h"
00018 #include "DatabaseInterface/DbiOutRowStream.h"
00019 #include "DatabaseInterface/DbiResultSet.h"
00020 #include "DatabaseInterface/DbiValidityRec.h"
00021 
00022 ClassImp(PlexPixelToRawChannel)
00023 
00024 //   Definition of static data members
00025 //   *********************************
00026 
00027 CVSID("$Id: PlexPixelToRawChannel.cxx,v 1.14 2005/08/26 18:47:03 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00028 Bool_t PlexPixelToRawChannel::fgDefensiveUnpkg = kFALSE;
00029 
00030 //  Instantiate associated Result Pointer class.
00031 //  *******************************************
00032 
00033 #include "DatabaseInterface/DbiResultPtr.tpl"
00034 template class  DbiResultPtr<PlexPixelToRawChannel>;
00035 
00036 #include "DatabaseInterface/DbiWriter.tpl"
00037 template class  DbiWriter<PlexPixelToRawChannel>;
00038 
00039 // Definition of member functions (alphabetical order)
00040 // ***************************************************
00041 
00042 
00043 //.....................................................................
00044 
00045 void PlexPixelToRawChannel::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    muxbox=0, tube, pixel;
00079    int    crate=0, chadd=0;
00080    int    varc, vmm, adcsel, vachip, vachan;
00081    int    geoaddr, master, minder;
00082 
00083    if (fgDefensiveUnpkg) {
00084 
00085       // unpack allowing for various column names and ordering
00086 
00087       Int_t numCol = rs.NumCols();
00088       //  The first column (SeqNo) has already been processed.
00089       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00090          string colName = rs.CurColName();
00091          if (      colName == "AGGREGATENO" ) rs >> fAggregate;
00092          else if ( colName == "ELECTYPE"    ) rs >> elecType;
00093          else if ( colName == "ELECNAME"    ) rs >> elecName;
00094          else if ( colName == "CRATE"       ) rs >> crate;
00095          else if ( colName == "CHADD"       ) rs >> chadd;
00096          else if ( colName == "VARC"        ) rs >> varc;
00097          else if ( colName == "VMM"         ) rs >> vmm;
00098          else if ( colName == "VFB"         ) rs >> adcsel;
00099          else if ( colName == "VAADCSEL"    ) rs >> adcsel;
00100          else if ( colName == "VACHIP"      ) rs >> vachip;
00101          else if ( colName == "VACHAN"      ) rs >> vachan;
00102          else if ( colName == "GEOADDR"     ) rs >> geoaddr;
00103          else if ( colName == "MASTER"      ) rs >> master;
00104          else if ( colName == "MINDER"      ) rs >> minder;
00105          else if ( colName == "MUXBOX"      ) rs >> muxbox;
00106          else if ( colName == "RACKEASTWEST") rs >> rackEastWest;
00107          else if ( colName == "RACKLEVEL"   ) rs >> rackLevel;
00108          else if ( colName == "RACKBAY"     ) rs >> rackBay;
00109          else if ( colName == "MUXBOXINRACK") rs >> muxboxInRack;
00110          else if ( colName == "TUBE"        ) rs >> tube;
00111          else if ( colName == "PIXEL"       ) rs >> pixel;
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 //       RackEastWest  char(1),
00128 //       RackLevel     char(1),
00129 //       RackBay       tinyint,
00130 //       MuxBoxInRack  tinyint,
00131 //       Tube          tinyint,
00132 //       Pixel         tinyint,
00133 //       Crate         tinyint,
00134 //       VARC          tinyint,
00135 //       VMM           tinyint,
00136 //       VaAdcSel      tinyint,
00137 //       VaChip        tinyint,
00138 //       VaChan        tinyint,
00139 //       GeoAddr       tinyint,
00140 //       Master        tinyint,
00141 //       Minder        tinyint
00142 
00143       rs >> fAggregate
00144          >> elecName
00145          >> rackEastWest
00146          >> rackLevel
00147          >> rackBay
00148          >> muxboxInRack
00149          >> tube
00150          >> pixel
00151          >> crate
00152          >> varc
00153          >> vmm
00154          >> adcsel
00155          >> vachip
00156          >> vachan
00157          >> geoaddr
00158          >> master
00159          >> minder;
00160    }
00161 
00162    const Int_t  spot       = 0;
00163 
00164    ElecType::Elec_t elec = ElecType::CharToEnum(elecName);
00165    if (ElecType::kUnknown == elec)  elec = (ElecType::Elec_t) elecType;
00166 
00167    if (chadd) {
00168      fRawChannelId = RawChannelId(det,elec,crate,chadd);
00169    } 
00170    else if (ElecType::kVA == elec) {
00171      fRawChannelId = RawChannelId(det,elec,crate,varc,vmm,adcsel,vachip,vachan);
00172                                    
00173    }
00174    else if (ElecType::kQIE == elec) {
00175      fRawChannelId = RawChannelId(det,elec,crate,geoaddr,master,minder);
00176    } else {
00177      MSG("Plex",Msg::kWarning) 
00178        << " bad electronics type \"" << elecName << "\"" << endl;
00179    }
00180 
00181    fPlexPixelSpotId = PlexPixelSpotId(det,elec,rackEastWest,rackLevel,
00182                                       rackBay,muxboxInRack,tube,pixel,spot);
00183 
00184 #ifdef AGGREGATE_TEST
00185    int  numeric = fPlexPixelSpotId.GetNumericMuxBox();
00186    MSG("Plex",Msg::kInfo)
00187      << "PlexPixelToRawChannel "
00188      << " aggrno " << fAggregate 
00189      << " 0x" << hex << setw(8) << fAggregate << dec
00190      << " numeric " << numeric 
00191      << " 0x" << hex << setw(8) << numeric << dec
00192      << endl;
00193 
00194    //  AggregateNo = MuxBoxInRack + 8*(RackBay-1)
00195    // + (if "top")128
00196    // + (if "west")256
00197 #endif
00198 
00199 //_____________________________________________________________________________
00200 
00201 }
00202 //.....................................................................
00203 
00204 void PlexPixelToRawChannel::Store(DbiOutRowStream& ors,
00205                                   const DbiValidityRec* /* vrec */) const {
00206 //
00207 //
00208 //  Purpose:  Stream object to output row stream
00209 //
00210 //  Arguments: 
00211 //    ors          in     Output row stream.
00212 //    vrec         in     Associated validity record (or 0 if filling
00213 //                                                    DbiValidityRec)
00214 //
00215 //  Return:    
00216 //
00217 //  Contact:   R. Hatcher
00218 //
00219 //  Specification:-
00220 //  =============
00221 //
00222 //  o  Stream object to output row stream.
00223 
00224 //  Program Notes:-
00225 //  =============
00226 
00227 //  None.
00228 
00229   int  elect   = (int)fPlexPixelSpotId.GetElecType();
00230   char rackEastWest = fPlexPixelSpotId.GetEastWest();
00231   char rackLevel    = fPlexPixelSpotId.GetRackLevel();
00232   int  rackBay      = fPlexPixelSpotId.GetRackBay();
00233   int  muxInRack    = fPlexPixelSpotId.GetInRack();
00234 
00235    ors << fAggregate 
00236        << elect
00237        << rackEastWest
00238        << rackLevel
00239        << rackBay
00240        << muxInRack
00241        << fPlexPixelSpotId.GetTube()
00242        << fPlexPixelSpotId.GetPixel()
00243        << fRawChannelId.GetCrate()
00244        << fRawChannelId.GetChAdd();
00245    
00246 }
00247 
00248 /*    Template for New Member Function
00249 
00250 //.....................................................................
00251 
00252 PlexPixelToRawChannel:: {
00253 //
00254 //
00255 //  Purpose:  
00256 //
00257 //  Arguments: 
00258 //    xxxxxxxxx    in    yyyyyy
00259 //
00260 //  Return:    
00261 //
00262 //  Contact:   R. Hatcher
00263 //
00264 //  Specification:-
00265 //  =============
00266 //
00267 //  o 
00268 
00269 //  Program Notes:-
00270 //  =============
00271 
00272 //  None.
00273 
00274 
00275 }
00276 
00277 */
00278 

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