CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DCCDataUnpacker.cc
Go to the documentation of this file.
7 #include <set>
8 
9 std::atomic<bool> DCCDataUnpacker::silentMode_(false);
10 
12  bool hU,
13  bool srpU,
14  bool tccU,
15  bool feU,
16  bool memU,
17  bool syncCheck,
18  bool feIdCheck,
19  bool forceToKeepFRdata) {
20  electronicsMapper_ = mapper;
21  ebEventBlock_ = new DCCEBEventBlock(this, mapper, hU, srpU, tccU, feU, memU, forceToKeepFRdata);
22  eeEventBlock_ = new DCCEEEventBlock(this, mapper, hU, srpU, tccU, feU, memU, forceToKeepFRdata);
23  if (syncCheck) {
26  }
27  if (feIdCheck) {
30  }
31 }
32 
33 void DCCDataUnpacker::unpack(const uint64_t* buffer, size_t bufferSize, unsigned int smId, unsigned int fedId) {
34  //buffer is pointer to binary data
35  //See if this fed is on EB or in EE
36 
37  if (smId > 9 && smId < 46) {
40  ebEventBlock_->unpack(buffer, bufferSize, fedId);
41 
42  } else {
45  eeEventBlock_->unpack(buffer, bufferSize, fedId);
46  }
47 }
48 
50  delete ebEventBlock_;
51  delete eeEventBlock_;
52 }
53 
54 uint16_t DCCDataUnpacker::getChannelStatus(const DetId& id) const {
55  // return code for situation of missing channel record
56  // equal to "non responding isolated channel (dead of type other)":
57  // https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideEcalRecoLocalReco#Treatment_of_problematic_channel
58  // TODO: think on a better way how to cover this case
59  const uint16_t NO_DATA = 11;
60 
61  if (chdb_ == nullptr) {
62  edm::LogError("IncorrectMapping") << "ECAL channel status database do not initialized";
63  return NO_DATA;
64  }
65 
67 
68  if (pCh != chdb_->end()) {
69  return pCh->getStatusCode();
70  } else {
71  edm::LogError("IncorrectMapping") << "No channel status record found for detit = " << id.rawId();
72  return NO_DATA;
73  }
74 }
75 
76 uint16_t DCCDataUnpacker::getChannelValue(const DetId& id) const { return getChannelStatus(id) & 0x1F; }
77 
78 uint16_t DCCDataUnpacker::getChannelValue(const int fed, const int ccu, const int strip, const int xtal) const {
79  // conversion FED ID [601 - 654] -> DCC ID [1 - 54]
80  const int dcc = electronicsMapper_->getSMId(fed);
81 
82  // convert (dcc, ccu, strip, xtal) -> DetId
83  const EcalElectronicsId eid(dcc, ccu, strip, xtal);
84  const DetId id = electronicsMapper_->mapping()->getDetId(eid);
85 
86  return getChannelStatus(id) & 0x1F;
87 }
88 
89 uint16_t DCCDataUnpacker::getCCUValue(const int fed, const int ccu) const {
90  // get list of crystals (DetId) which correspond to given CCU
91  // (return empty list for MEM channels [CCU > 68])
92  const int dcc = electronicsMapper_->getSMId(fed);
93  const std::vector<DetId> xtals =
94  (ccu <= 68) ? electronicsMapper_->mapping()->dccTowerConstituents(dcc, ccu) : std::vector<DetId>();
95 
96  // collect set of status codes of given CCU
97  std::set<uint16_t> set;
98  for (size_t i = 0; i < xtals.size(); ++i) {
99  const uint16_t val = getChannelValue(xtals[i]);
100  set.insert(val);
101  }
102 
103  // if all crystals in CCU have the same status
104  // then this status is treated as CCU status
105  if (set.size() == 1)
106  return *set.begin();
107 
108  // if there are several or no statuses:
109  return 0;
110 }
DCCEventBlock * currentEvent_
unsigned int getSMId(unsigned int aDCCId) const
const EcalElectronicsMapping * mapping()
void enableSyncChecks()
void unpack(const uint64_t *buffer, size_t bufferSize, unsigned int smId, unsigned int fedId)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
DCCEBEventBlock * ebEventBlock_
void enableFeIdChecks()
void unpack(const uint64_t *buffer, size_t bufferSize, unsigned int expFedId) override
uint16_t getChannelStatus(const DetId &id) const
EcalElectronicsMapper * electronicsMapper_
Log< level::Error, false > LogError
DCCDataUnpacker(EcalElectronicsMapper *, bool hU, bool srpU, bool tccU, bool feU, bool memU, bool syncCheck, bool feIdCheck, bool forceToKeepFRdata)
static std::atomic< bool > silentMode_
const EcalChannelStatusMap * chdb_
uint16_t getChannelValue(const DetId &id) const
uint16_t getCCUValue(const int fed, const int ccu) const
DCCEEEventBlock * eeEventBlock_
Definition: DetId.h:17
unsigned long long uint64_t
Definition: Time.h:13
void unpack(const uint64_t *buffer, size_t bufferSize, unsigned int expFedId) override
void updateCollectors()
std::vector< Item >::const_iterator const_iterator
DetId getDetId(const EcalElectronicsId &id) const
Get the detid given an electronicsId.
const_iterator find(uint32_t rawId) const
const_iterator end() const
std::vector< DetId > dccTowerConstituents(int dccId, int tower) const
Get the constituent detids for this dccId.