CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CondCore/EcalPlugins/plugins/EcalPyUtils.cc

Go to the documentation of this file.
00001 /*
00002  * Make some convenient Ecal function available in python
00003  * 
00004  * \author Stefano Argiro
00005  * \version $Id: EcalPyUtils.cc,v 1.3 2010/07/09 09:36:49 argiro Exp $
00006  */
00007 
00008 
00009 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00010 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00011 #include "CondTools/Ecal/interface/EcalFloatCondObjectContainerXMLTranslator.h"
00012 #include <boost/python.hpp>
00013 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
00014 
00015 using namespace boost::python;
00016 
00017 
00018 
00019 namespace ecalpyutils{
00020   
00021   std::vector<int> hashedIndexToEtaPhi(int hashedindex){
00022     int ieta= EBDetId::unhashIndex(hashedindex).ieta();
00023     int iphi= EBDetId::unhashIndex(hashedindex).iphi();
00024     std::vector<int> ret;
00025     ret.push_back(ieta);
00026     ret.push_back(iphi);
00027     return ret;
00028   }
00029   
00030   std::vector<int> hashedIndexToXY(int hashedindex){
00031     int ix= EEDetId::unhashIndex(hashedindex).ix();
00032     int iy= EEDetId::unhashIndex(hashedindex).iy();
00033     int zside =  EEDetId::unhashIndex(hashedindex).zside();
00034     std::vector<int> ret;
00035     ret.push_back(ix);
00036     ret.push_back(iy);
00037     ret.push_back(zside);
00038     return ret;
00039   }
00040 
00041   
00042   int hashedIndex(int ieta, int iphi){
00043     EBDetId d(ieta,iphi);
00044     return d.hashedIndex();
00045   }
00046 
00047   int ism(int ieta, int iphi){
00048     EBDetId d(ieta,iphi);
00049     return d.ism();
00050   }
00051 
00052 }
00053 
00054 BOOST_PYTHON_MODULE(pluginEcalPyUtils) {
00055 
00056 //   looks like these are already defined somewhere
00057 
00058 //   python access to stl integer vectors 
00059 //   class_< std::vector<int> >("vectorInt") 
00060 //     .def(vector_indexing_suite<std::vector<int> >()) 
00061 //   ; 
00062 
00063 //   class_< std::vector<float> >("vectorFloat") 
00064 //     .def(vector_indexing_suite<std::vector<float> >()) 
00065 //   ; 
00066 
00067   def("hashedIndexToEtaPhi",&ecalpyutils::hashedIndexToEtaPhi);
00068   def("hashedIndexToXY",&ecalpyutils::hashedIndexToXY);
00069   def("hashedIndex",&ecalpyutils::hashedIndex);
00070     def("ism",&ecalpyutils::ism);
00071   def("barrelfromXML",&EcalFloatCondObjectContainerXMLTranslator::barrelfromXML);
00072   def("endcapfromXML",&EcalFloatCondObjectContainerXMLTranslator::endcapfromXML);
00073 }
00074