CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
8 
12 #include <boost/python.hpp>
13 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
14 
15 using namespace boost::python;
16 
17 
18 
19 namespace ecalpyutils{
20 
21  std::vector<int> hashedIndexToEtaPhi(int hashedindex){
22  int ieta= EBDetId::unhashIndex(hashedindex).ieta();
23  int iphi= EBDetId::unhashIndex(hashedindex).iphi();
24  std::vector<int> ret;
25  ret.push_back(ieta);
26  ret.push_back(iphi);
27  return ret;
28  }
29 
30  std::vector<int> hashedIndexToXY(int hashedindex){
31  int ix= EEDetId::unhashIndex(hashedindex).ix();
32  int iy= EEDetId::unhashIndex(hashedindex).iy();
33  int zside = EEDetId::unhashIndex(hashedindex).zside();
34  std::vector<int> ret;
35  ret.push_back(ix);
36  ret.push_back(iy);
37  ret.push_back(zside);
38  return ret;
39  }
40 
41 
42  int hashedIndex(int ieta, int iphi){
43  EBDetId d(ieta,iphi);
44  return d.hashedIndex();
45  }
46 
47  int hashedIndexEE(int ix, int iy, int iz){
48 
49  if (EEDetId::validDetId(ix,iy,iz)) {
50  EEDetId d(ix,iy,iz);
51  return d.hashedIndex();
52  }
53  return 0;
54  }
55 
56  int ism(int ieta, int iphi){
57  EBDetId d(ieta,iphi);
58  return d.ism();
59  }
60 
61  std::string arraystoXML(const std::vector<float>& eb, const std::vector<float>& ee){
64  }
65 }
66 
67 BOOST_PYTHON_MODULE(pluginEcalPyUtils) {
68 
69 // looks like these are already defined somewhere
70 
71 // python access to stl integer vectors
72 // class_< std::vector<int> >("vectorInt")
73 // .def(vector_indexing_suite<std::vector<int> >())
74 // ;
75 
76 // class_< std::vector<float> >("vectorFloat")
77 // .def(vector_indexing_suite<std::vector<float> >())
78 // ;
79 
80  def("hashedIndexToEtaPhi",&ecalpyutils::hashedIndexToEtaPhi);
81  def("hashedIndexToXY",&ecalpyutils::hashedIndexToXY);
82  def("hashedIndex",&ecalpyutils::hashedIndex);
83  def("hashedIndexEE",&ecalpyutils::hashedIndexEE);
84  def("ism",&ecalpyutils::ism);
87  def("arraystoXML",&ecalpyutils::arraystoXML);
88 }
89 
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:86
static std::vector< float > barrelfromXML(const std::string &filename)
int ix() const
Definition: EEDetId.h:76
int zside(DetId const &)
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:61
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
tuple d
Definition: ztail.py:151
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
BOOST_PYTHON_MODULE(pluginBeamSpotObjectsPyInterface)
static std::string dumpXML(const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)
int hashedIndexEE(int ix, int iy, int iz)
Definition: EcalPyUtils.cc:47
int zside() const
Definition: EEDetId.h:70
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
int iy() const
Definition: EEDetId.h:82
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
std::string arraystoXML(const std::vector< float > &eb, const std::vector< float > &ee)
Definition: EcalPyUtils.cc:61
static std::vector< float > endcapfromXML(const std::string &filename)
int hashedIndex() const
Definition: EEDetId.h:182
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
std::vector< int > hashedIndexToXY(int hashedindex)
Definition: EcalPyUtils.cc:30
std::vector< int > hashedIndexToEtaPhi(int hashedindex)
Definition: EcalPyUtils.cc:21
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
JetCorrectorParameters::Definitions def
Definition: classes.h:6