File indexing completed on 2024-09-07 04:36:09
0001 #include "EventFilter/EcalRawToDigi/interface/DCCEETCCBlock.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
0004 #include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
0005
0006 DCCEETCCBlock::DCCEETCCBlock(DCCDataUnpacker* u, EcalElectronicsMapper* m, DCCEventBlock* e, bool unpack)
0007 : DCCTCCBlock(u, m, e, unpack) {
0008 blockLength_ = 0;
0009 }
0010
0011 void DCCEETCCBlock::updateCollectors() {
0012 tps_ = unpacker_->ecalTpsCollection();
0013 pss_ = unpacker_->ecalPSsCollection();
0014 }
0015
0016 void DCCEETCCBlock::addTriggerPrimitivesToCollection() {
0017
0018 data_++;
0019
0020 bool processTPG2(true);
0021 unsigned int psInputCounter(0);
0022
0023 const uint16_t* tccP_ = reinterpret_cast<const uint16_t*>(data_);
0024
0025 int dccFOV = event_->fov();
0026 if (!(dccFOV == dcc_FOV_0 || dccFOV == dcc_FOV_1 || dccFOV == dcc_FOV_2)) {
0027 if (!DCCDataUnpacker::silentMode_) {
0028 edm::LogWarning("IncorrectEvent") << "\n FOV value in data is: " << dccFOV << "At event: " << event_->l1A()
0029 << " with bx " << event_->bx() << " in fed <<" << mapper_->getActiveDCC()
0030 << "\n TCC id " << tccId_ << " FOV " << dccFOV
0031 << " which is not a foreseen value. Setting it to: " << dcc_FOV_2;
0032 }
0033 dccFOV = dcc_FOV_2;
0034 }
0035
0036
0037
0038
0039 if (dccFOV == dcc_FOV_0) {
0040
0041 if (ps_) {
0042 for (unsigned int i = 1; i <= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++) {
0043 pPS_ = mapper_->getPSInputDigiPointer(tccId_, psInputCounter);
0044 if (!pPS_)
0045 continue;
0046 pPS_->setSampleValue(0, *tccP_);
0047 (*pss_)->push_back(*pPS_);
0048 }
0049 }
0050
0051
0052
0053 for (unsigned int i = 1; i <= NUMB_TTS_TPG1; i++, tccP_++) {
0054
0055 if (i <= nTTs_) {
0056 pTP_ = mapper_->getTPPointer(tccId_, i);
0057 if (pTP_)
0058 pTP_->setSample(0, *tccP_);
0059 } else {
0060 processTPG2 = false;
0061 break;
0062 }
0063
0064 if (pTP_)
0065 (*tps_)->push_back(*pTP_);
0066 else
0067 edm::LogError("IncorrectBlock") << "trigger primitive digi was not aquired";
0068 }
0069
0070 if (processTPG2) {
0071
0072 if (ps_) {
0073 for (unsigned int i = 1; i <= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++) {
0074 if (i <= NUMB_TTS_TPG2_DUPL)
0075 continue;
0076
0077 pPS_ = mapper_->getPSInputDigiPointer(tccId_, psInputCounter);
0078 if (!pPS_)
0079 continue;
0080 pPS_->setSampleValue(0, *tccP_);
0081 (*pss_)->push_back(*pPS_);
0082 }
0083 }
0084
0085
0086 for (unsigned int i = 1; i <= NUMB_TTS_TPG2; i++, tccP_++) {
0087 unsigned int tt = i + NUMB_TTS_TPG1;
0088
0089 if (tt <= nTTs_) {
0090 pTP_ = mapper_->getTPPointer(tccId_, tt);
0091 if (pTP_)
0092 pTP_->setSample(0, *tccP_);
0093 } else
0094 break;
0095
0096 (*tps_)->push_back(*pTP_);
0097 }
0098
0099 }
0100
0101 }
0102
0103
0104
0105 else if (dccFOV == dcc_FOV_1 || dccFOV == dcc_FOV_2) {
0106
0107 if (ps_) {
0108 for (unsigned int i = 1; i <= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++) {
0109 pPS_ = mapper_->getPSInputDigiPointer(tccId_, psInputCounter);
0110 if (!pPS_)
0111 continue;
0112 pPS_->setSampleValue(0, *tccP_);
0113 (*pss_)->push_back(*pPS_);
0114 }
0115 }
0116
0117 int offset(0);
0118
0119
0120 for (unsigned int i = 1; i <= NUMB_TTS_TPG1; i++, tccP_++) {
0121
0122 if (i <= nTTs_) {
0123 if (mapper_->isTCCExternal(tccId_)) {
0124 if (i > 8 && i <= 16)
0125 continue;
0126 if (i > 8)
0127 offset = 8;
0128 if (i > 24)
0129 continue;
0130 }
0131
0132 pTP_ = mapper_->getTPPointer(tccId_, i - offset);
0133 if (pTP_)
0134 pTP_->setSample(0, *tccP_);
0135
0136 } else {
0137 processTPG2 = false;
0138 break;
0139 }
0140
0141 if (pTP_)
0142 (*tps_)->push_back(*pTP_);
0143 else
0144 edm::LogError("IncorrectBlock") << "trigger primitive digi was not aquired";
0145 }
0146
0147 if (processTPG2) {
0148
0149 if (ps_) {
0150 for (unsigned int i = 1; i <= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++) {
0151 if (i <= NUMB_TTS_TPG2_DUPL)
0152 continue;
0153
0154 pPS_ = mapper_->getPSInputDigiPointer(tccId_, psInputCounter);
0155 if (!pPS_)
0156 continue;
0157 pPS_->setSampleValue(0, *tccP_);
0158 (*pss_)->push_back(*pPS_);
0159 }
0160 }
0161
0162
0163 for (unsigned int i = 1; i <= NUMB_TTS_TPG2; i++, tccP_++) {
0164 unsigned int tt = i + NUMB_TTS_TPG1;
0165
0166 if (i <= nTTs_) {
0167 if (mapper_->isTCCExternal(tccId_)) {
0168 if (tt > 8 && tt <= 16)
0169 continue;
0170 if (tt > 8)
0171 offset = 8;
0172 if (tt > 24)
0173 continue;
0174 }
0175
0176 pTP_ = mapper_->getTPPointer(tccId_, tt - offset);
0177 if (pTP_)
0178 pTP_->setSample(0, *tccP_);
0179 } else
0180 break;
0181
0182 (*tps_)->push_back(*pTP_);
0183 }
0184 }
0185 }
0186 }
0187
0188 bool DCCEETCCBlock::checkTccIdAndNumbTTs() {
0189 bool tccFound(false);
0190 bool errorOnNumbOfTTs(false);
0191 const int activeDCC = mapper_->getActiveSM();
0192 std::vector<unsigned int>* m = mapper_->getTccs(activeDCC);
0193 std::vector<unsigned int>::iterator it;
0194 for (it = m->begin(); it != m->end(); it++) {
0195 if ((*it) == tccId_) {
0196 tccFound = true;
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211 if (nTTs_ != 28 && nTTs_ != 16) {
0212 if (!DCCDataUnpacker::silentMode_) {
0213 edm::LogWarning("IncorrectBlock")
0214 << "Error on event " << event_->l1A() << " with bx " << event_->bx() << " in fed <<"
0215 << mapper_->getActiveDCC() << "\n TCC id " << tccId_ << " has " << nTTs_
0216 << " Trigger Towers (only 28 or 16 are the expected values in EE)"
0217 << "\n => Skipping to next fed block...";
0218 errorOnNumbOfTTs = true;
0219
0220 }
0221 }
0222 }
0223 }
0224
0225 if (!tccFound) {
0226 if (!DCCDataUnpacker::silentMode_) {
0227 edm::LogWarning("IncorrectBlock") << "Error on event " << event_->l1A() << " with bx " << event_->bx()
0228 << " in fed <<" << mapper_->getActiveDCC() << "\n TCC id " << tccId_
0229 << " is not valid for this dcc "
0230 << "\n => Skipping to next fed block...";
0231
0232 }
0233 }
0234
0235 return (tccFound || errorOnNumbOfTTs);
0236 }
0237
0238 unsigned int DCCEETCCBlock::getLength() {
0239 const uint64_t* temp = data_;
0240 temp++;
0241
0242 ps_ = (*temp >> TCC_PS_B) & B_MASK;
0243
0244 unsigned int numbTps = (NUMB_TTS_TPG1 + NUMB_TTS_TPG2);
0245 if (ps_) {
0246 numbTps += 2 * NUMB_PSEUDOSTRIPS;
0247 }
0248
0249 unsigned int length = numbTps / 4 + 2;
0250 if (numbTps % 4)
0251 length++;
0252
0253 return length;
0254 }