CMS 3D CMS Logo

HGCalBackendLayer2Processor3DClustering_SA.cc
Go to the documentation of this file.
2 
12 
13 #include <utility>
14 
16 public:
19  distributor_(conf.getParameterSet("DistributionParameters")),
20  conf_(conf) {
21  multiclusteringHistoSeeding_ = std::make_unique<HGCalHistoSeedingImpl>(
22  conf.getParameterSet("C3d_parameters").getParameterSet("histoMax_C3d_seeding_parameters"));
23 
24  const edm::ParameterSet& clusteringParamConfig =
25  conf.getParameterSet("C3d_parameters").getParameterSet("histoMax_C3d_clustering_parameters");
26  const edm::ParameterSet& sortingTruncationParamConfig =
27  conf.getParameterSet("C3d_parameters").getParameterSet("histoMax_C3d_sorting_truncation_parameters");
28  const std::string& clusteringAlgoWrapperName = clusteringParamConfig.getParameter<std::string>("AlgoName");
29  const std::string& sortingTruncationAlgoWrapperName =
30  sortingTruncationParamConfig.getParameter<std::string>("AlgoName");
31 
32  multiclusteringHistoClusteringWrapper_ = std::unique_ptr<HGCalHistoClusteringWrapperBase>{
33  HGCalHistoClusteringWrapperBaseFactory::get()->create(clusteringAlgoWrapperName, clusteringParamConfig)};
35  std::unique_ptr<HGCalStage2FilteringWrapperBase>{HGCalStage2FilteringWrapperBaseFactory::get()->create(
36  sortingTruncationAlgoWrapperName, sortingTruncationParamConfig)};
37 
38  for (const auto& interpretationPset : conf.getParameter<std::vector<edm::ParameterSet>>("energy_interpretations")) {
39  std::unique_ptr<HGCalTriggerClusterInterpreterBase> interpreter{
40  HGCalTriggerClusterInterpreterFactory::get()->create(interpretationPset.getParameter<std::string>("type"))};
41  interpreter->initialize(interpretationPset);
42  energy_interpreters_.push_back(std::move(interpreter));
43  }
44  }
45 
47  std::pair<l1t::HGCalMulticlusterBxCollection, l1t::HGCalClusterBxCollection>& be_output) override {
49  multiclusteringHistoSeeding_->setGeometry(geometry());
50  l1t::HGCalMulticlusterBxCollection& collCluster3D_sorted = be_output.first;
51  l1t::HGCalClusterBxCollection& rejectedClusters = be_output.second;
52 
53  /* create a persistent vector of pointers to the trigger-cells */
54  std::unordered_map<uint32_t, std::vector<edm::Ptr<l1t::HGCalCluster>>> tcs_per_fpga;
55 
56  for (unsigned i = 0; i < collHandle->size(); ++i) {
57  edm::Ptr<l1t::HGCalCluster> tc_ptr(collHandle, i);
58  uint32_t module = geometry()->getModuleFromTriggerCell(tc_ptr->detId());
59  uint32_t stage1_fpga = geometry()->getStage1FpgaFromModule(module);
60  HGCalTriggerGeometryBase::geom_set possible_stage2_fpgas = geometry()->getStage2FpgasFromStage1Fpga(stage1_fpga);
61 
63  distributor_.getStage2FPGAs(stage1_fpga, possible_stage2_fpgas, tc_ptr);
64 
65  for (auto& fpga : stage2_fpgas) {
66  tcs_per_fpga[fpga].push_back(tc_ptr);
67  }
68  }
69 
70  // Configuration
71  const std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&> configuration{geometry(), conf_};
74 
75  for (auto& fpga_tcs : tcs_per_fpga) {
76  /* create a vector of seed positions and their energy*/
77  std::vector<std::pair<GlobalPoint, double>> seedPositionsEnergy;
78 
79  /* call to multiclustering and compute shower shape*/
80  multiclusteringHistoSeeding_->findHistoSeeds(fpga_tcs.second, seedPositionsEnergy);
81 
82  // Inputs
83  std::pair<const std::vector<edm::Ptr<l1t::HGCalCluster>>&, const std::vector<std::pair<GlobalPoint, double>>&>
84  inputClustersAndSeeds{fpga_tcs.second, seedPositionsEnergy};
85  // Outputs
86  l1t::HGCalMulticlusterBxCollection collCluster3D_perFPGA;
87  l1t::HGCalMulticlusterBxCollection collCluster3D_perFPGA_sorted;
88  l1t::HGCalClusterBxCollection rejectedClusters_perFPGA;
89 
90  std::pair<l1t::HGCalMulticlusterBxCollection&, l1t::HGCalClusterBxCollection&>
91  outputMulticlustersAndRejectedClusters_perFPGA{collCluster3D_perFPGA, rejectedClusters_perFPGA};
92 
93  // Process
94  multiclusteringHistoClusteringWrapper_->process(inputClustersAndSeeds,
95  outputMulticlustersAndRejectedClusters_perFPGA);
96 
97  multiclusteringSortingTruncationWrapper_->process(collCluster3D_perFPGA, collCluster3D_perFPGA_sorted);
98 
99  // Call all the energy interpretation modules on the cluster collection
100  for (const auto& interpreter : energy_interpreters_) {
101  interpreter->setGeometry(geometry());
102  interpreter->interpret(collCluster3D_perFPGA_sorted);
103  }
104 
105  for (const auto& collcluster : collCluster3D_perFPGA_sorted) {
106  collCluster3D_sorted.push_back(0, collcluster);
107  }
108  for (const auto& rejectedcluster : rejectedClusters_perFPGA) {
109  rejectedClusters.push_back(0, rejectedcluster);
110  }
111  }
112  }
113 
114 private:
115  /* algorithms instances */
116  std::unique_ptr<HGCalHistoSeedingImpl> multiclusteringHistoSeeding_;
117 
118  std::unique_ptr<HGCalHistoClusteringWrapperBase> multiclusteringHistoClusteringWrapper_;
119 
120  std::unique_ptr<HGCalStage2FilteringWrapperBase> multiclusteringSortingTruncationWrapper_;
121 
122  std::vector<std::unique_ptr<HGCalTriggerClusterInterpreterBase>> energy_interpreters_;
123 
126 };
127 
130  "HGCalBackendLayer2Processor3DClusteringSA");
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< HGCalStage2FilteringWrapperBase > multiclusteringSortingTruncationWrapper_
virtual unsigned getStage1FpgaFromModule(const unsigned module_id) const =0
std::unique_ptr< HGCalHistoClusteringWrapperBase > multiclusteringHistoClusteringWrapper_
ParameterSet const & getParameterSet(std::string const &) const
uint32_t detId() const
Definition: HGCalClusterT.h:92
std::vector< std::unique_ptr< HGCalTriggerClusterInterpreterBase > > energy_interpreters_
unsigned size(int bx) const
virtual geom_set getStage2FpgasFromStage1Fpga(const unsigned stage1_id) const =0
void run(const edm::Handle< l1t::HGCalClusterBxCollection > &collHandle, std::pair< l1t::HGCalMulticlusterBxCollection, l1t::HGCalClusterBxCollection > &be_output) override
const HGCalTriggerGeometryBase * geometry() const
virtual unsigned getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const =0
ParameterSet const & getParameterSet(ParameterSetID const &id)
std::unordered_set< unsigned > geom_set
#define DEFINE_EDM_PLUGIN(factory, type, name)
#define get
HGCalTriggerGeometryBase::geom_set getStage2FPGAs(const unsigned stage1_fpga, const HGCalTriggerGeometryBase::geom_set &stage2_fpgas, const edm::Ptr< l1t::HGCalCluster > &tc_ptr) const
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< HGCalHistoSeedingImpl > multiclusteringHistoSeeding_
void push_back(int bx, T object)