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

PlexPixelSpotToStripEnd.cxx

Go to the documentation of this file.
00001 
00002 // $Id: PlexPixelSpotToStripEnd.cxx,v 1.21 2005/08/26 18:47:03 rhatcher Exp $
00003 //
00004 // PlexPixelSpotToStripEnd
00005 //
00006 // Package: Plex
00007 //
00008 // R. Hatcher  2001-06-27
00009 //
00010 // Concept:
00011 //   
00012 // Purpose:
00013 //
00015 
00016 #include "Plex/PlexPixelSpotToStripEnd.h"
00017 #include "Plex/PlexVetoShieldHack.h"
00018 #include "MessageService/MsgService.h"
00019 #include "DatabaseInterface/DbiOutRowStream.h"
00020 #include "DatabaseInterface/DbiResultSet.h"
00021 #include "DatabaseInterface/DbiValidityRec.h"
00022 #include "Plex/PlexLoanPool.h"
00023 
00024 ClassImp(PlexPixelSpotToStripEnd)
00025 
00026 //   Definition of static data members
00027 //   *********************************
00028 
00029 CVSID("$Id: PlexPixelSpotToStripEnd.cxx,v 1.21 2005/08/26 18:47:03 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00030 Bool_t PlexPixelSpotToStripEnd::fgDefensiveUnpkg = kFALSE;
00031 
00032 //  Instantiate associated Result Pointer class.
00033 //  *******************************************
00034 
00035 #include "DatabaseInterface/DbiResultPtr.tpl"
00036 template class  DbiResultPtr<PlexPixelSpotToStripEnd>;
00037 
00038 #include "DatabaseInterface/DbiWriter.tpl"
00039 template class  DbiWriter<PlexPixelSpotToStripEnd>;
00040 
00041 // Definition of member functions (alphabetical order)
00042 // ***************************************************
00043 
00044 void PlexPixelSpotToStripEnd::Fill(DbiResultSet& rs,
00045                                    const DbiValidityRec* vrec) {
00046 //
00047 //
00048 //  Purpose:  Fill object from Result Set
00049 //
00050 //  Arguments: 
00051 //    rs           in    Result Set used to fill object
00052 //    vrec         in    Associated validity record (or 0 if filling
00053 //                                                    DbiValidityRec)
00054 //
00055 //  Return:    
00056 //
00057 //  Contact:   R. Hatcher
00058 //
00059 //  Specification:-
00060 //  =============
00061 //
00062 //  o Fill object from current row of Result Set.
00063 
00064 //  Program Notes:-
00065 //  =============
00066 
00067 //  None.
00068 
00069    Detector::Detector_t det =
00070       (Detector::Detector_t) 
00071       ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00072    
00073             char elecName = '?';
00074             char elecType = ElecType::kUnknown;
00075             char rackEastWest='?', rackLevel='?', endchar='?';
00076    unsigned int  rackBay=0, muxboxInRack=0;
00077    unsigned int  tube, pixel, spot;
00078    unsigned int  plane, strip;
00079 
00080    if (fgDefensiveUnpkg) {
00081 
00082       // unpack allowing for various column names and ordering
00083 
00084       Int_t numCol = rs.NumCols();
00085       //  The first column (SeqNo) has already been processed.
00086       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00087          string colName = rs.CurColName();
00088          if (      colName == "AGGREGATENO" ) rs >> fAggregate;
00089          else if ( colName == "ELECTYPE"    ) rs >> elecType;
00090          else if ( colName == "ELECNAME"    ) rs >> elecName;
00091          else if ( colName == "RACKEASTWEST") rs >> rackEastWest;
00092          else if ( colName == "RACKLEVEL"   ) rs >> rackLevel;
00093          else if ( colName == "RACKBAY"     ) rs >> rackBay;
00094          else if ( colName == "MUXBOXINRACK") rs >> muxboxInRack;
00095          else if ( colName == "TUBE"        ) rs >> tube;
00096          else if ( colName == "PIXEL"       ) rs >> pixel;
00097          else if ( colName == "SPOT"        ) rs >> spot;
00098          else if ( colName == "PLANE"       ) rs >> plane;
00099          else if ( colName == "STRIP"       ) rs >> strip;
00100          else if ( colName == "STRIPEND"    ) rs >> endchar;
00101          // "END" is obsolete
00102          else if ( colName == "END"         ) rs >> endchar;
00103          else {
00104             static int nmsg = 25;
00105             if (nmsg-- > 0) MSG("Plex",Msg::kWarning) 
00106                << "Ignoring column " << rs.CurColNum() 
00107                << " (of " << rs.NumCols() << ")"
00108                << " \""<< colName << "\"; not part of "
00109                << ClassName() << endl;
00110             rs.IncrementCurCol();
00111          }
00112       }
00113    } // end defensive unpacking
00114    else {
00115 //       SeqNo         int,
00116 //       AggregateNo   int,
00117 //       ElecName      tinytext,
00118 //       RackEastWest  char(1),
00119 //       RackLevel     char(1),
00120 //       RackBay       tinyint,
00121 //       MuxBoxInRack  tinyint,
00122 //       Tube          tinyint,
00123 //       Pixel         tinyint,
00124 //       Spot          tinyint,
00125 //       Plane         smallint,
00126 //       Strip         smallint,
00127 //       StripEnd      char(1)
00128 
00129       rs >> fAggregate
00130          >> elecName
00131          >> rackEastWest
00132          >> rackLevel
00133          >> rackBay
00134          >> muxboxInRack
00135          >> tube
00136          >> pixel
00137          >> spot
00138          >> plane
00139          >> strip
00140          >> endchar;
00141       
00142    }
00143 
00144    ElecType::Elec_t elec = ElecType::CharToEnum(elecName);
00145    if (ElecType::kUnknown == elec)  elec = (ElecType::Elec_t) elecType;
00146 
00147    StripEnd::StripEnd_t end  = StripEnd::CharToEnum(endchar);
00148 
00149    fPlexPixelSpotId = PlexPixelSpotId(det,elec,rackEastWest,rackLevel,
00150                                       rackBay,muxboxInRack,tube,pixel,spot);
00151 
00152    fPlexStripEndId = PlexStripEndId(det,plane,strip,end);
00153 
00154    // completely ugly hack for the veto shield
00155    if (Detector::kFar == det && plane >= 512) {
00156      VldContext vldc = PlexVetoShieldHack::GetDefaultContext();
00157      fPlexStripEndId = 
00158        PlexVetoShieldHack::RenumberMuxToMdl(vldc,fPlexStripEndId);
00159      if (fPlexStripEndId.GetPlane() < 528) {
00160        MSG("Plex",Msg::kWarning)
00161          << "still mux scheme " 
00162          << endl 
00163          << " translated to " << fPlexStripEndId.AsString("C")
00164          << " from (" << plane << "," << strip << "," << endchar << ")"
00165          << endl
00166          << " from spot " << fPlexPixelSpotId
00167          << " (" << elecName << "," << rackEastWest << "," << rackLevel
00168          << "," << rackBay << "," << muxboxInRack 
00169          << "," << tube << "," << pixel << "," << spot << ")"
00170          << endl;
00171        //assert(0);
00172      }
00173    }
00174 
00175 }
00176 //.....................................................................
00177 
00178 void PlexPixelSpotToStripEnd::Store(DbiOutRowStream& ors,
00179                                     const DbiValidityRec* /* vrec */) const {
00180 //
00181 //
00182 //  Purpose:  Stream object to output row stream
00183 //
00184 //  Arguments: 
00185 //    ors          in     Output row stream.
00186 //    vrec         in     Associated validity record (or 0 if filling
00187 //                                                    DbiValidityRec)
00188 //
00189 //  Return:    
00190 //
00191 //  Contact:   R. Hatcher
00192 //
00193 //  Specification:-
00194 //  =============
00195 //
00196 //  o  Stream object to output row stream.
00197 
00198 //  Program Notes:-
00199 //  =============
00200 
00201 //  None.
00202 
00203    ElecType::Elec_t elec = fPlexPixelSpotId.GetElecType();
00204    //   int  numeric      = fPlexPixelSpotId.GetNumericMuxBox();
00205    char rackEastWest = fPlexPixelSpotId.GetEastWest();
00206    char rackLevel    = fPlexPixelSpotId.GetRackLevel();
00207    int  rackBay      = fPlexPixelSpotId.GetRackBay();
00208    int  muxInRack    = fPlexPixelSpotId.GetInRack();
00209 
00210    ors << fAggregate 
00211        << ElecType::AsString(elec)
00212        << rackEastWest
00213        << rackLevel
00214        << rackBay
00215        << muxInRack
00216        << fPlexPixelSpotId.GetTube()
00217        << fPlexPixelSpotId.GetPixel()
00218        << fPlexPixelSpotId.GetSpot()
00219        << fPlexStripEndId.GetPlane()
00220        << fPlexStripEndId.GetStrip()
00221        << StripEnd::AsString(fPlexStripEndId.GetEnd())[0];
00222    
00223 }
00224 
00225 //.....................................................................
00226 
00227 
00228 

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