CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
trackerTFP::ProducerKFin Class Reference

transforms TTTracks into KF input More...

Inheritance diagram for trackerTFP::ProducerKFin:
edm::stream::EDProducer<>

Public Member Functions

 ProducerKFin (const ParameterSet &)
 
 ~ProducerKFin () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 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
 

Private Member Functions

void beginRun (const Run &, const EventSetup &) override
 
virtual void endJob ()
 
void produce (Event &, const EventSetup &) override
 

Private Attributes

const DataFormatsdataFormats_ = nullptr
 
EDGetTokenT< StreamsStubedGetTokenStubs_
 
EDGetTokenT< vector< TTTrack< Ref_Phase2TrackerDigi_ > > > edGetTokenTTTracks_
 
EDPutTokenT< StreamsStubedPutTokenAcceptedStubs_
 
EDPutTokenT< StreamsTrackedPutTokenAcceptedTracks_
 
EDPutTokenT< StreamsStubedPutTokenLostStubs_
 
EDPutTokenT< StreamsTrackedPutTokenLostTracks_
 
bool enableTruncation_
 
ESGetToken< DataFormats, DataFormatsRcdesGetTokenDataFormats_
 
ESGetToken< LayerEncoding, LayerEncodingRcdesGetTokenLayerEncoding_
 
ESGetToken< Setup, SetupRcdesGetTokenSetup_
 
ParameterSet iConfig_
 
const LayerEncodinglayerEncoding_ = nullptr
 
const Setupsetup_ = nullptr
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
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

transforms TTTracks into KF input

Author
Thomas Schuh
Date
2020, July

Definition at line 37 of file ProducerKFin.cc.

Constructor & Destructor Documentation

◆ ProducerKFin()

trackerTFP::ProducerKFin::ProducerKFin ( const ParameterSet iConfig)
explicit

Definition at line 75 of file ProducerKFin.cc.

References edGetTokenStubs_, edGetTokenTTTracks_, edPutTokenAcceptedStubs_, edPutTokenAcceptedTracks_, edPutTokenLostStubs_, edPutTokenLostTracks_, enableTruncation_, esGetTokenDataFormats_, esGetTokenLayerEncoding_, esGetTokenSetup_, edm::ParameterSet::getParameter(), and ProducerED_cfi::InputTag.

75  : iConfig_(iConfig) {
76  const string& labelTTTracks = iConfig.getParameter<string>("LabelZHTout");
77  const string& labelStubs = iConfig.getParameter<string>("LabelZHT");
78  const string& branchAcceptedStubs = iConfig.getParameter<string>("BranchAcceptedStubs");
79  const string& branchAcceptedTracks = iConfig.getParameter<string>("BranchAcceptedTracks");
80  const string& branchLostStubs = iConfig.getParameter<string>("BranchLostStubs");
81  const string& branchLostTracks = iConfig.getParameter<string>("BranchLostTracks");
82  // book in- and output ED products
84  consumes<vector<TTTrack<Ref_Phase2TrackerDigi_>>>(InputTag(labelTTTracks, branchAcceptedTracks));
85  edGetTokenStubs_ = consumes<StreamsStub>(InputTag(labelStubs, branchAcceptedStubs));
86  edPutTokenAcceptedStubs_ = produces<StreamsStub>(branchAcceptedStubs);
87  edPutTokenAcceptedTracks_ = produces<StreamsTrack>(branchAcceptedTracks);
88  edPutTokenLostStubs_ = produces<StreamsStub>(branchLostStubs);
89  edPutTokenLostTracks_ = produces<StreamsTrack>(branchLostTracks);
90  // book ES products
91  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
92  esGetTokenDataFormats_ = esConsumes<DataFormats, DataFormatsRcd, Transition::BeginRun>();
93  esGetTokenLayerEncoding_ = esConsumes<LayerEncoding, LayerEncodingRcd, Transition::BeginRun>();
94  //
95  enableTruncation_ = iConfig.getParameter<bool>("EnableTruncation");
96  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
Definition: ProducerKFin.cc:58
ESGetToken< LayerEncoding, LayerEncodingRcd > esGetTokenLayerEncoding_
Definition: ProducerKFin.cc:62
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
Definition: ProducerKFin.cc:60
EDPutTokenT< StreamsStub > edPutTokenLostStubs_
Definition: ProducerKFin.cc:53
EDPutTokenT< StreamsTrack > edPutTokenLostTracks_
Definition: ProducerKFin.cc:56
EDGetTokenT< vector< TTTrack< Ref_Phase2TrackerDigi_ > > > edGetTokenTTTracks_
Definition: ProducerKFin.cc:48
EDPutTokenT< StreamsTrack > edPutTokenAcceptedTracks_
Definition: ProducerKFin.cc:55
EDPutTokenT< StreamsStub > edPutTokenAcceptedStubs_
Definition: ProducerKFin.cc:52
EDGetTokenT< StreamsStub > edGetTokenStubs_
Definition: ProducerKFin.cc:50

◆ ~ProducerKFin()

trackerTFP::ProducerKFin::~ProducerKFin ( )
inlineoverride

Definition at line 40 of file ProducerKFin.cc.

40 {}

Member Function Documentation

◆ beginRun()

void trackerTFP::ProducerKFin::beginRun ( const Run iRun,
const EventSetup iSetup 
)
overrideprivate

Definition at line 98 of file ProducerKFin.cc.

References tt::Setup::checkHistory(), tt::Setup::configurationSupported(), dataFormats_, esGetTokenDataFormats_, esGetTokenLayerEncoding_, esGetTokenSetup_, edm::EventSetup::getData(), edm::ParameterSet::getParameter(), iConfig_, layerEncoding_, edm::Run::processHistory(), and setup_.

98  {
99  // helper class to store configurations
100  setup_ = &iSetup.getData(esGetTokenSetup_);
102  return;
103  // check process history if desired
104  if (iConfig_.getParameter<bool>("CheckHistory"))
106  // helper class to extract structured data from tt::Frames
108  // helper class to encode layer
110  }
const DataFormats * dataFormats_
Definition: ProducerKFin.cc:68
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
Definition: ProducerKFin.cc:58
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
ESGetToken< LayerEncoding, LayerEncodingRcd > esGetTokenLayerEncoding_
Definition: ProducerKFin.cc:62
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
Definition: ProducerKFin.cc:60
bool configurationSupported() const
Definition: Setup.h:60
ProcessHistory const & processHistory() const
Definition: Run.cc:115
void checkHistory(const edm::ProcessHistory &processHistory) const
Definition: Setup.cc:242
const LayerEncoding * layerEncoding_
Definition: ProducerKFin.cc:70

◆ endJob()

virtual void trackerTFP::ProducerKFin::endJob ( void  )
inlineprivatevirtual

Definition at line 45 of file ProducerKFin.cc.

45 {}

◆ produce()

void trackerTFP::ProducerKFin::produce ( Event iEvent,
const EventSetup iSetup 
)
overrideprivate

Definition at line 112 of file ProducerKFin.cc.

References tt::Setup::configurationSupported(), trackerTFP::cot, trackerTFP::StubZHT::cot(), dataFormats_, trackerTFP::DataFormat::digi(), trackerTFP::dPhi, tt::Setup::dPhi(), trackerTFP::dZ, tt::Setup::dZ(), edGetTokenStubs_, edGetTokenTTTracks_, edPutTokenAcceptedStubs_, edPutTokenAcceptedTracks_, edPutTokenLostStubs_, edPutTokenLostTracks_, enableTruncation_, trackerTFP::DataFormat::floating(), trackerTFP::DataFormats::format(), amptDefault_cfi::frame, mps_fire::i, iEvent, createfilelist::int, trackerTFP::DataFormat::integer(), trackerTFP::inv2R, trackerTFP::StubZHT::inv2R(), trackerTFP::kf, trackerTFP::kfin, MainPageGenerator::l, layerEncoding_, tt::Setup::layerId(), trackerTFP::LayerEncoding::layerIdKF(), trackerTFP::LayerEncoding::maybePattern(), SiStripPI::min, eostools::move(), GetRecoTauVFromDQM_MC_cff::next, trackerTFP::DataFormats::numChannel(), tt::Setup::numFrames(), tt::Setup::numLayers(), tt::Setup::numRegions(), tt::Setup::numSectorsPhi(), trackerTFP::DataFormats::numStreamsStubs(), trackerTFP::DataFormats::numStreamsTracks(), edm::Handle< T >::product(), nano_mu_digi_cff::region, tt::Setup::sectorCot(), trackerTFP::sectorPhi, setup_, cms::cuda::stream, HLT_2024v12_cff::streams, trackerTFP::DataFormat::toUnsigned(), HLT_2024v12_cff::track, DiMuonV_cfg::tracks, trackerTFP::zht, tt::Setup::zhtMaxStubsPerLayer(), and trackerTFP::zT.

112  {
118  // empty KFin products
119  StreamsStub streamAcceptedStubs(dataFormats_->numStreamsStubs(Process::kf));
120  StreamsTrack streamAcceptedTracks(dataFormats_->numStreamsTracks(Process::kf));
123  // read in SFout Product and produce KFin product
125  Handle<StreamsStub> handleStubs;
126  iEvent.getByToken<StreamsStub>(edGetTokenStubs_, handleStubs);
127  const StreamsStub& streams = *handleStubs.product();
129  iEvent.getByToken<vector<TTTrack<Ref_Phase2TrackerDigi_>>>(edGetTokenTTTracks_, handleTTTracks);
130  const vector<TTTrack<Ref_Phase2TrackerDigi_>>& ttTracks = *handleTTTracks.product();
131  for (int region = 0; region < setup_->numRegions(); region++) {
132  // Unpack input SF data into vector
133  int nStubsZHR(0);
134  for (int channel = 0; channel < dataFormats_->numChannel(Process::zht); channel++) {
135  const int index = region * dataFormats_->numChannel(Process::zht) + channel;
136  const StreamStub& stream = streams[index];
137  nStubsZHR += accumulate(stream.begin(), stream.end(), 0, [](int sum, const FrameStub& frame) {
138  return sum + (frame.first.isNonnull() ? 1 : 0);
139  });
140  }
141  vector<StubZHT> stubsZHT;
142  stubsZHT.reserve(nStubsZHR);
143  for (int channel = 0; channel < dataFormats_->numChannel(Process::zht); channel++) {
144  const int index = region * dataFormats_->numChannel(Process::zht) + channel;
145  for (const FrameStub& frame : streams[index])
146  if (frame.first.isNonnull())
147  stubsZHT.emplace_back(frame, dataFormats_);
148  }
149  vector<deque<FrameStub>> dequesStubs(dataFormats_->numChannel(Process::kf) * setup_->numLayers());
150  vector<deque<FrameTrack>> dequesTracks(dataFormats_->numChannel(Process::kf));
151  int i(0);
152  for (const TTTrack<Ref_Phase2TrackerDigi_>& ttTrack : ttTracks) {
153  if ((int)ttTrack.phiSector() / setup_->numSectorsPhi() != region) {
154  i++;
155  continue;
156  }
157  const int sectorPhi = ttTrack.phiSector() % setup_->numSectorsPhi();
158  deque<FrameTrack>& tracks = dequesTracks[sectorPhi];
159  const int binEta = ttTrack.etaSector();
160  const int binZT = dfzT.toUnsigned(dfzT.integer(ttTrack.z0()));
161  const int binCot = dfcot.toUnsigned(dfcot.integer(ttTrack.tanL()));
162  StubZHT* stubZHT = nullptr;
163  vector<int> layerCounts(setup_->numLayers(), 0);
164  for (const TTStubRef& ttStubRef : ttTrack.getStubRefs()) {
165  const int layerId = setup_->layerId(ttStubRef);
166  const int layerIdKF = layerEncoding_->layerIdKF(binEta, binZT, binCot, layerId);
167  if (layerIdKF == -1)
168  continue;
169  if (layerCounts[layerIdKF] == setup_->zhtMaxStubsPerLayer())
170  continue;
171  layerCounts[layerIdKF]++;
172  deque<FrameStub>& stubs = dequesStubs[sectorPhi * setup_->numLayers() + layerIdKF];
173  auto identical = [ttStubRef, ttTrack](const StubZHT& stub) {
174  return (int)ttTrack.trackSeedType() == stub.trackId() && ttStubRef == stub.ttStubRef();
175  };
176  stubZHT = &*find_if(stubsZHT.begin(), stubsZHT.end(), identical);
177  const double inv2R = dfinv2R.floating(stubZHT->inv2R());
178  const double cot = dfcot.floating(stubZHT->cot()) + setup_->sectorCot(binEta);
179  const double dPhi = dfdPhi.digi(setup_->dPhi(ttStubRef, inv2R));
180  const double dZ = dfdZ.digi(setup_->dZ(ttStubRef, cot));
181  stubs.emplace_back(StubKFin(*stubZHT, dPhi, dZ, layerIdKF).frame());
182  }
183  const int size = *max_element(layerCounts.begin(), layerCounts.end());
184  int layerIdKF(0);
185  for (int layerCount : layerCounts) {
186  deque<FrameStub>& stubs = dequesStubs[sectorPhi * setup_->numLayers() + layerIdKF++];
187  const int nGaps = size - layerCount;
188  stubs.insert(stubs.end(), nGaps, FrameStub());
189  }
190  const TTBV& maybePattern = layerEncoding_->maybePattern(binEta, binZT, binCot);
191  const TrackKFin track(*stubZHT, TTTrackRef(handleTTTracks, i++), maybePattern);
192  tracks.emplace_back(track.frame());
193  const int nGaps = size - 1;
194  tracks.insert(tracks.end(), nGaps, FrameTrack());
195  }
196  // transform deques to vectors & emulate truncation
197  for (int channel = 0; channel < dataFormats_->numChannel(Process::kf); channel++) {
198  const int index = region * dataFormats_->numChannel(Process::kf) + channel;
199  deque<FrameTrack>& tracks = dequesTracks[channel];
200  auto limitTracks = next(tracks.begin(), min(setup_->numFrames(), (int)tracks.size()));
201  if (!enableTruncation_)
202  limitTracks = tracks.end();
203  streamAcceptedTracks[index] = StreamTrack(tracks.begin(), limitTracks);
204  streamLostTracks[index] = StreamTrack(limitTracks, tracks.end());
205  for (int l = 0; l < setup_->numLayers(); l++) {
206  deque<FrameStub>& stubs = dequesStubs[channel * setup_->numLayers() + l];
207  auto limitStubs = next(stubs.begin(), min(setup_->numFrames(), (int)stubs.size()));
208  if (!enableTruncation_)
209  limitStubs = stubs.end();
210  streamAcceptedStubs[index * setup_->numLayers() + l] = StreamStub(stubs.begin(), limitStubs);
211  streamLostStubs[index * setup_->numLayers() + l] = StreamStub(limitStubs, stubs.end());
212  }
213  }
214  }
215  }
216  // store products
217  iEvent.emplace(edPutTokenAcceptedStubs_, std::move(streamAcceptedStubs));
218  iEvent.emplace(edPutTokenAcceptedTracks_, std::move(streamAcceptedTracks));
219  iEvent.emplace(edPutTokenLostStubs_, std::move(streamLostStubs));
220  iEvent.emplace(edPutTokenLostTracks_, std::move(streamLostTracks));
221  }
size
Write out results.
const DataFormats * dataFormats_
Definition: ProducerKFin.cc:68
double dZ(const TTStubRef &ttStubRef, double cot) const
Definition: Setup.cc:600
std::vector< StreamTrack > StreamsTrack
Definition: TTTypes.h:67
int numSectorsPhi() const
Definition: Setup.h:413
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
Definition: TTBV.h:20
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
std::vector< StreamStub > StreamsStub
Definition: TTTypes.h:66
std::vector< FrameStub > StreamStub
Definition: TTTypes.h:63
T const * product() const
Definition: Handle.h:70
int numFrames() const
Definition: Setup.h:153
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
TTBV maybePattern(int binEta, int binZT, int binCot) const
std::vector< FrameTrack > StreamTrack
Definition: TTTypes.h:64
double dPhi(const TTStubRef &ttStubRef, double inv2R) const
Definition: Setup.cc:580
EDPutTokenT< StreamsStub > edPutTokenLostStubs_
Definition: ProducerKFin.cc:53
int numChannel(Process p) const
Definition: DataFormats.h:498
std::pair< TTTrackRef, Frame > FrameTrack
Definition: TTTypes.h:62
int iEvent
Definition: GenABIO.cc:224
int layerId(const TTStubRef &ttStubRef) const
Definition: Setup.cc:511
EDPutTokenT< StreamsTrack > edPutTokenLostTracks_
Definition: ProducerKFin.cc:56
bool configurationSupported() const
Definition: Setup.h:60
int numLayers() const
Definition: Setup.h:215
EDGetTokenT< vector< TTTrack< Ref_Phase2TrackerDigi_ > > > edGetTokenTTTracks_
Definition: ProducerKFin.cc:48
EDPutTokenT< StreamsTrack > edPutTokenAcceptedTracks_
Definition: ProducerKFin.cc:55
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
int numStreamsTracks(Process p) const
Definition: DataFormats.h:504
int zhtMaxStubsPerLayer() const
Definition: Setup.h:477
int numRegions() const
Definition: Setup.h:349
int numStreamsStubs(Process p) const
Definition: DataFormats.h:502
EDPutTokenT< StreamsStub > edPutTokenAcceptedStubs_
Definition: ProducerKFin.cc:52
const int layerIdKF(int binEta, int binZT, int binCot, int layerId) const
edm::Ref< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > >, TTTrack< Ref_Phase2TrackerDigi_ > > TTTrackRef
Definition: TTTypes.h:51
double sectorCot(int eta) const
Definition: Setup.h:432
EDGetTokenT< StreamsStub > edGetTokenStubs_
Definition: ProducerKFin.cc:50
def move(src, dest)
Definition: eostools.py:511
const LayerEncoding * layerEncoding_
Definition: ProducerKFin.cc:70
const DataFormat & format(Variable v, Process p) const
Definition: DataFormats.h:506

Member Data Documentation

◆ dataFormats_

const DataFormats* trackerTFP::ProducerKFin::dataFormats_ = nullptr
private

Definition at line 68 of file ProducerKFin.cc.

Referenced by beginRun(), and produce().

◆ edGetTokenStubs_

EDGetTokenT<StreamsStub> trackerTFP::ProducerKFin::edGetTokenStubs_
private

Definition at line 50 of file ProducerKFin.cc.

Referenced by produce(), and ProducerKFin().

◆ edGetTokenTTTracks_

EDGetTokenT<vector<TTTrack<Ref_Phase2TrackerDigi_> > > trackerTFP::ProducerKFin::edGetTokenTTTracks_
private

Definition at line 48 of file ProducerKFin.cc.

Referenced by produce(), and ProducerKFin().

◆ edPutTokenAcceptedStubs_

EDPutTokenT<StreamsStub> trackerTFP::ProducerKFin::edPutTokenAcceptedStubs_
private

Definition at line 52 of file ProducerKFin.cc.

Referenced by produce(), and ProducerKFin().

◆ edPutTokenAcceptedTracks_

EDPutTokenT<StreamsTrack> trackerTFP::ProducerKFin::edPutTokenAcceptedTracks_
private

Definition at line 55 of file ProducerKFin.cc.

Referenced by produce(), and ProducerKFin().

◆ edPutTokenLostStubs_

EDPutTokenT<StreamsStub> trackerTFP::ProducerKFin::edPutTokenLostStubs_
private

Definition at line 53 of file ProducerKFin.cc.

Referenced by produce(), and ProducerKFin().

◆ edPutTokenLostTracks_

EDPutTokenT<StreamsTrack> trackerTFP::ProducerKFin::edPutTokenLostTracks_
private

Definition at line 56 of file ProducerKFin.cc.

Referenced by produce(), and ProducerKFin().

◆ enableTruncation_

bool trackerTFP::ProducerKFin::enableTruncation_
private

Definition at line 72 of file ProducerKFin.cc.

Referenced by produce(), and ProducerKFin().

◆ esGetTokenDataFormats_

ESGetToken<DataFormats, DataFormatsRcd> trackerTFP::ProducerKFin::esGetTokenDataFormats_
private

Definition at line 60 of file ProducerKFin.cc.

Referenced by beginRun(), and ProducerKFin().

◆ esGetTokenLayerEncoding_

ESGetToken<LayerEncoding, LayerEncodingRcd> trackerTFP::ProducerKFin::esGetTokenLayerEncoding_
private

Definition at line 62 of file ProducerKFin.cc.

Referenced by beginRun(), and ProducerKFin().

◆ esGetTokenSetup_

ESGetToken<Setup, SetupRcd> trackerTFP::ProducerKFin::esGetTokenSetup_
private

Definition at line 58 of file ProducerKFin.cc.

Referenced by beginRun(), and ProducerKFin().

◆ iConfig_

ParameterSet trackerTFP::ProducerKFin::iConfig_
private

Definition at line 64 of file ProducerKFin.cc.

Referenced by beginRun().

◆ layerEncoding_

const LayerEncoding* trackerTFP::ProducerKFin::layerEncoding_ = nullptr
private

Definition at line 70 of file ProducerKFin.cc.

Referenced by beginRun(), and produce().

◆ setup_

const Setup* trackerTFP::ProducerKFin::setup_ = nullptr
private