CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
trklet::ProducerTBout Class Reference

Transforms TTTracks and Streams from Tracklet pattern reco. into StreamsTrack by adding to the digitised track stream a reference to the corresponding TTTrack. (Could not be done in previous L1TrackFPGAProducer, as single EDProducer can't produce output containing both an EDProduct and refs to that product). Writes Tracks & stubs rejected/kept after truncation to separate StreamsTrack & StreamsStub branches. More...

Inheritance diagram for trklet::ProducerTBout:
edm::stream::EDProducer<>

Public Member Functions

 ProducerTBout (const ParameterSet &)
 
 ~ProducerTBout () 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

ChannelAssignmentchannelAssignment_ = nullptr
 
const DataFormatsdataFormats_ = nullptr
 
EDGetTokenT< StreamsStubedGetTokenStubs_
 
EDGetTokenT< StreamsedGetTokenTracks_
 
EDGetTokenT< TTTracksedGetTokenTTTracks_
 
EDPutTokenT< StreamsStubedPutTokenAcceptedStubs_
 
EDPutTokenT< StreamsTrackedPutTokenAcceptedTracks_
 
EDPutTokenT< StreamsStubedPutTokenLostStubs_
 
EDPutTokenT< StreamsTrackedPutTokenLostTracks_
 
bool enableTruncation_
 
ESGetToken< ChannelAssignment, ChannelAssignmentRcdesGetTokenChannelAssignment_
 
ESGetToken< DataFormats, DataFormatsRcdesGetTokenDataFormats_
 
ESGetToken< Setup, SetupRcdesGetTokenSetup_
 
ParameterSet iConfig_
 
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 and Streams from Tracklet pattern reco. into StreamsTrack by adding to the digitised track stream a reference to the corresponding TTTrack. (Could not be done in previous L1TrackFPGAProducer, as single EDProducer can't produce output containing both an EDProduct and refs to that product). Writes Tracks & stubs rejected/kept after truncation to separate StreamsTrack & StreamsStub branches.

Author
Thomas Schuh
Date
2021, Oct

Definition at line 40 of file ProducerTBout.cc.

Constructor & Destructor Documentation

◆ ProducerTBout()

trklet::ProducerTBout::ProducerTBout ( const ParameterSet iConfig)
explicit

Definition at line 80 of file ProducerTBout.cc.

References edGetTokenStubs_, edGetTokenTracks_, edGetTokenTTTracks_, edPutTokenAcceptedStubs_, edPutTokenAcceptedTracks_, edPutTokenLostStubs_, edPutTokenLostTracks_, enableTruncation_, esGetTokenChannelAssignment_, esGetTokenDataFormats_, esGetTokenSetup_, edm::ParameterSet::getParameter(), and SimL1EmulatorRepack_Full_cff::inputTag.

80  : iConfig_(iConfig) {
81  const InputTag& inputTag = iConfig.getParameter<InputTag>("InputTag");
82  const string& branchAcceptedStubs = iConfig.getParameter<string>("BranchAcceptedStubs");
83  const string& branchAcceptedTracks = iConfig.getParameter<string>("BranchAcceptedTracks");
84  const string& branchLostStubs = iConfig.getParameter<string>("BranchLostStubs");
85  const string& branchLostTracks = iConfig.getParameter<string>("BranchLostTracks");
86  // book in- and output ED products
87  edGetTokenTTTracks_ = consumes<TTTracks>(inputTag);
88  edGetTokenTracks_ = consumes<Streams>(inputTag);
89  edGetTokenStubs_ = consumes<StreamsStub>(inputTag);
90  edPutTokenAcceptedStubs_ = produces<StreamsStub>(branchAcceptedStubs);
91  edPutTokenAcceptedTracks_ = produces<StreamsTrack>(branchAcceptedTracks);
92  edPutTokenLostStubs_ = produces<StreamsStub>(branchLostStubs);
93  edPutTokenLostTracks_ = produces<StreamsTrack>(branchLostTracks);
94  // book ES products
95  esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
96  esGetTokenDataFormats_ = esConsumes<DataFormats, DataFormatsRcd, Transition::BeginRun>();
97  esGetTokenChannelAssignment_ = esConsumes<ChannelAssignment, ChannelAssignmentRcd, Transition::BeginRun>();
98  //
99  enableTruncation_ = iConfig.getParameter<bool>("EnableTruncation");
100  }
EDGetTokenT< StreamsStub > edGetTokenStubs_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EDGetTokenT< TTTracks > edGetTokenTTTracks_
EDPutTokenT< StreamsTrack > edPutTokenLostTracks_
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
EDPutTokenT< StreamsStub > edPutTokenLostStubs_
ESGetToken< ChannelAssignment, ChannelAssignmentRcd > esGetTokenChannelAssignment_
EDPutTokenT< StreamsTrack > edPutTokenAcceptedTracks_
EDGetTokenT< Streams > edGetTokenTracks_
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
EDPutTokenT< StreamsStub > edPutTokenAcceptedStubs_

◆ ~ProducerTBout()

trklet::ProducerTBout::~ProducerTBout ( )
inlineoverride

Definition at line 43 of file ProducerTBout.cc.

43 {}

Member Function Documentation

◆ beginRun()

void trklet::ProducerTBout::beginRun ( const Run iRun,
const EventSetup iSetup 
)
overrideprivate

Definition at line 102 of file ProducerTBout.cc.

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

102  {
103  // helper class to store configurations
104  setup_ = &iSetup.getData(esGetTokenSetup_);
106  return;
107  // check process history if desired
108  if (iConfig_.getParameter<bool>("CheckHistory"))
110  // helper class to extract structured data from tt::Frames
112  // helper class to assign tracks to channel
114  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
ESGetToken< DataFormats, DataFormatsRcd > esGetTokenDataFormats_
ESGetToken< ChannelAssignment, ChannelAssignmentRcd > esGetTokenChannelAssignment_
ChannelAssignment * channelAssignment_
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:238
const Setup * setup_
ESGetToken< Setup, SetupRcd > esGetTokenSetup_
const DataFormats * dataFormats_

◆ endJob()

virtual void trklet::ProducerTBout::endJob ( void  )
inlineprivatevirtual

Definition at line 48 of file ProducerTBout.cc.

48 {}

◆ produce()

void trklet::ProducerTBout::produce ( Event iEvent,
const EventSetup iSetup 
)
overrideprivate

Definition at line 116 of file ProducerTBout.cc.

References channelAssignment_, trklet::ChannelAssignment::channelId(), totem::nt2::vfat::channelId(), tt::Setup::configurationSupported(), HLT_2022v15_cff::distance, edGetTokenStubs_, edGetTokenTracks_, edGetTokenTTTracks_, edPutTokenAcceptedStubs_, edPutTokenAcceptedTracks_, edPutTokenLostStubs_, edPutTokenLostTracks_, enableTruncation_, cppFunctionSkipper::exception, f, amptDefault_cfi::frame, mps_fire::i, iEvent, createfilelist::int, remoteMonitoring_LASER_era2018_cfg::limit, eostools::move(), GetRecoTauVFromDQM_MC_cff::next, BeamSpotPI::nTracks, trklet::ChannelAssignment::numChannelsStub(), trklet::ChannelAssignment::numChannelsTrack(), tt::Setup::numFrames(), tt::Setup::numRegions(), push_back(), HLT_2022v15_cff::region, setup_, and HcalDetIdTransform::transform().

116  {
117  const int numStreamsTracks = setup_->numRegions() * channelAssignment_->numChannelsTrack();
118  const int numStreamsStubs = setup_->numRegions() * channelAssignment_->numChannelsStub();
119  // empty KFin products
120  StreamsStub streamAcceptedStubs(numStreamsStubs);
121  StreamsTrack streamAcceptedTracks(numStreamsTracks);
122  StreamsStub streamLostStubs(numStreamsStubs);
123  StreamsTrack streamLostTracks(numStreamsTracks);
124  // read in hybrid track finding product and produce KFin product
126  // create and structure TTrackRefs in h/w channel
127  vector<deque<TTTrackRef>> ttTrackRefs(numStreamsTracks);
128  Handle<TTTracks> handleTTTracks;
129  iEvent.getByToken<TTTracks>(edGetTokenTTTracks_, handleTTTracks);
130  int channelId(-1);
131  for (int i = 0; i < (int)handleTTTracks->size(); i++) {
132  const TTTrackRef ttTrackRef(handleTTTracks, i);
133  if (channelAssignment_->channelId(ttTrackRef, channelId))
134  ttTrackRefs[channelId].push_back(ttTrackRef);
135  }
136  // get and trunacte tracks
137  Handle<Streams> handleTracks;
138  iEvent.getByToken<Streams>(edGetTokenTracks_, handleTracks);
139  channelId = 0;
140  for (const Stream& streamTrack : *handleTracks) {
141  const int nTracks = accumulate(
142  streamTrack.begin(), streamTrack.end(), 0, [](int& sum, const Frame& f) { return sum += f.any() ? 1 : 0; });
143  StreamTrack& accepted = streamAcceptedTracks[channelId];
144  StreamTrack& lost = streamLostTracks[channelId];
145  auto limit = streamTrack.end();
146  if (enableTruncation_ && (int)streamTrack.size() > setup_->numFrames())
147  limit = next(streamTrack.begin(), setup_->numFrames());
148  accepted.reserve(distance(streamTrack.begin(), limit));
149  lost.reserve(distance(limit, streamTrack.end()));
150  int nFrame(0);
151  const deque<TTTrackRef>& ttTracks = ttTrackRefs[channelId++];
152  if ((int)ttTracks.size() != nTracks) {
153  cms::Exception exception("LogicError.");
155  const int channel = channelId % channelAssignment_->numChannelsTrack();
156  exception << "Region " << region << " output channel " << channel << " has " << nTracks
157  << " tracks found but created " << ttTracks.size() << " TTTracks.";
158  exception.addContext("trklet::ProducerTBout::produce");
159  throw exception;
160  }
161  auto toFrameTrack = [&nFrame, &ttTracks](const Frame& frame) {
162  if (frame.any())
163  return FrameTrack(ttTracks[nFrame++], frame);
164  return FrameTrack();
165  };
166  transform(streamTrack.begin(), limit, back_inserter(accepted), toFrameTrack);
167  transform(limit, streamTrack.end(), back_inserter(lost), toFrameTrack);
168  }
169  // get and trunacte stubs
170  Handle<StreamsStub> handleStubs;
171  iEvent.getByToken<StreamsStub>(edGetTokenStubs_, handleStubs);
172  const StreamsStub& streamsStub = *handleStubs;
173  // reserve output ed products
174  channelId = 0;
175  for (const StreamStub& streamStub : streamsStub) {
176  auto limit = streamStub.end();
177  if (enableTruncation_ && (int)streamStub.size() > setup_->numFrames())
178  limit = next(streamStub.begin(), setup_->numFrames());
179  streamAcceptedStubs[channelId] = StreamStub(streamStub.begin(), limit);
180  streamLostStubs[channelId++] = StreamStub(limit, streamStub.end());
181  }
182  }
183  // store products
184  iEvent.emplace(edPutTokenAcceptedStubs_, move(streamAcceptedStubs));
185  iEvent.emplace(edPutTokenAcceptedTracks_, move(streamAcceptedTracks));
186  iEvent.emplace(edPutTokenLostStubs_, move(streamLostStubs));
187  iEvent.emplace(edPutTokenLostTracks_, move(streamLostTracks));
188  }
EDGetTokenT< StreamsStub > edGetTokenStubs_
std::bitset< TTBV::S_ > Frame
Definition: TTTypes.h:58
std::vector< StreamTrack > StreamsTrack
Definition: TTTypes.h:67
std::vector< StreamStub > StreamsStub
Definition: TTTypes.h:66
EDGetTokenT< TTTracks > edGetTokenTTTracks_
std::vector< FrameStub > StreamStub
Definition: TTTypes.h:63
EDPutTokenT< StreamsTrack > edPutTokenLostTracks_
int numFrames() const
Definition: Setup.h:153
EDPutTokenT< StreamsStub > edPutTokenLostStubs_
std::vector< FrameTrack > StreamTrack
Definition: TTTypes.h:64
bool channelId(const TTTrackRef &ttTrackRef, int &channelId)
std::pair< TTTrackRef, Frame > FrameTrack
Definition: TTTypes.h:62
int iEvent
Definition: GenABIO.cc:224
ChannelAssignment * channelAssignment_
bool configurationSupported() const
Definition: Setup.h:60
double f[11][100]
EDPutTokenT< StreamsTrack > edPutTokenAcceptedTracks_
std::vector< Frame > Stream
Definition: TTTypes.h:65
uint8_t channelId(const VFATFrame &frame)
retrieve this channel identifier
EDGetTokenT< Streams > edGetTokenTracks_
const Setup * setup_
std::vector< Stream > Streams
Definition: TTTypes.h:68
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
int numRegions() const
Definition: Setup.h:345
std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > TTTracks
Definition: TTTypes.h:70
EDPutTokenT< StreamsStub > edPutTokenAcceptedStubs_
def move(src, dest)
Definition: eostools.py:511
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Data Documentation

◆ channelAssignment_

ChannelAssignment* trklet::ProducerTBout::channelAssignment_ = nullptr
private

Definition at line 75 of file ProducerTBout.cc.

Referenced by beginRun(), and produce().

◆ dataFormats_

const DataFormats* trklet::ProducerTBout::dataFormats_ = nullptr
private

Definition at line 73 of file ProducerTBout.cc.

Referenced by beginRun().

◆ edGetTokenStubs_

EDGetTokenT<StreamsStub> trklet::ProducerTBout::edGetTokenStubs_
private

Definition at line 55 of file ProducerTBout.cc.

Referenced by produce(), and ProducerTBout().

◆ edGetTokenTracks_

EDGetTokenT<Streams> trklet::ProducerTBout::edGetTokenTracks_
private

Definition at line 53 of file ProducerTBout.cc.

Referenced by produce(), and ProducerTBout().

◆ edGetTokenTTTracks_

EDGetTokenT<TTTracks> trklet::ProducerTBout::edGetTokenTTTracks_
private

Definition at line 51 of file ProducerTBout.cc.

Referenced by produce(), and ProducerTBout().

◆ edPutTokenAcceptedStubs_

EDPutTokenT<StreamsStub> trklet::ProducerTBout::edPutTokenAcceptedStubs_
private

Definition at line 57 of file ProducerTBout.cc.

Referenced by produce(), and ProducerTBout().

◆ edPutTokenAcceptedTracks_

EDPutTokenT<StreamsTrack> trklet::ProducerTBout::edPutTokenAcceptedTracks_
private

Definition at line 60 of file ProducerTBout.cc.

Referenced by produce(), and ProducerTBout().

◆ edPutTokenLostStubs_

EDPutTokenT<StreamsStub> trklet::ProducerTBout::edPutTokenLostStubs_
private

Definition at line 58 of file ProducerTBout.cc.

Referenced by produce(), and ProducerTBout().

◆ edPutTokenLostTracks_

EDPutTokenT<StreamsTrack> trklet::ProducerTBout::edPutTokenLostTracks_
private

Definition at line 61 of file ProducerTBout.cc.

Referenced by produce(), and ProducerTBout().

◆ enableTruncation_

bool trklet::ProducerTBout::enableTruncation_
private

Definition at line 77 of file ProducerTBout.cc.

Referenced by produce(), and ProducerTBout().

◆ esGetTokenChannelAssignment_

ESGetToken<ChannelAssignment, ChannelAssignmentRcd> trklet::ProducerTBout::esGetTokenChannelAssignment_
private

Definition at line 67 of file ProducerTBout.cc.

Referenced by beginRun(), and ProducerTBout().

◆ esGetTokenDataFormats_

ESGetToken<DataFormats, DataFormatsRcd> trklet::ProducerTBout::esGetTokenDataFormats_
private

Definition at line 65 of file ProducerTBout.cc.

Referenced by beginRun(), and ProducerTBout().

◆ esGetTokenSetup_

ESGetToken<Setup, SetupRcd> trklet::ProducerTBout::esGetTokenSetup_
private

Definition at line 63 of file ProducerTBout.cc.

Referenced by beginRun(), and ProducerTBout().

◆ iConfig_

ParameterSet trklet::ProducerTBout::iConfig_
private

Definition at line 69 of file ProducerTBout.cc.

Referenced by beginRun().

◆ setup_

const Setup* trklet::ProducerTBout::setup_ = nullptr
private