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  edm::LogVerbatim("EcalTrigTowerConstituentsMap")
44  << "EcalTrigTowerConstituentsMap " << originalId.zside() << " " << etaTower << " " << phiTower;
45  return EcalTrigTowerDetId(originalId.zside(), EcalEndcap, etaTower, phiTower);
46  }
47  }
48  return EcalTrigTowerDetId(0);
49 }
50 
52  if (!(eeid.det() == DetId::Ecal && eeid.subdetId() == EcalEndcap))
53  return EEDetId(0);
54 
55  EEDetId myId(eeid);
56  switch ((myId.iquadrant() - 1) % 4) {
57  case 0:
58  return DetId(EEDetId(myId.ix(), myId.iy(), 1, EEDetId::XYMODE));
59  break;
60  case 1:
61  return DetId(EEDetId(101 - myId.ix(), myId.iy(), 1, EEDetId::XYMODE));
62  break;
63  case 2:
64  return DetId(EEDetId(101 - myId.ix(), 101 - myId.iy(), 1, EEDetId::XYMODE));
65  break;
66  case 3:
67  return DetId(EEDetId(myId.ix(), 101 - myId.iy(), 1, EEDetId::XYMODE));
68  break;
69  default:
70  /*should never be reached*/
71  edm::LogError("EcalTrigTowerConstituentsMapError") << "This should never be reached. Profound error!";
72  }
73  return EEDetId(0);
74 }
75 
77  EcalTrigTowerDetId etid(id);
78 
79  if (!(etid.det() == DetId::Ecal && etid.subdetId() == EcalTriggerTower && etid.subDet() == EcalEndcap))
80  return EcalTrigTowerDetId(0);
81 
82  switch ((etid.iquadrant() - 1) % 4) {
83  case 0:
84  return DetId(EcalTrigTowerDetId(1, EcalEndcap, etid.ietaAbs(), etid.iphi()));
85  break;
86  case 1:
89  break;
90  case 2:
93  break;
94  case 3:
97  break;
98  default:
99  /*should never be reached*/
100  edm::LogError("EcalTrigTowerConstituentsMapError") << "This should never be reached. Profound error!";
101  }
102  return EcalTrigTowerDetId(0);
103 }
104 
106  const int& toQuadrant,
107  const int& tozside) const {
108  if (!(fromid.det() == DetId::Ecal && fromid.subdetId() == EcalEndcap))
109  return EEDetId(0);
110 
111  EEDetId myId(fromid);
112  int dQuadrant = toQuadrant - myId.iquadrant();
113  switch (dQuadrant % 4) {
114  case 0:
115  return DetId(EEDetId(myId.ix(), myId.iy(), tozside, EEDetId::XYMODE));
116  break;
117  case 1:
118  /* adjacent tower: they are symetric*/
119  return DetId(EEDetId(101 - myId.ix(), myId.iy(), tozside, EEDetId::XYMODE));
120  break;
121  case 2:
122  /* opposite quadrant: they are identical*/
123  return DetId(EEDetId(101 - myId.ix(), 101 - myId.iy(), tozside, EEDetId::XYMODE));
124  break;
125  case 3:
126  /* adjacent tower: they are symetric*/
127  return DetId(EEDetId(myId.ix(), 101 - myId.iy(), tozside, EEDetId::XYMODE));
128  break;
129  default:
130  /*should never be reached*/
131  edm::LogError("EcalTrigTowerConstituentsMapError") << "This should never be reached. Profound error!";
132  }
133  return EEDetId(0);
134 }
135 
136 int EcalTrigTowerConstituentsMap::changeTowerQuadrant(int phiTower, int fromQuadrant, int toQuadrant) const {
137  int newPhiTower = phiTower;
138  int dQuadrant = toQuadrant - fromQuadrant;
139 
140  switch (dQuadrant % 4) {
141  case 0:
142  newPhiTower = phiTower;
143  break;
144  case 1:
145  /* adjacent tower: they are symetric*/
146  newPhiTower = EcalTrigTowerDetId::kEETowersInPhiPerQuadrant * 2 - phiTower + 1;
147  break;
148  case 2:
149  /* opposite quadrant: they are identical*/
150  newPhiTower = phiTower + EcalTrigTowerDetId::kEETowersInPhiPerQuadrant * 2;
151  break;
152  case 3:
153  /* adjacent tower: they are symetric*/
154  newPhiTower = EcalTrigTowerDetId::kEETowersInPhiPerQuadrant * 4 - phiTower + 1;
155  break;
156  default:
157  /*should never be reached*/
158  edm::LogError("EcalTrigTowerConstituentsMapError") << "This should never be reached. Profound error!";
159  }
160  return newPhiTower;
161 }
162 
164  if (m_items.find(cell) != m_items.end()) {
165  throw cms::Exception("EcalTrigTowers")
166  << "Cell with id " << std::hex << cell.rawId() << std::dec << " is already mapped to a EcalTrigTower "
167  << m_items.find(cell)->tower << std::endl;
168  }
169 
170  m_items.insert(MapItem(cell, tower));
171 }
172 
174  std::vector<DetId> items;
175 
176  if (id.det() == DetId::Ecal && id.subdetId() == EcalTriggerTower && id.subDet() == EcalBarrel) {
177  //--------------------
178  // Ecal Barrel
179  //--------------------
180  // trigger towers are 5x5 crystals in the barrel
181  int etaxtalMin = (id.ietaAbs() - 1) * 5 + 1;
182  int phixtalMin = ((id.iphi() - 1) * 5 + 11) % 360;
183  if (phixtalMin <= 0)
184  phixtalMin += 360;
185  int etaxtalMax = id.ietaAbs() * 5;
186  int phixtalMax = ((id.iphi()) * 5 + 10) % 360;
187  if (phixtalMax <= 0)
188  phixtalMax += 360;
189  for (int e = etaxtalMin; e <= etaxtalMax; e++)
190  for (int p = phixtalMin; p <= phixtalMax; p++)
191  items.emplace_back(DetId(EBDetId(id.zside() * e, p, EBDetId::ETAPHIMODE)));
192  } else if (id.det() == DetId::Ecal && id.subdetId() == EcalTriggerTower && id.subDet() == EcalEndcap) {
193  //--------------------
194  // Ecal Endcap
195  //--------------------
196  //DetId myId=wrapEcalTrigTowerDetId(id);
197  EcalTowerMap_by_towerDetId::const_iterator lb, ub;
198  //boost::tuples::tie(lb,ub)=get<1>(m_items).equal_range(myId);
199  boost::tuples::tie(lb, ub) = boost::get<1>(m_items).equal_range(id);
200  while (lb != ub) {
201  //EEDetId mappedId((*lb).cell);
202  //items.emplace_back(changeEEDetIdQuadrantAndZ(mappedId,id.iquadrant(),id.zside()));
203  items.emplace_back((*lb).cell);
204  ++lb;
205  }
206  }
207 
208  return items;
209 }
Log< level::Info, true > LogVerbatim
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:333
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