CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
tmtt::TMTrackProducer Class Reference

#include <TMTrackProducer.h>

Inheritance diagram for tmtt::TMTrackProducer:
edm::stream::EDProducer< edm::GlobalCache< GlobalCacheTMTT > >

Public Member Functions

 TMTrackProducer (const edm::ParameterSet &, GlobalCacheTMTT const *globalCacheTMTT)
 
 ~TMTrackProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< GlobalCacheTMTT > >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void globalEndJob (GlobalCacheTMTT *globalCacheTMTT)
 
static std::unique_ptr< GlobalCacheTMTTinitializeGlobalCache (edm::ParameterSet const &iConfig)
 

Private Types

typedef std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > TTTrackCollection
 

Private Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< TTClusterAssMapclusterTruthToken_
 
bool debug_
 
std::unique_ptr< DegradeBenddegradeBend_
 
std::map< std::string, std::unique_ptr< TrackFitGeneric > > fitterWorkerMap_
 
edm::EDGetTokenT< reco::GenJetCollectiongenJetToken_
 
Histoshists_
 
HTrphi::ErrorMonitorhtRphiErrMon_
 
std::list< TrackerModulelistTrackerModule_
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldToken_
 
bool runRZfilter_
 
Settings settings_
 
const StubAlgorithmOfficialstubAlgo_
 
std::unique_ptr< StubFEWindowsstubFEWindows_
 
edm::EDGetTokenT< TTStubDetSetVecstubToken_
 
edm::EDGetTokenT< TTStubAssMapstubTruthToken_
 
StubWindowSuggeststubWindowSuggest_
 
edm::EDGetTokenT< TrackingParticleCollectiontpToken_
 
const TrackerGeometrytrackerGeometry_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerGeometryToken_
 
const TrackerTopologytrackerTopology_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtrackerTopologyToken_
 
std::vector< std::string > trackFitters_
 
edm::ESGetToken< StubAlgorithm, TTStubAlgorithmRecordttStubAlgoToken_
 
std::vector< std::string > useRZfilter_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< GlobalCacheTMTT > >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 42 of file TMTrackProducer.h.

Member Typedef Documentation

◆ TTTrackCollection

Definition at line 52 of file TMTrackProducer.h.

Constructor & Destructor Documentation

◆ TMTrackProducer()

tmtt::TMTrackProducer::TMTrackProducer ( const edm::ParameterSet iConfig,
GlobalCacheTMTT const *  globalCacheTMTT 
)
explicit

Definition at line 37 of file TMTrackProducer.cc.

References tmtt::Settings::clusterTruthInputTag(), clusterTruthToken_, tmtt::trackFitFactory::create(), ZCounting_cfi::edmName, tmtt::Settings::enableMCtruth(), tmtt::Settings::enableOutputIntermediateTTTracks(), fitterWorkerMap_, tmtt::Settings::genJetInputTag(), genJetToken_, tmtt::Settings::magneticFieldInputTag(), magneticFieldToken_, runRZfilter_, settings_, AlCaHLTBitMon_QueryRunRegistry::string, tmtt::Settings::stubInputTag(), stubToken_, tmtt::Settings::stubTruthInputTag(), stubTruthToken_, tmtt::Settings::tpInputTag(), tpToken_, tmtt::Settings::trackerGeometryInputTag(), trackerGeometryToken_, tmtt::Settings::trackerTopologyInputTag(), trackerTopologyToken_, tmtt::Settings::trackFitters(), trackFitters_, tmtt::Settings::ttStubAlgoInputTag(), ttStubAlgoToken_, tmtt::Settings::useRZfilter(), and useRZfilter_.

38  : settings_(iConfig), // Set configuration parameters
39  stubWindowSuggest_(globalCacheTMTT->stubWindowSuggest()), // For tuning FE stub window sizes
40  hists_(globalCacheTMTT->hists()), // Initialize histograms
41  htRphiErrMon_(globalCacheTMTT->htRphiErrMon()), // rphi HT error monitoring
42  debug_(true) // Debug printout
43  {
44  using namespace edm;
45 
46  // Get tokens for ES data access.
48  esConsumes<MagneticField, IdealMagneticFieldRecord, Transition::BeginRun>(settings_.magneticFieldInputTag());
49  trackerGeometryToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, Transition::BeginRun>(
52  esConsumes<TrackerTopology, TrackerTopologyRcd, Transition::BeginRun>(settings_.trackerTopologyInputTag());
54  esConsumes<StubAlgorithm, TTStubAlgorithmRecord, Transition::BeginRun>(settings_.ttStubAlgoInputTag());
55 
56  // Get tokens for ED data access.
57  stubToken_ = consumes<TTStubDetSetVec>(settings_.stubInputTag());
58  if (settings_.enableMCtruth()) {
59  // These lines use lots of CPU, even if no use of truth info is made later.
60  tpToken_ = consumes<TrackingParticleCollection>(settings_.tpInputTag());
61  stubTruthToken_ = consumes<TTStubAssMap>(settings_.stubTruthInputTag());
62  clusterTruthToken_ = consumes<TTClusterAssMap>(settings_.clusterTruthInputTag());
63  genJetToken_ = consumes<reco::GenJetCollection>(settings_.genJetInputTag());
64  }
65 
68  runRZfilter_ = (not useRZfilter_.empty()); // Do any fitters require an r-z track filter to be run?
69 
70  // Book histograms.
71  //hists_.book();
72 
73  // Create track fitting algorithm
74  for (const string& fitterName : trackFitters_) {
75  fitterWorkerMap_[fitterName] = trackFitFactory::create(fitterName, &settings_);
76  }
77 
78  //--- Define EDM output to be written to file (if required)
79 
81  // L1 tracks found by Hough Transform
82  produces<TTTrackCollection>("TML1TracksHT").setBranchAlias("TML1TracksHT");
83  // L1 tracks found by r-z track filter.
84  if (runRZfilter_)
85  produces<TTTrackCollection>("TML1TracksRZ").setBranchAlias("TML1TracksRZ");
86  }
87  // L1 tracks after track fit by each of the fitting algorithms under study
88  for (const string& fitterName : trackFitters_) {
89  string edmName = string("TML1Tracks") + fitterName;
90  produces<TTTrackCollection>(edmName).setBranchAlias(edmName);
91  }
92  }
HTrphi::ErrorMonitor & htRphiErrMon_
const std::vector< std::string > & useRZfilter() const
Definition: Settings.h:251
std::map< std::string, std::unique_ptr< TrackFitGeneric > > fitterWorkerMap_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
edm::ESInputTag trackerGeometryInputTag() const
Definition: Settings.h:27
edm::EDGetTokenT< TTClusterAssMap > clusterTruthToken_
edm::EDGetTokenT< TTStubAssMap > stubTruthToken_
std::vector< std::string > trackFitters_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
edm::InputTag tpInputTag() const
Definition: Settings.h:32
std::unique_ptr< TrackFitGeneric > create(const std::string &fitterName, const Settings *settings)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
edm::ESInputTag ttStubAlgoInputTag() const
Definition: Settings.h:29
edm::InputTag genJetInputTag() const
Definition: Settings.h:35
edm::ESGetToken< StubAlgorithm, TTStubAlgorithmRecord > ttStubAlgoToken_
edm::ESInputTag magneticFieldInputTag() const
Definition: Settings.h:26
bool enableOutputIntermediateTTTracks() const
Definition: Settings.h:44
edm::InputTag clusterTruthInputTag() const
Definition: Settings.h:34
edm::InputTag stubTruthInputTag() const
Definition: Settings.h:33
HLT enums.
bool enableMCtruth() const
Definition: Settings.h:40
StubWindowSuggest & stubWindowSuggest_
const std::vector< std::string > & trackFitters() const
Definition: Settings.h:248
edm::EDGetTokenT< TTStubDetSetVec > stubToken_
edm::InputTag stubInputTag() const
Definition: Settings.h:31
edm::EDGetTokenT< reco::GenJetCollection > genJetToken_
std::vector< std::string > useRZfilter_
edm::ESInputTag trackerTopologyInputTag() const
Definition: Settings.h:28

◆ ~TMTrackProducer()

tmtt::TMTrackProducer::~TMTrackProducer ( )
inlineoverride

Definition at line 45 of file TMTrackProducer.h.

45 {}

Member Function Documentation

◆ beginRun()

void tmtt::TMTrackProducer::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 96 of file TMTrackProducer.cc.

References tmtt::TrackerModule::ModuleTypeCfg::barrelVsType, tmtt::Settings::barrelVsType(), Calorimetry_cff::bField, degradeBend_, edm::ESHandleBase::description(), hcalRecHitTable_cff::detId, TrackerGeometry::dets(), edm::EventSetup::getData(), edm::EventSetup::getHandle(), edm::getParameterSet(), MagneticField::inTesla(), TrackerTopology::isLower(), listTrackerModule_, magneticFieldToken_, edm::eventsetup::ComponentDescription::pid_, tmtt::TrackerModule::ModuleTypeCfg::pitchVsType, tmtt::Settings::pitchVsType(), tmtt::TrackerModule::ModuleTypeCfg::psVsType, tmtt::Settings::psVsType(), tmtt::StubWindowSuggest::setFEWindows(), tmtt::Settings::setMagneticField(), settings_, tmtt::TrackerModule::ModuleTypeCfg::spaceVsType, tmtt::Settings::spaceVsType(), stubAlgo_, stubFEWindows_, stubWindowSuggest_, submitPVValidationJobs::t, submitPVValidationJobs::text, StripSubdetector::TID, tmtt::TrackerModule::ModuleTypeCfg::tiltedVsType, tmtt::Settings::tiltedVsType(), StripSubdetector::TOB, trackerGeometry_, trackerGeometryToken_, trackerTopology_, trackerTopologyToken_, ttStubAlgoToken_, and PV3DBase< T, PVType, FrameType >::z().

96  {
97  // Get the B-field and store its value in the Settings class.
98  const MagneticField* theMagneticField = &(iSetup.getData(magneticFieldToken_));
99  float bField = theMagneticField->inTesla(GlobalPoint(0, 0, 0)).z(); // B field in Tesla.
101 
102  // Set also B field in GlobalCacheTMTT (used only for Histogramming)
103  globalCache()->settings().setMagneticField(bField);
104 
105  std::stringstream text;
106  text << "\n--- B field = " << bField << " Tesla ---\n";
107  std::call_once(
108  printOnce, [](string t) { PrintL1trk() << t; }, text.str());
109 
110  // Get tracker geometry
113 
114  // Loop over tracker modules to get module info.
115 
116  // Identifies tracker module type for firmware.
117  TrackerModule::ModuleTypeCfg moduleTypeCfg;
118  moduleTypeCfg.pitchVsType = settings_.pitchVsType();
119  moduleTypeCfg.spaceVsType = settings_.spaceVsType();
120  moduleTypeCfg.barrelVsType = settings_.barrelVsType();
121  moduleTypeCfg.psVsType = settings_.psVsType();
122  moduleTypeCfg.tiltedVsType = settings_.tiltedVsType();
123 
124  listTrackerModule_.clear();
125  for (const GeomDet* gd : trackerGeometry_->dets()) {
126  DetId detId = gd->geographicalId();
127  // Phase 2 Outer Tracker uses TOB for entire barrel & TID for entire endcap.
128  if (detId.subdetId() != StripSubdetector::TOB && detId.subdetId() != StripSubdetector::TID)
129  continue;
130  if (trackerTopology_->isLower(detId)) { // Select only lower of the two sensors in a module.
131  // Store info about this tracker module.
132  listTrackerModule_.emplace_back(trackerGeometry_, trackerTopology_, moduleTypeCfg, detId);
133  }
134  }
135 
136  // Takes one copy of this to GlobalCacheTMTT for later histogramming.
137  globalCache()->setListTrackerModule(listTrackerModule_);
138 
139  // Get TTStubProducerAlgorithm algorithm, to adjust stub bend FE encoding.
140  stubAlgo_ = dynamic_cast<const StubAlgorithmOfficial*>(&iSetup.getData(ttStubAlgoToken_));
141  // Get FE stub window size from TTStub producer configuration
142  const edm::ESHandle<StubAlgorithm> stubAlgoHandle = iSetup.getHandle(ttStubAlgoToken_);
143  const edm::ParameterSet& pSetStubAlgo = getParameterSet(stubAlgoHandle.description()->pid_);
144  stubFEWindows_ = std::make_unique<StubFEWindows>(pSetStubAlgo);
145  // Initialize utilities needing FE window size.
147  degradeBend_ = std::make_unique<DegradeBend>(trackerTopology_, stubFEWindows_.get(), stubAlgo_);
148  }
const StubAlgorithmOfficial * stubAlgo_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::unique_ptr< DegradeBend > degradeBend_
T z() const
Definition: PV3DBase.h:61
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const TrackerTopology * trackerTopology_
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const std::vector< double > & pitchVsType() const
Definition: Settings.h:95
void setFEWindows(const StubFEWindows *sw)
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
std::unique_ptr< StubFEWindows > stubFEWindows_
void setMagneticField(float magneticField) const
Definition: Settings.h:400
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
const std::vector< bool > & psVsType() const
Definition: Settings.h:98
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyToken_
const std::vector< bool > & barrelVsType() const
Definition: Settings.h:97
static constexpr auto TOB
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
const TrackerGeometry * trackerGeometry_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
edm::ESGetToken< StubAlgorithm, TTStubAlgorithmRecord > ttStubAlgoToken_
Definition: DetId.h:17
bool isLower(const DetId &id) const
edm::eventsetup::ComponentDescription const * description() const
Definition: ESHandle.cc:9
std::list< TrackerModule > listTrackerModule_
ParameterSet const & getParameterSet(ParameterSetID const &id)
TTStubAlgorithm_official< Ref_Phase2TrackerDigi_ > StubAlgorithmOfficial
StubWindowSuggest & stubWindowSuggest_
const std::vector< double > & spaceVsType() const
Definition: Settings.h:96
static constexpr auto TID
const std::vector< bool > & tiltedVsType() const
Definition: Settings.h:99

◆ globalEndJob()

void tmtt::TMTrackProducer::globalEndJob ( GlobalCacheTMTT globalCacheTMTT)
static

Definition at line 401 of file TMTrackProducer.cc.

References tmtt::Histos::endJobAnalysis(), tmtt::GlobalCacheTMTT::hists(), tmtt::GlobalCacheTMTT::htRphiErrMon(), tmtt::GlobalCacheTMTT::listTrackerModule(), tmtt::Settings::numEtaRegions(), tmtt::Settings::numPhiSectors(), tmtt::StubWindowSuggest::printResults(), tmtt::Settings::printStubWindows(), tmtt::GlobalCacheTMTT::settings(), tmtt::GlobalCacheTMTT::stubWindowSuggest(), and tmtt::Histos::trackerGeometryAnalysis().

401  {
402  const Settings& settings = globalCacheTMTT->settings();
403 
404  // Print stub window sizes that TMTT recommends CMS uses in FE chips.
405  if (settings.printStubWindows())
406  globalCacheTMTT->stubWindowSuggest().printResults();
407 
408  // Print (once) info about tracker geometry.
409  globalCacheTMTT->hists().trackerGeometryAnalysis(globalCacheTMTT->listTrackerModule());
410 
411  PrintL1trk() << "\n Number of (eta,phi) sectors used = (" << settings.numEtaRegions() << ","
412  << settings.numPhiSectors() << ")";
413 
414  // Print job summary
415  globalCacheTMTT->hists().endJobAnalysis(&(globalCacheTMTT->htRphiErrMon()));
416  }

◆ initializeGlobalCache()

std::unique_ptr< GlobalCacheTMTT > tmtt::TMTrackProducer::initializeGlobalCache ( edm::ParameterSet const &  iConfig)
static

Definition at line 33 of file TMTrackProducer.cc.

33  {
34  return std::make_unique<GlobalCacheTMTT>(iConfig);
35  }

◆ produce()

void tmtt::TMTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 152 of file TMTrackProducer.cc.

References tmtt::L1fittedTrack::accepted(), clusterTruthToken_, submitPVResolutionJobs::count, debug_, degradeBend_, tmtt::L1fittedTrack::digitizeTrack(), ZCounting_cfi::edmName, tmtt::Settings::enableDigitize(), tmtt::Settings::enableOutputIntermediateTTTracks(), tmtt::MiniHTstage::exec(), tmtt::MuxHToutputs::exec(), tmtt::Histos::fill(), tmtt::DupFitTrkKiller::filter(), fitterWorkerMap_, genJetToken_, tmtt::InputData::getTPs(), tmtt::Stub::GP, hists_, tmtt::Stub::HT, htRphiErrMon_, iEvent, tmtt::Settings::isHTRPhiEtaRegWhitelisted(), listTrackerModule_, tmtt::Settings::miniHTstage(), eostools::move(), tmtt::Settings::muxOutputsHT(), tmtt::Settings::numEtaRegions(), tmtt::Settings::numPhiSectors(), AlCaHLTBitMon_ParallelJobs::p, tmtt::Make3Dtracks::run(), runRZfilter_, alignCSCRings::s, nano_mu_digi_cff::sector, settings_, AlCaHLTBitMon_QueryRunRegistry::string, stubToken_, stubTruthToken_, stubWindowSuggest_, tmtt::Stub::TF, tpToken_, tmtt::HTbase::trackCands2D(), tmtt::Make3Dtracks::trackCands3D(), trackerGeometry_, trackerTopology_, trackFitters_, and useRZfilter_.

152  {
153  // Note useful info about MC truth particles and about reconstructed stubs .
154  InputData inputData(iEvent,
155  iSetup,
156  &settings_,
158  degradeBend_.get(),
162  tpToken_,
163  stubToken_,
166  genJetToken_);
167 
168  const list<TP>& vTPs = inputData.getTPs();
169  const list<Stub*>& vStubs = inputData.stubs();
170 
171  // Creates matrix of Sector objects, which decide which stubs are in which (eta,phi) sector
172  Array2D<unique_ptr<Sector>> mSectors(settings_.numPhiSectors(), settings_.numEtaRegions());
173  // Create matrix of r-phi Hough-Transform arrays, with one-to-one correspondence to sectors.
174  Array2D<unique_ptr<HTrphi>> mHtRphis(settings_.numPhiSectors(), settings_.numEtaRegions());
175  // Create matrix of Make3Dtracks objects, to run optional r-z track filter, with one-to-one correspondence to sectors.
176  Array2D<unique_ptr<Make3Dtracks>> mMake3Dtrks(settings_.numPhiSectors(), settings_.numEtaRegions());
177  // Create matrix of tracks from each fitter in each sector
178  Array2D<map<string, std::list<L1fittedTrack>>> mapmFitTrks(settings_.numPhiSectors(), settings_.numEtaRegions());
179  // Final tracks after duplicate removal from each track fitter in entire tracker.
180  map<string, list<const L1fittedTrack*>> mapFinalTracks;
181 
182  //=== Initialization
183  // Create utility for converting L1 tracks from our private format to official CMSSW EDM format.
184  const ConverterToTTTrack converter(&settings_);
185 
186  // Pointers to TTTrack collections for ED output.
187  auto htTTTracksForOutput = std::make_unique<TTTrackCollection>();
188  auto rzTTTracksForOutput = std::make_unique<TTTrackCollection>();
189  map<string, unique_ptr<TTTrackCollection>> allFitTTTracksForOutput;
190  for (const string& fitterName : trackFitters_) {
191  auto fitTTTracksForOutput = std::make_unique<TTTrackCollection>();
192  allFitTTTracksForOutput[fitterName] = std::move(fitTTTracksForOutput);
193  }
194 
195  //=== Do tracking in the r-phi Hough transform within each sector.
196 
197  // Fill Hough-Transform arrays with stubs.
198  for (unsigned int iPhiSec = 0; iPhiSec < settings_.numPhiSectors(); iPhiSec++) {
199  for (unsigned int iEtaReg = 0; iEtaReg < settings_.numEtaRegions(); iEtaReg++) {
200  // Initialize constants for this sector.
201  mSectors(iPhiSec, iEtaReg) = std::make_unique<Sector>(&settings_, iPhiSec, iEtaReg);
202  Sector* sector = mSectors(iPhiSec, iEtaReg).get();
203 
204  mHtRphis(iPhiSec, iEtaReg) = std::make_unique<HTrphi>(
205  &settings_, iPhiSec, iEtaReg, sector->etaMin(), sector->etaMax(), sector->phiCentre(), &htRphiErrMon_);
206  HTrphi* htRphi = mHtRphis(iPhiSec, iEtaReg).get();
207 
208  // Check sector is enabled (always true, except if user disabled some for special studies).
209  if (settings_.isHTRPhiEtaRegWhitelisted(iEtaReg)) {
210  for (Stub* stub : vStubs) {
211  // Digitize stub as would be at input to GP. This doesn't need the nonant number, since we assumed an integer number of
212  // phi digitisation bins inside an nonant. N.B. This changes the coordinates & bend stored in the stub.
213 
215  stub->digitize(iPhiSec, Stub::DigiStage::GP);
216 
217  // Check if stub is inside this sector
218  bool inside = sector->inside(stub);
219 
220  if (inside) {
221  // Check which eta subsectors within the sector the stub is compatible with (if subsectors being used).
222  const vector<bool> inEtaSubSecs = sector->insideEtaSubSecs(stub);
223 
224  // Digitize stub if as would be at input to HT, which slightly degrades its coord. & bend resolution, affecting the HT performance.
226  stub->digitize(iPhiSec, Stub::DigiStage::HT);
227 
228  // Store stub in Hough transform array for this sector, indicating its compatibility with eta subsectors with sector.
229  htRphi->store(stub, inEtaSubSecs);
230  }
231  }
232  }
233 
234  // Find tracks in r-phi HT array.
235  htRphi->end(); // Calls htArrayRphi_.end() -> HTBase::end()
236  }
237  }
238 
239  if (settings_.muxOutputsHT() > 0) {
240  // Multiplex outputs of several HT onto one pair of output opto-links.
241  // This only affects tracking performance if option busySectorKill is enabled, so that tracks that
242  // can't be sent down the link within the time-multiplexed period are killed.
243  MuxHToutputs muxHT(&settings_);
244  muxHT.exec(mHtRphis);
245  }
246 
247  // Optionally, run 2nd stage mini HT -- WITHOUT TRUNCATION ???
248  if (settings_.miniHTstage()) {
249  MiniHTstage miniHTstage(&settings_);
250  miniHTstage.exec(mHtRphis);
251  }
252 
253  //=== Make 3D tracks, optionally running r-z track filters (such as Seed Filter) & duplicate track removal.
254 
255  for (unsigned int iPhiSec = 0; iPhiSec < settings_.numPhiSectors(); iPhiSec++) {
256  for (unsigned int iEtaReg = 0; iEtaReg < settings_.numEtaRegions(); iEtaReg++) {
257  const Sector* sector = mSectors(iPhiSec, iEtaReg).get();
258 
259  // Get tracks found by r-phi HT.
260  const HTrphi* htRphi = mHtRphis(iPhiSec, iEtaReg).get();
261  const list<L1track2D>& vecTracksRphi = htRphi->trackCands2D();
262 
263  // Initialize utility for making 3D tracks from 2D ones.
264  mMake3Dtrks(iPhiSec, iEtaReg) = std::make_unique<Make3Dtracks>(
265  &settings_, iPhiSec, iEtaReg, sector->etaMin(), sector->etaMax(), sector->phiCentre());
266  Make3Dtracks* make3Dtrk = mMake3Dtrks(iPhiSec, iEtaReg).get();
267 
268  // Convert 2D tracks found by HT to 3D tracks (optionally by running r-z filters & duplicate track removal)
269  make3Dtrk->run(vecTracksRphi);
270 
272  // Convert these tracks to EDM format for output (used for collaborative work outside TMTT group).
273  // Do this for tracks output by HT & optionally also for those output by r-z track filter.
274  const list<L1track3D>& vecTrk3D_ht = make3Dtrk->trackCands3D(false);
275  for (const L1track3D& trk : vecTrk3D_ht) {
276  TTTrack<Ref_Phase2TrackerDigi_> htTTTrack = converter.makeTTTrack(&trk, iPhiSec, iEtaReg);
277  htTTTracksForOutput->push_back(htTTTrack);
278  }
279 
280  if (runRZfilter_) {
281  const list<L1track3D>& vecTrk3D_rz = make3Dtrk->trackCands3D(true);
282  for (const L1track3D& trk : vecTrk3D_rz) {
283  TTTrack<Ref_Phase2TrackerDigi_> rzTTTrack = converter.makeTTTrack(&trk, iPhiSec, iEtaReg);
284  rzTTTracksForOutput->push_back(rzTTTrack);
285  }
286  }
287  }
288  }
289  }
290 
291  //=== Do a helix fit to all the track candidates.
292 
293  // Loop over all the fitting algorithms we are trying.
294  for (const string& fitterName : trackFitters_) {
295  for (unsigned int iPhiSec = 0; iPhiSec < settings_.numPhiSectors(); iPhiSec++) {
296  for (unsigned int iEtaReg = 0; iEtaReg < settings_.numEtaRegions(); iEtaReg++) {
297  const Make3Dtracks* make3Dtrk = mMake3Dtrks(iPhiSec, iEtaReg).get();
298 
299  // Does this fitter require r-z track filter to be run before it?
300  bool useRZfilt = (std::count(useRZfilter_.begin(), useRZfilter_.end(), fitterName) > 0);
301 
302  // Get 3D track candidates found by Hough transform (plus optional r-z filters/duplicate removal) in this sector.
303  const list<L1track3D>& vecTrk3D = make3Dtrk->trackCands3D(useRZfilt);
304 
305  // Find list where fitted tracks will be stored.
306  list<L1fittedTrack>& fitTrksInSec = mapmFitTrks(iPhiSec, iEtaReg)[fitterName];
307 
308  // Fit all tracks in this sector
309  for (const L1track3D& trk : vecTrk3D) {
310  // Ensure stubs assigned to this track is digitized with respect to the phi sector the track is in.
311  if (settings_.enableDigitize()) {
312  const vector<Stub*>& stubsOnTrk = trk.stubs();
313  for (Stub* s : stubsOnTrk) {
314  // Also digitize stub in way this specific track fitter uses it.
315  s->digitize(iPhiSec, Stub::DigiStage::TF);
316  }
317  }
318 
319  L1fittedTrack fitTrk = fitterWorkerMap_[fitterName]->fit(trk);
320 
321  if (fitTrk.accepted()) { // If fitter accepted track, then store it.
322  // Optionally digitize fitted track, degrading slightly resolution.
324  fitTrk.digitizeTrack(fitterName);
325  // Store fitted tracks, such that there is one fittedTracks corresponding to each HT tracks.
326  fitTrksInSec.push_back(fitTrk);
327  }
328  }
329  }
330  }
331  }
332 
333  // Run duplicate track removal on the fitted tracks if requested.
334 
335  // Initialize the duplicate track removal algorithm that can optionally be run after the track fit.
336  DupFitTrkKiller killDupFitTrks(&settings_);
337 
338  // Loop over all the fitting algorithms we used.
339  for (const string& fitterName : trackFitters_) {
340  for (unsigned int iPhiSec = 0; iPhiSec < settings_.numPhiSectors(); iPhiSec++) {
341  for (unsigned int iEtaReg = 0; iEtaReg < settings_.numEtaRegions(); iEtaReg++) {
342  // Get fitted tracks in sector
343  const list<L1fittedTrack>& fitTrksInSec = mapmFitTrks(iPhiSec, iEtaReg)[fitterName];
344 
345  // Run duplicate removal
346  list<const L1fittedTrack*> filteredFitTrksInSec = killDupFitTrks.filter(fitTrksInSec);
347 
348  // Prepare TTTrack collection.
349  for (const L1fittedTrack* fitTrk : filteredFitTrksInSec) {
350  // Convert these fitted tracks to EDM format for output (used for collaborative work outside TMTT group).
351  TTTrack<Ref_Phase2TrackerDigi_> fitTTTrack = converter.makeTTTrack(fitTrk, iPhiSec, iEtaReg);
352  allFitTTTracksForOutput[fitterName]->push_back(fitTTTrack);
353  }
354 
355  // Store fitted tracks from entire tracker.
356  mapFinalTracks[fitterName].insert(
357  mapFinalTracks[fitterName].end(), filteredFitTrksInSec.begin(), filteredFitTrksInSec.end());
358  }
359  }
360  }
361 
362  // Debug printout
363  if (debug_) {
364  PrintL1trk() << "INPUT #TPs = " << vTPs.size() << " #STUBs = " << vStubs.size();
365  unsigned int numHTtracks = 0;
366  for (unsigned int iPhiSec = 0; iPhiSec < settings_.numPhiSectors(); iPhiSec++) {
367  for (unsigned int iEtaReg = 0; iEtaReg < settings_.numEtaRegions(); iEtaReg++) {
368  const Make3Dtracks* make3Dtrk = mMake3Dtrks(iPhiSec, iEtaReg).get();
369  numHTtracks += make3Dtrk->trackCands3D(false).size();
370  }
371  }
372  PrintL1trk() << "Number of tracks after HT = " << numHTtracks;
373  for (const auto& p : mapFinalTracks) {
374  const string& fitName = p.first;
375  const list<const L1fittedTrack*> fittedTracks = p.second;
376  PrintL1trk() << "Number of tracks after " << fitName << " track helix fit = " << fittedTracks.size();
377  }
378  }
379 
380  // Allow histogramming to plot undigitized variables.
381  for (Stub* stub : vStubs) {
383  stub->setDigitizeWarningsOn(false);
384  }
385 
386  // Fill histograms to monitor input data & tracking performance.
387  hists_.fill(inputData, mSectors, mHtRphis, mMake3Dtrks, mapFinalTracks);
388 
389  //=== Store output EDM track and hardware stub collections.
391  iEvent.put(std::move(htTTTracksForOutput), "TML1TracksHT");
392  if (runRZfilter_)
393  iEvent.put(std::move(rzTTTracksForOutput), "TML1TracksRZ");
394  }
395  for (const string& fitterName : trackFitters_) {
396  string edmName = string("TML1Tracks") + fitterName;
397  iEvent.put(std::move(allFitTTTracksForOutput[fitterName]), edmName);
398  }
399  }
bool miniHTstage() const
Definition: Settings.h:149
bool enableDigitize() const
Definition: Settings.h:80
HTrphi::ErrorMonitor & htRphiErrMon_
std::unique_ptr< DegradeBend > degradeBend_
const TrackerTopology * trackerTopology_
unsigned int numEtaRegions() const
Definition: Settings.h:125
std::map< std::string, std::unique_ptr< TrackFitGeneric > > fitterWorkerMap_
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
edm::EDGetTokenT< TTClusterAssMap > clusterTruthToken_
edm::EDGetTokenT< TTStubAssMap > stubTruthToken_
int iEvent
Definition: GenABIO.cc:224
std::vector< std::string > trackFitters_
virtual void fill(const InputData &inputData, const Array2D< std::unique_ptr< Sector >> &mSectors, const Array2D< std::unique_ptr< HTrphi >> &mHtPhis, const Array2D< std::unique_ptr< Make3Dtracks >> &mGet3Dtrks, const std::map< std::string, std::list< const L1fittedTrack *>> &mapFinalTracks)
Definition: Histos.cc:83
const TrackerGeometry * trackerGeometry_
bool enableOutputIntermediateTTTracks() const
Definition: Settings.h:44
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
std::list< TrackerModule > listTrackerModule_
unsigned int muxOutputsHT() const
Definition: Settings.h:189
bool isHTRPhiEtaRegWhitelisted(unsigned const iEtaReg) const
Definition: Settings.cc:467
StubWindowSuggest & stubWindowSuggest_
edm::EDGetTokenT< TTStubDetSetVec > stubToken_
unsigned int numPhiSectors() const
Definition: Settings.h:110
edm::EDGetTokenT< reco::GenJetCollection > genJetToken_
def move(src, dest)
Definition: eostools.py:511
std::vector< std::string > useRZfilter_

Member Data Documentation

◆ clusterTruthToken_

edm::EDGetTokenT<TTClusterAssMap> tmtt::TMTrackProducer::clusterTruthToken_
private

Definition at line 68 of file TMTrackProducer.h.

Referenced by produce(), and TMTrackProducer().

◆ debug_

bool tmtt::TMTrackProducer::debug_
private

Definition at line 93 of file TMTrackProducer.h.

Referenced by produce().

◆ degradeBend_

std::unique_ptr<DegradeBend> tmtt::TMTrackProducer::degradeBend_
private

Definition at line 86 of file TMTrackProducer.h.

Referenced by beginRun(), and produce().

◆ fitterWorkerMap_

std::map<std::string, std::unique_ptr<TrackFitGeneric> > tmtt::TMTrackProducer::fitterWorkerMap_
private

Definition at line 91 of file TMTrackProducer.h.

Referenced by produce(), and TMTrackProducer().

◆ genJetToken_

edm::EDGetTokenT<reco::GenJetCollection> tmtt::TMTrackProducer::genJetToken_
private

Definition at line 69 of file TMTrackProducer.h.

Referenced by produce(), and TMTrackProducer().

◆ hists_

Histos& tmtt::TMTrackProducer::hists_
private

Definition at line 88 of file TMTrackProducer.h.

Referenced by produce().

◆ htRphiErrMon_

HTrphi::ErrorMonitor& tmtt::TMTrackProducer::htRphiErrMon_
private

Definition at line 89 of file TMTrackProducer.h.

Referenced by produce().

◆ listTrackerModule_

std::list<TrackerModule> tmtt::TMTrackProducer::listTrackerModule_
private

Definition at line 74 of file TMTrackProducer.h.

Referenced by beginRun(), and produce().

◆ magneticFieldToken_

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> tmtt::TMTrackProducer::magneticFieldToken_
private

Definition at line 60 of file TMTrackProducer.h.

Referenced by beginRun(), and TMTrackProducer().

◆ runRZfilter_

bool tmtt::TMTrackProducer::runRZfilter_
private

Definition at line 80 of file TMTrackProducer.h.

Referenced by produce(), and TMTrackProducer().

◆ settings_

Settings tmtt::TMTrackProducer::settings_
private

Definition at line 77 of file TMTrackProducer.h.

Referenced by beginRun(), produce(), and TMTrackProducer().

◆ stubAlgo_

const StubAlgorithmOfficial* tmtt::TMTrackProducer::stubAlgo_
private

Definition at line 83 of file TMTrackProducer.h.

Referenced by beginRun().

◆ stubFEWindows_

std::unique_ptr<StubFEWindows> tmtt::TMTrackProducer::stubFEWindows_
private

Definition at line 84 of file TMTrackProducer.h.

Referenced by beginRun().

◆ stubToken_

edm::EDGetTokenT<TTStubDetSetVec> tmtt::TMTrackProducer::stubToken_
private

Definition at line 65 of file TMTrackProducer.h.

Referenced by produce(), and TMTrackProducer().

◆ stubTruthToken_

edm::EDGetTokenT<TTStubAssMap> tmtt::TMTrackProducer::stubTruthToken_
private

Definition at line 67 of file TMTrackProducer.h.

Referenced by produce(), and TMTrackProducer().

◆ stubWindowSuggest_

StubWindowSuggest& tmtt::TMTrackProducer::stubWindowSuggest_
private

Definition at line 85 of file TMTrackProducer.h.

Referenced by beginRun(), and produce().

◆ tpToken_

edm::EDGetTokenT<TrackingParticleCollection> tmtt::TMTrackProducer::tpToken_
private

Definition at line 66 of file TMTrackProducer.h.

Referenced by produce(), and TMTrackProducer().

◆ trackerGeometry_

const TrackerGeometry* tmtt::TMTrackProducer::trackerGeometry_
private

Definition at line 72 of file TMTrackProducer.h.

Referenced by beginRun(), and produce().

◆ trackerGeometryToken_

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tmtt::TMTrackProducer::trackerGeometryToken_
private

Definition at line 61 of file TMTrackProducer.h.

Referenced by beginRun(), and TMTrackProducer().

◆ trackerTopology_

const TrackerTopology* tmtt::TMTrackProducer::trackerTopology_
private

Definition at line 73 of file TMTrackProducer.h.

Referenced by beginRun(), and produce().

◆ trackerTopologyToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tmtt::TMTrackProducer::trackerTopologyToken_
private

Definition at line 62 of file TMTrackProducer.h.

Referenced by beginRun(), and TMTrackProducer().

◆ trackFitters_

std::vector<std::string> tmtt::TMTrackProducer::trackFitters_
private

Definition at line 78 of file TMTrackProducer.h.

Referenced by produce(), and TMTrackProducer().

◆ ttStubAlgoToken_

edm::ESGetToken<StubAlgorithm, TTStubAlgorithmRecord> tmtt::TMTrackProducer::ttStubAlgoToken_
private

Definition at line 63 of file TMTrackProducer.h.

Referenced by beginRun(), and TMTrackProducer().

◆ useRZfilter_

std::vector<std::string> tmtt::TMTrackProducer::useRZfilter_
private

Definition at line 79 of file TMTrackProducer.h.

Referenced by produce(), and TMTrackProducer().