CMS 3D CMS Logo

HGCalConcentratorProcessorSelection.cc
Go to the documentation of this file.
2 #include <limits>
3 
5 
7 
10  fixedDataSizePerHGCROC_(conf.getParameter<bool>("fixedDataSizePerHGCROC")),
11  allTrigCellsInTrigSums_(conf.getParameter<bool>("allTrigCellsInTrigSums")),
12  coarsenTriggerCells_(conf.getParameter<std::vector<unsigned>>("coarsenTriggerCells")),
13  selectionType_(kNSubDetectors_) {
14  std::vector<std::string> selectionType(conf.getParameter<std::vector<std::string>>("Method"));
16  throw cms::Exception("HGCTriggerParameterError")
17  << "Inconsistent number of sub-detectors (should be " << kNSubDetectors_ << ")";
18  }
19 
20  for (int subdet = 0; subdet < kNSubDetectors_; subdet++) {
21  if (selectionType[subdet] == "thresholdSelect") {
23  if (!thresholdImpl_)
24  thresholdImpl_ = std::make_unique<HGCalConcentratorThresholdImpl>(conf);
25  if (!trigSumImpl_)
26  trigSumImpl_ = std::make_unique<HGCalConcentratorTrigSumImpl>(conf);
27  } else if (selectionType[subdet] == "bestChoiceSelect") {
29  if (!bestChoiceImpl_)
30  bestChoiceImpl_ = std::make_unique<HGCalConcentratorBestChoiceImpl>(conf);
31  if (!trigSumImpl_)
32  trigSumImpl_ = std::make_unique<HGCalConcentratorTrigSumImpl>(conf);
33  } else if (selectionType[subdet] == "superTriggerCellSelect") {
36  superTriggerCellImpl_ = std::make_unique<HGCalConcentratorSuperTriggerCellImpl>(conf);
37  } else if (selectionType[subdet] == "autoEncoder") {
39  if (!autoEncoderImpl_)
40  autoEncoderImpl_ = std::make_unique<HGCalConcentratorAutoEncoderImpl>(conf);
41  } else if (selectionType[subdet] == "noSelection") {
42  selectionType_[subdet] = noSelection;
43  } else {
44  throw cms::Exception("HGCTriggerParameterError")
45  << "Unknown type of concentrator selection '" << selectionType[subdet] << "'";
46  }
47  }
48 
49  if (std::find(coarsenTriggerCells_.begin(), coarsenTriggerCells_.end(), true) != coarsenTriggerCells_.end() ||
51  coarsenerImpl_ = std::make_unique<HGCalConcentratorCoarsenerImpl>(conf);
52  }
53 }
54 
58  l1t::HGCalConcentratorDataBxCollection>& triggerCollOutput,
59  const edm::EventSetup& es) {
60  if (thresholdImpl_)
61  thresholdImpl_->eventSetup(es);
62  if (bestChoiceImpl_)
63  bestChoiceImpl_->eventSetup(es);
65  superTriggerCellImpl_->eventSetup(es);
66  if (autoEncoderImpl_)
67  autoEncoderImpl_->eventSetup(es);
68  if (coarsenerImpl_)
69  coarsenerImpl_->eventSetup(es);
70  if (trigSumImpl_)
71  trigSumImpl_->eventSetup(es);
73 
74  auto& triggerCellCollOutput = std::get<0>(triggerCollOutput);
75  auto& triggerSumCollOutput = std::get<1>(triggerCollOutput);
76  auto& autoEncoderCollOutput = std::get<2>(triggerCollOutput);
77 
78  const l1t::HGCalTriggerCellBxCollection& collInput = *triggerCellCollInput;
79 
80  std::unordered_map<uint32_t, std::vector<l1t::HGCalTriggerCell>> tc_modules;
81  for (const auto& trigCell : collInput) {
82  uint32_t module = geometry_->getModuleFromTriggerCell(trigCell.detId());
83  tc_modules[module].push_back(trigCell);
84  }
85 
86  for (const auto& module_trigcell : tc_modules) {
87  std::vector<l1t::HGCalTriggerCell> trigCellVecOutput;
88  std::vector<l1t::HGCalTriggerCell> trigCellVecCoarsened;
89  std::vector<l1t::HGCalTriggerCell> trigCellVecNotSelected;
90  std::vector<l1t::HGCalTriggerSums> trigSumsVecOutput;
91  std::vector<l1t::HGCalConcentratorData> ae_EncodedLayerOutput;
92 
93  int thickness = triggerTools_.thicknessIndex(module_trigcell.second.at(0).detId(), true);
94 
95  HGCalTriggerTools::SubDetectorType subdet = triggerTools_.getSubDetectorType(module_trigcell.second.at(0).detId());
96 
98  coarsenerImpl_->coarsen(module_trigcell.second, trigCellVecCoarsened);
99 
100  switch (selectionType_[subdet]) {
101  case thresholdSelect:
102  thresholdImpl_->select(trigCellVecCoarsened, trigCellVecOutput, trigCellVecNotSelected);
103  break;
104  case bestChoiceSelect:
105  if (triggerTools_.isEm(module_trigcell.first)) {
106  bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
107  geometry_->getModuleSize(module_trigcell.first),
108  module_trigcell.second,
109  trigCellVecOutput,
110  trigCellVecNotSelected);
111  } else {
112  bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
113  geometry_->getModuleSize(module_trigcell.first),
114  trigCellVecCoarsened,
115  trigCellVecOutput,
116  trigCellVecNotSelected);
117  }
118  break;
120  superTriggerCellImpl_->select(trigCellVecCoarsened, trigCellVecOutput);
121  break;
122  case autoEncoderSelect:
123  autoEncoderImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
124  trigCellVecCoarsened,
125  trigCellVecOutput,
126  ae_EncodedLayerOutput);
127  break;
128  case noSelection:
129  trigCellVecOutput = trigCellVecCoarsened;
130  break;
131  default:
132  // Should not happen, selection type checked in constructor
133  break;
134  }
135 
136  } else {
137  switch (selectionType_[subdet]) {
138  case thresholdSelect:
139  thresholdImpl_->select(module_trigcell.second, trigCellVecOutput, trigCellVecNotSelected);
140  break;
141  case bestChoiceSelect:
142  bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
143  geometry_->getModuleSize(module_trigcell.first),
144  module_trigcell.second,
145  trigCellVecOutput,
146  trigCellVecNotSelected);
147  break;
149  superTriggerCellImpl_->select(module_trigcell.second, trigCellVecOutput);
150  break;
151  case autoEncoderSelect:
152  autoEncoderImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
153  module_trigcell.second,
154  trigCellVecOutput,
155  ae_EncodedLayerOutput);
156  break;
157  case noSelection:
158  trigCellVecOutput = module_trigcell.second;
159  break;
160  default:
161  // Should not happen, selection type checked in constructor
162  break;
163  }
164  }
165 
166  // trigger sum
167  if (trigSumImpl_) {
168  if (allTrigCellsInTrigSums_) { // using all TCs
169  trigSumImpl_->doSum(module_trigcell.first, module_trigcell.second, trigSumsVecOutput);
170  } else { // using only unselected TCs
171  trigSumImpl_->doSum(module_trigcell.first, trigCellVecNotSelected, trigSumsVecOutput);
172  }
173  }
174 
175  for (const auto& trigCell : trigCellVecOutput) {
176  triggerCellCollOutput.push_back(0, trigCell);
177  }
178  for (const auto& trigSums : trigSumsVecOutput) {
179  triggerSumCollOutput.push_back(0, trigSums);
180  }
181  for (const auto& aeVal : ae_EncodedLayerOutput) {
182  autoEncoderCollOutput.push_back(0, aeVal);
183  }
184  }
185 }
HGCalTriggerTools::eventSetup
void eventSetup(const edm::EventSetup &)
Definition: HGCalTriggerTools.cc:35
electrons_cff.bool
bool
Definition: electrons_cff.py:366
HGCalConcentratorProcessorSelection::coarsenTriggerCells_
std::vector< unsigned > coarsenTriggerCells_
Definition: HGCalConcentratorProcessorSelection.h:36
HGCalConcentratorProcessorSelection::kHighDensityThickness_
static constexpr int kHighDensityThickness_
Definition: HGCalConcentratorProcessorSelection.h:37
HGCalConcentratorProcessorSelection::thresholdImpl_
std::unique_ptr< HGCalConcentratorThresholdImpl > thresholdImpl_
Definition: HGCalConcentratorProcessorSelection.h:42
HGCalConcentratorProcessorSelection::kNSubDetectors_
static constexpr int kNSubDetectors_
Definition: HGCalConcentratorProcessorSelection.h:38
HGCalConcentratorProcessorSelection::HGCalConcentratorProcessorSelection
HGCalConcentratorProcessorSelection(const edm::ParameterSet &conf)
Definition: HGCalConcentratorProcessorSelection.cc:8
HGCalTriggerTools::thicknessIndex
int thicknessIndex(const DetId &, bool tc=false) const
Definition: HGCalTriggerTools.cc:233
HGCalConcentratorProcessorSelection
Definition: HGCalConcentratorProcessorSelection.h:20
HGCalConcentratorProcessorSelection::fixedDataSizePerHGCROC_
bool fixedDataSizePerHGCROC_
Definition: HGCalConcentratorProcessorSelection.h:34
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
HGCalConcentratorProcessorSelection::superTriggerCellImpl_
std::unique_ptr< HGCalConcentratorSuperTriggerCellImpl > superTriggerCellImpl_
Definition: HGCalConcentratorProcessorSelection.h:44
HGCalTriggerGeometryBase::getLinksInModule
virtual unsigned getLinksInModule(const unsigned module_id) const =0
BXVector
Definition: BXVector.h:15
HGCalConcentratorProcessorSelection::bestChoiceSelect
Definition: HGCalConcentratorProcessorSelection.h:22
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:115
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
HGCalTriggerTools::getSubDetectorType
SubDetectorType getSubDetectorType(const DetId &id) const
Definition: HGCalTriggerTools.cc:198
HGCalTriggerTools::isEm
bool isEm(const DetId &) const
Definition: HGCalTriggerTools.cc:151
HGCalConcentratorProcessorSelection::allTrigCellsInTrigSums_
bool allTrigCellsInTrigSums_
Definition: HGCalConcentratorProcessorSelection.h:35
HGCalConcentratorProcessorSelection::superTriggerCellSelect
Definition: HGCalConcentratorProcessorSelection.h:22
edm::ParameterSet
Definition: ParameterSet.h:47
edmplugin::PluginFactory
Definition: PluginFactory.h:34
HGCalConcentratorProcessorSelection::coarsenerImpl_
std::unique_ptr< HGCalConcentratorCoarsenerImpl > coarsenerImpl_
Definition: HGCalConcentratorProcessorSelection.h:45
HGCalProcessorBaseT::geometry_
const HGCalTriggerGeometryBase * geometry_
Definition: HGCalProcessorBaseT.h:26
HGCDigiCollections.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
HGCalConcentratorProcessorSelection.h
HGCalConcentratorProcessorSelection::autoEncoderSelect
Definition: HGCalConcentratorProcessorSelection.h:22
callgraph.module
module
Definition: callgraph.py:61
HGCalConcentratorProcessorSelection::trigSumImpl_
std::unique_ptr< HGCalConcentratorTrigSumImpl > trigSumImpl_
Definition: HGCalConcentratorProcessorSelection.h:46
HGCalTriggerGeometryBase::getModuleFromTriggerCell
virtual unsigned getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const =0
std
Definition: JetResolutionObject.h:76
HGCalTriggerTools::SubDetectorType
SubDetectorType
Definition: HGCalTriggerTools.h:89
Exception
Definition: hltDiff.cc:245
HGCalConcentratorProcessorSelection::autoEncoderImpl_
std::unique_ptr< HGCalConcentratorAutoEncoderImpl > autoEncoderImpl_
Definition: HGCalConcentratorProcessorSelection.h:47
HGCalConcentratorProcessorSelection::triggerTools_
HGCalTriggerTools triggerTools_
Definition: HGCalConcentratorProcessorSelection.h:49
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HGCalConcentratorProcessorSelection::noSelection
Definition: HGCalConcentratorProcessorSelection.h:22
HGCalConcentratorProcessorSelection::thresholdSelect
Definition: HGCalConcentratorProcessorSelection.h:22
HGCalConcentratorProcessorSelection::run
void run(const edm::Handle< l1t::HGCalTriggerCellBxCollection > &triggerCellCollInput, std::tuple< l1t::HGCalTriggerCellBxCollection, l1t::HGCalTriggerSumsBxCollection, l1t::HGCalConcentratorDataBxCollection > &triggerCollOutput, const edm::EventSetup &es) override
Definition: HGCalConcentratorProcessorSelection.cc:55
HGCalConcentratorProcessorSelection::selectionType_
std::vector< SelectionType > selectionType_
Definition: HGCalConcentratorProcessorSelection.h:40
HGCalTriggerGeometryBase::getModuleSize
virtual unsigned getModuleSize(const unsigned module_id) const =0
HGCalProcessorBaseT
Definition: HGCalProcessorBaseT.h:10
muonSelectionTypeValueMapProducer_cff.selectionType
selectionType
Definition: muonSelectionTypeValueMapProducer_cff.py:6
HGCalConcentratorProcessorSelection::bestChoiceImpl_
std::unique_ptr< HGCalConcentratorBestChoiceImpl > bestChoiceImpl_
Definition: HGCalConcentratorProcessorSelection.h:43