CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/CondCore/EcalPlugins/plugins/EcalTPGTowerStatusPyWrapper.cc

Go to the documentation of this file.
00001 #include "CondFormats/EcalObjects/interface/EcalTPGTowerStatus.h"
00002 #include "CondTools/Ecal/interface/EcalTPGTowerStatusXMLTranslator.h"
00003 #include "CondTools/Ecal/interface/EcalCondHeader.h"
00004 #include "TROOT.h"
00005 #include "TH2F.h"
00006 #include "TCanvas.h"
00007 #include "TStyle.h"
00008 #include "TColor.h"
00009 #include "TLine.h"
00010 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00011 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00012 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00013 
00014 #include "CondCore/Utilities/interface/PayLoadInspector.h"
00015 #include "CondCore/Utilities/interface/InspectorPythonWrapper.h"
00016 
00017 #include <string>
00018 #include <sstream>
00019 #include <algorithm>
00020 #include <numeric>
00021 #include <iterator>
00022 #include <boost/ref.hpp>
00023 #include <boost/bind.hpp>
00024 #include <boost/function.hpp>
00025 #include <boost/iterator/transform_iterator.hpp>
00026 
00027 #include <fstream>
00028 
00029 namespace cond {
00030   template<>
00031   std::string PayLoadInspector<EcalTPGTowerStatus>::dump() const {
00032     std::stringstream ss;
00033     EcalCondHeader h;
00034     ss << EcalTPGTowerStatusXMLTranslator::dumpXML(h,object());
00035     return ss.str();
00036   }
00037 
00038   template<>
00039   std::string PayLoadInspector<EcalTPGTowerStatus>::summary() const {
00040     std::stringstream ss;
00041 
00042     const EcalTPGTowerStatusMap &towerMap = object().getMap();
00043     EcalTPGTowerStatusMapIterator it;
00044     int NbMaskedTT = 0;
00045     for(it = towerMap.begin(); it != towerMap.end(); ++it)
00046       if((*it).second > 0) NbMaskedTT++;
00047     ss <<"Barrel masked Trigger Towers " << NbMaskedTT <<std::endl;
00048     return ss.str();
00049   }
00050 
00051   template<>
00052   std::string PayLoadInspector<EcalTPGTowerStatus>::plot(std::string const & filename,
00053                                                          std::string const &, 
00054                                                          std::vector<int> const&, 
00055                                                          std::vector<float> const& ) const {
00056     gStyle->SetPalette(1);
00057 
00058     TCanvas canvas("CC map","CC map",800, 400);
00059 
00060     TH2F* barrel = new TH2F("EB","EB TPG Tower Status", 72, 0, 72, 34, -17, 17);
00061 
00062     const EcalTPGTowerStatusMap &towerMap = object().getMap();
00063     std::cout << " tower map size " << towerMap.size() << std::endl;
00064     EcalTPGTowerStatusMapIterator it;
00065     for(it = towerMap.begin(); it != towerMap.end(); ++it) {
00066       if((*it).second > 0) {
00067         EcalTrigTowerDetId ttId((*it).first);
00068         int ieta = ttId.ieta();
00069         if(ieta < 0) ieta--;   // 1 to 17
00070         int iphi = ttId.iphi() - 1;  // 0 to 71
00071         barrel->Fill(iphi, ieta, (*it).second);
00072       }
00073     }
00074     TLine* l = new TLine(0., 0., 0., 0.);
00075     l->SetLineWidth(1);
00076     canvas.cd();
00077     barrel->SetStats(0);
00078     barrel->Draw("col");
00079     for(int i = 0; i <17; i++) {
00080       Double_t x = 4.+ (i * 4);
00081       l = new TLine(x, -17., x, 17.);
00082       l->Draw();
00083     }
00084     l = new TLine(0., 0., 72., 0.);
00085     l->Draw();
00086 
00087     canvas.SaveAs(filename.c_str());
00088     return filename;
00089   }  // plot
00090 }
00091 PYTHON_WRAPPER(EcalTPGTowerStatus,EcalTPGTowerStatus);