CMS 3D CMS Logo

EcalPyUtils.cc
Go to the documentation of this file.
1 /*
2  * Make some convenient Ecal function available in python
3  *
4  * \author Stefano Argiro
5  * \version $Id: EcalPyUtils.cc,v 1.6 2012/07/17 09:17:11 davidlt Exp $
6  */
7 
11 #include <pybind11/pybind11.h>
12 namespace py = pybind11;
13 
14 namespace ecalpyutils {
15 
16  std::vector<int> hashedIndexToEtaPhi(int hashedindex) {
17  int ieta = EBDetId::unhashIndex(hashedindex).ieta();
18  int iphi = EBDetId::unhashIndex(hashedindex).iphi();
19  std::vector<int> ret;
20  ret.push_back(ieta);
21  ret.push_back(iphi);
22  return ret;
23  }
24 
25  std::vector<int> hashedIndexToXY(int hashedindex) {
26  int ix = EEDetId::unhashIndex(hashedindex).ix();
27  int iy = EEDetId::unhashIndex(hashedindex).iy();
28  int zside = EEDetId::unhashIndex(hashedindex).zside();
29  std::vector<int> ret;
30  ret.push_back(ix);
31  ret.push_back(iy);
32  ret.push_back(zside);
33  return ret;
34  }
35 
36  int hashedIndex(int ieta, int iphi) {
37  EBDetId d(ieta, iphi);
38  return d.hashedIndex();
39  }
40 
41  int hashedIndexEE(int ix, int iy, int iz) {
42  if (EEDetId::validDetId(ix, iy, iz)) {
43  EEDetId d(ix, iy, iz);
44  return d.hashedIndex();
45  }
46  return 0;
47  }
48 
49  int ism(int ieta, int iphi) {
50  EBDetId d(ieta, iphi);
51  return d.ism();
52  }
53 
54  std::string arraystoXML(const std::vector<float>& eb, const std::vector<float>& ee) {
57  }
58 } // namespace ecalpyutils
59 
61  // looks like these are already defined somewhere
62 
63  // python access to stl integer vectors
64  // class_< std::vector<int> >("vectorInt")
65  // .def(vector_indexing_suite<std::vector<int> >())
66  // ;
67 
68  // class_< std::vector<float> >("vectorFloat")
69  // .def(vector_indexing_suite<std::vector<float> >())
70  // ;
71 
72  m.def("hashedIndexToEtaPhi", &ecalpyutils::hashedIndexToEtaPhi);
73  m.def("hashedIndexToXY", &ecalpyutils::hashedIndexToXY);
74  m.def("hashedIndex", &ecalpyutils::hashedIndex);
75  m.def("hashedIndexEE", &ecalpyutils::hashedIndexEE);
76  m.def("ism", &ecalpyutils::ism);
79  m.def("arraystoXML", &ecalpyutils::arraystoXML);
80 }
static std::vector< float > barrelfromXML(const std::string &filename)
ret
prodAgent to be discontinued
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
int ix() const
Definition: EEDetId.h:77
int zside(DetId const &)
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:36
int hashedIndexEE(int ix, int iy, int iz)
Definition: EcalPyUtils.cc:41
d
Definition: ztail.py:151
std::string arraystoXML(const std::vector< float > &eb, const std::vector< float > &ee)
Definition: EcalPyUtils.cc:54
static std::vector< float > endcapfromXML(const std::string &filename)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
int zside() const
Definition: EEDetId.h:71
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static std::string dumpXML(const EcalCondHeader &header, const std::vector< float > &eb, const std::vector< float > &ee)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
std::vector< int > hashedIndexToXY(int hashedindex)
Definition: EcalPyUtils.cc:25
std::vector< int > hashedIndexToEtaPhi(int hashedindex)
Definition: EcalPyUtils.cc:16
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:49
PYBIND11_MODULE(pluginEcalPyUtils, m)
Definition: EcalPyUtils.cc:60
int iy() const
Definition: EEDetId.h:83