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
 
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 ( DCCDataUnpacker u,
EcalElectronicsMapper m,
DCCEventBlock e,
bool  unpack,
bool  forceToKeepFRdata 
)

Definition at line 9 of file DCCSCBlock.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:29
DCCFEBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack, bool forceToKeepFRdata)
Definition: DCCFEBlock.cc:9

Member Function Documentation

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

Reimplemented from DCCFEBlock.

Definition at line 270 of file DCCSCBlock.cc.

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

270  {
271 
272  const int activeDCC = mapper_->getActiveSM();
273 
274  if ( (NUMB_SM_EE_MIN_MIN <=activeDCC && activeDCC<=NUMB_SM_EE_MIN_MAX) ||
275  (NUMB_SM_EE_PLU_MIN <=activeDCC && activeDCC<=NUMB_SM_EE_PLU_MAX) ){
277  (*errorColection)->push_back(*eleTp);
278  }else{
280  edm::LogWarning("IncorrectBlock")
281  <<"For event "<<event_->l1A()<<" there's fed: "<< activeDCC
282  <<" activeDcc: "<<mapper_->getActiveSM()
283  <<" but that activeDcc is not valid in EE.";
284  }
285  }
286 
287 }
unsigned int expTowerID_
Definition: DCCFEBlock.h:50
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
EcalElectronicsId * getSCElectronicsPointer(unsigned int smId, unsigned int feChannel)
static std::atomic< bool > silentMode_
EcalElectronicsMapper * mapper_
unsigned int l1A()
Definition: DCCEventBlock.h:54
int DCCSCBlock::unpackXtalData ( unsigned int  stripID,
unsigned int  xtalID 
)
overrideprotectedvirtual

Reimplemented from DCCFEBlock.

Definition at line 29 of file DCCSCBlock.cc.

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

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

Reimplemented from DCCFEBlock.

Definition at line 13 of file DCCSCBlock.cc.

References digis_, DCCDataUnpacker::eeDigisCollection(), invalidChIds_, DCCDataUnpacker::invalidEEChIdsCollection(), DCCDataUnpacker::invalidEEGainsCollection(), DCCDataUnpacker::invalidEEGainsSwitchCollection(), invalidGains_, invalidGainsSwitch_, DCCDataBlockPrototype::unpacker_, and DCCFEBlock::updateCollectors().

13  {
14 
16 
17  // needs to be update for eb/ee
19 
23 
24 }
std::unique_ptr< EEDigiCollection > * eeDigisCollection()
std::unique_ptr< EEDetIdCollection > * invalidEEChIdsCollection()
std::unique_ptr< EEDetIdCollection > * invalidGainsSwitch_
Definition: DCCSCBlock.h:45
std::unique_ptr< EEDetIdCollection > * invalidEEGainsSwitchCollection()
void updateCollectors() override
Definition: DCCFEBlock.cc:20
std::unique_ptr< EEDetIdCollection > * invalidEEGainsCollection()
std::unique_ptr< EEDetIdCollection > * invalidChIds_
Definition: DCCSCBlock.h:46
std::unique_ptr< EEDetIdCollection > * invalidGains_
Definition: DCCSCBlock.h:44
DCCDataUnpacker * unpacker_
std::unique_ptr< EEDigiCollection > * digis_
Definition: DCCSCBlock.h:41

Member Data Documentation

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

Definition at line 41 of file DCCSCBlock.h.

Referenced by updateCollectors().

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

Definition at line 46 of file DCCSCBlock.h.

Referenced by updateCollectors().

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

Definition at line 44 of file DCCSCBlock.h.

Referenced by updateCollectors().

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

Definition at line 45 of file DCCSCBlock.h.

Referenced by updateCollectors().

EEDetId* DCCSCBlock::pDetId_
protected

Definition at line 38 of file DCCSCBlock.h.

Referenced by unpackXtalData().

EEDataFrame* DCCSCBlock::pDFId_
protected

Definition at line 39 of file DCCSCBlock.h.