CMS 3D CMS Logo

DCCFEBlock Class Reference

#include <EventFilter/EcalRawToDigiDev/interface/DCCFEBlock.h>

Inheritance diagram for DCCFEBlock:

DCCDataBlockPrototype DCCSCBlock DCCTowerBlock

List of all members.

Public Member Functions

 DCCFEBlock (DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack)
void display (std::ostream &o)
void enableFeIdChecks ()
uint getLength ()
int unpack (uint64_t **data, uint *dwToEnd, bool zs, uint expectedTowerID)
virtual void updateCollectors ()
void zsFlag (bool zs)
virtual ~DCCFEBlock ()

Protected Member Functions

virtual void fillEcalElectronicsError (std::auto_ptr< EcalElectronicsIdCollection > *)
virtual int unpackXtalData (uint stripID, uint xtalID)

Protected Attributes

uint blockSize_
uint bx_
bool checkFeId_
uint expTowerID_
uint expXtalTSamples_
std::auto_ptr
< EcalElectronicsIdCollection > * 
invalidBlockLengths_
std::auto_ptr
< EcalElectronicsIdCollection > * 
invalidTTIds_
uint l1_
uint lastStripId_
uint lastXtalId_
uint nTSamples_
uint numbDWInXtalBlock_
uint towerId_
uint unfilteredDataBlockLength_
uint xtalBlockSize_
short * xtalGains_
bool zs_


Detailed Description

Definition at line 22 of file DCCFEBlock.h.


Constructor & Destructor Documentation

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

Definition at line 9 of file DCCFEBlock.cc.

References expXtalTSamples_, EcalElectronicsMapper::getUnfilteredTowerBlockLength(), DCCDataBlockPrototype::mapper_, numbDWInXtalBlock_, EcalElectronicsMapper::numbXtalTSamples(), unfilteredDataBlockLength_, and xtalGains_.

virtual DCCFEBlock::~DCCFEBlock (  )  [inline, virtual]

Definition at line 28 of file DCCFEBlock.h.

References xtalGains_.

00028 { delete [] xtalGains_;}


Member Function Documentation

void DCCFEBlock::display ( std::ostream &  o  )  [virtual]

Reimplemented from DCCDataBlockPrototype.

Definition at line 228 of file DCCFEBlock.cc.

References DCCDataBlockPrototype::blockLength_, bx_, l1_, nTSamples_, and towerId_.

00228                                      {
00229 
00230   o<<"\n Unpacked Info for DCC Tower Block"
00231   <<"\n DW1 ============================="
00232   <<"\n Tower Id "<<towerId_
00233   <<"\n Numb Samp "<<nTSamples_
00234   <<"\n Bx "<<bx_
00235   <<"\n L1 "<<l1_
00236   <<"\n blockLength "<<blockLength_;  
00237 } 

void DCCFEBlock::enableFeIdChecks (  )  [inline]

Definition at line 32 of file DCCFEBlock.h.

References checkFeId_.

Referenced by DCCEventBlock::enableFeIdChecks().

00032 {checkFeId_= true;}

virtual void DCCFEBlock::fillEcalElectronicsError ( std::auto_ptr< EcalElectronicsIdCollection > *   )  [inline, protected, virtual]

Reimplemented in DCCSCBlock, and DCCTowerBlock.

Definition at line 45 of file DCCFEBlock.h.

Referenced by unpack().

00045 {};

uint DCCFEBlock::getLength (  )  [inline]

Reimplemented from DCCDataBlockPrototype.

Definition at line 40 of file DCCFEBlock.h.

References DCCDataBlockPrototype::blockLength_.

00040 {return blockLength_; }

int DCCFEBlock::unpack ( uint64_t **  data,
uint *  dwToEnd,
bool  zs,
uint  expectedTowerID 
)

Definition at line 29 of file DCCFEBlock.cc.

References BLOCK_UNPACKED, DCCDataBlockPrototype::blockLength_, blockSize_, DCCEventBlock::bx(), bx_, checkFeId_, DCCDataBlockPrototype::data_, DCCDataBlockPrototype::datap_, DCCDataBlockPrototype::dwToEnd_, DCCDataBlockPrototype::event_, expTowerID_, expXtalTSamples_, fillEcalElectronicsError(), EcalElectronicsMapper::getActiveDCC(), EcalElectronicsMapper::getActiveSM(), EcalElectronicsMapper::getNumChannelsInDcc(), invalidBlockLengths_, invalidTTIds_, l1_, DCCEventBlock::l1A(), lastStripId_, lastXtalId_, DCCDataBlockPrototype::mapper_, nTSamples_, numbDWInXtalBlock_, DCCDataUnpacker::silentMode_, SKIP_BLOCK_UNPACKING, STOP_EVENT_UNPACKING, DCCDataBlockPrototype::sync_, TCC_BX_MASK, TCC_L1_MASK, TOWER_BX_B, TOWER_BX_MASK, TOWER_ID_MASK, TOWER_L1_B, TOWER_L1_MASK, TOWER_LENGTH_B, TOWER_LENGTH_MASK, TOWER_NSAMP_B, TOWER_NSAMP_MASK, towerId_, unfilteredDataBlockLength_, unpackXtalData(), DCCDataBlockPrototype::updateEventPointers(), xtalBlockSize_, and zs_.

Referenced by DCCEventBlock::unpack().

00029                                                                                      {
00030   
00031   zs_      = zs;  
00032   datap_   = data;
00033   data_    = *data;
00034   dwToEnd_ = dwToEnd;
00035   
00036  
00037   if( (*dwToEnd_)<1){
00038     if( ! DCCDataUnpacker::silentMode_ ){
00039       edm::LogWarning("EcalRawToDigiDevTowerSize")
00040         <<"\n Unable to unpack Tower block for event "<<event_->l1A()<<" in fed "<<mapper_->getActiveDCC()
00041         <<"\n The end of event was reached "
00042         <<"\n(or, previously, pointers intended to navigate outside of FedBlock (based on block sizes), and were stopped by setting dwToEnd_ to zero)"    ;
00043       //TODO : add this to a dcc event size collection error?
00044     }
00045     return STOP_EVENT_UNPACKING;
00046   }
00047   
00048   lastStripId_     = 0;
00049   lastXtalId_      = 0;
00050   expTowerID_      = expectedTowerID;
00051   
00052   
00053   //Point to begin of block
00054   data_++;
00055   
00056   towerId_           = ( *data_ )                   & TOWER_ID_MASK;
00057   nTSamples_         = ( *data_>>TOWER_NSAMP_B  )   & TOWER_NSAMP_MASK; 
00058   bx_                = ( *data_>>TOWER_BX_B     )   & TOWER_BX_MASK;
00059   l1_                = ( *data_>>TOWER_L1_B     )   & TOWER_L1_MASK;
00060   blockLength_       = ( *data_>>TOWER_LENGTH_B )   & TOWER_LENGTH_MASK;
00061 
00062   //debugging
00063   //display(cout);
00064 
00065 
00066   uint activeDCC = mapper_->getActiveSM();
00067   
00069   // check that expected fe_id==fe_expected is on
00070   if( checkFeId_              &&
00071       expTowerID_ != towerId_ &&
00072       expTowerID_ <= mapper_->getNumChannelsInDcc(activeDCC) ){ // fe_id must be within range foreseen in the FED 
00073     if( ! DCCDataUnpacker::silentMode_ ){
00074       edm::LogWarning("EcalRawToDigiDevTowerId")
00075         <<"\n For event "<<event_->l1A()<<" and fed "<<mapper_->getActiveDCC()
00076         <<"\n Expected FE_id is "<<expTowerID_<<" while "<<towerId_<<" was found "
00077         <<"\n => Skipping to next FE block...";
00078      } 
00079 
00080      fillEcalElectronicsError(invalidTTIds_); 
00081     
00082     updateEventPointers();
00083     return SKIP_BLOCK_UNPACKING;
00084   }
00085 
00087   // check that expected fe_id==fe_expected is off
00088   // still, check the range (to avoid non-valid detId's)
00089   else if( (!checkFeId_) && 
00090            towerId_ > mapper_->getNumChannelsInDcc(activeDCC) ){ // fe_id must still be within range foreseen in the FED 
00091     if( ! DCCDataUnpacker::silentMode_ ){
00092       edm::LogWarning("EcalRawToDigiDevTowerId")
00093         <<"\n For event "<<event_->l1A()<<" and fed "<<mapper_->getActiveDCC()<<" (there's no check fe_id==dcc_channel)"
00094         <<"\n the FE_id found: "<<towerId_<<" exceeds max number of FE foreseen in fed"
00095         <<"\n => Skipping to next FE block...";
00096     }
00097     
00098     updateEventPointers();
00099     return SKIP_BLOCK_UNPACKING;
00100   }
00101   
00102   
00103   
00104   // Check synchronization
00105   if(sync_){
00106 
00107     uint dccBx = (event_->bx())&TCC_BX_MASK;
00108     uint dccL1 = (event_->l1A())&TCC_L1_MASK; 
00109     // accounting for counters starting from 0 in ECAL FE, while from 1 in CSM
00110     if( dccBx != bx_ || dccL1 != (l1_+1) ){
00111       if( ! DCCDataUnpacker::silentMode_ ){
00112         edm::LogWarning("EcalRawToDigiDevNumTowerBlocks")
00113           <<"\n Synchronization error for Tower Block "<<towerId_<<" in event "<<event_->l1A()
00114           <<" with bx "<<event_->bx()<<" in fed "<<mapper_->getActiveDCC()
00115           <<"\n TCC local l1A is  "<<l1_<<" and local bx is "<<bx_
00116           <<"\n => Skipping to next tower block...";
00117        }
00118       //Note : add to error collection ?                 
00119       updateEventPointers();
00120       return SKIP_BLOCK_UNPACKING;
00121     }
00122   }
00123 
00124 
00125 
00126   // check number of samples
00127   if( nTSamples_ != expXtalTSamples_ ){
00128     if( ! DCCDataUnpacker::silentMode_ ){
00129       edm::LogWarning("EcalRawToDigiDevNumTowerBlocks")
00130         <<"EcalRawToDigi@SUB=DCCFEBlock::unpack"
00131         <<"\n Unable to unpack Tower Block "<<towerId_<<" for event L1A "<<event_->l1A()<<" in fed "<<mapper_->getActiveDCC()
00132         <<"\n Number of time samples "<<nTSamples_<<" is not the same as expected ("<<expXtalTSamples_<<")"
00133         <<"\n => Skipping to next tower block...";
00134      } 
00135     //Note : add to error collection ?           
00136     updateEventPointers();
00137     return SKIP_BLOCK_UNPACKING;
00138   }
00139 
00140   
00141   xtalBlockSize_     = numbDWInXtalBlock_*8;
00142   blockSize_           = blockLength_*8;  
00143   
00144   if((*dwToEnd_)<blockLength_){
00145     if( ! DCCDataUnpacker::silentMode_ ){
00146       edm::LogWarning("EcalRawToDigiDevNumTowerBlocks")
00147         <<"\n Unable to unpack Tower Block "<<towerId_<<" for event L1A "<<event_->l1A()<<" in fed "<<mapper_->getActiveDCC()
00148         <<"\n Only "<<((*dwToEnd_)*8)<<" bytes are available while "<<blockSize_<<" are needed!"
00149         <<"\n => Skipping to next fed block...";
00150     }
00151     //TODO : add to error collections
00152     return STOP_EVENT_UNPACKING;
00153   }
00154 
00155 
00156   if(!zs_){
00157          
00158     if ( unfilteredDataBlockLength_ != blockLength_ ){
00159       if( ! DCCDataUnpacker::silentMode_ ){ 
00160         edm::LogWarning("EcalRawToDigiDevNumTowerBlocks")
00161           <<"\n For event L1A "<<event_->l1A()<<", fed "<<mapper_->getActiveDCC()<<" and tower "<<towerId_
00162           <<"\n Expected block size is "<<(unfilteredDataBlockLength_*8)<<" bytes while "<<(blockLength_*8)<<" was found"
00163           <<"\n => Skipping to next fed block...";
00164        }
00165 
00166       fillEcalElectronicsError(invalidBlockLengths_) ;
00167 
00168       //Safer approach...  - why pointers do not navigate in this case?
00169       return STOP_EVENT_UNPACKING;        
00170     }
00171 
00172     
00173   }else if( blockLength_ > unfilteredDataBlockLength_ || (blockLength_-1) < numbDWInXtalBlock_ ){
00174     if( ! DCCDataUnpacker::silentMode_ ){
00175       edm::LogWarning("EcalRawToDigiDevNumTowerBlocks")
00176         <<"\n For event L1A "<<event_->l1A()<<" and fed "<<mapper_->getActiveDCC()
00177         <<"\n The tower "<<towerId_<<" has a wrong number of bytes : "<<(blockLength_*8)           
00178         <<"\n => Skipping to next fed block...";
00179      }
00180 
00181     fillEcalElectronicsError(invalidBlockLengths_) ;
00182 
00183     //Safer approach... - why pointers do not navigate in this case?
00184     return STOP_EVENT_UNPACKING;
00185   }
00186   
00187 
00188 
00189   uint numbOfXtalBlocks = (blockLength_-1)/numbDWInXtalBlock_; 
00190 
00191   // get XTAL Data
00192   uint expStripID(0), expXtalID(0);
00193   //point to xtal data
00194   data_++;
00195   
00196   int statusUnpackXtal =0;
00197 
00198   for(uint numbXtal=1; numbXtal <= numbOfXtalBlocks && statusUnpackXtal!= SKIP_BLOCK_UNPACKING; numbXtal++){
00199 
00200     // If zs is disabled we know the expected strip and xtal ids
00201     // Note : this is valid for the EB how about the EE ? -> retieve expected index from mapper
00202     
00203     if(!zs_){
00204       expStripID  = ( numbXtal-1)/5 + 1;        
00205       expXtalID   =  numbXtal - (expStripID-1)*5;
00206     }
00207     
00208     statusUnpackXtal = unpackXtalData(expStripID,expXtalID);
00209     if (statusUnpackXtal== SKIP_BLOCK_UNPACKING)
00210       {
00211         if( ! DCCDataUnpacker::silentMode_ ){
00212           edm::LogWarning("EcalRawToDigiDev")
00213             <<"\n For event L1A "<<event_->l1A()<<" and fed "<<mapper_->getActiveDCC()
00214             <<"\n The tower "<<towerId_<<" won't be unpacked further";
00215         }
00216       }
00217 
00218   }// end loop over xtals of given FE 
00219 
00220   updateEventPointers();
00221   return BLOCK_UNPACKED;                
00222   
00223 }

virtual int DCCFEBlock::unpackXtalData ( uint  stripID,
uint  xtalID 
) [inline, protected, virtual]

Reimplemented in DCCSCBlock, and DCCTowerBlock.

Definition at line 44 of file DCCFEBlock.h.

References BLOCK_UNPACKED.

Referenced by unpack().

00044 {      return BLOCK_UNPACKED;};

void DCCFEBlock::updateCollectors (  )  [virtual]

Reimplemented from DCCDataBlockPrototype.

Reimplemented in DCCSCBlock, and DCCTowerBlock.

Definition at line 20 of file DCCFEBlock.cc.

References invalidBlockLengths_, DCCDataUnpacker::invalidBlockLengthsCollection(), invalidTTIds_, DCCDataUnpacker::invalidTTIdsCollection(), and DCCDataBlockPrototype::unpacker_.

Referenced by DCCEventBlock::updateCollectors(), DCCSCBlock::updateCollectors(), and DCCTowerBlock::updateCollectors().

void DCCFEBlock::zsFlag ( bool  zs  )  [inline]

Definition at line 30 of file DCCFEBlock.h.

References zs_.

00030 { zs_ = zs;}


Member Data Documentation

uint DCCFEBlock::blockSize_ [protected]

Definition at line 61 of file DCCFEBlock.h.

Referenced by unpack().

uint DCCFEBlock::bx_ [protected]

Definition at line 62 of file DCCFEBlock.h.

Referenced by display(), and unpack().

bool DCCFEBlock::checkFeId_ [protected]

Definition at line 49 of file DCCFEBlock.h.

Referenced by enableFeIdChecks(), and unpack().

uint DCCFEBlock::expTowerID_ [protected]

Definition at line 50 of file DCCFEBlock.h.

Referenced by DCCSCBlock::fillEcalElectronicsError(), DCCTowerBlock::fillEcalElectronicsError(), and unpack().

uint DCCFEBlock::expXtalTSamples_ [protected]

Definition at line 51 of file DCCFEBlock.h.

Referenced by DCCFEBlock(), and unpack().

std::auto_ptr<EcalElectronicsIdCollection>* DCCFEBlock::invalidBlockLengths_ [protected]

Definition at line 67 of file DCCFEBlock.h.

Referenced by unpack(), and updateCollectors().

std::auto_ptr<EcalElectronicsIdCollection>* DCCFEBlock::invalidTTIds_ [protected]

Definition at line 66 of file DCCFEBlock.h.

Referenced by unpack(), and updateCollectors().

uint DCCFEBlock::l1_ [protected]

Definition at line 63 of file DCCFEBlock.h.

Referenced by display(), and unpack().

uint DCCFEBlock::lastStripId_ [protected]

Definition at line 53 of file DCCFEBlock.h.

Referenced by unpack(), DCCTowerBlock::unpackXtalData(), and DCCSCBlock::unpackXtalData().

uint DCCFEBlock::lastXtalId_ [protected]

Definition at line 54 of file DCCFEBlock.h.

Referenced by unpack(), DCCTowerBlock::unpackXtalData(), and DCCSCBlock::unpackXtalData().

uint DCCFEBlock::nTSamples_ [protected]

Definition at line 59 of file DCCFEBlock.h.

Referenced by display(), unpack(), DCCTowerBlock::unpackXtalData(), and DCCSCBlock::unpackXtalData().

uint DCCFEBlock::numbDWInXtalBlock_ [protected]

Definition at line 57 of file DCCFEBlock.h.

Referenced by DCCFEBlock(), unpack(), DCCTowerBlock::unpackXtalData(), and DCCSCBlock::unpackXtalData().

uint DCCFEBlock::towerId_ [protected]

Definition at line 56 of file DCCFEBlock.h.

Referenced by display(), unpack(), DCCTowerBlock::unpackXtalData(), and DCCSCBlock::unpackXtalData().

uint DCCFEBlock::unfilteredDataBlockLength_ [protected]

Definition at line 52 of file DCCFEBlock.h.

Referenced by DCCFEBlock(), and unpack().

uint DCCFEBlock::xtalBlockSize_ [protected]

Definition at line 58 of file DCCFEBlock.h.

Referenced by unpack().

short* DCCFEBlock::xtalGains_ [protected]

Definition at line 65 of file DCCFEBlock.h.

Referenced by DCCFEBlock(), DCCTowerBlock::unpackXtalData(), DCCSCBlock::unpackXtalData(), and ~DCCFEBlock().

bool DCCFEBlock::zs_ [protected]

Definition at line 45 of file DCCFEBlock.h.

Referenced by unpack(), DCCTowerBlock::unpackXtalData(), DCCSCBlock::unpackXtalData(), and zsFlag().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:17:41 2009 for CMSSW by  doxygen 1.5.4