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  coarsenTriggerCells_(conf.getParameter<std::vector<unsigned>>("coarsenTriggerCells")),
12  selectionType_(kNSubDetectors_) {
13  std::vector<std::string> selectionType(conf.getParameter<std::vector<std::string>>("Method"));
15  throw cms::Exception("HGCTriggerParameterError")
16  << "Inconsistent number of sub-detectors (should be " << kNSubDetectors_ << ")";
17  }
18 
19  for (int subdet = 0; subdet < kNSubDetectors_; subdet++) {
20  if (selectionType[subdet] == "thresholdSelect") {
22  if (!thresholdImpl_)
23  thresholdImpl_ = std::make_unique<HGCalConcentratorThresholdImpl>(conf);
24  if (!trigSumImpl_)
25  trigSumImpl_ = std::make_unique<HGCalConcentratorTrigSumImpl>(conf);
26  } else if (selectionType[subdet] == "bestChoiceSelect") {
28  if (!bestChoiceImpl_)
29  bestChoiceImpl_ = std::make_unique<HGCalConcentratorBestChoiceImpl>(conf);
30  if (!trigSumImpl_)
31  trigSumImpl_ = std::make_unique<HGCalConcentratorTrigSumImpl>(conf);
32  } else if (selectionType[subdet] == "superTriggerCellSelect") {
35  superTriggerCellImpl_ = std::make_unique<HGCalConcentratorSuperTriggerCellImpl>(conf);
36  } else if (selectionType[subdet] == "noSelection") {
37  selectionType_[subdet] = noSelection;
38  } else {
39  throw cms::Exception("HGCTriggerParameterError")
40  << "Unknown type of concentrator selection '" << selectionType[subdet] << "'";
41  }
42  }
43 
44  if (std::find(coarsenTriggerCells_.begin(), coarsenTriggerCells_.end(), true) != coarsenTriggerCells_.end() ||
46  coarsenerImpl_ = std::make_unique<HGCalConcentratorCoarsenerImpl>(conf);
47  }
48 }
49 
51  const edm::Handle<l1t::HGCalTriggerCellBxCollection>& triggerCellCollInput,
52  std::pair<l1t::HGCalTriggerCellBxCollection, l1t::HGCalTriggerSumsBxCollection>& triggerCollOutput,
53  const edm::EventSetup& es) {
54  if (thresholdImpl_)
55  thresholdImpl_->eventSetup(es);
56  if (bestChoiceImpl_)
57  bestChoiceImpl_->eventSetup(es);
59  superTriggerCellImpl_->eventSetup(es);
60  if (coarsenerImpl_)
61  coarsenerImpl_->eventSetup(es);
62  if (trigSumImpl_)
63  trigSumImpl_->eventSetup(es);
65 
66  auto& triggerCellCollOutput = triggerCollOutput.first;
67  auto& triggerSumCollOutput = triggerCollOutput.second;
68 
69  const l1t::HGCalTriggerCellBxCollection& collInput = *triggerCellCollInput;
70 
71  std::unordered_map<uint32_t, std::vector<l1t::HGCalTriggerCell>> tc_modules;
72  for (const auto& trigCell : collInput) {
73  uint32_t module = geometry_->getModuleFromTriggerCell(trigCell.detId());
74  tc_modules[module].push_back(trigCell);
75  }
76 
77  for (const auto& module_trigcell : tc_modules) {
78  std::vector<l1t::HGCalTriggerCell> trigCellVecOutput;
79  std::vector<l1t::HGCalTriggerCell> trigCellVecCoarsened;
80  std::vector<l1t::HGCalTriggerCell> trigCellVecNotSelected;
81  std::vector<l1t::HGCalTriggerSums> trigSumsVecOutput;
82 
83  int thickness = triggerTools_.thicknessIndex(module_trigcell.second.at(0).detId(), true);
84 
85  HGCalTriggerTools::SubDetectorType subdet = triggerTools_.getSubDetectorType(module_trigcell.second.at(0).detId());
86 
88  coarsenerImpl_->coarsen(module_trigcell.second, trigCellVecCoarsened);
89 
90  switch (selectionType_[subdet]) {
91  case thresholdSelect:
92  thresholdImpl_->select(trigCellVecCoarsened, trigCellVecOutput, trigCellVecNotSelected);
93  break;
94  case bestChoiceSelect:
95  if (triggerTools_.isEm(module_trigcell.first)) {
96  bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
97  geometry_->getModuleSize(module_trigcell.first),
98  module_trigcell.second,
99  trigCellVecOutput,
100  trigCellVecNotSelected);
101  } else {
102  bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
103  geometry_->getModuleSize(module_trigcell.first),
104  trigCellVecCoarsened,
105  trigCellVecOutput,
106  trigCellVecNotSelected);
107  }
108  break;
110  superTriggerCellImpl_->select(trigCellVecCoarsened, trigCellVecOutput);
111  break;
112  case noSelection:
113  trigCellVecOutput = trigCellVecCoarsened;
114  break;
115  default:
116  // Should not happen, selection type checked in constructor
117  break;
118  }
119 
120  } else {
121  switch (selectionType_[subdet]) {
122  case thresholdSelect:
123  thresholdImpl_->select(module_trigcell.second, trigCellVecOutput, trigCellVecNotSelected);
124  break;
125  case bestChoiceSelect:
126  bestChoiceImpl_->select(geometry_->getLinksInModule(module_trigcell.first),
127  geometry_->getModuleSize(module_trigcell.first),
128  module_trigcell.second,
129  trigCellVecOutput,
130  trigCellVecNotSelected);
131  break;
133  superTriggerCellImpl_->select(module_trigcell.second, trigCellVecOutput);
134  break;
135  case noSelection:
136  trigCellVecOutput = module_trigcell.second;
137  break;
138  default:
139  // Should not happen, selection type checked in constructor
140  break;
141  }
142  }
143 
144  // trigger sum
145  if (trigSumImpl_) {
146  trigSumImpl_->doSum(module_trigcell.first, trigCellVecNotSelected, trigSumsVecOutput);
147  }
148 
149  for (const auto& trigCell : trigCellVecOutput) {
150  triggerCellCollOutput.push_back(0, trigCell);
151  }
152  for (const auto& trigSums : trigSumsVecOutput) {
153  triggerSumCollOutput.push_back(0, trigSums);
154  }
155  }
156 }
HGCalTriggerTools::eventSetup
void eventSetup(const edm::EventSetup &)
Definition: HGCalTriggerTools.cc:35
electrons_cff.bool
bool
Definition: electrons_cff.py:372
HGCalConcentratorProcessorSelection::coarsenTriggerCells_
std::vector< unsigned > coarsenTriggerCells_
Definition: HGCalConcentratorProcessorSelection.h:30
HGCalConcentratorProcessorSelection::kHighDensityThickness_
static constexpr int kHighDensityThickness_
Definition: HGCalConcentratorProcessorSelection.h:31
HGCalConcentratorProcessorSelection::thresholdImpl_
std::unique_ptr< HGCalConcentratorThresholdImpl > thresholdImpl_
Definition: HGCalConcentratorProcessorSelection.h:36
HGCalConcentratorProcessorSelection::kNSubDetectors_
static constexpr int kNSubDetectors_
Definition: HGCalConcentratorProcessorSelection.h:32
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:17
HGCalConcentratorProcessorSelection::fixedDataSizePerHGCROC_
bool fixedDataSizePerHGCROC_
Definition: HGCalConcentratorProcessorSelection.h:29
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:38
HGCalTriggerGeometryBase::getLinksInModule
virtual unsigned getLinksInModule(const unsigned module_id) const =0
BXVector
Definition: BXVector.h:15
HGCalConcentratorProcessorSelection::bestChoiceSelect
Definition: HGCalConcentratorProcessorSelection.h:19
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:114
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::superTriggerCellSelect
Definition: HGCalConcentratorProcessorSelection.h:19
edm::ParameterSet
Definition: ParameterSet.h:36
edmplugin::PluginFactory
Definition: PluginFactory.h:34
HGCalConcentratorProcessorSelection::coarsenerImpl_
std::unique_ptr< HGCalConcentratorCoarsenerImpl > coarsenerImpl_
Definition: HGCalConcentratorProcessorSelection.h:39
HGCalProcessorBaseT::geometry_
const HGCalTriggerGeometryBase * geometry_
Definition: HGCalProcessorBaseT.h:24
HGCDigiCollections.h
edm::EventSetup
Definition: EventSetup.h:57
HGCalConcentratorProcessorSelection.h
module
Definition: vlib.h:198
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HGCalConcentratorProcessorSelection::trigSumImpl_
std::unique_ptr< HGCalConcentratorTrigSumImpl > trigSumImpl_
Definition: HGCalConcentratorProcessorSelection.h:40
HGCalTriggerGeometryBase::getModuleFromTriggerCell
virtual unsigned getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const =0
std
Definition: JetResolutionObject.h:76
HGCalTriggerTools::SubDetectorType
SubDetectorType
Definition: HGCalTriggerTools.h:88
Exception
Definition: hltDiff.cc:246
HGCalConcentratorProcessorSelection::triggerTools_
HGCalTriggerTools triggerTools_
Definition: HGCalConcentratorProcessorSelection.h:42
HGCalConcentratorProcessorSelection::noSelection
Definition: HGCalConcentratorProcessorSelection.h:19
HGCalConcentratorProcessorSelection::thresholdSelect
Definition: HGCalConcentratorProcessorSelection.h:19
HGCalConcentratorProcessorSelection::run
void run(const edm::Handle< l1t::HGCalTriggerCellBxCollection > &triggerCellCollInput, std::pair< l1t::HGCalTriggerCellBxCollection, l1t::HGCalTriggerSumsBxCollection > &triggerCollOutput, const edm::EventSetup &es) override
Definition: HGCalConcentratorProcessorSelection.cc:50
HGCalConcentratorProcessorSelection::selectionType_
std::vector< SelectionType > selectionType_
Definition: HGCalConcentratorProcessorSelection.h:34
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:37