CMS 3D CMS Logo

MTDDetLayerGeometry.cc
Go to the documentation of this file.
1 
8 
13 
16 
17 #include <algorithm>
18 
19 using namespace std;
20 using namespace geomsort;
21 
23 
25 
26 void MTDDetLayerGeometry::addETLLayers(const pair<vector<DetLayer*>, vector<DetLayer*> >& etllayers) {
27  for (auto const it : etllayers.first) {
28  etlLayers_fw.push_back(it);
29  allForward.push_back(it);
30 
31  detLayersMap[makeDetLayerId(it)] = it;
32  }
33 
34  for (auto const it : etllayers.second) {
35  etlLayers_bk.push_back(it);
36  allBackward.push_back(it);
37 
38  detLayersMap[makeDetLayerId(it)] = it;
39  }
40 }
41 
42 void MTDDetLayerGeometry::addBTLLayers(const vector<DetLayer*>& dtlayers) {
43  for (auto const it : dtlayers) {
44  btlLayers.push_back(it);
45  allBarrel.push_back(it);
46 
47  detLayersMap[makeDetLayerId(it)] = it;
48  }
49 }
50 
52  if (detLayer->subDetector() == GeomDetEnumerators::TimingEndcap) {
53  ETLDetId id(detLayer->basicComponents().front()->geographicalId().rawId());
54  return ETLDetId(id.mtdSide(), 0, 0, 0);
55  } else if (detLayer->subDetector() == GeomDetEnumerators::TimingBarrel) {
56  BTLDetId id(detLayer->basicComponents().front()->geographicalId().rawId());
57  return BTLDetId(id.mtdSide(), 0, 0, 0, 0);
58  } else
59  throw cms::Exception("InvalidModuleIdentification"); // << detLayer->module();
60 }
61 
62 const vector<const DetLayer*>& MTDDetLayerGeometry::allBarrelLayers() const { return allBarrel; }
63 
64 const vector<const DetLayer*>& MTDDetLayerGeometry::allEndcapLayers() const { return allEndcap; }
65 
66 const vector<const DetLayer*>& MTDDetLayerGeometry::allForwardLayers() const { return allForward; }
67 
68 const vector<const DetLayer*>& MTDDetLayerGeometry::allBackwardLayers() const { return allBackward; }
69 
70 const vector<const DetLayer*>& MTDDetLayerGeometry::allBTLLayers() const { return btlLayers; }
71 
72 const vector<const DetLayer*>& MTDDetLayerGeometry::allETLLayers() const { return etlLayers_all; }
73 
74 const vector<const DetLayer*>& MTDDetLayerGeometry::allLayers() const { return allDetLayers; }
75 
77 
79  DetId idout;
80  MTDDetId detId(id);
81 
82  if (detId.mtdSubDetector() == 2) { // 2 is ETL
83  ETLDetId etlId(detId.rawId());
84  idout = ETLDetId(etlId.mtdSide(), 0, 0, 0);
85  } else if (detId.mtdSubDetector() == 1) { // 1 is BTL
86  BTLDetId btlId(detId.rawId());
87  idout = BTLDetId(btlId.mtdSide(), 0, 0, 0, 0);
88  } else
89  throw cms::Exception("InvalidSubdetId") << detId.subdetId();
90 
91  std::map<DetId, const DetLayer*>::const_iterator layer = detLayersMap.find(idout);
92  if (layer == detLayersMap.end())
93  return nullptr;
94  return layer->second;
95 }
96 
97 // Quick way to sort barrel det layers by increasing R,
98 // do not abuse!
102  result_type operator()(const DetLayer* p) const {
103  const BarrelDetLayer* bdl = dynamic_cast<const BarrelDetLayer*>(p);
104  if (bdl)
105  return bdl->specificSurface().radius();
106  else
107  return -1.;
108  }
109 };
110 
112  // The following are filled inside-out, no need to re-sort
113  // precomputed_value_sort(dtLayers.begin(), dtLayers.end(),ExtractR<DetLayer,float>());
114  // precomputed_value_sort(cscLayers_fw.begin(), cscLayers_fw.end(),ExtractAbsZ<DetLayer,float>());
115  // precomputed_value_sort(cscLayers_bk.begin(), cscLayers_bk.end(),ExtractAbsZ<DetLayer,float>());
116  // precomputed_value_sort(rpcLayers_fw.begin(), rpcLayers_fw.end(),ExtractAbsZ<DetLayer,float>());
117  // precomputed_value_sort(rpcLayers_bk.begin(), rpcLayers_bk.end(),ExtractAbsZ<DetLayer,float>());
118  // precomputed_value_sort(rpcLayers_barrel.begin(), rpcLayers_barrel.end(), ExtractR<DetLayer,float>());
119 
120  // Sort these inside-out
121  precomputed_value_sort(allBarrel.begin(), allBarrel.end(), ExtractBarrelDetLayerR());
122  precomputed_value_sort(allBackward.begin(), allBackward.end(), ExtractAbsZ<DetLayer, float>());
123  precomputed_value_sort(allForward.begin(), allForward.end(), ExtractAbsZ<DetLayer, float>());
124 
125  // Build more complicated vectors with correct sorting
126 
127  //etlLayers_all: from -Z to +Z
128  etlLayers_all.reserve(etlLayers_bk.size() + etlLayers_fw.size());
129  std::copy(etlLayers_bk.begin(), etlLayers_bk.end(), back_inserter(etlLayers_all));
130  std::reverse(etlLayers_all.begin(), etlLayers_all.end());
131  std::copy(etlLayers_fw.begin(), etlLayers_fw.end(), back_inserter(etlLayers_all));
132 
133  // allEndcap: order is all bw, all fw
134  allEndcap.reserve(allBackward.size() + allForward.size());
135  std::copy(allBackward.begin(), allBackward.end(), back_inserter(allEndcap));
136  std::reverse(allEndcap.begin(), allEndcap.end());
137  std::copy(allForward.begin(), allForward.end(), back_inserter(allEndcap));
138 
139  // allDetLayers: order is all bw, all barrel, all fw
140  allDetLayers.reserve(allBackward.size() + allBarrel.size() + allForward.size());
141  std::copy(allBackward.begin(), allBackward.end(), back_inserter(allDetLayers));
142  std::reverse(allDetLayers.begin(), allDetLayers.end());
143  std::copy(allBarrel.begin(), allBarrel.end(), back_inserter(allDetLayers));
144  std::copy(allForward.begin(), allForward.end(), back_inserter(allDetLayers));
145 
146  // number layers
147  int sq = 0;
148  for (auto l : allDetLayers)
149  (*const_cast<DetLayer*>(l)).setSeqNum(sq++);
150 }
const std::vector< const DetLayer * > & allLayers() const
return all DetLayers (barrel + endcap), -Z to +Z
MTDDetLayerGeometry()
Constructor.
DetId makeDetLayerId(const DetLayer *detLayer) const
const std::vector< const DetLayer * > & allEndcapLayers() const
return all endcap layers
void addBTLLayers(const std::vector< DetLayer * > &btllayers)
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
virtual const std::vector< const GeomDet * > & basicComponents() const =0
~MTDDetLayerGeometry() override
Destructor.
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
const std::vector< const DetLayer * > & allBTLLayers() const
return the BTL DetLayers (barrel), inside-out
result_type operator()(const DetLayer *p) const
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
const std::vector< const DetLayer * > & allBackwardLayers() const
return all endcap layers
void addETLLayers(const std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > &etllayers)
const std::vector< const DetLayer * > & allETLLayers() const
return the ETL DetLayers (endcap), -Z to +Z
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
const DetLayer * idToLayer(const DetId &detId) const override
return the DetLayer which correspond to a certain DetId
const std::vector< const DetLayer * > & allForwardLayers() const
return all endcap layers
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
const std::vector< const DetLayer * > & allBarrelLayers() const
return all barrel layers
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:18
int mtdSubDetector() const
Definition: MTDDetId.h:56