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 *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::CaloTowerConstituentsMap ( )
delete
CaloTowerConstituentsMap::~CaloTowerConstituentsMap ( )

Definition at line 10 of file CaloTowerConstituentsMap.cc.

References m_reverseItems.

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

Definition at line 14 of file CaloTowerConstituentsMap.cc.

14  :
15  m_hcaltopo(hcaltopo),
16  m_cttopo(cttopo),
17  standardHB_(false),
18  standardHE_(false),
19  standardHF_(false),
20  standardHO_(false),
21  standardEB_(false),
22  m_reverseItems(nullptr)
23 {
24 }
const CaloTowerTopology * m_cttopo
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 TauDecayModes::dec, Exception, m_items, and DetId::rawId().

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 << " 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 CaloTowerTopology::convertCTtoHcal(), HcalDetId::crystal_ieta_high(), HcalDetId::crystal_ieta_low(), HcalDetId::crystal_iphi_high(), HcalDetId::crystal_iphi_low(), HcalTopology::depthBinInformation(), HLT_25ns14e33_v1_cff::etaMax, HLT_25ns14e33_v1_cff::etaMin, CaloTowerTopology::firstHERing(), CaloTowerTopology::firstHFRing(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, i, j, CaloTowerTopology::lastHBRing(), CaloTowerTopology::lastHERing(), CaloTowerTopology::lastHFRing(), CaloTowerTopology::lastHORing(), m_cttopo, m_hcaltopo, m_items, m_reverseItems, EBDetId::MAX_IETA, sd, standardEB_, standardHB_, standardHE_, standardHF_, standardHO_, HcalDetId::zside(), and ecaldqm::zside().

Referenced by CaloTowersCreationAlgo::hadShwrPos(), and 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  //use cttopo when dealing with calotower detids
91  int nd, sd;
92  int hcal_ieta = m_cttopo->convertCTtoHcal(id.ietaAbs());
93 
94  if (standardHB_) {
95  if (id.ietaAbs()<=m_cttopo->lastHBRing()) {
96  m_hcaltopo->depthBinInformation(HcalBarrel,hcal_ieta,nd,sd);
97  for (int i=0; i<nd; i++)
98  items.push_back(HcalDetId(HcalBarrel,hcal_ieta*id.zside(),id.iphi(),i+sd));
99  }
100  }
101  if (standardHO_) {
102  if (id.ietaAbs()<=m_cttopo->lastHORing()) {
103  m_hcaltopo->depthBinInformation(HcalOuter,hcal_ieta,nd,sd);
104  for (int i=0; i<nd; i++)
105  items.push_back(HcalDetId(HcalOuter,hcal_ieta*id.zside(),id.iphi(),i+sd));
106  }
107  }
108  if (standardHE_) {
109  if (id.ietaAbs()>=m_cttopo->firstHERing() && id.ietaAbs()<=m_cttopo->lastHERing()) {
110  m_hcaltopo->depthBinInformation(HcalEndcap,hcal_ieta,nd,sd);
111  for (int i=0; i<nd; i++)
112  items.push_back(HcalDetId(HcalEndcap,hcal_ieta*id.zside(),id.iphi(),i+sd));
113  }
114  }
115  if (standardHF_) {
116  if (id.ietaAbs()>=m_cttopo->firstHFRing() && id.ietaAbs()<=m_cttopo->lastHFRing()) {
117  m_hcaltopo->depthBinInformation(HcalForward,hcal_ieta,nd,sd);
118  for (int i=0; i<nd; i++)
119  items.push_back(HcalDetId(HcalForward,hcal_ieta*id.zside(),id.iphi(),i+sd));
120  // special handling for first HF tower
121  if (id.ietaAbs() == m_cttopo->firstHFRing()) {
122  int hcal_ieta2 = hcal_ieta-1;
123  m_hcaltopo->depthBinInformation(HcalForward,hcal_ieta2,nd,sd);
124  for (int i=0; i<nd; i++)
125  items.push_back(HcalDetId(HcalForward,hcal_ieta2*id.zside(),id.iphi(),i+sd));
126  }
127  }
128  }
129  if (standardEB_ && hcal_ieta<=EBDetId::MAX_IETA/5) {
130  HcalDetId hid(HcalBarrel,hcal_ieta*id.zside(),id.iphi(),1); // for the limits
131  int etaMin, etaMax;
132  if (hid.zside() == -1) {
133  etaMin = hid.crystal_ieta_high();
134  etaMax = hid.crystal_ieta_low();
135  } else {
136  etaMin = hid.crystal_ieta_low();
137  etaMax = hid.crystal_ieta_high();
138  }
139  for (int ie=etaMin; ie<=etaMax; ie++)
140  for (int ip=hid.crystal_iphi_low(); ip<=hid.crystal_iphi_high(); ip++)
141  items.push_back(EBDetId(ie,ip));
142  }
143  return items;
144 }
int i
Definition: DBlmapReader.cc:9
const CaloTowerTopology * m_cttopo
int zside(DetId const &)
int firstHERing() const
int lastHFRing() const
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 lastHERing() const
std::atomic< std::multimap< CaloTowerDetId, DetId > * > m_reverseItems
int convertCTtoHcal(int ct_ieta) const
int lastHORing() const
int lastHBRing() const
int firstHFRing() const
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 26 of file CaloTowerConstituentsMap.cc.

References CaloTowerTopology::convertHcaltoCT(), DetId::Ecal, EcalBarrel, DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, i, HcalDetId::ietaAbs(), citk::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 CaloTowersCreationAlgo::assignHitEcal(), CaloTowersCreationAlgo::assignHitHcal(), CaloTowersCreationAlgo::makeHcalDropChMap(), PhysicsTowerOrganizer::PhysicsTowerOrganizer(), CaloTowersCreationAlgo::rescale(), and EgammaHadTower::towerOf().

26  {
27  CaloTowerDetId tid; // null to start with
28 
30  if (i!=m_items.end()) tid=i->tower;
31 
32  //use hcaltopo when dealing with hcal detids
33  if (tid.null()) {
34  if (id.det()==DetId::Hcal) {
35  HcalDetId hid(id);
36  if ( (hid.subdet()==HcalBarrel && standardHB_ ) ||
37  (hid.subdet()==HcalEndcap && standardHE_ ) ||
38  (hid.subdet()==HcalOuter && standardHO_ ) ||
39  (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 }
int i
Definition: DBlmapReader.cc:9
int convertHcaltoCT(int hcal_ieta, HcalSubdetector subdet) const
std::vector< T >::const_iterator const_iterator
const CaloTowerTopology * m_cttopo
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
bool null() const
is this a null id ?
Definition: DetId.h:45
EcalSubdetector
edm::SortedCollection< MapItem > m_items
void CaloTowerConstituentsMap::useStandardEB ( bool  use = true)

add standard (hardcoded) EB items?

Definition at line 158 of file CaloTowerConstituentsMap.cc.

References standardEB_.

158  {
159  standardEB_=use;
160 }
void CaloTowerConstituentsMap::useStandardHB ( bool  use = true)

add standard (hardcoded) HB items?

Definition at line 146 of file CaloTowerConstituentsMap.cc.

References standardHB_.

146  {
147  standardHB_=use;
148 }
void CaloTowerConstituentsMap::useStandardHE ( bool  use = true)

add standard (hardcoded) HE items?

Definition at line 149 of file CaloTowerConstituentsMap.cc.

References standardHE_.

149  {
150  standardHE_=use;
151 }
void CaloTowerConstituentsMap::useStandardHF ( bool  use = true)

add standard (hardcoded) HF items?

Definition at line 155 of file CaloTowerConstituentsMap.cc.

References standardHF_.

155  {
156  standardHF_=use;
157 }
void CaloTowerConstituentsMap::useStandardHO ( bool  use = true)

add standard (hardcoded) HO items?

Definition at line 152 of file CaloTowerConstituentsMap.cc.

References standardHO_.

152  {
153  standardHO_=use;
154 }

Member Data Documentation

const CaloTowerTopology* CaloTowerConstituentsMap::m_cttopo
private

Definition at line 49 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf(), and towerOf().

const HcalTopology* CaloTowerConstituentsMap::m_hcaltopo
private

Definition at line 48 of file CaloTowerConstituentsMap.h.

Referenced by constituentsOf().

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

Definition at line 65 of file CaloTowerConstituentsMap.h.

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

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

Definition at line 66 of file CaloTowerConstituentsMap.h.

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

bool CaloTowerConstituentsMap::standardEB_
private

Definition at line 55 of file CaloTowerConstituentsMap.h.

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

bool CaloTowerConstituentsMap::standardHB_
private

Definition at line 51 of file CaloTowerConstituentsMap.h.

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

bool CaloTowerConstituentsMap::standardHE_
private

Definition at line 52 of file CaloTowerConstituentsMap.h.

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

bool CaloTowerConstituentsMap::standardHF_
private

Definition at line 53 of file CaloTowerConstituentsMap.h.

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

bool CaloTowerConstituentsMap::standardHO_
private

Definition at line 54 of file CaloTowerConstituentsMap.h.

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