File indexing completed on 2024-04-06 12:20:38
0001 #ifndef __L1Trigger_L1THGCal_HGCalConcentratorAutoEncoderImpl_h__
0002 #define __L1Trigger_L1THGCal_HGCalConcentratorAutoEncoderImpl_h__
0003
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
0006 #include "DataFormats/L1THGCal/interface/HGCalConcentratorData.h"
0007 #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"
0008 #include <vector>
0009
0010 #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
0011
0012 #include "PhysicsTools/TensorFlow/interface/TensorFlow.h"
0013
0014 class HGCalConcentratorAutoEncoderImpl {
0015 public:
0016 HGCalConcentratorAutoEncoderImpl(const edm::ParameterSet& conf);
0017
0018 void select(unsigned nLinks,
0019 const std::vector<l1t::HGCalTriggerCell>& trigCellVecInput,
0020 std::vector<l1t::HGCalTriggerCell>& trigCellVecOutput,
0021 std::vector<l1t::HGCalConcentratorData>& ae_EncodedOutput);
0022
0023 void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); }
0024
0025 private:
0026 static constexpr int nTriggerCells_ = 48;
0027
0028 static constexpr int maxAEInputSize_ = 192;
0029
0030 static constexpr int nEncodedLayerNodes_ = 16;
0031
0032 static constexpr unsigned int maxNumberOfLinks_ = 13;
0033
0034 static constexpr int cellUVSize_ = 8;
0035
0036 static constexpr int encoderTensorDims_ = 4;
0037
0038 static constexpr int decoderTensorDims_ = 2;
0039
0040 static constexpr int cellUVremap_[cellUVSize_][cellUVSize_] = {{47, 46, 45, 44, -1, -1, -1, -1},
0041 {16, 43, 42, 41, 40, -1, -1, -1},
0042 {20, 17, 39, 38, 37, 36, -1, -1},
0043 {24, 21, 18, 35, 34, 33, 32, -1},
0044 {28, 25, 22, 19, 3, 7, 11, 15},
0045 {-1, 29, 26, 23, 2, 6, 10, 14},
0046 {-1, -1, 30, 27, 1, 5, 9, 13},
0047 {-1, -1, -1, 31, 0, 4, 8, 12}};
0048 static constexpr int ae_outputCellU_[nTriggerCells_] = {7, 6, 5, 4, 7, 6, 5, 4, 7, 6, 5, 4, 7, 6, 5, 4,
0049 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7,
0050 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0};
0051 static constexpr int ae_outputCellV_[nTriggerCells_] = {4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
0052 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
0053 6, 5, 4, 3, 5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 1, 0};
0054
0055 unsigned int nInputs_;
0056 std::vector<int> cellRemap_;
0057 std::vector<int> cellRemapNoDuplicates_;
0058 std::vector<uint> encoderShape_;
0059 std::vector<uint> decoderShape_;
0060 int bitsPerInput_;
0061 int maxBitsPerOutput_;
0062 std::vector<int> outputBitsPerLink_;
0063
0064 std::vector<edm::ParameterSet> modelFilePaths_;
0065
0066 std::string inputTensorName_encoder_;
0067 std::string outputTensorName_encoder_;
0068 std::unique_ptr<tensorflow::GraphDef> graphDef_encoder_;
0069 std::vector<std::unique_ptr<tensorflow::Session>> session_encoder_;
0070
0071 std::string inputTensorName_decoder_;
0072 std::string outputTensorName_decoder_;
0073 std::unique_ptr<tensorflow::GraphDef> graphDef_decoder_;
0074 std::vector<std::unique_ptr<tensorflow::Session>> session_decoder_;
0075
0076 std::vector<unsigned int> linkToGraphMap_;
0077
0078 double zeroSuppresionThreshold_;
0079 bool bitShiftNormalization_;
0080 bool saveEncodedValues_;
0081 bool preserveModuleSum_;
0082
0083 std::array<double, nEncodedLayerNodes_> ae_encodedLayer_;
0084
0085 HGCalTriggerTools triggerTools_;
0086 };
0087
0088 #endif