Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:31

0001 // system include files
0002 #include <memory>
0003 #include <iostream>
0004 #include <sstream>
0005 
0006 // user include files
0007 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0008 
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
0011 #include "CondFormats/RPCObjects/interface/DccSpec.h"
0012 #include "CondFormats/RPCObjects/interface/TriggerBoardSpec.h"
0013 #include "CondFormats/RPCObjects/interface/LinkConnSpec.h"
0014 #include "CondFormats/RPCObjects/interface/LinkBoardSpec.h"
0015 #include "CondFormats/RPCObjects/interface/ChamberLocationSpec.h"
0016 #include "CondFormats/RPCObjects/interface/FebLocationSpec.h"
0017 #include "CondFormats/RPCObjects/interface/FebConnectorSpec.h"
0018 #include "CondFormats/RPCObjects/interface/ChamberStripSpec.h"
0019 
0020 #include "FWCore/ServiceRegistry/interface/Service.h"
0021 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0022 
0023 using namespace std;
0024 using namespace edm;
0025 
0026 class RPCReadOutMapBuilder : public edm::one::EDAnalyzer<> {
0027 public:
0028   explicit RPCReadOutMapBuilder(const edm::ParameterSet&);
0029   ~RPCReadOutMapBuilder() override = default;
0030   void analyze(const edm::Event&, const edm::EventSetup&) override{};
0031   void beginJob() override;
0032   void endJob() override;
0033 
0034 private:
0035   RPCReadOutMapping cabling;
0036   string m_record;
0037 };
0038 
0039 RPCReadOutMapBuilder::RPCReadOutMapBuilder(const edm::ParameterSet& iConfig)
0040     : m_record(iConfig.getParameter<std::string>("record")) {
0041   cout << " HERE record: " << m_record << endl;
0042   ::putenv(const_cast<char*>(std::string("CORAL_AUTH_USER=me").c_str()));
0043   ::putenv(const_cast<char*>(std::string("CORAL_AUTH_PASSWORD=test").c_str()));
0044 }
0045 
0046 // ------------ method called to store map -------------------
0047 void RPCReadOutMapBuilder::endJob() {
0048   cout << "Now writing to DB" << endl;
0049   edm::Service<cond::service::PoolDBOutputService> mydbservice;
0050   if (!mydbservice.isAvailable()) {
0051     cout << "db service unavailable" << endl;
0052     return;
0053   } else {
0054     cout << "DB service OK" << endl;
0055   }
0056 
0057   try {
0058     if (mydbservice->isNewTagRequest(m_record)) {
0059       mydbservice->createOneIOV(cabling, mydbservice->beginOfTime(), m_record);
0060     } else {
0061       mydbservice->appendOneIOV(cabling, mydbservice->currentTime(), m_record);
0062     }
0063   } catch (std::exception& e) {
0064     cout << "std::exception:  " << e.what();
0065   } catch (...) {
0066     cout << "Unknown error caught " << endl;
0067   }
0068   cout << "... all done, end" << endl;
0069 }
0070 
0071 // ------------ method called to produce the data  ------------
0072 void RPCReadOutMapBuilder::beginJob() {
0073   cout << "BeginJob method " << endl;
0074   cout << "Building RPC Cabling" << endl;
0075   RPCReadOutMapping cabling;
0076   {
0077     DccSpec dcc(790);
0078     for (int idtb = 1; idtb <= 68; idtb++) {
0079       TriggerBoardSpec tb(idtb);
0080 
0081       for (int idlc = 0; idlc <= 17; idlc++) {
0082         LinkConnSpec lc(idlc);
0083         for (int idlb = 0; idlb <= 2; idlb++) {
0084           bool master = (idlb == 0);
0085           LinkBoardSpec lb(master, idlb, 0);
0086           for (int ifeb = 0; ifeb <= 5; ifeb++) {
0087             FebLocationSpec febLocation = {3, 2, 1, 2};
0088             ChamberLocationSpec chamber = {1, 5, 3, 1, 1, 1, 1};
0089             FebConnectorSpec febConn(ifeb, chamber, febLocation);
0090             /*              for (int istrip=0; istrip <= 15; istrip++) {
0091               int chamberStrip = ifeb*16+istrip;
0092               int cmsStrip = chamberStrip;
0093               ChamberStripSpec strip = {istrip, chamberStrip, cmsStrip};
0094               febConn.add( strip);
0095             } */
0096             //            febConn.addStrips(16,1,1,1,1);
0097             lb.add(febConn);
0098           }
0099           lc.add(lb);
0100         }
0101         tb.add(lc);
0102       }
0103       dcc.add(tb);
0104     }
0105     cabling.add(dcc);
0106   }
0107 }
0108 
0109 //define this as a plug-in
0110 #include "FWCore/Framework/interface/MakerMacros.h"
0111 DEFINE_FWK_MODULE(RPCReadOutMapBuilder);