Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:45:21

0001 #include "EventFilter/EcalRawToDigi/interface/DCCTCCBlock.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
0004 #include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
0005 #include "EventFilter/EcalRawToDigi/interface/DCCEventBlock.h"
0006 
0007 DCCTCCBlock::DCCTCCBlock(DCCDataUnpacker* u, EcalElectronicsMapper* m, DCCEventBlock* e, bool unpack)
0008     : DCCDataBlockPrototype(u, m, e, unpack) {}
0009 
0010 int DCCTCCBlock::unpack(const uint64_t** data, unsigned int* dwToEnd, short tccChId) {
0011   dwToEnd_ = dwToEnd;
0012   datap_ = data;
0013   data_ = *data;
0014 
0015   // Need at least 1 dw to findout if pseudo-strips readout is enabled
0016   if (*dwToEnd == 1) {
0017     if (!DCCDataUnpacker::silentMode_) {
0018       edm::LogWarning("IncorrectEvent") << "EcalRawToDigi@SUB=DCCTCCBlock:unpack"
0019                                         << "\n Unable to unpack TCC block for event " << event_->l1A() << " in fed "
0020                                         << mapper_->getActiveDCC()
0021                                         << "\n Only 8 bytes are available until the end of event ..."
0022                                         << "\n => Skipping to next fed block...";
0023     }
0024 
0025     //todo : add this to error colection
0026 
0027     return STOP_EVENT_UNPACKING;
0028   }
0029 
0030   blockLength_ = getLength();
0031 
0032   if ((*dwToEnd_) < blockLength_) {
0033     if (!DCCDataUnpacker::silentMode_) {
0034       edm::LogWarning("IncorrectEvent") << "EcalRawToDigi@SUB=DCCTCCBlock:unpack"
0035                                         << "\n Unable to unpack TCC block for event " << event_->l1A() << " in fed "
0036                                         << mapper_->getActiveDCC() << "\n Only " << ((*dwToEnd_) * 8)
0037                                         << " bytes are available until the end of event while " << (blockLength_ * 8)
0038                                         << " are needed!"
0039                                         << "\n => Skipping to next fed block...";
0040     }
0041 
0042     //todo : add this to error colection
0043 
0044     return STOP_EVENT_UNPACKING;
0045   }
0046 
0047   if (unpackInternalData_) {
0048     //  Go to the begining of the tcc block
0049     data_++;
0050 
0051     tccId_ = (*data_) & TCC_ID_MASK;
0052     ps_ = (*data_ >> TCC_PS_B) & B_MASK;
0053     bx_ = (*data_ >> TCC_BX_B) & TCC_BX_MASK;
0054     l1_ = (*data_ >> TCC_L1_B) & TCC_L1_MASK;
0055     nTTs_ = (*data_ >> TCC_TT_B) & TCC_TT_MASK;
0056     nTSamples_ = (*data_ >> TCC_TS_B) & TCC_TS_MASK;
0057 
0058     event_->setTCCSyncNumbers(l1_, bx_, tccChId);
0059 
0060     if (!checkTccIdAndNumbTTs()) {
0061       updateEventPointers();
0062       return SKIP_BLOCK_UNPACKING;
0063     }
0064 
0065     // Check synchronization
0066     if (sync_) {
0067       const unsigned int dccBx = (event_->bx()) & TCC_BX_MASK;
0068       const unsigned int dccL1 = (event_->l1A()) & TCC_L1_MASK;
0069       const unsigned int fov = (event_->fov()) & H_FOV_MASK;
0070 
0071       if (!isSynced(dccBx, bx_, dccL1, l1_, TCC_SRP, fov)) {
0072         if (!DCCDataUnpacker::silentMode_) {
0073           edm::LogWarning("IncorrectBlock")
0074               << "Synchronization error for TCC block"
0075               << " (L1A " << event_->l1A() << " bx " << event_->bx() << " fed " << mapper_->getActiveDCC() << ")\n"
0076               << "  dccBx = " << dccBx << " bx_ = " << bx_ << " dccL1 = " << dccL1 << " l1_ = " << l1_ << "\n"
0077               << "  => TCC block skipped";
0078         }
0079 
0080         //Note : add to error collection ?
0081         updateEventPointers();
0082         return SKIP_BLOCK_UNPACKING;
0083       }
0084     }
0085 
0086     //check numb of samples
0087     /*  
0088     unsigned int expTriggerTSamples(mapper_->numbTriggerTSamples());
0089     
0090     if( nTSamples_ != expTriggerTSamples ){
0091       edm::LogWarning("IncorrectBlock")
0092         <<"Unable to unpack TCC block for event "<<event_->l1A()<<" in fed "<<mapper_->getActiveDCC()
0093         <<"\n Number of time samples is "<<nTSamples_<<" while "<<expTriggerTSamples<<" is expected"
0094         <<"\n TCC block skipped..."<<endl;
0095                 
0096        //Note : add to error collection ?
0097            updateEventPointers();                 
0098       return SKIP_BLOCK_UNPACKING;
0099     }
0100     */
0101 
0102     // debugging
0103     // display(cout);
0104 
0105     addTriggerPrimitivesToCollection();
0106   }
0107 
0108   updateEventPointers();
0109   return BLOCK_UNPACKED;
0110 }
0111 
0112 void DCCTCCBlock::display(std::ostream& o) {
0113   o << "\n Unpacked Info for DCC TCC Block"
0114     << "\n DW1 ============================="
0115     << "\n TCC Id " << tccId_ << "\n Bx " << bx_ << "\n L1 " << l1_ << "\n Numb TT " << nTTs_ << "\n Numb Samp "
0116     << nTSamples_;
0117 }