CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackerGeomBuilderFromGeometricDet.cc
Go to the documentation of this file.
1 
3 //#include "DetectorDescription/Core/interface/DDExpandedView.h"
4 //temporary
5 //#include "DetectorDescription/Core/interface/DDSolid.h"
6 //
20 
21 
22 #include <cfloat>
23 #include <cassert>
24 using std::vector;
25 using std::string;
26 
27 namespace {
28  void verifyDUinTG(TrackerGeometry const & tg) {
29  int off=0; int end=0;
30  for ( int i=1; i!=7; i++) {
31  auto det = GeomDetEnumerators::tkDetEnum[i];
32  off = tg.offsetDU(det);
33  end = tg.endsetDU(det); assert(end>off);
34  for (int j=off; j!=end; ++j) {
35  assert(tg.detUnits()[j]->geographicalId().subdetId()==i);
36  assert(tg.detUnits()[j]->subDetector()==det);
37  assert(tg.detUnits()[j]->index()==j);
38  }
39  }
40  }
41 }
42 
44 
45  thePixelDetTypeMap.clear();
46  theStripDetTypeMap.clear();
47 
49  std::vector<const GeometricDet*> comp;
50  gd->deepComponents(comp);
51 
52  std::vector<const GeometricDet*> dets[6];
53  std::vector<const GeometricDet*> & pixB = dets[0]; pixB.reserve(comp.size());
54  std::vector<const GeometricDet*> & pixF = dets[1]; pixF.reserve(comp.size());
55  std::vector<const GeometricDet*> & tib = dets[2]; tib.reserve(comp.size());
56  std::vector<const GeometricDet*> & tid = dets[3]; tid.reserve(comp.size());
57  std::vector<const GeometricDet*> & tob = dets[4]; tob.reserve(comp.size());
58  std::vector<const GeometricDet*> & tec = dets[5]; tec.reserve(comp.size());
59 
60  for(u_int32_t i = 0;i<comp.size();i++)
61  dets[comp[i]->geographicalID().subdetId()-1].push_back(comp[i]);
62 
63  // this order is VERY IMPORTANT!!!!!
64  buildPixel(pixB,tracker,theDetIdToEnum.type(1), "barrel"); //"PixelBarrel"
65  buildPixel(pixF,tracker,theDetIdToEnum.type(2), "endcap"); //"PixelEndcap"
66  buildSilicon(tib,tracker,theDetIdToEnum.type(3), "barrel");// "TIB"
67  buildSilicon(tid,tracker,theDetIdToEnum.type(4), "endcap");//"TID"
68  buildSilicon(tob,tracker,theDetIdToEnum.type(5), "barrel");//"TOB"
69  buildSilicon(tec,tracker,theDetIdToEnum.type(6), "endcap");//"TEC"
70  buildGeomDet(tracker);//"GeomDet"
71 
72  verifyDUinTG(*tracker);
73 
74  return tracker;
75 }
76 
77 void TrackerGeomBuilderFromGeometricDet::buildPixel(std::vector<const GeometricDet*> const & gdv,
80  const std::string& part){
81  tracker->setOffsetDU(det);
82 
83  for(u_int32_t i=0; i<gdv.size(); i++){
84 
85  std::string const & detName = gdv[i]->name().fullname();
86  if (thePixelDetTypeMap.find(detName) == thePixelDetTypeMap.end()) {
87  std::auto_ptr<const Bounds> bounds(gdv[i]->bounds());
88  PixelTopology* t =
90  gdv[i]->pixROCRows(),
91  gdv[i]->pixROCCols(),
92  gdv[i]->pixROCx(),
93  gdv[i]->pixROCy(),
94  part);
95 
96  thePixelDetTypeMap[detName] = new PixelGeomDetType(t,detName,det);
97  tracker->addType(thePixelDetTypeMap[detName]);
98  }
99 
101  GeomDetUnit* temp = new PixelGeomDetUnit(&(*plane),thePixelDetTypeMap[detName],gdv[i]);
102 
103  tracker->addDetUnit(temp);
104  tracker->addDetUnitId(gdv[i]->geographicalID());
105  }
106  tracker->setEndsetDU(det);
107 
108 }
109 
110 void TrackerGeomBuilderFromGeometricDet::buildSilicon(std::vector<const GeometricDet*> const & gdv,
113  const std::string& part)
114 {
115  tracker->setOffsetDU(det);
116 
117  for(u_int32_t i=0;i<gdv.size();i++){
118 
119  std::string const & detName = gdv[i]->name().fullname();
120  if (theStripDetTypeMap.find(detName) == theStripDetTypeMap.end()) {
121  std::auto_ptr<const Bounds> bounds(gdv[i]->bounds());
122  StripTopology* t =
123  theTopologyBuilder->buildStrip(&*bounds,
124  gdv[i]->siliconAPVNum(),
125  part);
126  theStripDetTypeMap[detName] = new StripGeomDetType( t,detName,det,
127  gdv[i]->stereo());
128  tracker->addType(theStripDetTypeMap[detName]);
129  }
130 
131  StripSubdetector sidet( gdv[i]->geographicalID());
132  double scale = (sidet.partnerDetId()) ? 0.5 : 1.0 ;
133 
135  GeomDetUnit* temp = new StripGeomDetUnit(&(*plane), theStripDetTypeMap[detName],gdv[i]);
136 
137  tracker->addDetUnit(temp);
138  tracker->addDetUnitId(gdv[i]->geographicalID());
139  }
140  tracker->setEndsetDU(det);
141 
142 }
143 
144 
146  PlaneBuilderForGluedDet gluedplaneBuilder;
147  std::vector<GeomDetUnit*> const & gdu= tracker->detUnits();
148  std::vector<DetId> const & gduId = tracker->detUnitIds();
149 
150  for(u_int32_t i=0;i<gdu.size();i++){
151  StripSubdetector sidet( gduId[i].rawId());
152  tracker->addDet((GeomDet*) gdu[i]);
153  tracker->addDetId(gduId[i]);
154  if(sidet.glued()!=0&&sidet.stereo()==1){
155  int partner_pos=-1;
156  for(u_int32_t jj=0;jj<gduId.size();jj++){
157  if(sidet.partnerDetId()== gduId[jj]) {
158  partner_pos=jj;
159  break;
160  }
161  }
162  const GeomDetUnit* dus = gdu[i];
163  if(partner_pos==-1){
164  throw cms::Exception("Configuration") <<"No partner detector found \n"
165  <<"There is a problem on Tracker geometry configuration\n";
166  }
167  const GeomDetUnit* dum = gdu[partner_pos];
168  std::vector<const GeomDetUnit *> glued(2);
169  glued[0]=dum;
170  glued[1]=dus;
171  PlaneBuilderForGluedDet::ResultType plane = gluedplaneBuilder.plane(glued);
172  GluedGeomDet* gluedDet = new GluedGeomDet(&(*plane),dum,dus);
173  tracker->addDet((GeomDet*) gluedDet);
174  tracker->addDetId(DetId(sidet.glued()));
175  }
176  }
177 }
178 
179 
180 // std::string TrackerGeomBuilderFromGeometricDet::getString(const std::string & s, DDExpandedView* ev) const
181 // {
182 // DDValue val(s);
183 // vector<const DDsvalues_type *> result;
184 // ev->specificsV(result);
185 // vector<const DDsvalues_type *>::iterator it = result.begin();
186 // bool foundIt = false;
187 // for (; it != result.end(); ++it)
188 // {
189 // foundIt = DDfetch(*it,val);
190 // if (foundIt) break;
191 
192 // }
193 // if (foundIt)
194 // {
195 // const std::vector<std::string> & temp = val.strings();
196 // if (temp.size() != 1)
197 // {
198 // throw cms::Exception("Configuration") << "I need 1 "<< s << " tags";
199 // }
200 // return temp[0];
201 // }
202 // return "NotFound";
203 // }
204 
205 // double TrackerGeomBuilderFromGeometricDet::getDouble(const std::string & s, DDExpandedView* ev) const
206 // {
207 // DDValue val(s);
208 // vector<const DDsvalues_type *> result;
209 // ev->specificsV(result);
210 // vector<const DDsvalues_type *>::iterator it = result.begin();
211 // bool foundIt = false;
212 // for (; it != result.end(); ++it)
213 // {
214 // foundIt = DDfetch(*it,val);
215 // if (foundIt) break;
216 // }
217 // if (foundIt)
218 // {
219 // const std::vector<std::string> & temp = val.strings();
220 // if (temp.size() != 1)
221 // {
222 // throw cms::Exception("Configuration") << "I need 1 "<< s << " tags";
223 // }
224 // return double(atof(temp[0].c_str()));
225 // }
226 // return 0;
227 // }
228 
231  double scale) const
232 {
233  PlaneBuilderFromGeometricDet planeBuilder;
234  PlaneBuilderFromGeometricDet::ResultType plane = planeBuilder.plane(gd);
235  //
236  // set medium properties (if defined)
237  //
238  plane->setMediumProperties(MediumProperties(gd->radLength()*scale,gd->xi()*scale));
239 
240  return plane;
241 }
int i
Definition: DBlmapReader.cc:9
double radLength() const
Definition: GeometricDet.h:240
void setEndsetDU(SubDetector sid)
PixelTopology * buildPixel(const Bounds *, double, double, double, double, std::string)
void buildPixel(std::vector< const GeometricDet * > const &, TrackerGeometry *, GeomDetType::SubDetector det, const std::string &part)
unsigned int partnerDetId() const
std::map< std::string, StripGeomDetType * > theStripDetTypeMap
ResultType plane(const std::vector< const GeomDetUnit * > &dets) const
void addDetId(DetId p)
virtual const DetUnitContainer & detUnits() const
Returm a vector of all GeomDetUnit.
unsigned int endsetDU(SubDetector sid) const
unsigned int glued() const
glued
void setOffsetDU(SubDetector sid)
void buildSilicon(std::vector< const GeometricDet * > const &, TrackerGeometry *, GeomDetType::SubDetector det, const std::string &part)
PlaneBuilderFromGeometricDet::ResultType buildPlaneWithMaterial(const GeometricDet *gd, double scaleFactor=1.) const
unsigned int offsetDU(SubDetector sid) const
StripTopology * buildStrip(const Bounds *, double, std::string)
ResultType plane(const GeometricDet *gd) const
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:38
SubDetector tkDetEnum[8]
Definition: DetId.h:20
unsigned int stereo() const
stereo
double xi() const
Definition: GeometricDet.h:244
std::map< std::string, PixelGeomDetType * > thePixelDetTypeMap
part
Definition: HCALResponse.h:21
TrackerGeometry * build(const GeometricDet *gd)
void addDetUnitId(DetId p)
void addType(GeomDetType *p)
ConstGeometricDetContainer deepComponents() const
virtual const DetIdContainer & detUnitIds() const
Returm a vector of all GeomDetUnit DetIds.
GeomDetType::SubDetector type(int) const
void addDetUnit(GeomDetUnit *p)
void addDet(GeomDet *p)