CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripSummaryPyWrapper.cc
Go to the documentation of this file.
1 
3 
6 
7 #include <string>
8 #include <fstream>
9 
10 
11 namespace cond {
12 
13  template<>
15 
16  std::string m_quantity;
18 
19  std::string const & quantity() const { return m_quantity;}
20  sistripsummary::TrackerRegion const & trackerregion() const { return m_trackerregion;}
21 
22  void set_quantity( std::string i) { m_quantity=i;}
24  };
25 
26 
27 
28 
29  template<>
30  class ValueExtractor<SiStripSummary>: public BaseValueExtractor<SiStripSummary> {
31  public:
32 
35  static What what() { return What();}
36 
39  : m_what(what)
40  {
41  // here one can make stuff really complicated...
42  }
43  void compute(Class const & it){
44  std::vector<std::string> vlistItems;
45  std::vector<float> res;
46  uint32_t detid=m_what.trackerregion();
47  std::string::size_type oldloc=0;
48  std::string ListItems = m_what.quantity();
49  std::string::size_type loc = ListItems.find( ",", oldloc );
50  size_t count=1;
51  while( loc != std::string::npos ) {
52  vlistItems.push_back(ListItems.substr(oldloc,loc-oldloc));
53  oldloc=loc+1;
54  loc=ListItems.find( ",", oldloc );
55  count++;
56  }
57  //there is a single item
58  vlistItems.push_back(ListItems.substr(oldloc,loc-oldloc));
59  std::vector<float> vres=it.getSummaryObj(detid,vlistItems);
60  res.insert(res.end(),vres.begin(),vres.end());
61  //res.push_back(detid);
62  swap(res);
63  }
64  private:
66  };
67 
68 
69  template<>
70  std::string
72  std::stringstream ss;
73  std::vector<std::string> listWhat= object().getUserDBContent();
74  for(size_t i=0;i<listWhat.size();++i)
75  ss << listWhat[i] << "###";
76  return ss.str();
77 
78  }
79 
80  template<>
82  std::stringstream ss;
83  ss << "Nr.Det " << object().getRegistryVectorEnd()-object().getRegistryVectorBegin()
84  << "\nNr.Quantities " << object().getUserDBContent().size()
85  << "\nNr.values " << object().getDataVectorEnd()-object().getDataVectorBegin()
86  << "\nRunNr= " << object().getRunNr()
87  << "\ntimeValue= " << object().getTimeValue();
88  //ss << "names of DBquantities ";
89  //std::vector<std::string> listWhat= object().getUserDBContent();
90  //for(size_t i=0;i<listWhat.size();++i)
91  // ss << listWhat[i] << "\n";
92  return ss.str();
93  }
94 
95 
96  template<>
97  std::string PayLoadInspector<SiStripSummary>::plot(std::string const & filename,
98  std::string const &,
99  std::vector<int> const&,
100  std::vector<float> const& ) const {
101  std::string fname = filename + ".png";
102  std::ofstream f(fname.c_str());
103  return fname;
104  }
105 
106 
107 }
108 
109 
110 namespace condPython {
111  template<>
113  using namespace boost::python;
114  enum_<sistripsummary::TrackerRegion>("TrackerRegion")
115  .value("Tracker",sistripsummary::TRACKER)
116  .value("TIB",sistripsummary::TIB)
117  .value("TID",sistripsummary::TID)
118  .value("TOB",sistripsummary::TOB)
119  .value("TEC",sistripsummary::TEC)
120  .value("TIB_L1",sistripsummary::TIB_1)
121  .value("TIB_L2",sistripsummary::TIB_2)
122  .value("TIB_L3",sistripsummary::TIB_3)
123  .value("TIB_L4",sistripsummary::TIB_4)
124  .value("TOB_L1",sistripsummary::TOB_1)
125  .value("TOB_L2",sistripsummary::TOB_2)
126  .value("TOB_L3",sistripsummary::TOB_3)
127  .value("TOB_L4",sistripsummary::TOB_4)
128  .value("TOB_L5",sistripsummary::TOB_5)
129  .value("TOB_L6",sistripsummary::TOB_6)
130  .value("TIDM_D1",sistripsummary::TIDM_1)
131  .value("TIDM_D2",sistripsummary::TIDM_2)
132  .value("TIDM_D3",sistripsummary::TIDM_3)
133  .value("TIDP_D1",sistripsummary::TIDP_1)
134  .value("TIDP_D2",sistripsummary::TIDP_2)
135  .value("TIDP_D3",sistripsummary::TIDP_3)
136  .value("TECP_D1",sistripsummary::TECP_1)
137  .value("TECP_D2",sistripsummary::TECP_2)
138  .value("TECP_D3",sistripsummary::TECP_3)
139  .value("TECP_D4",sistripsummary::TECP_4)
140  .value("TECP_D5",sistripsummary::TECP_5)
141  .value("TECP_D6",sistripsummary::TECP_6)
142  .value("TECP_D7",sistripsummary::TECP_7)
143  .value("TECP_D8",sistripsummary::TECP_8)
144  .value("TECP_D9",sistripsummary::TECP_9)
145  .value("TECM_D1",sistripsummary::TECM_1)
146  .value("TECM_D2",sistripsummary::TECM_2)
147  .value("TECM_D3",sistripsummary::TECM_3)
148  .value("TECM_D4",sistripsummary::TECM_4)
149  .value("TECM_D5",sistripsummary::TECM_5)
150  .value("TECM_D6",sistripsummary::TECM_6)
151  .value("TECM_D7",sistripsummary::TECM_7)
152  .value("TECM_D8",sistripsummary::TECM_8)
153  .value("TECM_D9",sistripsummary::TECM_9)
154  ;
155 
157  class_<What>("What",init<>())
158  .def("set_quantity",&What::set_quantity)
159  .def("set_how",&What::set_trackerregion)
160  .def("quantity",&What::quantity, return_value_policy<copy_const_reference>())
161  .def("how",&What::trackerregion, return_value_policy<copy_const_reference>())
162  ;
163  }
164 }
165 
166 
167 
168 
sistripsummary::TrackerRegion const & trackerregion() const
int i
Definition: DBlmapReader.cc:9
void defineWhat< SiStripSummary >()
std::string plot(std::string const &, std::string const &, std::vector< int > const &, std::vector< float > const &) const
ExtractWhat< Class > What
#define PYTHON_WRAPPER(_class, _name)
std::vector< float > getSummaryObj(uint32_t &detID, std::vector< std::string > list) const
uint16_t size_type
std::string summary() const
void set_trackerregion(sistripsummary::TrackerRegion i)
double f[11][100]
void swap(std::vector< float > &v)
sistripsummary::TrackerRegion m_trackerregion
list object
Definition: dbtoconf.py:77
string fname
main script
tuple filename
Definition: lut2db_cfg.py:20
std::string dump() const