CMS 3D CMS Logo

GEMGeometryBuilderFromCondDB.cc
Go to the documentation of this file.
1 
8 
11 
12 #include "CLHEP/Units/GlobalSystemOfUnits.h"
13 
14 #include <algorithm>
15 
17 
19 
21  const std::vector<DetId>& detids(rgeo.detIds());
22  std::unordered_map<uint32_t, GEMSuperChamber*> superChambers;
23  std::unordered_map<uint32_t, GEMChamber*> chambers;
24  std::unordered_map<uint32_t, GEMEtaPartition*> partitions;
25 
26  for (unsigned int id = 0; id < detids.size(); ++id) {
27  GEMDetId gemid(detids[id]);
28  LogDebug("GEMGeometryBuilderFromDDD") << "GEMGeometryBuilderFromDDD adding " << gemid << std::endl;
29  if (gemid.roll() == 0) {
30  if (gemid.layer() == 0) {
31  GEMSuperChamber* gsc = buildSuperChamber(rgeo, id, gemid);
32  superChambers.emplace(gemid.rawId(), gsc);
33  } else {
34  GEMChamber* gch = buildChamber(rgeo, id, gemid);
35  chambers.emplace(gemid.rawId(), gch);
36  }
37  } else {
38  GEMEtaPartition* gep = buildEtaPartition(rgeo, id, gemid);
39  partitions.emplace(gemid.rawId(), gep);
40  }
41  }
42 
44  // TEMP - for backward compatability with old geometry
45  // no superchambers or chambers in old geometry, using etpartitions
46  if (superChambers.empty()) {
47  for (unsigned int id = 0; id < detids.size(); ++id) {
48  GEMDetId gemid(detids[id]);
49  if (gemid.roll() == 1) {
50  GEMChamber* gch = buildChamber(rgeo, id, gemid.chamberId());
51  chambers.emplace(gemid.chamberId().rawId(), gch);
52  if (gemid.layer() == 1) {
53  GEMSuperChamber* gsc = buildSuperChamber(rgeo, id, gemid.superChamberId());
54  superChambers.emplace(gemid.superChamberId().rawId(), gsc);
55  }
56  }
57  }
58  }
60 
61  // construct the regions, stations and rings.
62  for (int re = -1; re <= 1; re = re + 2) {
63  GEMRegion* region = new GEMRegion(re);
64 
65  for (int st = 0; st <= GEMDetId::maxStationId; ++st) {
66  GEMStation* station = new GEMStation(re, st);
67  std::string sign(re == -1 ? "-" : "");
68  std::string name("GE" + sign + std::to_string(st) + "/1");
69  station->setName(name);
70 
71  for (int ri = 1; ri <= 1; ++ri) {
72  GEMRing* ring = new GEMRing(re, st, ri);
73 
74  for (auto sch : superChambers) {
75  auto superChamber = sch.second;
76  const GEMDetId scId(superChamber->id());
77  if (scId.region() != re || scId.station() != st || scId.ring() != ri)
78  continue;
79  int ch = scId.chamber();
80 
81  for (int ly = 1; ly <= GEMDetId::maxLayerId; ++ly) {
82  const GEMDetId chId(re, ri, st, ly, ch, 0);
83  auto chamberIt = chambers.find(chId.rawId());
84  if (chamberIt == chambers.end())
85  continue;
86  auto chamber = chamberIt->second;
87 
88  for (int roll = 1; roll <= GEMDetId::maxRollId; ++roll) {
89  const GEMDetId rollId(re, ri, st, ly, ch, roll);
90  auto gepIt = partitions.find(rollId.rawId());
91  if (gepIt == partitions.end())
92  continue;
93  auto gep = gepIt->second;
94 
95  chamber->add(gep);
96  theGeometry.add(gep);
97  }
98 
99  superChamber->add(chamber);
100  theGeometry.add(chamber);
101  }
102 
103  LogDebug("GEMGeometryBuilderFromDDD") << "Adding super chamber " << scId << " to ring: " << std::endl;
104  ring->add(superChamber);
105  theGeometry.add(superChamber);
106  } // end superChambers
107 
108  if (ring->nSuperChambers()) {
109  LogDebug("GEMGeometryBuilderFromDDD") << "Adding ring " << ri << " to station "
110  << "re " << re << " st " << st << std::endl;
111  station->add(ring);
112  theGeometry.add(ring);
113  } else {
114  delete ring;
115  }
116  } // end ring
117 
118  if (station->nRings()) {
119  LogDebug("GEMGeometryBuilderFromDDD") << "Adding station " << st << " to region " << re << std::endl;
120  region->add(station);
121  theGeometry.add(station);
122  } else {
123  delete station;
124  }
125  } // end station
126 
127  LogDebug("GEMGeometryBuilderFromDDD") << "Adding region " << re << " to the geometry " << std::endl;
128  theGeometry.add(region);
129  }
130 }
131 
133  unsigned int gid,
134  GEMDetId detId) const {
135  LogDebug("GEMGeometryBuilderFromCondDB") << "buildSuperChamber " << detId << std::endl;
136 
137  RCPBoundPlane surf(boundPlane(rgeo, gid, detId));
138 
139  GEMSuperChamber* superChamber = new GEMSuperChamber(detId, surf);
140  return superChamber;
141 }
142 
144  unsigned int gid,
145  GEMDetId detId) const {
146  LogDebug("GEMGeometryBuilderFromCondDB") << "buildChamber " << detId << std::endl;
147 
148  RCPBoundPlane surf(boundPlane(rgeo, gid, detId));
149 
150  GEMChamber* chamber = new GEMChamber(detId, surf);
151  return chamber;
152 }
153 
155  unsigned int gid,
156  GEMDetId detId) const {
157  std::vector<std::string>::const_iterator strStart = rgeo.strStart(gid);
158  std::string name = *(strStart);
159  LogDebug("GEMGeometryBuilderFromCondDB") << "buildEtaPartition " << name << " " << detId << std::endl;
160 
161  std::vector<double>::const_iterator shapeStart = rgeo.shapeStart(gid);
162  float be = *(shapeStart + 0) / cm;
163  float te = *(shapeStart + 1) / cm;
164  float ap = *(shapeStart + 2) / cm;
165  float ti = *(shapeStart + 3) / cm;
166  float nstrip = *(shapeStart + 4);
167  float npad = *(shapeStart + 5);
168 
169  std::vector<float> pars;
170  pars.emplace_back(be);
171  pars.emplace_back(te);
172  pars.emplace_back(ap);
173  pars.emplace_back(nstrip);
174  pars.emplace_back(npad);
175 
176  RCPBoundPlane surf(boundPlane(rgeo, gid, detId));
178 
179  LogDebug("GEMGeometryBuilderFromCondDB") << "size " << be << " " << te << " " << ap << " " << ti << std::endl;
180  GEMEtaPartition* etaPartition = new GEMEtaPartition(detId, surf, e_p_specs);
181  return etaPartition;
182 }
183 
185  unsigned int gid,
186  GEMDetId detId) const {
187  std::vector<double>::const_iterator shapeStart = rgeo.shapeStart(gid);
188  float be = *(shapeStart + 0) / cm;
189  float te = *(shapeStart + 1) / cm;
190  float ap = *(shapeStart + 2) / cm;
191  float ti = *(shapeStart + 3) / cm;
192  Bounds* bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
193 
194  std::vector<double>::const_iterator tranStart = rgeo.tranStart(gid);
195  Surface::PositionType posResult(*(tranStart) / cm, *(tranStart + 1) / cm, *(tranStart + 2) / cm);
196 
197  std::vector<double>::const_iterator rotStart = rgeo.rotStart(gid);
198  Surface::RotationType rotResult(*(rotStart + 0),
199  *(rotStart + 1),
200  *(rotStart + 2),
201  *(rotStart + 3),
202  *(rotStart + 4),
203  *(rotStart + 5),
204  *(rotStart + 6),
205  *(rotStart + 7),
206  *(rotStart + 8));
207 
208  //Change of axes for the forward
209  Basic3DVector<float> newX(1., 0., 0.);
210  Basic3DVector<float> newY(0., 0., -1.);
211  Basic3DVector<float> newZ(0., 1., 0.);
212 
213  rotResult.rotateAxes(newX, newY, newZ);
214 
215  return RCPBoundPlane(new BoundPlane(posResult, rotResult, bounds));
216 }
#define LogDebug(id)
static int32_t maxRollId
Definition: GEMDetId.h:33
int nSuperChambers() const
Return numbers of chambers.
Definition: GEMRing.cc:44
Plane BoundPlane
Definition: Plane.h:94
std::vector< double >::const_iterator rotStart(size_t ind) const
int roll() const
Definition: GEMDetId.h:188
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
GEMSuperChamber * buildSuperChamber(const RecoIdealGeometry &rgeo, unsigned int gid, GEMDetId detId) const
static int32_t maxStationId
Definition: GEMDetId.h:26
int chamber() const
Definition: GEMDetId.h:177
GEMDetId superChamberId() const
Definition: GEMDetId.h:196
ReferenceCountingPointer< BoundPlane > RCPBoundPlane
void add(GEMRing *ring)
Add ring to the station which takes ownership.
Definition: GEMStation.cc:22
void add(GEMSuperChamber *ch)
Add super chamber to the ring which takes ownership.
Definition: GEMRing.cc:14
TkRotation & rotateAxes(const Basic3DVector< T > &newX, const Basic3DVector< T > &newY, const Basic3DVector< T > &newZ)
std::vector< std::string >::const_iterator strStart(size_t ind) const
GEMDetId chamberId() const
Definition: GEMDetId.h:193
GEMEtaPartition * buildEtaPartition(const RecoIdealGeometry &rgeo, unsigned int gid, GEMDetId detId) const
int layer() const
Definition: GEMDetId.h:184
std::vector< double >::const_iterator tranStart(size_t ind) const
void setName(std::string name)
Set the station name.
Definition: GEMStation.cc:66
GEMChamber * buildChamber(const RecoIdealGeometry &rgeo, unsigned int gid, GEMDetId detId) const
const std::vector< DetId > & detIds() const
RCPBoundPlane boundPlane(const RecoIdealGeometry &rgeo, unsigned int gid, GEMDetId detId) const
static int32_t maxLayerId
Definition: GEMDetId.h:31
std::vector< double >::const_iterator shapeStart(size_t ind) const
int nRings() const
Return numbers of rings for this station.
Definition: GEMStation.cc:64
void add(GEMStation *st)
Add station to the region which takes ownership.
Definition: GEMRegion.cc:20
Definition: Bounds.h:20
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
void build(GEMGeometry &theGeometry, const RecoIdealGeometry &rgeo)
void add(const GEMRegion *region)
Add a GEMRegion to the Geometry.
Definition: GEMGeometry.cc:81