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) {}

Member Function Documentation

◆ fillEcalElectronicsError()

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

Reimplemented from DCCFEBlock.

Definition at line 263 of file DCCTowerBlock.cc.

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 }

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().

◆ unpackXtalData()

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

Reimplemented from DCCFEBlock.

Definition at line 23 of file DCCTowerBlock.cc.

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 }

References BLOCK_UNPACKED, DCCEventBlock::bx(), data, DCCDataBlockPrototype::data_, 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_, 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_.

◆ updateCollectors()

void DCCTowerBlock::updateCollectors ( )
overridevirtual

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().

mps_fire.i
i
Definition: mps_fire.py:355
TOWER_XTALID_MASK
Definition: DCCRawDataDefinitions.h:165
DCCFEBlock::unpack
int unpack(const uint64_t **data, unsigned int *dwToEnd, bool zs, unsigned int expectedTowerID)
Definition: DCCFEBlock.cc:22
SKIP_BLOCK_UNPACKING
Definition: DCCRawDataDefinitions.h:7
DCCFEBlock::xtalGains_
short * xtalGains_
Definition: DCCFEBlock.h:62
DCCDataBlockPrototype::data_
const uint64_t * data_
Definition: DCCDataBlockPrototype.h:73
DCCTowerBlock::invalidChIds_
std::unique_ptr< EBDetIdCollection > * invalidChIds_
Definition: DCCTowerBlock.h:41
min
T min(T a, T b)
Definition: MathUtil.h:58
EBDetId
Definition: EBDetId.h:17
EBDataFrame
Definition: EBDataFrame.h:11
DCCFEBlock::invalidZSXtalIds_
std::unique_ptr< EcalElectronicsIdCollection > * invalidZSXtalIds_
Definition: DCCFEBlock.h:64
TOWER_XTALID_B
Definition: DCCRawDataDefinitions.h:166
DCCFEBlock::expTowerID_
unsigned int expTowerID_
Definition: DCCFEBlock.h:46
DCCDataUnpacker::ebDigisCollection
std::unique_ptr< EBDigiCollection > * ebDigisCollection()
Definition: DCCDataUnpacker.h:118
EcalElectronicsMapper::getActiveSM
unsigned int getActiveSM()
Definition: EcalElectronicsMapper.h:128
DCCTowerBlock::invalidGains_
std::unique_ptr< EBDetIdCollection > * invalidGains_
Definition: DCCTowerBlock.h:39
NUMB_SM_EB_MIN_MIN
Definition: DCCRawDataDefinitions.h:54
DCCTowerBlock::pDetId_
EBDetId * pDetId_
Definition: DCCTowerBlock.h:36
DCCDataUnpacker::silentMode_
static std::atomic< bool > silentMode_
Definition: DCCDataUnpacker.h:185
DCCFEBlock::DCCFEBlock
DCCFEBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack, bool forceToKeepFRdata)
Definition: DCCFEBlock.cc:7
NUMB_STRIP
Definition: DCCRawDataDefinitions.h:46
DCCFEBlock::nTSamples_
unsigned int nTSamples_
Definition: DCCFEBlock.h:56
DCCFEBlock::zs_
bool zs_
Definition: DCCFEBlock.h:42
DCCFEBlock::towerId_
unsigned int towerId_
Definition: DCCFEBlock.h:53
alignCSCRings.s
s
Definition: alignCSCRings.py:92
TOWER_DIGI_MASK
Definition: DCCRawDataDefinitions.h:161
DCCFEBlock::updateCollectors
void updateCollectors() override
Definition: DCCFEBlock.cc:16
DCCTowerBlock::digis_
std::unique_ptr< EBDigiCollection > * digis_
Definition: DCCTowerBlock.h:34
EcalElectronicsMapper::getDetIdPointer
DetId * getDetIdPointer(unsigned int feChannel, unsigned int strip, unsigned int xtal)
Definition: EcalElectronicsMapper.h:86
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
DCCDataBlockPrototype::unpacker_
DCCDataUnpacker * unpacker_
Definition: DCCDataBlockPrototype.h:67
TCCID_SMID_SHIFT_EB
Definition: DCCRawDataDefinitions.h:40
DCCEventBlock::bx
unsigned int bx()
Definition: DCCEventBlock.h:58
EcalElectronicsMapper::getActiveDCC
unsigned int getActiveDCC()
Definition: EcalElectronicsMapper.h:126
EcalElectronicsId
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
Definition: EcalElectronicsId.h:18
DCCTowerBlock::fillEcalElectronicsError
void fillEcalElectronicsError(std::unique_ptr< EcalElectronicsIdCollection > *) override
Definition: DCCTowerBlock.cc:263
edm::LogWarning
Definition: MessageLogger.h:141
NUMB_SM_EB_PLU_MAX
Definition: DCCRawDataDefinitions.h:57
DCCDataBlockPrototype::event_
DCCEventBlock * event_
Definition: DCCDataBlockPrototype.h:70
NUMB_XTAL
Definition: DCCRawDataDefinitions.h:45
DCCFEBlock::lastXtalId_
unsigned int lastXtalId_
Definition: DCCFEBlock.h:51
DCCEventBlock::l1A
unsigned int l1A()
Definition: DCCEventBlock.h:57
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
DCCDataUnpacker::invalidGainsSwitchCollection
std::unique_ptr< EBDetIdCollection > * invalidGainsSwitchCollection()
Definition: DCCDataUnpacker.h:134
DCCDataBlockPrototype::mapper_
EcalElectronicsMapper * mapper_
Definition: DCCDataBlockPrototype.h:69
DCCDataUnpacker::invalidGainsCollection
std::unique_ptr< EBDetIdCollection > * invalidGainsCollection()
Definition: DCCDataUnpacker.h:132
DCCFEBlock::numbDWInXtalBlock_
unsigned int numbDWInXtalBlock_
Definition: DCCFEBlock.h:54
DCCDataUnpacker::getChannelValue
uint16_t getChannelValue(const DetId &id) const
Definition: DCCDataUnpacker.cc:76
DCCTowerBlock::invalidGainsSwitch_
std::unique_ptr< EBDetIdCollection > * invalidGainsSwitch_
Definition: DCCTowerBlock.h:40
TOWER_STRIPID_MASK
Definition: DCCRawDataDefinitions.h:163
EcalElectronicsMapper::getTTEleIdPointer
EcalElectronicsId * getTTEleIdPointer(unsigned int tccId, unsigned int tower)
Definition: EcalElectronicsMapper.h:94
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
DCCDataUnpacker::invalidChIdsCollection
std::unique_ptr< EBDetIdCollection > * invalidChIdsCollection()
Definition: DCCDataUnpacker.h:136
DCCFEBlock::lastStripId_
unsigned int lastStripId_
Definition: DCCFEBlock.h:50
BLOCK_UNPACKED
Definition: DCCRawDataDefinitions.h:6
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37