CMS 3D CMS Logo

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