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 
62 BOOST_PYTHON_MODULE(pluginEcalPyUtils) {
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 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
EcalFloatCondObjectContainerXMLTranslator::barrelfromXML
static std::vector< float > barrelfromXML(const std::string &filename)
Definition: EcalFloatCondObjectContainerXMLTranslator.cc:140
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
ecalpyutils
Definition: EcalPyUtils.cc:16
EBDetId
Definition: EBDetId.h:17
EEDetId::unhashIndex
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
EBDetId.h
EEDetId.h
EBDetId::unhashIndex
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
EEDetId::ix
int ix() const
Definition: EEDetId.h:77
ecalpyutils::hashedIndexEE
int hashedIndexEE(int ix, int iy, int iz)
Definition: EcalPyUtils.cc:43
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
h
EEDetId::zside
int zside() const
Definition: EEDetId.h:71
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
EcalCondHeader
Definition: EcalCondHeader.h:16
EcalFloatCondObjectContainerXMLTranslator.h
BOOST_PYTHON_MODULE
BOOST_PYTHON_MODULE(pluginEcalPyUtils)
Definition: EcalPyUtils.cc:62
ecalpyutils::hashedIndexToXY
std::vector< int > hashedIndexToXY(int hashedindex)
Definition: EcalPyUtils.cc:27
EEDetId::iy
int iy() const
Definition: EEDetId.h:83
EcalFloatCondObjectContainerXMLTranslator::endcapfromXML
static std::vector< float > endcapfromXML(const std::string &filename)
Definition: EcalFloatCondObjectContainerXMLTranslator.cc:148
ecalpyutils::arraystoXML
std::string arraystoXML(const std::vector< float > &eb, const std::vector< float > &ee)
Definition: EcalPyUtils.cc:56
ecalpyutils::ism
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:51
EcalFloatCondObjectContainerXMLTranslator::dumpXML
static std::string dumpXML(const EcalCondHeader &header, const std::vector< float > &eb, const std::vector< float > &ee)
Definition: EcalFloatCondObjectContainerXMLTranslator.cc:156
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
ztail.d
d
Definition: ztail.py:151
spu::def
int def(FILE *, FILE *, int)
Definition: SherpackUtilities.cc:14
ecalpyutils::hashedIndexToEtaPhi
std::vector< int > hashedIndexToEtaPhi(int hashedindex)
Definition: EcalPyUtils.cc:18
ecalpyutils::hashedIndex
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:38