CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CondTools/SiPixel/interface/PixelPopConDCSSourceHandler.h

Go to the documentation of this file.
00001 #ifndef CondTools_SiPixel_PixelPopConDCSSourceHandler_h
00002 #define CondTools_SiPixel_PixelPopConDCSSourceHandler_h
00003 
00015 #include "CoralBase/Attribute.h"
00016 #include "CoralBase/AttributeList.h"
00017 #include "RelationalAccess/ICursor.h"
00018 
00019 #include "CondCore/PopCon/interface/PopConSourceHandler.h"
00020 #include "CondFormats/SiPixelObjects/interface/PixelDCSObject.h"
00021 #include "CondTools/SiPixel/interface/PixelDCSBase.h"
00022 
00023 template <class Type>
00024 class PixelPopConDCSSourceHandler:
00025   public PixelDCSBase,
00026   public popcon::PopConSourceHandler< PixelDCSObject<Type> >
00027 {
00028   public:
00029 
00031   PixelPopConDCSSourceHandler( const edm::ParameterSet& );
00032 
00034   virtual void getNewObjects();
00035 
00037   virtual std::string id() const;
00038 
00039   private:
00040 
00042   static inline void setValue( Type& value, const coral::AttributeList& );
00043 
00045   virtual void fillObject( coral::ICursor& );
00046 };
00047 
00048 template <class Type>
00049 PixelPopConDCSSourceHandler<Type>::PixelPopConDCSSourceHandler(const edm::ParameterSet& cfg):
00050   PixelDCSBase(cfg)
00051 {
00052 }
00053 
00054 template <class Type>
00055 void PixelPopConDCSSourceHandler<Type>::setValue(Type& value, const coral::AttributeList& row)
00056 {
00057   const size_t nTable = row.size() - 1; // row includes name
00058 
00059   if (1 != nTable)
00060   {
00061     throw cms::Exception("PixelPopConDCSSourceHandler")
00062         << "Found " << nTable << " last value tables instead of 1. "
00063         << "Check your cfg.\n";
00064   }
00065 
00066   value = row[0].data<float>();
00067 }
00068 
00069 template <>
00070 void PixelPopConDCSSourceHandler<CaenChannel>::setValue(CaenChannel& value, const coral::AttributeList& row)
00071 {
00072   const size_t nTable = row.size() - 1; // row includes name
00073 
00074   if (3 != nTable)
00075   {
00076     throw cms::Exception("PixelPopConDCSSourceHandler<CaenChannel>")
00077         << "CaenChannel has 3 values (isOn, iMon, vMon) "
00078         << "but your cfg has " << nTable << " last value tables.\n";
00079   }
00080 
00081   value.isOn = row[0].data<float>();
00082   value.iMon = row[1].data<float>();
00083   value.vMon = row[2].data<float>();
00084 }
00085 
00086 template <class Type>
00087 void PixelPopConDCSSourceHandler<Type>::fillObject(coral::ICursor& cursor)
00088 {
00089   PixelDCSObject<Type>* data = new PixelDCSObject<Type>;
00090 
00091   while ( cursor.next() )
00092   {
00093     const coral::AttributeList& row = cursor.currentRow();
00094 
00095     typename PixelDCSObject<Type>::Item datum;
00096 
00097     datum.name = row["name"].data<std::string>();
00098     setValue(datum.value, row);
00099     data->items.push_back(datum);
00100   }
00101 
00102   this->m_to_transfer.push_back( std::make_pair(data, 1) );
00103 }
00104 
00105 template <class Type>
00106 void PixelPopConDCSSourceHandler<Type>::getNewObjects()
00107 {
00108   getData();
00109 }
00110 
00111 template <class Type>
00112 std::string PixelPopConDCSSourceHandler<Type>::id() const
00113 {
00114   std::string name = "PixelPopCon";
00115 
00116   name += typeid(Type).name();
00117   name += "SourceHandler";
00118 
00119   return name;
00120 }
00121 
00122 #endif