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.
15 
16 #include <cfloat>
17 #include <cassert>
18 using std::vector;
19 using std::string;
20 
21 namespace {
22  void verifyDUinTG(TrackerGeometry const & tg) {
23  int off=0; int end=0;
24  for ( int i=1; i!=7; i++) {
25  auto det = GeomDetEnumerators::tkDetEnum[i];
26  off = tg.offsetDU(det);
27  end = tg.endsetDU(det); assert(end>off);
28  for (int j=off; j!=end; ++j) {
29  assert(tg.detUnits()[j]->geographicalId().subdetId()==i);
30  assert(tg.detUnits()[j]->subDetector()==det);
31  assert(tg.detUnits()[j]->index()==j);
32  }
33  }
34  }
35 }
36 
39 {
40  bool upgradeGeometry = false;
41  int BIG_PIX_PER_ROC_X = 1;
42  int BIG_PIX_PER_ROC_Y = 2;
43 
44  if( pSet.exists( "trackerGeometryConstants" ))
45  {
46  const edm::ParameterSet tkGeomConsts( pSet.getParameter<edm::ParameterSet>( "trackerGeometryConstants" ));
47  upgradeGeometry = tkGeomConsts.getParameter<bool>( "upgradeGeometry" );
48  BIG_PIX_PER_ROC_X = tkGeomConsts.getParameter<int>( "BIG_PIX_PER_ROC_X" );
49  BIG_PIX_PER_ROC_Y = tkGeomConsts.getParameter<int>( "BIG_PIX_PER_ROC_Y" );
50  }
51 
52  thePixelDetTypeMap.clear();
53  theStripDetTypeMap.clear();
54 
56  std::vector<const GeometricDet*> comp;
57  gd->deepComponents(comp);
58 
59  std::vector<const GeometricDet*> dets[6];
60  std::vector<const GeometricDet*> & pixB = dets[0]; pixB.reserve(comp.size());
61  std::vector<const GeometricDet*> & pixF = dets[1]; pixF.reserve(comp.size());
62  std::vector<const GeometricDet*> & tib = dets[2]; tib.reserve(comp.size());
63  std::vector<const GeometricDet*> & tid = dets[3]; tid.reserve(comp.size());
64  std::vector<const GeometricDet*> & tob = dets[4]; tob.reserve(comp.size());
65  std::vector<const GeometricDet*> & tec = dets[5]; tec.reserve(comp.size());
66 
67  for(u_int32_t i = 0;i<comp.size();i++)
68  dets[comp[i]->geographicalID().subdetId()-1].push_back(comp[i]);
69 
70  // this order is VERY IMPORTANT!!!!!
72  upgradeGeometry,
73  BIG_PIX_PER_ROC_X,
74  BIG_PIX_PER_ROC_Y); //"PixelBarrel"
76  upgradeGeometry,
77  BIG_PIX_PER_ROC_X,
78  BIG_PIX_PER_ROC_Y); //"PixelEndcap"
79  buildSilicon(tib,tracker,GeomDetEnumerators::SubDetector::TIB, "barrel");//"TIB"
80  buildSilicon(tid,tracker,GeomDetEnumerators::SubDetector::TID, "endcap");//"TID"
81  buildSilicon(tob,tracker,GeomDetEnumerators::SubDetector::TOB, "barrel");//"TOB"
82  buildSilicon(tec,tracker,GeomDetEnumerators::SubDetector::TEC, "endcap");//"TEC"
83  buildGeomDet(tracker);//"GeomDet"
84 
85  verifyDUinTG(*tracker);
86 
87  return tracker;
88 }
89 
90 void TrackerGeomBuilderFromGeometricDet::buildPixel(std::vector<const GeometricDet*> const & gdv,
93  bool upgradeGeometry,
94  int BIG_PIX_PER_ROC_X, // in x direction, rows. BIG_PIX_PER_ROC_X = 0 for SLHC
95  int BIG_PIX_PER_ROC_Y) // in y direction, cols. BIG_PIX_PER_ROC_Y = 0 for SLHC
96 {
97  tracker->setOffsetDU(det);
98 
99  for(u_int32_t i=0; i<gdv.size(); i++){
100 
101  std::string const & detName = gdv[i]->name().fullname();
102  if (thePixelDetTypeMap.find(detName) == thePixelDetTypeMap.end()) {
103  std::unique_ptr<const Bounds> bounds(gdv[i]->bounds());
104 
105  PixelTopology* t =
106  PixelTopologyBuilder().build(&*bounds,
107  upgradeGeometry,
108  gdv[i]->pixROCRows(),
109  gdv[i]->pixROCCols(),
110  BIG_PIX_PER_ROC_X,
111  BIG_PIX_PER_ROC_Y,
112  gdv[i]->pixROCx(), gdv[i]->pixROCy());
113 
114  thePixelDetTypeMap[detName] = new PixelGeomDetType(t,detName,det);
115  tracker->addType(thePixelDetTypeMap[detName]);
116  }
117 
119  GeomDetUnit* temp = new PixelGeomDetUnit(&(*plane),thePixelDetTypeMap[detName],gdv[i]->geographicalID());
120 
121  tracker->addDetUnit(temp);
122  tracker->addDetUnitId(gdv[i]->geographicalID());
123  }
124  tracker->setEndsetDU(det);
125 
126 }
127 
128 void TrackerGeomBuilderFromGeometricDet::buildSilicon(std::vector<const GeometricDet*> const & gdv,
131  const std::string& part)
132 {
133  tracker->setOffsetDU(det);
134 
135  for(u_int32_t i=0;i<gdv.size();i++){
136 
137  std::string const & detName = gdv[i]->name().fullname();
138  if (theStripDetTypeMap.find(detName) == theStripDetTypeMap.end()) {
139  std::unique_ptr<const Bounds> bounds(gdv[i]->bounds());
140  StripTopology* t =
141  StripTopologyBuilder().build(&*bounds,
142  gdv[i]->siliconAPVNum(),
143  part);
144  theStripDetTypeMap[detName] = new StripGeomDetType( t,detName,det,
145  gdv[i]->stereo());
146  tracker->addType(theStripDetTypeMap[detName]);
147  }
148 
149  StripSubdetector sidet( gdv[i]->geographicalID());
150  double scale = (sidet.partnerDetId()) ? 0.5 : 1.0 ;
151 
153  GeomDetUnit* temp = new StripGeomDetUnit(&(*plane), theStripDetTypeMap[detName],gdv[i]->geographicalID());
154 
155  tracker->addDetUnit(temp);
156  tracker->addDetUnitId(gdv[i]->geographicalID());
157  }
158  tracker->setEndsetDU(det);
159 
160 }
161 
162 
164  PlaneBuilderForGluedDet gluedplaneBuilder;
165  auto const & gdu= tracker->detUnits();
166  auto const & gduId = tracker->detUnitIds();
167 
168  for(u_int32_t i=0;i<gdu.size();i++){
169  StripSubdetector sidet( gduId[i].rawId());
170  tracker->addDet((GeomDet*) gdu[i]);
171  tracker->addDetId(gduId[i]);
172  if(sidet.glued()!=0&&sidet.stereo()==1){
173  int partner_pos=-1;
174  for(u_int32_t jj=0;jj<gduId.size();jj++){
175  if(sidet.partnerDetId()== gduId[jj]) {
176  partner_pos=jj;
177  break;
178  }
179  }
180  const GeomDetUnit* dus = gdu[i];
181  if(partner_pos==-1){
182  throw cms::Exception("Configuration") <<"No partner detector found \n"
183  <<"There is a problem on Tracker geometry configuration\n";
184  }
185  const GeomDetUnit* dum = gdu[partner_pos];
186  std::vector<const GeomDetUnit *> glued(2);
187  glued[0]=dum;
188  glued[1]=dus;
189  PlaneBuilderForGluedDet::ResultType plane = gluedplaneBuilder.plane(glued);
190  GluedGeomDet* gluedDet = new GluedGeomDet(&(*plane),dum,dus);
191  tracker->addDet((GeomDet*) gluedDet);
192  tracker->addDetId(DetId(sidet.glued()));
193  }
194  }
195 }
196 
199  double scale) const
200 {
201  PlaneBuilderFromGeometricDet planeBuilder;
202  PlaneBuilderFromGeometricDet::ResultType plane = planeBuilder.plane(gd);
203  //
204  // set medium properties (if defined)
205  //
206  plane->setMediumProperties(MediumProperties(gd->radLength()*scale,gd->xi()*scale));
207 
208  return plane;
209 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
double radLength() const
Definition: GeometricDet.h:246
void addDet(GeomDet const *p)
StripTopology * build(const Bounds *, double, std::string)
void setEndsetDU(SubDetector sid)
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)
TrackerGeometry * build(const GeometricDet *gd, const edm::ParameterSet &pSet)
static const int BIG_PIX_PER_ROC_Y
Definition: TrackUtils.cc:60
bool exists(std::string const &parameterName) const
checks if a parameter exists
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)
unsigned int partnerDetId() const
ResultType plane(const std::vector< const GeomDetUnit * > &dets) const
void addDetId(DetId p)
virtual const DetUnitContainer & detUnits() const
Returm a vector of all GeomDetUnit.
void addDetUnit(GeomDetUnit const *p)
static const int BIG_PIX_PER_ROC_X
Definition: TrackUtils.cc:63
unsigned int endsetDU(SubDetector sid) const
unsigned int glued() const
glued
void setOffsetDU(SubDetector sid)
std::map< std::string, const StripGeomDetType * > theStripDetTypeMap
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
void addType(GeomDetType const *p)
unsigned int offsetDU(SubDetector sid) const
ResultType plane(const GeometricDet *gd) const
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:37
std::map< std::string, const PixelGeomDetType * > thePixelDetTypeMap
SubDetector tkDetEnum[8]
Definition: DetId.h:18
unsigned int stereo() const
stereo
double xi() const
Definition: GeometricDet.h:250
part
Definition: HCALResponse.h:20
void addDetUnitId(DetId p)
ConstGeometricDetContainer deepComponents() const
virtual const DetIdContainer & detUnitIds() const
Returm a vector of all GeomDetUnit DetIds.