CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/EventFilter/EcalRawToDigi/src/DCCTCCBlock.cc

Go to the documentation of this file.
00001 #include "EventFilter/EcalRawToDigi/interface/DCCTCCBlock.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
00004 #include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
00005 #include "EventFilter/EcalRawToDigi/interface/DCCEventBlock.h"
00006 
00007 DCCTCCBlock::DCCTCCBlock ( DCCDataUnpacker  * u, EcalElectronicsMapper * m, DCCEventBlock * e, bool unpack) : 
00008 DCCDataBlockPrototype(u,m,e,unpack){}
00009 
00010  
00011 int DCCTCCBlock::unpack(const uint64_t ** data, unsigned int * dwToEnd, short tccChId){ 
00012  
00013   dwToEnd_    = dwToEnd;  
00014   datap_      = data;
00015   data_       = *data;
00016   
00017   // Need at least 1 dw to findout if pseudo-strips readout is enabled
00018   if(*dwToEnd == 1){
00019     if( ! DCCDataUnpacker::silentMode_ ){
00020       edm::LogWarning("IncorrectEvent")
00021         <<"EcalRawToDigi@SUB=DCCTCCBlock:unpack"
00022         <<"\n Unable to unpack TCC block for event "<<event_->l1A()<<" in fed "<<mapper_->getActiveDCC()
00023         <<"\n Only 8 bytes are available until the end of event ..."
00024         <<"\n => Skipping to next fed block...";
00025      }
00026     
00027     //todo : add this to error colection
00028     
00029     return STOP_EVENT_UNPACKING;
00030   }
00031 
00032   blockLength_ = getLength();
00033   
00034   
00035   if( (*dwToEnd_)<blockLength_ ){
00036     if( ! DCCDataUnpacker::silentMode_ ){
00037       edm::LogWarning("IncorrectEvent")
00038         <<"EcalRawToDigi@SUB=DCCTCCBlock:unpack"
00039         <<"\n Unable to unpack TCC block for event "<<event_->l1A()<<" in fed "<<mapper_->getActiveDCC()
00040         <<"\n Only "<<((*dwToEnd_)*8)<<" bytes are available until the end of event while "<<(blockLength_*8)<<" are needed!"
00041         <<"\n => Skipping to next fed block...";
00042      }
00043     
00044     //todo : add this to error colection
00045     
00046     return STOP_EVENT_UNPACKING;
00047   }
00048   
00049   
00050   
00051   if(unpackInternalData_){ 
00052   
00053     //  Go to the begining of the tcc block
00054     data_++;
00055   
00056     tccId_    = ( *data_ )           & TCC_ID_MASK;
00057     ps_       = ( *data_>>TCC_PS_B ) & B_MASK;      
00058     bx_       = ( *data_>>TCC_BX_B ) & TCC_BX_MASK;
00059     l1_       = ( *data_>>TCC_L1_B ) & TCC_L1_MASK;
00060     nTTs_     = ( *data_>>TCC_TT_B ) & TCC_TT_MASK;
00061     nTSamples_= ( *data_>>TCC_TS_B ) & TCC_TS_MASK;
00062         
00063     event_->setTCCSyncNumbers(l1_,bx_,tccChId);
00064 
00065     if ( ! checkTccIdAndNumbTTs() ){
00066           updateEventPointers();
00067           return SKIP_BLOCK_UNPACKING;
00068         }  
00069   
00070     // Check synchronization
00071     if(sync_){
00072       const unsigned int dccBx = (event_->bx())  & TCC_BX_MASK;
00073       const unsigned int dccL1 = (event_->l1A()) & TCC_L1_MASK;
00074       const unsigned int fov   = ( event_->fov() ) & H_FOV_MASK;
00075       
00076       if (! isSynced(dccBx, bx_, dccL1, l1_, TCC_SRP, fov)) {
00077         if( ! DCCDataUnpacker::silentMode_ ){
00078           edm::LogWarning("IncorrectBlock")
00079             << "Synchronization error for TCC block"
00080             << " (L1A " << event_->l1A() << " bx " << event_->bx() << " fed " << mapper_->getActiveDCC() << ")\n"
00081             << "  dccBx = " << dccBx << " bx_ = " << bx_ << " dccL1 = " << dccL1 << " l1_ = " << l1_ << "\n"
00082             << "  => TCC block skipped";
00083         }
00084         
00085         //Note : add to error collection ?        
00086         updateEventPointers();
00087         return SKIP_BLOCK_UNPACKING;
00088         
00089       }
00090     }
00091     
00092     //check numb of samples
00093    /*  
00094     unsigned int expTriggerTSamples(mapper_->numbTriggerTSamples());
00095     
00096     if( nTSamples_ != expTriggerTSamples ){
00097       edm::LogWarning("IncorrectBlock")
00098         <<"Unable to unpack TCC block for event "<<event_->l1A()<<" in fed "<<mapper_->getActiveDCC()
00099         <<"\n Number of time samples is "<<nTSamples_<<" while "<<expTriggerTSamples<<" is expected"
00100         <<"\n TCC block skipped..."<<endl;
00101                 
00102        //Note : add to error collection ?
00103            updateEventPointers();                 
00104       return SKIP_BLOCK_UNPACKING;
00105     }
00106     */         
00107   
00108     // debugging
00109     // display(cout);
00110 
00111     addTriggerPrimitivesToCollection();
00112 
00113   } 
00114 
00115   updateEventPointers();
00116   return BLOCK_UNPACKED;        
00117   
00118 }
00119 
00120 
00121 
00122 void DCCTCCBlock::display(std::ostream& o){
00123 
00124   o<<"\n Unpacked Info for DCC TCC Block"
00125    <<"\n DW1 ============================="
00126    <<"\n TCC Id "<<tccId_
00127    <<"\n Bx "<<bx_
00128    <<"\n L1 "<<l1_
00129    <<"\n Numb TT "<<nTTs_
00130    <<"\n Numb Samp "<<nTSamples_;  
00131 } 
00132