File indexing completed on 2024-04-06 12:10:34
0001 #include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
0002 #include "EventFilter/EcalRawToDigi/interface/DCCEBEventBlock.h"
0003 #include "EventFilter/EcalRawToDigi/interface/DCCEEEventBlock.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0006 #include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
0007 #include <set>
0008
0009 std::atomic<bool> DCCDataUnpacker::silentMode_(false);
0010
0011 DCCDataUnpacker::DCCDataUnpacker(EcalElectronicsMapper* mapper,
0012 bool hU,
0013 bool srpU,
0014 bool tccU,
0015 bool feU,
0016 bool memU,
0017 bool syncCheck,
0018 bool feIdCheck,
0019 bool forceToKeepFRdata) {
0020 electronicsMapper_ = mapper;
0021 ebEventBlock_ = new DCCEBEventBlock(this, mapper, hU, srpU, tccU, feU, memU, forceToKeepFRdata);
0022 eeEventBlock_ = new DCCEEEventBlock(this, mapper, hU, srpU, tccU, feU, memU, forceToKeepFRdata);
0023 if (syncCheck) {
0024 ebEventBlock_->enableSyncChecks();
0025 eeEventBlock_->enableSyncChecks();
0026 }
0027 if (feIdCheck) {
0028 ebEventBlock_->enableFeIdChecks();
0029 eeEventBlock_->enableFeIdChecks();
0030 }
0031 }
0032
0033 void DCCDataUnpacker::unpack(const uint64_t* buffer, size_t bufferSize, unsigned int smId, unsigned int fedId) {
0034
0035
0036
0037 if (smId > 9 && smId < 46) {
0038 currentEvent_ = ebEventBlock_;
0039 ebEventBlock_->updateCollectors();
0040 ebEventBlock_->unpack(buffer, bufferSize, fedId);
0041
0042 } else {
0043 currentEvent_ = eeEventBlock_;
0044 eeEventBlock_->updateCollectors();
0045 eeEventBlock_->unpack(buffer, bufferSize, fedId);
0046 }
0047 }
0048
0049 DCCDataUnpacker::~DCCDataUnpacker() {
0050 delete ebEventBlock_;
0051 delete eeEventBlock_;
0052 }
0053
0054 uint16_t DCCDataUnpacker::getChannelStatus(const DetId& id) const {
0055
0056
0057
0058
0059 const uint16_t NO_DATA = 11;
0060
0061 if (chdb_ == nullptr) {
0062 edm::LogError("IncorrectMapping") << "ECAL channel status database do not initialized";
0063 return NO_DATA;
0064 }
0065
0066 EcalChannelStatus::const_iterator pCh = chdb_->find(id);
0067
0068 if (pCh != chdb_->end()) {
0069 return pCh->getStatusCode();
0070 } else {
0071 edm::LogError("IncorrectMapping") << "No channel status record found for detit = " << id.rawId();
0072 return NO_DATA;
0073 }
0074 }
0075
0076 uint16_t DCCDataUnpacker::getChannelValue(const DetId& id) const { return getChannelStatus(id) & 0x1F; }
0077
0078 uint16_t DCCDataUnpacker::getChannelValue(const int fed, const int ccu, const int strip, const int xtal) const {
0079
0080 const int dcc = electronicsMapper_->getSMId(fed);
0081
0082
0083 const EcalElectronicsId eid(dcc, ccu, strip, xtal);
0084 const DetId id = electronicsMapper_->mapping()->getDetId(eid);
0085
0086 return getChannelStatus(id) & 0x1F;
0087 }
0088
0089 uint16_t DCCDataUnpacker::getCCUValue(const int fed, const int ccu) const {
0090
0091
0092 const int dcc = electronicsMapper_->getSMId(fed);
0093 const std::vector<DetId> xtals =
0094 (ccu <= 68) ? electronicsMapper_->mapping()->dccTowerConstituents(dcc, ccu) : std::vector<DetId>();
0095
0096
0097 std::set<uint16_t> set;
0098 for (size_t i = 0; i < xtals.size(); ++i) {
0099 const uint16_t val = getChannelValue(xtals[i]);
0100 set.insert(val);
0101 }
0102
0103
0104
0105 if (set.size() == 1)
0106 return *set.begin();
0107
0108
0109 return 0;
0110 }