CMS 3D CMS Logo

EcalTrigTowerConstituentsMap.cc
Go to the documentation of this file.
4 
6 
8 #include <cassert>
9 
11 
13  assert(id.det() == DetId::Ecal && id.subdetId() == EcalBarrel);
14  //--------------------
15  // Ecal Barrel
16  //--------------------
17  EBDetId myId(id);
18  return myId.tower();
19 }
20 
22  if (id.det() == DetId::Ecal && id.subdetId() == EcalBarrel) {
23  //--------------------
24  // Ecal Barrel
25  //--------------------
26  EBDetId myId(id);
27  return myId.tower();
28  } else if (id.det() == DetId::Ecal && id.subdetId() == EcalEndcap) {
29  //--------------------
30  // Ecal Endcap
31  //--------------------
32  EEDetId originalId(id);
33  // DetId wrappedId=wrapEEDetId(id);
34  DetId wrappedId(originalId);
35  EcalTowerMap::const_iterator i = m_items.find(wrappedId);
36  if (i != m_items.end()) {
37  int etaTower = i->tower.ietaAbs();
38  int phiTower = i->tower.iphi();
39  //trigger tower <-> crystal maping read
40  //..........from file and done only for 1 quadrant
41  //move from quadrant 1 to the actual one:
42  // phiTower = changeTowerQuadrant(phiTower, 1, originalId.iquadrant());
43  // std::cout << originalId.zside() << " " << etaTower << " " << phiTower << std::endl;
44  return EcalTrigTowerDetId(originalId.zside(), EcalEndcap, etaTower, phiTower);
45  }
46  }
47  return EcalTrigTowerDetId(0);
48 }
49 
51  if (!(eeid.det() == DetId::Ecal && eeid.subdetId() == EcalEndcap))
52  return EEDetId(0);
53 
54  EEDetId myId(eeid);
55  switch ((myId.iquadrant() - 1) % 4) {
56  case 0:
57  return DetId(EEDetId(myId.ix(), myId.iy(), 1, EEDetId::XYMODE));
58  break;
59  case 1:
60  return DetId(EEDetId(101 - myId.ix(), myId.iy(), 1, EEDetId::XYMODE));
61  break;
62  case 2:
63  return DetId(EEDetId(101 - myId.ix(), 101 - myId.iy(), 1, EEDetId::XYMODE));
64  break;
65  case 3:
66  return DetId(EEDetId(myId.ix(), 101 - myId.iy(), 1, EEDetId::XYMODE));
67  break;
68  default:
69  /*should never be reached*/
70  edm::LogError("EcalTrigTowerConstituentsMapError") << "This should never be reached. Profound error!";
71  }
72  return EEDetId(0);
73 }
74 
76  EcalTrigTowerDetId etid(id);
77 
78  if (!(etid.det() == DetId::Ecal && etid.subdetId() == EcalTriggerTower && etid.subDet() == EcalEndcap))
79  return EcalTrigTowerDetId(0);
80 
81  switch ((etid.iquadrant() - 1) % 4) {
82  case 0:
83  return DetId(EcalTrigTowerDetId(1, EcalEndcap, etid.ietaAbs(), etid.iphi()));
84  break;
85  case 1:
88  break;
89  case 2:
92  break;
93  case 3:
96  break;
97  default:
98  /*should never be reached*/
99  edm::LogError("EcalTrigTowerConstituentsMapError") << "This should never be reached. Profound error!";
100  }
101  return EcalTrigTowerDetId(0);
102 }
103 
105  const int& toQuadrant,
106  const int& tozside) const {
107  if (!(fromid.det() == DetId::Ecal && fromid.subdetId() == EcalEndcap))
108  return EEDetId(0);
109 
110  EEDetId myId(fromid);
111  int dQuadrant = toQuadrant - myId.iquadrant();
112  switch (dQuadrant % 4) {
113  case 0:
114  return DetId(EEDetId(myId.ix(), myId.iy(), tozside, EEDetId::XYMODE));
115  break;
116  case 1:
117  /* adjacent tower: they are symetric*/
118  return DetId(EEDetId(101 - myId.ix(), myId.iy(), tozside, EEDetId::XYMODE));
119  break;
120  case 2:
121  /* opposite quadrant: they are identical*/
122  return DetId(EEDetId(101 - myId.ix(), 101 - myId.iy(), tozside, EEDetId::XYMODE));
123  break;
124  case 3:
125  /* adjacent tower: they are symetric*/
126  return DetId(EEDetId(myId.ix(), 101 - myId.iy(), tozside, EEDetId::XYMODE));
127  break;
128  default:
129  /*should never be reached*/
130  edm::LogError("EcalTrigTowerConstituentsMapError") << "This should never be reached. Profound error!";
131  }
132  return EEDetId(0);
133 }
134 
135 int EcalTrigTowerConstituentsMap::changeTowerQuadrant(int phiTower, int fromQuadrant, int toQuadrant) const {
136  int newPhiTower = phiTower;
137  int dQuadrant = toQuadrant - fromQuadrant;
138 
139  switch (dQuadrant % 4) {
140  case 0:
141  newPhiTower = phiTower;
142  break;
143  case 1:
144  /* adjacent tower: they are symetric*/
145  newPhiTower = EcalTrigTowerDetId::kEETowersInPhiPerQuadrant * 2 - phiTower + 1;
146  break;
147  case 2:
148  /* opposite quadrant: they are identical*/
149  newPhiTower = phiTower + EcalTrigTowerDetId::kEETowersInPhiPerQuadrant * 2;
150  break;
151  case 3:
152  /* adjacent tower: they are symetric*/
153  newPhiTower = EcalTrigTowerDetId::kEETowersInPhiPerQuadrant * 4 - phiTower + 1;
154  break;
155  default:
156  /*should never be reached*/
157  edm::LogError("EcalTrigTowerConstituentsMapError") << "This should never be reached. Profound error!";
158  }
159  return newPhiTower;
160 }
161 
163  if (m_items.find(cell) != m_items.end()) {
164  throw cms::Exception("EcalTrigTowers")
165  << "Cell with id " << std::hex << cell.rawId() << std::dec << " is already mapped to a EcalTrigTower "
166  << m_items.find(cell)->tower << std::endl;
167  }
168 
169  m_items.insert(MapItem(cell, tower));
170 }
171 
173  std::vector<DetId> items;
174 
175  if (id.det() == DetId::Ecal && id.subdetId() == EcalTriggerTower && id.subDet() == EcalBarrel) {
176  //--------------------
177  // Ecal Barrel
178  //--------------------
179  // trigger towers are 5x5 crystals in the barrel
180  int etaxtalMin = (id.ietaAbs() - 1) * 5 + 1;
181  int phixtalMin = ((id.iphi() - 1) * 5 + 11) % 360;
182  if (phixtalMin <= 0)
183  phixtalMin += 360;
184  int etaxtalMax = id.ietaAbs() * 5;
185  int phixtalMax = ((id.iphi()) * 5 + 10) % 360;
186  if (phixtalMax <= 0)
187  phixtalMax += 360;
188  for (int e = etaxtalMin; e <= etaxtalMax; e++)
189  for (int p = phixtalMin; p <= phixtalMax; p++)
190  items.emplace_back(DetId(EBDetId(id.zside() * e, p, EBDetId::ETAPHIMODE)));
191  } else if (id.det() == DetId::Ecal && id.subdetId() == EcalTriggerTower && id.subDet() == EcalEndcap) {
192  //--------------------
193  // Ecal Endcap
194  //--------------------
195  //DetId myId=wrapEcalTrigTowerDetId(id);
196  EcalTowerMap_by_towerDetId::const_iterator lb, ub;
197  //boost::tuples::tie(lb,ub)=get<1>(m_items).equal_range(myId);
198  boost::tuples::tie(lb, ub) = boost::get<1>(m_items).equal_range(id);
199  while (lb != ub) {
200  //EEDetId mappedId((*lb).cell);
201  //items.emplace_back(changeEEDetIdQuadrantAndZ(mappedId,id.iquadrant(),id.zside()));
202  items.emplace_back((*lb).cell);
203  ++lb;
204  }
205  }
206 
207  return items;
208 }
void assign(const DetId &cell, const EcalTrigTowerDetId &tower)
set the association between a DetId and a tower
DetId changeEEDetIdQuadrantAndZ(const DetId &fromid, const int &toQuadrant, const int &tozside) const
std::vector< DetId > constituentsOf(const EcalTrigTowerDetId &id) const
Get the constituent detids for this tower id.
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
static const int XYMODE
Definition: EEDetId.h:335
int ix() const
Definition: EEDetId.h:77
int changeTowerQuadrant(int phiTower, int fromQuadrant, int toQuadrant) const
int zside(DetId const &)
Log< level::Error, false > LogError
assert(be >=bs)
int iquadrant() const
Definition: EEDetId.cc:206
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
DetId wrapEcalTrigTowerDetId(const DetId &id) const
Wrap a generic EcalTrigTowerDetId to the equivalent one in z+ Quadrant 1 (from 0 < phi < pi/2) ...
static const int kEETowersInPhiPerQuadrant
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static const int ETAPHIMODE
Definition: EBDetId.h:158
int ietaAbs() const
get the absolute value of the tower ieta
Definition: DetId.h:17
int zside() const
Definition: EEDetId.h:71
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
DetId wrapEEDetId(const DetId &id) const
Wrap a generic EEDetId to the equivalent one in z+ Quadrant 1 (from 0 < phi < pi/2) ...
int iphi() const
get the tower iphi
static EcalTrigTowerDetId barrelTowerOf(const DetId &id)
int iy() const
Definition: EEDetId.h:83