CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CondTools/DQM/plugins/DQMXMLFileEventSetupAnalyzer.cc

Go to the documentation of this file.
00001 // C++ common header
00002 #include <iostream>
00003 #include <vector>
00004 #include <fstream>
00005 
00006 // Boost headers
00007 #include "boost/scoped_ptr.hpp"
00008 
00009 #include "FWCore/Framework/interface/EDAnalyzer.h"
00010 #include "FWCore/Framework/interface/Run.h"
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "FWCore/Framework/interface/MakerMacros.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "FWCore/Utilities/interface/Exception.h"
00017 #include "FWCore/ServiceRegistry/interface/Service.h"
00018 #include "CondFormats/Common/interface/FileBlob.h"
00019 #include "CondFormats/DataRecord/interface/DQMXMLFileRcd.h"
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 #include "DQMServices/Core/interface/MonitorElement.h"
00022 
00023 namespace edmtest {
00024   class DQMXMLFileEventSetupAnalyzer: public edm::EDAnalyzer {
00025    public:
00026     explicit DQMXMLFileEventSetupAnalyzer(const edm::ParameterSet & pset);
00027     explicit DQMXMLFileEventSetupAnalyzer(int i);
00028     virtual ~DQMXMLFileEventSetupAnalyzer();
00029     virtual void analyze(const edm::Event& event, const edm::EventSetup& setup);
00030     virtual void beginRun(edm::Run const&, edm::EventSetup const&) ;
00031   private:
00032     bool init_ ;
00033     std::string labelToGet_ ;
00034   };
00035   
00036   DQMXMLFileEventSetupAnalyzer::DQMXMLFileEventSetupAnalyzer(const edm::ParameterSet &ps):labelToGet_(ps.getParameter<std::string>("labelToGet")) {
00037     init_ = false ;
00038     //std::cout << "DQMXMLFileEventSetupAnalyzer(const edm::ParameterSet &ps)" << std::endl;
00039   }
00040   
00041   DQMXMLFileEventSetupAnalyzer::DQMXMLFileEventSetupAnalyzer(int i) {
00042     init_ = false ;
00043     //std::cout << "DQMXMLFileEventSetupAnalyzer(int i) " << i << std::endl;
00044   }
00045   
00046   DQMXMLFileEventSetupAnalyzer::~DQMXMLFileEventSetupAnalyzer()
00047   {
00048     init_ = false ;
00049     //std::cout << "~DQMXMLFileEventSetupAnalyzer" << std::endl;
00050   }
00051   
00052   void DQMXMLFileEventSetupAnalyzer::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup)
00053   {
00054     return ;
00055   }
00056 
00057   void DQMXMLFileEventSetupAnalyzer::beginRun(edm::Run const& run , edm::EventSetup const& iSetup)
00058   {
00059     //std::cout << "DQMXMLFileEventSetupAnalyzer::beginRun()" << std::endl;    
00060     if(!init_)
00061       {
00062         init_ = true ;
00063         edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("DQMXMLFileRcd"));
00064         if(recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
00065           throw cms::Exception ("Record not found") << "Record \"DQMXMLFileRcd" 
00066                                                     << "\" does not exist!" << std::endl;
00067         }
00068         edm::ESHandle<FileBlob> rootgeo;
00069         iSetup.get<DQMXMLFileRcd>().get(labelToGet_,rootgeo);
00070         //std::cout<<"XML FILE IN MEMORY 1 with label " << labelToGet_ <<std::endl;
00071         boost::scoped_ptr<std::vector<unsigned char> > tb1( (*rootgeo).getUncompressedBlob() );
00072         //here you can implement the stream for putting the TFile on disk...
00073         std::string outfile1("XML1_retrieved.xml") ;
00074         ofstream output1(outfile1.c_str()) ;
00075         output1.write((const char *)&(*tb1)[0], tb1->size());
00076         output1.close() ;
00077         
00078 //      iSetup.get<DQMXMLFileRcd>().get("XML2_mio",rootgeo);
00079 //      std::cout<<"ROOT FILE IN MEMORY 2"<<std::endl;
00080 //      boost::scoped_ptr<std::vector<unsigned char> > tb2( (*rootgeo).getUncompressedBlob() );
00081 //      //here you can implement the stream for putting the TFile on disk...
00082 //      std::string outfile2("XML2_retrieved.xml") ;
00083 //      ofstream output2(outfile2.c_str()) ;
00084 //      output2.write((const char *)&(*tb2)[0], tb2->size());
00085 //      output2.close() ;
00086         //      boost::scoped_ptr<std::vector<unsigned char> > tb( (*rootgeo).getUncompressedBlob() );
00087       }
00088   }
00089   
00090   DEFINE_FWK_MODULE(DQMXMLFileEventSetupAnalyzer);
00091 }