CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/EventFilter/EcalRawToDigi/src/DCCEBSRPBlock.cc

Go to the documentation of this file.
00001 #include "EventFilter/EcalRawToDigi/interface/DCCEBSRPBlock.h"
00002 #include "EventFilter/EcalRawToDigi/interface/DCCDataBlockPrototype.h"
00003 #include "EventFilter/EcalRawToDigi/interface/DCCEventBlock.h"
00004 #include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
00005 #include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
00006 
00007 
00008 
00009 DCCEBSRPBlock::DCCEBSRPBlock(
00010   DCCDataUnpacker * u,EcalElectronicsMapper * m, DCCEventBlock * e, bool unpack
00011 ) : DCCSRPBlock(u,m,e,unpack)
00012 {
00013   
00014   expNumbSrFlags_ = SRP_EB_NUMBFLAGS;
00015   
00016 }
00017 
00018 
00019 void DCCEBSRPBlock::updateCollectors(){
00020  // Set SR flag digis
00021   ebSrFlagsDigis_ = unpacker_->ebSrFlagsCollection(); 
00022 }
00023 
00024 
00025 void DCCEBSRPBlock::addSRFlagToCollection(){
00026   
00027   // Point to SR flags 
00028   data_++;
00029   const uint16_t * my16Bitp_ = reinterpret_cast<const uint16_t *> (data_);
00030   
00031   unsigned int towersInPhi = EcalElectronicsMapper::kTowersInPhi;
00032 
00033   unsigned int fov = event_->fov();
00034 
00035 
00036   for( unsigned int n=0; n<expNumbSrFlags_ ; n++ ){
00037     
00038     if(n>0&&n%4==0) my16Bitp_++;
00039    
00040     unsigned short  srFlag =  ( *my16Bitp_ >> ( (n-(n/4)*4) * 3 ) )  &  SRP_SRFLAG_MASK ;
00041 
00042     unsigned int theSRPi = n ;
00043 
00044 
00045     if(NUMB_SM_EB_PLU_MIN<= mapper_->getActiveSM() && mapper_->getActiveSM()<=NUMB_SM_EB_PLU_MAX && fov>=1 ){
00046       unsigned int u   = n%towersInPhi;
00047       u        = towersInPhi-u;
00048       theSRPi  = ( n/towersInPhi )*towersInPhi + u - 1;
00049     }
00050 
00051     
00052     srFlags_[theSRPi] = srFlag;
00053 
00054     if(unpackInternalData_){  
00055     
00056       std::vector<EcalSrFlag*> srs = mapper_->getSrFlagPointer(theSRPi+1);
00057 
00058       for(size_t i = 0; i < srs.size(); ++i){
00059         srs[i]->setValue(srFlag); 
00060         (*ebSrFlagsDigis_)->push_back(*((EBSrFlag*)srs[i]));
00061       } 
00062     }
00063   } 
00064 }
00065 
00066 
00067 
00068 bool DCCEBSRPBlock::checkSrpIdAndNumbSRFlags(){
00069 
00070    //todo : check srp id based on sm...
00071 
00072   // Check number of SR flags
00073   if (nSRFlags_ != expNumbSrFlags_) {
00074     if (! DCCDataUnpacker::silentMode_) {
00075       edm::LogWarning("IncorrectBlock")
00076         <<"Unable to unpack SRP block for event " << event_->l1A()<<" in fed <<"<<mapper_->getActiveDCC()
00077         <<"\nNumber of flags "<<nSRFlags_<<" is different from expected "<<expNumbSrFlags_;
00078      }
00079     //Note : add to error collection ?
00080     return false;
00081   }
00082   return true;
00083 
00084 } 
00085