CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from DCCFEBlock
 DCCFEBlock (DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack, bool forceToKeepFRdata)
 
void display (std::ostream &o)
 
void enableFeIdChecks ()
 
unsigned int getLength ()
 
int unpack (const uint64_t **data, unsigned int *dwToEnd, bool zs, unsigned int expectedTowerID)
 
void zsFlag (bool zs)
 
virtual ~DCCFEBlock ()
 
- 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::auto_ptr< EcalElectronicsIdCollection > *)
 
int unpackXtalData (unsigned int stripID, unsigned int xtalID)
 

Protected Attributes

std::auto_ptr< EBDigiCollection > * digis_
 
std::auto_ptr
< EBDetIdCollection > * 
invalidChIds_
 
std::auto_ptr
< EBDetIdCollection > * 
invalidGains_
 
std::auto_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::auto_ptr
< EcalElectronicsIdCollection > * 
invalidBlockLengths_
 
std::auto_ptr
< EcalElectronicsIdCollection > * 
invalidTTIds_
 
std::auto_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::auto_ptr< EcalElectronicsIdCollection > *  errorColection)
protectedvirtual

Reimplemented from DCCFEBlock.

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

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

Reimplemented from DCCFEBlock.

Definition at line 29 of file DCCTowerBlock.cc.

References BLOCK_UNPACKED, DCCEventBlock::bx(), data, DCCDataBlockPrototype::data_, DCCDataBlockPrototype::event_, fillEcalElectronicsError(), EcalElectronicsMapper::getActiveDCC(), DCCDataUnpacker::getChannelValue(), EcalElectronicsMapper::getDetIdPointer(), 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  stripId = expStripID;
52  xtalId = expXtalID;
53  errorOnXtal= true;
54 
55  // return here, so to skip all following checks
56  lastXtalId_++;
59  return BLOCK_UNPACKED;
60  }
61 
62 
63  // check id in case of 0suppressed data
64 
65  else if(zs_){
66 
67  // Check for valid Ids 1) values out of range
68 
69  if(stripId == 0 || stripId > 5 || xtalId == 0 || xtalId > 5){
71  edm::LogWarning("IncorrectBlock")
72  <<"For event L1A: "<<event_->l1A()<<", fed "<<mapper_->getActiveDCC()<<" and tower "<<towerId_
73  <<"\n Invalid strip : "<<stripId<<" or xtal : "<<xtalId
74  <<" ids ( last strip was: " << lastStripId_ << " last ch was: " << lastXtalId_ << ")";
75  }
76 
77  int st = lastStripId_;
78  int ch = lastXtalId_;
79  ch++;
80  if (ch > NUMB_XTAL) {ch=1; st++;}
81  if (st > NUMB_STRIP) {ch=1; st=1;}
82 
83  // adding channel following the last valid
84  //pDetId_ = (EBDetId*) mapper_->getDetIdPointer(towerId_,st,ch);
85  //(*invalidChIds_)->push_back(*pDetId_);
87 
88  errorOnXtal = true;
89 
90  lastStripId_ = st;
91  lastXtalId_ = ch;
92 
93  // return here, so to skip all following checks
94  return SKIP_BLOCK_UNPACKING;
95 
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  errorOnXtal = true;
124  lastStripId_ = st;
125  lastXtalId_ = ch;
126 
127  // return here, so to skip all following checks
128  return SKIP_BLOCK_UNPACKING;
129 
130  }
131 
132  // if channel id not proven wrong, update lastStripId_ and lastXtalId_
133  lastStripId_ = stripId;
134  lastXtalId_ = xtalId;
135  }//end else
136  }// end if (zs_)
137 
138 
139  bool addedFrame=false;
140 
141  // if there is an error on xtal id ignore next error checks
142  // otherwise, assume channel_id is valid and proceed with making and checking the data frame
143  if(errorOnXtal) return SKIP_BLOCK_UNPACKING;
144 
145  pDetId_ = (EBDetId*) mapper_->getDetIdPointer(towerId_,stripId,xtalId);
146  (*digis_)->push_back(*pDetId_);
147  EBDataFrame df( (*digis_)->back() );
148  addedFrame=true;
149  bool wrongGain(false);
150 
151  //set samples in the data frame
152  for(unsigned int i =0; i< nTSamples_ ;i++){ // loop on samples
153  xData_++;
154  unsigned int data = (*xData_) & TOWER_DIGI_MASK;
155  unsigned int gain = data>>12;
156  xtalGains_[i]=gain;
157  if(gain == 0){
158  wrongGain = true;
159  // although gain==0 found, produce the dataFrame in order to have it, for saturation case
160  }
161  df.setSample(i,data);
162  }// loop on samples
163 
164  bool isSaturation(true);
165  if(wrongGain){
166 
167  // check whether the gain==0 has features of saturation or not
168  // gain==0 occurs either in case of data corruption or of ADC saturation
169  // \->reject digi \-> keep digi
170 
171  // determine where gainId==0 starts
172  short firstGainZeroSampID(-1); short firstGainZeroSampADC(-1);
173  for (unsigned int s=0; s<nTSamples_; s++ ) {
174  if(df.sample(s).gainId()==0 && firstGainZeroSampID==-1)
175  {
176  firstGainZeroSampID = s;
177  firstGainZeroSampADC = df.sample(s).adc();
178  break;
179  }
180  }
181 
182  // check whether gain==0 and adc() stays constant for (at least) 5 consecutive samples
183  unsigned int plateauEnd = std::min(nTSamples_,(unsigned int)(firstGainZeroSampID+5));
184  for (unsigned int s=firstGainZeroSampID; s<plateauEnd; s++)
185  {
186  if( df.sample(s).gainId()==0 && df.sample(s).adc()==firstGainZeroSampADC ) {;}
187  else
188  { isSaturation=false; break;} //it's not saturation
189  }
190  // get rid of channels which are stuck in gain0
191  if(firstGainZeroSampID<3) {isSaturation=false; }
192 
194  if (unpacker_->getChannelValue(mapper_->getActiveDCC(), towerId_, stripId, xtalId) != 10) {
195  edm::LogWarning("IncorrectBlock")
196  << "Gain zero" << (isSaturation ? " with features of saturation" : "" ) << " was found in Tower Block"
197  << " (L1A " << event_->l1A() << " bx " << event_->bx() << " fed " << mapper_->getActiveDCC()
198  << " tower " << towerId_ << " strip " << stripId << " xtal " << xtalId << ")";
199  }
200  }
201 
202  if (! isSaturation)
203  {
204  (*invalidGains_)->push_back(*pDetId_);
205  (*digis_)->pop_back();
206  errorOnXtal = true;
207 
208  //Point to begin of next xtal Block
210  //return here, so to skip all the rest
211  //make special collection for gain0 data frames when due to saturation
212  return BLOCK_UNPACKED;
213  }//end isSaturation
214  else {
216  return BLOCK_UNPACKED;
217  }
218 
219  }//end WrongGain
220 
221 
222  // from here on, care about gain switches
223 
224  short firstGainWrong=-1;
225  short numGainWrong=0;
226 
227  for (unsigned int i=1; i<nTSamples_; i++ ) {
228  if (i>0 && xtalGains_[i-1]>xtalGains_[i]) {
229  numGainWrong++;
230  if (firstGainWrong == -1) { firstGainWrong=i;}
231  }
232  }
233 
234 
235  if (numGainWrong > 0) {
237  edm::LogWarning("IncorrectBlock")
238  << "A wrong gain transition switch was found for Tower Block in strip " << stripId << " and xtal " << xtalId
239  << " (L1A " << event_->l1A() << " bx " << event_->bx() << " fed " << mapper_->getActiveDCC() << " tower " << towerId_ << ")";
240  }
241 
242  (*invalidGainsSwitch_)->push_back(*pDetId_);
243  errorOnXtal = true;
244  }
245 
246  //Add frame to collection only if all data format and gain rules are respected
247  if (errorOnXtal && addedFrame) {
248  (*digis_)->pop_back();
249  }
250 
251  //Point to begin of next xtal Block
253 
254  return BLOCK_UNPACKED;
255 }
int i
Definition: DBlmapReader.cc:9
unsigned int towerId_
Definition: DCCFEBlock.h:57
bool zs_
Definition: DCCFEBlock.h:45
#define min(a, b)
Definition: mlp_lapack.h:161
DetId * getDetIdPointer(unsigned int feChannel, unsigned int strip, unsigned int xtal)
static bool silentMode_
unsigned int nTSamples_
Definition: DCCFEBlock.h:60
unsigned int lastXtalId_
Definition: DCCFEBlock.h:55
uint16_t getChannelValue(const DetId &id) const
unsigned int bx()
Definition: DCCEventBlock.h:57
std::auto_ptr< EcalElectronicsIdCollection > * invalidZSXtalIds_
Definition: DCCFEBlock.h:68
EBDetId * pDetId_
Definition: DCCTowerBlock.h:39
void fillEcalElectronicsError(std::auto_ptr< EcalElectronicsIdCollection > *)
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_
short * xtalGains_
Definition: DCCFEBlock.h:66
unsigned int l1A()
Definition: DCCEventBlock.h:56
void DCCTowerBlock::updateCollectors ( )
virtual

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::auto_ptr< EBDetIdCollection > * invalidGainsSwitchCollection()
std::auto_ptr< EBDetIdCollection > * invalidGainsSwitch_
Definition: DCCTowerBlock.h:43
std::auto_ptr< EBDigiCollection > * digis_
Definition: DCCTowerBlock.h:37
std::auto_ptr< EBDetIdCollection > * invalidChIdsCollection()
std::auto_ptr< EBDetIdCollection > * invalidGainsCollection()
virtual void updateCollectors()
Definition: DCCFEBlock.cc:20
DCCDataUnpacker * unpacker_
std::auto_ptr< EBDigiCollection > * ebDigisCollection()
std::auto_ptr< EBDetIdCollection > * invalidChIds_
Definition: DCCTowerBlock.h:44
std::auto_ptr< EBDetIdCollection > * invalidGains_
Definition: DCCTowerBlock.h:42

Member Data Documentation

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

Definition at line 37 of file DCCTowerBlock.h.

Referenced by updateCollectors().

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

Definition at line 44 of file DCCTowerBlock.h.

Referenced by updateCollectors().

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

Definition at line 42 of file DCCTowerBlock.h.

Referenced by updateCollectors().

std::auto_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().