10 : cellRemap_(conf.getParameter<
std::
vector<
int>>(
"cellRemap")),
11 cellRemapNoDuplicates_(conf.getParameter<
std::
vector<
int>>(
"cellRemapNoDuplicates")),
12 encoderShape_(conf.getParameter<
std::
vector<
uint>>(
"encoderShape")),
13 decoderShape_(conf.getParameter<
std::
vector<
uint>>(
"decoderShape")),
14 bitsPerInput_(conf.getParameter<
int>(
"nBitsPerInput")),
15 maxBitsPerOutput_(conf.getParameter<
int>(
"maxBitsPerOutput")),
16 outputBitsPerLink_(conf.getParameter<
std::
vector<
int>>(
"bitsPerLink")),
18 linkToGraphMap_(conf.getParameter<
std::
vector<unsigned
int>>(
"linkToGraphMap")),
19 zeroSuppresionThreshold_(conf.getParameter<double>(
"zeroSuppresionThreshold")),
20 bitShiftNormalization_(conf.getParameter<
bool>(
"bitShiftNormalization")),
21 saveEncodedValues_(conf.getParameter<
bool>(
"saveEncodedValues")),
22 preserveModuleSum_(conf.getParameter<
bool>(
"preserveModuleSum")) {
33 <<
"Encoder input shapes are currently expected to be " <<
encoderTensorDims_ <<
" values";
38 <<
"Encoder input shapes are currently expected to be " <<
decoderTensorDims_ <<
" values long";
44 <<
") does not agree with the total size specified for the encoder inputs based on the encoderShape variable ("
50 <<
"Size of cellRemap (" <<
cellRemap_.size() <<
") does not agree with size of cellRemapNoDuplicates ("
61 <<
" is larger than the number of trigger cells " <<
nTriggerCells_;
91 throw cms::Exception(
"BadInitialization") <<
"provided list of encoder graphs have different input nodes";
94 throw cms::Exception(
"BadInitialization") <<
"provided list of encoder graphs have different output nodes";
97 throw cms::Exception(
"BadInitialization") <<
"provided list of decoder graphs have different input nodes";
100 throw cms::Exception(
"BadInitialization") <<
"provided list of decoder graphs have different output nodes";
108 <<
"Autoencoder graph number must be specified for all link allocation possibilities. Only "
116 <<
"Autoencoder graph number " << graphNumber <<
" is larger than the size of the provided list of graphs "
123 const std::vector<l1t::HGCalTriggerCell>& trigCellVecInput,
124 std::vector<l1t::HGCalTriggerCell>& trigCellVecOutput,
125 std::vector<l1t::HGCalConcentratorData>& ae_encodedLayer_Output) {
126 std::array<double, nTriggerCells_> mipPt;
127 std::array<double, nTriggerCells_> uncompressedCharge;
128 std::array<double, nTriggerCells_> compressedCharge;
129 std::array<double, maxAEInputSize_> ae_inputArray;
130 std::array<double, nTriggerCells_> ae_outputArray;
134 uncompressedCharge.fill(0);
135 compressedCharge.fill(0);
136 ae_inputArray.fill(0);
137 ae_outputArray.fill(0);
145 double inputMaxIntSize = 1;
148 double outputMaxIntSize = 1;
149 if (bitsPerOutput > 0)
150 outputMaxIntSize = 1 << bitsPerOutput;
151 double outputMaxIntSizeGlobal = 1;
155 for (
const auto& trigCell : trigCellVecInput) {
160 uint cellu =
id.triggerCellU();
161 uint cellv =
id.triggerCellV();
163 if (inputIndex < 0) {
165 <<
"Invalid index provided for trigger cell u=" << cellu <<
" v=" << cellv <<
" in cellUVRemap[" << cellu
166 <<
"][" << cellv <<
"]";
169 mipPt[inputIndex] = trigCell.mipPt();
170 uncompressedCharge[inputIndex] = trigCell.uncompressedCharge();
171 compressedCharge[inputIndex] = trigCell.compressedCharge();
173 modSum += trigCell.mipPt();
181 int msb =
int(log2(modSum));
193 ae_inputArray[
i] = std::round(ae_inputArray[
i] * inputMaxIntSize) / inputMaxIntSize;
198 tensorflow::Tensor encoder_input(tensorflow::DT_FLOAT,
201 float*
d = encoder_input.flat<
float>().
data();
203 *
d = ae_inputArray[
i];
208 std::vector<tensorflow::Tensor> encoder_outputs;
214 if (encoder_outputs.empty()) {
215 throw cms::Exception(
"BadInitialization") <<
"Autoencoder graph returning empty output vector";
218 d = encoder_outputs[0].flat<
float>().
data();
219 for (
int i = 0;
i < encoder_outputs[0].NumElements();
i++,
d++) {
228 d = decoder_input.flat<
float>().
data();
233 std::vector<tensorflow::Tensor> decoder_outputs;
239 double outputSum = 0.;
241 d = decoder_outputs[0].flat<
float>().
data();
247 ae_outputArray[remapIndex] = *
d;
250 double renormalizationFactor = 1.;
252 renormalizationFactor = modSum / outputSum;
259 int subdet =
id.subdet();
261 int type =
id.type();
262 int layer =
id.layer();
267 float mipPtToEt_conv = trigCellVecInput[0].et() / trigCellVecInput[0].mipPt();
268 float mipToADC_conv = trigCellVecInput[0].hwPt() / (trigCellVecInput[0].mipPt() * cosh(trigCellVecInput[0].
eta()));
271 if (ae_outputArray[
i] > 0) {
282 double mipPt = ae_outputArray[
i] *
normalization * renormalizationFactor;
283 double adc = mipPt * cosh(
point.eta()) * mipToADC_conv;
284 double et = mipPt * mipPtToEt_conv;
300 trigCellVecOutput.push_back(triggerCell);
308 ae_encodedLayer_Output.push_back(encodedLayerData);