00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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
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
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
00046
00047
00048
00049
00050 std::ostream& operator<<(std::ostream& os, const UgliDbiStripStruct& udss)
00051 { return udss.FormatToOStream(os); }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 string UgliDbiStripStruct::GetShapeName() const
00063 {
00064
00065
00066
00067
00068 UInt_t apln = 0;
00069
00070 if (Detector::kFar == GetDetector()) {
00071
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
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
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
00123
00124 Int_t numCol = rs.NumCols();
00125
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 }
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* ) const {
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
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
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
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;
00285 }
00286 else {
00287 os << dvr->GetSeqNo() << sep;
00288 }
00289
00290 os << GetStrip() << sep
00291 << -1 << sep
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
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
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
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382