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  standardHB_(false),
9  standardHE_(false),
10  standardHF_(false),
11  standardHO_(false),
12  standardEB_(false)
13 {
14 }
15 
17  CaloTowerDetId tid; // null to start with
18 
20  if (i!=m_items.end()) tid=i->tower;
21 
22  if (tid.null()) {
23  if (id.det()==DetId::Hcal) {
24  HcalDetId hid(id);
25  if ( (hid.subdet()==HcalBarrel && standardHB_ ) ||
26  (hid.subdet()==HcalEndcap && standardHE_ ) ||
27  (hid.subdet()==HcalOuter && standardHO_ ) ||
28  (hid.subdet()==HcalForward && standardHF_) ) {
29  if ((hid.subdet()==HcalForward) && hid.ietaAbs()==29) // special handling for tower 29
30  tid=CaloTowerDetId(30*hid.zside(),hid.iphi());
31  else
32  tid=CaloTowerDetId(hid.ieta(),hid.iphi());
33  }
34  } else if (id.det()==DetId::Ecal) {
35  EcalSubdetector esd=(EcalSubdetector)id.subdetId();
36  if (esd==EcalBarrel && standardEB_) {
37  EBDetId ebid(id);
38  tid=CaloTowerDetId(ebid.tower_ieta(),ebid.tower_iphi());
39  }
40  }
41  }
42 
43  return tid;
44 }
45 
46 void CaloTowerConstituentsMap::assign(const DetId& cell, const CaloTowerDetId& tower) {
47  if (m_items.find(cell)!=m_items.end()) {
48  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;
49  }
50  m_items.push_back(MapItem(cell,tower));
51 }
52 
54  m_items.sort();
55 }
56 
57 std::vector<DetId> CaloTowerConstituentsMap::constituentsOf(const CaloTowerDetId& id) const {
58  std::vector<DetId> items;
59 
60  // build reverse map if needed
61  if (!m_items.empty() && m_reverseItems.empty()) {
63  m_reverseItems.insert(std::pair<CaloTowerDetId,DetId>(i->tower,i->cell));
64  }
65 
67  std::multimap<CaloTowerDetId,DetId>::const_iterator j;
68  std::pair<std::multimap<CaloTowerDetId,DetId>::const_iterator,std::multimap<CaloTowerDetId,DetId>::const_iterator> range=m_reverseItems.equal_range(id);
69  for (j=range.first; j!=range.second; j++)
70  items.push_back(j->second);
71 
72  // dealing with topo dependency...
73  static HcalTopology htopo;
74  int nd, sd;
75 
76  if (standardHB_) {
77  if (id.ietaAbs()<=htopo.lastHBRing()) {
78  htopo.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()<=htopo.lastHORing()) {
85  htopo.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()>=htopo.firstHERing() && id.ietaAbs()<=htopo.lastHERing()) {
92  htopo.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()>htopo.firstHFRing() && id.ietaAbs()<=htopo.lastHFRing()) {
99  int ieta=id.ieta();
100  htopo.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();
105  htopo.depthBinInformation(HcalForward,ieta,nd,sd);
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:65
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:48
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:164
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:47
std::vector< T >::const_iterator const_iterator
void useStandardEB(bool use=true)
add standard (hardcoded) EB items?
int lastHBRing() const
Definition: HcalTopology.h:62
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:66
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
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?
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:122
int firstHERing() const
Definition: HcalTopology.h:63
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
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:53
EcalSubdetector
int lastHORing() const
Definition: HcalTopology.h:68
void useStandardHF(bool use=true)
add standard (hardcoded) HF items?
int lastHERing() const
Definition: HcalTopology.h:64
edm::SortedCollection< MapItem > m_items