CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/EventFilter/EcalRawToDigi/src/DCCEBTCCBlock.cc

Go to the documentation of this file.
00001 #include "EventFilter/EcalRawToDigi/interface/DCCEBTCCBlock.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
00004 #include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
00005 
00006 DCCEBTCCBlock::DCCEBTCCBlock ( DCCDataUnpacker  * u,  EcalElectronicsMapper * m, DCCEventBlock * e, bool unpack) 
00007 : DCCTCCBlock(u,m,e,unpack)
00008 {
00009   blockLength_ = mapper_->getEBTCCBlockLength();
00010   expNumbTTs_  = TCC_EB_NUMBTTS;
00011 }
00012 
00013 void DCCEBTCCBlock::updateCollectors(){
00014   tps_ = unpacker_->ecalTpsCollection();
00015 }
00016 
00017 bool DCCEBTCCBlock::checkTccIdAndNumbTTs(){
00018 
00019   expTccId_ = mapper_->getActiveSM()+TCCID_SMID_SHIFT_EB;
00020 
00021   if( tccId_ != expTccId_ ){
00022 
00023     if( ! DCCDataUnpacker::silentMode_ ){
00024       edm::LogWarning("IncorrectBlock")
00025         <<"Error on event "<<event_->l1A()<<" with bx "<<event_->bx()<<" in fed "<<mapper_->getActiveDCC()
00026         <<"\n TCC id is "<<tccId_<<" while expected is "<<expTccId_
00027         <<"\n TCC Block Skipped ...";  
00028          //todo : add this to error colection
00029      }
00030      return false;
00031   }
00032   
00033   //Check number of TT Flags
00034   if( nTTs_ != expNumbTTs_ ){
00035     if( ! DCCDataUnpacker::silentMode_ ){
00036       edm::LogWarning("IncorrectBlock")
00037        <<"Unable to unpack TCC block for event "<<event_->l1A()<<" in fed "<<mapper_->getActiveDCC()
00038        <<"\n Number of TTs "<<nTTs_<<" is different from expected "<<expNumbTTs_
00039        <<"\n TCC Block Skipped ..."; 
00040          //todo : add this to error colection
00041      }
00042      return false;
00043   }  
00044   return true;
00045 }
00046 
00047 
00048 void DCCEBTCCBlock::addTriggerPrimitivesToCollection(){
00049 
00050   //point to trigger data
00051   data_++;
00052 
00053   unsigned int towersInPhi = EcalElectronicsMapper::kTowersInPhi;
00054   
00055   const uint16_t * tccP_= reinterpret_cast<const uint16_t * >(data_);
00056  
00057 
00058   for( unsigned int i = 1; i <= expNumbTTs_; i++){
00059 
00060     unsigned int theTT = i;
00061 
00062     if(NUMB_SM_EB_PLU_MIN<= mapper_->getActiveSM() && mapper_->getActiveSM()<=NUMB_SM_EB_PLU_MAX)
00063     {
00064         unsigned int u = (i-1)%towersInPhi;
00065         u      = towersInPhi-u;
00066         theTT  = ( (i-1)/towersInPhi )*towersInPhi + u;
00067     }
00068    
00069     pTP_ =  mapper_->getTPPointer(tccId_,theTT);
00070     for(unsigned int ns = 0; ns<nTSamples_;ns++,tccP_++){
00071       
00072       pTP_->setSampleValue(ns, (*tccP_));
00073       (*tps_)->push_back(*pTP_);
00074                   
00075     }
00076   }
00077 
00078 
00079 }
00080 
00081