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!
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 }
MTDDetLayerGeometry::sortLayers
void sortLayers()
Definition: MTDDetLayerGeometry.cc:111
BTLDetId.h
ExtractBarrelDetLayerR
Definition: MTDDetLayerGeometry.cc:100
MTDDetLayerGeometry::~MTDDetLayerGeometry
~MTDDetLayerGeometry() override
Destructor.
Definition: MTDDetLayerGeometry.cc:24
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
MTDDetLayerGeometry::addETLLayers
void addETLLayers(const std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > &etllayers)
Definition: MTDDetLayerGeometry.cc:26
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
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ETLDetId
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
ETLDetId.h
precomputed_value_sort.h
MTDDetLayerGeometry::makeDetLayerId
DetId makeDetLayerId(const DetLayer *detLayer) const
Definition: MTDDetLayerGeometry.cc:51
MTDDetLayerGeometry::addBTLLayers
void addBTLLayers(const std::vector< DetLayer * > &btllayers)
Definition: MTDDetLayerGeometry.cc:42
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:62
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
ExtractBarrelDetLayerR::result_type
Surface::Scalar result_type
Definition: MTDDetLayerGeometry.cc:101
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:102
MTDDetId::mtdSubDetector
int mtdSubDetector() const
Definition: MTDDetId.h:56
MTDDetLayerGeometry::idToLayer
const DetLayer * idToLayer(const DetId &detId) const override
return the DetLayer which correspond to a certain DetId
Definition: MTDDetLayerGeometry.cc:78
BarrelDetLayer.h
MTDDetLayerGeometry::MTDDetLayerGeometry
MTDDetLayerGeometry()
Constructor.
Definition: MTDDetLayerGeometry.cc:22
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:70
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:68
MTDDetLayerGeometry::allLayers
const std::vector< const DetLayer * > & allLayers() const
return all DetLayers (barrel + endcap), -Z to +Z
Definition: MTDDetLayerGeometry.cc:74
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:31
MTDDetId
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
Exception
Definition: hltDiff.cc:246
MTDDetLayerGeometry::allForwardLayers
const std::vector< const DetLayer * > & allForwardLayers() const
return all endcap layers
Definition: MTDDetLayerGeometry.cc:66
GeometricSorting.h
DetLayer.h
MTDDetLayerGeometry::allEndcapLayers
const std::vector< const DetLayer * > & allEndcapLayers() const
return all endcap layers
Definition: MTDDetLayerGeometry.cc:64
Exception.h
MTDDetLayerGeometry::allETLLayers
const std::vector< const DetLayer * > & allETLLayers() const
return the ETL DetLayers (endcap), -Z to +Z
Definition: MTDDetLayerGeometry.cc:72
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
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