82 kPtSize = TTTrack_TrackWord::TrackBitWidths::kRinvSize - 1,
84 kEtaSize = TTTrack_TrackWord::TrackBitWidths::kTanlSize,
131 ap_fixed<TrackBitWidths::kEtaSize, TrackBitWidths::kEtaMagSize> etaEmulation;
132 etaEmulation.V = etaEmulationBits.range();
141 ap_uint<TrackBitWidths::kPtSize> ptEmulationBits =
t.getTrackWord()(
142 TTTrack_TrackWord::TrackBitLocations::kRinvMSB - 1, TTTrack_TrackWord::TrackBitLocations::kRinvLSB);
143 ap_ufixed<TrackBitWidths::kPtSize, TrackBitWidths::kPtMagSize> ptEmulation;
144 ptEmulation.V = ptEmulationBits.range();
177 log <<
"Processed track link counters:\t[";
184 log <<
"Truncated track link counters:\t[";
219 : processSimulatedTracks_(iConfig.getParameter<
bool>(
"processSimulatedTracks")),
220 processEmulatedTracks_(iConfig.getParameter<
bool>(
"processEmulatedTracks")),
222 l1VerticesToken_(processSimulatedTracks_
225 l1SelectedTracksToken_(
226 processSimulatedTracks_
229 l1VerticesEmulationToken_(
230 processEmulatedTracks_
233 l1SelectedTracksEmulationToken_(processEmulatedTracks_
235 "l1SelectedTracksEmulationInputTag"))
237 outputCollectionName_(iConfig.getParameter<
std::
string>(
"outputCollectionName")),
240 deltaZMaxEtaBounds_(cutSet_.getParameter<
std::
vector<double>>(
"deltaZMaxEtaBounds")),
241 deltaZMax_(cutSet_.getParameter<
std::
vector<double>>(
"deltaZMax")),
242 useDisplacedTracksDeltaZOverride_(iConfig.getParameter<double>(
"useDisplacedTracksDeltaZOverride")),
243 fwNTrackSetsTVA_(iConfig.getParameter<unsigned
int>(
"fwNTrackSetsTVA")),
244 debug_(iConfig.getParameter<
int>(
"debug")) {
247 throw cms::Exception(
"You must process at least one of the track collections (simulated or emulated).");
251 throw cms::Exception(
"The number of deltaZ cuts does not match the number of eta bins!");
278 log <<
"The original selected track collection (pt, eta, phi, nstub, bendchi2, chi2rz, chi2rphi, z0) values are " 280 for (
const auto&
track : *l1SelectedTracksHandle) {
283 log <<
"\t---\n\tNumber of tracks in this selection = " << l1SelectedTracksHandle->size() <<
"\n\n";
286 log <<
"The original selected emulated track collection (pt, eta, phi, nstub, bendchi2, chi2rz, chi2rphi, z0) " 288 for (
const auto&
track : *l1SelectedTracksEmulationHandle) {
291 log <<
"\t---\n\tNumber of tracks in this selection = " << l1SelectedTracksEmulationHandle->size() <<
"\n\n";
297 l1SelectedTracksHandle->
end(),
298 l1SelectedTracksEmulationHandle->
begin(),
299 l1SelectedTracksEmulationHandle->
end(),
300 std::back_inserter(inSimButNotEmu));
302 l1SelectedTracksEmulationHandle->
end(),
303 l1SelectedTracksHandle->
begin(),
304 l1SelectedTracksHandle->
end(),
305 std::back_inserter(inEmuButNotSim));
306 log <<
"The set of tracks selected via cuts on the simulated values which are not in the set of tracks selected " 307 "by cutting on the emulated values ... \n";
308 for (
const auto&
track : inSimButNotEmu) {
311 log <<
"\t---\n\tNumber of tracks in this selection = " << inSimButNotEmu.size() <<
"\n\n" 312 <<
"The set of tracks selected via cuts on the emulated values which are not in the set of tracks selected " 313 "by cutting on the simulated values ... \n";
314 for (
const auto&
track : inEmuButNotSim) {
317 log <<
"\t---\n\tNumber of tracks in this selection = " << inEmuButNotSim.size() <<
"\n\n";
320 log <<
"The selected and leading vertex associated track collection (pt, eta, phi, nstub, bendchi2, chi2rz, " 321 "chi2rphi, z0) values are ... \n";
322 for (
const auto&
track : *vTTTrackAssociatedOutput) {
325 log <<
"\t---\n\tNumber of tracks in this selection = " << vTTTrackAssociatedOutput->size() <<
"\n\n";
328 log <<
"The emulation selected and leading vertex associated track collection (pt, eta, phi, nstub, bendchi2, " 329 "chi2rz, chi2rphi, z0) values are " 331 for (
const auto&
track : *vTTTrackAssociatedEmulationOutput) {
334 log <<
"\t---\n\tNumber of tracks in this selection = " << vTTTrackAssociatedEmulationOutput->size() <<
"\n\n";
340 vTTTrackAssociatedOutput->end(),
341 vTTTrackAssociatedEmulationOutput->begin(),
342 vTTTrackAssociatedEmulationOutput->end(),
343 std::back_inserter(inSimButNotEmu));
345 vTTTrackAssociatedEmulationOutput->end(),
346 vTTTrackAssociatedOutput->begin(),
347 vTTTrackAssociatedOutput->end(),
348 std::back_inserter(inEmuButNotSim));
349 log <<
"The set of vertex associated tracks selected via cuts on the simulated values which are not in the set of " 351 "by cutting on the emulated values ... \n";
352 for (
const auto&
track : inSimButNotEmu) {
355 log <<
"\t---\n\tNumber of tracks in this selection = " << inSimButNotEmu.size() <<
"\n\n" 356 <<
"The set of vertex associated tracks selected via cuts on the emulated values which are not in the set of " 358 "by cutting on the simulated values ... \n";
359 for (
const auto&
track : inEmuButNotSim) {
362 log <<
"\t---\n\tNumber of tracks in this selection = " << inEmuButNotSim.size() <<
"\n\n";
368 bool printEmulation)
const {
369 log <<
"\t(" <<
track.momentum().perp() <<
", " <<
track.momentum().eta() <<
", " <<
track.momentum().phi() <<
", " 370 <<
track.getStubRefs().size() <<
", " <<
track.stubPtConsistency() <<
", " <<
track.chi2ZRed() <<
", " 371 <<
track.chi2XYRed() <<
", " <<
track.z0() <<
")\n";
373 if (printEmulation) {
374 ap_uint<TrackBitWidths::kPtSize> ptEmulationBits =
track.getTrackWord()(
375 TTTrack_TrackWord::TrackBitLocations::kRinvMSB - 1, TTTrack_TrackWord::TrackBitLocations::kRinvLSB);
376 ap_ufixed<TrackBitWidths::kPtSize, TrackBitWidths::kPtMagSize> ptEmulation;
377 ptEmulation.V = ptEmulationBits.range();
379 ap_fixed<TrackBitWidths::kEtaSize, TrackBitWidths::kEtaMagSize> etaEmulation;
380 etaEmulation.V = etaEmulationBits.range();
381 double floatTkZ0 =
track.undigitizeSignedValue(
383 double floatTkPhi =
track.undigitizeSignedValue(
385 log <<
"\t\t(" << ptEmulation.to_double() <<
", " << etaEmulation.to_double() <<
", " << floatTkPhi <<
", " 386 <<
track.getNStubs() <<
", " <<
track.getBendChi2() <<
", " <<
track.getChi2RZ() <<
", " <<
track.getChi2RPhi()
387 <<
", " << floatTkZ0 <<
")\n";
393 auto vTTTrackAssociatedOutput = std::make_unique<TTTrackRefCollectionType>();
394 auto vTTTrackAssociatedEmulationOutput = std::make_unique<TTTrackRefCollectionType>();
412 size_t nOutputApproximate = l1TracksHandle->size();
417 leadingVertex = l1VerticesHandle->at(0);
419 edm::LogInfo(
"L1TrackVertexAssociationProducer") <<
"leading vertex z0 = " << leadingVertex.
z0();
421 vTTTrackAssociatedOutput->reserve(nOutputApproximate);
426 leadingEmulationVertex = l1VerticesEmulationHandle->at(0);
429 <<
"leading emulation vertex z0 = " << leadingEmulationVertex.
z0();
431 vTTTrackAssociatedEmulationOutput->reserve(nOutputApproximate);
433 for (
size_t i = 0;
i < nOutputApproximate;
i++) {
434 const auto&
track = l1TracksHandle->at(
i);
437 bool passLinkLimit = linkLimitSel(
track);
439 auto itr = std::find_if(l1SelectedTracksHandle->
begin(), l1SelectedTracksHandle->
end(), [
track](
const auto& ref) {
440 return (*ref).getTrackWord() ==
track.getTrackWord();
442 bool passSelection = (itr != l1SelectedTracksHandle->
end());
444 if (passLinkLimit && passSelection && deltaZSel(
track, leadingVertex)) {
445 vTTTrackAssociatedOutput->push_back(
TTTrackRef(l1TracksHandle,
i));
450 bool passLinkLimitEmu = linkLimitSelEmu(
track);
452 auto itrEmu = std::find_if(l1SelectedTracksEmulationHandle->
begin(),
453 l1SelectedTracksEmulationHandle->
end(),
454 [
track](
const auto& ref) {
return (*ref).getTrackWord() ==
track.getTrackWord(); });
455 bool passSelectionEmu = (itrEmu != l1SelectedTracksEmulationHandle->
end());
457 if (passLinkLimitEmu && passSelectionEmu && deltaZSelEmu(
track, l1VerticesEmulationHandle->at(0))) {
458 vTTTrackAssociatedEmulationOutput->push_back(
TTTrackRef(l1TracksHandle,
i));
470 linkLimitSelEmu.
log();
475 l1SelectedTracksEmulationHandle,
476 vTTTrackAssociatedOutput,
477 vTTTrackAssociatedEmulationOutput);
486 edm::InputTag(
"l1tTrackSelectionProducer",
"Level1TTTracksSelected"));
488 edm::InputTag(
"l1tTrackSelectionProducer",
"Level1TTTracksSelectedEmulation"));
491 edm::InputTag(
"l1tVertexFinderEmulator",
"L1VerticesEmulation"));
492 desc.add<
std::string>(
"outputCollectionName",
"Level1TTTracksSelectedAssociated");
495 descCutSet.
add<std::vector<double>>(
"deltaZMaxEtaBounds", {0.0, 0.7, 1.0, 1.2, 1.6, 2.0, 2.4})
496 ->setComment(
"these values define the bin boundaries in |eta|");
497 descCutSet.
add<std::vector<double>>(
"deltaZMax", {0.37, 0.50, 0.60, 0.75, 1.00, 1.60})
499 "delta z must be less than these values, there will be one less value here than in deltaZMaxEtaBounds, " 503 desc.add<
double>(
"useDisplacedTracksDeltaZOverride", -1.0)
504 ->setComment(
"override the deltaZ cut value for displaced tracks");
505 desc.add<
bool>(
"processSimulatedTracks",
true)
506 ->setComment(
"return selected tracks after cutting on the floating point values");
507 desc.add<
bool>(
"processEmulatedTracks",
true)
508 ->setComment(
"return selected tracks after cutting on the bitwise emulated values");
509 desc.add<
unsigned int>(
"fwNTrackSetsTVA", 94)->setComment(
"firmware limit on processed tracks per GTT input link");
510 desc.add<
int>(
"debug", 0)->setComment(
"Verbosity levels: 0, 1, 2, 3");
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::vector< double > deltaZMax_
const edm::EDGetTokenT< TTTrackCollectionType > l1TracksToken_
void printTrackInfo(edm::LogInfo &log, const TTTrackType &track, bool printEmulation=false) const
bool operator()(const TTTrackType &t, const l1t::VertexWord &v) const
TTTrackWordLinkLimitSelector(const edm::ParameterSet &cfg)
L1TrackVertexAssociationProducer(const edm::ParameterSet &)
TTTrackDeltaZMaxSelector(const std::vector< double > &deltaZMaxEtaBounds, const std::vector< double > &deltaZMax)
std::vector< unsigned int > processedTracksPerLink_
TTTrackDeltaZMaxSelector(const edm::ParameterSet &cfg)
bool operator()(const TTTrackType &t, const l1t::Vertex &v) const
std::vector< double > deltaZMaxEtaBounds_
~L1TrackVertexAssociationProducer() override
const std::string outputCollectionName_
const bool processEmulatedTracks_
const edm::ParameterSet cutSet_
std::vector< Vertex > VertexCollection
const double useDisplacedTracksDeltaZOverride_
const edm::EDGetTokenT< l1t::VertexCollection > l1VerticesToken_
const edm::EDGetTokenT< TTTrackRefCollectionType > l1SelectedTracksToken_
TTTrackWordDeltaZMaxSelector(const std::vector< double > &deltaZMaxEtaBounds, const std::vector< double > &deltaZMax)
const unsigned int fwNTrackSetsTVA_
ap_fixed< VertexBitWidths::kZ0Size, VertexBitWidths::kZ0MagSize, AP_RND_CONV, AP_SAT > vtxz0_t
edm::Handle< TTTrackCollectionType > TTTrackCollectionHandle
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
TTTrackWordLinkLimitSelector(const unsigned int fwNTrackSetsTVA)
unsigned int gttLinkID(T track)
Abs< T >::type abs(const T &t)
def template(fileName, svg, replaceme="REPLACEME")
std::vector< unsigned int > truncatedTracksPerLink_
#define DEFINE_FWK_MODULE(type)
std::vector< VertexWord > VertexWordCollection
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool operator()(const TTTrackType &t)
unsigned int fwNTrackSetsTVA_
TTTrackWordDeltaZMaxSelector(const edm::ParameterSet &cfg)
Log< level::Info, false > LogInfo
std::vector< double > deltaZMax_
Class to store the L1 Track Trigger tracks.
const_iterator end() const
Termination of iteration.
void printDebugInfo(const edm::Handle< TTTrackRefCollectionType > &l1SelectedTracksHandle, const edm::Handle< TTTrackRefCollectionType > &l1SelectedTracksEmulationHandle, const TTTrackRefCollectionUPtr &vTTTrackAssociatedOutput, const TTTrackRefCollectionUPtr &vTTTrackAssociatedEmulationOutput) const
std::vector< double > deltaZMaxEtaBounds_
static constexpr double stepPhi0
std::vector< double > deltaZMax_
std::vector< double > deltaZMaxEtaBounds_
std::unique_ptr< TTTrackRefCollectionType > TTTrackRefCollectionUPtr
ap_uint< TrackBitWidths::kTanlSize > tanl_t
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< l1t::VertexWordCollection > l1VerticesEmulationToken_
edm::RefVector< TTTrackCollectionType > TTTrackRefCollectionType
const_iterator begin() const
Initialize an iterator over the RefVector.
TTTrack< Ref_Phase2TrackerDigi_ > TTTrackType
static constexpr double stepZ0
const edm::EDGetTokenT< TTTrackRefCollectionType > l1SelectedTracksEmulationToken_
const bool processSimulatedTracks_
std::vector< TTTrackType > TTTrackCollectionType