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

BfieldCoilCurrent.cxx

Go to the documentation of this file.
00001 #include "BField/BfieldCoilCurrent.h"
00002 #include "MessageService/MsgService.h"
00003 #include "DatabaseInterface/DbiOutRowStream.h"
00004 #include "DatabaseInterface/DbiResultSet.h"
00005 #include "DatabaseInterface/DbiValidityRec.h"
00006 
00007 ClassImp(BfieldCoilCurrent)
00008 
00009 CVSID("$Id: BfieldCoilCurrent.cxx,v 1.8 2005/08/26 19:14:53 rhatcher Exp $\n  CVSID_DBIRESULTPTR ");
00010 
00011 #include "DatabaseInterface/DbiResultPtr.tpl"
00012 template class  DbiResultPtr<BfieldCoilCurrent>;
00013 
00014 #include "DatabaseInterface/DbiWriter.tpl"
00015 template class  DbiWriter<BfieldCoilCurrent>;
00016 
00017 
00018 //.....................................................................
00019 
00020 BfieldCoilCurrent::BfieldCoilCurrent(Int_t stat1,  Int_t curr1,
00021                                      Int_t stat2,  Int_t curr2, 
00022                                      Int_t turns1, Int_t turns2)
00023   : sm1stat(stat1), sm1curr(curr1), sm2stat(stat2), sm2curr(curr2),
00024     sm1turns(turns1), sm2turns(turns2)
00025 {
00026   // we have no context so if turns==0 we don't know what to set
00027 }
00028 
00029 //.....................................................................
00030 
00031 void BfieldCoilCurrent::Fill(DbiResultSet& rs, 
00032                              const DbiValidityRec* vrec) {
00033 
00034   if (    rs.TableName() != "BfieldCoilCurrent"
00035        && rs.TableName() != "BFIELDCOILCURRENT" ) {
00036     rs >> sm1stat >> sm1curr >> sm2stat >> sm2curr;
00037   }
00038   else {
00039     Int_t numCol = rs.NumCols();
00040     // seqno already processed
00041     for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00042       string colName = rs.CurColName();
00043       if (      colName == "SM1_CURRENT" )   rs >> sm1curr;
00044       else if ( colName == "SM1_STATUS" )    rs >> sm1stat;
00045       else if ( colName == "SM2_CURRENT" )   rs >> sm2curr;
00046       else if ( colName == "SM2_STATUS" )    rs >> sm2stat;
00047       else {
00048         MSG("Dbi",Msg::kDebug) << "Ignoring column " << curCol
00049           << "(" << colName << ")"
00050           << "; not part of BfieldCoilCurrent" << endl;
00051         rs.IncrementCurCol();
00052       }
00053     }
00054   }
00055 
00056 
00057   Detector::Detector_t det = 
00058     (Detector::Detector_t)
00059     ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00060 
00061   switch ( det ) {
00062   case Detector::kNear:
00063     sm1turns = 8;  // 8 turns (planks, each with 6 parallel conductors)
00064     sm2turns = 0;
00065     break;
00066   case Detector::kFar:
00067     sm1turns = 190;
00068     sm2turns = 190;
00069     break;
00070   default:
00071     sm1turns = 0;
00072     sm2turns = 0;
00073     break;
00074   }
00075 
00076 }
00077 
00078 //.....................................................................
00079 
00080 void BfieldCoilCurrent::Store(DbiOutRowStream& ors, 
00081                               const DbiValidityRec* /* vrec */) const {
00082   ors << sm1stat << sm1curr << sm2stat << sm2curr;
00083 }
00084 
00085 //.....................................................................
00086 
00087 std::ostream& operator<<(std::ostream& os, const BfieldCoilCurrent& bcc)
00088 { return bcc.FormatToOStream(os); }
00089  
00090 //.....................................................................
00091 void BfieldCoilCurrent::Print(Option_t *option) const
00092 { FormatToOStream(cout,option); }
00093  
00094 //.....................................................................
00095 std::ostream& BfieldCoilCurrent::FormatToOStream(std::ostream& os,
00096                                                  Option_t * /* option */) const
00097 {
00098   os << GetName();
00099   os << " SM1 status=" << sm1stat 
00100      << " @ " << sm1curr << "A*" << sm1turns << "turns";
00101   if ( sm2stat != 0 || sm2curr != 0 || sm2turns != 0 ) 
00102     os << ", SM2 status=" << sm2stat 
00103        << " @ " << sm2curr << "A*" << sm2turns << "turns";
00104   os << endl;
00105  
00106   return os;
00107 }
00108  
00109 //.....................................................................

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