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