00001 #include "CalTimeJump.h"
00002
00003 #include "DatabaseInterface/DbiResultSet.h"
00004 #include "MessageService/MsgService.h"
00005 #include <cassert>
00006
00007 ClassImp(CalTimeJump)
00008
00009
00010 CVSID("$Id: CalTimeJump.cxx,v 1.6 2007/03/01 17:35:34 rhatcher Exp $");
00011
00012 #include "DatabaseInterface/DbiResultPtr.tpl"
00013 template class DbiResultPtr<CalTimeJump>;
00014
00015 #include "DatabaseInterface/DbiWriter.tpl"
00016 template class DbiWriter<CalTimeJump>;
00017
00018
00019
00021
00023 Int_t CalTimeJump::GetIndex(const RawChannelId& rcid)
00024 {
00025 if(rcid.GetDetector()==Detector::kFar) {
00026 Int_t index = rcid.GetCrate()*108
00027 + rcid.GetVarcId()*36
00028 + rcid.GetVmm()*6
00029 + rcid.GetVaAdcSel()*3
00030 + rcid.GetVaChip();
00031 return index;
00032 } else if(rcid.IsNull()) {
00033 return -1;
00034 } else {
00035
00036 assert(0);
00037 }
00038 return -1;
00039 }
00040
00041 RawChannelId CalTimeJump::GetRawChannelId(Int_t index)
00042 {
00043 Int_t temp = index;
00044 Int_t crate = index/108;
00045 temp -= crate*108;
00046 Int_t varc = temp/36;
00047 temp -= varc*36;
00048 Int_t vmm = temp/6;
00049 temp -= vmm*6;
00050 Int_t vaadc = temp/3;
00051 temp -= vaadc*3;
00052 Int_t vachip = temp;
00053
00054 return RawChannelId(Detector::kFar,
00055 ElecType::kVA,
00056 crate,
00057 varc,
00058 vmm,
00059 vaadc,
00060 vachip,
00061 0
00062 );
00063 }
00064
00065
00067
00069 void CalTimeJump::Fill(DbiResultSet& rs,
00070 const DbiValidityRec* ) {
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 if ( rs.TableName() == "CALTIMEJUMP" ) {
00082
00083 rs >> fChannelIndex >> fJump;
00084 }
00085 else {
00086
00087 Int_t numCol = rs.NumCols();
00088
00089 for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00090 string colName = rs.CurColName();
00091 if ( colName == "CHANNELINDEX" ) rs >> fChannelIndex;
00092 else if( colName == "JUMP" ) rs >> fJump;
00093 else {
00094 MSG("Dbi",Msg::kDebug) << "Ignoring column " << curCol
00095 << "(" << colName << ")"
00096 << "; not part of CalTimeJump"
00097 << endl;
00098 rs.IncrementCurCol();
00099 }
00100 }
00101 }
00102
00103 }
00104
00105
00106 void CalTimeJump::Store(DbiOutRowStream& ors,
00107 const DbiValidityRec* ) const
00108 {
00109
00110
00111
00112
00113
00114 ors << fChannelIndex << fJump;
00115 }
00116