CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 *topology)
 
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

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

Detailed Description

Author
J. Mans - Minnesota

Definition at line 17 of file CaloTowerConstituentsMap.h.

Constructor & Destructor Documentation

CaloTowerConstituentsMap::CaloTowerConstituentsMap ( )
delete
CaloTowerConstituentsMap::~CaloTowerConstituentsMap ( )

Definition at line 9 of file CaloTowerConstituentsMap.cc.

References m_reverseItems.

9  {
10  delete m_reverseItems.load();
11  m_reverseItems = nullptr;
12 }
std::atomic< std::multimap< CaloTowerDetId, DetId > * > m_reverseItems
CaloTowerConstituentsMap::CaloTowerConstituentsMap ( const HcalTopology topology)

Definition at line 13 of file CaloTowerConstituentsMap.cc.

13  :
14  m_topology(topology),
15  standardHB_(false),
16  standardHE_(false),
17  standardHF_(false),
18  standardHO_(false),
19  standardEB_(false),
20  m_reverseItems(nullptr)
21 {
22 }
std::atomic< std::multimap< CaloTowerDetId, DetId > * > m_reverseItems

Member Function Documentation

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 edm::hlt::Exception, m_items, and DetId::rawId().

Referenced by 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 << " is already mapped to a CaloTower " << m_items.find(cell)->tower << std::endl;
57  }
58  m_items.push_back(MapItem(cell,tower));
59 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
edm::SortedCollection< MapItem > m_items
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.

References HcalDetId::crystal_ieta_high(), HcalDetId::crystal_ieta_low(), HcalDetId::crystal_iphi_high(), HcalDetId::crystal_iphi_low(), HcalTopology::depthBinInformation(), HcalTopology::firstHERing(), HcalTopology::firstHFRing(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, i, j, HcalTopology::lastHBRing(), HcalTopology::lastHERing(), HcalTopology::lastHFRing(), HcalTopology::lastHORing(), m_items, m_reverseItems, m_topology, EBDetId::MAX_IETA, sd, standardEB_, standardHB_, standardHE_, standardHF_, standardHO_, and HcalDetId::zside().

Referenced by CaloTowersCreationAlgo::makeEcalBadChs().

69  {
70  std::vector<DetId> items;
71 
72  // build reverse map if needed
73  if(!m_reverseItems.load(std::memory_order_acquire)) {
74  std::unique_ptr<std::multimap<CaloTowerDetId,DetId>> ptr{new std::multimap<CaloTowerDetId,DetId>};
75  for (auto i=m_items.begin(); i!=m_items.end(); i++)
76  ptr->insert(std::pair<CaloTowerDetId,DetId>(i->tower,i->cell));
77  std::multimap<CaloTowerDetId,DetId>* expected = nullptr;
78  if(m_reverseItems.compare_exchange_strong(expected, ptr.get(), std::memory_order_acq_rel)) {
79  ptr.release();
80  }
81  }
82 
84  std::multimap<CaloTowerDetId,DetId>::const_iterator j;
85  auto range=(*m_reverseItems.load(std::memory_order_acquire)).equal_range(id);
86  for (j=range.first; j!=range.second; j++)
87  items.push_back(j->second);
88 
89  // dealing with topo dependency...
90  int nd, sd;
91 
92  if (standardHB_) {
93  if (id.ietaAbs()<=m_topology->lastHBRing()) {
94  m_topology->depthBinInformation(HcalBarrel,id.ietaAbs(),nd,sd);
95  for (int i=0; i<nd; i++)
96  items.push_back(HcalDetId(HcalBarrel,id.ieta(),id.iphi(),i+sd));
97  }
98  }
99  if (standardHO_) {
100  if (id.ietaAbs()<=m_topology->lastHORing()) {
101  m_topology->depthBinInformation(HcalOuter,id.ietaAbs(),nd,sd);
102  for (int i=0; i<nd; i++)
103  items.push_back(HcalDetId(HcalOuter,id.ieta(),id.iphi(),i+sd));
104  }
105  }
106  if (standardHE_) {
107  if (id.ietaAbs()>=m_topology->firstHERing() && id.ietaAbs()<=m_topology->lastHERing()) {
108  m_topology->depthBinInformation(HcalEndcap,id.ietaAbs(),nd,sd);
109  for (int i=0; i<nd; i++)
110  items.push_back(HcalDetId(HcalEndcap,id.ieta(),id.iphi(),i+sd));
111  }
112  }
113  if (standardHF_) {
114  if (id.ietaAbs()>m_topology->firstHFRing() && id.ietaAbs()<=m_topology->lastHFRing()) {
115  int ieta=id.ieta();
116  m_topology->depthBinInformation(HcalForward,id.ietaAbs(),nd,sd);
117  for (int i=0; i<nd; i++)
118  items.push_back(HcalDetId(HcalForward,ieta,id.iphi(),i+sd));
119  if (id.ietaAbs() == 30) {
120  ieta = 29*id.zside();
122  for (int i=0; i<nd; i++)
123  items.push_back(HcalDetId(HcalForward,ieta,id.iphi(),i+sd));
124  }
125  }
126  }
127  if (standardEB_ && id.ietaAbs()<=EBDetId::MAX_IETA/5) {
128  HcalDetId hid(HcalBarrel,id.ieta(),id.iphi(),1); // for the limits
129  int etaMin, etaMax;
130  if (hid.zside() == -1) {
131  etaMin = hid.crystal_ieta_high();
132  etaMax = hid.crystal_ieta_low();
133  } else {
134  etaMin = hid.crystal_ieta_low();
135  etaMax = hid.crystal_ieta_high();
136  }
137  for (int ie=etaMin; ie<=etaMax; ie++)
138  for (int ip=hid.crystal_iphi_low(); ip<=hid.crystal_iphi_high(); ip++)
139  items.push_back(EBDetId(ie,ip));
140  }
141  return items;
142 }
int firstHFRing() const
Definition: HcalTopology.h:83
int i
Definition: DBlmapReader.cc:9
int lastHBRing() const
Definition: HcalTopology.h:80
int lastHFRing() const
Definition: HcalTopology.h:84
int j
Definition: DBlmapReader.cc:9
void depthBinInformation(HcalSubdetector subdet, int etaRing, int &nDepthBins, int &startingBin) const
finds the number of depth bins and which is the number to start with
double sd
static const int MAX_IETA
Definition: EBDetId.h:143
int firstHERing() const
Definition: HcalTopology.h:81
std::atomic< std::multimap< CaloTowerDetId, DetId > * > m_reverseItems
int lastHORing() const
Definition: HcalTopology.h:86
int lastHERing() const
Definition: HcalTopology.h:82
edm::SortedCollection< MapItem > m_items
void CaloTowerConstituentsMap::sort ( )

done adding to the association

Definition at line 61 of file CaloTowerConstituentsMap.cc.

References m_items.

61  {
62  m_items.sort();
63 
64 // for (auto const & it : m_items)
65 // std::cout << std::hex << it.cell.rawId() << " " << it.tower.rawId() << std::dec << std::endl;
66 
67 }
edm::SortedCollection< MapItem > m_items
CaloTowerDetId CaloTowerConstituentsMap::towerOf ( const DetId id) const

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

Definition at line 24 of file CaloTowerConstituentsMap.cc.

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

Referenced by CaloTowersCreationAlgo::assignHitEcal(), CaloTowersCreationAlgo::assignHitHcal(), FastL1Region::FillEMCrystals(), CaloTowersCreationAlgo::makeHcalDropChMap(), PhysicsTowerOrganizer::PhysicsTowerOrganizer(), CaloTowersCreationAlgo::rescale(), and EgammaHadTower::towerOf().

24  {
25  CaloTowerDetId tid; // null to start with
26 
28  if (i!=m_items.end()) tid=i->tower;
29 
30  if (tid.null()) {
31  if (id.det()==DetId::Hcal) {
32  HcalDetId hid(id);
33  if ( (hid.subdet()==HcalBarrel && standardHB_ ) ||
34  (hid.subdet()==HcalEndcap && standardHE_ ) ||
35  (hid.subdet()==HcalOuter && standardHO_ ) ||
36  (hid.subdet()==HcalForward && standardHF_) ) {
37  if ((hid.subdet()==HcalForward) && hid.ietaAbs()==29) // special handling for tower 29
38  tid=CaloTowerDetId(30*hid.zside(),hid.iphi());
39  else
40  tid=CaloTowerDetId(hid.ieta(),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 }
int i
Definition: DBlmapReader.cc:9
std::vector< T >::const_iterator const_iterator
bool null() const
is this a null id ?
Definition: DetId.h:45
if(dp >Float(M_PI)) dp-
EcalSubdetector
edm::SortedCollection< MapItem > m_items
void CaloTowerConstituentsMap::useStandardEB ( bool  use = true)

add standard (hardcoded) EB items?

Definition at line 156 of file CaloTowerConstituentsMap.cc.

References standardEB_.

156  {
157  standardEB_=use;
158 }
void CaloTowerConstituentsMap::useStandardHB ( bool  use = true)

add standard (hardcoded) HB items?

Definition at line 144 of file CaloTowerConstituentsMap.cc.

References standardHB_.

144  {
145  standardHB_=use;
146 }
void CaloTowerConstituentsMap::useStandardHE ( bool  use = true)

add standard (hardcoded) HE items?

Definition at line 147 of file CaloTowerConstituentsMap.cc.

References standardHE_.

147  {
148  standardHE_=use;
149 }
void CaloTowerConstituentsMap::useStandardHF ( bool  use = true)

add standard (hardcoded) HF items?

Definition at line 153 of file CaloTowerConstituentsMap.cc.

References standardHF_.

153  {
154  standardHF_=use;
155 }
void CaloTowerConstituentsMap::useStandardHO ( bool  use = true)

add standard (hardcoded) HO items?

Definition at line 150 of file CaloTowerConstituentsMap.cc.

References standardHO_.

150  {
151  standardHO_=use;
152 }

Member Data Documentation

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

Definition at line 63 of file CaloTowerConstituentsMap.h.

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

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

Definition at line 64 of file CaloTowerConstituentsMap.h.

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

const HcalTopology* CaloTowerConstituentsMap::m_topology
private

Definition at line 47 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf().

bool CaloTowerConstituentsMap::standardEB_
private

Definition at line 53 of file CaloTowerConstituentsMap.h.

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

bool CaloTowerConstituentsMap::standardHB_
private

Definition at line 49 of file CaloTowerConstituentsMap.h.

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

bool CaloTowerConstituentsMap::standardHE_
private

Definition at line 50 of file CaloTowerConstituentsMap.h.

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

bool CaloTowerConstituentsMap::standardHF_
private

Definition at line 51 of file CaloTowerConstituentsMap.h.

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

bool CaloTowerConstituentsMap::standardHO_
private

Definition at line 52 of file CaloTowerConstituentsMap.h.

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