CMS 3D CMS Logo

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