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
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 ()
 
- 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< EEDigiCollection > * digis_
 
std::auto_ptr
< EEDetIdCollection > * 
invalidChIds_
 
std::auto_ptr
< EEDetIdCollection > * 
invalidGains_
 
std::auto_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::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 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::auto_ptr< EcalElectronicsIdCollection > *  errorColection)
protectedvirtual

Reimplemented from DCCFEBlock.

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

276  {
277 
278  const int activeDCC = mapper_->getActiveSM();
279 
280  if ( (NUMB_SM_EE_MIN_MIN <=activeDCC && activeDCC<=NUMB_SM_EE_MIN_MAX) ||
281  (NUMB_SM_EE_PLU_MIN <=activeDCC && activeDCC<=NUMB_SM_EE_PLU_MAX) ){
283  (*errorColection)->push_back(*eleTp);
284  }else{
286  edm::LogWarning("IncorrectBlock")
287  <<"For event "<<event_->l1A()<<" there's fed: "<< activeDCC
288  <<" activeDcc: "<<mapper_->getActiveSM()
289  <<" but that activeDcc is not valid in EE.";
290  }
291  }
292 
293 }
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 bool silentMode_
EcalElectronicsMapper * mapper_
unsigned int l1A()
Definition: DCCEventBlock.h:56
int DCCSCBlock::unpackXtalData ( unsigned int  stripID,
unsigned int  xtalID 
)
protectedvirtual

Reimplemented from DCCFEBlock.

Definition at line 29 of file DCCSCBlock.cc.

References BLOCK_UNPACKED, DCCEventBlock::bx(), data, DCCDataBlockPrototype::data_, DCCDataBlockPrototype::event_, fillEcalElectronicsError(), EcalElectronicsMapper::getActiveDCC(), DCCDataUnpacker::getChannelValue(), EcalElectronicsMapper::getDetIdPointer(), 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  stripId = expStripID;
59  xtalId = expXtalID;
60  errorOnXtal = true;
61 
62  // return here, so to skip all following checks
64  return BLOCK_UNPACKED;
65  }
66 
67 
68  // check id in case of 0suppressed data
69 
70  else if(zs_) {
71 
72  // Check for valid Ids 1) values out of range
73 
74  if (stripId == 0 || stripId > 5 || xtalId == 0 || xtalId > 5) {
75 
77  edm::LogWarning("IncorrectBlock")
78  <<"For event LV1: "<<event_->l1A()<<", fed "<<mapper_->getActiveDCC()<<" and tower "<<towerId_
79  <<"\n Invalid strip : "<<stripId<<" or xtal : "<<xtalId
80  <<" ids ( last strip was: " << lastStripId_ << " last ch was: " << lastXtalId_ << ")";
81  }
82 
83  int st = lastStripId_;
84  int ch = lastXtalId_;
85  ch++;
86  if (ch > NUMB_XTAL) {ch=1; st++;}
87  if (st > NUMB_STRIP) {ch=1; st=1;}
88 
89  // adding channel following the last valid
90  //pDetId_ = (EEDetId*) mapper_->getDetIdPointer(towerId_,st,ch);
91  //(*invalidChIds_)->push_back(*pDetId_);
93  errorOnXtal = true;
94 
95  lastStripId_ = st;
96  lastXtalId_ = ch;
97 
98  // return here, so to skip all following checks
99  return SKIP_BLOCK_UNPACKING;
100  }
101  else {
102  // Check for zs valid Ids 2) if channel-in-strip has increased wrt previous xtal
103  // 3) if strip has increased wrt previous xtal
104  if ((stripId == lastStripId_ && xtalId <= lastXtalId_ ) ||
105  (stripId < lastStripId_))
106  {
108  edm::LogWarning("IncorrectBlock")
109  << "Xtal id was expected to increase but it didn't - last xtal id was " << lastXtalId_ << " while current xtal is " << xtalId
110  << " (LV1 " << event_->l1A() << " fed " << mapper_->getActiveDCC() << " tower " << towerId_ << ")";
111  }
112 
113  int st = lastStripId_;
114  int ch = lastXtalId_;
115  ch++;
116  if (ch > NUMB_XTAL) {ch=1; st++;}
117  if (st > NUMB_STRIP) {ch=1; st=1;}
118 
119  // adding channel following the last valid
120  //pDetId_ = (EEDetId*) mapper_->getDetIdPointer(towerId_,stripId,xtalId);
121  //(*invalidChIds_)->push_back(*pDetId_);
123 
124  errorOnXtal = true;
125  lastStripId_ = st;
126  lastXtalId_ = ch;
127 
128  // return here, so to skip all following checks
129  return SKIP_BLOCK_UNPACKING;
130 
131  }
132 
133  lastStripId_ = stripId;
134  lastXtalId_ = xtalId;
135  }// end else
136  }// end if(zs_)
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_ = (EEDetId*) mapper_->getDetIdPointer(towerId_, stripId, xtalId);
145 
146  if(pDetId_){// checking that requested EEDetId exists
147 
148  (*digis_)->push_back(*pDetId_);
149  EEDataFrame df( (*digis_)->back() );
150  addedFrame=true;
151  bool wrongGain(false);
152 
153  //set samples in the frame
154  for(unsigned int i =0; i< nTSamples_ ;i++){
155  xData_++;
156  unsigned int data = (*xData_) & TOWER_DIGI_MASK;
157  unsigned int gain = data>>12;
158  xtalGains_[i]=gain;
159  if(gain == 0){ wrongGain = true; } // although gain==0 found, produce the dataFrame in order to have it, for saturation case
160  df.setSample(i,data);
161  }
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("IncorrectBlock")
195  << "Gain zero" << (isSaturation ? " with features of saturation" : "" ) << " was found in SC 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  errorOnXtal = true;
206 
207  //return here, so to skip all the rest
208  //make special collection for gain0 data frames (saturation)
209  //Point to begin of next xtal Block
211 
212  return BLOCK_UNPACKED;
213 
214  }//end isSaturation
215  else {
217  return BLOCK_UNPACKED;
218  }
219  }//end WrongGain
220 
221  short firstGainWrong=-1;
222  short numGainWrong=0;
223 
224  for (unsigned int i=1; i<nTSamples_; i++ ) {
225  if (xtalGains_[i-1]>xtalGains_[i]) {
226  numGainWrong++;
227 
228  if (firstGainWrong == -1) { firstGainWrong=i;}
229  }
230  }
231 
232  if (numGainWrong > 0) {
234  edm::LogWarning("IncorrectBlock")
235  << "A wrong gain transition switch was found for SC 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 
241  errorOnXtal = true;
242  }
243 
244  //Add frame to collection only if all data format and gain rules are respected
245  if (errorOnXtal && addedFrame) {
246  (*digis_)->pop_back();
247  }
248 
249  }// End 'if EE id exist'
250 
251  else {
252  // in case EEDetId do not exist
253  // In EE we may have crystals with no valid EEDetId
254  if (! mapper_->isGhost(mapper_->getActiveDCC(), towerId_, stripId)) { // check the VFE is not a 'ghost'
255 
256  // this is real EE VFE - print warning
258  edm::LogWarning("IncorrectBlock")
259  << "An EEDetId was requested that does not exist "
260  << "(LV1 " << event_->l1A()
261  << " fed " << mapper_->getActiveDCC()
262  << " tower " << towerId_
263  << " strip " << stripId
264  << " xtal " << xtalId << ")";
265  }
266  }
267  }
268 
269  //Point to begin of next xtal Block
271 
272  return BLOCK_UNPACKED;
273 }
int i
Definition: DBlmapReader.cc:9
unsigned int towerId_
Definition: DCCFEBlock.h:57
bool zs_
Definition: DCCFEBlock.h:45
void fillEcalElectronicsError(std::auto_ptr< EcalElectronicsIdCollection > *)
Definition: DCCSCBlock.cc:276
#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
EEDetId * pDetId_
Definition: DCCSCBlock.h:38
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_
short * xtalGains_
Definition: DCCFEBlock.h:66
unsigned int l1A()
Definition: DCCEventBlock.h:56
void DCCSCBlock::updateCollectors ( )
virtual

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::auto_ptr< EEDetIdCollection > * invalidEEChIdsCollection()
std::auto_ptr< EEDetIdCollection > * invalidGainsSwitch_
Definition: DCCSCBlock.h:45
std::auto_ptr< EEDetIdCollection > * invalidEEGainsCollection()
virtual void updateCollectors()
Definition: DCCFEBlock.cc:20
std::auto_ptr< EEDetIdCollection > * invalidGains_
Definition: DCCSCBlock.h:44
std::auto_ptr< EEDigiCollection > * digis_
Definition: DCCSCBlock.h:41
DCCDataUnpacker * unpacker_
std::auto_ptr< EEDigiCollection > * eeDigisCollection()
std::auto_ptr< EEDetIdCollection > * invalidEEGainsSwitchCollection()
std::auto_ptr< EEDetIdCollection > * invalidChIds_
Definition: DCCSCBlock.h:46

Member Data Documentation

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

Definition at line 41 of file DCCSCBlock.h.

Referenced by updateCollectors().

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

Definition at line 46 of file DCCSCBlock.h.

Referenced by updateCollectors().

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

Definition at line 44 of file DCCSCBlock.h.

Referenced by updateCollectors().

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