CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Stub.cc
Go to the documentation of this file.
2 
3 namespace l1tVertexFinder {
4 
5  //=== Store useful info about this stub.
6 
8  : settings_(nullptr),
9  phi_(0.),
10  r_(0.),
11  z_(0.),
12  idDet_(0),
13  moduleMinR_(0.),
14  moduleMaxR_(0.),
15  moduleMinPhi_(0.),
16  moduleMaxPhi_(0.),
17  moduleMinZ_(0.),
18  moduleMaxZ_(0.),
19  psModule_(false),
20  layerId_(0),
21  endcapRing_(0),
22  barrel_(false),
23  sigmaPerp_(0.),
24  sigmaPar_(0.),
25  stripPitch_(0.),
26  stripLength_(0.),
27  nStrips_(0),
28  sensorWidth_(0.),
29  outerModuleAtSmallerR_(false) {}
30 
31  Stub::Stub(const TTStubRef& ttStubRef,
32  const AnalysisSettings& settings,
33  const TrackerGeometry* trackerGeometry,
34  const TrackerTopology* trackerTopology)
35  : TTStubRef(ttStubRef), settings_(&settings) {
36  auto geoDetId = trackerGeometry->idToDet(ttStubRef->clusterRef(0)->getDetId())->geographicalId();
37  auto theGeomDet = trackerGeometry->idToDet(geoDetId);
38  auto measurementPoint = ttStubRef->clusterRef(0)->findAverageLocalCoordinatesCentered();
39  auto pos = theGeomDet->surface().toGlobal(theGeomDet->topology().localPosition(measurementPoint));
40 
41  phi_ = pos.phi();
42  r_ = pos.perp();
43  z_ = pos.z();
44 
45  if (r_ < settings_->trackerInnerRadius() || r_ > settings_->trackerOuterRadius() ||
47  throw cms::Exception(
48  "Stub: Stub found outside assumed tracker volume. Please update tracker dimensions specified in Settings.h!")
49  << " r=" << r_ << " z=" << z_ << " " << ttStubRef->getDetId().subdetId() << std::endl;
50  }
51 
52  // Set info about the module this stub is in
53  this->setModuleInfo(trackerGeometry, trackerTopology, geoDetId);
54  }
55 
56  //=== Note which tracking particle(s), if any, produced this stub.
57  void Stub::fillTruth(edm::Handle<TTStubAssMap> mcTruthTTStubHandle,
58  edm::Handle<TTClusterAssMap> mcTruthTTClusterHandle) {
59  const TTStubRef& ttStubRef(*this); // Cast to base class
60 
61  //--- Fill assocTP_ info. If both clusters in this stub were produced by the same single tracking particle, find out which one it was.
62 
63  // Require same TP contributed to both clusters.
64  if (mcTruthTTStubHandle->isGenuine(ttStubRef)) {
65  assocTP_ = mcTruthTTStubHandle->findTrackingParticlePtr(ttStubRef);
66  }
67 
68  // Fill assocTPs_ info.
69  if (settings_->stubMatchStrict()) {
70  // We consider only stubs in which this TP contributed to both clusters.
71  if (!assocTP_.isNull())
72  assocTPs_.insert(assocTP_);
73  } else {
74  // We consider stubs in which this TP contributed to either cluster.
75 
76  for (unsigned int iClus = 0; iClus <= 1; iClus++) { // Loop over both clusters that make up stub.
77  const TTClusterRef& ttClusterRef = ttStubRef->clusterRef(iClus);
78 
79  // Now identify all TP's contributing to either cluster in stub.
80  std::vector<edm::Ptr<TrackingParticle>> vecTpPtr =
81  mcTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
82 
83  for (const edm::Ptr<TrackingParticle>& tpPtr : vecTpPtr) {
84  assocTPs_.insert(tpPtr);
85  }
86  }
87  }
88  }
89 
90  void Stub::setModuleInfo(const TrackerGeometry* trackerGeometry,
91  const TrackerTopology* trackerTopology,
92  const DetId& detId) {
93  idDet_ = detId();
94 
95  // Get min & max (r,phi,z) coordinates of the centre of the two sensors containing this stub.
96  const GeomDetUnit* det0 = trackerGeometry->idToDetUnit(detId);
97  const GeomDetUnit* det1 = trackerGeometry->idToDetUnit(trackerTopology->partnerDetId(detId));
98 
99  float R0 = det0->position().perp();
100  float R1 = det1->position().perp();
101  float PHI0 = det0->position().phi();
102  float PHI1 = det1->position().phi();
103  float Z0 = det0->position().z();
104  float Z1 = det1->position().z();
105  moduleMinR_ = std::min(R0, R1);
106  moduleMaxR_ = std::max(R0, R1);
107  moduleMinPhi_ = std::min(PHI0, PHI1);
108  moduleMaxPhi_ = std::max(PHI0, PHI1);
109  moduleMinZ_ = std::min(Z0, Z1);
110  moduleMaxZ_ = std::max(Z0, Z1);
111 
112  // Note if module is PS or 2S, and whether in barrel or endcap.
113  psModule_ =
114  trackerGeometry->getDetectorType(detId) ==
116  Ph2PSP; // From https://github.com/cms-sw/cmssw/blob/CMSSW_8_1_X/Geometry/TrackerGeometryBuilder/README.md
118 
119  // Encode layer ID.
120  if (barrel_) {
121  layerId_ = trackerTopology->layer(detId); // barrel layer 1-6 encoded as 1-6
122  } else {
123  // layerId_ = 10*detId.iSide() + detId.iDisk(); // endcap layer 1-5 encoded as 11-15 (endcap A) or 21-25 (endcapB)
124  // EJC This seems to give the same encoding
125  layerId_ = 10 * trackerTopology->side(detId) + trackerTopology->tidWheel(detId);
126  }
127 
128  // Note module ring in endcap
129  // endcapRing_ = barrel_ ? 0 : detId.iRing();
130  endcapRing_ = barrel_ ? 0 : trackerTopology->tidRing(detId);
131 
132  // Get sensor strip or pixel pitch using innermost sensor of pair.
133 
134  const PixelGeomDetUnit* unit = reinterpret_cast<const PixelGeomDetUnit*>(det0);
135  const PixelTopology& topo = unit->specificTopology();
136  const Bounds& bounds = det0->surface().bounds();
137 
138  std::pair<float, float> pitch = topo.pitch();
139  stripPitch_ = pitch.first; // Strip pitch (or pixel pitch along shortest axis)
140  stripLength_ = pitch.second; // Strip length (or pixel pitch along longest axis)
141  nStrips_ = topo.nrows(); // No. of strips in sensor
142  sensorWidth_ = bounds.width(); // Width of sensitive region of sensor (= stripPitch * nStrips).
143 
144  outerModuleAtSmallerR_ = false;
145  if (barrel_ && det0->position().perp() > det1->position().perp()) {
146  outerModuleAtSmallerR_ = true;
147  }
148 
149  sigmaPerp_ = stripPitch_ / sqrt(12.); // resolution perpendicular to strip (or to longest pixel axis)
150  sigmaPar_ = stripLength_ / sqrt(12.); // resolution parallel to strip (or to longest pixel axis)
151  }
152 
153 } // end namespace l1tVertexFinder
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
void fillTruth(edm::Handle< TTStubAssMap > mcTruthTTStubHandle, edm::Handle< TTClusterAssMap > mcTruthTTClusterHandle)
Definition: Stub.cc:57
std::set< TrackingParticlePtr > assocTPs_
Definition: Stub.h:112
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
unsigned int side(const DetId &id) const
virtual int nrows() const =0
unsigned int idDet_
Definition: Stub.h:92
const AnalysisSettings * settings_
Definition: Stub.h:85
float moduleMaxPhi_
Definition: Stub.h:96
const Bounds & bounds() const
Definition: Surface.h:87
unsigned int tidWheel(const DetId &id) const
float moduleMinPhi_
Definition: Stub.h:95
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
unsigned int layerId_
Definition: Stub.h:100
DetId partnerDetId(const DetId &id) const
double trackerOuterRadius() const
Definition: AlgoSettings.h:75
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
bool isNull() const
Checks for null.
Definition: Ptr.h:142
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
unsigned int nStrips_
Definition: Stub.h:107
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float moduleMaxR_
Definition: Stub.h:94
static constexpr auto TOB
ModuleType getDetectorType(DetId) const
void setModuleInfo(const TrackerGeometry *trackerGeometry, const TrackerTopology *trackerTopology, const DetId &detId)
Definition: Stub.cc:90
const TrackerGeomDet * idToDet(DetId) const override
float moduleMinZ_
Definition: Stub.h:97
float stripLength_
Definition: Stub.h:106
Definition: DetId.h:17
static constexpr auto TIB
double trackerHalfLength() const
Definition: AlgoSettings.h:78
static const double Z0
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
bool outerModuleAtSmallerR_
Definition: Stub.h:109
unsigned int layer(const DetId &id) const
float sensorWidth_
Definition: Stub.h:108
unsigned int endcapRing_
Definition: Stub.h:101
TrackingParticlePtr assocTP_
Definition: Stub.h:111
float moduleMinR_
Definition: Stub.h:93
float moduleMaxZ_
Definition: Stub.h:98
Definition: Bounds.h:18
virtual std::pair< float, float > pitch() const =0
virtual float width() const =0
Basic3DVector unit() const