Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:55:45

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1Trigger/L1TTrackMatch
0004 // Class:      L1TrackSelectionProducer
0005 //
0006 /**\class L1TrackSelectionProducer L1TrackSelectionProducer.cc L1Trigger/L1TTrackMatch/plugins/L1TrackSelectionProducer.cc
0007 
0008  Description: Selects a set of L1Tracks based on a set of predefined criteria.
0009 
0010  Implementation:
0011      Inputs:
0012          std::vector<TTTrack> - Each floating point TTTrack inside this collection inherits from
0013                                 a bit-accurate TTTrack_TrackWord, used for emulation purposes.
0014      Outputs:
0015          std::vector<TTTrack> - A collection of TTTracks selected from cuts on the TTTrack properties
0016          std::vector<TTTrack> - A collection of TTTracks selected from cuts on the TTTrack_TrackWord properties
0017 */
0018 //
0019 // Original Author:  Alexx Perloff
0020 //         Created:  Thu, 16 Dec 2021 19:02:50 GMT
0021 //
0022 //
0023 
0024 // system include files
0025 #include <algorithm>
0026 #include <memory>
0027 #include <string>
0028 #include <vector>
0029 
0030 // Xilinx HLS includes
0031 #include <ap_fixed.h>
0032 #include <ap_int.h>
0033 
0034 // user include files
0035 #include "DataFormats/Common/interface/Handle.h"
0036 #include "DataFormats/Common/interface/Ref.h"
0037 #include "DataFormats/Common/interface/RefVector.h"
0038 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0039 #include "DataFormats/L1Trigger/interface/Vertex.h"
0040 #include "DataFormats/L1Trigger/interface/VertexWord.h"
0041 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0042 #include "CommonTools/Utils/interface/AndSelector.h"
0043 #include "CommonTools/Utils/interface/EtaRangeSelector.h"
0044 #include "CommonTools/Utils/interface/MinSelector.h"
0045 #include "CommonTools/Utils/interface/MinFunctionSelector.h"
0046 #include "CommonTools/Utils/interface/MinNumberSelector.h"
0047 #include "CommonTools/Utils/interface/PtMinSelector.h"
0048 #include "CommonTools/Utils/interface/Selection.h"
0049 #include "FWCore/Framework/interface/Frameworkfwd.h"
0050 #include "FWCore/Framework/interface/global/EDProducer.h"
0051 #include "FWCore/Framework/interface/Event.h"
0052 #include "FWCore/Framework/interface/MakerMacros.h"
0053 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0054 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0055 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0056 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0057 #include "FWCore/Utilities/interface/EDMException.h"
0058 #include "FWCore/Utilities/interface/StreamID.h"
0059 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0060 
0061 //
0062 // class declaration
0063 //
0064 
0065 class L1TrackSelectionProducer : public edm::global::EDProducer<> {
0066 public:
0067   explicit L1TrackSelectionProducer(const edm::ParameterSet&);
0068   ~L1TrackSelectionProducer() override;
0069 
0070   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0071 
0072 private:
0073   // ----------constants, enums and typedefs ---------
0074   // Relevant constants for the converted track word
0075   enum TrackBitWidths {
0076     kPtSize = TTTrack_TrackWord::TrackBitWidths::kRinvSize - 1,  // Width of pt
0077     kPtMagSize = 9,                                              // Width of pt magnitude (unsigned)
0078     kEtaSize = TTTrack_TrackWord::TrackBitWidths::kTanlSize,     // Width of eta
0079     kEtaMagSize = 3,                                             // Width of eta magnitude (signed)
0080   };
0081 
0082   typedef TTTrack<Ref_Phase2TrackerDigi_> L1Track;
0083   typedef std::vector<L1Track> TTTrackCollection;
0084   typedef edm::Handle<TTTrackCollection> TTTrackCollectionHandle;
0085   typedef edm::Ref<TTTrackCollection> TTTrackRef;
0086   typedef edm::RefVector<TTTrackCollection> TTTrackRefCollection;
0087   typedef std::unique_ptr<TTTrackRefCollection> TTTrackRefCollectionUPtr;
0088 
0089   // ----------member functions ----------------------
0090   void printDebugInfo(const TTTrackCollectionHandle& l1TracksHandle,
0091                       const TTTrackRefCollectionUPtr& vTTTrackOutput,
0092                       const TTTrackRefCollectionUPtr& vTTTrackEmulationOutput) const;
0093   void printTrackInfo(edm::LogInfo& log, const L1Track& track, bool printEmulation = false) const;
0094   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0095 
0096   // ----------selectors -----------------------------
0097   // Based on recommendations from https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideGenericSelectors
0098   struct TTTrackPtMinSelector {
0099     TTTrackPtMinSelector(double ptMin) : ptMin_(ptMin) {}
0100     TTTrackPtMinSelector(const edm::ParameterSet& cfg) : ptMin_(cfg.template getParameter<double>("ptMin")) {}
0101     bool operator()(const L1Track& t) const { return t.momentum().perp() >= ptMin_; }
0102 
0103   private:
0104     double ptMin_;
0105   };
0106   struct TTTrackWordPtMinSelector {
0107     TTTrackWordPtMinSelector(double ptMin) : ptMin_(ptMin) {}
0108     TTTrackWordPtMinSelector(const edm::ParameterSet& cfg) : ptMin_(cfg.template getParameter<double>("ptMin")) {}
0109     bool operator()(const L1Track& t) const {
0110       ap_uint<TrackBitWidths::kPtSize> ptEmulationBits = t.getTrackWord()(
0111           TTTrack_TrackWord::TrackBitLocations::kRinvMSB - 1, TTTrack_TrackWord::TrackBitLocations::kRinvLSB);
0112       ap_ufixed<TrackBitWidths::kPtSize, TrackBitWidths::kPtMagSize> ptEmulation;
0113       ptEmulation.V = ptEmulationBits.range();
0114       return ptEmulation.to_double() >= ptMin_;
0115     }
0116 
0117   private:
0118     double ptMin_;
0119   };
0120   struct TTTrackAbsEtaMaxSelector {
0121     TTTrackAbsEtaMaxSelector(double absEtaMax) : absEtaMax_(absEtaMax) {}
0122     TTTrackAbsEtaMaxSelector(const edm::ParameterSet& cfg)
0123         : absEtaMax_(cfg.template getParameter<double>("absEtaMax")) {}
0124     bool operator()(const L1Track& t) const { return std::abs(t.momentum().eta()) <= absEtaMax_; }
0125 
0126   private:
0127     double absEtaMax_;
0128   };
0129   struct TTTrackWordAbsEtaMaxSelector {
0130     TTTrackWordAbsEtaMaxSelector(double absEtaMax) : absEtaMax_(absEtaMax) {}
0131     TTTrackWordAbsEtaMaxSelector(const edm::ParameterSet& cfg)
0132         : absEtaMax_(cfg.template getParameter<double>("absEtaMax")) {}
0133     bool operator()(const L1Track& t) const {
0134       TTTrack_TrackWord::tanl_t etaEmulationBits = t.getTanlWord();
0135       ap_fixed<TrackBitWidths::kEtaSize, TrackBitWidths::kEtaMagSize> etaEmulation;
0136       etaEmulation.V = etaEmulationBits.range();
0137       return std::abs(etaEmulation.to_double()) <= absEtaMax_;
0138     }
0139 
0140   private:
0141     double absEtaMax_;
0142   };
0143   struct TTTrackAbsZ0MaxSelector {
0144     TTTrackAbsZ0MaxSelector(double absZ0Max) : absZ0Max_(absZ0Max) {}
0145     TTTrackAbsZ0MaxSelector(const edm::ParameterSet& cfg) : absZ0Max_(cfg.template getParameter<double>("absZ0Max")) {}
0146     bool operator()(const L1Track& t) const { return std::abs(t.z0()) <= absZ0Max_; }
0147 
0148   private:
0149     double absZ0Max_;
0150   };
0151   struct TTTrackWordAbsZ0MaxSelector {
0152     TTTrackWordAbsZ0MaxSelector(double absZ0Max) : absZ0Max_(absZ0Max) {}
0153     TTTrackWordAbsZ0MaxSelector(const edm::ParameterSet& cfg)
0154         : absZ0Max_(cfg.template getParameter<double>("absZ0Max")) {}
0155     bool operator()(const L1Track& t) const {
0156       double floatZ0 = t.undigitizeSignedValue(
0157           t.getZ0Bits(), TTTrack_TrackWord::TrackBitWidths::kZ0Size, TTTrack_TrackWord::stepZ0, 0.0);
0158       return std::abs(floatZ0) <= absZ0Max_;
0159     }
0160 
0161   private:
0162     double absZ0Max_;
0163   };
0164   struct TTTrackNStubsMinSelector {
0165     TTTrackNStubsMinSelector(double nStubsMin) : nStubsMin_(nStubsMin) {}
0166     TTTrackNStubsMinSelector(const edm::ParameterSet& cfg)
0167         : nStubsMin_(cfg.template getParameter<double>("nStubsMin")) {}
0168     bool operator()(const L1Track& t) const { return t.getStubRefs().size() >= nStubsMin_; }
0169 
0170   private:
0171     double nStubsMin_;
0172   };
0173   struct TTTrackWordNStubsMinSelector {
0174     TTTrackWordNStubsMinSelector(double nStubsMin) : nStubsMin_(nStubsMin) {}
0175     TTTrackWordNStubsMinSelector(const edm::ParameterSet& cfg)
0176         : nStubsMin_(cfg.template getParameter<double>("nStubsMin")) {}
0177     bool operator()(const L1Track& t) const { return t.getNStubs() >= nStubsMin_; }
0178 
0179   private:
0180     double nStubsMin_;
0181   };
0182   struct TTTrackNPSStubsMinSelector {
0183     TTTrackNPSStubsMinSelector(double nStubsMin, const TrackerTopology& tTopo)
0184         : nPSStubsMin_(nStubsMin), tTopo_(tTopo) {}
0185     TTTrackNPSStubsMinSelector(const edm::ParameterSet& cfg, const TrackerTopology& tTopo)
0186         : nPSStubsMin_(cfg.template getParameter<double>("nPSStubsMin")), tTopo_(tTopo) {}
0187     bool operator()(const L1Track& t) const {
0188       int nPSStubs = 0;
0189       for (const auto& stub : t.getStubRefs()) {
0190         DetId detId(stub->getDetId());
0191         if (detId.det() == DetId::Detector::Tracker) {
0192           if ((detId.subdetId() == StripSubdetector::TOB && tTopo_.tobLayer(detId) <= 3) ||
0193               (detId.subdetId() == StripSubdetector::TID && tTopo_.tidRing(detId) <= 9))
0194             nPSStubs++;
0195         }
0196       }
0197       return nPSStubs >= nPSStubsMin_;
0198     }
0199 
0200   private:
0201     double nPSStubsMin_;
0202     const TrackerTopology& tTopo_;
0203   };
0204   struct TTTrackBendChi2MaxSelector {
0205     TTTrackBendChi2MaxSelector(double bendChi2Max) : bendChi2Max_(bendChi2Max) {}
0206     TTTrackBendChi2MaxSelector(const edm::ParameterSet& cfg)
0207         : bendChi2Max_(cfg.template getParameter<double>("reducedBendChi2Max")) {}
0208     bool operator()(const L1Track& t) const { return t.stubPtConsistency() < bendChi2Max_; }
0209 
0210   private:
0211     double bendChi2Max_;
0212   };
0213   struct TTTrackWordBendChi2MaxSelector {
0214     TTTrackWordBendChi2MaxSelector(double bendChi2Max) : bendChi2Max_(bendChi2Max) {}
0215     TTTrackWordBendChi2MaxSelector(const edm::ParameterSet& cfg)
0216         : bendChi2Max_(cfg.template getParameter<double>("reducedBendChi2Max")) {}
0217     bool operator()(const L1Track& t) const { return t.getBendChi2() < bendChi2Max_; }
0218 
0219   private:
0220     double bendChi2Max_;
0221   };
0222   struct TTTrackChi2RZMaxSelector {
0223     TTTrackChi2RZMaxSelector(double reducedChi2RZMax) : reducedChi2RZMax_(reducedChi2RZMax) {}
0224     TTTrackChi2RZMaxSelector(const edm::ParameterSet& cfg)
0225         : reducedChi2RZMax_(cfg.template getParameter<double>("reducedChi2RZMax")) {}
0226     bool operator()(const L1Track& t) const { return t.chi2ZRed() < reducedChi2RZMax_; }
0227 
0228   private:
0229     double reducedChi2RZMax_;
0230   };
0231   struct TTTrackWordChi2RZMaxSelector {
0232     TTTrackWordChi2RZMaxSelector(double reducedChi2RZMax) : reducedChi2RZMax_(reducedChi2RZMax) {}
0233     TTTrackWordChi2RZMaxSelector(const edm::ParameterSet& cfg)
0234         : reducedChi2RZMax_(cfg.template getParameter<double>("reducedChi2RZMax")) {}
0235     bool operator()(const L1Track& t) const { return t.getChi2RZ() < reducedChi2RZMax_; }
0236 
0237   private:
0238     double reducedChi2RZMax_;
0239   };
0240   struct TTTrackChi2RPhiMaxSelector {
0241     TTTrackChi2RPhiMaxSelector(double reducedChi2RPhiMax) : reducedChi2RPhiMax_(reducedChi2RPhiMax) {}
0242     TTTrackChi2RPhiMaxSelector(const edm::ParameterSet& cfg)
0243         : reducedChi2RPhiMax_(cfg.template getParameter<double>("reducedChi2RPhiMax")) {}
0244     bool operator()(const L1Track& t) const { return t.chi2XYRed() < reducedChi2RPhiMax_; }
0245 
0246   private:
0247     double reducedChi2RPhiMax_;
0248   };
0249   struct TTTrackWordChi2RPhiMaxSelector {
0250     TTTrackWordChi2RPhiMaxSelector(double reducedChi2RPhiMax) : reducedChi2RPhiMax_(reducedChi2RPhiMax) {}
0251     TTTrackWordChi2RPhiMaxSelector(const edm::ParameterSet& cfg)
0252         : reducedChi2RPhiMax_(cfg.template getParameter<double>("reducedChi2RPhiMax")) {}
0253     bool operator()(const L1Track& t) const { return t.getChi2RPhi() < reducedChi2RPhiMax_; }
0254 
0255   private:
0256     double reducedChi2RPhiMax_;
0257   };
0258 
0259   typedef AndSelector<TTTrackPtMinSelector, TTTrackAbsEtaMaxSelector, TTTrackAbsZ0MaxSelector, TTTrackNStubsMinSelector>
0260       TTTrackPtMinEtaMaxZ0MaxNStubsMinSelector;
0261   typedef AndSelector<TTTrackWordPtMinSelector,
0262                       TTTrackWordAbsEtaMaxSelector,
0263                       TTTrackWordAbsZ0MaxSelector,
0264                       TTTrackWordNStubsMinSelector>
0265       TTTrackWordPtMinEtaMaxZ0MaxNStubsMinSelector;
0266   typedef AndSelector<TTTrackBendChi2MaxSelector, TTTrackChi2RZMaxSelector, TTTrackChi2RPhiMaxSelector>
0267       TTTrackBendChi2Chi2RZChi2RPhiMaxSelector;
0268   typedef AndSelector<TTTrackWordBendChi2MaxSelector, TTTrackWordChi2RZMaxSelector, TTTrackWordChi2RPhiMaxSelector>
0269       TTTrackWordBendChi2Chi2RZChi2RPhiMaxSelector;
0270 
0271   // ----------member data ---------------------------
0272   const edm::EDGetTokenT<TTTrackCollection> l1TracksToken_;
0273   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0274   const std::string outputCollectionName_;
0275   const edm::ParameterSet cutSet_;
0276   const double ptMin_, absEtaMax_, absZ0Max_, bendChi2Max_, reducedChi2RZMax_, reducedChi2RPhiMax_;
0277   const int nStubsMin_, nPSStubsMin_;
0278   bool processSimulatedTracks_, processEmulatedTracks_;
0279   int debug_;
0280 };
0281 
0282 //
0283 // constructors and destructor
0284 //
0285 L1TrackSelectionProducer::L1TrackSelectionProducer(const edm::ParameterSet& iConfig)
0286     : l1TracksToken_(consumes<TTTrackCollection>(iConfig.getParameter<edm::InputTag>("l1TracksInputTag"))),
0287       tTopoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd>(edm::ESInputTag("", ""))),
0288       outputCollectionName_(iConfig.getParameter<std::string>("outputCollectionName")),
0289       cutSet_(iConfig.getParameter<edm::ParameterSet>("cutSet")),
0290 
0291       ptMin_(cutSet_.getParameter<double>("ptMin")),
0292       absEtaMax_(cutSet_.getParameter<double>("absEtaMax")),
0293       absZ0Max_(cutSet_.getParameter<double>("absZ0Max")),
0294       bendChi2Max_(cutSet_.getParameter<double>("reducedBendChi2Max")),
0295       reducedChi2RZMax_(cutSet_.getParameter<double>("reducedChi2RZMax")),
0296       reducedChi2RPhiMax_(cutSet_.getParameter<double>("reducedChi2RPhiMax")),
0297       nStubsMin_(cutSet_.getParameter<int>("nStubsMin")),
0298       nPSStubsMin_(cutSet_.getParameter<int>("nPSStubsMin")),
0299       processSimulatedTracks_(iConfig.getParameter<bool>("processSimulatedTracks")),
0300       processEmulatedTracks_(iConfig.getParameter<bool>("processEmulatedTracks")),
0301       debug_(iConfig.getParameter<int>("debug")) {
0302   // Confirm the the configuration makes sense
0303   if (!processSimulatedTracks_ && !processEmulatedTracks_) {
0304     throw cms::Exception("You must process at least one of the track collections (simulated or emulated).");
0305   }
0306 
0307   if (processSimulatedTracks_) {
0308     produces<TTTrackRefCollection>(outputCollectionName_);
0309   }
0310   if (processEmulatedTracks_) {
0311     produces<TTTrackRefCollection>(outputCollectionName_ + "Emulation");
0312   }
0313 }
0314 
0315 L1TrackSelectionProducer::~L1TrackSelectionProducer() {}
0316 
0317 //
0318 // member functions
0319 //
0320 
0321 void L1TrackSelectionProducer::printDebugInfo(const TTTrackCollectionHandle& l1TracksHandle,
0322                                               const TTTrackRefCollectionUPtr& vTTTrackOutput,
0323                                               const TTTrackRefCollectionUPtr& vTTTrackEmulationOutput) const {
0324   edm::LogInfo log("L1TrackSelectionProducer");
0325   log << "The original track collection (pt, eta, phi, nstub, bendchi2, chi2rz, chi2rphi, z0) values are ... \n";
0326   for (const auto& track : *l1TracksHandle) {
0327     printTrackInfo(log, track, debug_ >= 4);
0328   }
0329   log << "\t---\n\tNumber of tracks in this selection = " << l1TracksHandle->size() << "\n\n";
0330   if (processSimulatedTracks_) {
0331     log << "The selected track collection (pt, eta, phi, nstub, bendchi2, chi2rz, chi2rphi, z0) values are ... \n";
0332     for (const auto& track : *vTTTrackOutput) {
0333       printTrackInfo(log, *track, debug_ >= 4);
0334     }
0335     log << "\t---\n\tNumber of tracks in this selection = " << vTTTrackOutput->size() << "\n\n";
0336   }
0337   if (processEmulatedTracks_) {
0338     log << "The emulation selected track collection (pt, eta, phi, nstub, bendchi2, chi2rz, chi2rphi, z0) values are "
0339            "... \n";
0340     for (const auto& track : *vTTTrackEmulationOutput) {
0341       printTrackInfo(log, *track, debug_ >= 4);
0342     }
0343     log << "\t---\n\tNumber of tracks in this selection = " << vTTTrackEmulationOutput->size() << "\n\n";
0344   }
0345   if (processSimulatedTracks_ && processEmulatedTracks_) {
0346     TTTrackRefCollection inSimButNotEmu;
0347     TTTrackRefCollection inEmuButNotSim;
0348     std::set_difference(vTTTrackOutput->begin(),
0349                         vTTTrackOutput->end(),
0350                         vTTTrackEmulationOutput->begin(),
0351                         vTTTrackEmulationOutput->end(),
0352                         std::back_inserter(inSimButNotEmu));
0353     std::set_difference(vTTTrackEmulationOutput->begin(),
0354                         vTTTrackEmulationOutput->end(),
0355                         vTTTrackOutput->begin(),
0356                         vTTTrackOutput->end(),
0357                         std::back_inserter(inEmuButNotSim));
0358     log << "The set of tracks selected via cuts on the simulated values which are not in the set of tracks selected "
0359            "by cutting on the emulated values ... \n";
0360     for (const auto& track : inSimButNotEmu) {
0361       printTrackInfo(log, *track, debug_ >= 3);
0362     }
0363     log << "\t---\n\tNumber of tracks in this selection = " << inSimButNotEmu.size() << "\n\n"
0364         << "The set of tracks selected via cuts on the emulated values which are not in the set of tracks selected "
0365            "by cutting on the simulated values ... \n";
0366     for (const auto& track : inEmuButNotSim) {
0367       printTrackInfo(log, *track, debug_ >= 3);
0368     }
0369     log << "\t---\n\tNumber of tracks in this selection = " << inEmuButNotSim.size() << "\n\n";
0370   }
0371 }
0372 
0373 void L1TrackSelectionProducer::printTrackInfo(edm::LogInfo& log, const L1Track& track, bool printEmulation) const {
0374   log << "\t(" << track.momentum().perp() << ", " << track.momentum().eta() << ", " << track.momentum().phi() << ", "
0375       << track.getStubRefs().size() << ", " << track.stubPtConsistency() << ", " << track.chi2ZRed() << ", "
0376       << track.chi2XYRed() << ", " << track.z0() << ")\n";
0377 
0378   if (printEmulation) {
0379     ap_uint<TrackBitWidths::kPtSize> ptEmulationBits = track.getTrackWord()(
0380         TTTrack_TrackWord::TrackBitLocations::kRinvMSB - 1, TTTrack_TrackWord::TrackBitLocations::kRinvLSB);
0381     ap_ufixed<TrackBitWidths::kPtSize, TrackBitWidths::kPtMagSize> ptEmulation;
0382     ptEmulation.V = ptEmulationBits.range();
0383     TTTrack_TrackWord::tanl_t etaEmulationBits = track.getTanlWord();
0384     ap_fixed<TrackBitWidths::kEtaSize, TrackBitWidths::kEtaMagSize> etaEmulation;
0385     etaEmulation.V = etaEmulationBits.range();
0386     double floatTkZ0 = track.undigitizeSignedValue(
0387         track.getZ0Bits(), TTTrack_TrackWord::TrackBitWidths::kZ0Size, TTTrack_TrackWord::stepZ0, 0.0);
0388     double floatTkPhi = track.undigitizeSignedValue(
0389         track.getPhiBits(), TTTrack_TrackWord::TrackBitWidths::kPhiSize, TTTrack_TrackWord::stepPhi0, 0.0);
0390     log << "\t\t(" << ptEmulation.to_double() << ", " << etaEmulation.to_double() << ", " << floatTkPhi << ", "
0391         << track.getNStubs() << ", " << track.getBendChi2() << ", " << track.getChi2RZ() << ", " << track.getChi2RPhi()
0392         << ", " << floatTkZ0 << ")\n";
0393   }
0394 }
0395 
0396 // ------------ method called to produce the data  ------------
0397 void L1TrackSelectionProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0398   auto vTTTrackOutput = std::make_unique<TTTrackRefCollection>();
0399   auto vTTTrackEmulationOutput = std::make_unique<TTTrackRefCollection>();
0400 
0401   // Tracker Topology
0402   const TrackerTopology& tTopo = iSetup.getData(tTopoToken_);
0403 
0404   TTTrackCollectionHandle l1TracksHandle;
0405 
0406   iEvent.getByToken(l1TracksToken_, l1TracksHandle);
0407   size_t nOutputApproximate = l1TracksHandle->size();
0408   if (processSimulatedTracks_) {
0409     vTTTrackOutput->reserve(nOutputApproximate);
0410   }
0411   if (processEmulatedTracks_) {
0412     vTTTrackEmulationOutput->reserve(nOutputApproximate);
0413   }
0414 
0415   TTTrackPtMinEtaMaxZ0MaxNStubsMinSelector kinSel(ptMin_, absEtaMax_, absZ0Max_, nStubsMin_);
0416   TTTrackWordPtMinEtaMaxZ0MaxNStubsMinSelector kinSelEmu(ptMin_, absEtaMax_, absZ0Max_, nStubsMin_);
0417   TTTrackBendChi2Chi2RZChi2RPhiMaxSelector chi2Sel(bendChi2Max_, reducedChi2RZMax_, reducedChi2RPhiMax_);
0418   TTTrackWordBendChi2Chi2RZChi2RPhiMaxSelector chi2SelEmu(bendChi2Max_, reducedChi2RZMax_, reducedChi2RPhiMax_);
0419   TTTrackNPSStubsMinSelector nPSStubsSel(nPSStubsMin_, tTopo);
0420 
0421   for (size_t i = 0; i < nOutputApproximate; i++) {
0422     const auto& track = l1TracksHandle->at(i);
0423 
0424     // Select tracks based on the floating point TTTrack
0425     if (processSimulatedTracks_ && kinSel(track) && nPSStubsSel(track) && chi2Sel(track)) {
0426       vTTTrackOutput->push_back(TTTrackRef(l1TracksHandle, i));
0427     }
0428 
0429     // Select tracks based on the bitwise accurate TTTrack_TrackWord
0430     if (processEmulatedTracks_ && kinSelEmu(track) && chi2SelEmu(track)) {
0431       vTTTrackEmulationOutput->push_back(TTTrackRef(l1TracksHandle, i));
0432     }
0433   }
0434 
0435   if (debug_ >= 2) {
0436     printDebugInfo(l1TracksHandle, vTTTrackOutput, vTTTrackEmulationOutput);
0437   }
0438 
0439   // Put the outputs into the event
0440   if (processSimulatedTracks_) {
0441     iEvent.put(std::move(vTTTrackOutput), outputCollectionName_);
0442   }
0443   if (processEmulatedTracks_) {
0444     iEvent.put(std::move(vTTTrackEmulationOutput), outputCollectionName_ + "Emulation");
0445   }
0446 }
0447 
0448 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0449 void L1TrackSelectionProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0450   //L1TrackSelectionProducer
0451   edm::ParameterSetDescription desc;
0452   desc.add<edm::InputTag>("l1TracksInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
0453   desc.add<std::string>("outputCollectionName", "Level1TTTracksSelected");
0454   {
0455     edm::ParameterSetDescription descCutSet;
0456     descCutSet.add<double>("ptMin", 2.0)->setComment("pt must be greater than this value, [GeV]");
0457     descCutSet.add<double>("absEtaMax", 2.4)->setComment("absolute value of eta must be less than this value");
0458     descCutSet.add<double>("absZ0Max", 15.0)->setComment("z0 must be less than this value, [cm]");
0459     descCutSet.add<int>("nStubsMin", 4)->setComment("number of stubs must be greater than or equal to this value");
0460     descCutSet.add<int>("nPSStubsMin", 0)
0461         ->setComment("number of stubs in the PS Modules must be greater than or equal to this value");
0462 
0463     descCutSet.add<double>("reducedBendChi2Max", 2.25)->setComment("bend chi2 must be less than this value");
0464     descCutSet.add<double>("reducedChi2RZMax", 5.0)->setComment("chi2rz/dof must be less than this value");
0465     descCutSet.add<double>("reducedChi2RPhiMax", 20.0)->setComment("chi2rphi/dof must be less than this value");
0466 
0467     desc.add<edm::ParameterSetDescription>("cutSet", descCutSet);
0468   }
0469   desc.add<bool>("processSimulatedTracks", true)
0470       ->setComment("return selected tracks after cutting on the floating point values");
0471   desc.add<bool>("processEmulatedTracks", true)
0472       ->setComment("return selected tracks after cutting on the bitwise emulated values");
0473   desc.add<int>("debug", 0)->setComment("Verbosity levels: 0, 1, 2, 3");
0474   descriptions.addWithDefaultLabel(desc);
0475 }
0476 
0477 //define this as a plug-in
0478 DEFINE_FWK_MODULE(L1TrackSelectionProducer);