CMS 3D CMS Logo

Stub.cc
Go to the documentation of this file.
2 
3 #include <cmath>
4 #include <iterator>
5 #include <algorithm>
6 #include <utility>
7 
8 using namespace edm;
9 using namespace std;
10 
11 namespace trackerDTC {
12 
13  Stub::Stub(const ParameterSet& iConfig, const Setup& setup, SensorModule* sm, const TTStubRef& ttStubRef)
14  : setup_(&setup), sm_(sm), ttStubRef_(ttStubRef), hybrid_(iConfig.getParameter<bool>("UseHybrid")), valid_(true) {
15  regions_.reserve(setup.numOverlappingRegions());
16  // get stub local coordinates
17  const MeasurementPoint& mp = ttStubRef->clusterRef(0)->findAverageLocalCoordinatesCentered();
18 
19  // convert to uniformed local coordinates
20 
21  // column number in pitch units
22  col_ = (int)floor(pow(-1, sm->signCol()) * (mp.y() - sm->numColumns() / 2) / setup.baseCol());
23  // row number in half pitch units
24  row_ = (int)floor(pow(-1, sm->signRow()) * (mp.x() - sm->numRows() / 2) / setup.baseRow());
25  // bend number in quarter pitch units
26  bend_ = (int)floor(pow(-1, sm->signBend()) * (ttStubRef->bendBE()) / setup.baseBend());
27  // reduced row number for look up
28  rowLUT_ = (int)floor((double)row_ / pow(2., setup.widthRow() - setup.dtcWidthRowLUT()));
29  // sub row number inside reduced row number
30  rowSub_ = row_ - (rowLUT_ + .5) * pow(2, setup.widthRow() - setup.dtcWidthRowLUT());
31 
32  // convert local to global coordinates
33 
34  const double y = (col_ + .5) * setup.baseCol() * sm->pitchCol();
35  // radius of a column of strips/pixel in cm
36  d_ = sm->r() + y * sm->sin();
37  // stub z in cm
38  z_ = digi(sm->z() + y * sm->cos(), setup.baseZ());
39 
40  const double x0 = rowLUT_ * setup.baseRow() * setup.dtcNumMergedRows() * sm->pitchRow();
41  const double x1 = (rowLUT_ + 1) * setup.baseRow() * setup.dtcNumMergedRows() * sm->pitchRow();
42  const double x = (rowLUT_ + .5) * setup.baseRow() * setup.dtcNumMergedRows() * sm->pitchRow();
43  // stub r in cm
44  r_ = sqrt(d_ * d_ + x * x);
45 
46  const double phi0 = sm->phi() + atan2(x0, d_);
47  const double phi1 = sm->phi() + atan2(x1, d_);
48  const double c = (phi0 + phi1) / 2.;
49  const double m = (phi1 - phi0) / setup.dtcNumMergedRows();
50 
51  // intercept of linearized stub phi in rad
52  c_ = digi(c, setup.basePhi());
53  // slope of linearized stub phi in rad / strip
54  m_ = digi(m, setup.dtcBaseM());
55 
56  if (hybrid_) {
57  if (abs(z_ / r_) > setup.hybridMaxCot())
58  // did not pass eta cut
59  valid_ = false;
60  } else {
61  // extrapolated z at radius T assuming z0=0
62  const double zT = setup.chosenRofZ() * z_ / r_;
63  // extrapolated z0 window at radius T
64  const double dZT = setup.beamWindowZ() * abs(1. - setup.chosenRofZ() / r_);
65  double zTMin = zT - dZT;
66  double zTMax = zT + dZT;
67  if (zTMin >= setup.maxZT() || zTMax < -setup.maxZT())
68  // did not pass "eta" cut
69  valid_ = false;
70  else {
71  zTMin = max(zTMin, -setup.maxZT());
72  zTMax = min(zTMax, setup.maxZT());
73  }
74  // range of stub cot(theta)
75  cot_ = {zTMin / setup.chosenRofZ(), zTMax / setup.chosenRofZ()};
76  }
77 
78  // stub r w.r.t. chosenRofPhi in cm
79  static const double chosenRofPhi = hybrid_ ? setup.hybridChosenRofPhi() : setup.chosenRofPhi();
80  r_ = digi(r_ - chosenRofPhi, setup.baseR());
81 
82  // radial (cylindrical) component of sensor separation
83  const double dr = sm->sep() / (sm->cos() - sm->sin() * z_ / d_);
84  // converts bend into qOverPt in 1/cm
85  const double qOverPtOverBend = sm->pitchRow() / dr / d_;
86  // qOverPt in 1/cm
87  const double qOverPt = bend_ * setup.baseBend() * qOverPtOverBend;
88  // qOverPt uncertainty in 1/cm
89  const double dQoverPt = setup.bendCut() * qOverPtOverBend;
90  const double minPt = hybrid_ ? setup.hybridMinPt() : setup.minPt();
91  const double maxQoverPt = setup.invPtToDphi() / minPt - setup.dtcBaseQoverPt() / 2.;
92  double qOverPtMin = digi(qOverPt - dQoverPt, setup.dtcBaseQoverPt());
93  double qOverPtMax = digi(qOverPt + dQoverPt, setup.dtcBaseQoverPt());
94  if (qOverPtMin >= maxQoverPt || qOverPtMax < -maxQoverPt)
95  // did not pass pt cut
96  valid_ = false;
97  else {
98  qOverPtMin = max(qOverPtMin, -maxQoverPt);
99  qOverPtMax = min(qOverPtMax, maxQoverPt);
100  }
101  // range of stub qOverPt in 1/cm
102  qOverPt_ = {qOverPtMin, qOverPtMax};
103 
104  // stub phi w.r.t. detector region centre in rad
105  phi_ = c_ + rowSub_ * m_;
106 
107  // range of stub extrapolated phi to radius chosenRofPhi in rad
108  phiT_.first = phi_ + r_ * qOverPt_.first;
109  phiT_.second = phi_ + r_ * qOverPt_.second;
110  if (phiT_.first > phiT_.second)
111  swap(phiT_.first, phiT_.second);
112 
113  if (phiT_.first < 0.)
114  regions_.push_back(0);
115  if (phiT_.second >= 0.)
116  regions_.push_back(1);
117 
118  // apply data format specific manipulations
119  if (!hybrid_)
120  return;
121 
122  // stub r w.r.t. an offset in cm
123  r_ -= sm->offsetR() - chosenRofPhi;
124  // stub z w.r.t. an offset in cm
125  z_ -= sm->offsetZ();
126  if (sm->type() == SensorModule::Disk2S) {
127  // encoded r
128  r_ = sm->encodedR() + (sm->side() ? -col_ : (col_ + sm->numColumns() / 2));
129  r_ = (r_ + 0.5) * setup.hybridBaseR(sm->type());
130  }
131 
132  // encode bend
133  const vector<double>& encodingBend = setup.encodingBend(sm->windowSize(), sm->psModule());
134  const auto pos = find(encodingBend.begin(), encodingBend.end(), abs(bend_));
135  const int uBend = distance(encodingBend.begin(), pos);
136  bend_ = pow(-1, signbit(bend_)) * (uBend - (int)encodingBend.size() / 2);
137  }
138 
139  // returns bit accurate representation of Stub
141 
142  // returns true if stub belongs to region
143  bool Stub::inRegion(int region) const { return find(regions_.begin(), regions_.end(), region) != regions_.end(); }
144 
145  // truncates double precision to f/w integer equivalent
146  double Stub::digi(double value, double precision) const { return (floor(value / precision) + .5) * precision; }
147 
148  // returns 64 bit stub in hybrid data format
150  const SensorModule::Type type = sm_->type();
151  // stub phi w.r.t. processing region centre in rad
152  const double phi = phi_ - (region - .5) * setup_->baseRegion();
153  // convert stub variables into bit vectors
154  const TTBV hwR(r_, setup_->hybridBaseR(type), setup_->hybridWidthR(type), true);
155  const TTBV hwPhi(phi, setup_->hybridBasePhi(type), setup_->hybridWidthPhi(type), true);
156  const TTBV hwZ(z_, setup_->hybridBaseZ(type), setup_->hybridWidthZ(type), true);
157  const TTBV hwAlpha(row_, setup_->hybridBaseAlpha(type), setup_->hybridWidthAlpha(type), true);
158  const TTBV hwBend(bend_, setup_->hybridWidthBend(type), true);
159  const TTBV hwLayer(sm_->encodedLayerId(), setup_->hybridWidthLayer());
160  const TTBV hwGap(0, setup_->hybridNumUnusedBits(type));
161  const TTBV hwValid(1, 1);
162  // assemble final bitset
163  return TTDTC::BV(hwGap.str() + hwR.str() + hwZ.str() + hwPhi.str() + hwAlpha.str() + hwBend.str() + hwLayer.str() +
164  hwValid.str());
165  }
166 
168  int layerM = sm_->layerId();
169  // convert unique layer id [1-6,11-15] into reduced layer id [0-6]
170  // a fiducial track may not cross more then 7 detector layers, for stubs from a given track the reduced layer id is actually unique
171  int layer(-1);
172  if (layerM == 1)
173  layer = 0;
174  else if (layerM == 2)
175  layer = 1;
176  else if (layerM == 6 || layerM == 11)
177  layer = 2;
178  else if (layerM == 5 || layerM == 12)
179  layer = 3;
180  else if (layerM == 4 || layerM == 13)
181  layer = 4;
182  else if (layerM == 14)
183  layer = 5;
184  else if (layerM == 3 || layerM == 15)
185  layer = 6;
186  // assign stub to phi sectors within a processing region, to be generalized
187  TTBV sectorsPhi(0, setup_->numOverlappingRegions() * setup_->numSectorsPhi());
188  if (phiT_.first < 0.) {
189  if (phiT_.first < -setup_->baseSector())
190  sectorsPhi.set(0);
191  else
192  sectorsPhi.set(1);
193  if (phiT_.second < 0. && phiT_.second >= -setup_->baseSector())
194  sectorsPhi.set(1);
195  }
196  if (phiT_.second >= 0.) {
197  if (phiT_.second < setup_->baseSector())
198  sectorsPhi.set(2);
199  else
200  sectorsPhi.set(3);
201  if (phiT_.first >= 0. && phiT_.first < setup_->baseSector())
202  sectorsPhi.set(2);
203  }
204  // assign stub to eta sectors within a processing region
205  pair<int, int> setcorEta({0, setup_->numSectorsEta() - 1});
206  for (int bin = 0; bin < setup_->numSectorsEta(); bin++)
207  if (asinh(cot_.first) < setup_->boundarieEta(bin + 1)) {
208  setcorEta.first = bin;
209  break;
210  }
211  for (int bin = setcorEta.first; bin < setup_->numSectorsEta(); bin++)
212  if (asinh(cot_.second) < setup_->boundarieEta(bin + 1)) {
213  setcorEta.second = bin;
214  break;
215  }
216  // stub phi w.r.t. processing region centre in rad
217  const double phi = phi_ - (region - .5) * setup_->baseRegion();
218  // convert stub variables into bit vectors
219  const TTBV hwValid(1, 1);
220  const TTBV hwGap(0, setup_->dtcNumUnusedBits());
221  const TTBV hwLayer(layer, setup_->widthLayer());
222  const TTBV hwSectorEtaMin(setcorEta.first, setup_->widthSectorEta());
223  const TTBV hwSectorEtaMax(setcorEta.second, setup_->widthSectorEta());
224  const TTBV hwR(r_, setup_->baseR(), setup_->widthR(), true);
225  const TTBV hwPhi(phi, setup_->basePhi(), setup_->widthPhiDTC(), true);
226  const TTBV hwZ(z_, setup_->baseZ(), setup_->widthZ(), true);
227  const TTBV hwQoverPtMin(qOverPt_.first, setup_->htBaseQoverPt(), setup_->htWidthQoverPt(), true);
228  const TTBV hwQoverPtMax(qOverPt_.second, setup_->htBaseQoverPt(), setup_->htWidthQoverPt(), true);
229  TTBV hwSectorPhis(0, setup_->numSectorsPhi());
230  for (int sectorPhi = 0; sectorPhi < setup_->numSectorsPhi(); sectorPhi++)
231  hwSectorPhis[sectorPhi] = sectorsPhi[region * setup_->numSectorsPhi() + sectorPhi];
232  // assemble final bitsetTTDTC::BV(hwGap.str() + hwValid.str() + hwR.str() + hwPhi.str() + hwZ.str() + hwQoverPtMin.str() +
233  return TTDTC::BV(hwGap.str() + hwValid.str() + hwR.str() + hwPhi.str() + hwZ.str() + hwQoverPtMin.str() +
234  hwQoverPtMax.str() + hwSectorEtaMin.str() + hwSectorEtaMax.str() + hwSectorPhis.str() +
235  hwLayer.str());
236  }
237 
238 } // namespace trackerDTC
trackerDTC::SensorModule::offsetR
double offsetR() const
Definition: SensorModule.h:67
trackerDTC::Setup::hybridBasePhi
double hybridBasePhi(SensorModule::Type type) const
Definition: Setup.h:164
Point2DBase
Definition: Point2DBase.h:9
trackerDTC::SensorModule::phi
double phi() const
Definition: SensorModule.h:47
trackerDTC::SensorModule::windowSize
int windowSize() const
Definition: SensorModule.h:71
electrons_cff.bool
bool
Definition: electrons_cff.py:366
trackerDTC::SensorModule::offsetZ
double offsetZ() const
Definition: SensorModule.h:69
trackerDTC::SensorModule
Definition: SensorModule.h:11
trackerDTC::Setup::baseR
double baseR() const
Definition: Setup.h:131
trackerDTC::Stub::frame
TTDTC::BV frame(int region) const
Definition: Stub.cc:140
trackerDTC::Setup::htWidthQoverPt
int htWidthQoverPt() const
Definition: Setup.h:299
trackerDTC::Stub::formatHybrid
TTDTC::BV formatHybrid(int region) const
Definition: Stub.cc:149
min
T min(T a, T b)
Definition: MathUtil.h:58
trackerDTC::Setup::baseZ
double baseZ() const
Definition: Setup.h:133
TTBV::set
TTBV & set()
Definition: TTBV.h:156
edm
HLT enums.
Definition: AlignableModifier.h:19
trackerDTC::Setup::hybridNumUnusedBits
int hybridNumUnusedBits(SensorModule::Type type) const
Definition: Setup.h:170
trackerDTC::SensorModule::signCol
bool signCol() const
Definition: SensorModule.h:35
edm::swap
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
pos
Definition: PixelAliasList.h:18
trackerDTC::SensorModule::cos
double cos() const
Definition: SensorModule.h:61
trackerDTC::Setup::numOverlappingRegions
int numOverlappingRegions() const
Definition: Setup.h:221
TTDTC::BV
std::bitset< TTBV::S > BV
Definition: TTDTC.h:20
trackerDTC::SensorModule::signRow
bool signRow() const
Definition: SensorModule.h:33
trackerDTC::Setup::widthLayer
int widthLayer() const
Definition: Setup.h:129
trackerDTC::Stub::bend_
int bend_
Definition: Stub.h:51
trackerDTC::SensorModule::numRows
int numRows() const
Definition: SensorModule.h:41
trackerDTC::Setup::numSectorsEta
int numSectorsEta() const
Definition: Setup.h:270
trackerDTC::Stub::sm_
SensorModule * sm_
Definition: Stub.h:39
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
trackerDTC::Setup
Class to process and provide run-time constants used by Track Trigger emulators.
Definition: Setup.h:41
trackerDTC::SensorModule::Type
Type
Definition: SensorModule.h:16
trackerDTC::Stub::col_
int col_
Definition: Stub.h:47
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
trackerDTC::Setup::boundarieEta
double boundarieEta(int eta) const
Definition: Setup.h:276
edm::Ref
Definition: AssociativeIterator.h:58
trackerDTC::SensorModule::encodedLayerId
int encodedLayerId() const
Definition: SensorModule.h:65
sistrip::valid_
static const uint16_t valid_
Definition: Constants.h:17
trackerDTC::Stub::cot_
std::pair< double, double > cot_
Definition: Stub.h:71
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
trackerDTC::Setup::widthPhiDTC
int widthPhiDTC() const
Definition: Setup.h:259
trackerDTC::Setup::hybridBaseR
double hybridBaseR(SensorModule::Type type) const
Definition: Setup.h:162
trackerDTC::Setup::numSectorsPhi
int numSectorsPhi() const
Definition: Setup.h:268
trackerDTC::Stub::formatTMTT
TTDTC::BV formatTMTT(int region) const
Definition: Stub.cc:167
trackerDTC::SensorModule::pitchRow
double pitchRow() const
Definition: SensorModule.h:53
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
trackerDTC::Setup::hybridWidthR
int hybridWidthR(SensorModule::Type type) const
Definition: Setup.h:150
trackerDTC::Stub::rowLUT_
int rowLUT_
Definition: Stub.h:53
trackerDTC::Stub::qOverPt_
std::pair< double, double > qOverPt_
Definition: Stub.h:69
trackerDTC::Stub::phi_
double phi_
Definition: Stub.h:59
trackerDTC::SensorModule::psModule
bool psModule() const
Definition: SensorModule.h:29
trackerDTC::Setup::hybridWidthAlpha
int hybridWidthAlpha(SensorModule::Type type) const
Definition: Setup.h:156
trackerDTC::Stub::c_
double c_
Definition: Stub.h:65
trackerDTC::SensorModule::sin
double sin() const
Definition: SensorModule.h:59
trackerDTC::SensorModule::Disk2S
Definition: SensorModule.h:16
trackerDTC::Setup::widthSectorEta
int widthSectorEta() const
Definition: Setup.h:284
trackerDTC::SensorModule::side
bool side() const
Definition: SensorModule.h:25
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
trackerDTC::SensorModule::z
double z() const
Definition: SensorModule.h:49
trackerDTC::Stub::m_
double m_
Definition: Stub.h:63
funct::true
true
Definition: Factorize.h:173
common_cff.precision
precision
Definition: common_cff.py:44
edm::ParameterSet
Definition: ParameterSet.h:47
trackerDTC::SensorModule::encodedR
int encodedR() const
Definition: SensorModule.h:63
trackerDTC::SensorModule::type
Type type() const
Definition: SensorModule.h:19
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
PV2DBase::y
T y() const
Definition: PV2DBase.h:44
PV2DBase::x
T x() const
Definition: PV2DBase.h:43
trackerDTC::Setup::widthR
int widthR() const
Definition: Setup.h:123
trackerDTC::Setup::hybridWidthBend
int hybridWidthBend(SensorModule::Type type) const
Definition: Setup.h:158
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88271
createfilelist.int
int
Definition: createfilelist.py:10
trackerDTC::Setup::baseRegion
double baseRegion() const
Definition: Setup.h:98
value
Definition: value.py:1
trackerDTC::Setup::widthZ
int widthZ() const
Definition: Setup.h:127
trackerDTC::Stub::z_
double z_
Definition: Stub.h:61
trackerDTC::Setup::basePhi
double basePhi() const
Definition: Setup.h:135
TTBV
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
Definition: TTBV.h:18
trackerDTC::Stub::digi
double digi(double value, double precision) const
Definition: Stub.cc:146
beam_dqm_sourceclient-live_cfg.minPt
minPt
Definition: beam_dqm_sourceclient-live_cfg.py:328
trackerDTC::Setup::baseSector
double baseSector() const
Definition: Setup.h:278
trackerDTC::Setup::hybridBaseZ
double hybridBaseZ(SensorModule::Type type) const
Definition: Setup.h:166
trackerDTC
Definition: DTC.h:10
trackerDTC::Setup::hybridWidthLayer
int hybridWidthLayer() const
Definition: Setup.h:160
trackerDTC::Stub::hybrid_
bool hybrid_
Definition: Stub.h:43
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
Stub.h
trackerDTC::SensorModule::signBend
bool signBend() const
Definition: SensorModule.h:37
std
Definition: JetResolutionObject.h:76
trackerDTC::Stub::phiT_
std::pair< double, double > phiT_
Definition: Stub.h:73
trackerDTC::SensorModule::layerId
int layerId() const
Definition: SensorModule.h:43
trackerDTC::Stub::inRegion
bool inRegion(int region) const
Definition: Stub.cc:143
trackerDTC::Stub::regions_
std::vector< int > regions_
Definition: Stub.h:75
trackerDTC::Stub::setup_
const Setup * setup_
Definition: Stub.h:37
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
trackerDTC::SensorModule::numColumns
int numColumns() const
Definition: SensorModule.h:39
trackerDTC::Setup::htBaseQoverPt
double htBaseQoverPt() const
Definition: Setup.h:305
trackerDTC::Setup::hybridWidthZ
int hybridWidthZ(SensorModule::Type type) const
Definition: Setup.h:152
trackerDTC::Setup::hybridBaseAlpha
double hybridBaseAlpha(SensorModule::Type type) const
Definition: Setup.h:168
TTBV::str
std::string str() const
Definition: TTBV.h:211
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trackerDTC::Stub::r_
double r_
Definition: Stub.h:57
trackerDTC::Setup::hybridWidthPhi
int hybridWidthPhi(SensorModule::Type type) const
Definition: Setup.h:154
trackerDTC::Stub::d_
double d_
Definition: Stub.h:67
trackerDTC::Stub::row_
int row_
Definition: Stub.h:49
trackerDTC::SensorModule::sep
double sep() const
Definition: SensorModule.h:51
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
trackerDTC::SensorModule::r
double r() const
Definition: SensorModule.h:45
trackerDTC::Stub::ttStubRef
TTStubRef ttStubRef() const
Definition: Stub.h:18
trackerDTC::SensorModule::pitchCol
double pitchCol() const
Definition: SensorModule.h:55
trackerDTC::Setup::dtcNumUnusedBits
int dtcNumUnusedBits() const
Definition: Setup.h:137
trackerDTC::Stub::valid_
bool valid_
Definition: Stub.h:45
trackerDTC::Stub::rowSub_
int rowSub_
Definition: Stub.h:55