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

Definition at line 10 of file DCCTowerBlock.cc.

11 : 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 DCCTowerBlock::fillEcalElectronicsError ( std::unique_ptr< EcalElectronicsIdCollection > *  errorColection)
overrideprotectedvirtual

Reimplemented from DCCFEBlock.

Definition at line 256 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().

256  {
257 
258  const int activeDCC = mapper_->getActiveSM();
259 
260  if(NUMB_SM_EB_MIN_MIN<=activeDCC && activeDCC<=NUMB_SM_EB_PLU_MAX){
262  (*errorColection)->push_back(*eleTp);
263  }else{
265  edm::LogWarning("IncorrectBlock")
266  <<"For event "<<event_->l1A()<<" there's fed: "<< activeDCC
267  <<" activeDcc: "<<mapper_->getActiveSM()
268  <<" but that activeDcc is not valid in EB.";
269  }
270 
271  }
272 
273 }
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 [...
static std::atomic< bool > silentMode_
EcalElectronicsMapper * mapper_
EcalElectronicsId * getTTEleIdPointer(unsigned int tccId, unsigned int tower)
unsigned int l1A()
Definition: DCCEventBlock.h:54
int DCCTowerBlock::unpackXtalData ( unsigned int  stripID,
unsigned int  xtalID 
)
overrideprotectedvirtual

Reimplemented from DCCFEBlock.

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

Reimplemented from DCCFEBlock.

Definition at line 14 of file DCCTowerBlock.cc.

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

14  {
15 
17 
18  // needs to be update for eb/ee
20 
24 
25 }
std::unique_ptr< EBDetIdCollection > * invalidGainsCollection()
std::unique_ptr< EBDetIdCollection > * invalidGainsSwitch_
Definition: DCCTowerBlock.h:43
std::unique_ptr< EBDetIdCollection > * invalidChIds_
Definition: DCCTowerBlock.h:44
void updateCollectors() override
Definition: DCCFEBlock.cc:20
std::unique_ptr< EBDetIdCollection > * invalidGainsSwitchCollection()
std::unique_ptr< EBDetIdCollection > * invalidChIdsCollection()
DCCDataUnpacker * unpacker_
std::unique_ptr< EBDetIdCollection > * invalidGains_
Definition: DCCTowerBlock.h:42
std::unique_ptr< EBDigiCollection > * digis_
Definition: DCCTowerBlock.h:37
std::unique_ptr< EBDigiCollection > * ebDigisCollection()

Member Data Documentation

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

Definition at line 37 of file DCCTowerBlock.h.

Referenced by updateCollectors().

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

Definition at line 44 of file DCCTowerBlock.h.

Referenced by updateCollectors().

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

Definition at line 42 of file DCCTowerBlock.h.

Referenced by updateCollectors().

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

Definition at line 43 of file DCCTowerBlock.h.

Referenced by updateCollectors().

EBDetId* DCCTowerBlock::pDetId_
protected

Definition at line 39 of file DCCTowerBlock.h.

Referenced by unpackXtalData().