CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelPopConDCSSourceHandler.h
Go to the documentation of this file.
1 #ifndef CondTools_SiPixel_PixelPopConDCSSourceHandler_h
2 #define CondTools_SiPixel_PixelPopConDCSSourceHandler_h
3 
15 #include "CoralBase/Attribute.h"
16 #include "CoralBase/AttributeList.h"
17 #include "RelationalAccess/ICursor.h"
18 
21 #include "CondTools/SiPixel/interface/PixelDCSBase.h"
22 
23 template <class Type>
25  public PixelDCSBase,
26  public popcon::PopConSourceHandler< PixelDCSObject<Type> >
27 {
28  public:
29 
32 
34  virtual void getNewObjects();
35 
37  virtual std::string id() const;
38 
39  private:
40 
42  static inline void setValue( Type& value, const coral::AttributeList& );
43 
45  virtual void fillObject( coral::ICursor& );
46 };
47 
48 template <class Type>
50  PixelDCSBase(cfg)
51 {
52 }
53 
54 template <class Type>
55 void PixelPopConDCSSourceHandler<Type>::setValue(Type& value, const coral::AttributeList& row)
56 {
57  const size_t nTable = row.size() - 1; // row includes name
58 
59  if (1 != nTable)
60  {
61  throw cms::Exception("PixelPopConDCSSourceHandler")
62  << "Found " << nTable << " last value tables instead of 1. "
63  << "Check your cfg.\n";
64  }
65 
66  value = row[0].data<float>();
67 }
68 
69 template <>
71 {
72  const size_t nTable = row.size() - 1; // row includes name
73 
74  if (3 != nTable)
75  {
76  throw cms::Exception("PixelPopConDCSSourceHandler<CaenChannel>")
77  << "CaenChannel has 3 values (isOn, iMon, vMon) "
78  << "but your cfg has " << nTable << " last value tables.\n";
79  }
80 
81  value.isOn = row[0].data<float>();
82  value.iMon = row[1].data<float>();
83  value.vMon = row[2].data<float>();
84 }
85 
86 template <class Type>
88 {
90 
91  while ( cursor.next() )
92  {
93  const coral::AttributeList& row = cursor.currentRow();
94 
95  typename PixelDCSObject<Type>::Item datum;
96 
97  datum.name = row["name"].data<std::string>();
98  setValue(datum.value, row);
99  data->items.push_back(datum);
100  }
101 
102  this->m_to_transfer.push_back( std::make_pair(data, 1) );
103 }
104 
105 template <class Type>
107 {
108  getData();
109 }
110 
111 template <class Type>
113 {
114  std::string name = "PixelPopCon";
115 
116  name += typeid(Type).name();
117  name += "SourceHandler";
118 
119  return name;
120 }
121 
122 #endif
tuple cfg
Definition: looper.py:293
std::vector< Item > items
virtual void fillObject(coral::ICursor &)
Fill object from all rows in DB.
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
virtual void getNewObjects()
Get data from DB by calling PixelDCSBase::getData().
virtual std::string id() const
Name of this source handler.
PixelPopConDCSSourceHandler(const edm::ParameterSet &)
Init PixelDCSBase from cfg file.
static void setValue(Type &value, const coral::AttributeList &)
Specialise this template to assign values to a non-POD object type from a row in DB.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82