File indexing completed on 2024-04-06 12:29:28
0001 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBGroup.h"
0002 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBIdMap.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixFgvbEB.h>
0005
0006 EcalFenixFgvbEB::EcalFenixFgvbEB(int maxNrSamples) { add_out_8_.resize(maxNrSamples); }
0007
0008 EcalFenixFgvbEB::~EcalFenixFgvbEB() {}
0009
0010 void EcalFenixFgvbEB::process(std::vector<int> &add_out, std::vector<int> &maxof2_out, std::vector<int> &output) {
0011 int Elow, Ehigh, Tlow, Thigh, lut;
0012 int ERatLow, ERatHigh;
0013
0014 int COMP3, COMP2, COMP1, COMP0;
0015
0016
0017
0018
0019
0020
0021
0022 Elow = ETlow_;
0023 Ehigh = EThigh_;
0024 Tlow = Ratlow_;
0025 Thigh = Rathigh_;
0026 lut = lut_;
0027
0028 if (Tlow > 127)
0029 Tlow = Tlow - 128;
0030 if (Thigh > 127)
0031 Thigh = Thigh - 128;
0032
0033 for (unsigned int i = 0; i < add_out.size(); i++) {
0034 ERatLow = add_out[i] * Tlow >> 7;
0035 if (ERatLow > 0xFFF)
0036 ERatLow = 0xFFF;
0037 ERatHigh = add_out[i] * Thigh >> 7;
0038 if (ERatHigh > 0xFFF)
0039 ERatHigh = 0xFFF;
0040 if (add_out[i] > 0XFF)
0041 add_out_8_[i] = 0xFF;
0042 else
0043 add_out_8_[i] = add_out[i];
0044
0045 if (maxof2_out[i] >= ERatLow)
0046 COMP3 = 1;
0047 else
0048 COMP3 = 0;
0049 if (maxof2_out[i] >= ERatHigh)
0050 COMP2 = 1;
0051 else
0052 COMP2 = 0;
0053 if (add_out_8_[i] >= Elow)
0054 COMP1 = 1;
0055 else
0056 COMP1 = 0;
0057 if (add_out_8_[i] >= Ehigh)
0058 COMP0 = 1;
0059 else
0060 COMP0 = 0;
0061
0062 int ilut = (COMP3 << 3) + (COMP2 << 2) + (COMP1 << 1) + COMP0;
0063 int mask = 1 << (ilut);
0064 output[i] = (lut) & (mask);
0065 if (output[i] > 0)
0066 output[i] = 1;
0067 }
0068 return;
0069 }
0070
0071 void EcalFenixFgvbEB::setParameters(uint32_t towid,
0072 const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup,
0073 const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB) {
0074 const EcalTPGGroups::EcalTPGGroupsMap &groupmap = ecaltpgFgEBGroup->getMap();
0075 EcalTPGGroups::EcalTPGGroupsMapItr it = groupmap.find(towid);
0076 if (it != groupmap.end()) {
0077
0078
0079
0080
0081
0082
0083
0084 EcalTPGFineGrainEBIdMap::EcalTPGFineGrainEBMapItr itfg = (ecaltpgFineGrainEB->getMap()).find((*it).second);
0085 (*itfg).second.getValues(ETlow_, EThigh_, Ratlow_, Rathigh_, lut_);
0086 } else
0087 edm::LogWarning("EcalTPG") << " could not find EcalTPGGroupsMap entry for " << towid;
0088 }