00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00015
00016 #include "Plex/PlexPinDiodeToLed.h"
00017 #include "MessageService/MsgService.h"
00018 #include "DatabaseInterface/DbiOutRowStream.h"
00019 #include "DatabaseInterface/DbiResultSet.h"
00020 #include "DatabaseInterface/DbiValidityRec.h"
00021
00022 ClassImp(PlexPinDiodeToLed)
00023
00024
00025
00026
00027 CVSID("$Id: PlexPinDiodeToLed.cxx,v 1.9 2005/08/26 18:47:03 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00028 Bool_t PlexPinDiodeToLed::fgDefensiveUnpkg = kFALSE;
00029
00030
00031
00032
00033 #include "DatabaseInterface/DbiResultPtr.tpl"
00034 template class DbiResultPtr<PlexPinDiodeToLed>;
00035
00036 #include "DatabaseInterface/DbiWriter.tpl"
00037 template class DbiWriter<PlexPinDiodeToLed>;
00038
00039
00040
00041
00042
00043
00044
00045 void PlexPinDiodeToLed::Fill(DbiResultSet& rs,
00046 const DbiValidityRec* vrec) {
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
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 diodeinbox=0, gain=0;
00079 int pulserbox=0, ledinbox=0;
00080
00081 if (fgDefensiveUnpkg) {
00082
00083
00084
00085 Int_t numCol = rs.NumCols();
00086
00087 for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00088 string colName = rs.CurColName();
00089 if ( colName == "AGGREGATENO" ) rs >> fAggregate;
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 == "DIODEINBOX" ) rs >> diodeinbox;
00096 else if ( colName == "GAIN" ) rs >> gain;
00097 else if ( colName == "PULSERBOX" ) rs >> pulserbox;
00098 else if ( colName == "LEDINBOX" ) rs >> ledinbox;
00099 else {
00100 static int nmsg = 25;
00101 if (nmsg-- > 0) MSG("Plex",Msg::kWarning)
00102 << "Ignoring column " << rs.CurColNum()
00103 << " (of " << rs.NumCols() << ")"
00104 << " \""<< colName << "\"; not part of "
00105 << ClassName() << endl;
00106 rs.IncrementCurCol();
00107 }
00108 }
00109 }
00110 else {
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 rs >> fAggregate
00124 >> elecName
00125 >> rackEastWest
00126 >> rackLevel
00127 >> rackBay
00128 >> muxboxInRack
00129 >> diodeinbox
00130 >> gain
00131 >> pulserbox
00132 >> ledinbox;
00133
00134 }
00135
00136 ElecType::Elec_t elec = ElecType::CharToEnum(elecName);
00137 if (ElecType::kUnknown == elec) elec = (ElecType::Elec_t) elecType;
00138
00139 fPlexPinDiodeId = PlexPinDiodeId(det,elec,rackEastWest,rackLevel,
00140 rackBay,muxboxInRack,diodeinbox,gain);
00141 fPlexLedId = PlexLedId(det,pulserbox,ledinbox);
00142
00143 }
00144
00145
00146 void PlexPinDiodeToLed::Store(DbiOutRowStream& ors,
00147 const DbiValidityRec* ) const {
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 ElecType::Elec_t elec = fPlexPinDiodeId.GetElecType();
00172
00173 char rackEastWest = fPlexPinDiodeId.GetEastWest();
00174 char rackLevel = fPlexPinDiodeId.GetRackLevel();
00175 int rackBay = fPlexPinDiodeId.GetRackBay();
00176 int muxInRack = fPlexPinDiodeId.GetInRack();
00177
00178
00179 ors << fAggregate
00180 << ElecType::AsString(elec)
00181 << rackEastWest
00182 << rackLevel
00183 << rackBay
00184 << muxInRack
00185 << fPlexPinDiodeId.GetInBox()
00186 << fPlexPinDiodeId.GetGain()
00187 << fPlexLedId.GetPulserBox()
00188 << fPlexLedId.GetLedInBox();
00189 }
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221