CMS 3D CMS Logo

TrackerGeomBuilderFromGeometricDet.cc
Go to the documentation of this file.
19 
20 #include <cfloat>
21 #include <cassert>
22 using std::string;
23 using std::vector;
24 
25 namespace {
26  void verifyDUinTG(TrackerGeometry const& tg) {
27  int off = 0;
28  int end = 0;
29  for (int i = 1; i != 7; i++) {
30  auto det = GeomDetEnumerators::tkDetEnum[i];
31  off = tg.offsetDU(det);
32  end = tg.endsetDU(det);
33  assert(end >= off); // allow empty subdetectors. Needed for upgrade
34  for (int j = off; j != end; ++j) {
35  assert(tg.detUnits()[j]->geographicalId().subdetId() == i);
36  assert(GeomDetEnumerators::subDetGeom[tg.detUnits()[j]->subDetector()] == det);
37  assert(tg.detUnits()[j]->index() == j);
38  }
39  }
40  }
41 } // namespace
42 
44  const PTrackerParameters& ptp,
45  const TrackerTopology* tTopo) {
46  int BIG_PIX_PER_ROC_X = ptp.vpars[2];
47  int BIG_PIX_PER_ROC_Y = ptp.vpars[3];
48 
49  thePixelDetTypeMap.clear();
50  theStripDetTypeMap.clear();
51 
53  std::vector<const GeometricDet*> comp;
54  gd->deepComponents(comp);
55 
56  if (tTopo)
57  theTopo = tTopo;
58 
59  //define a vector which associate to the detid subdetector index -1 (from 0 to 5) the GeometridDet enumerator to be able to know which type of subdetector it is
60 
61  std::vector<GeometricDet::GDEnumType> gdsubdetmap(
62  6, GeometricDet::unknown); // hardcoded "6" should not be a surprise...
64 
65  LogDebug("SubDetectorGeometricDetType") << "GeometriDet enumerator values of the subdetectors";
66  for (unsigned int i = 0; i < subdetgd.size(); ++i) {
67  assert(subdetgd[i]->geographicalId().subdetId() > 0 && subdetgd[i]->geographicalId().subdetId() < 7);
68  gdsubdetmap[subdetgd[i]->geographicalId().subdetId() - 1] = subdetgd[i]->type();
69  LogTrace("SubDetectorGeometricDetType")
70  << "subdet " << i << " type " << subdetgd[i]->type() << " detid " << subdetgd[i]->geographicalId().rawId()
71  << " subdetid " << subdetgd[i]->geographicalId().subdetId();
72  }
73 
74  std::vector<const GeometricDet*> dets[6];
75  std::vector<const GeometricDet*>& pixB = dets[0];
76  pixB.reserve(comp.size());
77  std::vector<const GeometricDet*>& pixF = dets[1];
78  pixF.reserve(comp.size());
79  std::vector<const GeometricDet*>& tib = dets[2];
80  tib.reserve(comp.size());
81  std::vector<const GeometricDet*>& tid = dets[3];
82  tid.reserve(comp.size());
83  std::vector<const GeometricDet*>& tob = dets[4];
84  tob.reserve(comp.size());
85  std::vector<const GeometricDet*>& tec = dets[5];
86  tec.reserve(comp.size());
87 
88  for (auto& i : comp)
89  dets[i->geographicalID().subdetId() - 1].emplace_back(i);
90 
91  //loop on all the six elements of dets and firstly check if they are from pixel-like detector and call buildPixel, then loop again and check if they are strip and call buildSilicon. "unknown" can be filled either way but the vector of GeometricDet must be empty !!
92  // this order is VERY IMPORTANT!!!!! For the moment I (AndreaV) understand that some pieces of code rely on pixel-like being before strip-like
93 
94  // now building the Pixel-like subdetectors
95  for (unsigned int i = 0; i < 6; ++i) {
96  if (gdsubdetmap[i] == GeometricDet::PixelBarrel)
97  buildPixel(
98  dets[i], tracker, GeomDetEnumerators::SubDetector::PixelBarrel, false, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
99  if (gdsubdetmap[i] == GeometricDet::PixelPhase1Barrel)
100  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P1PXB, false, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
101  // Phase2 case
102  if (gdsubdetmap[i] == GeometricDet::PixelPhase2Barrel)
103  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P2PXB, true, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
104  //
105  if (gdsubdetmap[i] == GeometricDet::PixelEndCap)
106  buildPixel(
107  dets[i], tracker, GeomDetEnumerators::SubDetector::PixelEndcap, false, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
108  if (gdsubdetmap[i] == GeometricDet::PixelPhase1EndCap)
109  buildPixel(
110  dets[i], tracker, GeomDetEnumerators::SubDetector::P1PXEC, false, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
111  if (gdsubdetmap[i] == GeometricDet::PixelPhase2EndCap)
112  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P2PXEC, true, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
113  if (gdsubdetmap[i] == GeometricDet::OTPhase2Barrel)
114  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P2OTB, true, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
115  if (gdsubdetmap[i] == GeometricDet::OTPhase2EndCap)
116  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P2OTEC, true, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
117  }
118  //now building Strips
119  for (unsigned int i = 0; i < 6; ++i) {
120  if (gdsubdetmap[i] == GeometricDet::TIB)
122  if (gdsubdetmap[i] == GeometricDet::TID)
124  if (gdsubdetmap[i] == GeometricDet::TOB)
126  if (gdsubdetmap[i] == GeometricDet::TEC)
128  }
129  // and finally the "empty" subdetectors (maybe it is not needed)
130  for (unsigned int i = 0; i < 6; ++i) {
131  if (gdsubdetmap[i] == GeometricDet::unknown) {
132  if (!dets[i].empty())
133  throw cms::Exception("NotEmptyUnknownSubDet")
134  << "Subdetector " << i + 1 << " is unknown but it is not empty: " << dets[i].size();
135  buildSilicon(
136  dets[i], tracker, GeomDetEnumerators::tkDetEnum[i + 1], "barrel"); // "barrel" is used but it is irrelevant
137  }
138  }
139  buildGeomDet(tracker); //"GeomDet"
140 
141  verifyDUinTG(*tracker);
142 
143  return tracker;
144 }
145 
147  std::vector<const GeometricDet*> const& gdv,
150  bool upgradeGeometry,
151  int BIG_PIX_PER_ROC_X, // in x direction, rows. BIG_PIX_PER_ROC_X = 0 for SLHC
152  int BIG_PIX_PER_ROC_Y) // in y direction, cols. BIG_PIX_PER_ROC_Y = 0 for SLHC
153 {
154  LogDebug("BuildingGeomDetUnits") << " Pixel type. Size of vector: " << gdv.size()
155  << " GeomDetType subdetector: " << det
156  << " logical subdetector: " << GeomDetEnumerators::subDetGeom[det]
157  << " big pix per ROC x: " << BIG_PIX_PER_ROC_X << " y: " << BIG_PIX_PER_ROC_Y
158  << " is upgrade: " << upgradeGeometry;
159 
160  tracker->setOffsetDU(GeomDetEnumerators::subDetGeom[det]);
161 
162  for (auto i : gdv) {
163  std::string const& detName = i->name();
164  if (thePixelDetTypeMap.find(detName) == thePixelDetTypeMap.end()) {
165  std::unique_ptr<const Bounds> bounds(i->bounds());
166 
168  upgradeGeometry,
169  i->pixROCRows(),
170  i->pixROCCols(),
171  BIG_PIX_PER_ROC_X,
172  BIG_PIX_PER_ROC_Y,
173  i->pixROCx(),
174  i->pixROCy());
175 
176  thePixelDetTypeMap[detName] = new PixelGeomDetType(t, detName, det);
177  tracker->addType(thePixelDetTypeMap[detName]);
178  }
179 
181  GeomDetUnit* temp = new PixelGeomDetUnit(&(*plane), thePixelDetTypeMap[detName], i->geographicalID());
182 
183  tracker->addDetUnit(temp);
184  tracker->addDetUnitId(i->geographicalID());
185  }
186  tracker->setEndsetDU(GeomDetEnumerators::subDetGeom[det]);
187 }
188 
189 void TrackerGeomBuilderFromGeometricDet::buildSilicon(std::vector<const GeometricDet*> const& gdv,
192  const std::string& part) {
193  LogDebug("BuildingGeomDetUnits") << " Strip type. Size of vector: " << gdv.size()
194  << " GeomDetType subdetector: " << det
195  << " logical subdetector: " << GeomDetEnumerators::subDetGeom[det] << " part "
196  << part;
197 
198  tracker->setOffsetDU(GeomDetEnumerators::subDetGeom[det]);
199 
200  for (auto i : gdv) {
201  std::string const& detName = i->name();
202  if (theStripDetTypeMap.find(detName) == theStripDetTypeMap.end()) {
203  std::unique_ptr<const Bounds> bounds(i->bounds());
204  StripTopology* t = StripTopologyBuilder().build(&*bounds, i->siliconAPVNum(), part);
205  theStripDetTypeMap[detName] = new StripGeomDetType(t, detName, det, i->stereo());
206  tracker->addType(theStripDetTypeMap[detName]);
207  }
208 
209  double scale = (theTopo->partnerDetId(i->geographicalID())) ? 0.5 : 1.0;
210 
212  GeomDetUnit* temp = new StripGeomDetUnit(&(*plane), theStripDetTypeMap[detName], i->geographicalID());
213 
214  tracker->addDetUnit(temp);
215  tracker->addDetUnitId(i->geographicalID());
216  }
217  tracker->setEndsetDU(GeomDetEnumerators::subDetGeom[det]);
218 }
219 
221  PlaneBuilderForGluedDet gluedplaneBuilder;
222  auto const& gdu = tracker->detUnits();
223  auto const& gduId = tracker->detUnitIds();
224 
225  for (u_int32_t i = 0; i < gdu.size(); i++) {
226  tracker->addDet(gdu[i]);
227  tracker->addDetId(gduId[i]);
228  string gduTypeName = gdu[i]->type().name();
229 
230  //this step is time consuming >> TO FIX with a MAP?
231  if ((gduTypeName.find("Ster") != std::string::npos || gduTypeName.find("Lower") != std::string::npos) &&
232  (theTopo->glued(gduId[i]) != 0 || theTopo->stack(gduId[i]) != 0)) {
233  int partner_pos = -1;
234  for (u_int32_t jj = 0; jj < gduId.size(); jj++) {
235  if (theTopo->partnerDetId(gduId[i]) == gduId[jj]) {
236  partner_pos = jj;
237  break;
238  }
239  }
240  if (partner_pos == -1) {
241  throw cms::Exception("Configuration") << "Module Type is Stereo or Lower but no partner detector found \n"
242  << "There is a problem on Tracker geometry configuration\n";
243  }
244 
245  const GeomDetUnit* dus = gdu[i];
246  const GeomDetUnit* dum = gdu[partner_pos];
247  std::vector<const GeomDetUnit*> composed(2);
248  composed[0] = dum;
249  composed[1] = dus;
250  DetId composedDetId;
251  if (gduTypeName.find("Ster") != std::string::npos) {
252  PlaneBuilderForGluedDet::ResultType plane = gluedplaneBuilder.plane(composed);
253  composedDetId = theTopo->glued(gduId[i]);
254  GluedGeomDet* gluedDet = new GluedGeomDet(&(*plane), dum, dus, composedDetId);
255  tracker->addDet((GeomDet*)gluedDet);
256  tracker->addDetId(composedDetId);
257 
258  } else if (gduTypeName.find("Lower") != std::string::npos) {
259  //FIXME::ERICA: the plane builder is built in the middle...
260  PlaneBuilderForGluedDet::ResultType plane = gluedplaneBuilder.plane(composed);
261  composedDetId = theTopo->stack(gduId[i]);
262  StackGeomDet* stackDet = new StackGeomDet(&(*plane), dum, dus, composedDetId);
263  tracker->addDet((GeomDet*)stackDet);
264  tracker->addDetId(composedDetId);
265  }
266  }
267  }
268 }
269 
271  const GeometricDet* gd, double scale) const {
272  PlaneBuilderFromGeometricDet planeBuilder;
273  PlaneBuilderFromGeometricDet::ResultType plane = planeBuilder.plane(gd);
274  //
275  // set medium properties (if defined)
276  //
277  plane->setMediumProperties(MediumProperties(gd->radLength() * scale, gd->xi() * scale));
278 
279  return plane;
280 }
GeomDetEnumerators::SubDetector
SubDetector
Definition: GeomDetEnumerators.h:10
SectorBuilder_Tib_cff.TIB
TIB
Definition: SectorBuilder_Tib_cff.py:16
mps_fire.i
i
Definition: mps_fire.py:355
TrackerGeomBuilderFromGeometricDet::thePixelDetTypeMap
std::map< std::string, const PixelGeomDetType * > thePixelDetTypeMap
Definition: TrackerGeomBuilderFromGeometricDet.h:37
TrackerGeomBuilderFromGeometricDet::buildGeomDet
void buildGeomDet(TrackerGeometry *)
Definition: TrackerGeomBuilderFromGeometricDet.cc:220
GeometricDet::PixelEndCap
Definition: GeometricDet.h:56
StripGeomDetUnit.h
MessageLogger.h
TrackerGeometry.h
GeomDet
Definition: GeomDet.h:27
StripGeomDetType.h
PTrackerParameters
Definition: PTrackerParameters.h:6
PlaneBuilderForGluedDet
Definition: PlaneBuilderForGluedDet.h:15
TrackerGeomBuilderFromGeometricDet::buildPlaneWithMaterial
PlaneBuilderFromGeometricDet::ResultType buildPlaneWithMaterial(const GeometricDet *gd, double scaleFactor=1.) const
Definition: TrackerGeomBuilderFromGeometricDet.cc:270
GeometricDet::components
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:139
TrackerTopology
Definition: TrackerTopology.h:16
GeometricDet::TID
Definition: GeometricDet.h:58
SectorBuilder_Tec_cff.TEC
TEC
Definition: SectorBuilder_Tec_cff.py:16
cms::cuda::assert
assert(be >=bs)
GeomDetEnumerators::P2OTB
Definition: GeomDetEnumerators.h:23
GluedGeomDet.h
GeometricDet::PixelBarrel
Definition: GeometricDet.h:55
StripTopologyBuilder.h
TrackerGeomBuilderFromGeometricDet::build
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
Definition: TrackerGeomBuilderFromGeometricDet.cc:43
TrackerTopology::stack
uint32_t stack(const DetId &id) const
Definition: TrackerTopology.cc:104
GeometricDet::OTPhase2Barrel
Definition: GeometricDet.h:76
PTrackerParameters.h
ReferenceCountingPointer
Definition: ReferenceCounted.h:60
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
end
#define end
Definition: vmac.h:39
DetId
Definition: DetId.h:17
PlaneBuilderForGluedDet::plane
ResultType plane(const std::vector< const GeomDetUnit * > &dets) const
Definition: PlaneBuilderForGluedDet.cc:10
GeomDetEnumerators::PixelBarrel
Definition: GeomDetEnumerators.h:11
TrackerTopology.h
GeometricDet::PixelPhase1EndCap
Definition: GeometricDet.h:73
part
part
Definition: HCALResponse.h:20
TrackerGeomBuilderFromGeometricDet::theStripDetTypeMap
std::map< std::string, const StripGeomDetType * > theStripDetTypeMap
Definition: TrackerGeomBuilderFromGeometricDet.h:38
TrackerTopology::glued
uint32_t glued(const DetId &id) const
Definition: TrackerTopology.cc:85
TrackerGeometry::endsetDU
unsigned int endsetDU(SubDetector sid) const
Definition: TrackerGeometry.h:73
TrackerGeometry::detUnits
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
Definition: TrackerGeometry.h:61
GeomDetEnumerators::P1PXEC
Definition: GeomDetEnumerators.h:26
GeometricDet::PixelPhase2Barrel
Definition: GeometricDet.h:79
GeomDetEnumerators::tkDetEnum
constexpr SubDetector tkDetEnum[8]
Definition: GeomDetEnumerators.h:37
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
MediumProperties.h
GeometricDet
Definition: GeometricDet.h:30
TrackerTopology::partnerDetId
DetId partnerDetId(const DetId &id) const
Definition: TrackerTopology.cc:233
GeomDetEnumerators::P2OTEC
Definition: GeomDetEnumerators.h:24
OrderedSet.t
t
Definition: OrderedSet.py:90
PixelTopology
Definition: PixelTopology.h:10
GeometricDet::unknown
Definition: GeometricDet.h:53
PixelGeomDetType.h
GluedGeomDet
Definition: GluedGeomDet.h:7
GeometricDet::radLength
double radLength() const
Definition: GeometricDet.h:171
PlaneBuilderFromGeometricDet::plane
ResultType plane(const GeometricDet *gd) const
Definition: PlaneBuilderFromGeometricDet.cc:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GeometricDet::PixelPhase2EndCap
Definition: GeometricDet.h:80
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
TrackerGeomBuilderFromGeometricDet::buildPixel
void buildPixel(std::vector< const GeometricDet * > const &, TrackerGeometry *, GeomDetType::SubDetector det, bool upgradeGeometry, int BIG_PIX_PER_ROC_X, int BIG_PIX_PER_ROC_Y)
Definition: TrackerGeomBuilderFromGeometricDet.cc:146
GeomDetEnumerators::P1PXB
Definition: GeomDetEnumerators.h:25
Scenarios_cff.scale
scale
Definition: Scenarios_cff.py:2186
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
PTrackerParameters::vpars
std::vector< int > vpars
Definition: PTrackerParameters.h:19
GeometricDet::PixelPhase1Barrel
Definition: GeometricDet.h:72
GeometricDet::OTPhase2EndCap
Definition: GeometricDet.h:75
GeometricDet::TIB
Definition: GeometricDet.h:57
GeometricDet::deepComponents
ConstGeometricDetContainer deepComponents() const
Definition: GeometricDet.cc:184
StackGeomDet.h
StripTopologyBuilder
Definition: StripTopologyBuilder.h:13
PixelTopologyBuilder
Definition: PixelTopologyBuilder.h:12
PlaneBuilderForGluedDet.h
TrackerGeomBuilderFromGeometricDet::buildSilicon
void buildSilicon(std::vector< const GeometricDet * > const &, TrackerGeometry *, GeomDetType::SubDetector det, const std::string &part)
Definition: TrackerGeomBuilderFromGeometricDet.cc:189
GeomDet.h
StackGeomDet
Definition: StackGeomDet.h:7
StripGeomDetType
Definition: StripGeomDetType.h:11
MediumProperties
Definition: MediumProperties.h:12
GeometricDet::ConstGeometricDetContainer
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:33
GeometricDet::TOB
Definition: GeometricDet.h:59
GeomDetEnumerators::subDetGeom
constexpr SubDetector subDetGeom[21]
Definition: GeomDetEnumerators.h:40
DetId.h
StripTopologyBuilder::build
StripTopology * build(const Bounds *, double, const std::string &)
Definition: StripTopologyBuilder.cc:9
PixelTopologyBuilder::build
PixelTopology * build(const Bounds *bounds, bool upgradeGeometry, int ROWS_PER_ROC, int COLS_PER_ROC, int BIG_PIX_PER_ROC_X, int BIG_PIX_PER_ROC_Y, int ROCS_X, int ROCS_Y)
Definition: PixelTopologyBuilder.cc:8
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:246
SectorBuilder_Tid_cff.TID
TID
Definition: SectorBuilder_Tid_cff.py:16
findQualityFiles.jj
string jj
Definition: findQualityFiles.py:188
PixelGeomDetUnit.h
GeometricDet::xi
double xi() const
Definition: GeometricDet.h:172
Exception.h
TrackerGeomBuilderFromGeometricDet::theTopo
const TrackerTopology * theTopo
Definition: TrackerGeomBuilderFromGeometricDet.h:39
GeomDetEnumerators::PixelEndcap
Definition: GeomDetEnumerators.h:12
TrackerGeomBuilderFromGeometricDet.h
GeomDetEnumerators::P2PXB
Definition: GeomDetEnumerators.h:27
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TrackerGeometry::offsetDU
unsigned int offsetDU(SubDetector sid) const
Definition: TrackerGeometry.h:72
SectorBuilder_Tob_cff.TOB
TOB
Definition: SectorBuilder_Tob_cff.py:16
StripTopology
Definition: StripTopology.h:11
PixelGeomDetType
Definition: PixelGeomDetType.h:11
PixelTopologyBuilder.h
PlaneBuilderFromGeometricDet
Definition: PlaneBuilderFromGeometricDet.h:11
GeometricDet::TEC
Definition: GeometricDet.h:60
GeomDetEnumerators::P2PXEC
Definition: GeomDetEnumerators.h:28
StripGeomDetUnit
Definition: StripGeomDetUnit.h:15
TrackerGeometry
Definition: TrackerGeometry.h:14