CMS 3D CMS Logo

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

#include <DCCSCBlock.h>

Inheritance diagram for DCCSCBlock:
DCCFEBlock DCCDataBlockPrototype

Public Member Functions

 DCCSCBlock (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< EEDigiCollection > * digis_
 
std::unique_ptr< EEDetIdCollection > * invalidChIds_
 
std::unique_ptr< EEDetIdCollection > * invalidGains_
 
std::unique_ptr< EEDetIdCollection > * invalidGainsSwitch_
 
EEDetIdpDetId_
 
EEDataFramepDFId_
 
- 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 DCCSCBlock.h.

Constructor & Destructor Documentation

◆ DCCSCBlock()

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

Definition at line 7 of file DCCSCBlock.cc.

9  : DCCFEBlock(u, m, e, unpack, forceToKeepFRdata) {}

Member Function Documentation

◆ fillEcalElectronicsError()

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

Reimplemented from DCCFEBlock.

Definition at line 269 of file DCCSCBlock.cc.

269  {
270  const int activeDCC = mapper_->getActiveSM();
271 
272  if ((NUMB_SM_EE_MIN_MIN <= activeDCC && activeDCC <= NUMB_SM_EE_MIN_MAX) ||
273  (NUMB_SM_EE_PLU_MIN <= activeDCC && activeDCC <= NUMB_SM_EE_PLU_MAX)) {
275  (*errorColection)->push_back(*eleTp);
276  } else {
278  edm::LogWarning("IncorrectBlock") << "For event " << event_->l1A() << " there's fed: " << activeDCC
279  << " activeDcc: " << mapper_->getActiveSM()
280  << " but that activeDcc is not valid in EE.";
281  }
282  }
283 }

References DCCDataBlockPrototype::event_, DCCFEBlock::expTowerID_, EcalElectronicsMapper::getActiveSM(), EcalElectronicsMapper::getSCElectronicsPointer(), DCCEventBlock::l1A(), DCCDataBlockPrototype::mapper_, NUMB_SM_EE_MIN_MAX, NUMB_SM_EE_MIN_MIN, NUMB_SM_EE_PLU_MAX, NUMB_SM_EE_PLU_MIN, and DCCDataUnpacker::silentMode_.

Referenced by unpackXtalData().

◆ unpackXtalData()

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

Reimplemented from DCCFEBlock.

Definition at line 22 of file DCCSCBlock.cc.

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

References BLOCK_UNPACKED, DCCEventBlock::bx(), data, DCCDataBlockPrototype::data_, hgcalPerformanceValidation::df, DCCDataBlockPrototype::event_, fillEcalElectronicsError(), PedestalClient_cfi::gain, EcalElectronicsMapper::getActiveDCC(), DCCDataUnpacker::getChannelValue(), EcalElectronicsMapper::getDetIdPointer(), mps_fire::i, DCCFEBlock::invalidZSXtalIds_, EcalElectronicsMapper::isGhost(), 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 DCCSCBlock::updateCollectors ( )
overridevirtual

Member Data Documentation

◆ digis_

std::unique_ptr<EEDigiCollection>* DCCSCBlock::digis_
protected

Definition at line 37 of file DCCSCBlock.h.

Referenced by updateCollectors().

◆ invalidChIds_

std::unique_ptr<EEDetIdCollection>* DCCSCBlock::invalidChIds_
protected

Definition at line 42 of file DCCSCBlock.h.

Referenced by updateCollectors().

◆ invalidGains_

std::unique_ptr<EEDetIdCollection>* DCCSCBlock::invalidGains_
protected

Definition at line 40 of file DCCSCBlock.h.

Referenced by updateCollectors().

◆ invalidGainsSwitch_

std::unique_ptr<EEDetIdCollection>* DCCSCBlock::invalidGainsSwitch_
protected

Definition at line 41 of file DCCSCBlock.h.

Referenced by updateCollectors().

◆ pDetId_

EEDetId* DCCSCBlock::pDetId_
protected

Definition at line 34 of file DCCSCBlock.h.

Referenced by unpackXtalData().

◆ pDFId_

EEDataFrame* DCCSCBlock::pDFId_
protected

Definition at line 35 of file DCCSCBlock.h.

DCCDataUnpacker::eeDigisCollection
std::unique_ptr< EEDigiCollection > * eeDigisCollection()
Definition: DCCDataUnpacker.h:120
mps_fire.i
i
Definition: mps_fire.py:428
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
EcalElectronicsMapper::getSCElectronicsPointer
EcalElectronicsId * getSCElectronicsPointer(unsigned int smId, unsigned int feChannel)
Definition: EcalElectronicsMapper.h:106
min
T min(T a, T b)
Definition: MathUtil.h:58
DCCSCBlock::invalidGainsSwitch_
std::unique_ptr< EEDetIdCollection > * invalidGainsSwitch_
Definition: DCCSCBlock.h:41
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
EcalElectronicsMapper::getActiveSM
unsigned int getActiveSM()
Definition: EcalElectronicsMapper.h:128
NUMB_SM_EE_PLU_MAX
Definition: DCCRawDataDefinitions.h:59
DCCSCBlock::invalidChIds_
std::unique_ptr< EEDetIdCollection > * invalidChIds_
Definition: DCCSCBlock.h:42
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
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
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
EcalElectronicsMapper::getDetIdPointer
DetId * getDetIdPointer(unsigned int feChannel, unsigned int strip, unsigned int xtal)
Definition: EcalElectronicsMapper.h:86
DCCDataUnpacker::invalidEEChIdsCollection
std::unique_ptr< EEDetIdCollection > * invalidEEChIdsCollection()
Definition: DCCDataUnpacker.h:143
NUMB_SM_EE_PLU_MIN
Definition: DCCRawDataDefinitions.h:58
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
DCCDataBlockPrototype::unpacker_
DCCDataUnpacker * unpacker_
Definition: DCCDataBlockPrototype.h:67
DCCDataUnpacker::invalidEEGainsSwitchCollection
std::unique_ptr< EEDetIdCollection > * invalidEEGainsSwitchCollection()
Definition: DCCDataUnpacker.h:141
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
DCCDataUnpacker::invalidEEGainsCollection
std::unique_ptr< EEDetIdCollection > * invalidEEGainsCollection()
Definition: DCCDataUnpacker.h:139
EEDetId
Definition: EEDetId.h:14
EcalElectronicsMapper::isGhost
bool isGhost(const int FED, const int CCU, const int VFE)
Definition: EcalElectronicsMapper.cc:688
DCCDataBlockPrototype::event_
DCCEventBlock * event_
Definition: DCCDataBlockPrototype.h:70
NUMB_XTAL
Definition: DCCRawDataDefinitions.h:45
DCCFEBlock::lastXtalId_
unsigned int lastXtalId_
Definition: DCCFEBlock.h:51
DCCSCBlock::invalidGains_
std::unique_ptr< EEDetIdCollection > * invalidGains_
Definition: DCCSCBlock.h:40
DCCEventBlock::l1A
unsigned int l1A()
Definition: DCCEventBlock.h:57
DCCSCBlock::digis_
std::unique_ptr< EEDigiCollection > * digis_
Definition: DCCSCBlock.h:37
NUMB_SM_EE_MIN_MIN
Definition: DCCRawDataDefinitions.h:52
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
NUMB_SM_EE_MIN_MAX
Definition: DCCRawDataDefinitions.h:53
DCCDataBlockPrototype::mapper_
EcalElectronicsMapper * mapper_
Definition: DCCDataBlockPrototype.h:69
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:640
DCCFEBlock::numbDWInXtalBlock_
unsigned int numbDWInXtalBlock_
Definition: DCCFEBlock.h:54
DCCSCBlock::fillEcalElectronicsError
void fillEcalElectronicsError(std::unique_ptr< EcalElectronicsIdCollection > *) override
Definition: DCCSCBlock.cc:269
DCCDataUnpacker::getChannelValue
uint16_t getChannelValue(const DetId &id) const
Definition: DCCDataUnpacker.cc:76
TOWER_STRIPID_MASK
Definition: DCCRawDataDefinitions.h:163
DCCSCBlock::pDetId_
EEDetId * pDetId_
Definition: DCCSCBlock.h:34
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
EEDataFrame
Definition: EEDataFrame.h:12
DCCFEBlock::lastStripId_
unsigned int lastStripId_
Definition: DCCFEBlock.h:50
BLOCK_UNPACKED
Definition: DCCRawDataDefinitions.h:6
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37