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 <boost/python.hpp>
12 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
13 
14 using namespace boost::python;
15 
16 namespace ecalpyutils {
17 
18  std::vector<int> hashedIndexToEtaPhi(int hashedindex) {
19  int ieta = EBDetId::unhashIndex(hashedindex).ieta();
20  int iphi = EBDetId::unhashIndex(hashedindex).iphi();
21  std::vector<int> ret;
22  ret.push_back(ieta);
23  ret.push_back(iphi);
24  return ret;
25  }
26 
27  std::vector<int> hashedIndexToXY(int hashedindex) {
28  int ix = EEDetId::unhashIndex(hashedindex).ix();
29  int iy = EEDetId::unhashIndex(hashedindex).iy();
30  int zside = EEDetId::unhashIndex(hashedindex).zside();
31  std::vector<int> ret;
32  ret.push_back(ix);
33  ret.push_back(iy);
34  ret.push_back(zside);
35  return ret;
36  }
37 
38  int hashedIndex(int ieta, int iphi) {
39  EBDetId d(ieta, iphi);
40  return d.hashedIndex();
41  }
42 
43  int hashedIndexEE(int ix, int iy, int iz) {
44  if (EEDetId::validDetId(ix, iy, iz)) {
45  EEDetId d(ix, iy, iz);
46  return d.hashedIndex();
47  }
48  return 0;
49  }
50 
51  int ism(int ieta, int iphi) {
52  EBDetId d(ieta, iphi);
53  return d.ism();
54  }
55 
56  std::string arraystoXML(const std::vector<float>& eb, const std::vector<float>& ee) {
59  }
60 } // namespace ecalpyutils
61 
63  // looks like these are already defined somewhere
64 
65  // python access to stl integer vectors
66  // class_< std::vector<int> >("vectorInt")
67  // .def(vector_indexing_suite<std::vector<int> >())
68  // ;
69 
70  // class_< std::vector<float> >("vectorFloat")
71  // .def(vector_indexing_suite<std::vector<float> >())
72  // ;
73 
74  def("hashedIndexToEtaPhi", &ecalpyutils::hashedIndexToEtaPhi);
75  def("hashedIndexToXY", &ecalpyutils::hashedIndexToXY);
76  def("hashedIndex", &ecalpyutils::hashedIndex);
77  def("hashedIndexEE", &ecalpyutils::hashedIndexEE);
78  def("ism", &ecalpyutils::ism);
81  def("arraystoXML", &ecalpyutils::arraystoXML);
82 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
static std::vector< float > barrelfromXML(const std::string &filename)
int ix() const
Definition: EEDetId.h:77
ret
prodAgent to be discontinued
int zside(DetId const &)
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:59
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:38
int hashedIndexEE(int ix, int iy, int iz)
Definition: EcalPyUtils.cc:43
int zside() const
Definition: EEDetId.h:71
int iy() const
Definition: EEDetId.h:83
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
d
Definition: ztail.py:151
std::string arraystoXML(const std::vector< float > &eb, const std::vector< float > &ee)
Definition: EcalPyUtils.cc:56
static std::vector< float > endcapfromXML(const std::string &filename)
int hashedIndex() const
Definition: EEDetId.h:183
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
BOOST_PYTHON_MODULE(pluginEcalPyUtils)
Definition: EcalPyUtils.cc:62
std::vector< int > hashedIndexToXY(int hashedindex)
Definition: EcalPyUtils.cc:27
std::vector< int > hashedIndexToEtaPhi(int hashedindex)
Definition: EcalPyUtils.cc:18
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:51
JetCorrectorParameters::Definitions def
Definition: classes.h:6