CMS 3D CMS Logo

LayerEncoding.cc
Go to the documentation of this file.
4 
5 #include <vector>
6 #include <set>
7 #include <algorithm>
8 #include <iterator>
9 
10 using namespace std;
11 using namespace edm;
12 using namespace tt;
13 
14 namespace trackerDTC {
15 
16  LayerEncoding::LayerEncoding(const ParameterSet& iConfig, const Setup* setup)
17  : setup_(setup), numDTCsPerRegion_(setup->numDTCsPerRegion()) {
19  for (int dtcInRegion = 0; dtcInRegion < setup->numDTCsPerRegion(); dtcInRegion++) {
20  set<int> encodingLayerId;
21  for (int region = 0; region < setup->numRegions(); region++) {
22  const int dtcId = dtcInRegion + region * setup->numDTCsPerRegion();
23  const vector<SensorModule*>& modules = setup->dtcModules(dtcId);
24  for (SensorModule* sm : modules)
25  encodingLayerId.insert(sm->layerId());
26  }
27  // check configuration
28  if ((int)encodingLayerId.size() > setup->hybridNumLayers()) {
29  cms::Exception exception("overflow");
30  exception << "Cabling map connects more than " << setup->hybridNumLayers() << " layers to a DTC.";
31  exception.addContext("trackerDTC::LayerEncoding::LayerEncoding");
32  throw exception;
33  }
34  encodingsLayerId_.emplace_back(encodingLayerId.begin(), encodingLayerId.end());
35  }
36  }
37 
38  // decode layer id for given sensor module
40  const vector<int>& encoding = encodingsLayerId_.at(sm->dtcId() % setup_->numDTCsPerRegion());
41  const auto pos = find(encoding.begin(), encoding.end(), sm->layerId());
42  return distance(encoding.begin(), pos);
43  }
44 
45 } // namespace trackerDTC
std::vector< std::vector< int > > encodingsLayerId_
Definition: LayerEncoding.h:35
Class to process and provide run-time constants used by Track Trigger emulators.
Definition: Setup.h:44
int numDTCsPerRegion() const
Definition: Setup.h:351
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Definition: TTTypes.h:54
const tt::Setup * setup_
Definition: LayerEncoding.h:31
int dtcId() const
Definition: SensorModule.h:21
Definition: DTC.h:12
HLT enums.
int decode(tt::SensorModule *sm) const
int layerId() const
Definition: SensorModule.h:43