CMS 3D CMS Logo

ETLDetLayerGeometryBuilder.cc
Go to the documentation of this file.
2 
7 
10 
12 
13 #include <iostream>
14 
15 using namespace std;
16 
17 pair<vector<DetLayer*>, vector<DetLayer*> >
19 
20  vector<DetLayer*> result[2]; // one for each endcap
21 
22  for(unsigned endcap=0; endcap<2; ++endcap) {
23  // there is only one layer for ETL right now, maybe more later
24  for(unsigned layer = 0; layer <= 0; ++layer) {
25  vector<unsigned> rings;
26  for(unsigned ring = 1; ring <= 12; ++ring) {
27  rings.push_back(ring);
28  }
29  MTDRingForwardDoubleLayer* thelayer = buildLayer(endcap, layer, rings, geo);
30  if (thelayer) result[endcap].push_back(thelayer);
31  }
32  }
33  pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[0], result[1]);
34  return res_pair;
35 }
36 
38  int layer,
39  vector<unsigned>& rings,
40  const MTDGeometry& geo) {
41  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|ETLDetLayerGeometryBuilder";
43 
44  vector<const ForwardDetRing*> frontRings, backRings;
45 
46  for(unsigned ring : rings ) {
47  vector<const GeomDet*> frontGeomDets, backGeomDets;
48  for(unsigned module = 1; module <= ETLDetId::kETLmoduleMask; ++module) {
49  ETLDetId detId(endcap, ring, module,0);
50  const GeomDet* geomDet = geo.idToDet(detId);
51  // we sometimes loop over more chambers than there are in ring
52  bool isInFront = isFront(layer, ring, module);
53  if(geomDet != nullptr)
54  {
55  if(isInFront)
56  {
57  frontGeomDets.push_back(geomDet);
58  }
59  else
60  {
61  backGeomDets.push_back(geomDet);
62  }
63  LogTrace(metname)
64  << "get ETL module "
65  << std::hex << ETLDetId(endcap, layer, ring, module).rawId() << std::dec
66  << " at R=" << geomDet->position().perp()
67  << ", phi=" << geomDet->position().phi()
68  << ", z= " << geomDet->position().z()
69  << " isFront? " << isInFront << std::endl;
70  }
71  }
72 
73  if(!backGeomDets.empty())
74  {
75  backRings.push_back(makeDetRing(backGeomDets));
76  }
77 
78  if(!frontGeomDets.empty())
79  {
80  frontRings.push_back(makeDetRing(frontGeomDets));
81  assert(!backGeomDets.empty());
82  float frontz = frontRings[0]->position().z();
83  float backz = backRings[0]->position().z();
84  assert(fabs(frontz) < fabs(backz));
85  }
86  }
87 
88  // How should they be sorted?
89  // precomputed_value_sort(muDetRods.begin(), muDetRods.end(), geomsort::ExtractZ<GeometricSearchDet,float>());
90  result = new MTDRingForwardDoubleLayer(frontRings, backRings);
91  LogTrace(metname)
92  << "New MTDRingForwardLayer with " << frontRings.size()
93  << " and " << backRings.size()
94  << " rings, at Z " << result->position().z()
95  << " R1: " << result->specificSurface().innerRadius()
96  << " R2: " << result->specificSurface().outerRadius() << std::endl;
97  return result;
98 }
99 
100 
102 {
103  return (module+1)%2;
104 }
105 
106 
107 
108 MTDDetRing * ETLDetLayerGeometryBuilder::makeDetRing(vector<const GeomDet*> & geomDets)
109 {
110  const std::string metname = "MTD|RecoMTD|RecoMTDDetLayers|ETLDetLayerGeometryBuilder";
111 
112 
113  precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetPhi());
114  MTDDetRing * result = new MTDDetRing(geomDets);
115  LogTrace(metname)
116  << "New MTDDetRing with " << geomDets.size()
117  << " chambers at z="<< result->position().z()
118  << " R1: " << result->specificSurface().innerRadius()
119  << " R2: " << result->specificSurface().outerRadius() << std::endl;;
120  return result;
121 }
122 
static MTDDetRing * makeDetRing(std::vector< const GeomDet * > &geomDets)
ExtractPhi< GeomDet, float > DetPhi
Definition: DetSorting.h:39
T perp() const
Definition: PV3DBase.h:72
const std::string metname
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
static bool isFront(int layer, int ring, int module)
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:184
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:48
T z() const
Definition: PV3DBase.h:64
#define LogTrace(id)
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
static const uint32_t kETLmoduleMask
Definition: ETLDetId.h:20
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
static std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > buildLayers(const MTDGeometry &geo)
static MTDRingForwardDoubleLayer * buildLayer(int endcap, int layer, std::vector< unsigned > &rings, const MTDGeometry &geo)
Definition: vlib.h:208