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