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 
24 using std::vector;
25 using std::string;
26 
27 
29 
30  thePixelDetTypeMap.clear();
31  theStripDetTypeMap.clear();
32 
34  std::vector<const GeometricDet*> comp;
35  gd->deepComponents(comp);
36 
37  std::vector<const GeometricDet*> dets[6];
38  std::vector<const GeometricDet*> & pixB = dets[0]; pixB.reserve(comp.size());
39  std::vector<const GeometricDet*> & pixF = dets[1]; pixF.reserve(comp.size());
40  std::vector<const GeometricDet*> & tib = dets[2]; tib.reserve(comp.size());
41  std::vector<const GeometricDet*> & tid = dets[3]; tid.reserve(comp.size());
42  std::vector<const GeometricDet*> & tob = dets[4]; tob.reserve(comp.size());
43  std::vector<const GeometricDet*> & tec = dets[5]; tec.reserve(comp.size());
44 
45  for(u_int32_t i = 0;i<comp.size();i++)
46  dets[comp[i]->geographicalID().subdetId()-1].push_back(comp[i]);
47 
48 
49  buildPixel(pixB,tracker,theDetIdToEnum.type(1), "barrel"); //"PixelBarrel"
50  buildPixel(pixF,tracker,theDetIdToEnum.type(2), "endcap"); //"PixelEndcap"
51  buildSilicon(tib,tracker,theDetIdToEnum.type(3), "barrel");// "TIB"
52  buildSilicon(tid,tracker,theDetIdToEnum.type(4), "endcap");//"TID"
53  buildSilicon(tob,tracker,theDetIdToEnum.type(5), "barrel");//"TOB"
54  buildSilicon(tec,tracker,theDetIdToEnum.type(6), "endcap");//"TEC"
55  buildGeomDet(tracker);//"GeomDet"
56  return tracker;
57 }
58 
59 void TrackerGeomBuilderFromGeometricDet::buildPixel(std::vector<const GeometricDet*> const & gdv,
62  const std::string& part){
63 
64  for(u_int32_t i=0; i<gdv.size(); i++){
65 
66  std::string const & detName = gdv[i]->name().fullname();
67  if (thePixelDetTypeMap.find(detName) == thePixelDetTypeMap.end()) {
68  std::auto_ptr<const Bounds> bounds(gdv[i]->bounds());
69  PixelTopology* t =
71  gdv[i]->pixROCRows(),
72  gdv[i]->pixROCCols(),
73  gdv[i]->pixROCx(),
74  gdv[i]->pixROCy(),
75  part);
76 
77  thePixelDetTypeMap[detName] = new PixelGeomDetType(t,detName,det);
78  tracker->addType(thePixelDetTypeMap[detName]);
79  }
80 
82  GeomDetUnit* temp = new PixelGeomDetUnit(&(*plane),thePixelDetTypeMap[detName],gdv[i]);
83 
84  tracker->addDetUnit(temp);
85  tracker->addDetUnitId(gdv[i]->geographicalID());
86  }
87 }
88 
89 void TrackerGeomBuilderFromGeometricDet::buildSilicon(std::vector<const GeometricDet*> const & gdv,
92  const std::string& part)
93 {
94  for(u_int32_t i=0;i<gdv.size();i++){
95 
96  std::string const & detName = gdv[i]->name().fullname();
97  if (theStripDetTypeMap.find(detName) == theStripDetTypeMap.end()) {
98  std::auto_ptr<const Bounds> bounds(gdv[i]->bounds());
99  StripTopology* t =
100  theTopologyBuilder->buildStrip(&*bounds,
101  gdv[i]->siliconAPVNum(),
102  part);
103  theStripDetTypeMap[detName] = new StripGeomDetType( t,detName,det,
104  gdv[i]->stereo());
105  tracker->addType(theStripDetTypeMap[detName]);
106  }
107 
108  StripSubdetector sidet( gdv[i]->geographicalID());
109  double scale = (sidet.partnerDetId()) ? 0.5 : 1.0 ;
110 
112  GeomDetUnit* temp = new StripGeomDetUnit(&(*plane), theStripDetTypeMap[detName],gdv[i]);
113 
114  tracker->addDetUnit(temp);
115  tracker->addDetUnitId(gdv[i]->geographicalID());
116  }
117 }
118 
119 
121  PlaneBuilderForGluedDet gluedplaneBuilder;
122  std::vector<GeomDetUnit*> const & gdu= tracker->detUnits();
123  std::vector<DetId> const & gduId = tracker->detUnitIds();
124 
125  for(u_int32_t i=0;i<gdu.size();i++){
126  StripSubdetector sidet( gduId[i].rawId());
127  tracker->addDet((GeomDet*) gdu[i]);
128  tracker->addDetId(gduId[i]);
129  if(sidet.glued()!=0&&sidet.stereo()==1){
130  int partner_pos=-1;
131  for(u_int32_t jj=0;jj<gduId.size();jj++){
132  if(sidet.partnerDetId()== gduId[jj]) {
133  partner_pos=jj;
134  break;
135  }
136  }
137  const GeomDetUnit* dus = gdu[i];
138  if(partner_pos==-1){
139  throw cms::Exception("Configuration") <<"No partner detector found \n"
140  <<"There is a problem on Tracker geometry configuration\n";
141  }
142  const GeomDetUnit* dum = gdu[partner_pos];
143  std::vector<const GeomDetUnit *> glued(2);
144  glued[0]=dum;
145  glued[1]=dus;
146  PlaneBuilderForGluedDet::ResultType plane = gluedplaneBuilder.plane(glued);
147  GluedGeomDet* gluedDet = new GluedGeomDet(&(*plane),dum,dus);
148  tracker->addDet((GeomDet*) gluedDet);
149  tracker->addDetId(DetId(sidet.glued()));
150  }
151  }
152 }
153 
154 
155 // std::string TrackerGeomBuilderFromGeometricDet::getString(const std::string & s, DDExpandedView* ev) const
156 // {
157 // DDValue val(s);
158 // vector<const DDsvalues_type *> result;
159 // ev->specificsV(result);
160 // vector<const DDsvalues_type *>::iterator it = result.begin();
161 // bool foundIt = false;
162 // for (; it != result.end(); ++it)
163 // {
164 // foundIt = DDfetch(*it,val);
165 // if (foundIt) break;
166 
167 // }
168 // if (foundIt)
169 // {
170 // const std::vector<std::string> & temp = val.strings();
171 // if (temp.size() != 1)
172 // {
173 // throw cms::Exception("Configuration") << "I need 1 "<< s << " tags";
174 // }
175 // return temp[0];
176 // }
177 // return "NotFound";
178 // }
179 
180 // double TrackerGeomBuilderFromGeometricDet::getDouble(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 // if (foundIt)
193 // {
194 // const std::vector<std::string> & temp = val.strings();
195 // if (temp.size() != 1)
196 // {
197 // throw cms::Exception("Configuration") << "I need 1 "<< s << " tags";
198 // }
199 // return double(atof(temp[0].c_str()));
200 // }
201 // return 0;
202 // }
203 
206  double scale) const
207 {
208  PlaneBuilderFromGeometricDet planeBuilder;
209  PlaneBuilderFromGeometricDet::ResultType plane = planeBuilder.plane(gd);
210  //
211  // set medium properties (if defined)
212  //
213  plane->setMediumProperties(MediumProperties(gd->radLength()*scale,gd->xi()*scale));
214 
215  return plane;
216 }
int i
Definition: DBlmapReader.cc:9
double radLength() const
Definition: GeometricDet.h:240
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 glued() const
glued
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
StripTopology * buildStrip(const Bounds *, double, std::string)
ResultType plane(const GeometricDet *gd) const
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)