Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:34

0001 #include "EventFilter/EcalRawToDigi/interface/DCCEBSRPBlock.h"
0002 #include "EventFilter/EcalRawToDigi/interface/DCCDataBlockPrototype.h"
0003 #include "EventFilter/EcalRawToDigi/interface/DCCEventBlock.h"
0004 #include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
0005 #include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
0006 
0007 DCCEBSRPBlock::DCCEBSRPBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack)
0008     : DCCSRPBlock(u, m, e, unpack) {
0009   expNumbSrFlags_ = SRP_EB_NUMBFLAGS;
0010 }
0011 
0012 void DCCEBSRPBlock::updateCollectors() {
0013   // Set SR flag digis
0014   ebSrFlagsDigis_ = unpacker_->ebSrFlagsCollection();
0015 }
0016 
0017 void DCCEBSRPBlock::addSRFlagToCollection() {
0018   // Point to SR flags
0019   data_++;
0020   const uint16_t *my16Bitp_ = reinterpret_cast<const uint16_t *>(data_);
0021 
0022   unsigned int towersInPhi = EcalElectronicsMapper::kTowersInPhi;
0023 
0024   unsigned int fov = event_->fov();
0025 
0026   for (unsigned int n = 0; n < expNumbSrFlags_; n++) {
0027     if (n > 0 && n % 4 == 0)
0028       my16Bitp_++;
0029 
0030     unsigned short srFlag = (*my16Bitp_ >> ((n - (n / 4) * 4) * 3)) & SRP_SRFLAG_MASK;
0031 
0032     unsigned int theSRPi = n;
0033 
0034     if (NUMB_SM_EB_PLU_MIN <= mapper_->getActiveSM() && mapper_->getActiveSM() <= NUMB_SM_EB_PLU_MAX && fov >= 1) {
0035       unsigned int u = n % towersInPhi;
0036       u = towersInPhi - u;
0037       theSRPi = (n / towersInPhi) * towersInPhi + u - 1;
0038     }
0039 
0040     srFlags_[theSRPi] = srFlag;
0041 
0042     if (unpackInternalData_) {
0043       std::vector<EcalSrFlag *> srs = mapper_->getSrFlagPointer(theSRPi + 1);
0044 
0045       for (size_t i = 0; i < srs.size(); ++i) {
0046         srs[i]->setValue(srFlag);
0047         (*ebSrFlagsDigis_)->push_back(*((EBSrFlag *)srs[i]));
0048       }
0049     }
0050   }
0051 }
0052 
0053 bool DCCEBSRPBlock::checkSrpIdAndNumbSRFlags() {
0054   //todo : check srp id based on sm...
0055 
0056   // Check number of SR flags
0057   if (nSRFlags_ != expNumbSrFlags_) {
0058     if (!DCCDataUnpacker::silentMode_) {
0059       edm::LogWarning("IncorrectBlock") << "Unable to unpack SRP block for event " << event_->l1A() << " in fed <<"
0060                                         << mapper_->getActiveDCC() << "\nNumber of flags " << nSRFlags_
0061                                         << " is different from expected " << expNumbSrFlags_;
0062     }
0063     //Note : add to error collection ?
0064     return false;
0065   }
0066   return true;
0067 }