File indexing completed on 2024-04-06 12:29:22
0001 #include <SimCalorimetry/EcalEBTrigPrimAlgos/interface/EcalEBFenixAmplitudeFilter.h>
0002 #include "CondFormats/EcalObjects/interface/EcalTPGWeightIdMap.h"
0003 #include "CondFormats/EcalObjects/interface/EcalTPGWeightGroup.h"
0004 #include "CondFormats/EcalObjects/interface/EcalTPGGroups.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include <iostream>
0007
0008 EcalEBFenixAmplitudeFilter::EcalEBFenixAmplitudeFilter() : inputsAlreadyIn_(0), shift_(6) {}
0009
0010 EcalEBFenixAmplitudeFilter::~EcalEBFenixAmplitudeFilter() {}
0011
0012 int EcalEBFenixAmplitudeFilter::setInput(int input, int fgvb) {
0013 if (input > 0X3FFFF) {
0014 std::cout << "ERROR IN INPUT OF AMPLITUDE FILTER" << std::endl;
0015 return -1;
0016 }
0017 if (inputsAlreadyIn_ < 5) {
0018
0019 buffer_[inputsAlreadyIn_] = input;
0020 fgvbBuffer_[inputsAlreadyIn_] = fgvb;
0021 inputsAlreadyIn_++;
0022 } else {
0023 for (int i = 0; i < 4; i++) {
0024 buffer_[i] = buffer_[i + 1];
0025
0026 fgvbBuffer_[i] = fgvbBuffer_[i + 1];
0027 }
0028 buffer_[4] = input;
0029 fgvbBuffer_[4] = fgvb;
0030 }
0031 return 1;
0032 }
0033
0034 void EcalEBFenixAmplitudeFilter::process(std::vector<int> &addout,
0035 std::vector<int> &output,
0036 std::vector<int> &fgvbIn,
0037 std::vector<int> &fgvbOut) {
0038
0039
0040 inputsAlreadyIn_ = 0;
0041 for (unsigned int i = 0; i < 5; i++) {
0042 buffer_[i] = 0;
0043 fgvbBuffer_[i] = 0;
0044 }
0045
0046
0047
0048
0049 for (unsigned int i = 0; i < addout.size(); i++) {
0050 setInput(addout[i], fgvbIn[i]);
0051 for (unsigned int i = 0; i < 5; i++) {
0052
0053 }
0054
0055 process();
0056 output[i] = processedOutput_;
0057 fgvbOut[i] = processedFgvbOutput_;
0058 }
0059
0060 for (unsigned int i = 0; i < (output.size()); i++) {
0061 if (i != output.size() - 1) {
0062 output[i] = output[i + 1];
0063 fgvbOut[i] = fgvbOut[i + 1];
0064 } else {
0065 output[i] = 0;
0066 fgvbOut[i] = 0;
0067 }
0068 }
0069 return;
0070 }
0071
0072 void EcalEBFenixAmplitudeFilter::process() {
0073
0074 processedOutput_ = 0;
0075 processedFgvbOutput_ = 0;
0076 if (inputsAlreadyIn_ < 5)
0077 return;
0078 int output = 0;
0079 int fgvbInt = 0;
0080 for (int i = 0; i < 5; i++) {
0081 output += (weights_[i] * buffer_[i]) >> shift_;
0082
0083 if ((fgvbBuffer_[i] == 1 && i == 3) || fgvbInt == 1) {
0084 fgvbInt = 1;
0085 }
0086 }
0087 if (output < 0)
0088 output = 0;
0089 if (output > 0X3FFFF)
0090 output = 0X3FFFF;
0091 processedOutput_ = output;
0092 processedFgvbOutput_ = fgvbInt;
0093 }
0094
0095 void EcalEBFenixAmplitudeFilter::setParameters(uint32_t raw,
0096 const EcalTPGWeightIdMap *ecaltpgWeightMap,
0097 const EcalTPGWeightGroup *ecaltpgWeightGroup) {
0098 uint32_t params_[5];
0099 const EcalTPGGroups::EcalTPGGroupsMap &groupmap = ecaltpgWeightGroup->getMap();
0100 EcalTPGGroups::EcalTPGGroupsMapItr it = groupmap.find(raw);
0101 if (it != groupmap.end()) {
0102 uint32_t weightid = (*it).second;
0103 const EcalTPGWeightIdMap::EcalTPGWeightMap &weightmap = ecaltpgWeightMap->getMap();
0104 EcalTPGWeightIdMap::EcalTPGWeightMapItr itw = weightmap.find(weightid);
0105 (*itw).second.getValues(params_[0], params_[1], params_[2], params_[3], params_[4]);
0106
0107
0108
0109
0110 for (int i = 0; i < 5; ++i) {
0111 weights_[i] = (params_[i] & 0x40) ? (int)(params_[i] | 0xffffffc0) : (int)(params_[i]);
0112
0113
0114
0115
0116
0117 }
0118
0119 } else
0120 edm::LogWarning("EcalTPG") << " could not find EcalTPGGroupsMap entry for " << raw;
0121 }