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

CalTimeJump.cxx

Go to the documentation of this file.
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 // Index <---> RawChannelId
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     // ND not supported.
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  // no particular channel on chip
00062                       );                      
00063 }
00064 
00065 
00067 // Database stuff
00069 void CalTimeJump::Fill(DbiResultSet& rs, 
00070                          const DbiValidityRec* /* vrec */ ) {
00071 
00072 //
00073 //
00074 //  Purpose:  Fill object from Result Set
00075 //
00076 //  Arguments: 
00077 //    rs           in    Result Set used to fill object
00078 //    vrec         in    Associated validity record (or 0 if filling
00079 //                                                    DbiValidityRec)
00080 
00081    if ( rs.TableName() == "CALTIMEJUMP" ) {
00082       // Dumb method.
00083      rs  >> fChannelIndex >> fJump;
00084    }
00085    else {      
00086      // Smart method
00087      Int_t numCol = rs.NumCols();
00088      //  The first column (SeqNo) has already been processed.
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* /* vrec */) const 
00108 {
00109   //
00110   //
00111   //  Purpose:  Stream object to output row stream
00112   //
00113   
00114   ors << fChannelIndex << fJump;
00115 }
00116 

Generated on Mon Feb 15 11:06:27 2010 for loon by  doxygen 1.3.9.1