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

UgliDbiStripStruct.cxx

Go to the documentation of this file.
00001 
00002 // $Id: UgliDbiStripStruct.cxx,v 1.25 2007/03/09 05:59:47 rhatcher Exp $
00003 //
00004 // UgliDbiStripStruct
00005 //
00006 // Package: UgliGeometry
00007 //
00008 // R. Hatcher  2001-08-08
00009 //
00010 // Concept:
00011 //   
00012 // Purpose:
00013 //
00015 
00016 #include "UgliGeometry/UgliDbiStripStruct.h"
00017 #include "MessageService/MsgService.h"
00018 #include "DatabaseInterface/DbiOutRowStream.h"
00019 #include "DatabaseInterface/DbiResultSet.h"
00020 #include "DatabaseInterface/DbiValidityRec.h"
00021 
00022 #include "UgliGeometry/UgliDbiTableDescr.h"
00023 
00024 #include "Plex/PlexStripEndId.h"
00025 
00026 #include <cassert>
00027 
00028 ClassImp(UgliDbiStripStruct)
00029 
00030 //   Definition of static data members
00031 //   *********************************
00032 
00033 CVSID("$Id: UgliDbiStripStruct.cxx,v 1.25 2007/03/09 05:59:47 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00034 Bool_t UgliDbiStripStruct::fgDefensiveUnpkg = kFALSE;
00035 
00036 //  Instantiate associated Result Pointer class.
00037 //  *******************************************
00038 
00039 #include "DatabaseInterface/DbiResultPtr.tpl"
00040 template class  DbiResultPtr<UgliDbiStripStruct>;
00041 
00042 #include "DatabaseInterface/DbiWriter.tpl"
00043 template class  DbiWriter<UgliDbiStripStruct>;
00044 
00045 // Definition of ctor's
00046 // ***************************************************
00047 
00048 //.....................................................................
00049 
00050 std::ostream& operator<<(std::ostream& os, const UgliDbiStripStruct& udss)
00051 { return udss.FormatToOStream(os); }
00052 
00053 //.....................................................................
00054 
00055 
00056 // Definition of member functions (alphabetical order)
00057 // ***************************************************
00058 
00059 //.....................................................................
00060 
00061 
00062 string UgliDbiStripStruct::GetShapeName() const
00063 {
00064    // make a name for this configuration
00065    
00066    // no meaningful plane #, but we don't care 
00067    // except for veto configurations
00068    UInt_t apln = 0;
00069    // use an arbitrary plane ... execpt in case of veto stuff
00070    if (Detector::kFar == GetDetector()) {
00071      // more work if far
00072      if (GetPlaneView()     >= PlaneView::kVSTopFlat || 
00073          GetPlaneCoverage() >= PlaneCoverage::kVScN      ) apln = 512;
00074    }
00075 
00076    PlexStripEndId seid(GetDetector(),apln,GetStrip());
00077    seid.SetPlaneView(GetPlaneView());
00078    seid.SetPlaneCoverage(GetPlaneCoverage());
00079 
00080    return seid.AsString("s");
00081 }
00082 
00083 //.....................................................................
00084 
00085 void UgliDbiStripStruct::Fill(DbiResultSet& rs,
00086                                       const DbiValidityRec* vrec) {
00087 //
00088 //
00089 //  Purpose:  Fill object from Result Set
00090 //
00091 //  Arguments: 
00092 //    rs           in    Result Set used to fill object
00093 //    vrec         in    Associated validity record (or 0 if filling
00094 //                                                    DbiValidityRec)
00095 //
00096 //  Return:    
00097 //
00098 //  Contact:   R. Hatcher
00099 //
00100 //  Specification:-
00101 //  =============
00102 //
00103 //  o Fill object from current row of Result Set.
00104 
00105 //  Program Notes:-
00106 //  =============
00107 
00108 //  None.
00109 
00110    Detector::Detector_t det =
00111       (Detector::Detector_t) 
00112       ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00113 
00114    UInt_t   hashv = 0;
00115    UInt_t   tmpdet = det;
00116    UInt_t   tmpview = PlaneView::kUnknown;
00117     Int_t   tmpcoverage = PlaneCoverage::kUnknown;
00118    UShort_t stripinpln = 0xffff;
00119 
00120    if (fgDefensiveUnpkg) {
00121 
00122       // unpack allowing for various column names and ordering
00123 
00124       Int_t numCol = rs.NumCols();
00125       //  The first column (SeqNo) has already been processed.
00126       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00127          string colName = rs.CurColName();
00128          if      ( colName == "HASHVAL"     ) rs.IncrementCurCol();
00129          else if ( colName == "DETECTOR"    ) rs >> tmpdet;
00130          else if ( colName == "PLNVIEW"     ) rs >> tmpview;
00131          else if ( colName == "COVERAGE"    ) rs >> tmpcoverage;
00132          else if ( colName == "STRIP"       ) rs >> stripinpln;
00133          else if ( colName == "INMODULE"    ) rs >> fInModule;
00134          else if ( colName == "TOTALLEN"    ) rs >> fTotalLen;
00135          else if ( colName == "WLSLENEAST"  ) rs >> fWlsLenEast;
00136          else if ( colName == "WLSLENWEST"  ) rs >> fWlsLenWest;
00137          else if ( colName == "LENEASTPART" ) rs >> fLenEastPart;
00138          else if ( colName == "LENWESTPART" ) rs >> fLenWestPart;
00139          else if ( colName == "WLSLENBYPASS") rs >> fWlsLenBypass;
00140          else {
00141             static int nmsg = 25;
00142             if (nmsg-- > 0) MSG("Ugli",Msg::kWarning) 
00143                << "Ignoring column " << rs.CurColNum() 
00144                << " (of " << rs.NumCols() << ")"
00145                << " \""<< colName << "\"; not part of "
00146                << ClassName() << endl;
00147             rs.IncrementCurCol();
00148          }
00149       }
00150    } // end defensive unpacking
00151    else {
00152       rs >> hashv
00153          >> tmpdet
00154          >> tmpview
00155          >> tmpcoverage
00156          >> fInModule
00157          >> stripinpln
00158          >> fTotalLen
00159          >> fWlsLenEast
00160          >> fWlsLenWest
00161          >> fLenEastPart
00162          >> fLenWestPart
00163          >> fWlsLenBypass;
00164    }
00165 
00166    fDetViewCoverStrip =
00167      UgliDbiStructHash( (Detector::Detector_t)tmpdet,
00168                         (PlaneView::PlaneView_t)tmpview,
00169                         (PlaneCoverage::PlaneCoverage_t)tmpcoverage,
00170                         stripinpln );
00171 }
00172 
00173 //.....................................................................
00174 
00175 void UgliDbiStripStruct::Store(DbiOutRowStream& ors,
00176                                const DbiValidityRec* /* vrec */) const {
00177 //
00178 //
00179 //  Purpose:  Stream object to output row stream
00180 //
00181 //  Arguments: 
00182 //    ors          in     Output row stream.
00183 //    vrec         in     Associated validity record (or 0 if filling
00184 //                                                    DbiValidityRec)
00185 //
00186 //  Return:    
00187 //
00188 //  Contact:   R. Hatcher
00189 //
00190 //  Specification:-
00191 //  =============
00192 //
00193 //  o  Stream object to output row stream.
00194 
00195 //  Program Notes:-
00196 //  =============
00197 
00198 //  None.
00199 
00200    const char* tabledescr = GetTableDescr();
00201    vector< pair<string,string> > components = 
00202       UgliDbiTableDescr::ParseTableDescr(tabledescr);
00203    int n = components.size();
00204 
00205    for (int i=0; i<n; i++) {
00206       pair<string,string> colPair = components[i];
00207       string colName = colPair.first;
00208       if      ( colName == "HASHVAL"      ) ors << (int)GetIndex(0);
00209       else if ( colName == "DETECTOR"     ) 
00210                         ors << (int)GetDetector();
00211       else if ( colName == "PLNVIEW"      ) 
00212                         ors << (int)GetPlaneView();
00213       else if ( colName == "COVERAGE"     ) 
00214                         ors << (int)GetPlaneCoverage();
00215       else if ( colName == "INMODULE"     ) ors << fInModule;
00216       else if ( colName == "STRIP"        ) ors << GetStrip();
00217       else if ( colName == "TOTALLEN"     ) ors << fTotalLen;
00218       else if ( colName == "WLSLENEAST"   ) ors << fWlsLenEast;
00219       else if ( colName == "WLSLENWEST"   ) ors << fWlsLenWest;
00220       else if ( colName == "LENEASTPART"  ) ors << fLenEastPart;
00221       else if ( colName == "LENWESTPART"  ) ors << fLenWestPart;
00222       else if ( colName == "WLSLENBYPASS" ) ors << fWlsLenBypass;
00223 
00224       else if ( colName == "ROW_COUNTER"  ) {;}
00225       else if ( colName == "SEQNO"        ) {;}
00226       else {
00227          MSG("Ugli",Msg::kFatal)
00228             << "Column name '" << colName << "' not correctly handled" << endl;
00229          assert(0);
00230       }
00231    }
00232 }
00233 
00234 //.....................................................................
00235 
00236 void UgliDbiStripStruct::Print(Option_t* option) const
00237 {
00238     FormatToOStream(cout,option);
00239 }
00240 
00241 //.....................................................................
00242 
00243 std::ostream& UgliDbiStripStruct::FormatToOStream(std::ostream& os,
00244                                                   Option_t* option,
00245                                                   const DbiValidityRec* dvr) const
00246 {
00247 //
00248 //
00249 //  Purpose:  Print the current row
00250 //
00251 //  Return:   nothing
00252 //
00253 //  Contact:   R. Hatcher
00254 //
00255 //  Specification:-
00256 //  =============
00257 //
00258 
00259 //  Program Notes:-
00260 //  =============
00261 
00262 //  None.
00263 
00264   string opt = option;
00265 
00266   if ( opt.find("H") != string::npos ) {
00267      string tabledescr = GetTableDescr();
00268      tabledescr = UgliDbiTableDescr::TextTableDescrLine(tabledescr);
00269      os << tabledescr << endl;
00270   }
00271   else if ( opt.find("h") != string::npos ) {
00272     string tabledescr = GetTableDescr();
00273     vector< pair<string,string> > components = 
00274         UgliDbiTableDescr::ParseTableDescr(tabledescr);
00275     for (unsigned int ic = 0; ic < components.size(); ++ic) 
00276         os << components[ic].first << '\t';
00277     os << endl;
00278   }
00279 
00280   char sep = '\t';
00281   if ( opt.find(",") != string::npos ) sep = ',';
00282 
00283   if ( ! dvr ) {
00284       os << "SeqNo"         << sep;  // no way of knowing the SEQNO?
00285   }
00286   else {
00287       os << dvr->GetSeqNo() << sep;
00288   }
00289 
00290   os   << GetStrip() << sep  // within aggregate(=plane) strip => row_counter
00291        << -1         << sep  // Hashval is obsolete
00292        << (int)GetDetector()      << sep
00293        << (int)GetPlaneView()     << sep
00294        << (int)GetPlaneCoverage() << sep
00295        << fInModule             << sep
00296        << GetStrip()            << sep
00297        << fTotalLen             << sep
00298        << fWlsLenEast           << sep
00299        << fWlsLenWest           << sep
00300        << fLenEastPart          << sep
00301        << fLenWestPart          << sep
00302        << fWlsLenBypass         << endl;
00303 
00304   return os;
00305 }
00306 
00307 //.....................................................................
00308 
00309 const char* UgliDbiStripStruct::GetTableDescr()
00310 {
00311 //
00312 //
00313 //  Purpose:  Return a string describing rows in the table
00314 //            Used in creating temporary tables
00315 //
00316 //  Return:   const char* to parenthesized comma separated list
00317 //            of column name and type pairs
00318 //
00319 //  Contact:   R. Hatcher
00320 //
00321 //  Specification:-
00322 //  =============
00323 //
00324 
00325 //  Program Notes:-
00326 //  =============
00327 
00328 //  None.
00329 
00330    const char* const_tabledescr = "(\
00331        SEQNO         int,      \
00332        ROW_COUNTER   int,      \
00333        HASHVAL       int,      \
00334        DETECTOR      tinyint,  \
00335        PLNVIEW       tinyint,  \
00336        COVERAGE      tinyint,  \
00337        INMODULE      tinyint,  \
00338        STRIP         smallint, \
00339        TOTALLEN      float,    \
00340        WLSLENEAST    float,    \
00341        WLSLENWEST    float,    \
00342        LENEASTPART   float,    \
00343        LENWESTPART   float,    \
00344        WLSLENBYPASS  float,    \
00345        primary key (SEQNO,ROW_COUNTER) \
00346        )";
00347 
00348    return const_tabledescr;
00349 }
00350 
00351 
00352 /*    Template for New Member Function
00353 
00354 //.....................................................................
00355 
00356 UgliDbiStripStruct:: {
00357 //
00358 //
00359 //  Purpose:  
00360 //
00361 //  Arguments: 
00362 //    xxxxxxxxx    in    yyyyyy
00363 //
00364 //  Return:    
00365 //
00366 //  Contact:   R. Hatcher
00367 //
00368 //  Specification:-
00369 //  =============
00370 //
00371 //  o 
00372 
00373 //  Program Notes:-
00374 //  =============
00375 
00376 //  None.
00377 
00378 
00379 }
00380 
00381 */
00382 

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