CMS 3D CMS Logo

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