CMS 3D CMS Logo

TTStubAlgorithm_official.cc
Go to the documentation of this file.
1 
12 
14 template <>
16  bool& aConfirmation,
17  int& aDisplacement,
18  int& anOffset,
19  float& anHardBend,
20  const TTStub<Ref_Phase2TrackerDigi_>& aTTStub) const {
22  // These are already corrected for being at the center of each pixel
23  MeasurementPoint mp0 = aTTStub.clusterRef(0)->findAverageLocalCoordinates();
24  MeasurementPoint mp1 = aTTStub.clusterRef(1)->findAverageLocalCoordinates();
25 
26  bool isPS = aTTStub.moduleTypePS(); // get it from the stub now
27 
29  // TODO temporary: should use a method from the topology
30  DetId stDetId(aTTStub.getDetId());
31  const GeomDetUnit* det0 = theTrackerGeom_->idToDetUnit(stDetId + 1);
32  const GeomDetUnit* det1 = theTrackerGeom_->idToDetUnit(stDetId + 2);
33 
35  const PixelGeomDetUnit* pix0 = dynamic_cast<const PixelGeomDetUnit*>(det0);
36  const PixelGeomDetUnit* pix1 = dynamic_cast<const PixelGeomDetUnit*>(det1);
37  const PixelTopology* top0 = dynamic_cast<const PixelTopology*>(&(pix0->specificTopology()));
38  const PixelTopology* top1 = dynamic_cast<const PixelTopology*>(&(pix1->specificTopology()));
39  std::pair<float, float> pitch0 = top0->pitch();
40  std::pair<float, float> pitch1 = top1->pitch();
41 
43  int cols0 = top0->ncolumns();
44  int cols1 = top1->ncolumns();
45  int ratio = cols0 / cols1;
46  int segment0 = floor(mp0.y() / ratio);
47 
48  // if ( ratio == 1 ) /// 2S Modules
49  if (!isPS) {
50  if (mPerformZMatching2S && (segment0 != floor(mp1.y())))
51  return;
52  } else
53  {
54  if (mPerformZMatchingPS && (segment0 != floor(mp1.y())))
55  return;
56  }
57 
59  double R0 = det0->position().perp();
60  double R1 = det1->position().perp();
61  double Z0 = det0->position().z();
62  double Z1 = det1->position().z();
63 
64  double DR = R1 - R0;
65  double DZ = Z1 - Z0;
66 
67  double alpha = atan2(DR, DZ);
68  double delta = sqrt(DR * DR + DZ * DZ) / (R0 * sin(alpha) + Z0 * cos(alpha));
69 
70  int window = 0;
71 
76 
87  double dispD = 2 * (mp1.x() - mp0.x()) * (pitch0.first / pitch1.first);
88  int dispI = ((dispD > 0) - (dispD < 0)) * floor(std::abs(dispD));
89 
95  double offsetD = 2 * delta * (mp0.x() - (top0->nrows() / 2 - 0.5)) * (pitch0.first / pitch1.first);
96  int offsetI = ((offsetD > 0) - (offsetD < 0)) * floor(std::abs(offsetD));
97 
98  if (stDetId.subdetId() == StripSubdetector::TOB) {
99  int layer = theTrackerTopo_->layer(stDetId);
100  int ladder = theTrackerTopo_->tobRod(stDetId);
101  int type = 2 * theTrackerTopo_->tobSide(stDetId) - 3; // -1 for tilted-, 1 for tilted+, 3 for flat
102  double corr = 0;
103 
104  if (type < 3) // Only for tilted modules
105  {
106  corr = (barrelNTilt.at(layer) + 1) / 2.;
107  // Corrected ring number, bet 0 and barrelNTilt.at(layer), in ascending |z|
108  ladder = corr - (corr - ladder) * type;
109  window = 2 * (tiltedCut.at(layer)).at(ladder);
110  } else // Classis barrel window otherwise
111  {
112  window = 2 * barrelCut.at(layer);
113  }
114 
115  } else if (stDetId.subdetId() == StripSubdetector::TID) {
116  window = 2 * (ringCut.at(theTrackerTopo_->tidWheel(stDetId))).at(theTrackerTopo_->tidRing(stDetId));
117  }
118 
120  if (std::abs(dispI - offsetI) <= window)
121  {
122  aConfirmation = true;
123  aDisplacement = dispI;
124  anOffset = offsetI;
125  anHardBend = this->degradeBend(isPS, window, (aDisplacement - anOffset)); // In strips units
126  }
127 }
128 
129 //--- Does the actual work of degrading the bend. (based on I.Tomalin's code)
130 template <>
132  // Number of bits used to encoded bend output by FE electronics.
133  const unsigned int bitsPS_ = 3;
134  const unsigned int bits2S_ = 4;
135 
136  // Number of degraded bend values should correspond to 3 bits (PS modules) or 4 bits (2S modules),
137  // so measuring everything in half-strip units, max integer "window" size that can be encoded without
138  // compression given by 2*window+1 <= pow(2,B), where B is number of bits.
139  // Hence no compression required if window cut is abs(b) <= 3 (PS) or 7 (2S). Must introduce one merge for
140  // each 1 unit increase in "window" beyond this.
141 
142  // Bend is measured with granularity of 0.5 strips.
143  // Convert it to integer measured in half-strip units for this calculation!
144 
145  float degradedB;
146  unsigned int numBends = 2 * window + 1;
147  unsigned int numAllowed = (psModule) ? pow(2, bitsPS_) : pow(2, bits2S_);
148 
149  // Existance of bend = 0 means can only use an odd number of groups.
150  numAllowed -= 1; // NumAllowed can be only based on 3 or 4 bits encoded bends, so 7 or 15 possible values
151  if (numBends <= numAllowed) {
152  // Can output uncompressed bend info. (So if window is lower or equal than 1.5 in PS, and 3.5 in 2S
153  degradedB = static_cast<double>(bend);
154  } else // all other cases, need to compress
155  {
156  unsigned int inSmallGroup = numBends / numAllowed;
157  unsigned int numLargeGroups = numBends % numAllowed;
158  unsigned int inLargeGroup = inSmallGroup + 1;
159  unsigned int numSmallGroups = numAllowed - numLargeGroups;
160 
161  std::vector<unsigned int> groups;
162 
163  // At the end we have
164  //
165  // numBends=inSmallGroup*numSmallGroups+inLargeGroup*numLargeGroups
166  // and
167  // numAllowed= numSmallGroups+numLargeGroups;
168  //
169  // Then you alternate large-small-large-small....large. In the middle, you
170  // put either large or small, depending if group size is odd or not
171 
172  for (unsigned int i = 0; i < numLargeGroups / 2; i++)
173  groups.push_back(inLargeGroup);
174  for (unsigned int i = 0; i < numSmallGroups / 2; i++)
175  groups.push_back(inSmallGroup);
176 
177  // Only one of numLargeGroups & numSmallGroups can be odd, since numAllowed is odd.
178  // And whichever one is odd is associated to a group with an odd number of elements since numBends is odd,
179  if (numLargeGroups % 2 == 1 && inLargeGroup % 2 == 1) {
180  groups.push_back(inLargeGroup);
181  } else if (numSmallGroups % 2 == 1 && inSmallGroup % 2 == 1) {
182  groups.push_back(inSmallGroup);
183  } else {
184  throw cms::Exception("DegradeBend: logic error with odd numbers");
185  }
186 
187  for (unsigned int i = 0; i < numSmallGroups / 2; i++)
188  groups.push_back(inSmallGroup);
189  for (unsigned int i = 0; i < numLargeGroups / 2; i++)
190  groups.push_back(inLargeGroup);
191 
192  degradedB = 999;
193  int iUp = -static_cast<int>(window) - 1; // Start with the minimal possible bend -1
194  int iDown;
195 
196  for (unsigned int& inGroup : groups) {
197  iUp += inGroup;
198  iDown = iUp - inGroup + 1;
199  if (bend <= iUp && bend >= iDown) {
200  degradedB = 0.5 * (iUp + iDown);
201  }
202  }
203  if (degradedB == 999)
204  throw cms::Exception(
205  "DegradeStubResolution: error in the group creation, method has been called with wrong inputs");
206  }
207 
208  // This is degraded bend in full strip units (neglecting bend sign).
209  return static_cast<float>(degradedB) / 2.;
210 }
211 
212 //--- Check for mistakes.
GeomDet::position
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
Point2DBase
Definition: Point2DBase.h:9
mps_fire.i
i
Definition: mps_fire.py:355
GeomDet
Definition: GeomDet.h:27
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
PixelTopology::pitch
virtual std::pair< float, float > pitch() const =0
svgfig.window
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:643
TTStubAlgorithm_official::degradeBend
float degradeBend(bool psModule, int window, int bend) const
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
TTStub::clusterRef
const edm::Ref< edmNew::DetSetVector< TTCluster< T > >, TTCluster< T > > & clusterRef(unsigned int hitStackMember) const
Clusters composing the Stub – see https://twiki.cern.ch/twiki/bin/viewauth/CMS/SLHCTrackerTriggerSWTo...
Definition: TTStub.h:150
DetId
Definition: DetId.h:17
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
TTStub::moduleTypePS
bool moduleTypePS() const
check if a PS module
Definition: TTStub.h:194
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
TTStub
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
PixelTopology::ncolumns
virtual int ncolumns() const =0
PixelTopology
Definition: PixelTopology.h:10
particleFlowDisplacedVertex_cfi.ratio
ratio
Definition: particleFlowDisplacedVertex_cfi.py:93
HLT_2018_cff.barrelCut
barrelCut
Definition: HLT_2018_cff.py:13770
TTStub::getDetId
DetId getDetId() const
Detector element.
Definition: TTStub.h:44
PV2DBase::y
T y() const
Definition: PV2DBase.h:44
PixelGeomDetUnit::specificTopology
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
Definition: PixelGeomDetUnit.cc:17
PV2DBase::x
T x() const
Definition: PV2DBase.h:43
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
HLT_2018_cff.R0
R0
Definition: HLT_2018_cff.py:7317
type
type
Definition: HCALResponse.h:21
trklet::bend
double bend(double r, double rinv, double stripPitch)
Definition: Util.h:160
Exception
Definition: hltDiff.cc:246
PVValHelper::ladder
Definition: PVValidationHelpers.h:72
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TTStubAlgorithm_official::PatternHitCorrelation
void PatternHitCorrelation(bool &aConfirmation, int &aDisplacement, int &anOffset, float &anHardBend, const TTStub< T > &aTTStub) const override
Matching operations.
PixelTopology::nrows
virtual int nrows() const =0
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17
TTStubAlgorithm_official.h
Z0
static const double Z0
Definition: CastorGeometryData.h:32