From 3b1ab1f61db93c54a25751c6fa2f1fefd91da795 Mon Sep 17 00:00:00 2001 From: Thomas Schuh Date: Thu, 9 Dec 2021 15:39:57 +0000 Subject: [PATCH] fixing merge errors. --- .../interface/ChannelAssignment.h | 6 - .../src/ChannelAssignment.cc | 147 +++++++++++++----- 2 files changed, 109 insertions(+), 44 deletions(-) diff --git a/L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h b/L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h index d17ccee03021a..244beaaa7d28a 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h +++ b/L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h @@ -6,7 +6,6 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/L1TrackTrigger/interface/TTTypes.h" #include "L1Trigger/TrackTrigger/interface/Setup.h" -#include "DataFormats/L1TrackTrigger/interface/TTTypes.h" #include @@ -35,13 +34,8 @@ namespace trklet { int maxNumProjectionLayers() const { return maxNumProjectionLayers_; } // map of used DTC tfp channels in InputRouter std::vector channelEncoding() const { return channelEncoding_; } - // helper class to store configurations - const tt::Setup* setup() const { return setup_; } private: - // checks is seedType is supported - void checkSeedType(int seedType) const; - // helper class to store configurations const tt::Setup* setup_; // use tracklet seed type as channel id if False, binned track pt used if True diff --git a/L1Trigger/TrackFindingTracklet/src/ChannelAssignment.cc b/L1Trigger/TrackFindingTracklet/src/ChannelAssignment.cc index 27a59332adb9f..616f33e1b7f61 100644 --- a/L1Trigger/TrackFindingTracklet/src/ChannelAssignment.cc +++ b/L1Trigger/TrackFindingTracklet/src/ChannelAssignment.cc @@ -1,6 +1,10 @@ #include "L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h" +#include "L1Trigger/TrackFindingTracklet/interface/Settings.h" #include +#include +#include +#include using namespace std; using namespace edm; @@ -12,51 +16,131 @@ namespace trklet { : setup_(setup), useDuplicateRemoval_(iConfig.getParameter("UseDuplicateRemoval")), boundaries_(iConfig.getParameter>("PtBoundaries")), - seedTypeNames_(iConfig.getParameter>("SeedTypes")), + seedTypeNames_(iConfig.getParameter>("SeedTypesReduced")), numSeedTypes_(seedTypeNames_.size()), numChannels_(useDuplicateRemoval_ ? 2 * boundaries_.size() : numSeedTypes_), maxNumProjectionLayers_(iConfig.getParameter("MaxNumProjectionLayers")), channelEncoding_(iConfig.getParameter>("IRChannelsIn")) { - const ParameterSet& pSetSeedTypesSeedLayers = iConfig.getParameter("SeedTypesSeedLayers"); - const ParameterSet& pSetSeedTypesProjectionLayers = iConfig.getParameter("SeedTypesProjectionLayers"); + const ParameterSet& pSetSeedTypesSeedLayers = iConfig.getParameter("SeedTypesSeedLayersReduced"); + const ParameterSet& pSetSeedTypesProjectionLayers = + iConfig.getParameter("SeedTypesProjectionLayersReduced"); seedTypesSeedLayers_.reserve(numSeedTypes_); seedTypesProjectionLayers_.reserve(numSeedTypes_); for (const string& s : seedTypeNames_) { seedTypesSeedLayers_.emplace_back(pSetSeedTypesSeedLayers.getParameter>(s)); seedTypesProjectionLayers_.emplace_back(pSetSeedTypesProjectionLayers.getParameter>(s)); } + // consistency check + static constexpr int offsetBarrel = 1; + static constexpr int numBarrelLayer = 6; + static constexpr int offsetDisk = 11; + static constexpr int invalidSeedLayer = -1; + static constexpr int invalidLayerDisk = 0; + const Settings settings; + const auto& seedlayers = settings.seedlayers(); + const auto& projlayers = settings.projlayers(); + const auto& projdisks = settings.projdisks(); + // convert Seetings layer ids into ChannelAssignment layer ids + vector> allSeedingLayer(seedlayers.size()); + vector> allProjectionLayer(seedlayers.size()); + for (int iSeed = 0; iSeed < (int)seedlayers.size(); iSeed++) + for (const auto& layer: seedlayers[iSeed]) + if (layer != invalidSeedLayer) + allSeedingLayer[iSeed].insert(layer < numBarrelLayer ? layer + offsetBarrel : layer + offsetDisk - numBarrelLayer); + for (int iSeed = 0; iSeed < (int)projlayers.size(); iSeed++) + for (const auto& layer: projlayers[iSeed]) + if (layer != invalidLayerDisk) + allProjectionLayer[iSeed].insert(layer); + for (int iSeed = 0; iSeed < (int)projdisks.size(); iSeed++) + for (const auto& disk: projdisks[iSeed]) + if (disk != invalidLayerDisk) + allProjectionLayer[iSeed].insert(disk - offsetBarrel + offsetDisk); + // check if ChannelAssignment seedTypesSeedLayers_ and seedTypesProjectionLayers_ are subsets of Settings pendants + for (int iSubSeed = 0; iSubSeed < numSeedTypes_; iSubSeed++) { + const vector& seedLayers = seedTypesSeedLayers_[iSubSeed]; + bool subset(false); + for (int iAllSeed = 0; iAllSeed < (int)seedlayers.size(); iAllSeed++) { + // compare seed layer + const set& asl = allSeedingLayer[iAllSeed]; + set sl(seedLayers.begin(), seedLayers.end()); + set intersect; + set_intersection(sl.begin(), sl.end(), asl.begin(), asl.end(), inserter(intersect, intersect.begin())); + if (intersect == sl) { + subset = true; + // compare projection layer + const vector& projectionLayers = seedTypesProjectionLayers_[iSubSeed]; + const set& apl = allProjectionLayer[iAllSeed]; + set pl(projectionLayers.begin(), projectionLayers.end()); + set intersect; + set_intersection(pl.begin(), pl.end(), apl.begin(), apl.end(), inserter(intersect, intersect.begin())); + if (intersect == pl) + break; + set difference; + set_difference(pl.begin(), pl.end(), intersect.begin(), intersect.end(), inserter(difference, difference.begin())); + cms::Exception exception("LogicError."); + exception << "ProjectionLayers ( "; + for (int layer : difference) + exception << layer << " "; + exception << ") are not supported with seed type ( "; + for (int layer : seedLayers) + exception << layer << " "; + exception << ")"; + exception.addContext("trklet::ChannelAssignment::ChannelAssignment"); + throw exception; + } + } + if (subset) + continue; + cms::Exception exception("LogicError."); + exception << "SeedLayers ( "; + for (int layer : seedLayers) + exception << layer << " "; + exception << ") are not supported"; + exception.addContext("trklet::ChannelAssignment::ChannelAssignment"); + throw exception; + } } // sets channelId of given TTTrackRef, return false if track outside pt range - bool ChannelAssignment::channelId(const TTTrackRef& ttTrackRef, int& channelId) const { - const int phiSector = ttTrackRef->phiSector(); - bool valid(true); - channelId = -1; + bool ChannelAssignment::channelId(const TTTrackRef& ttTrackRef, int& channelId) { if (!useDuplicateRemoval_) { const int seedType = ttTrackRef->trackSeedType(); - checkSeedType(seedType); - channelId = seedType; - } else { - const double rInv = ttTrackRef->rInv(); - const double pt = 2. * setup_->invPtToDphi() / abs(rInv); - for (double boundary : boundaries_) { - if (pt < boundary) - break; - else - channelId++; + if (seedType >= numSeedTypes_) { + cms::Exception exception("logic_error"); + exception << "TTTracks form seed type" << seedType << " not in supported list: ("; + for (const auto& s : seedTypeNames_) + exception << s << " "; + exception << ")."; + exception.addContext("trklet:ChannelAssignment:channelId"); + throw exception; } - if (channelId == -1) - valid = false; - channelId = rInv < 0. ? channelId : numChannels_ - channelId - 1; + channelId = ttTrackRef->phiSector() * numSeedTypes_ + seedType; + return true; + } + const double pt = ttTrackRef->momentum().perp(); + channelId = -1; + for (double boundary : boundaries_) { + if (pt < boundary) + break; + else + channelId++; } - channelId += phiSector * numChannels_; - return valid; + if (channelId == -1) + return false; + channelId = ttTrackRef->rInv() < 0. ? channelId : numChannels_ - channelId - 1; + channelId += ttTrackRef->phiSector() * numChannels_; + return true; } // sets layerId of given TTStubRef and seedType, returns false if seeed stub - bool ChannelAssignment::layerId(int seedType, const TTStubRef& ttStubRef, int& layerId) const { + bool ChannelAssignment::layerId(int seedType, const TTStubRef& ttStubRef, int& layerId) { layerId = -1; - checkSeedType(seedType); + if (seedType < 0 || seedType >= numSeedTypes_) { + cms::Exception exception("logic_error"); + exception.addContext("trklet::ChannelAssignment::layerId"); + exception << "TTTracks with with seed type " << seedType << " not supported."; + throw exception; + } const int layer = setup_->layerId(ttStubRef); const vector& seedingLayers = seedTypesSeedLayers_[seedType]; if (find(seedingLayers.begin(), seedingLayers.end(), layer) != seedingLayers.end()) @@ -66,7 +150,7 @@ namespace trklet { if (pos == projectingLayers.end()) { const string& name = seedTypeNames_[seedType]; cms::Exception exception("logic_error"); - exception.addContext("ChannelAssignment::ChannelAssignment::layerId"); + exception.addContext("trklet::ChannelAssignment::layerId"); exception << "TTStub from layer " << layer << " (barrel: 1-6; discs: 11-15) from seed type " << name << " not supported."; throw exception; @@ -82,17 +166,4 @@ namespace trklet { return setup_->layerId(ttStubRef) - (setup_->barrel(ttStubRef) ? offsetBarrel : offsetDisks); } - // checks is seedType is supported - void ChannelAssignment::checkSeedType(int seedType) const { - if (seedType >= 0 && seedType < numSeedTypes_) - return; - cms::Exception exception("logic_error"); - exception << "TTTracks form seed type" << seedType << " not in supported list: ("; - for (const auto& s : seedTypeNames_) - exception << s << " "; - exception << ")."; - exception.addContext("ChannelAssignment:checkSeedType:channelId"); - throw exception; - } - } // namespace trklet \ No newline at end of file