CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
CaloTowerConstituentsMap Class Reference

#include <CaloTowerConstituentsMap.h>

Classes

struct  MapItem
 

Public Member Functions

void assign (const DetId &cell, const CaloTowerDetId &tower)
 set the association between a DetId and a tower More...
 
 CaloTowerConstituentsMap ()=delete
 
 CaloTowerConstituentsMap (const HcalTopology *hcaltopo, const CaloTowerTopology *cttopo)
 
std::vector< DetIdconstituentsOf (const CaloTowerDetId &id) const
 Get the constituent detids for this tower id ( not yet implemented ) More...
 
void sort ()
 done adding to the association More...
 
CaloTowerDetId towerOf (const DetId &id) const
 Get the tower id for this det id (or null if not known) More...
 
void useStandardEB (bool use=true)
 add standard (hardcoded) EB items? More...
 
void useStandardHB (bool use=true)
 add standard (hardcoded) HB items? More...
 
void useStandardHE (bool use=true)
 add standard (hardcoded) HE items? More...
 
void useStandardHF (bool use=true)
 add standard (hardcoded) HF items? More...
 
void useStandardHO (bool use=true)
 add standard (hardcoded) HO items? More...
 
 ~CaloTowerConstituentsMap ()
 

Private Attributes

const CaloTowerTopologym_cttopo
 
const HcalTopologym_hcaltopo
 
edm::SortedCollection< MapItemm_items
 
std::atomic< std::multimap< CaloTowerDetId, DetId > * > m_reverseItems
 
bool standardEB_
 
bool standardHB_
 
bool standardHE_
 
bool standardHF_
 
bool standardHO_
 

Detailed Description

Author
J. Mans - Minnesota

Definition at line 18 of file CaloTowerConstituentsMap.h.

Constructor & Destructor Documentation

◆ CaloTowerConstituentsMap() [1/2]

CaloTowerConstituentsMap::CaloTowerConstituentsMap ( )
delete

◆ ~CaloTowerConstituentsMap()

CaloTowerConstituentsMap::~CaloTowerConstituentsMap ( )

Definition at line 13 of file CaloTowerConstituentsMap.cc.

References m_reverseItems.

13  {
14  delete m_reverseItems.load();
15  m_reverseItems = nullptr;
16 }
std::atomic< std::multimap< CaloTowerDetId, DetId > * > m_reverseItems

◆ CaloTowerConstituentsMap() [2/2]

CaloTowerConstituentsMap::CaloTowerConstituentsMap ( const HcalTopology hcaltopo,
const CaloTowerTopology cttopo 
)

Definition at line 17 of file CaloTowerConstituentsMap.cc.

18  : m_hcaltopo(hcaltopo),
19  m_cttopo(cttopo),
20  standardHB_(false),
21  standardHE_(false),
22  standardHF_(false),
23  standardHO_(false),
24  standardEB_(false),
25  m_reverseItems(nullptr) {}
const CaloTowerTopology * m_cttopo
std::atomic< std::multimap< CaloTowerDetId, DetId > * > m_reverseItems

Member Function Documentation

◆ assign()

void CaloTowerConstituentsMap::assign ( const DetId cell,
const CaloTowerDetId tower 
)

set the association between a DetId and a tower

Definition at line 54 of file CaloTowerConstituentsMap.cc.

References TauDecayModes::dec, Exception, m_items, DetId::rawId(), and l1tHGCalTowerProducer_cfi::tower.

Referenced by CaloTowerConstituentsMapBuilder::assignEEtoHE(), and CaloTowerConstituentsMapBuilder::parseTextMap().

54  {
55  if (m_items.find(cell) != m_items.end()) {
56  throw cms::Exception("CaloTowers") << "Cell with id " << std::hex << cell.rawId() << std::dec
57  << " is already mapped to a CaloTower " << m_items.find(cell)->tower
58  << std::endl;
59  }
60  m_items.emplace_back(MapItem(cell, tower));
61 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::SortedCollection< MapItem > m_items

◆ constituentsOf()

std::vector< DetId > CaloTowerConstituentsMap::constituentsOf ( const CaloTowerDetId id) const

Get the constituent detids for this tower id ( not yet implemented )

copy from the items map

Definition at line 70 of file CaloTowerConstituentsMap.cc.

References CaloTowerTopology::convertCTtoHcal(), HcalDetId::crystal_ieta_high(), HcalDetId::crystal_ieta_low(), HcalDetId::crystal_iphi_high(), HcalDetId::crystal_iphi_low(), TauDecayModes::dec, HcalTopology::depthBinInformation(), ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, spr::find(), CaloTowerTopology::firstHERing(), CaloTowerTopology::firstHFRing(), HcalTopology::getMergePositionFlag(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, mps_fire::i, hcalRecHitTable_cff::ieta, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::ietaAbs(), hcalRecHitTable_cff::iphi, mps_monitormerge::items, dqmiolumiharvest::j, CaloTowerTopology::lastHBRing(), CaloTowerTopology::lastHERing(), CaloTowerTopology::lastHFRing(), CaloTowerTopology::lastHORing(), m_cttopo, m_hcaltopo, m_items, m_reverseItems, EBDetId::MAX_IETA, HcalTopology::mergedDepthDetId(), FastTimerService_cff::range, standardEB_, standardHB_, standardHE_, standardHF_, standardHO_, HcalDetId::zside(), and ecaldqm::zside().

Referenced by spr::eECALmatrix(), CaloTowersCreationAlgo::hadShwrPos(), egamma::hasActiveHcal(), CaloTowersCreationAlgo::makeEcalBadChs(), and CaloTowersCreationAlgo::makeHcalDropChMap().

70  {
71 #ifdef EDM_ML_DEBUG
72  edm::LogVerbatim("CaloTower") << "Get constituent of " << std::hex << id.rawId() << std::dec << " ID " << id
73  << " ieta " << id.ieta();
74 #endif
75  std::vector<DetId> items;
76  if (id.ieta() == 0)
77  return items;
78 
79  // build reverse map if needed
80  if (!m_reverseItems.load(std::memory_order_acquire)) {
81  std::unique_ptr<std::multimap<CaloTowerDetId, DetId>> ptr{new std::multimap<CaloTowerDetId, DetId>};
82  for (auto m_item : m_items)
83  ptr->insert(std::pair<CaloTowerDetId, DetId>(m_item.tower, m_item.cell));
84  std::multimap<CaloTowerDetId, DetId>* expected = nullptr;
85  if (m_reverseItems.compare_exchange_strong(expected, ptr.get(), std::memory_order_acq_rel)) {
86  ptr.release();
87  }
88  }
89 
91  std::multimap<CaloTowerDetId, DetId>::const_iterator j;
92  auto range = (*m_reverseItems.load(std::memory_order_acquire)).equal_range(id);
93  for (j = range.first; j != range.second; j++)
94  items.emplace_back(j->second);
95 
96  // dealing with topo dependency...
97  //use cttopo when dealing with calotower detids
98  int nd, sd;
99  int hcal_ieta = m_cttopo->convertCTtoHcal(id.ietaAbs());
100 
101  if (standardHB_) {
102  if (id.ietaAbs() <= m_cttopo->lastHBRing()) {
103  m_hcaltopo->depthBinInformation(HcalBarrel, hcal_ieta, id.iphi(), id.zside(), nd, sd);
104  for (int i = 0; i < nd; i++) {
106  HcalDetId hid =
107  m_hcaltopo->mergedDepthDetId(HcalDetId(HcalBarrel, hcal_ieta * id.zside(), id.iphi(), i + sd));
108  if (std::find(items.begin(), items.end(), hid) == items.end()) {
109  items.emplace_back(hid);
110 #ifdef EDM_ML_DEBUG
111  edm::LogVerbatim("CaloTower") << id << " Depth " << i << ":" << i + sd << " " << hid;
112 #endif
113  }
114  } else {
115  HcalDetId hid(HcalBarrel, hcal_ieta * id.zside(), id.iphi(), i + sd);
116  items.emplace_back(hid);
117 #ifdef EDM_ML_DEBUG
118  edm::LogVerbatim("CaloTower") << id << " Depth " << i << ":" << i + sd << " " << hid;
119 #endif
120  }
121  }
122  }
123  }
124  if (standardHO_) {
125  if (id.ietaAbs() <= m_cttopo->lastHORing()) {
126  m_hcaltopo->depthBinInformation(HcalOuter, hcal_ieta, id.iphi(), id.zside(), nd, sd);
127  for (int i = 0; i < nd; i++) {
128  HcalDetId hid(HcalOuter, hcal_ieta * id.zside(), id.iphi(), i + sd);
129  items.emplace_back(hid);
130 #ifdef EDM_ML_DEBUG
131  edm::LogVerbatim("CaloTower") << id << " Depth " << i << ":" << i + sd << " " << hid;
132 #endif
133  }
134  }
135  }
136  if (standardHE_) {
137  if (id.ietaAbs() >= m_cttopo->firstHERing() && id.ietaAbs() <= m_cttopo->lastHERing()) {
138  m_hcaltopo->depthBinInformation(HcalEndcap, hcal_ieta, id.iphi(), id.zside(), nd, sd);
139  for (int i = 0; i < nd; i++) {
141  HcalDetId hid =
142  m_hcaltopo->mergedDepthDetId(HcalDetId(HcalEndcap, hcal_ieta * id.zside(), id.iphi(), i + sd));
143  if (std::find(items.begin(), items.end(), hid) == items.end()) {
144  items.emplace_back(hid);
145 #ifdef EDM_ML_DEBUG
146  edm::LogVerbatim("CaloTower") << id << " Depth " << i << ":" << i + sd << " " << hid;
147 #endif
148  }
149  } else {
150  HcalDetId hid(HcalEndcap, hcal_ieta * id.zside(), id.iphi(), i + sd);
151  items.emplace_back(hid);
152 #ifdef EDM_ML_DEBUG
153  edm::LogVerbatim("CaloTower") << id << " Depth " << i << ":" << i + sd << " " << hid;
154 #endif
155  }
156  }
157  }
158  }
159  if (standardHF_) {
160  if (id.ietaAbs() >= m_cttopo->firstHFRing() && id.ietaAbs() <= m_cttopo->lastHFRing()) {
161  m_hcaltopo->depthBinInformation(HcalForward, hcal_ieta, id.iphi(), id.zside(), nd, sd);
162  for (int i = 0; i < nd; i++) {
163  HcalDetId hid(HcalForward, hcal_ieta * id.zside(), id.iphi(), i + sd);
164  items.emplace_back(hid);
165 #ifdef EDM_ML_DEBUG
166  edm::LogVerbatim("CaloTower") << id << " Depth " << i << ":" << i + sd << " " << hid;
167 #endif
168  }
169  // special handling for first HF tower
170  if (id.ietaAbs() == m_cttopo->firstHFRing()) {
171  int hcal_ieta2 = hcal_ieta - 1;
172  m_hcaltopo->depthBinInformation(HcalForward, hcal_ieta2, id.iphi(), id.zside(), nd, sd);
173  for (int i = 0; i < nd; i++) {
174  HcalDetId hid(HcalForward, hcal_ieta2 * id.zside(), id.iphi(), i + sd);
175  items.emplace_back(hid);
176 #ifdef EDM_ML_DEBUG
177  edm::LogVerbatim("CaloTower") << id << " Depth " << i << ":" << i + sd << " " << hid;
178 #endif
179  }
180  }
181  }
182  }
183  if (standardEB_ && hcal_ieta <= EBDetId::MAX_IETA / 5) {
184  HcalDetId hid(HcalBarrel, hcal_ieta * id.zside(), id.iphi(), 1); // for the limits
185  int etaMin, etaMax;
186  if (hid.zside() == -1) {
187  etaMin = hid.crystal_ieta_high();
188  etaMax = hid.crystal_ieta_low();
189  } else {
190  etaMin = hid.crystal_ieta_low();
191  etaMax = hid.crystal_ieta_high();
192  }
193  for (int ie = etaMin; ie <= etaMax; ie++)
194  for (int ip = hid.crystal_iphi_low(); ip <= hid.crystal_iphi_high(); ip++)
195  items.emplace_back(EBDetId(ie, ip));
196  }
197  return items;
198 }
Log< level::Info, true > LogVerbatim
bool getMergePositionFlag() const
Definition: HcalTopology.h:167
constexpr int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
const CaloTowerTopology * m_cttopo
constexpr int crystal_iphi_high() const
get the largest crystal_iphi of the crystal in front of this tower (HB and HE tower 17 only) ...
Definition: HcalDetId.h:267
int zside(DetId const &)
int lastHFRing() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int lastHERing() const
int lastHORing() const
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
int firstHERing() const
int convertCTtoHcal(int ct_ieta) const
constexpr int crystal_ieta_high() const
get the largest crystal_ieta of the crystal in front of this tower (HB and HE tower 17 only) ...
Definition: HcalDetId.h:259
constexpr int crystal_ieta_low() const
get the smallest crystal_ieta of the crystal in front of this tower (HB and HE tower 17 only) ...
Definition: HcalDetId.h:257
void depthBinInformation(HcalSubdetector subdet, int etaRing, int iphi, int zside, int &nDepthBins, int &startingBin) const
finds the number of depth bins and which is the number to start with
static const int MAX_IETA
Definition: EBDetId.h:136
HcalDetId mergedDepthDetId(const HcalDetId &id) const
Definition: HcalTopology.h:166
int firstHFRing() const
constexpr int crystal_iphi_low() const
get the smallest crystal_iphi of the crystal in front of this tower (HB and HE tower 17 only) ...
Definition: HcalDetId.h:261
std::atomic< std::multimap< CaloTowerDetId, DetId > * > m_reverseItems
int lastHBRing() const
edm::SortedCollection< MapItem > m_items

◆ sort()

void CaloTowerConstituentsMap::sort ( )

done adding to the association

Definition at line 63 of file CaloTowerConstituentsMap.cc.

References m_items.

63  {
64  m_items.sort();
65 
66  // for (auto const & it : m_items)
67  // edm::LogVerbatim("CaloTower") << std::hex << it.cell.rawId() << " " << it.tower.rawId() << std::dec;
68 }
edm::SortedCollection< MapItem > m_items

◆ towerOf()

CaloTowerDetId CaloTowerConstituentsMap::towerOf ( const DetId id) const

Get the tower id for this det id (or null if not known)

Definition at line 27 of file CaloTowerConstituentsMap.cc.

References CaloTowerTopology::convertHcaltoCT(), DetId::Ecal, EcalBarrel, DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, mps_fire::i, HcalDetId::ietaAbs(), ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), HcalDetId::iphi(), m_cttopo, m_items, DetId::null(), standardEB_, standardHB_, standardHE_, standardHF_, standardHO_, HcalDetId::subdet(), EBDetId::tower_ieta(), EBDetId::tower_iphi(), and HcalDetId::zside().

Referenced by EGHcalRecHitSelector::addDetIds(), CaloTowersCreationAlgo::assignHitEcal(), CaloTowersCreationAlgo::assignHitHcal(), spr::eECALmatrix(), CaloTowersCreationAlgo::makeHcalDropChMap(), PhysicsTowerOrganizer::PhysicsTowerOrganizer(), CaloTowersCreationAlgo::rescale(), and egamma::towerOf().

27  {
28  CaloTowerDetId tid; // null to start with
29 
31  if (i != m_items.end())
32  tid = i->tower;
33 
34  //use hcaltopo when dealing with hcal detids
35  if (tid.null()) {
36  if (id.det() == DetId::Hcal) {
37  HcalDetId hid(id);
38  if ((hid.subdet() == HcalBarrel && standardHB_) || (hid.subdet() == HcalEndcap && standardHE_) ||
39  (hid.subdet() == HcalOuter && standardHO_) || (hid.subdet() == HcalForward && standardHF_)) {
40  tid = CaloTowerDetId(m_cttopo->convertHcaltoCT(hid.ietaAbs(), hid.subdet()) * hid.zside(), hid.iphi());
41  }
42  } else if (id.det() == DetId::Ecal) {
43  EcalSubdetector esd = (EcalSubdetector)id.subdetId();
44  if (esd == EcalBarrel && standardEB_) {
45  EBDetId ebid(id);
46  tid = CaloTowerDetId(ebid.tower_ieta(), ebid.tower_iphi());
47  }
48  }
49  }
50 
51  return tid;
52 }
std::vector< T >::const_iterator const_iterator
const CaloTowerTopology * m_cttopo
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
int convertHcaltoCT(int hcal_ieta, HcalSubdetector subdet) const
EcalSubdetector
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
edm::SortedCollection< MapItem > m_items

◆ useStandardEB()

void CaloTowerConstituentsMap::useStandardEB ( bool  use = true)

add standard (hardcoded) EB items?

Definition at line 204 of file CaloTowerConstituentsMap.cc.

References standardEB_.

◆ useStandardHB()

void CaloTowerConstituentsMap::useStandardHB ( bool  use = true)

add standard (hardcoded) HB items?

Definition at line 200 of file CaloTowerConstituentsMap.cc.

References standardHB_.

◆ useStandardHE()

void CaloTowerConstituentsMap::useStandardHE ( bool  use = true)

add standard (hardcoded) HE items?

Definition at line 201 of file CaloTowerConstituentsMap.cc.

References standardHE_.

◆ useStandardHF()

void CaloTowerConstituentsMap::useStandardHF ( bool  use = true)

add standard (hardcoded) HF items?

Definition at line 203 of file CaloTowerConstituentsMap.cc.

References standardHF_.

◆ useStandardHO()

void CaloTowerConstituentsMap::useStandardHO ( bool  use = true)

add standard (hardcoded) HO items?

Definition at line 202 of file CaloTowerConstituentsMap.cc.

References standardHO_.

Member Data Documentation

◆ m_cttopo

const CaloTowerTopology* CaloTowerConstituentsMap::m_cttopo
private

Definition at line 49 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf(), and towerOf().

◆ m_hcaltopo

const HcalTopology* CaloTowerConstituentsMap::m_hcaltopo
private

Definition at line 48 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf().

◆ m_items

edm::SortedCollection<MapItem> CaloTowerConstituentsMap::m_items
private

Definition at line 65 of file CaloTowerConstituentsMap.h.

Referenced by assign(), constituentsOf(), sort(), and towerOf().

◆ m_reverseItems

std::atomic<std::multimap<CaloTowerDetId, DetId>*> CaloTowerConstituentsMap::m_reverseItems
mutableprivate

Definition at line 66 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf(), and ~CaloTowerConstituentsMap().

◆ standardEB_

bool CaloTowerConstituentsMap::standardEB_
private

Definition at line 55 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf(), towerOf(), and useStandardEB().

◆ standardHB_

bool CaloTowerConstituentsMap::standardHB_
private

Definition at line 51 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf(), towerOf(), and useStandardHB().

◆ standardHE_

bool CaloTowerConstituentsMap::standardHE_
private

Definition at line 52 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf(), towerOf(), and useStandardHE().

◆ standardHF_

bool CaloTowerConstituentsMap::standardHF_
private

Definition at line 53 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf(), towerOf(), and useStandardHF().

◆ standardHO_

bool CaloTowerConstituentsMap::standardHO_
private

Definition at line 54 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf(), towerOf(), and useStandardHO().