CMS 3D CMS Logo

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