CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
trklet::DRin Class Reference

Class to emulate transformation of tracklet tracks and stubs into TMTT format and routing of seed type streams into inv2R streams. More...

#include <DRin.h>

Classes

struct  Stub
 
struct  Track
 

Public Member Functions

void consume (const tt::StreamsTrack &streamsTrack, const tt::StreamsStub &streamsStub)
 
 DRin (const edm::ParameterSet &iConfig, const tt::Setup *setup_, const trackerTFP::DataFormats *dataFormats, const trackerTFP::LayerEncoding *layerEncoding, const ChannelAssignment *channelAssignment, const Settings *settings, int region)
 
void produce (tt::StreamsStub &accpetedStubs, tt::StreamsTrack &acceptedTracks, tt::StreamsStub &lostStubs, tt::StreamsTrack &lostTracks)
 
 ~DRin ()
 

Private Member Functions

double digi (double val, double base) const
 
template<class T >
Tpop_front (std::deque< T *> &ts) const
 
double redigi (double val, double baseLow, double baseHigh, int widthMultiplier) const
 

Private Attributes

double baseHcot_
 
double baseHinv2R_
 
double baseHphi_
 
double baseHphiT_
 
double baseHr_
 
double baseHz_
 
double baseHzT_
 
double baseInvCot_
 
double baseLcot_
 
double baseLinv2R_
 
double baseLphi_
 
double baseLphiT_
 
double baseLr_
 
double baseLz_
 
double baseLzT_
 
double baseUcot_
 
double baseUinv2R_
 
double baseUphi_
 
double baseUphiT_
 
double baseUr_
 
double baseUz_
 
double baseUzT_
 
const ChannelAssignmentchannelAssignment_
 
const trackerTFP::DataFormatsdataFormats_
 
bool enableTruncation_
 
std::vector< std::vector< Track * > > input_
 
const trackerTFP::LayerEncodinglayerEncoding_
 
const int region_
 
const Settingssettings_
 
const tt::Setupsetup_
 
std::vector< Stubstubs_
 
std::vector< Tracktracks_
 
bool useTTStubResiduals_
 

Detailed Description

Class to emulate transformation of tracklet tracks and stubs into TMTT format and routing of seed type streams into inv2R streams.

Author
Thomas Schuh
Date
2023, Jan

Definition at line 21 of file DRin.h.

Constructor & Destructor Documentation

◆ DRin()

trklet::DRin::DRin ( const edm::ParameterSet iConfig,
const tt::Setup setup_,
const trackerTFP::DataFormats dataFormats,
const trackerTFP::LayerEncoding layerEncoding,
const ChannelAssignment channelAssignment,
const Settings settings,
int  region 
)

Definition at line 15 of file DRin.cc.

References baseInvCot_, reco::ceil(), trackerTFP::cot, tt::Setup::hybridRangeR(), trackerTFP::inv2R, trackerTFP::kfin, tt::Setup::outerRadius(), trackerTFP::phiT, funct::pow(), setup_, tt::Setup::widthDSPbu(), and trackerTFP::zT.

22  : enableTruncation_(iConfig.getParameter<bool>("EnableTruncation")),
23  useTTStubResiduals_(iConfig.getParameter<bool>("UseTTStubResiduals")),
24  setup_(setup),
25  dataFormats_(dataFormats),
26  layerEncoding_(layerEncoding),
27  channelAssignment_(channelAssignment),
28  settings_(settings),
29  region_(region),
31  // unified tracklet digitisation granularity
36  baseUr_(settings_->kr()),
38  baseUz_(settings_->kz()),
39  // KF input format digitisation granularity (identical to TMTT)
40  baseLinv2R_(dataFormats->base(Variable::inv2R, Process::kfin)),
41  baseLphiT_(dataFormats->base(Variable::phiT, Process::kfin)),
42  baseLcot_(dataFormats->base(Variable::cot, Process::kfin)),
43  baseLzT_(dataFormats->base(Variable::zT, Process::kfin)),
44  baseLr_(dataFormats->base(Variable::r, Process::kfin)),
45  baseLphi_(dataFormats->base(Variable::phi, Process::kfin)),
46  baseLz_(dataFormats->base(Variable::z, Process::kfin)),
47  // Finer granularity (by powers of 2) than the TMTT one. Used to transform from Tracklet to TMTT base.
48  baseHinv2R_(baseLinv2R_ * pow(2, floor(log2(baseUinv2R_ / baseLinv2R_)))),
49  baseHphiT_(baseLphiT_ * pow(2, floor(log2(baseUphiT_ / baseLphiT_)))),
50  baseHcot_(baseLcot_ * pow(2, floor(log2(baseUcot_ / baseLcot_)))),
51  baseHzT_(baseLzT_ * pow(2, floor(log2(baseUzT_ / baseLzT_)))),
52  baseHr_(baseLr_ * pow(2, floor(log2(baseUr_ / baseLr_)))),
53  baseHphi_(baseLphi_ * pow(2, floor(log2(baseUphi_ / baseLphi_)))),
54  baseHz_(baseLz_ * pow(2, floor(log2(baseUz_ / baseLz_)))) {
55  // calculate digitisation granularity used for inverted cot(theta)
56  const int baseShiftInvCot = ceil(log2(setup_->outerRadius() / setup_->hybridRangeR())) - setup_->widthDSPbu();
57  baseInvCot_ = pow(2, baseShiftInvCot);
58  }
double baseHphi_
Definition: DRin.h:161
const tt::Setup * setup_
Definition: DRin.h:122
constexpr int32_t ceil(float num)
double base(Variable v, Process p) const
Definition: DataFormats.h:492
double kz() const
Definition: Settings.h:342
double baseInvCot_
Definition: DRin.h:164
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
double baseUz_
Definition: DRin.h:146
double baseLz_
Definition: DRin.h:154
double kphi1() const
Definition: Settings.h:339
bool enableTruncation_
Definition: DRin.h:118
double baseHr_
Definition: DRin.h:160
const trackerTFP::LayerEncoding * layerEncoding_
Definition: DRin.h:126
int widthDSPbu() const
Definition: Setup.h:141
double baseLcot_
Definition: DRin.h:150
int phi0_shift() const
Definition: Settings.h:381
float float float z
double baseUphiT_
Definition: DRin.h:141
double baseHz_
Definition: DRin.h:162
double baseHzT_
Definition: DRin.h:159
bool useTTStubResiduals_
Definition: DRin.h:120
int t_shift() const
Definition: Settings.h:382
const int region_
Definition: DRin.h:132
double baseLphiT_
Definition: DRin.h:149
double hybridRangeR() const
Definition: Setup.h:302
int z0_shift() const
Definition: Settings.h:383
const trackerTFP::DataFormats * dataFormats_
Definition: DRin.h:124
double outerRadius() const
Definition: Setup.h:241
const Settings * settings_
Definition: DRin.h:130
double baseLr_
Definition: DRin.h:152
double baseHinv2R_
Definition: DRin.h:156
double kr() const
Definition: Settings.h:344
double baseLphi_
Definition: DRin.h:153
double baseUinv2R_
Definition: DRin.h:140
double baseUzT_
Definition: DRin.h:143
int rinv_shift() const
Definition: Settings.h:380
const ChannelAssignment * channelAssignment_
Definition: DRin.h:128
double baseUphi_
Definition: DRin.h:145
double baseUr_
Definition: DRin.h:144
double baseHphiT_
Definition: DRin.h:157
std::vector< std::vector< Track * > > input_
Definition: DRin.h:138
double baseHcot_
Definition: DRin.h:158
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
double baseLinv2R_
Definition: DRin.h:148
double baseUcot_
Definition: DRin.h:142
double baseLzT_
Definition: DRin.h:151

◆ ~DRin()

trklet::DRin::~DRin ( )
inline

Definition at line 30 of file DRin.h.

30 {}

Member Function Documentation

◆ consume()

void trklet::DRin::consume ( const tt::StreamsTrack streamsTrack,
const tt::StreamsStub streamsStub 
)

Definition at line 61 of file DRin.cc.

References funct::abs(), Reference_intrackfit_cff::barrel, tt::Setup::barrel(), baseInvCot_, tt::Setup::baseRegion(), baseUcot_, baseUinv2R_, baseUphi_, baseUphiT_, baseUr_, baseUz_, baseUzT_, tt::Setup::beamWindowZ(), channelAssignment_, trackerTFP::DataFormats::chosenRofPhi(), tt::Setup::chosenRofZ(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), trackerTFP::cot, dataFormats_, tt::deltaPhi(), digi(), tt::Setup::disk2SR(), enableTruncation_, dqmdumpme::first, amptDefault_cfi::frame, l1trig_cff::hwPhi, tt::Setup::hybridBaseR(), tt::Setup::hybridDiskZ(), tt::Setup::hybridLayerR(), tt::Setup::hybridMaxCot(), tt::Setup::hybridRangePhi(), tt::Setup::indexLayerId(), input, input_, createfilelist::int, edm::Ref< C, T, F >::isNull(), trklet::Settings::kphi(), trklet::Settings::kphi1(), trklet::Settings::kz(), trklet::ChannelAssignment::layerId(), remoteMonitoring_LASER_era2018_cfg::limit, tt::Setup::maxEta(), trklet::Settings::nbitst(), beamSpotPI::nTracks, trklet::ChannelAssignment::numChannelsTrack(), tt::Setup::numFrames(), trklet::ChannelAssignment::numProjectionLayers(), trklet::ChannelAssignment::numSeedingLayers(), tt::Setup::offsetLayerDisks(), tt::Setup::offsetLayerId(), trklet::ChannelAssignment::offsetStub(), trklet::Settings::phiresidbits(), trackerTFP::phiT, funct::pow(), tt::Setup::psModule(), region_, trklet::Settings::rresidbits(), settings_, setup_, tt::Setup::stubPos(), stubs_, tt::Setup::tbWidthR(), tt::Setup::tiltedLayerLimitZ(), tt::Setup::trackletLayerId(), tracks_, funct::true, tt::Setup::type(), useTTStubResiduals_, TTBV::val(), validateGeometry_cfg::valid, tt::Setup::widthAddrBRAM18(), trklet::ChannelAssignment::widthSeedStubId(), trklet::Settings::zresidbits(), and trackerTFP::zT.

Referenced by trklet::ProducerDRin::produce().

61  {
62  static const double maxCot = sinh(setup_->maxEta()) + setup_->beamWindowZ() / setup_->chosenRofZ();
63  static const int unusedMSBcot = floor(log2(baseUcot_ * pow(2, settings_->nbitst()) / (2. * maxCot)));
64  static const double baseCot =
65  baseUcot_ * pow(2, settings_->nbitst() - unusedMSBcot - 1 - setup_->widthAddrBRAM18());
66  const int offsetTrack = region_ * channelAssignment_->numChannelsTrack();
67  // count tracks and stubs to reserve container
68  int nTracks(0);
69  int nStubs(0);
70  for (int channel = 0; channel < channelAssignment_->numChannelsTrack(); channel++) {
71  const int channelTrack = offsetTrack + channel;
72  const int offsetStub = channelAssignment_->offsetStub(channelTrack);
73  const StreamTrack& streamTrack = streamsTrack[channelTrack];
74  input_[channel].reserve(streamTrack.size());
75  for (int frame = 0; frame < (int)streamTrack.size(); frame++) {
76  if (streamTrack[frame].first.isNull())
77  continue;
78  nTracks++;
79  for (int layer = 0; layer < channelAssignment_->numProjectionLayers(channel); layer++)
80  if (streamsStub[offsetStub + layer][frame].first.isNonnull())
81  nStubs++;
82  }
83  }
84  stubs_.reserve(nStubs + nTracks * channelAssignment_->numSeedingLayers());
85  tracks_.reserve(nTracks);
86  // store tracks and stubs
87  for (int channel = 0; channel < channelAssignment_->numChannelsTrack(); channel++) {
88  const int channelTrack = offsetTrack + channel;
89  const int offsetStub = channelAssignment_->offsetStub(channelTrack);
90  const StreamTrack& streamTrack = streamsTrack[channelTrack];
91  vector<Track*>& input = input_[channel];
92  for (int frame = 0; frame < (int)streamTrack.size(); frame++) {
93  const TTTrackRef& ttTrackRef = streamTrack[frame].first;
94  if (ttTrackRef.isNull()) {
95  input.push_back(nullptr);
96  continue;
97  }
98  //convert track parameter
99  const double r2Inv = digi(-ttTrackRef->rInv() / 2., baseUinv2R_);
100  const double phi0U =
101  digi(tt::deltaPhi(ttTrackRef->phi() - region_ * setup_->baseRegion() + setup_->hybridRangePhi() / 2.),
102  baseUphiT_);
103  const double phi0S = digi(phi0U - setup_->hybridRangePhi() / 2., baseUphiT_);
104  const double cot = digi(ttTrackRef->tanL(), baseUcot_);
105  const double z0 = digi(ttTrackRef->z0(), baseUzT_);
106  const double phiT = digi(phi0S + r2Inv * digi(dataFormats_->chosenRofPhi(), baseUr_), baseUphiT_);
107  const double zT = digi(z0 + cot * digi(setup_->chosenRofZ(), baseUr_), baseUzT_);
108  // kill tracks outside of fiducial range
109  if (abs(phiT) > setup_->baseRegion() / 2. || abs(zT) > setup_->hybridMaxCot() * setup_->chosenRofZ() ||
110  abs(z0) > setup_->beamWindowZ()) {
111  input.push_back(nullptr);
112  continue;
113  }
114  // convert stubs
115  vector<Stub*> stubs;
117  for (int layer = 0; layer < channelAssignment_->numProjectionLayers(channel); layer++) {
118  const FrameStub& frameStub = streamsStub[offsetStub + layer][frame];
119  const TTStubRef& ttStubRef = frameStub.first;
120  if (ttStubRef.isNull())
121  continue;
122  const int layerId = channelAssignment_->layerId(channel, layer);
123  // parse residuals from tt::Frame and take r and layerId from tt::TTStubRef
124  const bool barrel = setup_->barrel(ttStubRef);
125  const int layerIdTracklet = setup_->trackletLayerId(ttStubRef);
126  const double basePhi = barrel ? settings_->kphi1() : settings_->kphi(layerIdTracklet);
127  const double baseRZ = barrel ? settings_->kz(layerIdTracklet) : settings_->kz();
128  const int widthRZ = barrel ? settings_->zresidbits() : settings_->rresidbits();
129  TTBV hw(frameStub.second);
130  const TTBV hwRZ(hw, widthRZ, 0, true);
131  hw >>= widthRZ;
132  const TTBV hwPhi(hw, settings_->phiresidbits(), 0, true);
133  hw >>= settings_->phiresidbits();
134  const int indexLayerId = setup_->indexLayerId(ttStubRef);
135  const SensorModule::Type type = setup_->type(ttStubRef);
136  const int widthR = setup_->tbWidthR(type);
137  const double baseR = setup_->hybridBaseR(type);
138  const TTBV hwR(hw, widthR, 0, barrel);
139  hw >>= widthR;
140  double r = hwR.val(baseR) + (barrel ? setup_->hybridLayerR(indexLayerId) : 0.);
141  if (type == SensorModule::Disk2S)
142  r = setup_->disk2SR(indexLayerId, r);
144  double phi = hwPhi.val(basePhi);
145  if (basePhi > baseUphi_)
146  phi += baseUphi_ / 2.;
147  const double z = digi(hwRZ.val(baseRZ) * (barrel ? 1. : -cot), baseUz_);
148  const TTBV hwStubId(hw, channelAssignment_->widthSeedStubId(), 0, false);
149  const int stubId = hwStubId.val();
150  // determine module type
151  bool psTilt;
152  if (barrel) {
153  const double posZ = (r + digi(dataFormats_->chosenRofPhi(), baseUr_)) * cot + z0 + z;
154  const int indexLayerId = setup_->indexLayerId(ttStubRef);
155  const double limit = setup_->tiltedLayerLimitZ(indexLayerId);
156  psTilt = abs(posZ) < limit;
157  } else
158  psTilt = setup_->psModule(ttStubRef);
159  if (useTTStubResiduals_) {
160  const GlobalPoint gp = setup_->stubPos(ttStubRef);
161  const double ttR = r;
162  const double ttZ = gp.z() - (z0 + (ttR + dataFormats_->chosenRofPhi()) * cot);
163  stubs_.emplace_back(ttStubRef, layerId, layerIdTracklet, false, stubId, ttR, phi, ttZ, psTilt);
164  } else
165  stubs_.emplace_back(ttStubRef, layerId, layerIdTracklet, false, stubId, r, phi, z, psTilt);
166  stubs.push_back(&stubs_.back());
167  }
168  // create fake seed stubs, since TrackBuilder doesn't output these stubs, required by the KF.
169  for (int seedingLayer = 0; seedingLayer < channelAssignment_->numSeedingLayers(); seedingLayer++) {
170  const int channelStub = channelAssignment_->numProjectionLayers(channel) + seedingLayer;
171  const FrameStub& frameStub = streamsStub[offsetStub + channelStub][frame];
172  const TTStubRef& ttStubRef = frameStub.first;
173  if (ttStubRef.isNull())
174  continue;
175  const int layerId = channelAssignment_->layerId(channel, channelStub);
176  const int layerIdTracklet = setup_->trackletLayerId(ttStubRef);
177  const int stubId = TTBV(frameStub.second).val(channelAssignment_->widthSeedStubId());
178  const bool barrel = setup_->barrel(ttStubRef);
179  double r;
180  if (barrel)
182  else {
183  r = (z0 +
185  digi(1. / digi(abs(cot), baseCot), baseInvCot_);
187  }
188  static constexpr double phi = 0.;
189  static constexpr double z = 0.;
190  // determine module type
191  bool psTilt;
192  if (barrel) {
193  const double posZ =
195  const int indexLayerId = setup_->indexLayerId(ttStubRef);
196  const double limit = digi(setup_->tiltedLayerLimitZ(indexLayerId), baseUz_);
197  psTilt = abs(posZ) < limit;
198  } else
199  psTilt = true;
200  const GlobalPoint gp = setup_->stubPos(ttStubRef);
201  const double ttR = gp.perp() - dataFormats_->chosenRofPhi();
202  const double ttZ = gp.z() - (z0 + (ttR + dataFormats_->chosenRofPhi()) * cot);
204  stubs_.emplace_back(ttStubRef, layerId, layerIdTracklet, true, stubId, ttR, phi, ttZ, psTilt);
205  else
206  stubs_.emplace_back(ttStubRef, layerId, layerIdTracklet, true, stubId, r, phi, z, psTilt);
207  stubs.push_back(&stubs_.back());
208  }
209  const bool valid = frame < setup_->numFrames() ? true : enableTruncation_;
210  tracks_.emplace_back(ttTrackRef, valid, r2Inv, phiT, cot, zT, stubs);
211  input.push_back(&tracks_.back());
212  }
213  }
214  }
double hybridDiskZ(int layerId) const
Definition: Setup.h:298
const tt::Setup * setup_
Definition: DRin.h:122
double kz() const
Definition: Settings.h:342
double baseInvCot_
Definition: DRin.h:164
double hybridLayerR(int layerId) const
Definition: Setup.h:296
double hybridRangePhi() const
Definition: Setup.h:300
double hybridMaxCot() const
Definition: Setup.h:292
double baseUz_
Definition: DRin.h:146
double kphi1() const
Definition: Settings.h:339
std::vector< Stub > stubs_
Definition: DRin.h:136
double chosenRofZ() const
Definition: Setup.h:417
bool enableTruncation_
Definition: DRin.h:118
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
Definition: TTBV.h:20
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
int tbWidthR(SensorModule::Type type) const
Definition: Setup.h:308
int numFrames() const
Definition: Setup.h:153
SensorModule::Type type(const TTStubRef &ttStubRef) const
Definition: Setup.cc:329
double hybridBaseR(SensorModule::Type type) const
Definition: Setup.h:282
std::vector< FrameTrack > StreamTrack
Definition: TTTypes.h:64
int offsetStub(int channelTrack) const
int rresidbits() const
Definition: Settings.h:409
static std::string const input
Definition: EdmProvDump.cc:50
double chosenRofPhi() const
Definition: DataFormats.h:508
double tiltedLayerLimitZ(int layer) const
Definition: Setup.h:165
double baseUphiT_
Definition: DRin.h:141
int nbitst() const
Definition: Settings.h:376
double beamWindowZ() const
Definition: Setup.h:180
bool useTTStubResiduals_
Definition: DRin.h:120
GlobalPoint stubPos(const TTStubRef &ttStubRef) const
Definition: Setup.cc:824
const int region_
Definition: DRin.h:132
double maxEta() const
Definition: Setup.h:211
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double digi(double val, double base) const
Definition: DRin.h:41
bool isNull() const
Checks for null.
Definition: Ref.h:235
const trackerTFP::DataFormats * dataFormats_
Definition: DRin.h:124
const Settings * settings_
Definition: DRin.h:130
std::vector< Track > tracks_
Definition: DRin.h:134
int offsetLayerDisks() const
Definition: Setup.h:371
int offsetLayerId() const
Definition: Setup.h:373
int numProjectionLayers(int seedType) const
int widthAddrBRAM18() const
Definition: Setup.h:151
bool psModule(int dtcId) const
Definition: Setup.cc:322
int val() const
Definition: TTBV.h:259
double baseUinv2R_
Definition: DRin.h:140
double baseUzT_
Definition: DRin.h:143
int trackletLayerId(const TTStubRef &ttStubRef) const
Definition: Setup.cc:518
double disk2SR(int layerId, int r) const
Definition: Setup.h:306
int zresidbits() const
Definition: Settings.h:408
int phiresidbits() const
Definition: Settings.h:407
const ChannelAssignment * channelAssignment_
Definition: DRin.h:128
double baseUphi_
Definition: DRin.h:145
double baseUr_
Definition: DRin.h:144
double deltaPhi(double lhs, double rhs=0.)
Definition: Setup.h:37
bool layerId(int seedType, const TTStubRef &ttStubRef, int &layerId) const
int indexLayerId(const TTStubRef &ttStubRef) const
Definition: Setup.cc:523
std::vector< std::vector< Track * > > input_
Definition: DRin.h:138
double baseRegion() const
Definition: Setup.h:184
double kphi() const
Definition: Settings.h:338
bool barrel(const TTStubRef &ttStubRef) const
Definition: Setup.cc:528
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
double baseUcot_
Definition: DRin.h:142

◆ digi()

double trklet::DRin::digi ( double  val,
double  base 
) const
inlineprivate

Definition at line 41 of file DRin.h.

References newFWLiteAna::base, MillePedeFileConverter_cfg::e, and heppy_batch::val.

Referenced by consume(), produce(), and redigi().

41 { return (floor(val / base + 1.e-12) + .5) * base; }
base
Main Program
Definition: newFWLiteAna.py:92

◆ pop_front()

template<class T >
T * trklet::DRin::pop_front ( std::deque< T *> &  ts) const
private

Definition at line 443 of file DRin.cc.

References submitPVValidationJobs::t.

Referenced by produce().

443  {
444  T* t = nullptr;
445  if (!ts.empty()) {
446  t = ts.front();
447  ts.pop_front();
448  }
449  return t;
450  }
long double T

◆ produce()

void trklet::DRin::produce ( tt::StreamsStub accpetedStubs,
tt::StreamsTrack acceptedTracks,
tt::StreamsStub lostStubs,
tt::StreamsTrack lostTracks 
)

Definition at line 217 of file DRin.cc.

References baseHcot_, baseHinv2R_, baseHphi_, baseHphiT_, baseHr_, baseHz_, baseHzT_, baseLcot_, baseLinv2R_, baseLphi_, baseLphiT_, baseLz_, baseLzT_, tt::Setup::baseSector(), baseUcot_, baseUinv2R_, baseUphi_, baseUphiT_, baseUr_, baseUz_, baseUzT_, tt::Setup::boundarieEta(), channelAssignment_, trackerTFP::DataFormats::chosenRofPhi(), tt::Setup::chosenRofZ(), trackerTFP::cot, dataFormats_, trklet::ChannelAssignment::depthMemory(), digi(), PVValHelper::dz, enableTruncation_, cond::serialization::equal(), trackerTFP::DataFormats::format(), trackerTFP::hitPattern, hfClusterShapes_cfi::hits, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), input, input_, PixelMapPlotter::inputs, trackerTFP::DataFormat::inRange(), trackerTFP::inv2R, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, tt::Setup::kfMinLayers(), trklet::DRin::Stub::layer_, trklet::DRin::Stub::layerDet_, layerEncoding_, trackerTFP::LayerEncoding::layerIdKF(), trklet::DRin::Stub::layerKF_, remoteMonitoring_LASER_era2018_cfg::limit, isotracks_cff::lostTracks, trackerTFP::LayerEncoding::maybePattern(), GetRecoTauVFromDQM_MC_cff::next, trklet::ChannelAssignment::nodeDR(), trklet::ChannelAssignment::numChannelsTrack(), tt::Setup::numFrames(), tt::Setup::numLayers(), trklet::ChannelAssignment::numNodesDR(), tt::Setup::numSectorsEta(), or, PVValHelper::phi, trklet::DRin::Stub::phi_, trackerTFP::phiT, pop_front(), trklet::DRin::Stub::psTilt_, alignCSCRings::r, trklet::DRin::Stub::r_, redigi(), region_, tt::Setup::sectorCot(), trackerTFP::sectorEta, trackerTFP::sectorPhi, setup_, svgfig::stack, trklet::DRin::Stub::stubId_, to_string(), trackerTFP::DataFormat::toUnsigned(), HLT_2023v12_cff::track, DiMuonV_cfg::tracks, tracks_, trackerTFP::DataFormat::ttBV(), trklet::DRin::Stub::ttStubRef_, trklet::DRin::Stub::valid_, tt::Setup::widthDSPbu(), trklet::ChannelAssignment::widthLayerId(), trklet::ChannelAssignment::widthSeedStubId(), detailsBasic3DVector::z, trklet::DRin::Stub::z_, and trackerTFP::zT.

Referenced by trklet::ProducerDRin::produce().

220  {
221  // base transform into high precision TMTT format
222  for (Track& track : tracks_) {
223  track.inv2R_ = redigi(track.inv2R_, baseUinv2R_, baseHinv2R_, setup_->widthDSPbu());
224  track.phiT_ = redigi(track.phiT_, baseUphiT_, baseHphiT_, setup_->widthDSPbu());
227  for (Stub* stub : track.stubs_) {
228  stub->r_ = redigi(stub->r_, baseUr_, baseHr_, setup_->widthDSPbu());
229  stub->phi_ = redigi(stub->phi_, baseUphi_, baseHphi_, setup_->widthDSPbu());
230  stub->z_ = redigi(stub->z_, baseUz_, baseHz_, setup_->widthDSPbu());
231  }
232  }
233  // find sector
234  for (Track& track : tracks_) {
235  const int sectorPhi = track.phiT_ < 0. ? 0 : 1;
236  track.phiT_ -= (sectorPhi - .5) * setup_->baseSector();
237  int sectorEta(-1);
238  for (; sectorEta < setup_->numSectorsEta(); sectorEta++)
239  if (track.zT_ < digi(setup_->chosenRofZ() * sinh(setup_->boundarieEta(sectorEta + 1)), baseHzT_))
240  break;
241  if (sectorEta >= setup_->numSectorsEta() || sectorEta <= -1) {
242  track.valid_ = false;
243  continue;
244  }
245  track.cot_ = track.cot_ - digi(setup_->sectorCot(sectorEta), baseHcot_);
246  track.zT_ = track.zT_ - digi(setup_->chosenRofZ() * setup_->sectorCot(sectorEta), baseHzT_);
247  track.sector_ = sectorPhi * setup_->numSectorsEta() + sectorEta;
248  }
249  // base transform into TMTT format
250  for (Track& track : tracks_) {
251  if (!track.valid_)
252  continue;
253  // store track parameter shifts
254  const double dinv2R = digi(track.inv2R_ - digi(track.inv2R_, baseLinv2R_), baseHinv2R_);
255  const double dphiT = digi(track.phiT_ - digi(track.phiT_, baseLphiT_), baseHphiT_);
256  const double dcot = digi(track.cot_ - digi(track.cot_, baseLcot_), baseHcot_);
257  const double dzT = digi(track.zT_ - digi(track.zT_, baseLzT_), baseHzT_);
258  // shift track parameter;
259  track.inv2R_ = digi(track.inv2R_, baseLinv2R_);
260  track.phiT_ = digi(track.phiT_, baseLphiT_);
261  track.cot_ = digi(track.cot_, baseLcot_);
262  track.zT_ = digi(track.zT_, baseLzT_);
263  // range checks
264  if (!dataFormats_->format(Variable::inv2R, Process::kfin).inRange(track.inv2R_, true))
265  track.valid_ = false;
266  if (!dataFormats_->format(Variable::phiT, Process::kfin).inRange(track.phiT_, true))
267  track.valid_ = false;
268  if (!dataFormats_->format(Variable::cot, Process::kfin).inRange(track.cot_, true))
269  track.valid_ = false;
270  if (!dataFormats_->format(Variable::zT, Process::kfin).inRange(track.zT_, true))
271  track.valid_ = false;
272  if (!track.valid_)
273  continue;
274  // adjust stub residuals by track parameter shifts
275  for (Stub* stub : track.stubs_) {
276  const double dphi = digi(dphiT + stub->r_ * dinv2R, baseHphi_);
277  const double r = stub->r_ + digi(dataFormats_->chosenRofPhi() - setup_->chosenRofZ(), baseHr_);
278  const double dz = digi(dzT + r * dcot, baseHz_);
279  stub->phi_ = digi(stub->phi_ + dphi, baseLphi_);
280  stub->z_ = digi(stub->z_ + dz, baseLz_);
281  // range checks
282  if (!dataFormats_->format(Variable::phi, Process::kfin).inRange(stub->phi_))
283  stub->valid_ = false;
284  if (!dataFormats_->format(Variable::z, Process::kfin).inRange(stub->z_))
285  stub->valid_ = false;
286  }
287  }
288  // encode layer id
289  for (Track& track : tracks_) {
290  if (!track.valid_)
291  continue;
292  const int sectorEta = track.sector_ % setup_->numSectorsEta();
293  const int zT = dataFormats_->format(Variable::zT, Process::kfin).toUnsigned(track.zT_);
294  const int cot = dataFormats_->format(Variable::cot, Process::kfin).toUnsigned(track.cot_);
295  for (Stub* stub : track.stubs_) {
296  if (!stub->valid_)
297  continue;
298  // store encoded layerId
299  stub->layerKF_ = layerEncoding_->layerIdKF(sectorEta, zT, cot, stub->layer_);
300  // kill stubs from layers which can't be crossed by track
301  if (stub->layerKF_ == -1)
302  stub->valid_ = false;
303  }
305  // kill multiple stubs from same kf layer
306  for (Stub* stub : track.stubs_) {
307  if (!stub->valid_)
308  continue;
309  if (hitPattern[stub->layerKF_])
310  stub->valid_ = false;
311  else
312  hitPattern.set(stub->layerKF_);
313  }
314  // lookup maybe layers
315  track.maybe_ = layerEncoding_->maybePattern(sectorEta, zT, cot);
316  }
317  // kill tracks with not enough layer
318  for (Track& track : tracks_) {
319  if (!track.valid_)
320  continue;
321  TTBV hits(0, setup_->numLayers());
322  for (const Stub* stub : track.stubs_)
323  if (stub->valid_)
324  hits.set(stub->layerKF_);
325  if (hits.count() < setup_->kfMinLayers())
326  track.valid_ = false;
327  }
328  // store helper
329  auto frameTrack = [this](Track* track) {
330  const TTBV sectorPhi(
331  dataFormats_->format(Variable::sectorPhi, Process::kfin).ttBV(track->sector_ / setup_->numSectorsEta()));
332  const TTBV sectorEta(
333  dataFormats_->format(Variable::sectorEta, Process::kfin).ttBV(track->sector_ % setup_->numSectorsEta()));
334  const TTBV inv2R(dataFormats_->format(Variable::inv2R, Process::kfin).ttBV(track->inv2R_));
335  const TTBV phiT(dataFormats_->format(Variable::phiT, Process::kfin).ttBV(track->phiT_));
336  const TTBV cot(dataFormats_->format(Variable::cot, Process::kfin).ttBV(track->cot_));
337  const TTBV zT(dataFormats_->format(Variable::zT, Process::kfin).ttBV(track->zT_));
338  return FrameTrack(
339  track->ttTrackRef_,
340  Frame("1" + sectorPhi.str() + sectorEta.str() + inv2R.str() + phiT.str() + zT.str() + cot.str()));
341  };
342  auto frameStub = [this](Track* track, int layer) {
343  auto equal = [layer](Stub* stub) { return stub->valid_ && stub->layerKF_ == layer; };
344  const auto it = find_if(track->stubs_.begin(), track->stubs_.end(), equal);
345  if (it == track->stubs_.end() || !(*it)->valid_)
346  return FrameStub();
347  Stub* stub = *it;
348  const TTBV layerId(stub->layerDet_, channelAssignment_->widthLayerId());
349  const TTBV stubId(stub->stubId_, channelAssignment_->widthSeedStubId(), true);
350  const TTBV r(dataFormats_->format(Variable::r, Process::kfin).ttBV(stub->r_));
351  const TTBV phi(dataFormats_->format(Variable::phi, Process::kfin).ttBV(stub->phi_));
352  const TTBV z(dataFormats_->format(Variable::z, Process::kfin).ttBV(stub->z_));
353  return FrameStub(
354  stub->ttStubRef_,
355  Frame("1" + to_string(stub->psTilt_) + layerId.str() + stubId.str() + r.str() + phi.str() + z.str()));
356  };
357  // route tracks into pt bins and store result
358  const int offsetTrack = region_ * channelAssignment_->numNodesDR();
359  for (int nodeDR = 0; nodeDR < channelAssignment_->numNodesDR(); nodeDR++) {
360  deque<Track*> accepted;
361  deque<Track*> lost;
362  vector<deque<Track*>> stacks(channelAssignment_->numChannelsTrack());
363  vector<deque<Track*>> inputs(channelAssignment_->numChannelsTrack());
364  for (int channel = 0; channel < channelAssignment_->numChannelsTrack(); channel++) {
365  for (Track* track : input_[channel]) {
366  const bool match = track && channelAssignment_->nodeDR(track->ttTrackRef_) == nodeDR;
367  if (match && !track->valid_)
368  lost.push_back(track);
369  inputs[channel].push_back(match && track->valid_ ? track : nullptr);
370  }
371  }
372  // remove all gaps between end and last track
373  for (deque<Track*>& input : inputs)
374  for (auto it = input.end(); it != input.begin();)
375  it = (*--it) ? input.begin() : input.erase(it);
376  // clock accurate firmware emulation, each while trip describes one clock tick, one stub in and one stub out per tick
377  while (!all_of(inputs.begin(), inputs.end(), [](const deque<Track*>& tracks) { return tracks.empty(); }) or
378  !all_of(stacks.begin(), stacks.end(), [](const deque<Track*>& tracks) { return tracks.empty(); })) {
379  // fill input fifos
380  for (int channel = 0; channel < channelAssignment_->numChannelsTrack(); channel++) {
381  deque<Track*>& stack = stacks[channel];
382  Track* track = pop_front(inputs[channel]);
383  if (track) {
384  if (enableTruncation_ && (int)stack.size() == channelAssignment_->depthMemory() - 1)
385  lost.push_back(pop_front(stack));
386  stack.push_back(track);
387  }
388  }
389  // merge input fifos to one stream, prioritizing higher input channel over lower channel
390  bool nothingToRoute(true);
391  for (int channel = channelAssignment_->numChannelsTrack() - 1; channel >= 0; channel--) {
392  Track* track = pop_front(stacks[channel]);
393  if (track) {
394  nothingToRoute = false;
395  accepted.push_back(track);
396  break;
397  }
398  }
399  if (nothingToRoute)
400  accepted.push_back(nullptr);
401  }
402  // truncate if desired
403  if (enableTruncation_ && (int)accepted.size() > setup_->numFrames()) {
404  const auto limit = next(accepted.begin(), setup_->numFrames());
405  copy_if(limit, accepted.end(), back_inserter(lost), [](const Track* track) { return track; });
406  accepted.erase(limit, accepted.end());
407  }
408  // remove all gaps between end and last track
409  for (auto it = accepted.end(); it != accepted.begin();)
410  it = (*--it) ? accepted.begin() : accepted.erase(it);
411  // fill products StreamsStub& accpetedStubs, StreamsTrack& acceptedTracks, StreamsStub& lostStubs, StreamsTrack& lostTracks
412  const int channelTrack = offsetTrack + nodeDR;
413  const int offsetStub = channelTrack * setup_->numLayers();
414  // fill lost tracks and stubs without gaps
415  lostTracks[channelTrack].reserve(lost.size());
416  for (int layer = 0; layer < setup_->numLayers(); layer++)
417  lostStubs[offsetStub + layer].reserve(lost.size());
418  for (Track* track : lost) {
419  lostTracks[channelTrack].emplace_back(frameTrack(track));
420  for (int layer = 0; layer < setup_->numLayers(); layer++)
421  lostStubs[offsetStub + layer].emplace_back(frameStub(track, layer));
422  }
423  // fill accepted tracks and stubs with gaps
424  acceptedTracks[channelTrack].reserve(accepted.size());
425  for (int layer = 0; layer < setup_->numLayers(); layer++)
426  accpetedStubs[offsetStub + layer].reserve(accepted.size());
427  for (Track* track : accepted) {
428  if (!track) { // fill gap
429  acceptedTracks[channelTrack].emplace_back(FrameTrack());
430  for (int layer = 0; layer < setup_->numLayers(); layer++)
431  accpetedStubs[offsetStub + layer].emplace_back(FrameStub());
432  continue;
433  }
434  acceptedTracks[channelTrack].emplace_back(frameTrack(track));
435  for (int layer = 0; layer < setup_->numLayers(); layer++)
436  accpetedStubs[offsetStub + layer].emplace_back(frameStub(track, layer));
437  }
438  }
439  }
bool inRange(double d, bool digi=false) const
Definition: DataFormats.h:106
double baseHphi_
Definition: DRin.h:161
const tt::Setup * setup_
Definition: DRin.h:122
std::bitset< TTBV::S_ > Frame
Definition: TTTypes.h:58
double redigi(double val, double baseLow, double baseHigh, int widthMultiplier) const
Definition: DRin.cc:453
double baseUz_
Definition: DRin.h:146
double baseLz_
Definition: DRin.h:154
double chosenRofZ() const
Definition: Setup.h:417
bool enableTruncation_
Definition: DRin.h:118
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
Definition: TTBV.h:20
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
TTBV ttBV(int i) const
Definition: DataFormats.h:78
double baseHr_
Definition: DRin.h:160
const trackerTFP::LayerEncoding * layerEncoding_
Definition: DRin.h:126
double boundarieEta(int eta) const
Definition: Setup.h:421
int nodeDR(const TTTrackRef &ttTrackRef) const
int numFrames() const
Definition: Setup.h:153
int widthDSPbu() const
Definition: Setup.h:141
double baseLcot_
Definition: DRin.h:150
float float float z
TTBV maybePattern(int binEta, int binZT, int binCot) const
int kfMinLayers() const
Definition: Setup.h:493
static std::string to_string(const XMLCh *ch)
bool equal(const T &first, const T &second)
Definition: Equal.h:32
static std::string const input
Definition: EdmProvDump.cc:50
double chosenRofPhi() const
Definition: DataFormats.h:508
double baseUphiT_
Definition: DRin.h:141
std::pair< TTTrackRef, Frame > FrameTrack
Definition: TTTypes.h:62
double baseHz_
Definition: DRin.h:162
double baseHzT_
Definition: DRin.h:159
int numSectorsEta() const
Definition: Setup.h:415
const int region_
Definition: DRin.h:132
double baseSector() const
Definition: Setup.h:424
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
stack
Definition: svgfig.py:559
double baseLphiT_
Definition: DRin.h:149
double digi(double val, double base) const
Definition: DRin.h:41
const trackerTFP::DataFormats * dataFormats_
Definition: DRin.h:124
int numLayers() const
Definition: Setup.h:215
std::vector< Track > tracks_
Definition: DRin.h:134
double baseHinv2R_
Definition: DRin.h:156
double baseLphi_
Definition: DRin.h:153
double baseUinv2R_
Definition: DRin.h:140
double baseUzT_
Definition: DRin.h:143
int toUnsigned(int i) const
Definition: DataFormats.h:102
const ChannelAssignment * channelAssignment_
Definition: DRin.h:128
T * pop_front(std::deque< T *> &ts) const
Definition: DRin.cc:443
double baseUphi_
Definition: DRin.h:145
double baseUr_
Definition: DRin.h:144
const int layerIdKF(int binEta, int binZT, int binCot, int layerId) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
double baseHphiT_
Definition: DRin.h:157
std::vector< std::vector< Track * > > input_
Definition: DRin.h:138
double sectorCot(int eta) const
Definition: Setup.h:432
double baseHcot_
Definition: DRin.h:158
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
double baseLinv2R_
Definition: DRin.h:148
double baseUcot_
Definition: DRin.h:142
double baseLzT_
Definition: DRin.h:151
const DataFormat & format(Variable v, Process p) const
Definition: DataFormats.h:506

◆ redigi()

double trklet::DRin::redigi ( double  val,
double  baseLow,
double  baseHigh,
int  widthMultiplier 
) const
private

Definition at line 453 of file DRin.cc.

References newFWLiteAna::base, digi(), funct::pow(), HcalDetIdTransform::transform(), and heppy_batch::val.

Referenced by produce().

453  {
454  const double base = pow(2, 1 - widthMultiplier);
455  const double transform = digi(baseLow / baseHigh, base);
456  return (floor(val * transform / baseLow) + .5) * baseHigh;
457  }
base
Main Program
Definition: newFWLiteAna.py:92
double digi(double val, double base) const
Definition: DRin.h:41
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Data Documentation

◆ baseHcot_

double trklet::DRin::baseHcot_
private

Definition at line 158 of file DRin.h.

Referenced by produce().

◆ baseHinv2R_

double trklet::DRin::baseHinv2R_
private

Definition at line 156 of file DRin.h.

Referenced by produce().

◆ baseHphi_

double trklet::DRin::baseHphi_
private

Definition at line 161 of file DRin.h.

Referenced by produce().

◆ baseHphiT_

double trklet::DRin::baseHphiT_
private

Definition at line 157 of file DRin.h.

Referenced by produce().

◆ baseHr_

double trklet::DRin::baseHr_
private

Definition at line 160 of file DRin.h.

Referenced by produce().

◆ baseHz_

double trklet::DRin::baseHz_
private

Definition at line 162 of file DRin.h.

Referenced by produce().

◆ baseHzT_

double trklet::DRin::baseHzT_
private

Definition at line 159 of file DRin.h.

Referenced by produce().

◆ baseInvCot_

double trklet::DRin::baseInvCot_
private

Definition at line 164 of file DRin.h.

Referenced by consume(), and DRin().

◆ baseLcot_

double trklet::DRin::baseLcot_
private

Definition at line 150 of file DRin.h.

Referenced by produce().

◆ baseLinv2R_

double trklet::DRin::baseLinv2R_
private

Definition at line 148 of file DRin.h.

Referenced by produce().

◆ baseLphi_

double trklet::DRin::baseLphi_
private

Definition at line 153 of file DRin.h.

Referenced by produce().

◆ baseLphiT_

double trklet::DRin::baseLphiT_
private

Definition at line 149 of file DRin.h.

Referenced by produce().

◆ baseLr_

double trklet::DRin::baseLr_
private

Definition at line 152 of file DRin.h.

◆ baseLz_

double trklet::DRin::baseLz_
private

Definition at line 154 of file DRin.h.

Referenced by produce().

◆ baseLzT_

double trklet::DRin::baseLzT_
private

Definition at line 151 of file DRin.h.

Referenced by produce().

◆ baseUcot_

double trklet::DRin::baseUcot_
private

Definition at line 142 of file DRin.h.

Referenced by consume(), and produce().

◆ baseUinv2R_

double trklet::DRin::baseUinv2R_
private

Definition at line 140 of file DRin.h.

Referenced by consume(), and produce().

◆ baseUphi_

double trklet::DRin::baseUphi_
private

Definition at line 145 of file DRin.h.

Referenced by consume(), and produce().

◆ baseUphiT_

double trklet::DRin::baseUphiT_
private

Definition at line 141 of file DRin.h.

Referenced by consume(), and produce().

◆ baseUr_

double trklet::DRin::baseUr_
private

Definition at line 144 of file DRin.h.

Referenced by consume(), and produce().

◆ baseUz_

double trklet::DRin::baseUz_
private

Definition at line 146 of file DRin.h.

Referenced by consume(), and produce().

◆ baseUzT_

double trklet::DRin::baseUzT_
private

Definition at line 143 of file DRin.h.

Referenced by consume(), and produce().

◆ channelAssignment_

const ChannelAssignment* trklet::DRin::channelAssignment_
private

Definition at line 128 of file DRin.h.

Referenced by consume(), and produce().

◆ dataFormats_

const trackerTFP::DataFormats* trklet::DRin::dataFormats_
private

Definition at line 124 of file DRin.h.

Referenced by consume(), and produce().

◆ enableTruncation_

bool trklet::DRin::enableTruncation_
private

Definition at line 118 of file DRin.h.

Referenced by consume(), and produce().

◆ input_

std::vector<std::vector<Track*> > trklet::DRin::input_
private

Definition at line 138 of file DRin.h.

Referenced by consume(), and produce().

◆ layerEncoding_

const trackerTFP::LayerEncoding* trklet::DRin::layerEncoding_
private

Definition at line 126 of file DRin.h.

Referenced by produce().

◆ region_

const int trklet::DRin::region_
private

Definition at line 132 of file DRin.h.

Referenced by consume(), and produce().

◆ settings_

const Settings* trklet::DRin::settings_
private

Definition at line 130 of file DRin.h.

Referenced by consume().

◆ setup_

const tt::Setup* trklet::DRin::setup_
private

Definition at line 122 of file DRin.h.

Referenced by consume(), DRin(), produce(), and upgradeWorkflowComponents.UpgradeWorkflow::setup().

◆ stubs_

std::vector<Stub> trklet::DRin::stubs_
private

Definition at line 136 of file DRin.h.

Referenced by consume().

◆ tracks_

std::vector<Track> trklet::DRin::tracks_
private

Definition at line 134 of file DRin.h.

Referenced by consume(), and produce().

◆ useTTStubResiduals_

bool trklet::DRin::useTTStubResiduals_
private

Definition at line 120 of file DRin.h.

Referenced by consume().