CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DegradeBend.cc
Go to the documentation of this file.
3 
7 
8 #include <map>
9 #include <set>
10 #include <utility>
11 #include <cmath>
12 #include <algorithm>
13 #include <iostream>
14 
15 using namespace std;
16 
17 namespace tmtt {
18 
19  //--- Given the original bend, flag indicating if this is a PS or 2S module, & detector identifier,
20  //--- this returns the degraded stub bend, a boolean indicatng if stub bend was outside the assumed window
21  //--- size programmed below, and an integer indicating how many values of the original bend
22  //--- were grouped together into this single value of the degraded bend.
23 
24  void DegradeBend::degrade(float bend,
25  bool psModule,
26  const DetId& stDetId,
27  float windowFEnew,
28  float& degradedBend,
29  unsigned int& numInGroup) const {
30  // Get degraded bend value.
31  unsigned int windowHalfStrips;
32  this->work(bend, psModule, stDetId, windowFEnew, degradedBend, numInGroup, windowHalfStrips);
33  }
34 
35  //--- Does the actual work of degrading the bend.
36 
37  void DegradeBend::work(float bend,
38  bool psModule,
39  const DetId& stDetId,
40  float windowFEnew,
41  float& degradedBend,
42  unsigned int& numInGroup,
43  unsigned int& windowHalfStrips) const {
44  // Calculate stub window size in half-strip units used to produce stubs.
45  // Code accessing geometry inspired by L1Trigger/TrackTrigger/src/TTStubAlgorithm_official.cc
46 
47  const double* storedHalfWindow = sw_->storedWindowSize(theTrackerTopo_, stDetId);
48 
49  // Compare this with the possibly tighter window provided by the user, converting to half-strip units.
50  const double window = std::min(*storedHalfWindow, double(windowFEnew));
51  windowHalfStrips = (unsigned int)(2 * window);
52 
53  // Bend is measured with granularity of 0.5 strips.
54  // Convert it to integer measured in half-strip units for this calculation!
55  int b = std::round(2 * bend);
56 
57  if ((unsigned int)(std::abs(b)) <= windowHalfStrips) {
58  // Call the official CMS bend encoding algorithm.
59  degradedBend = stubAlgo_->degradeBend(psModule, windowHalfStrips, b);
60  } else {
61  // This should only happen for stubs subsequently rejected by the FE.
62  numInGroup = 0;
63  constexpr float rejectedStubBend = 99999.;
64  degradedBend = rejectedStubBend;
65  }
66  }
67 } // namespace tmtt
def window
Definition: svgfig.py:643
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: DetId.h:17
double b
Definition: hdecay.h:118