test
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.
18 
19 #include <cfloat>
20 #include <cassert>
21 using std::vector;
22 using std::string;
23 
24 namespace {
25  void verifyDUinTG(TrackerGeometry const & tg) {
26  int off=0; int end=0;
27  for ( int i=1; i!=7; i++) {
28  auto det = GeomDetEnumerators::tkDetEnum[i];
29  off = tg.offsetDU(det);
30  end = tg.endsetDU(det); assert(end>=off); // allow empty subdetectors. Needed for upgrade
31  for (int j=off; j!=end; ++j) {
32  assert(tg.detUnits()[j]->geographicalId().subdetId()==i);
33  assert(GeomDetEnumerators::subDetGeom[tg.detUnits()[j]->subDetector()]==det);
34  assert(tg.detUnits()[j]->index()==j);
35  }
36  }
37  }
38 }
39 
42 {
43  int BIG_PIX_PER_ROC_X = ptp.vpars[2];
44  int BIG_PIX_PER_ROC_Y = ptp.vpars[3];
45 
46  thePixelDetTypeMap.clear();
47  theStripDetTypeMap.clear();
48 
50  std::vector<const GeometricDet*> comp;
51  gd->deepComponents(comp);
52 
53  //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
54 
55  std::vector<GeometricDet::GDEnumType> gdsubdetmap(6,GeometricDet::unknown); // hardcoded "6" should not be a surprise...
57 
58  LogDebug("SubDetectorGeometricDetType") << "GeometriDet enumerator values of the subdetectors";
59  for(unsigned int i=0;i<subdetgd.size();++i) {
60  assert(subdetgd[i]->geographicalId().subdetId()>0 && subdetgd[i]->geographicalId().subdetId()<7);
61  gdsubdetmap[subdetgd[i]->geographicalId().subdetId()-1]= subdetgd[i]->type();
62  LogTrace("SubDetectorGeometricDetType") << "subdet " << i
63  << " type " << subdetgd[i]->type()
64  << " detid " << subdetgd[i]->geographicalId()
65  << " subdetid " << subdetgd[i]->geographicalId().subdetId();
66  }
67 
68  std::vector<const GeometricDet*> dets[6];
69  std::vector<const GeometricDet*> & pixB = dets[0]; pixB.reserve(comp.size());
70  std::vector<const GeometricDet*> & pixF = dets[1]; pixF.reserve(comp.size());
71  std::vector<const GeometricDet*> & tib = dets[2]; tib.reserve(comp.size());
72  std::vector<const GeometricDet*> & tid = dets[3]; tid.reserve(comp.size());
73  std::vector<const GeometricDet*> & tob = dets[4]; tob.reserve(comp.size());
74  std::vector<const GeometricDet*> & tec = dets[5]; tec.reserve(comp.size());
75 
76  for(u_int32_t i = 0;i<comp.size();i++)
77  dets[comp[i]->geographicalID().subdetId()-1].push_back(comp[i]);
78 
79  //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 !!
80  // this order is VERY IMPORTANT!!!!! For the moment I (AndreaV) understand that some pieces of code rely on pixel-like being before strip-like
81 
82  // now building the Pixel-like subdetectors
83  for(unsigned int i=0;i<6;++i) {
84  if(gdsubdetmap[i] == GeometricDet::PixelBarrel)
86  false,
87  BIG_PIX_PER_ROC_X,
88  BIG_PIX_PER_ROC_Y);
89  if(gdsubdetmap[i] == GeometricDet::PixelPhase1Barrel)
91  true,
92  BIG_PIX_PER_ROC_X,
93  BIG_PIX_PER_ROC_Y);
94  if(gdsubdetmap[i] == GeometricDet::PixelEndCap)
96  false,
97  BIG_PIX_PER_ROC_X,
98  BIG_PIX_PER_ROC_Y);
99  if(gdsubdetmap[i] == GeometricDet::PixelPhase1EndCap)
101  true,
102  BIG_PIX_PER_ROC_X,
103  BIG_PIX_PER_ROC_Y);
104  if(gdsubdetmap[i] == GeometricDet::PixelPhase2EndCap)
106  true,
107  BIG_PIX_PER_ROC_X,
108  BIG_PIX_PER_ROC_Y);
109  if(gdsubdetmap[i] == GeometricDet::OTPhase2Barrel)
111  true,
112  BIG_PIX_PER_ROC_X,
113  BIG_PIX_PER_ROC_Y);
114  if(gdsubdetmap[i] == GeometricDet::OTPhase2EndCap)
116  true,
117  BIG_PIX_PER_ROC_X,
118  BIG_PIX_PER_ROC_Y);
119  }
120  //now building Strips
121  for(unsigned int i=0;i<6;++i) {
122  if(gdsubdetmap[i] == GeometricDet::TIB) buildSilicon(dets[i],tracker,GeomDetEnumerators::SubDetector::TIB, "barrel");
123  if(gdsubdetmap[i] == GeometricDet::TID) buildSilicon(dets[i],tracker,GeomDetEnumerators::SubDetector::TID, "endcap");
124  if(gdsubdetmap[i] == GeometricDet::TOB) buildSilicon(dets[i],tracker,GeomDetEnumerators::SubDetector::TOB, "barrel");
125  if(gdsubdetmap[i] == GeometricDet::TEC) buildSilicon(dets[i],tracker,GeomDetEnumerators::SubDetector::TEC, "endcap");
126  }
127  // and finally the "empty" subdetectors (maybe it is not needed)
128  for(unsigned int i=0;i<6;++i) {
129  if(gdsubdetmap[i] == GeometricDet::unknown) {
130  if(dets[i].size()!=0) throw cms::Exception("NotEmptyUnknownSubDet") << "Subdetector " << i+1 << " is unknown but it is not empty: " << dets[i].size();
131  buildSilicon(dets[i],tracker,GeomDetEnumerators::tkDetEnum[i+1], "barrel"); // "barrel" is used but it is irrelevant
132  }
133  }
134  buildGeomDet(tracker);//"GeomDet"
135 
136  verifyDUinTG(*tracker);
137 
138  return tracker;
139 }
140 
141 void TrackerGeomBuilderFromGeometricDet::buildPixel(std::vector<const GeometricDet*> const & gdv,
144  bool upgradeGeometry,
145  int BIG_PIX_PER_ROC_X, // in x direction, rows. BIG_PIX_PER_ROC_X = 0 for SLHC
146  int BIG_PIX_PER_ROC_Y) // in y direction, cols. BIG_PIX_PER_ROC_Y = 0 for SLHC
147 {
148  LogDebug("BuildingGeomDetUnits") << " Pixel type. Size of vector: " << gdv.size()
149  << " GeomDetType subdetector: " << det
150  << " logical subdetector: " << GeomDetEnumerators::subDetGeom[det]
151  << " big pix per ROC x: " << BIG_PIX_PER_ROC_X << " y: " << BIG_PIX_PER_ROC_Y
152  << " is upgrade: " << upgradeGeometry;
153 
155 
156  for(u_int32_t i=0; i<gdv.size(); i++){
157 
158  std::string const & detName = gdv[i]->name().fullname();
159  if (thePixelDetTypeMap.find(detName) == thePixelDetTypeMap.end()) {
160  std::unique_ptr<const Bounds> bounds(gdv[i]->bounds());
161 
162  PixelTopology* t =
163  PixelTopologyBuilder().build(&*bounds,
164  upgradeGeometry,
165  gdv[i]->pixROCRows(),
166  gdv[i]->pixROCCols(),
167  BIG_PIX_PER_ROC_X,
168  BIG_PIX_PER_ROC_Y,
169  gdv[i]->pixROCx(), gdv[i]->pixROCy());
170 
171  thePixelDetTypeMap[detName] = new PixelGeomDetType(t,detName,det);
172  tracker->addType(thePixelDetTypeMap[detName]);
173  }
174 
176  GeomDetUnit* temp = new PixelGeomDetUnit(&(*plane),thePixelDetTypeMap[detName],gdv[i]->geographicalID());
177 
178  tracker->addDetUnit(temp);
179  tracker->addDetUnitId(gdv[i]->geographicalID());
180  }
182 }
183 
184 void TrackerGeomBuilderFromGeometricDet::buildSilicon(std::vector<const GeometricDet*> const & gdv,
187  const std::string& part)
188 {
189  LogDebug("BuildingGeomDetUnits") << " Strip type. Size of vector: " << gdv.size()
190  << " GeomDetType subdetector: " << det
191  << " logical subdetector: " << GeomDetEnumerators::subDetGeom[det]
192  << " part " << part;
193 
195 
196  for(u_int32_t i=0;i<gdv.size();i++){
197 
198  std::string const & detName = gdv[i]->name().fullname();
199  if (theStripDetTypeMap.find(detName) == theStripDetTypeMap.end()) {
200  std::unique_ptr<const Bounds> bounds(gdv[i]->bounds());
201  StripTopology* t =
202  StripTopologyBuilder().build(&*bounds,
203  gdv[i]->siliconAPVNum(),
204  part);
205  theStripDetTypeMap[detName] = new StripGeomDetType( t,detName,det,
206  gdv[i]->stereo());
207  tracker->addType(theStripDetTypeMap[detName]);
208  }
209 
210  StripSubdetector sidet( gdv[i]->geographicalID());
211  double scale = (sidet.partnerDetId()) ? 0.5 : 1.0 ;
212 
214  GeomDetUnit* temp = new StripGeomDetUnit(&(*plane), theStripDetTypeMap[detName],gdv[i]->geographicalID());
215 
216  tracker->addDetUnit(temp);
217  tracker->addDetUnitId(gdv[i]->geographicalID());
218  }
220 
221 }
222 
223 
225  PlaneBuilderForGluedDet gluedplaneBuilder;
226  auto const & gdu= tracker->detUnits();
227  auto const & gduId = tracker->detUnitIds();
228 
229  for(u_int32_t i=0;i<gdu.size();i++){
230  StripSubdetector sidet( gduId[i].rawId());
231  tracker->addDet(gdu[i]);
232  tracker->addDetId(gduId[i]);
233  if(sidet.glued()!=0&&sidet.stereo()==1){
234  int partner_pos=-1;
235  for(u_int32_t jj=0;jj<gduId.size();jj++){
236  if(sidet.partnerDetId()== gduId[jj]) {
237  partner_pos=jj;
238  break;
239  }
240  }
241  const GeomDetUnit* dus = gdu[i];
242  if(partner_pos==-1){
243  throw cms::Exception("Configuration") <<"No partner detector found \n"
244  <<"There is a problem on Tracker geometry configuration\n";
245  }
246  const GeomDetUnit* dum = gdu[partner_pos];
247  std::vector<const GeomDetUnit *> glued(2);
248  glued[0]=dum;
249  glued[1]=dus;
250  PlaneBuilderForGluedDet::ResultType plane = gluedplaneBuilder.plane(glued);
251  GluedGeomDet* gluedDet = new GluedGeomDet(&(*plane),dum,dus);
252  tracker->addDet((GeomDet*) gluedDet);
253  tracker->addDetId(DetId(sidet.glued()));
254  }
255  }
256 }
257 
260  double scale) const
261 {
262  PlaneBuilderFromGeometricDet planeBuilder;
263  PlaneBuilderFromGeometricDet::ResultType plane = planeBuilder.plane(gd);
264  //
265  // set medium properties (if defined)
266  //
267  plane->setMediumProperties(MediumProperties(gd->radLength()*scale,gd->xi()*scale));
268 
269  return plane;
270 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::vector< int > vpars
double radLength() const
Definition: GeometricDet.h:251
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)
assert(m_qm.get())
static const int BIG_PIX_PER_ROC_Y
Definition: TrackUtils.cc:66
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
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:174
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:69
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]
#define LogTrace(id)
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:36
Definition: DetId.h:18
unsigned int stereo() const
stereo
SubDetector subDetGeom[18]
double xi() const
Definition: GeometricDet.h:255
part
Definition: HCALResponse.h:20
void addDetUnitId(DetId p)
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp)
ConstGeometricDetContainer deepComponents() const
virtual const DetIdContainer & detUnitIds() const
Returm a vector of all GeomDetUnit DetIds.
tuple size
Write out results.