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 
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(uint64_t * buffer, unsigned int 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  const int dcc = electronicsMapper_->getSMId(fed);
101  const std::vector<DetId> xtals = electronicsMapper_->mapping()->dccTowerConstituents(dcc, ccu);
102 
103  // collect set of status codes of given CCU
104  std::set<uint16_t> set;
105  for (size_t i = 0; i < xtals.size(); ++i) {
106  const uint16_t val = getChannelValue(xtals[i]);
107  set.insert(val);
108  }
109 
110  // if all crystals in CCU have the same status
111  // then this status is treated as CCU status
112  if (set.size() == 1) return *set.begin();
113 
114  // if there are several statuses:
115  return 0;
116 }
void unpack(uint64_t *buffer, unsigned int bufferSize, unsigned int smId, unsigned int fedId)
int i
Definition: DBlmapReader.cc:9
DCCEventBlock * currentEvent_
unsigned int getSMId(unsigned int aDCCId) const
const EcalElectronicsMapping * mapping()
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
void unpack(uint64_t *buffer, unsigned int bufferSize, unsigned int expFedId)
void enableSyncChecks()
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(uint64_t *buffer, unsigned int bufferSize, unsigned int expFedId)
static bool silentMode_
DCCDataUnpacker(EcalElectronicsMapper *, bool hU, bool srpU, bool tccU, bool feU, bool memU, bool syncCheck, bool feIdCheck, bool forceToKeepFRdata)
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:20
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.
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.