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  if (ptp.vpars.size() != 6) {
47  throw cms::Exception("TrackerGeomBuilderFromGeometricDet")
48  << "Tracker parameters block from XMLs called vPars is expected to have 6 entries, but has " << ptp.vpars.size()
49  << " entrie(s).";
50  }
51 
52  const int BIG_PIX_PER_ROC_X = ptp.vpars[2];
53  const int BIG_PIX_PER_ROC_Y = ptp.vpars[3];
54 
55  thePixelDetTypeMap.clear();
56  theStripDetTypeMap.clear();
57 
59  std::vector<const GeometricDet*> comp;
60  gd->deepComponents(comp);
61 
62  if (tTopo)
63  theTopo = tTopo;
64 
65  //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
66 
67  std::vector<GeometricDet::GDEnumType> gdsubdetmap(
68  6, GeometricDet::unknown); // hardcoded "6" should not be a surprise...
70 
71  LogDebug("SubDetectorGeometricDetType") << "GeometriDet enumerator values of the subdetectors";
72  for (unsigned int i = 0; i < subdetgd.size(); ++i) {
73  assert(subdetgd[i]->geographicalId().subdetId() > 0 && subdetgd[i]->geographicalId().subdetId() < 7);
74  gdsubdetmap[subdetgd[i]->geographicalId().subdetId() - 1] = subdetgd[i]->type();
75  LogTrace("SubDetectorGeometricDetType")
76  << "subdet " << i << " type " << subdetgd[i]->type() << " detid " << subdetgd[i]->geographicalId().rawId()
77  << " subdetid " << subdetgd[i]->geographicalId().subdetId();
78  }
79 
80  std::vector<const GeometricDet*> dets[6];
81  std::vector<const GeometricDet*>& pixB = dets[0];
82  pixB.reserve(comp.size());
83  std::vector<const GeometricDet*>& pixF = dets[1];
84  pixF.reserve(comp.size());
85  std::vector<const GeometricDet*>& tib = dets[2];
86  tib.reserve(comp.size());
87  std::vector<const GeometricDet*>& tid = dets[3];
88  tid.reserve(comp.size());
89  std::vector<const GeometricDet*>& tob = dets[4];
90  tob.reserve(comp.size());
91  std::vector<const GeometricDet*>& tec = dets[5];
92  tec.reserve(comp.size());
93 
94  for (auto& i : comp)
95  dets[i->geographicalId().subdetId() - 1].emplace_back(i);
96 
97  //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 !!
98  // this order is VERY IMPORTANT!!!!! For the moment I (AndreaV) understand that some pieces of code rely on pixel-like being before strip-like
99 
100  // now building the Pixel-like subdetectors
101  for (unsigned int i = 0; i < 6; ++i) {
102  if (gdsubdetmap[i] == GeometricDet::PixelBarrel)
103  buildPixel(
104  dets[i], tracker, GeomDetEnumerators::SubDetector::PixelBarrel, false, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
105  if (gdsubdetmap[i] == GeometricDet::PixelPhase1Barrel)
106  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P1PXB, false, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
107  // Phase2 case
108  if (gdsubdetmap[i] == GeometricDet::PixelPhase2Barrel)
109  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P2PXB, true, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
110  //
111  if (gdsubdetmap[i] == GeometricDet::PixelEndCap)
112  buildPixel(
113  dets[i], tracker, GeomDetEnumerators::SubDetector::PixelEndcap, false, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
114  if (gdsubdetmap[i] == GeometricDet::PixelPhase1EndCap)
115  buildPixel(
116  dets[i], tracker, GeomDetEnumerators::SubDetector::P1PXEC, false, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
117  if (gdsubdetmap[i] == GeometricDet::PixelPhase2EndCap)
118  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P2PXEC, true, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
119  if (gdsubdetmap[i] == GeometricDet::OTPhase2Barrel)
120  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P2OTB, true, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
121  if (gdsubdetmap[i] == GeometricDet::OTPhase2EndCap)
122  buildPixel(dets[i], tracker, GeomDetEnumerators::SubDetector::P2OTEC, true, BIG_PIX_PER_ROC_X, BIG_PIX_PER_ROC_Y);
123  }
124  //now building Strips
125  for (unsigned int i = 0; i < 6; ++i) {
126  if (gdsubdetmap[i] == GeometricDet::TIB)
128  if (gdsubdetmap[i] == GeometricDet::TID)
130  if (gdsubdetmap[i] == GeometricDet::TOB)
132  if (gdsubdetmap[i] == GeometricDet::TEC)
134  }
135  // and finally the "empty" subdetectors (maybe it is not needed)
136  for (unsigned int i = 0; i < 6; ++i) {
137  if (gdsubdetmap[i] == GeometricDet::unknown) {
138  if (!dets[i].empty())
139  throw cms::Exception("NotEmptyUnknownSubDet")
140  << "Subdetector " << i + 1 << " is unknown but it is not empty: " << dets[i].size();
141  buildSilicon(
142  dets[i], tracker, GeomDetEnumerators::tkDetEnum[i + 1], "barrel"); // "barrel" is used but it is irrelevant
143  }
144  }
145  buildGeomDet(tracker); //"GeomDet"
146 
147  verifyDUinTG(*tracker);
148 
149  return tracker;
150 }
151 
153  std::vector<const GeometricDet*> const& gdv,
156  bool upgradeGeometry,
157  int BIG_PIX_PER_ROC_X, // in x direction, rows. BIG_PIX_PER_ROC_X = 0 for SLHC
158  int BIG_PIX_PER_ROC_Y) // in y direction, cols. BIG_PIX_PER_ROC_Y = 0 for SLHC
159 {
160  LogDebug("BuildingGeomDetUnits") << " Pixel type. Size of vector: " << gdv.size()
161  << " GeomDetType subdetector: " << det
162  << " logical subdetector: " << GeomDetEnumerators::subDetGeom[det]
163  << " big pix per ROC x: " << BIG_PIX_PER_ROC_X << " y: " << BIG_PIX_PER_ROC_Y
164  << " is upgrade: " << upgradeGeometry;
165 
166  tracker->setOffsetDU(GeomDetEnumerators::subDetGeom[det]);
167 
168  for (auto const& i : gdv) {
169  std::string const& detName = i->name();
170  if (thePixelDetTypeMap.find(detName) == thePixelDetTypeMap.end()) {
171  std::unique_ptr<const Bounds> bounds(i->bounds());
172  PixelTopology* t = PixelTopologyBuilder().build(bounds.get(),
173  upgradeGeometry,
174  (int)i->pixROCRows(),
175  (int)i->pixROCCols(),
176  BIG_PIX_PER_ROC_X,
177  BIG_PIX_PER_ROC_Y,
178  (int)i->pixROCx(),
179  (int)i->pixROCy());
180 
181  thePixelDetTypeMap[detName] = new PixelGeomDetType(t, detName, det);
182  tracker->addType(thePixelDetTypeMap[detName]);
183  }
184 
186  GeomDetUnit* temp = new PixelGeomDetUnit(&(*plane), thePixelDetTypeMap[detName], i->geographicalId());
187 
188  tracker->addDetUnit(temp);
189  tracker->addDetUnitId(i->geographicalId());
190  }
191  tracker->setEndsetDU(GeomDetEnumerators::subDetGeom[det]);
192 }
193 
194 void TrackerGeomBuilderFromGeometricDet::buildSilicon(std::vector<const GeometricDet*> const& gdv,
197  const std::string& part) {
198  LogDebug("BuildingGeomDetUnits") << " Strip type. Size of vector: " << gdv.size()
199  << " GeomDetType subdetector: " << det
200  << " logical subdetector: " << GeomDetEnumerators::subDetGeom[det] << " part "
201  << part;
202 
203  tracker->setOffsetDU(GeomDetEnumerators::subDetGeom[det]);
204 
205  for (auto const& i : gdv) {
206  std::string const& detName = i->name();
207  if (theStripDetTypeMap.find(detName) == theStripDetTypeMap.end()) {
208  std::unique_ptr<const Bounds> bounds(i->bounds());
209  StripTopology* t = StripTopologyBuilder().build(bounds.get(), i->siliconAPVNum(), part);
210  theStripDetTypeMap[detName] = new StripGeomDetType(t, detName, det, i->stereo());
211  tracker->addType(theStripDetTypeMap[detName]);
212  }
213 
214  double scale = (theTopo->partnerDetId(i->geographicalId())) ? 0.5 : 1.0;
215 
217  GeomDetUnit* temp = new StripGeomDetUnit(&(*plane), theStripDetTypeMap[detName], i->geographicalId());
218 
219  tracker->addDetUnit(temp);
220  tracker->addDetUnitId(i->geographicalId());
221  }
222  tracker->setEndsetDU(GeomDetEnumerators::subDetGeom[det]);
223 }
224 
226  PlaneBuilderForGluedDet gluedplaneBuilder;
227  auto const& gdu = tracker->detUnits();
228  auto const& gduId = tracker->detUnitIds();
229 
230  for (u_int32_t i = 0; i < gdu.size(); i++) {
231  tracker->addDet(gdu[i]);
232  tracker->addDetId(gduId[i]);
233  string gduTypeName = gdu[i]->type().name();
234 
235  //this step is time consuming >> TO FIX with a MAP?
236  if ((gduTypeName.find("Ster") != std::string::npos || gduTypeName.find("Lower") != std::string::npos) &&
237  (theTopo->glued(gduId[i]) != 0 || theTopo->stack(gduId[i]) != 0)) {
238  int partner_pos = -1;
239  for (u_int32_t jj = 0; jj < gduId.size(); jj++) {
240  if (theTopo->partnerDetId(gduId[i]) == gduId[jj]) {
241  partner_pos = jj;
242  break;
243  }
244  }
245  if (partner_pos == -1) {
246  throw cms::Exception("Configuration") << "Module Type is Stereo or Lower but no partner detector found \n"
247  << "There is a problem on Tracker geometry configuration\n";
248  }
249 
250  const GeomDetUnit* dus = gdu[i];
251  const GeomDetUnit* dum = gdu[partner_pos];
252  std::vector<const GeomDetUnit*> composed(2);
253  composed[0] = dum;
254  composed[1] = dus;
255  DetId composedDetId;
256  if (gduTypeName.find("Ster") != std::string::npos) {
257  PlaneBuilderForGluedDet::ResultType plane = gluedplaneBuilder.plane(composed);
258  composedDetId = theTopo->glued(gduId[i]);
259  GluedGeomDet* gluedDet = new GluedGeomDet(&(*plane), dum, dus, composedDetId);
260  tracker->addDet((GeomDet*)gluedDet);
261  tracker->addDetId(composedDetId);
262 
263  } else if (gduTypeName.find("Lower") != std::string::npos) {
264  //The plane is *not* built in the middle, but on the Lower surface
265  Plane* plane = new Plane(dus->surface());
266  composedDetId = theTopo->stack(gduId[i]);
267  StackGeomDet* stackDet = new StackGeomDet(&(*plane), dus, dum, composedDetId);
268  tracker->addDet((GeomDet*)stackDet);
269  tracker->addDetId(composedDetId);
270  }
271  }
272  }
273 }
274 
276  const GeometricDet* gd, double scale) const {
277  PlaneBuilderFromGeometricDet planeBuilder;
278  PlaneBuilderFromGeometricDet::ResultType plane = planeBuilder.plane(gd);
279  //
280  // set medium properties (if defined)
281  //
282  plane->setMediumProperties(MediumProperties(gd->radLength() * scale, gd->xi() * scale));
283 
284  return plane;
285 }
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:428
TrackerGeomBuilderFromGeometricDet::thePixelDetTypeMap
std::map< std::string, const PixelGeomDetType * > thePixelDetTypeMap
Definition: TrackerGeomBuilderFromGeometricDet.h:37
TrackerGeomBuilderFromGeometricDet::buildGeomDet
void buildGeomDet(TrackerGeometry *)
Definition: TrackerGeomBuilderFromGeometricDet.cc:225
GeometricDet::PixelEndCap
Definition: GeometricDet.h:52
StripGeomDetUnit.h
MessageLogger.h
TrackerGeometry.h
GeomDet
Definition: GeomDet.h:27
StripGeomDetType.h
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
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:275
GeometricDet::components
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:149
TrackerTopology
Definition: TrackerTopology.h:16
GeometricDet::TID
Definition: GeometricDet.h:54
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:51
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:72
PTrackerParameters.h
ReferenceCountingPointer
Definition: ReferenceCounted.h:60
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
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
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrackerTopology.h
GeometricDet::PixelPhase1EndCap
Definition: GeometricDet.h:69
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:75
GeomDetEnumerators::tkDetEnum
constexpr SubDetector tkDetEnum[8]
Definition: GeomDetEnumerators.h:37
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
mps_fire.end
end
Definition: mps_fire.py:242
MediumProperties.h
GeometricDet
Definition: GeometricDet.h:31
TrackerTopology::partnerDetId
DetId partnerDetId(const DetId &id) const
Definition: TrackerTopology.cc:233
GeomDetEnumerators::P2OTEC
Definition: GeomDetEnumerators.h:24
PixelTopology
Definition: PixelTopology.h:10
GeometricDet::unknown
Definition: GeometricDet.h:49
PixelGeomDetType.h
GluedGeomDet
Definition: GluedGeomDet.h:7
GeometricDet::radLength
double radLength() const
Definition: GeometricDet.h:126
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:76
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:152
GeomDetEnumerators::P1PXB
Definition: GeomDetEnumerators.h:25
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
PTrackerParameters::vpars
std::vector< int > vpars
Definition: PTrackerParameters.h:19
GeometricDet::PixelPhase1Barrel
Definition: GeometricDet.h:68
GeometricDet::OTPhase2EndCap
Definition: GeometricDet.h:71
createfilelist.int
int
Definition: createfilelist.py:10
GeometricDet::TIB
Definition: GeometricDet.h:53
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
GeometricDet::deepComponents
ConstGeometricDetContainer deepComponents() const
Definition: GeometricDet.cc:226
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:194
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:34
GeometricDet::TOB
Definition: GeometricDet.h:55
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
Plane
Definition: Plane.h:16
findQualityFiles.jj
string jj
Definition: findQualityFiles.py:188
PixelGeomDetUnit.h
GeometricDet::xi
double xi() const
Definition: GeometricDet.h:127
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:224
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
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:56
GeomDetEnumerators::P2PXEC
Definition: GeomDetEnumerators.h:28
StripGeomDetUnit
Definition: StripGeomDetUnit.h:15
TrackerGeometry
Definition: TrackerGeometry.h:14