CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloTowerConstituentsMap.cc
Go to the documentation of this file.
6 
8  m_topology(topology),
9  standardHB_(false),
10  standardHE_(false),
11  standardHF_(false),
12  standardHO_(false),
13  standardEB_(false)
14 {
15 }
16 
18  CaloTowerDetId tid; // null to start with
19 
21  if (i!=m_items.end()) tid=i->tower;
22 
23  if (tid.null()) {
24  if (id.det()==DetId::Hcal) {
25  HcalDetId hid(id);
26  if ( (hid.subdet()==HcalBarrel && standardHB_ ) ||
27  (hid.subdet()==HcalEndcap && standardHE_ ) ||
28  (hid.subdet()==HcalOuter && standardHO_ ) ||
29  (hid.subdet()==HcalForward && standardHF_) ) {
30  if ((hid.subdet()==HcalForward) && hid.ietaAbs()==29) // special handling for tower 29
31  tid=CaloTowerDetId(30*hid.zside(),hid.iphi());
32  else
33  tid=CaloTowerDetId(hid.ieta(),hid.iphi());
34  }
35  } else if (id.det()==DetId::Ecal) {
36  EcalSubdetector esd=(EcalSubdetector)id.subdetId();
37  if (esd==EcalBarrel && standardEB_) {
38  EBDetId ebid(id);
39  tid=CaloTowerDetId(ebid.tower_ieta(),ebid.tower_iphi());
40  }
41  }
42  }
43 
44  return tid;
45 }
46 
47 void CaloTowerConstituentsMap::assign(const DetId& cell, const CaloTowerDetId& tower) {
48  if (m_items.find(cell)!=m_items.end()) {
49  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;
50  }
51  m_items.push_back(MapItem(cell,tower));
52 }
53 
55  m_items.sort();
56 }
57 
58 std::vector<DetId> CaloTowerConstituentsMap::constituentsOf(const CaloTowerDetId& id) const {
59  std::vector<DetId> items;
60 
61  // build reverse map if needed
62  if (!m_items.empty() && m_reverseItems.empty()) {
64  m_reverseItems.insert(std::pair<CaloTowerDetId,DetId>(i->tower,i->cell));
65  }
66 
68  std::multimap<CaloTowerDetId,DetId>::const_iterator j;
69  std::pair<std::multimap<CaloTowerDetId,DetId>::const_iterator,std::multimap<CaloTowerDetId,DetId>::const_iterator> range=m_reverseItems.equal_range(id);
70  for (j=range.first; j!=range.second; j++)
71  items.push_back(j->second);
72 
73  // dealing with topo dependency...
74  int nd, sd;
75 
76  if (standardHB_) {
77  if (id.ietaAbs()<=m_topology->lastHBRing()) {
78  m_topology->depthBinInformation(HcalBarrel,id.ietaAbs(),nd,sd);
79  for (int i=0; i<nd; i++)
80  items.push_back(HcalDetId(HcalBarrel,id.ieta(),id.iphi(),i+sd));
81  }
82  }
83  if (standardHO_) {
84  if (id.ietaAbs()<=m_topology->lastHORing()) {
85  m_topology->depthBinInformation(HcalOuter,id.ietaAbs(),nd,sd);
86  for (int i=0; i<nd; i++)
87  items.push_back(HcalDetId(HcalOuter,id.ieta(),id.iphi(),i+sd));
88  }
89  }
90  if (standardHE_) {
91  if (id.ietaAbs()>=m_topology->firstHERing() && id.ietaAbs()<=m_topology->lastHERing()) {
92  m_topology->depthBinInformation(HcalEndcap,id.ietaAbs(),nd,sd);
93  for (int i=0; i<nd; i++)
94  items.push_back(HcalDetId(HcalEndcap,id.ieta(),id.iphi(),i+sd));
95  }
96  }
97  if (standardHF_) {
98  if (id.ietaAbs()>m_topology->firstHFRing() && id.ietaAbs()<=m_topology->lastHFRing()) {
99  int ieta=id.ieta();
100  m_topology->depthBinInformation(HcalForward,id.ietaAbs(),nd,sd);
101  for (int i=0; i<nd; i++)
102  items.push_back(HcalDetId(HcalForward,ieta,id.iphi(),i+sd));
103  if (id.ietaAbs() == 30) {
104  ieta = 29*id.zside();
106  for (int i=0; i<nd; i++)
107  items.push_back(HcalDetId(HcalForward,ieta,id.iphi(),i+sd));
108  }
109  }
110  }
111  if (standardEB_ && id.ietaAbs()<=EBDetId::MAX_IETA/5) {
112  HcalDetId hid(HcalBarrel,id.ieta(),id.iphi(),1); // for the limits
113  int etaMin, etaMax;
114  if (hid.zside() == -1) {
115  etaMin = hid.crystal_ieta_high();
116  etaMax = hid.crystal_ieta_low();
117  } else {
118  etaMin = hid.crystal_ieta_low();
119  etaMax = hid.crystal_ieta_high();
120  }
121  for (int ie=etaMin; ie<=etaMax; ie++)
122  for (int ip=hid.crystal_iphi_low(); ip<=hid.crystal_iphi_high(); ip++)
123  items.push_back(EBDetId(ie,ip));
124  }
125 
126  return items;
127 }
128 
130  standardHB_=use;
131 }
133  standardHE_=use;
134 }
136  standardHO_=use;
137 }
139  standardHF_=use;
140 }
142  standardEB_=use;
143 }
int firstHFRing() const
Definition: HcalTopology.h:82
int i
Definition: DBlmapReader.cc:9
void useStandardHE(bool use=true)
add standard (hardcoded) HE items?
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
std::multimap< CaloTowerDetId, DetId > m_reverseItems
int tower_ieta() const
get the HCAL/trigger ieta of this crystal
Definition: EBDetId.h:56
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:34
int tower_iphi() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.cc:114
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.cc:46
std::vector< T >::const_iterator const_iterator
void useStandardEB(bool use=true)
add standard (hardcoded) EB items?
int lastHBRing() const
Definition: HcalTopology.h:79
void sort()
done adding to the association
void useStandardHB(bool use=true)
add standard (hardcoded) HB items?
std::vector< DetId > constituentsOf(const CaloTowerDetId &id) const
Get the constituent detids for this tower id ( not yet implemented )
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
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:44
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
int lastHFRing() const
Definition: HcalTopology.h:83
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
CaloTowerConstituentsMap(const HcalTopology *topology)
void assign(const DetId &cell, const CaloTowerDetId &tower)
set the association between a DetId and a tower
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:36
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
Definition: DetId.h:20
void useStandardHO(bool use=true)
add standard (hardcoded) HO items?
double sd
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:46
bool null() const
is this a null id ?
Definition: DetId.h:47
static const int MAX_IETA
Definition: EBDetId.h:144
int firstHERing() const
Definition: HcalTopology.h:80
if(dp >Float(M_PI)) dp-
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.cc:52
EcalSubdetector
int lastHORing() const
Definition: HcalTopology.h:85
void useStandardHF(bool use=true)
add standard (hardcoded) HF items?
int lastHERing() const
Definition: HcalTopology.h:81
edm::SortedCollection< MapItem > m_items