CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SensorModule.cc
Go to the documentation of this file.
4 
5 #include <cmath>
6 #include <algorithm>
7 #include <iterator>
8 #include <vector>
9 
10 using namespace std;
11 using namespace edm;
12 
13 namespace trackerDTC {
14 
15  SensorModule::SensorModule(const Setup& setup, const DetId& detId, int dtcId, int modId)
16  : detId_(detId), dtcId_(dtcId), modId_(modId) {
17  const TrackerGeometry* trackerGeometry = setup.trackerGeometry();
18  const TrackerTopology* trackerTopology = setup.trackerTopology();
19  const GeomDetUnit* geomDetUnit = trackerGeometry->idToDetUnit(detId);
20  const PixelTopology* pixelTopology =
21  dynamic_cast<const PixelTopology*>(&(dynamic_cast<const PixelGeomDetUnit*>(geomDetUnit)->specificTopology()));
22  const Plane& plane = dynamic_cast<const PixelGeomDetUnit*>(geomDetUnit)->surface();
23  const GlobalPoint pos0 = GlobalPoint(geomDetUnit->position());
24  const GlobalPoint pos1 =
25  GlobalPoint(trackerGeometry->idToDetUnit(trackerTopology->partnerDetId(detId))->position());
26  // detector region [0-8]
27  const int region = dtcId_ / setup.numDTCsPerRegion();
28  // module radius in cm
29  r_ = pos0.perp();
30  // module phi w.r.t. detector region_ centre in rad
31  phi_ = deltaPhi(pos0.phi() - (region + .5) * setup.baseRegion());
32  // module z in cm
33  z_ = pos0.z();
34  // sensor separation in cm
35  sep_ = (pos1 - pos0).mag();
36  // sensor pitch in cm [strip=.009,pixel=.01]
37  pitchRow_ = pixelTopology->pitch().first;
38  // sensor length in cm [strip=5,pixel=.15625]
39  pitchCol_ = pixelTopology->pitch().second;
40  // number of columns [2S=2,PS=8]
41  numColumns_ = pixelTopology->ncolumns();
42  // number of rows [2S=8*127,PS=8*120]
43  numRows_ = pixelTopology->nrows();
44  // +z or -z
45  side_ = pos0.z() >= 0.;
46  // main sensor inside or outside
47  flipped_ = pos0.mag() > pos1.mag();
48  // barrel or endcap
50  // Pixel-Strip or 2Strip module
52  // module tilt measured w.r.t. beam axis (0=barrel), tk layout measures w.r.t. radial axis
53  tilt_ = flipped_ ? atan2(pos1.z() - pos0.z(), pos0.perp() - pos1.perp())
54  : atan2(pos0.z() - pos1.z(), pos1.perp() - pos0.perp());
55  // sinus of module tilt measured w.r.t. beam axis (0=barrel), tk layout measures w.r.t. radial axis
56  sin_ = std::sin(tilt_);
57  // cosinus of module tilt measured w.r.t. beam axis (+-1=endcap), tk layout measures w.r.t. radial axis
58  cos_ = std::cos(tilt_);
59  // layer id [barrel: 0-5, endcap: 0-4]
60  const int layer =
61  (barrel_ ? trackerTopology->layer(detId) : trackerTopology->tidWheel(detId)) - setup.offsetLayerId();
62  // layer id [1-6,11-15]
63  layerId_ = layer + setup.offsetLayerId() + (barrel_ ? 0 : setup.offsetLayerDisks());
64  // TTStub row needs flip of sign
65  signRow_ = signbit(deltaPhi(plane.rotation().x().phi() - pos0.phi()));
66  // TTStub col needs flip of sign
67  signCol_ = !barrel_ && !side_;
68  // TTStub bend needs flip of sign
69  signBend_ = barrel_ || (!barrel_ && side_);
70  // determing sensor type
71  if (barrel_ && psModule_)
72  type_ = BarrelPS;
73  if (barrel_ && !psModule_)
74  type_ = Barrel2S;
75  if (!barrel_ && psModule_)
76  type_ = DiskPS;
77  if (!barrel_ && !psModule_)
78  type_ = Disk2S;
79  // encoding for 2S endcap radii
80  encodedR_ = -1;
81  if (type_ == Disk2S) {
82  const int offset = setup.hybridNumRingsPS(layer);
83  const int ring = trackerTopology->tidRing(detId);
84  encodedR_ = numColumns_ * (ring - offset);
85  }
86  // r and z offsets
87  if (barrel_) {
88  offsetR_ = setup.hybridLayerR(layer);
89  offsetZ_ = 0.;
90  } else {
91  offsetR_ = 0.;
92  offsetZ_ = side_ ? setup.hybridDiskZ(layer) : -setup.hybridDiskZ(layer);
93  }
94  // getting bend window size
95  double windowSize(-1.);
96  if (barrel_) {
97  enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 };
98  const TypeBarrel type = static_cast<TypeBarrel>(trackerTopology->tobSide(detId));
99  if (type == flat)
100  windowSize = setup.windowSizeBarrelLayer(layerId_);
101  else {
102  int ladder = trackerTopology->tobRod(detId);
103  if (type == tiltedMinus)
104  // Corrected ring number, bet 0 and barrelNTilt.at(layer), in ascending |z|
105  ladder = 1 + setup.numTiltedLayerRing(layerId_) - ladder;
106  windowSize = setup.windowSizeTiltedLayerRing(layerId_, ladder);
107  }
108  } else {
109  const int ring = trackerTopology->tidRing(detId);
110  const int lay = layer + setup.offsetLayerId();
111  windowSize = setup.windowSizeEndcapDisksRing(lay, ring);
112  }
113  windowSize_ = windowSize / setup.baseWindowSize();
114  // getting encoded layer id
115  const vector<int>& encodingLayerId = setup.encodingLayerId(dtcId_);
116  const auto pos = find(encodingLayerId.begin(), encodingLayerId.end(), layerId_);
117  encodedLayerId_ = distance(encodingLayerId.begin(), pos);
118  }
119 
120 } // namespace trackerDTC
T perp() const
Definition: PV3DBase.h:69
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
unsigned int tidRing(const DetId &id) const
virtual int ncolumns() const =0
double baseRegion() const
Definition: Setup.h:98
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
virtual int nrows() const =0
unsigned int tidWheel(const DetId &id) const
Geom::Phi< T > phi() const
double windowSizeBarrelLayer(int layerId) const
Definition: Setup.h:185
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Definition: Plane.h:16
double deltaPhi(double lhs, double rhs=0.)
Definition: Setup.h:34
Basic3DVector< T > x() const
DetId partnerDetId(const DetId &id) const
constexpr std::array< uint8_t, layerIndexSize > layer
int numDTCsPerRegion() const
Definition: Setup.h:223
T mag() const
Definition: PV3DBase.h:64
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
double windowSizeTiltedLayerRing(int layerId, int ring) const
Definition: Setup.h:187
const TrackerTopology * trackerTopology() const
Definition: Setup.h:77
T z() const
Definition: PV3DBase.h:61
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int tobSide(const DetId &id) const
const std::vector< int > & encodingLayerId(int tfpChannel) const
Definition: Setup.cc:339
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
double hybridDiskZ(int layerId) const
Definition: Setup.h:178
double numTiltedLayerRing(int layerId) const
Definition: Setup.h:183
double baseWindowSize() const
Definition: Setup.h:195
static constexpr auto TOB
ModuleType getDetectorType(DetId) const
Class to process and provide run-time constants used by Track Trigger emulators.
Definition: Setup.h:41
int hybridNumRingsPS(int layerId) const
Definition: Setup.h:174
const TrackerGeometry * trackerGeometry() const
Definition: Setup.h:75
Definition: DetId.h:17
int offsetLayerId() const
Definition: Setup.h:241
double windowSizeEndcapDisksRing(int layerId, int ring) const
Definition: Setup.h:191
double hybridLayerR(int layerId) const
Definition: Setup.h:176
unsigned int layer(const DetId &id) const
int offsetLayerDisks() const
Definition: Setup.h:239
static int position[264][3]
Definition: ReadPGInfo.cc:289
const RotationType & rotation() const
virtual std::pair< float, float > pitch() const =0
unsigned int tobRod(const DetId &id) const