Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:59

0001 #include "CondTools/Ecal/interface/EcalLaserHandler.h"
0002 
0003 #include "CondTools/Ecal/interface/EcalMappingElectronicsHandler.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0005 
0006 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0007 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0008 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
0009 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
0010 
0011 #include "DataFormats/Provenance/interface/Timestamp.h"
0012 #include <iostream>
0013 #include <memory>
0014 
0015 EcalMappingElectronicsHandler::EcalMappingElectronicsHandler(const edm::ParameterSet &ps)
0016     : txtFileSource_(ps.getUntrackedParameter<std::string>("txtFile")),
0017       m_name(ps.getUntrackedParameter<std::string>("name", "EcalMappingElectronicsHandler")),
0018       since_(ps.getUntrackedParameter<long long>("since", 1)) {
0019   std::cout << "EcalMappingElectronics Source handler constructor\n" << std::endl;
0020 }
0021 
0022 EcalMappingElectronicsHandler::~EcalMappingElectronicsHandler() {}
0023 
0024 void EcalMappingElectronicsHandler::getNewObjects() {
0025   std::cout << "------- Ecal - > getNewObjects\n";
0026   EcalMappingElectronics *payload = new EcalMappingElectronics;
0027   std::unique_ptr<EcalMappingElectronics> mapping = std::make_unique<EcalMappingElectronics>();
0028   //Filling map reading from file
0029   edm::LogInfo("EcalMappingElectronicsHandler")
0030       << "Reading mapping from file " << edm::FileInPath(txtFileSource_).fullPath().c_str();
0031 
0032   std::ifstream f(edm::FileInPath(txtFileSource_).fullPath().c_str());
0033   if (!f.good()) {
0034     edm::LogError("EcalMappingElectronicsHandler") << "File not found";
0035     throw cms::Exception("FileNotFound");
0036   }
0037 
0038   // uint32_t detid, elecid, triggerid;
0039 
0040   int ix, iy, iz, CL;
0041   // int dccid, towerid, stripid, xtalid;
0042   // int tccid, tower, ipseudostrip, xtalinps;
0043   int dccid, towerid, pseudostrip_in_SC, xtal_in_pseudostrip;
0044   int tccid, tower, pseudostrip_in_TCC, pseudostrip_in_TT;
0045 
0046   while (!f.eof()) {
0047     // f >> detid >> elecid >> triggerid;
0048     f >> ix >> iy >> iz >> CL >> dccid >> towerid >> pseudostrip_in_SC >> xtal_in_pseudostrip >> tccid >> tower >>
0049         pseudostrip_in_TCC >> pseudostrip_in_TT;
0050 
0051     //       if (!EEDetId::validDetId(ix,iy,iz))
0052     //    continue;
0053 
0054     EEDetId detid(ix, iy, iz, EEDetId::XYMODE);
0055     // std::cout << " dcc tower ps_in_SC xtal_in_ps " << dccid << " " << towerid << " " << pseudostrip_in_SC << " " << xtal_in_pseudostrip << std::endl;
0056     EcalElectronicsId elecid(dccid, towerid, pseudostrip_in_SC, xtal_in_pseudostrip);
0057     // std::cout << " tcc tt ps_in_TT xtal_in_ps " << tccid << " " << tower << " " << pseudostrip_in_TT << " " << xtal_in_pseudostrip << std::endl;
0058     EcalTriggerElectronicsId triggerid(tccid, tower, pseudostrip_in_TT, xtal_in_pseudostrip);
0059     EcalMappingElement aElement;
0060     aElement.electronicsid = elecid.rawId();
0061     aElement.triggerid = triggerid.rawId();
0062     (*payload).setValue(detid, aElement);
0063   }
0064 
0065   f.close();
0066   edm::LogInfo("EcalMappingElectronicsHandler") << "Reading completed ready to insert in DB";
0067   //Filling completed transferring to DB
0068   m_to_transfer.push_back(std::make_pair(payload, since_));
0069   //  delete payload;
0070 }