CMS 3D CMS Logo

MTDGeomBuilderFromGeometricTimingDet.cc
Go to the documentation of this file.
13 
14 #include <cfloat>
15 #include <cassert>
16 using std::vector;
17 using std::string;
18 
19 namespace {
20  void verifyDUinTG(MTDGeometry const & tg) {
21  int off=0; int end=0;
22  for ( int i=1; i!=2; i++) {
23  auto det = i - 1;
24  off = tg.offsetDU(det);
25  end = tg.endsetDU(det); assert(end>=off); // allow empty subdetectors. Needed for upgrade
26  for (int j=off; j!=end; ++j) {
27  assert(tg.detUnits()[j]->geographicalId().subdetId()==i);
28  assert(tg.detUnits()[j]->index()==j);
29  }
30  }
31  }
32 }
33 
36 {
37  theMTDDetTypeMap.clear();
38 
39  MTDGeometry* tracker = new MTDGeometry(gd);
40  std::vector<const GeometricTimingDet*> comp;
41  gd->deepComponents(comp);
42 
43  if(tTopo) theTopo = tTopo;
44 
45  //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
46 
47  std::vector<GeometricTimingDet::GTDEnumType> gdsubdetmap(2,GeometricTimingDet::unknown); // hardcoded "2" should not be a surprise...
49 
50  LogDebug("SubDetectorGeometricTimingDetType")
51  << "GeometricTimingDet enumerator values of the subdetectors" << std::endl;
52  for(unsigned int i=0;i<subdetgd.size();++i) {
53  MTDDetId mtdid(subdetgd[i]->geographicalId());
54  assert(mtdid.mtdSubDetector()>0 && mtdid.mtdSubDetector()<3);
55  gdsubdetmap[mtdid.mtdSubDetector()-1]= subdetgd[i]->type();
56  LogTrace("SubDetectorGeometricTimingDetType")
57  << "subdet " << i
58  << " type " << subdetgd[i]->type()
59  << " detid " << std::hex << subdetgd[i]->geographicalId().rawId() << std::dec
60  << " subdetid " << subdetgd[i]->geographicalId().subdetId() << std::endl;
61  }
62 
63  std::vector<const GeometricTimingDet*> dets[2];
64  std::vector<const GeometricTimingDet*> & btl = dets[0]; btl.reserve(comp.size());
65  std::vector<const GeometricTimingDet*> & etl = dets[1]; etl.reserve(comp.size());
66 
67  for(auto & i : comp) {
68  MTDDetId mtdid(i->geographicalId());
69  dets[mtdid.mtdSubDetector()-1].emplace_back(i);
70  }
71 
72  //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 GeometricTimingDet must be empty !!
73  // this order is VERY IMPORTANT!!!!! For the moment I (AndreaV) understand that some pieces of code rely on pixel-like being before strip-like
74 
75  // now building the Pixel-like subdetectors
76  for(unsigned int i=0;i<2;++i) {
77  if(gdsubdetmap[i] == GeometricTimingDet::BTL)
78  buildPixel(dets[i],tracker,
80  ptp);
81  if(gdsubdetmap[i] == GeometricTimingDet::ETL)
82  buildPixel(dets[i],tracker,
84  ptp);
85  }
86 
87  buildGeomDet(tracker);//"GeomDet"
88 
89  verifyDUinTG(*tracker);
90 
91  return tracker;
92 }
93 
94 void MTDGeomBuilderFromGeometricTimingDet::buildPixel(std::vector<const GeometricTimingDet*> const & gdv,
97  const PMTDParameters& ptp) // in y direction, cols. BIG_PIX_PER_ROC_Y = 0 for SLHC
98 {
99  LogDebug("BuildingGeomDetUnits")
100  << " Pixel type. Size of vector: " << gdv.size()
101  << " GeomDetType subdetector: " << det
102  << " logical subdetector: " << GeomDetEnumerators::subDetGeom[det]
103  << " big pix per ROC x: " << 0<< " y: " << 0
104  << " is upgrade: " << true << std::endl;
105 
106  // this is a hack while we put things into the DDD
107  int ROCrows(0),ROCcols(0),ROCSx(0),ROCSy(0);
108  switch(det) {
110  ROCrows = ptp.vitems_[0].vpars_[8];
111  ROCcols = ptp.vitems_[0].vpars_[9];
112  ROCSx = ptp.vitems_[0].vpars_[10];
113  ROCSy = ptp.vitems_[0].vpars_[11];
114  break;
116  ROCrows = ptp.vitems_[1].vpars_[8];
117  ROCcols = ptp.vitems_[1].vpars_[9];
118  ROCSx = ptp.vitems_[1].vpars_[10];
119  ROCSy = ptp.vitems_[1].vpars_[11];
120  break;
121  break;
122  default:
123  throw cms::Exception("UnknownDet")
124  << "MTDGeomBuilderFromGeometricTimingDet got a weird detector: " << det;
125  }
126 
127  switch(det) {
129  tracker->setOffsetDU(0);
130  break;
132  tracker->setOffsetDU(1);
133  break;
134  default:
135  throw cms::Exception("MTDGeomBuilderFromGeometricTimingDet") << det << " is not a timing detector!";
136  }
137 
138  for(auto i : gdv){
139 
140  std::string const & detName = i->name().fullname();
141  if (theMTDDetTypeMap.find(detName) == theMTDDetTypeMap.end()) {
142  std::unique_ptr<const Bounds> bounds(i->bounds());
143 
144  PixelTopology* t =
145  MTDTopologyBuilder().build(&*bounds,
146  true,
147  ROCrows,
148  ROCcols,
149  0,0, // these are BIG_PIX_XXXXX
150  ROCSx, ROCSy);
151 
152  theMTDDetTypeMap[detName] = new MTDGeomDetType(t,detName,det);
153  tracker->addType(theMTDDetTypeMap[detName]);
154  }
155 
157  GeomDetUnit* temp = new MTDGeomDetUnit(&(*plane),theMTDDetTypeMap[detName],i->geographicalID());
158 
159  tracker->addDetUnit(temp);
160  tracker->addDetUnitId(i->geographicalID());
161  }
162  switch(det) {
164  tracker->setEndsetDU(0);
165  break;
167  tracker->setEndsetDU(1);
168  break;
169  default:
170  throw cms::Exception("MTDGeomBuilderFromGeometricTimingDet") << det << " is not a timing detector!";
171  }
172 }
173 
175 
176  auto const & gdu = tracker->detUnits();
177  auto const & gduId = tracker->detUnitIds();
178 
179  for(u_int32_t i=0;i<gdu.size();i++){
180 
181  tracker->addDet(gdu[i]);
182  tracker->addDetId(gduId[i]);
183  string gduTypeName = gdu[i]->type().name();
184 
185  }
186 }
187 
190  double scale) const
191 {
193  PlaneBuilderFromGeometricTimingDet::ResultType plane = planeBuilder.plane(gd);
194  //
195  // set medium properties (if defined)
196  //
197  plane->setMediumProperties(MediumProperties(gd->radLength()*scale,gd->xi()*scale));
198 
199  return plane;
200 }
#define LogDebug(id)
void setEndsetDU(unsigned sid)
Definition: MTDGeometry.h:43
std::vector< Item > vitems_
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
Definition: MTDGeometry.h:28
void addType(GeomDetType const *p)
Definition: MTDGeometry.cc:123
unsigned int endsetDU(unsigned sid) const
Definition: MTDGeometry.h:40
void addDetId(DetId p)
Definition: MTDGeometry.cc:156
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
double radLength() const
ConstGeometricTimingDetContainer & components()
unsigned int offsetDU(unsigned sid) const
Definition: MTDGeometry.h:39
ResultType plane(const GeometricTimingDet *gd) const
PlaneBuilderFromGeometricTimingDet::ResultType buildPlaneWithMaterial(const GeometricTimingDet *gd, double scaleFactor=1.) const
ConstGeometricTimingDetContainer deepComponents() const
const DetIdContainer & detUnitIds() const override
Returm a vector of all GeomDetUnit DetIds.
Definition: MTDGeometry.h:30
SubDetector subDetGeom[21]
#define end
Definition: vmac.h:39
MTDGeometry * build(const GeometricTimingDet *gd, const PMTDParameters &ptp, const MTDTopology *tTopo)
#define LogTrace(id)
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)
void addDet(GeomDet const *p)
Definition: MTDGeometry.cc:138
void addDetUnitId(DetId p)
Definition: MTDGeometry.cc:134
std::map< std::string, const MTDGeomDetType * > theMTDDetTypeMap
int mtdSubDetector() const
Definition: MTDDetId.h:58
void buildPixel(std::vector< const GeometricTimingDet * > const &, MTDGeometry *, GeomDetType::SubDetector det, const PMTDParameters &ptp)
void setOffsetDU(unsigned sid)
Definition: MTDGeometry.h:42
std::vector< GeometricTimingDet const * > ConstGeometricTimingDetContainer
void addDetUnit(GeomDet const *p)
Definition: MTDGeometry.cc:127