CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
DCCTowerBlock Class Reference

#include <DCCTowerBlock.h>

Inheritance diagram for DCCTowerBlock:
DCCFEBlock DCCDataBlockPrototype

Public Member Functions

 DCCTowerBlock (DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack, bool forceToKeepFRdata)
 
void updateCollectors () override
 
- Public Member Functions inherited from DCCFEBlock
 DCCFEBlock (DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack, bool forceToKeepFRdata)
 
void display (std::ostream &o) override
 
void enableFeIdChecks ()
 
unsigned int getLength () override
 
virtual int unpack (const uint64_t **data, unsigned int *dwToEnd)
 
int unpack (const uint64_t **data, unsigned int *dwToEnd, bool zs, unsigned int expectedTowerID)
 
void zsFlag (bool zs)
 
 ~DCCFEBlock () override
 
- Public Member Functions inherited from DCCDataBlockPrototype
 DCCDataBlockPrototype (DCCDataUnpacker *unpacker, EcalElectronicsMapper *mapper, DCCEventBlock *event, bool unpack=true)
 
void enableSyncChecks ()
 
virtual int unpack (const uint64_t **data, unsigned int *dwToEnd)
 
virtual void updateEventPointers ()
 
virtual ~DCCDataBlockPrototype ()
 

Protected Member Functions

void fillEcalElectronicsError (std::unique_ptr< EcalElectronicsIdCollection > *) override
 
int unpackXtalData (unsigned int stripID, unsigned int xtalID) override
 

Protected Attributes

std::unique_ptr< EBDigiCollection > * digis_
 
std::unique_ptr< EBDetIdCollection > * invalidChIds_
 
std::unique_ptr< EBDetIdCollection > * invalidGains_
 
std::unique_ptr< EBDetIdCollection > * invalidGainsSwitch_
 
EBDetIdpDetId_
 
- Protected Attributes inherited from DCCFEBlock
unsigned int blockSize_
 
unsigned int bx_
 
bool checkFeId_
 
unsigned int expTowerID_
 
unsigned int expXtalTSamples_
 
bool forceToKeepFRdata_
 
std::unique_ptr< EcalElectronicsIdCollection > * invalidBlockLengths_
 
std::unique_ptr< EcalElectronicsIdCollection > * invalidTTIds_
 
std::unique_ptr< EcalElectronicsIdCollection > * invalidZSXtalIds_
 
unsigned int l1_
 
unsigned int lastStripId_
 
unsigned int lastXtalId_
 
unsigned int nTSamples_
 
unsigned int numbDWInXtalBlock_
 
unsigned int towerId_
 
unsigned int unfilteredDataBlockLength_
 
unsigned int xtalBlockSize_
 
short * xtalGains_
 
bool zs_
 
- Protected Attributes inherited from DCCDataBlockPrototype
unsigned int blockLength_
 
const uint64_t * data_
 
const uint64_t ** datap_
 
unsigned int * dwToEnd_
 
bool error_
 
DCCEventBlockevent_
 
EcalElectronicsMappermapper_
 
bool sync_
 
DCCDataUnpackerunpacker_
 
bool unpackInternalData_
 

Detailed Description

Definition at line 22 of file DCCTowerBlock.h.

Constructor & Destructor Documentation

◆ DCCTowerBlock()

DCCTowerBlock::DCCTowerBlock ( DCCDataUnpacker u,
EcalElectronicsMapper m,
DCCEventBlock e,
bool  unpack,
bool  forceToKeepFRdata 
)

Definition at line 8 of file DCCTowerBlock.cc.

10  : DCCFEBlock(u, m, e, unpack, forceToKeepFRdata) {}
int unpack(const uint64_t **data, unsigned int *dwToEnd, bool zs, unsigned int expectedTowerID)
Definition: DCCFEBlock.cc:22
DCCFEBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack, bool forceToKeepFRdata)
Definition: DCCFEBlock.cc:7

Member Function Documentation

◆ fillEcalElectronicsError()

void DCCTowerBlock::fillEcalElectronicsError ( std::unique_ptr< EcalElectronicsIdCollection > *  errorColection)
overrideprotectedvirtual

Reimplemented from DCCFEBlock.

Definition at line 263 of file DCCTowerBlock.cc.

References DCCDataBlockPrototype::event_, DCCFEBlock::expTowerID_, EcalElectronicsMapper::getActiveSM(), EcalElectronicsMapper::getTTEleIdPointer(), DCCEventBlock::l1A(), DCCDataBlockPrototype::mapper_, NUMB_SM_EB_MIN_MIN, NUMB_SM_EB_PLU_MAX, DCCDataUnpacker::silentMode_, and TCCID_SMID_SHIFT_EB.

Referenced by unpackXtalData().

263  {
264  const int activeDCC = mapper_->getActiveSM();
265 
266  if (NUMB_SM_EB_MIN_MIN <= activeDCC && activeDCC <= NUMB_SM_EB_PLU_MAX) {
268  (*errorColection)->push_back(*eleTp);
269  } else {
271  edm::LogWarning("IncorrectBlock") << "For event " << event_->l1A() << " there's fed: " << activeDCC
272  << " activeDcc: " << mapper_->getActiveSM()
273  << " but that activeDcc is not valid in EB.";
274  }
275  }
276 }
unsigned int expTowerID_
Definition: DCCFEBlock.h:46
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
static std::atomic< bool > silentMode_
EcalElectronicsMapper * mapper_
Log< level::Warning, false > LogWarning
EcalElectronicsId * getTTEleIdPointer(unsigned int tccId, unsigned int tower)
unsigned int l1A()
Definition: DCCEventBlock.h:57

◆ unpackXtalData()

int DCCTowerBlock::unpackXtalData ( unsigned int  stripID,
unsigned int  xtalID 
)
overrideprotectedvirtual

Reimplemented from DCCFEBlock.

Definition at line 23 of file DCCTowerBlock.cc.

References BLOCK_UNPACKED, DCCEventBlock::bx(), data, DCCDataBlockPrototype::data_, das-up-to-nevents::df, DCCDataBlockPrototype::event_, fillEcalElectronicsError(), PedestalClient_cfi::gain, EcalElectronicsMapper::getActiveDCC(), DCCDataUnpacker::getChannelValue(), EcalElectronicsMapper::getDetIdPointer(), mps_fire::i, DCCFEBlock::invalidZSXtalIds_, DCCEventBlock::l1A(), DCCFEBlock::lastStripId_, DCCFEBlock::lastXtalId_, DCCDataBlockPrototype::mapper_, SiStripPI::min, DCCFEBlock::nTSamples_, NUMB_STRIP, NUMB_XTAL, DCCFEBlock::numbDWInXtalBlock_, pDetId_, alignCSCRings::s, DCCDataUnpacker::silentMode_, SKIP_BLOCK_UNPACKING, TOWER_DIGI_MASK, TOWER_STRIPID_MASK, TOWER_XTALID_B, TOWER_XTALID_MASK, DCCFEBlock::towerId_, DCCDataBlockPrototype::unpacker_, DCCFEBlock::xtalGains_, and DCCFEBlock::zs_.

23  {
24  bool errorOnXtal(false);
25 
26  const uint16_t *xData_ = reinterpret_cast<const uint16_t *>(data_);
27 
28  // Get xtal data ids
29  unsigned int stripId = (*xData_) & TOWER_STRIPID_MASK;
30  unsigned int xtalId = ((*xData_) >> TOWER_XTALID_B) & TOWER_XTALID_MASK;
31 
32  // check id in case data are not 0suppressed
33  if (!zs_ && (expStripID != stripId || expXtalID != xtalId)) {
35  edm::LogWarning("IncorrectBlock") << "For event L1A: " << event_->l1A() << ", fed " << mapper_->getActiveDCC()
36  << " and tower " << towerId_ << "\n The expected strip is " << expStripID
37  << " and " << stripId << " was found"
38  << "\n The expected xtal is " << expXtalID << " and " << xtalId
39  << " was found";
40  }
41  // using expected cry_di to raise warning about xtal_id problem
42  pDetId_ = (EBDetId *)mapper_->getDetIdPointer(towerId_, expStripID, expXtalID);
43  (*invalidChIds_)->push_back(*pDetId_);
44 
45  // return here, so to skip all following checks
46  lastXtalId_++;
47  if (lastXtalId_ > NUMB_XTAL) {
48  lastXtalId_ = 1;
49  lastStripId_++;
50  }
52  return BLOCK_UNPACKED;
53 
54  //keep these here in case the return is to be dropped
55  stripId = expStripID;
56  xtalId = expXtalID;
57  errorOnXtal = true;
58  }
59 
60  // check id in case of 0suppressed data
61 
62  else if (zs_) {
63  // Check for valid Ids 1) values out of range
64 
65  if (stripId == 0 || stripId > 5 || xtalId == 0 || xtalId > 5) {
67  edm::LogWarning("IncorrectBlock")
68  << "For event L1A: " << event_->l1A() << ", fed " << mapper_->getActiveDCC() << " and tower " << towerId_
69  << "\n Invalid strip : " << stripId << " or xtal : " << xtalId << " ids ( last strip was: " << lastStripId_
70  << " last ch was: " << lastXtalId_ << ")";
71  }
72 
73  int st = lastStripId_;
74  int ch = lastXtalId_;
75  ch++;
76  if (ch > NUMB_XTAL) {
77  ch = 1;
78  st++;
79  }
80  if (st > NUMB_STRIP) {
81  ch = 1;
82  st = 1;
83  }
84 
85  // adding channel following the last valid
86  //pDetId_ = (EBDetId*) mapper_->getDetIdPointer(towerId_,st,ch);
87  //(*invalidChIds_)->push_back(*pDetId_);
89 
90  lastStripId_ = st;
91  lastXtalId_ = ch;
92 
93  // return here, so to skip all following checks
94  return SKIP_BLOCK_UNPACKING;
95  errorOnXtal = true; //keep it here in case the return is to be dropped
96  } else {
97  // Check for zs valid Ids 2) if channel-in-strip has increased wrt previous xtal
98 
99  // Check for zs valid Ids 2) if channel-in-strip has increased wrt previous xtal
100  // 3) if strip has increased wrt previous xtal
101  if ((stripId == lastStripId_ && xtalId <= lastXtalId_) || (stripId < lastStripId_)) {
103  edm::LogWarning("IncorrectBlock")
104  << "Xtal id was expected to increase but it didn't - last valid xtal id was " << lastXtalId_
105  << " while current xtal is " << xtalId << " (LV1 " << event_->l1A() << " fed " << mapper_->getActiveDCC()
106  << " tower " << towerId_ << ")";
107  }
108 
109  int st = lastStripId_;
110  int ch = lastXtalId_;
111  ch++;
112  if (ch > NUMB_XTAL) {
113  ch = 1;
114  st++;
115  }
116  if (st > NUMB_STRIP) {
117  ch = 1;
118  st = 1;
119  }
120 
121  // adding channel following the last valid
122  //pDetId_ = (EBDetId*) mapper_->getDetIdPointer(towerId_,st,ch);
123  //(*invalidChIds_)->push_back(*pDetId_);
125 
126  lastStripId_ = st;
127  lastXtalId_ = ch;
128 
129  // return here, so to skip all following checks
130  return SKIP_BLOCK_UNPACKING;
131  errorOnXtal = true; //keep it here in case the return is to be dropped
132  }
133 
134  // if channel id not proven wrong, update lastStripId_ and lastXtalId_
135  lastStripId_ = stripId;
136  lastXtalId_ = xtalId;
137  } //end else
138  } // end if (zs_)
139 
140  bool addedFrame = false;
141 
142  // if there is an error on xtal id ignore next error checks
143  // otherwise, assume channel_id is valid and proceed with making and checking the data frame
144  if (errorOnXtal)
145  return SKIP_BLOCK_UNPACKING;
146 
147  pDetId_ = (EBDetId *)mapper_->getDetIdPointer(towerId_, stripId, xtalId);
148  (*digis_)->push_back(*pDetId_);
149  EBDataFrame df((*digis_)->back());
150  addedFrame = true;
151  bool wrongGain(false);
152 
153  //set samples in the data frame
154  for (unsigned int i = 0; i < nTSamples_; i++) { // loop on samples
155  xData_++;
156  unsigned int data = (*xData_) & TOWER_DIGI_MASK;
157  unsigned int gain = data >> 12;
158  xtalGains_[i] = gain;
159  if (gain == 0) {
160  wrongGain = true;
161  // although gain==0 found, produce the dataFrame in order to have it, for saturation case
162  }
163  df.setSample(i, data);
164  } // loop on samples
165 
166  bool isSaturation(true);
167  if (wrongGain) {
168  // check whether the gain==0 has features of saturation or not
169  // gain==0 occurs either in case of data corruption or of ADC saturation
170  // \->reject digi \-> keep digi
171 
172  // determine where gainId==0 starts
173  short firstGainZeroSampID(-1);
174  short firstGainZeroSampADC(-1);
175  for (unsigned int s = 0; s < nTSamples_; s++) {
176  if (df.sample(s).gainId() == 0 && firstGainZeroSampID == -1) {
177  firstGainZeroSampID = s;
178  firstGainZeroSampADC = df.sample(s).adc();
179  break;
180  }
181  }
182 
183  // check whether gain==0 and adc() stays constant for (at least) 5 consecutive samples
184  unsigned int plateauEnd = std::min(nTSamples_, (unsigned int)(firstGainZeroSampID + 5));
185  for (unsigned int s = firstGainZeroSampID; s < plateauEnd; s++) {
186  if (df.sample(s).gainId() == 0 && df.sample(s).adc() == firstGainZeroSampADC) {
187  ;
188  } else {
189  isSaturation = false;
190  break;
191  } //it's not saturation
192  }
193  // get rid of channels which are stuck in gain0
194  if (firstGainZeroSampID < 3) {
195  isSaturation = false;
196  }
197 
199  if (unpacker_->getChannelValue(mapper_->getActiveDCC(), towerId_, stripId, xtalId) != 10) {
200  edm::LogWarning("IncorrectGain") << "Gain zero" << (isSaturation ? " with features of saturation" : "")
201  << " was found in Tower Block"
202  << " (L1A " << event_->l1A() << " bx " << event_->bx() << " fed "
203  << mapper_->getActiveDCC() << " tower " << towerId_ << " strip " << stripId
204  << " xtal " << xtalId << ")";
205  }
206  }
207 
208  if (!isSaturation) {
209  (*invalidGains_)->push_back(*pDetId_);
210  (*digis_)->pop_back();
211 
212  //Point to begin of next xtal Block
214  //return here, so to skip all the rest
215  //make special collection for gain0 data frames when due to saturation
216  return BLOCK_UNPACKED;
217  errorOnXtal = true; //keep it here in case the return is to be dropped
218  } //end isSaturation
219  else {
221  return BLOCK_UNPACKED;
222  }
223 
224  } //end WrongGain
225 
226  // from here on, care about gain switches
227 
228  short numGain = 1;
229  bool gainSwitchError = false;
230 
231  for (unsigned int i = 1; i < nTSamples_; i++) {
232  if (xtalGains_[i - 1] > xtalGains_[i] && numGain < 5)
233  gainSwitchError = true;
234  if (xtalGains_[i - 1] == xtalGains_[i])
235  numGain++;
236  else
237  numGain = 1;
238  }
239 
240  if (gainSwitchError) {
242  edm::LogWarning("IncorrectGain") << "A wrong gain transition switch was found for Tower Block in strip "
243  << stripId << " and xtal " << xtalId << " (L1A " << event_->l1A() << " bx "
244  << event_->bx() << " fed " << mapper_->getActiveDCC() << " tower " << towerId_
245  << ")";
246  }
247 
248  (*invalidGainsSwitch_)->push_back(*pDetId_);
249  errorOnXtal = true;
250  }
251 
252  //Add frame to collection only if all data format and gain rules are respected
253  if (errorOnXtal && addedFrame) {
254  (*digis_)->pop_back();
255  }
256 
257  //Point to begin of next xtal Block
259 
260  return BLOCK_UNPACKED;
261 }
void fillEcalElectronicsError(std::unique_ptr< EcalElectronicsIdCollection > *) override
unsigned int towerId_
Definition: DCCFEBlock.h:53
bool zs_
Definition: DCCFEBlock.h:42
DetId * getDetIdPointer(unsigned int feChannel, unsigned int strip, unsigned int xtal)
unsigned int nTSamples_
Definition: DCCFEBlock.h:56
uint16_t getChannelValue(const DetId &id) const
static std::atomic< bool > silentMode_
unsigned int lastXtalId_
Definition: DCCFEBlock.h:51
unsigned int bx()
Definition: DCCEventBlock.h:58
EBDetId * pDetId_
Definition: DCCTowerBlock.h:36
unsigned int lastStripId_
Definition: DCCFEBlock.h:50
DCCDataUnpacker * unpacker_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
unsigned int numbDWInXtalBlock_
Definition: DCCFEBlock.h:54
EcalElectronicsMapper * mapper_
std::unique_ptr< EcalElectronicsIdCollection > * invalidZSXtalIds_
Definition: DCCFEBlock.h:64
Log< level::Warning, false > LogWarning
short * xtalGains_
Definition: DCCFEBlock.h:62
unsigned int l1A()
Definition: DCCEventBlock.h:57

◆ updateCollectors()

void DCCTowerBlock::updateCollectors ( )
overridevirtual

Reimplemented from DCCFEBlock.

Definition at line 12 of file DCCTowerBlock.cc.

References digis_, DCCDataUnpacker::ebDigisCollection(), invalidChIds_, DCCDataUnpacker::invalidChIdsCollection(), invalidGains_, DCCDataUnpacker::invalidGainsCollection(), invalidGainsSwitch_, DCCDataUnpacker::invalidGainsSwitchCollection(), DCCDataBlockPrototype::unpacker_, and DCCFEBlock::updateCollectors().

12  {
14 
15  // needs to be update for eb/ee
17 
21 }
std::unique_ptr< EBDetIdCollection > * invalidGainsCollection()
std::unique_ptr< EBDetIdCollection > * invalidGainsSwitch_
Definition: DCCTowerBlock.h:40
std::unique_ptr< EBDetIdCollection > * invalidChIds_
Definition: DCCTowerBlock.h:41
void updateCollectors() override
Definition: DCCFEBlock.cc:16
std::unique_ptr< EBDetIdCollection > * invalidGainsSwitchCollection()
std::unique_ptr< EBDetIdCollection > * invalidChIdsCollection()
DCCDataUnpacker * unpacker_
std::unique_ptr< EBDetIdCollection > * invalidGains_
Definition: DCCTowerBlock.h:39
std::unique_ptr< EBDigiCollection > * digis_
Definition: DCCTowerBlock.h:34
std::unique_ptr< EBDigiCollection > * ebDigisCollection()

Member Data Documentation

◆ digis_

std::unique_ptr<EBDigiCollection>* DCCTowerBlock::digis_
protected

Definition at line 34 of file DCCTowerBlock.h.

Referenced by updateCollectors().

◆ invalidChIds_

std::unique_ptr<EBDetIdCollection>* DCCTowerBlock::invalidChIds_
protected

Definition at line 41 of file DCCTowerBlock.h.

Referenced by updateCollectors().

◆ invalidGains_

std::unique_ptr<EBDetIdCollection>* DCCTowerBlock::invalidGains_
protected

Definition at line 39 of file DCCTowerBlock.h.

Referenced by updateCollectors().

◆ invalidGainsSwitch_

std::unique_ptr<EBDetIdCollection>* DCCTowerBlock::invalidGainsSwitch_
protected

Definition at line 40 of file DCCTowerBlock.h.

Referenced by updateCollectors().

◆ pDetId_

EBDetId* DCCTowerBlock::pDetId_
protected

Definition at line 36 of file DCCTowerBlock.h.

Referenced by unpackXtalData().