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 12 of file CaloTowerConstituentsMap.cc.

12  {
13  delete m_reverseItems.load();
14  m_reverseItems = nullptr;
15 }

References m_reverseItems.

◆ CaloTowerConstituentsMap() [2/2]

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

Definition at line 16 of file CaloTowerConstituentsMap.cc.

17  : m_hcaltopo(hcaltopo),
18  m_cttopo(cttopo),
19  standardHB_(false),
20  standardHE_(false),
21  standardHF_(false),
22  standardHO_(false),
23  standardEB_(false),
24  m_reverseItems(nullptr) {}

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 53 of file CaloTowerConstituentsMap.cc.

53  {
54  if (m_items.find(cell) != m_items.end()) {
55  throw cms::Exception("CaloTowers") << "Cell with id " << std::hex << cell.rawId() << std::dec
56  << " is already mapped to a CaloTower " << m_items.find(cell)->tower
57  << std::endl;
58  }
59  m_items.emplace_back(MapItem(cell, tower));
60 }

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

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

◆ 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 69 of file CaloTowerConstituentsMap.cc.

69  {
70 #ifdef EDM_ML_DEBUG
71  std::cout << "Get constituent of " << std::hex << id.rawId() << std::dec << " ID " << id << " ieta " << id.ieta()
72  << std::endl;
73 #endif
74  std::vector<DetId> items;
75  if (id.ieta() == 0)
76  return items;
77 
78  // build reverse map if needed
79  if (!m_reverseItems.load(std::memory_order_acquire)) {
80  std::unique_ptr<std::multimap<CaloTowerDetId, DetId>> ptr{new std::multimap<CaloTowerDetId, DetId>};
81  for (auto m_item : m_items)
82  ptr->insert(std::pair<CaloTowerDetId, DetId>(m_item.tower, m_item.cell));
83  std::multimap<CaloTowerDetId, DetId>* expected = nullptr;
84  if (m_reverseItems.compare_exchange_strong(expected, ptr.get(), std::memory_order_acq_rel)) {
85  ptr.release();
86  }
87  }
88 
90  std::multimap<CaloTowerDetId, DetId>::const_iterator j;
91  auto range = (*m_reverseItems.load(std::memory_order_acquire)).equal_range(id);
92  for (j = range.first; j != range.second; j++)
93  items.emplace_back(j->second);
94 
95  // dealing with topo dependency...
96  //use cttopo when dealing with calotower detids
97  int nd, sd;
98  int hcal_ieta = m_cttopo->convertCTtoHcal(id.ietaAbs());
99 
100  if (standardHB_) {
101  if (id.ietaAbs() <= m_cttopo->lastHBRing()) {
102  m_hcaltopo->depthBinInformation(HcalBarrel, hcal_ieta, id.iphi(), id.zside(), nd, sd);
103  for (int i = 0; i < nd; i++) {
105  HcalDetId hid =
106  m_hcaltopo->mergedDepthDetId(HcalDetId(HcalBarrel, hcal_ieta * id.zside(), id.iphi(), i + sd));
107  if (std::find(items.begin(), items.end(), hid) == items.end()) {
108  items.emplace_back(hid);
109 #ifdef EDM_ML_DEBUG
110  std::cout << id << " Depth " << i << ":" << i + sd << " " << hid << "\n";
111 #endif
112  }
113  } else {
114  HcalDetId hid(HcalBarrel, hcal_ieta * id.zside(), id.iphi(), i + sd);
115  items.emplace_back(hid);
116 #ifdef EDM_ML_DEBUG
117  std::cout << id << " Depth " << i << ":" << i + sd << " " << hid << "\n";
118 #endif
119  }
120  }
121  }
122  }
123  if (standardHO_) {
124  if (id.ietaAbs() <= m_cttopo->lastHORing()) {
125  m_hcaltopo->depthBinInformation(HcalOuter, hcal_ieta, id.iphi(), id.zside(), nd, sd);
126  for (int i = 0; i < nd; i++) {
127  HcalDetId hid(HcalOuter, hcal_ieta * id.zside(), id.iphi(), i + sd);
128  items.emplace_back(hid);
129 #ifdef EDM_ML_DEBUG
130  std::cout << id << " Depth " << i << ":" << i + sd << " " << hid << "\n";
131 #endif
132  }
133  }
134  }
135  if (standardHE_) {
136  if (id.ietaAbs() >= m_cttopo->firstHERing() && id.ietaAbs() <= m_cttopo->lastHERing()) {
137  m_hcaltopo->depthBinInformation(HcalEndcap, hcal_ieta, id.iphi(), id.zside(), nd, sd);
138  for (int i = 0; i < nd; i++) {
140  HcalDetId hid =
141  m_hcaltopo->mergedDepthDetId(HcalDetId(HcalEndcap, hcal_ieta * id.zside(), id.iphi(), i + sd));
142  if (std::find(items.begin(), items.end(), hid) == items.end()) {
143  items.emplace_back(hid);
144 #ifdef EDM_ML_DEBUG
145  std::cout << id << " Depth " << i << ":" << i + sd << " " << hid << "\n";
146 #endif
147  }
148  } else {
149  HcalDetId hid(HcalEndcap, hcal_ieta * id.zside(), id.iphi(), i + sd);
150  items.emplace_back(hid);
151 #ifdef EDM_ML_DEBUG
152  std::cout << id << " Depth " << i << ":" << i + sd << " " << hid << "\n";
153 #endif
154  }
155  }
156  }
157  }
158  if (standardHF_) {
159  if (id.ietaAbs() >= m_cttopo->firstHFRing() && id.ietaAbs() <= m_cttopo->lastHFRing()) {
160  m_hcaltopo->depthBinInformation(HcalForward, hcal_ieta, id.iphi(), id.zside(), nd, sd);
161  for (int i = 0; i < nd; i++) {
162  HcalDetId hid(HcalForward, hcal_ieta * id.zside(), id.iphi(), i + sd);
163  items.emplace_back(hid);
164 #ifdef EDM_ML_DEBUG
165  std::cout << id << " Depth " << i << ":" << i + sd << " " << hid << "\n";
166 #endif
167  }
168  // special handling for first HF tower
169  if (id.ietaAbs() == m_cttopo->firstHFRing()) {
170  int hcal_ieta2 = hcal_ieta - 1;
171  m_hcaltopo->depthBinInformation(HcalForward, hcal_ieta2, id.iphi(), id.zside(), nd, sd);
172  for (int i = 0; i < nd; i++) {
173  HcalDetId hid(HcalForward, hcal_ieta2 * id.zside(), id.iphi(), i + sd);
174  items.emplace_back(hid);
175 #ifdef EDM_ML_DEBUG
176  std::cout << id << " Depth " << i << ":" << i + sd << " " << hid << "\n";
177 #endif
178  }
179  }
180  }
181  }
182  if (standardEB_ && hcal_ieta <= EBDetId::MAX_IETA / 5) {
183  HcalDetId hid(HcalBarrel, hcal_ieta * id.zside(), id.iphi(), 1); // for the limits
184  int etaMin, etaMax;
185  if (hid.zside() == -1) {
186  etaMin = hid.crystal_ieta_high();
187  etaMax = hid.crystal_ieta_low();
188  } else {
189  etaMin = hid.crystal_ieta_low();
190  etaMax = hid.crystal_ieta_high();
191  }
192  for (int ie = etaMin; ie <= etaMax; ie++)
193  for (int ip = hid.crystal_iphi_low(); ip <= hid.crystal_iphi_high(); ip++)
194  items.emplace_back(EBDetId(ie, ip));
195  }
196  return items;
197 }

References CaloTowerTopology::convertCTtoHcal(), gather_cfg::cout, 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, LEDCalibrationChannels::ieta, LEDCalibrationChannels::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, sd, standardEB_, standardHB_, standardHE_, standardHF_, standardHO_, HcalDetId::zside(), and ecaldqm::zside().

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

◆ sort()

void CaloTowerConstituentsMap::sort ( )

done adding to the association

Definition at line 62 of file CaloTowerConstituentsMap.cc.

62  {
63  m_items.sort();
64 
65  // for (auto const & it : m_items)
66  // std::cout << std::hex << it.cell.rawId() << " " << it.tower.rawId() << std::dec << std::endl;
67 }

References 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 26 of file CaloTowerConstituentsMap.cc.

26  {
27  CaloTowerDetId tid; // null to start with
28 
30  if (i != m_items.end())
31  tid = i->tower;
32 
33  //use hcaltopo when dealing with hcal detids
34  if (tid.null()) {
35  if (id.det() == DetId::Hcal) {
36  HcalDetId hid(id);
37  if ((hid.subdet() == HcalBarrel && standardHB_) || (hid.subdet() == HcalEndcap && standardHE_) ||
38  (hid.subdet() == HcalOuter && standardHO_) || (hid.subdet() == HcalForward && standardHF_)) {
39  tid = CaloTowerDetId(m_cttopo->convertHcaltoCT(hid.ietaAbs(), hid.subdet()) * hid.zside(), hid.iphi());
40  }
41  } else if (id.det() == DetId::Ecal) {
42  EcalSubdetector esd = (EcalSubdetector)id.subdetId();
43  if (esd == EcalBarrel && standardEB_) {
44  EBDetId ebid(id);
45  tid = CaloTowerDetId(ebid.tower_ieta(), ebid.tower_iphi());
46  }
47  }
48  }
49 
50  return tid;
51 }

References CaloTowerTopology::convertHcaltoCT(), DetId::Ecal, EcalBarrel, DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, mps_fire::i, HcalDetId::ietaAbs(), 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().

◆ useStandardEB()

void CaloTowerConstituentsMap::useStandardEB ( bool  use = true)

add standard (hardcoded) EB items?

Definition at line 203 of file CaloTowerConstituentsMap.cc.

203 { standardEB_ = use; }

References standardEB_.

◆ useStandardHB()

void CaloTowerConstituentsMap::useStandardHB ( bool  use = true)

add standard (hardcoded) HB items?

Definition at line 199 of file CaloTowerConstituentsMap.cc.

199 { standardHB_ = use; }

References standardHB_.

◆ useStandardHE()

void CaloTowerConstituentsMap::useStandardHE ( bool  use = true)

add standard (hardcoded) HE items?

Definition at line 200 of file CaloTowerConstituentsMap.cc.

200 { standardHE_ = use; }

References standardHE_.

◆ useStandardHF()

void CaloTowerConstituentsMap::useStandardHF ( bool  use = true)

add standard (hardcoded) HF items?

Definition at line 202 of file CaloTowerConstituentsMap.cc.

202 { standardHF_ = use; }

References standardHF_.

◆ useStandardHO()

void CaloTowerConstituentsMap::useStandardHO ( bool  use = true)

add standard (hardcoded) HO items?

Definition at line 201 of file CaloTowerConstituentsMap.cc.

201 { standardHO_ = use; }

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().

HcalDetId::crystal_ieta_high
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
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
mps_fire.i
i
Definition: mps_fire.py:428
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
CaloTowerTopology::firstHFRing
int firstHFRing() const
Definition: CaloTowerTopology.h:40
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
EBDetId
Definition: EBDetId.h:17
HcalDetId::crystal_iphi_low
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
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DetId::Hcal
Definition: DetId.h:28
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
if
if(0==first)
Definition: CAHitNtupletGeneratorKernelsImpl.h:58
CaloTowerTopology::lastHORing
int lastHORing() const
Definition: CaloTowerTopology.h:43
DetId::null
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
HcalTopology::mergedDepthDetId
HcalDetId mergedDepthDetId(const HcalDetId &id) const
Definition: HcalTopology.h:166
CaloTowerTopology::firstHERing
int firstHERing() const
Definition: CaloTowerTopology.h:38
HcalBarrel
Definition: HcalAssistant.h:33
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
HcalTopology::getMergePositionFlag
bool getMergePositionFlag() const
Definition: HcalTopology.h:167
EcalBarrel
Definition: EcalSubdetector.h:10
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
CaloTowerConstituentsMap::m_hcaltopo
const HcalTopology * m_hcaltopo
Definition: CaloTowerConstituentsMap.h:48
CaloTowerConstituentsMap::standardHO_
bool standardHO_
Definition: CaloTowerConstituentsMap.h:54
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
CaloTowerTopology::convertHcaltoCT
int convertHcaltoCT(int hcal_ieta, HcalSubdetector subdet) const
Definition: CaloTowerTopology.cc:79
CaloTowerTopology::lastHFRing
int lastHFRing() const
Definition: CaloTowerTopology.h:41
CaloTowerConstituentsMap::m_cttopo
const CaloTowerTopology * m_cttopo
Definition: CaloTowerConstituentsMap.h:49
HcalOuter
Definition: HcalAssistant.h:35
CaloTowerConstituentsMap::standardHF_
bool standardHF_
Definition: CaloTowerConstituentsMap.h:53
CaloTowerConstituentsMap::standardHB_
bool standardHB_
Definition: CaloTowerConstituentsMap.h:51
CaloTowerConstituentsMap::standardEB_
bool standardEB_
Definition: CaloTowerConstituentsMap.h:55
CaloTowerConstituentsMap::standardHE_
bool standardHE_
Definition: CaloTowerConstituentsMap.h:52
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HcalDetId
Definition: HcalDetId.h:12
CaloTowerTopology::lastHERing
int lastHERing() const
Definition: CaloTowerTopology.h:39
HcalTopology::depthBinInformation
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
Definition: HcalTopology.cc:817
HcalDetId::crystal_ieta_low
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
DetId::Ecal
Definition: DetId.h:27
HcalForward
Definition: HcalAssistant.h:36
CaloTowerTopology::lastHBRing
int lastHBRing() const
Definition: CaloTowerTopology.h:37
CaloTowerTopology::convertCTtoHcal
int convertCTtoHcal(int ct_ieta) const
Definition: CaloTowerTopology.cc:67
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HcalEndcap
Definition: HcalAssistant.h:34
Exception
Definition: hltDiff.cc:245
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
CaloTowerConstituentsMap::m_reverseItems
std::atomic< std::multimap< CaloTowerDetId, DetId > * > m_reverseItems
Definition: CaloTowerConstituentsMap.h:66
CaloTowerConstituentsMap::m_items
edm::SortedCollection< MapItem > m_items
Definition: CaloTowerConstituentsMap.h:65
sd
double sd
Definition: CascadeWrapper.h:113
HcalDetId::crystal_iphi_high
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
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HcalDetId::zside
constexpr int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
EBDetId::MAX_IETA
static const int MAX_IETA
Definition: EBDetId.h:136
CaloTowerDetId
Definition: CaloTowerDetId.h:12