CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitTopologyESProducer< CAL > Class Template Reference
Inheritance diagram for ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitTopologyESProducer< CAL >:
edm::ESProducer edm::ESProductResolverFactoryProducer edm::eventsetup::ESProductResolverProvider

Public Member Functions

 PFRecHitTopologyESProducer (edm::ParameterSet const &iConfig)
 
std::unique_ptr< typename CAL::TopologyTypeHost > produce (const typename CAL::TopologyRecordType &iRecord)
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
 ESProducer (ESProducer &&)=delete
 
ESResolverIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (ESProducer &&)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESResolverIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProductResolverFactoryProducer
 ESProductResolverFactoryProducer ()
 
 ESProductResolverFactoryProducer (const ESProductResolverFactoryProducer &)=delete
 
const ESProductResolverFactoryProduceroperator= (const ESProductResolverFactoryProducer &)=delete
 
 ~ESProductResolverFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

uint32_t getNeighbourDetId (const uint32_t detId, const uint32_t direction, const CaloSubdetectorTopology &topo)
 
template<>
uint32_t getNeighbourDetId (const uint32_t detId, const uint32_t direction, const CaloSubdetectorTopology &topo)
 
template<>
uint32_t getNeighbourDetId (const uint32_t detId, const uint32_t direction, const CaloSubdetectorTopology &topo)
 

Private Attributes

const bool cutsFromDB_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeomToken_
 
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcdhcalCutsToken_
 
edm::ESGetToken< HcalTopology, HcalRecNumberingRecordhcalToken_
 

Additional Inherited Members

- Protected Types inherited from edm::ESProductResolverFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from edm::ESProducer
ESConsumesInfoconsumesInfoPushBackNew ()
 
unsigned int consumesInfoSize () const
 
template<typename CallbackT , typename TList , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
 
template<typename CallbackT , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TDecorator >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProductResolverFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ESProductResolverFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedResolversVector registerResolvers (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 

Detailed Description

template<typename CAL>
class ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitTopologyESProducer< CAL >

Definition at line 30 of file PFRecHitTopologyESProducer.cc.

Constructor & Destructor Documentation

◆ PFRecHitTopologyESProducer()

Definition at line 32 of file PFRecHitTopologyESProducer.cc.

References gpuPixelDoublets::cc, and ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr().

33  : ESProducer(iConfig), cutsFromDB_(iConfig.getParameter<bool>("usePFThresholdsFromDB")) {
34  auto cc = setWhatProduced(this);
35  geomToken_ = cc.consumes();
36  if constexpr (std::is_same_v<CAL, HCAL>) {
37  hcalToken_ = cc.consumes();
38  hcalCutsToken_ = cc.consumes();
39  }
40  }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > hcalToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > hcalCutsToken_

Member Function Documentation

◆ fillDescriptions()

template<typename CAL >
static void ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitTopologyESProducer< CAL >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 42 of file PFRecHitTopologyESProducer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), and submitPVResolutionJobs::desc.

42  {
44  if constexpr (std::is_same_v<CAL, HCAL>)
45  desc.add<bool>("usePFThresholdsFromDB", true);
46  else // only needs to be true for HBHE
47  desc.add<bool>("usePFThresholdsFromDB", false);
48  descriptions.addWithDefaultLabel(desc);
49  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ getNeighbourDetId() [1/3]

template<typename CAL >
uint32_t ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitTopologyESProducer< CAL >::getNeighbourDetId ( const uint32_t  detId,
const uint32_t  direction,
const CaloSubdetectorTopology topo 
)
private

◆ getNeighbourDetId() [2/3]

template<>
uint32_t ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitTopologyESProducer< ECAL >::getNeighbourDetId ( const uint32_t  detId,
const uint32_t  direction,
const CaloSubdetectorTopology topo 
)
private

Definition at line 157 of file PFRecHitTopologyESProducer.cc.

References hcalRecHitTable_cff::detId, CaloSubdetectorTopology::goEast(), CaloSubdetectorTopology::goNorth(), CaloSubdetectorTopology::goSouth(), and CaloSubdetectorTopology::goWest().

159  {
160  // desired order for PF: NORTH, SOUTH, EAST, WEST, NORTHEAST, SOUTHWEST, SOUTHEAST, NORTHWEST
161  if (detId == 0)
162  return 0;
163 
164  if (direction == 0) // NORTH
165  return topo.goNorth(detId); // larger iphi values (except phi boundary)
166  if (direction == 1) // SOUTH
167  return topo.goSouth(detId); // smaller iphi values (except phi boundary)
168  if (direction == 2) // EAST
169  return topo.goEast(detId); // smaller ieta values
170  if (direction == 3) // WEST
171  return topo.goWest(detId); // larger ieta values
172 
173  if (direction == 4) { // NORTHEAST
174  const uint32_t NE = getNeighbourDetId(getNeighbourDetId(detId, 0, topo), 2, topo);
175  if (NE)
176  return NE;
177  return getNeighbourDetId(getNeighbourDetId(detId, 2, topo), 0, topo);
178  }
179  if (direction == 5) { // SOUTHWEST
180  const uint32_t SW = getNeighbourDetId(getNeighbourDetId(detId, 1, topo), 3, topo);
181  if (SW)
182  return SW;
183  return getNeighbourDetId(getNeighbourDetId(detId, 3, topo), 1, topo);
184  }
185  if (direction == 6) { // SOUTHEAST
186  const uint32_t ES = getNeighbourDetId(getNeighbourDetId(detId, 2, topo), 1, topo);
187  if (ES)
188  return ES;
189  return getNeighbourDetId(getNeighbourDetId(detId, 1, topo), 2, topo);
190  }
191  if (direction == 7) { // NORTHWEST
192  const uint32_t WN = getNeighbourDetId(getNeighbourDetId(detId, 3, topo), 0, topo);
193  if (WN)
194  return WN;
195  return getNeighbourDetId(getNeighbourDetId(detId, 0, topo), 3, topo);
196  }
197  return 0;
198  }
virtual DetId goNorth(const DetId &id) const
virtual DetId goSouth(const DetId &id) const
virtual DetId goEast(const DetId &id) const
uint32_t getNeighbourDetId(const uint32_t detId, const uint32_t direction, const CaloSubdetectorTopology &topo)
virtual DetId goWest(const DetId &id) const

◆ getNeighbourDetId() [3/3]

template<>
uint32_t ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitTopologyESProducer< HCAL >::getNeighbourDetId ( const uint32_t  detId,
const uint32_t  direction,
const CaloSubdetectorTopology topo 
)
private

Definition at line 201 of file PFRecHitTopologyESProducer.cc.

References hcalRecHitTable_cff::detId, ALPAKA_ACCELERATOR_NAMESPACE::particleFlowRecHitProducer::HCAL::getZside(), CaloSubdetectorTopology::goEast(), CaloSubdetectorTopology::goNorth(), CaloSubdetectorTopology::goSouth(), and CaloSubdetectorTopology::goWest().

203  {
204  // desired order for PF: NORTH, SOUTH, EAST, WEST, NORTHEAST, SOUTHWEST, SOUTHEAST, NORTHWEST
205  if (detId == 0)
206  return 0;
207 
208  if (direction == 0) // NORTH
209  return topo.goNorth(detId); // larger iphi values (except phi boundary)
210  if (direction == 1) // SOUTH
211  return topo.goSouth(detId); // smaller iphi values (except phi boundary)
212  if (direction == 2) // EAST
213  return topo.goEast(detId); // smaller ieta values
214  if (direction == 3) // WEST
215  return topo.goWest(detId); // larger ieta values
216 
217  std::pair<uint32_t, uint32_t> directions;
218  if (direction == 4) { // NORTHEAST
219  if (HCAL::getZside(detId) > 0)
220  directions = {2, 0}; // positive eta: east -> move to smaller |ieta| (finner phi granularity) first
221  else
222  directions = {0, 2}; // negative eta: move in phi first then move to east (coarser phi granularity)
223  } else if (direction == 5) { // SOUTHWEST
224  if (HCAL::getZside(detId) > 0)
225  directions = {1, 3}; // positive eta: move in phi first then move to west (coarser phi granularity)
226  else
227  directions = {3, 1}; // negative eta: west -> move to smaller |ieta| (finner phi granularity) first
228  } else if (direction == 6) { // SOUTHEAST
229  if (HCAL::getZside(detId) > 0)
230  directions = {2, 1}; // positive eta: east -> move to smaller |ieta| (finner phi granularity) first
231  else
232  directions = {1, 2}; // negative eta: move in phi first then move to east (coarser phi granularity)
233  } else if (direction == 7) { // NORTHWEST
234  if (HCAL::getZside(detId) > 0)
235  directions = {0, 3}; // positive eta: move in phi first then move to west (coarser phi granularity)
236  else
237  directions = {3, 0}; // negative eta: west -> move to smaller |ieta| (finner phi granularity) first
238  } else
239  return 0;
240  const uint32_t nn1 = getNeighbourDetId(detId, directions.first, topo); // nearest neighbour in direction 1
241  const uint32_t nn2 = getNeighbourDetId(detId, directions.second, topo); // nearest neighbour in direction 2
242  const uint32_t nnn = getNeighbourDetId(nn1, directions.second, topo); // next-to-nearest neighbour
243  if (nnn == nn1 || nnn == nn2) // avoid duplicates
244  return 0;
245  return nnn;
246  }
virtual DetId goNorth(const DetId &id) const
virtual DetId goSouth(const DetId &id) const
virtual DetId goEast(const DetId &id) const
uint32_t getNeighbourDetId(const uint32_t detId, const uint32_t direction, const CaloSubdetectorTopology &topo)
virtual DetId goWest(const DetId &id) const

◆ produce()

template<typename CAL >
std::unique_ptr<typename CAL::TopologyTypeHost> ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitTopologyESProducer< CAL >::produce ( const typename CAL::TopologyRecordType &  iRecord)
inline

Definition at line 51 of file PFRecHitTopologyESProducer.cc.

References cms::cuda::assert(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), hcalRecHitTable_cff::detId, EcalBarrel, spr::find(), relativeConstraints::geom, CaloSubdetectorGeometry::getGeometry(), cms::alpakatools::host(), dqm-mbProfile::log, LogDebug, dqmiodumpmetadata::n, l1tHGCalVFEProducer_cfi::noiseThreshold, and dumpMFGeometry_cfg::prod.

51  {
52  const auto& geom = iRecord.get(geomToken_);
53  auto product = std::make_unique<typename CAL::TopologyTypeHost>(CAL::kSize, cms::alpakatools::host());
54  auto view = product->view();
55  const int calEnums[2] = {CAL::kSubdetectorBarrelId, CAL::kSubdetectorEndcapId};
56  for (const auto subdet : calEnums) {
57  // Construct topology
58  // for HCAL: using dedicated record
59  // for ECAL: from CaloGeometry (separate for barrel and endcap)
60  const CaloSubdetectorGeometry* geo = geom.getSubdetectorGeometry(CAL::kDetectorId, subdet);
61  const CaloSubdetectorTopology* topo;
62  std::variant<EcalBarrelTopology, EcalEndcapTopology> topoVar; // need to store ECAL topology temporarily
63  if constexpr (std::is_same_v<CAL, HCAL>)
64  topo = &iRecord.get(hcalToken_);
65  else if (subdet == EcalSubdetector::EcalBarrel)
66  topo = &topoVar.emplace<EcalBarrelTopology>(geom);
67  else
68  topo = &topoVar.emplace<EcalEndcapTopology>(geom);
69 
70  // Fill product
71  for (auto const detId : geom.getValidDetIds(CAL::kDetectorId, subdet)) {
72  const uint32_t denseId = CAL::detId2denseId(detId);
73  assert(denseId < CAL::kSize);
74 
75  // Fill SoA members with HCAL PF Thresholds from GT
76  if constexpr (std::is_same_v<CAL, HCAL>) {
77  view.cutsFromDB() = false;
78  if (cutsFromDB_) {
79  view.cutsFromDB() = true;
80  const HcalPFCuts& pfCuts = iRecord.get(hcalCutsToken_);
81  const HcalTopology& htopo = iRecord.get(hcalToken_);
82  std::unique_ptr<HcalPFCuts> prod = std::make_unique<HcalPFCuts>(pfCuts);
83  prod->setTopo(&htopo);
84  view.noiseThreshold(denseId) = prod->getValues(detId.rawId())->noiseThreshold();
85  view.seedThreshold(denseId) = prod->getValues(detId.rawId())->seedThreshold();
86  }
87  }
88 
89  const GlobalPoint pos = geo->getGeometry(detId)->getPosition();
90  view.positionX(denseId) = pos.x();
91  view.positionY(denseId) = pos.y();
92  view.positionZ(denseId) = pos.z();
93 
94  for (uint32_t n = 0; n < 8; n++) {
95  uint32_t neighDetId = getNeighbourDetId(detId, n, *topo);
96  if (CAL::detIdInRange(neighDetId))
97  view.neighbours(denseId)(n) = CAL::detId2denseId(neighDetId);
98  else
99  view.neighbours(denseId)(n) = 0xffffffff;
100  }
101  }
102  }
103 
104  // Remove neighbours that are not backward compatible (only for HCAL)
105  if constexpr (std::is_same_v<CAL, HCAL>) {
106  for (const auto subdet : calEnums)
107  for (auto const detId : geom.getValidDetIds(CAL::kDetectorId, subdet)) {
108  const uint32_t denseId = CAL::detId2denseId(detId);
109  for (uint32_t n = 0; n < 8; n++) {
110  if (view.neighbours(denseId)[n] == 0xffffffff)
111  continue;
112  const ::reco::PFRecHitsTopologyNeighbours& neighboursOfNeighbour =
113  view.neighbours(view.neighbours(denseId)[n]);
114  if (std::find(neighboursOfNeighbour.begin(), neighboursOfNeighbour.end(), denseId) ==
115  neighboursOfNeighbour.end())
116  view.neighbours(denseId)[n] = 0xffffffff;
117  }
118  }
119  }
120 
121  // Print results (for debugging)
122  LogDebug("PFRecHitTopologyESProducer").log([&](auto& log) {
123  for (const auto subdet : calEnums)
124  for (const auto detId : geom.getValidDetIds(CAL::kDetectorId, subdet)) {
125  const uint32_t denseId = CAL::detId2denseId(detId);
126  log.format("detId:{} denseId:{} pos:{},{},{} neighbours:{},{},{},{};{},{},{},{}\n",
127  (uint32_t)detId,
128  denseId,
129  view[denseId].positionX(),
130  view[denseId].positionY(),
131  view[denseId].positionZ(),
132  view[denseId].neighbours()(0),
133  view[denseId].neighbours()(1),
134  view[denseId].neighbours()(2),
135  view[denseId].neighbours()(3),
136  view[denseId].neighbours()(4),
137  view[denseId].neighbours()(5),
138  view[denseId].neighbours()(6),
139  view[denseId].neighbours()(7));
140  }
141  });
142 
143  return product;
144  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
assert(be >=bs)
Eigen::Matrix< uint32_t, 8, 1 > PFRecHitsTopologyNeighbours
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > hcalToken_
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
alpaka::DevCpu const & host()
Definition: host.h:14
uint32_t getNeighbourDetId(const uint32_t detId, const uint32_t direction, const CaloSubdetectorTopology &topo)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > hcalCutsToken_
#define LogDebug(id)

Member Data Documentation

◆ cutsFromDB_

template<typename CAL >
const bool ALPAKA_ACCELERATOR_NAMESPACE::PFRecHitTopologyESProducer< CAL >::cutsFromDB_
private

Definition at line 150 of file PFRecHitTopologyESProducer.cc.

◆ geomToken_

Definition at line 147 of file PFRecHitTopologyESProducer.cc.

◆ hcalCutsToken_

Definition at line 149 of file PFRecHitTopologyESProducer.cc.

◆ hcalToken_

Definition at line 148 of file PFRecHitTopologyESProducer.cc.