File indexing completed on 2024-04-06 12:29:22
0001 #include <SimCalorimetry/EcalEBTrigPrimAlgos/interface/EcalEBFenixTcpFormat.h>
0002 #include "CondFormats/EcalObjects/interface/EcalTPGLutGroup.h"
0003 #include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h"
0004 #include "CondFormats/EcalObjects/interface/EcalTPGTowerStatus.h"
0005 #include "CondFormats/EcalObjects/interface/EcalTPGSpike.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include <iostream>
0008
0009 using namespace std;
0010
0011 EcalEBFenixTcpFormat::EcalEBFenixTcpFormat(bool tcpFormat, bool debug, bool famos, int binOfMax)
0012 : tcpFormat_(tcpFormat), debug_(debug), famos_(famos), binOfMax_(binOfMax) {
0013 status_ = 0;
0014 badTTStatus_ = &status_;
0015 }
0016
0017 EcalEBFenixTcpFormat::~EcalEBFenixTcpFormat() {}
0018
0019 void EcalEBFenixTcpFormat::process(std::vector<int> &Etin, std::vector<int> &Etout) {
0020
0021
0022
0023
0024
0025 int myEt;
0026 int eTTotShift = 2;
0027
0028
0029 for (unsigned int i = 0; i < Etin.size(); ++i) {
0030
0031 myEt = Etin[i];
0032
0033 if (myEt > 0xfff)
0034 myEt = 0xfff;
0035
0036 myEt >>= eTTotShift;
0037
0038 if (myEt > 0x3ff)
0039 myEt = 0x3ff;
0040
0041
0042
0043
0044
0045 Etout[i] = myEt;
0046 }
0047 }
0048
0049 void EcalEBFenixTcpFormat::process(std::vector<int> &Et,
0050 std::vector<int> &fgvb,
0051 std::vector<int> &sfgvb,
0052 int eTTotShift,
0053 std::vector<EcalEBTriggerPrimitiveSample> &out,
0054 std::vector<EcalEBTriggerPrimitiveSample> &out2,
0055 bool isInInnerRings) {
0056
0057
0058
0059
0060
0061 int myEt;
0062 if (famos_) {
0063 for (unsigned int i = 0; i < out.size(); ++i) {
0064 if (i == binOfMax_ - 1) {
0065 myEt = Et[0] >> eTTotShift;
0066 if (myEt > 0x3ff)
0067 myEt = 0x3ff;
0068 if (isInInnerRings)
0069 myEt = myEt / 2;
0070
0071
0072
0073 int lut_out;
0074 if (*badTTStatus_ != 0) {
0075 lut_out = 0;
0076 } else
0077 lut_out = (lut_)[myEt];
0078
0079
0080 myEt = lut_out & 0xff;
0081
0082 out[i] = EcalEBTriggerPrimitiveSample(myEt);
0083 } else
0084 out[i] = EcalEBTriggerPrimitiveSample();
0085 }
0086 } else {
0087
0088 for (unsigned int i = 0; i < Et.size(); ++i) {
0089
0090 int mysFgvb = sfgvb[i];
0091
0092
0093
0094
0095
0096 myEt = Et[i];
0097
0098 if (myEt > 0xfff)
0099 myEt = 0xfff;
0100 if (isInInnerRings)
0101 myEt = myEt / 2;
0102 myEt >>= eTTotShift;
0103
0104 if (myEt > 0x3ff)
0105 myEt = 0x3ff;
0106
0107
0108 if ((myEt > spikeZeroThresh_) && (mysFgvb == 0)) {
0109 myEt = 0;
0110 }
0111
0112 int lut_out;
0113 if (*badTTStatus_ != 0) {
0114 lut_out = 0;
0115 } else
0116 lut_out = (lut_)[myEt];
0117
0118
0119 if (tcpFormat_) {
0120 out2[i] = EcalEBTriggerPrimitiveSample(myEt & 0x3ff);
0121
0122 }
0123
0124 myEt = lut_out & 0xff;
0125
0126 out[i] = EcalEBTriggerPrimitiveSample(myEt);
0127 }
0128 }
0129 }
0130
0131 void EcalEBFenixTcpFormat::setParameters(uint32_t towid,
0132 const EcalTPGLutGroup *ecaltpgLutGroup,
0133 const EcalTPGLutIdMap *ecaltpgLut,
0134 const EcalTPGTowerStatus *ecaltpgbadTT,
0135 const EcalTPGSpike *ecaltpgSpike) {
0136
0137 spikeZeroThresh_ = 1023;
0138 if (ecaltpgSpike != nullptr) {
0139 const EcalTPGSpike::EcalTPGSpikeMap &spikeMap = ecaltpgSpike->getMap();
0140 EcalTPGSpike::EcalTPGSpikeMapIterator sit = spikeMap.find(towid);
0141 if (sit != spikeMap.end()) {
0142 spikeZeroThresh_ = sit->second;
0143 }
0144 }
0145
0146 const EcalTPGGroups::EcalTPGGroupsMap &groupmap = ecaltpgLutGroup->getMap();
0147 EcalTPGGroups::EcalTPGGroupsMapItr it = groupmap.find(towid);
0148 if (it != groupmap.end()) {
0149 uint32_t lutid = (*it).second;
0150 const EcalTPGLutIdMap::EcalTPGLutMap &lutmap = ecaltpgLut->getMap();
0151 EcalTPGLutIdMap::EcalTPGLutMapItr itl = lutmap.find(lutid);
0152 if (itl != lutmap.end()) {
0153 lut_ = (*itl).second.getLut();
0154
0155 } else
0156 edm::LogWarning("EcalTPG") << " could not find EcalTPGLutMap for " << lutid;
0157
0158 } else
0159 edm::LogWarning("EcalTPG") << " could not find EcalTPGFineGrainTowerEEMap for " << towid;
0160
0161 const EcalTPGTowerStatusMap &badTTMap = ecaltpgbadTT->getMap();
0162 EcalTPGTowerStatusMapIterator itbadTT = badTTMap.find(towid);
0163 if (itbadTT != badTTMap.end()) {
0164 badTTStatus_ = &(*itbadTT).second;
0165 }
0166 }