CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SiStripRegionConnectivity.cc
Go to the documentation of this file.
13 
14 using namespace sistrip;
15 
17 public:
19  ~SiStripRegionConnectivity() override;
20 
21  std::unique_ptr<SiStripRegionCabling> produceRegionCabling(const SiStripRegionCablingRcd&);
22 
23 private:
27 
29  uint32_t etadivisions_;
30  uint32_t phidivisions_;
31 
33  double etamax_;
34 };
35 
37  : etadivisions_(pset.getUntrackedParameter<unsigned int>("EtaDivisions", 10)),
38  phidivisions_(pset.getUntrackedParameter<unsigned int>("PhiDivisions", 10)),
39  etamax_(pset.getUntrackedParameter<double>("EtaMax", 2.4))
40 
41 {
43  detcablingToken_ = cc.consumes();
44  tkgeomToken_ = cc.consumes();
45  tTopoToken_ = cc.consumes();
46 }
47 
49 
50 std::unique_ptr<SiStripRegionCabling> SiStripRegionConnectivity::produceRegionCabling(
51  const SiStripRegionCablingRcd& iRecord) {
52  const auto& detcabling = iRecord.get(detcablingToken_);
53  const auto& tkgeom = iRecord.get(tkgeomToken_);
54  const auto& tTopo = iRecord.get(tTopoToken_);
55 
56  //here build an object of type SiStripRegionCabling using the information from class SiStripDetCabling **PLUS** the geometry.
57 
58  //Construct region cabling object
59  auto RegionConnections = std::make_unique<SiStripRegionCabling>(etadivisions_, phidivisions_, etamax_);
60 
61  //Construct region cabling map
62  SiStripRegionCabling::Cabling regioncabling(
67 
68  //Loop det cabling
69  for (const auto& idet : detcabling.getDetCabling()) {
70  if (!idet.first || (idet.first == sistrip::invalid32_))
71  continue;
72 
73  // Check if geom det unit exists
74  auto geom_det = tkgeom.idToDetUnit(DetId(idet.first));
75  auto strip_det = dynamic_cast<StripGeomDetUnit const*>(geom_det);
76  if (!strip_det) {
77  continue;
78  }
79 
80  //Calculate region from geometry
81  double eta = tkgeom.idToDet(DetId(idet.first))->position().eta();
82  double phi = tkgeom.idToDet(DetId(idet.first))->position().phi().value();
83  uint32_t reg = RegionConnections->region(SiStripRegionCabling::Position(eta, phi));
84 
85  //Find subdet from det-id
86  uint32_t subdet = static_cast<uint32_t>(SiStripRegionCabling::subdetFromDetId(idet.first));
87 
88  //Find layer from det-id
89  uint32_t layer = tTopo.layer(idet.first);
90 
91  //@@ BELOW IS TEMP FIX TO HANDLE BUG IN DET CABLING
92  const std::vector<const FedChannelConnection*>& conns = idet.second;
93 
94  //Update region cabling map
95  regioncabling[reg][subdet][layer].push_back(SiStripRegionCabling::Element());
96  auto& elem = regioncabling[reg][subdet][layer].back();
97  elem.first = idet.first;
98  elem.second.resize(conns.size());
99  for (const auto& iconn : conns) {
100  if ((iconn != nullptr) && (iconn->apvPairNumber() < conns.size())) {
101  elem.second[iconn->apvPairNumber()] = *iconn;
102  }
103  }
104  }
105 
106  //Add map to region cabling object
107  RegionConnections->setRegionCabling(regioncabling);
108 
109  return RegionConnections;
110 }
111 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkgeomToken_
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
SiStripRegionConnectivity(const edm::ParameterSet &)
std::pair< uint32_t, std::vector< FedChannelConnection > > Element
static const uint32_t invalid32_
Definition: Constants.h:15
std::vector< Element > ElementCabling
sistrip classes
constexpr std::array< uint8_t, layerIndexSize > layer
static const SubDet subdetFromDetId(const uint32_t detid)
std::vector< RegionCabling > Cabling
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detcablingToken_
Definition: DetId.h:17
std::pair< double, double > Position
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
std::vector< WedgeCabling > RegionCabling
std::unique_ptr< SiStripRegionCabling > produceRegionCabling(const SiStripRegionCablingRcd &)
std::vector< ElementCabling > WedgeCabling
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const