Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-23 04:28:48

0001 // system include files
0002 #include <memory>
0003 #include <sstream>
0004 
0005 // user include files
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
0010 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h"
0011 #include "CondFormats/SiPixelObjects/interface/PixelFEDCabling.h"
0012 #include "CondFormats/SiPixelObjects/interface/PixelFEDLink.h"
0013 #include "CondFormats/SiPixelObjects/interface/PixelROC.h"
0014 
0015 #include "FWCore/ServiceRegistry/interface/Service.h"
0016 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0017 
0018 class EventSetup;
0019 class Event;
0020 
0021 using namespace std;
0022 using namespace edm;
0023 using namespace sipixelobjects;
0024 
0025 class SiPixelFedCablingMapTestWriter : public edm::one::EDAnalyzer<> {
0026 public:
0027   explicit SiPixelFedCablingMapTestWriter(const edm::ParameterSet&);
0028   ~SiPixelFedCablingMapTestWriter();
0029   virtual void beginJob();
0030   virtual void endJob();
0031   virtual void analyze(const edm::Event&, const edm::EventSetup&) {}
0032 
0033 private:
0034   SiPixelFedCablingTree* cablingTree;
0035   string m_record;
0036 };
0037 
0038 SiPixelFedCablingMapTestWriter::SiPixelFedCablingMapTestWriter(const edm::ParameterSet& iConfig)
0039     : cablingTree(0), m_record(iConfig.getParameter<std::string>("record")) {
0040   cout << " HERE record: " << m_record << endl;
0041   ::putenv((char*)"CORAL_AUTH_USER=konec");
0042   ::putenv((char*)"CORAL_AUTH_PASSWORD=test");
0043 }
0044 
0045 void SiPixelFedCablingMapTestWriter::endJob() {
0046   cout << "Convert Tree to Map";
0047 
0048   const auto& cablingMap = SiPixelFedCablingMap(cablingTree);
0049   cout << "Now writing to DB" << endl;
0050   edm::Service<cond::service::PoolDBOutputService> mydbservice;
0051   if (!mydbservice.isAvailable()) {
0052     cout << "db service unavailable" << endl;
0053     return;
0054   } else {
0055     cout << "DB service OK" << endl;
0056   }
0057 
0058   try {
0059     if (mydbservice->isNewTagRequest(m_record)) {
0060       mydbservice->createOneIOV<SiPixelFedCablingMap>(cablingMap, mydbservice->beginOfTime(), m_record);
0061     } else {
0062       mydbservice->appendOneIOV<SiPixelFedCablingMap>(cablingMap, mydbservice->currentTime(), m_record);
0063     }
0064   } catch (std::exception& e) {
0065     cout << "std::exception:  " << e.what();
0066   } catch (...) {
0067     cout << "Unknown error caught " << endl;
0068   }
0069   cout << "... all done, end" << endl;
0070 }
0071 
0072 SiPixelFedCablingMapTestWriter::~SiPixelFedCablingMapTestWriter() { cout << "DTOR !" << endl; }
0073 
0074 // ------------ method called to produce the data  ------------
0075 void SiPixelFedCablingMapTestWriter::beginJob() {
0076   cout << "BeginJob method " << endl;
0077   cout << "Building FED Cabling" << endl;
0078   cablingTree = new SiPixelFedCablingTree("My map V-TEST");
0079 
0080   PixelROC r1;
0081   PixelROC r2;
0082 
0083   PixelFEDLink link(2);
0084   PixelFEDLink::ROCs rocs;
0085   rocs.push_back(r1);
0086   rocs.push_back(r2);
0087   link.add(rocs);
0088 
0089   PixelFEDCabling fed(0);
0090   fed.addLink(link);
0091   cablingTree->addFed(fed);
0092   cout << "PRINTING MAP:" << endl << cablingTree->print(3) << endl;
0093 }
0094 
0095 //define this as a plug-in
0096 #include "FWCore/Framework/interface/MakerMacros.h"
0097 DEFINE_FWK_MODULE(SiPixelFedCablingMapTestWriter);