Skip to content

Commit

Permalink
Update files from code-checks and code-format and update to final l1t…
Browse files Browse the repository at this point in the history
… naming convention
  • Loading branch information
Nick Manganelli committed Jun 12, 2023
1 parent 1a5696f commit b17fb0e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 46 deletions.
4 changes: 1 addition & 3 deletions L1Trigger/L1TTrackMatch/plugins/L1TrackSelectionProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,7 @@ void L1TrackSelectionProducer::produce(edm::StreamID, edm::Event& iEvent, const
}

if (debug_ >= 2) {
printDebugInfo(l1TracksHandle,
vTTTrackOutput,
vTTTrackEmulationOutput);
printDebugInfo(l1TracksHandle, vTTTrackOutput, vTTTrackEmulationOutput);
}

// Put the outputs into the event
Expand Down
80 changes: 45 additions & 35 deletions L1Trigger/L1TTrackMatch/plugins/L1TrackVertexAssociationProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <ap_fixed.h>
#include <ap_int.h>


// user include files
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/Ref.h"
Expand Down Expand Up @@ -91,12 +90,11 @@ class L1TrackVertexAssociationProducer : public edm::global::EDProducer<> {
typedef edm::RefVector<TTTrackCollectionType> TTTrackRefCollectionType;
typedef std::unique_ptr<TTTrackRefCollectionType> TTTrackRefCollectionUPtr;


// ----------member functions ----------------------
void printDebugInfo(const edm::Handle<TTTrackRefCollectionType>& l1SelectedTracksHandle,
const edm::Handle<TTTrackRefCollectionType>& l1SelectedTracksEmulationHandle,
const TTTrackRefCollectionUPtr& vTTTrackAssociatedOutput,
const TTTrackRefCollectionUPtr& vTTTrackAssociatedEmulationOutput) const;
const edm::Handle<TTTrackRefCollectionType>& l1SelectedTracksEmulationHandle,
const TTTrackRefCollectionUPtr& vTTTrackAssociatedOutput,
const TTTrackRefCollectionUPtr& vTTTrackAssociatedEmulationOutput) const;
void printTrackInfo(edm::LogInfo& log, const TTTrackType& track, bool printEmulation = false) const;
void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;

Expand Down Expand Up @@ -168,18 +166,21 @@ class L1TrackVertexAssociationProducer : public edm::global::EDProducer<> {
// constructors and destructor
//
L1TrackVertexAssociationProducer::L1TrackVertexAssociationProducer(const edm::ParameterSet& iConfig)
: l1VerticesToken_(iConfig.getParameter<bool>("processSimulatedTracks") ?
consumes<l1t::VertexCollection>(iConfig.getParameter<edm::InputTag>("l1VerticesInputTag")) :
edm::EDGetTokenT<l1t::VertexCollection>()),
l1SelectedTracksToken_(iConfig.getParameter<bool>("processSimulatedTracks") ?
consumes<TTTrackRefCollectionType>(iConfig.getParameter<edm::InputTag>("l1SelectedTracksInputTag")) :
edm::EDGetTokenT<TTTrackRefCollectionType>()),
l1VerticesEmulationToken_(iConfig.getParameter<bool>("processEmulatedTracks") ?
consumes<l1t::VertexWordCollection>(iConfig.getParameter<edm::InputTag>("l1VerticesEmulationInputTag")) :
edm::EDGetTokenT<l1t::VertexWordCollection>()),
l1SelectedTracksEmulationToken_(iConfig.getParameter<bool>("processEmulatedTracks") ?
consumes<TTTrackRefCollectionType>(iConfig.getParameter<edm::InputTag>("l1SelectedTracksEmulationInputTag")) :
edm::EDGetTokenT<TTTrackRefCollectionType>()),
: l1VerticesToken_(iConfig.getParameter<bool>("processSimulatedTracks")
? consumes<l1t::VertexCollection>(iConfig.getParameter<edm::InputTag>("l1VerticesInputTag"))
: edm::EDGetTokenT<l1t::VertexCollection>()),
l1SelectedTracksToken_(
iConfig.getParameter<bool>("processSimulatedTracks")
? consumes<TTTrackRefCollectionType>(iConfig.getParameter<edm::InputTag>("l1SelectedTracksInputTag"))
: edm::EDGetTokenT<TTTrackRefCollectionType>()),
l1VerticesEmulationToken_(
iConfig.getParameter<bool>("processEmulatedTracks")
? consumes<l1t::VertexWordCollection>(iConfig.getParameter<edm::InputTag>("l1VerticesEmulationInputTag"))
: edm::EDGetTokenT<l1t::VertexWordCollection>()),
l1SelectedTracksEmulationToken_(iConfig.getParameter<bool>("processEmulatedTracks")
? consumes<TTTrackRefCollectionType>(iConfig.getParameter<edm::InputTag>(
"l1SelectedTracksEmulationInputTag"))
: edm::EDGetTokenT<TTTrackRefCollectionType>()),
outputCollectionName_(iConfig.getParameter<std::string>("outputCollectionName")),
cutSet_(iConfig.getParameter<edm::ParameterSet>("cutSet")),

Expand Down Expand Up @@ -232,20 +233,22 @@ L1TrackVertexAssociationProducer::~L1TrackVertexAssociationProducer() {}
//

void L1TrackVertexAssociationProducer::printDebugInfo(
const edm::Handle<TTTrackRefCollectionType>& l1SelectedTracksHandle,
const edm::Handle<TTTrackRefCollectionType>& l1SelectedTracksEmulationHandle,
const TTTrackRefCollectionUPtr& vTTTrackAssociatedOutput,
const TTTrackRefCollectionUPtr& vTTTrackAssociatedEmulationOutput) const {
const edm::Handle<TTTrackRefCollectionType>& l1SelectedTracksHandle,
const edm::Handle<TTTrackRefCollectionType>& l1SelectedTracksEmulationHandle,
const TTTrackRefCollectionUPtr& vTTTrackAssociatedOutput,
const TTTrackRefCollectionUPtr& vTTTrackAssociatedEmulationOutput) const {
edm::LogInfo log("L1TrackVertexAssociationProducer");
if (processSimulatedTracks_) {
log << "The original selected track collection (pt, eta, phi, nstub, bendchi2, chi2rz, chi2rphi, z0) values are ... \n";
log << "The original selected track collection (pt, eta, phi, nstub, bendchi2, chi2rz, chi2rphi, z0) values are "
"... \n";
for (const auto& track : *l1SelectedTracksHandle) {
printTrackInfo(log, *track, debug_ >= 4);
}
log << "\t---\n\tNumber of tracks in this selection = " << l1SelectedTracksHandle->size() << "\n\n";
}
if (processEmulatedTracks_) {
log << "The original selected emulated track collection (pt, eta, phi, nstub, bendchi2, chi2rz, chi2rphi, z0) values are ... \n";
log << "The original selected emulated track collection (pt, eta, phi, nstub, bendchi2, chi2rz, chi2rphi, z0) "
"values are ... \n";
for (const auto& track : *l1SelectedTracksEmulationHandle) {
printTrackInfo(log, *track, debug_ >= 4);
}
Expand Down Expand Up @@ -307,13 +310,15 @@ void L1TrackVertexAssociationProducer::printDebugInfo(
vTTTrackAssociatedOutput->begin(),
vTTTrackAssociatedOutput->end(),
std::back_inserter(inEmuButNotSim));
log << "The set of vertex associated tracks selected via cuts on the simulated values which are not in the set of tracks selected "
log << "The set of vertex associated tracks selected via cuts on the simulated values which are not in the set of "
"tracks selected "
"by cutting on the emulated values ... \n";
for (const auto& track : inSimButNotEmu) {
printTrackInfo(log, *track, debug_ >= 3);
}
log << "\t---\n\tNumber of tracks in this selection = " << inSimButNotEmu.size() << "\n\n"
<< "The set of vertex associated tracks selected via cuts on the emulated values which are not in the set of tracks selected "
<< "The set of vertex associated tracks selected via cuts on the emulated values which are not in the set of "
"tracks selected "
"by cutting on the simulated values ... \n";
for (const auto& track : inEmuButNotSim) {
printTrackInfo(log, *track, debug_ >= 3);
Expand All @@ -322,7 +327,9 @@ void L1TrackVertexAssociationProducer::printDebugInfo(
}
}

void L1TrackVertexAssociationProducer::printTrackInfo(edm::LogInfo& log, const TTTrackType& track, bool printEmulation) const {
void L1TrackVertexAssociationProducer::printTrackInfo(edm::LogInfo& log,
const TTTrackType& track,
bool printEmulation) const {
log << "\t(" << track.momentum().perp() << ", " << track.momentum().eta() << ", " << track.momentum().phi() << ", "
<< track.getStubRefs().size() << ", " << track.stubPtConsistency() << ", " << track.chi2ZRed() << ", "
<< track.chi2XYRed() << ", " << track.z0() << ")\n";
Expand Down Expand Up @@ -375,7 +382,7 @@ void L1TrackVertexAssociationProducer::produce(edm::StreamID, edm::Event& iEvent
auto track = l1tVertexFinder::L1Track(edm::refToPtr(trackword));
// Select tracks based on the floating point TTTrack
if (deltaZSel(*trackword, leadingVertex)) {
vTTTrackAssociatedOutput->push_back(trackword);
vTTTrackAssociatedOutput->push_back(trackword);
}
}
iEvent.put(std::move(vTTTrackAssociatedOutput), outputCollectionName_);
Expand All @@ -386,21 +393,22 @@ void L1TrackVertexAssociationProducer::produce(edm::StreamID, edm::Event& iEvent
size_t nOutputApproximateEmulation = l1SelectedTracksEmulationHandle->size();
leadingEmulationVertex = l1VerticesEmulationHandle->at(0);
if (debug_ >= 2) {
edm::LogInfo("L1TrackVertexAssociationProducer") << "leading emulation vertex z0 = " << leadingEmulationVertex.z0();
edm::LogInfo("L1TrackVertexAssociationProducer")
<< "leading emulation vertex z0 = " << leadingEmulationVertex.z0();
}
vTTTrackAssociatedEmulationOutput->reserve(nOutputApproximateEmulation);
for (const auto& trackword : *l1SelectedTracksEmulationHandle) {
// Select tracks based on the bitwise accurate TTTrack_TrackWord
if (deltaZSelEmu(*trackword, leadingEmulationVertex)) {
vTTTrackAssociatedEmulationOutput->push_back(trackword);
vTTTrackAssociatedEmulationOutput->push_back(trackword);
}
}
iEvent.put(std::move(vTTTrackAssociatedEmulationOutput), outputCollectionName_ + "Emulation");
}

if (processSimulatedTracks_ && processEmulatedTracks_ && debug_ >= 2) {
printDebugInfo(l1SelectedTracksHandle,
l1SelectedTracksEmulationHandle,
l1SelectedTracksEmulationHandle,
vTTTrackAssociatedOutput,
vTTTrackAssociatedEmulationOutput);
}
Expand All @@ -409,11 +417,13 @@ void L1TrackVertexAssociationProducer::produce(edm::StreamID, edm::Event& iEvent
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void L1TrackVertexAssociationProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.addOptional<edm::InputTag>("l1SelectedTracksInputTag", edm::InputTag("L1TrackSelectionProducer", "Level1TTTracksSelected"));
desc.addOptional<edm::InputTag>("l1SelectedTracksEmulationInputTag", edm::InputTag("L1TrackSelectionProducer", "Level1TTTracksSelectedEmulation"));
desc.addOptional<edm::InputTag>("l1VerticesInputTag", edm::InputTag("L1VertexFinder", "l1vertices"));
desc.addOptional<edm::InputTag>("l1VerticesEmulationInputTag",
edm::InputTag("L1VertexFinderEmulator", "l1verticesEmulation"));
desc.add<edm::InputTag>("l1SelectedTracksInputTag",
edm::InputTag("l1tTrackSelectionProducer", "Level1TTTracksSelected"));
desc.add<edm::InputTag>("l1SelectedTracksEmulationInputTag",
edm::InputTag("l1tTrackSelectionProducer", "Level1TTTracksSelectedEmulation"));
desc.add<edm::InputTag>("l1VerticesInputTag", edm::InputTag("l1tVertexFinder", "l1tVertices"));
desc.add<edm::InputTag>("l1VerticesEmulationInputTag",
edm::InputTag("l1tVertexFinderEmulator", "l1tVerticesEmulation"));
desc.add<std::string>("outputCollectionName", "Level1TTTracksSelectedAssociated");
{
edm::ParameterSetDescription descCutSet;
Expand Down
20 changes: 12 additions & 8 deletions L1Trigger/VertexFinder/src/VertexFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,10 @@ namespace l1tVertexFinder {
kWeightedSlidingSumMagSize = 10, // Width of the pT weighted sliding sum magnitude (signed)
kWindowSize = 3, // Number of bins in the window used to sum histogram bins
kSumPtLinkSize = 9, // Number of bits used to represent the sum of track pts in a single bin from a single link

kSumPtWindowBits = BitsToRepresent(HistogramBitWidths::kWindowSize * (1 << HistogramBitWidths::kSumPtLinkSize)),
// Number of bits to represent the untruncated sum of track pts in a single bin from a single link
kSumPtUntruncatedLinkSize = TrackBitWidths::kPtSize + 2,
kSumPtUntruncatedLinkSize = TrackBitWidths::kPtSize + 2,
kSumPtUntruncatedLinkMagSize = TrackBitWidths::kPtMagSize + 2,
};

Expand All @@ -804,8 +804,11 @@ namespace l1tVertexFinder {
histbin_fixed_t;
// This type is slightly arbitrary, but 2 bits larger than untruncated track pt to store sums in histogram bins
// with truncation just before vertex-finding
typedef ap_ufixed<HistogramBitWidths::kSumPtUntruncatedLinkSize, HistogramBitWidths::kSumPtUntruncatedLinkMagSize, AP_RND_INF, AP_SAT>
histbin_pt_sum_fixed_t;
typedef ap_ufixed<HistogramBitWidths::kSumPtUntruncatedLinkSize,
HistogramBitWidths::kSumPtUntruncatedLinkMagSize,
AP_RND_INF,
AP_SAT>
histbin_pt_sum_fixed_t;
// This value is slightly arbitrary, but small enough that the windows sums aren't too big.
typedef ap_ufixed<HistogramBitWidths::kSumPtLinkSize, HistogramBitWidths::kSumPtLinkSize, AP_RND_INF, AP_SAT>
link_pt_sum_fixed_t;
Expand Down Expand Up @@ -1020,15 +1023,16 @@ namespace l1tVertexFinder {
// track_pt_fixed_t pt_tmp = tkpt;
// Now, truncation should happen after histograms are filled but prior to the vertex-finding part of the algo
for (unsigned int hb = 0; hb < hist.size(); ++hb) {
link_pt_sum_fixed_t bin_trunc = hist_untruncated.at(hb).range(HistogramBitWidths::kSumPtUntruncatedLinkSize - 1,
HistogramBitWidths::kSumPtUntruncatedLinkSize - HistogramBitWidths::kSumPtUntruncatedLinkMagSize);
link_pt_sum_fixed_t bin_trunc = hist_untruncated.at(hb).range(
HistogramBitWidths::kSumPtUntruncatedLinkSize - 1,
HistogramBitWidths::kSumPtUntruncatedLinkSize - HistogramBitWidths::kSumPtUntruncatedLinkMagSize);
hist.at(hb) = bin_trunc;
if (settings_->debug() > 2) {
edm::LogInfo("VertexProducer") << "fastHistoEmulation::truncating histogram bin pt once filling is complete \n"
<< "hist_untruncated.at(" << hb << ") = " << hist_untruncated.at(hb).to_double()
<< "(" << hist_untruncated.at(hb).to_string(2)
<< ")\tbin_trunc = " << bin_trunc.to_double() << "(" << bin_trunc.to_string(2)
<< ")\n\thist.at(" << hb << ") = " << hist.at(hb).to_double() << "("
<< ")\tbin_trunc = " << bin_trunc.to_double() << "(" << bin_trunc.to_string(2)
<< ")\n\thist.at(" << hb << ") = " << hist.at(hb).to_double() << "("
<< hist.at(hb).to_string(2) << ")";
}
}
Expand Down

0 comments on commit b17fb0e

Please sign in to comment.