Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:36

0001 #include "EcalElectronicsMappingBuilder.h"
0002 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0003 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
0004 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
0005 
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "CondFormats/DataRecord/interface/EcalMappingElectronicsRcd.h"
0008 
0009 EcalElectronicsMappingBuilder::EcalElectronicsMappingBuilder(const edm::ParameterSet&)
0010     : eeToken_{
0011           setWhatProduced(this).consumesFrom<EcalMappingElectronics, EcalMappingElectronicsRcd>(edm::ESInputTag{})} {}
0012 
0013 // ------------ method called to produce the data  ------------
0014 EcalElectronicsMappingBuilder::ReturnType EcalElectronicsMappingBuilder::produce(const EcalMappingRcd& iRecord) {
0015   auto prod = std::make_unique<EcalElectronicsMapping>();
0016 
0017   const auto& item = iRecord.get(eeToken_);
0018 
0019   const std::vector<EcalMappingElement>& ee = item.endcapItems();
0020   FillFromDatabase(ee, *prod);
0021   return prod;
0022 }
0023 
0024 void EcalElectronicsMappingBuilder::FillFromDatabase(const std::vector<EcalMappingElement>& ee,
0025                                                      EcalElectronicsMapping& theMap) {
0026   for (unsigned int i = 0; i < ee.size(); i++) {
0027     if (ee[i].electronicsid == 0)
0028       continue;
0029     if (ee[i].triggerid == 0)
0030       continue;
0031     theMap.assign(EEDetId::unhashIndex(i).rawId(), ee[i].electronicsid, ee[i].triggerid);
0032   }
0033   return;
0034 }