CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1FPGATrackProducer Class Reference
Inheritance diagram for L1FPGATrackProducer:
edm::one::EDProducer< edm::one::WatchRuns > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1FPGATrackProducer (const edm::ParameterSet &iConfig)
 Constructor/destructor. More...
 
 ~L1FPGATrackProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::WatchRuns >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
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
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector
< edm::ProductResolverIndex >
const & 
putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginRun (const edm::Run &run, const edm::EventSetup &iSetup) override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 

Private Attributes

std::ofstream asciiEventOut_
 
string asciiEventOutName_
 
const edm::EDGetTokenT
< reco::BeamSpot
bsToken_
 
edm::ParameterSet config
 Containers of parameters passed by python configuration file. More...
 
std::map< string, vector< int > > dtclayerdisk
 
edm::ESGetToken
< trackerDTC::Setup,
trackerDTC::SetupRcd
esGetToken_
 
int eventnum
 
trklet::TrackletEventProcessor eventProcessor
 
bool extended_
 
edm::FileInPath fitPatternFile
 File path for configuration files. More...
 
const edm::ESGetToken
< MagneticField,
IdealMagneticFieldRecord
magneticFieldToken_
 
edm::InputTag MCTruthClusterInputTag
 
edm::InputTag MCTruthStubInputTag
 
edm::FileInPath memoryModulesFile
 
unsigned int nHelixPar_
 
edm::FileInPath processingModulesFile
 
bool readMoreMcTruth_
 
trklet::Settings settings
 
trackerDTC::Setup setup_
 
edm::FileInPath tableTEDFile
 
edm::FileInPath tableTREFile
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
tGeomToken_
 
edm::EDGetTokenT< TTDTCtokenDTC_
 
edm::InputTag TrackingParticleInputTag
 
edm::EDGetTokenT< std::vector
< TrackingParticle > > 
TrackingParticleToken_
 
bool trackQuality_
 
std::unique_ptr< TrackQualitytrackQualityModel_
 
edm::EDGetTokenT
< TTClusterAssociationMap
< Ref_Phase2TrackerDigi_ > > 
ttClusterMCTruthToken_
 
const edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
tTopoToken_
 
edm::FileInPath wiresFile
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 133 of file L1FPGATrackProducer.cc.

Constructor & Destructor Documentation

L1FPGATrackProducer::L1FPGATrackProducer ( const edm::ParameterSet iConfig)
explicit

Constructor/destructor.

Definition at line 202 of file L1FPGATrackProducer.cc.

References asciiEventOut_, asciiEventOutName_, trklet::Settings::debugTracklet(), esGetToken_, eventnum, extended_, fitPatternFile, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), MCTruthClusterInputTag, memoryModulesFile, nHelixPar_, processingModulesFile, readMoreMcTruth_, trklet::Settings::setExtended(), trklet::Settings::setFitPatternFile(), trklet::Settings::setMemoryModulesFile(), trklet::Settings::setNbitstrackletindex(), trklet::Settings::setNHelixPar(), trklet::Settings::setProcessingModulesFile(), trklet::Settings::setTableTEDFile(), trklet::Settings::setTableTREFile(), settings, trklet::Settings::setWiresFile(), tableTEDFile, tableTREFile, TrackingParticleInputTag, TrackingParticleToken_, trackQuality_, trackQualityModel_, ttClusterMCTruthToken_, and wiresFile.

203  : config(iConfig),
204  readMoreMcTruth_(iConfig.getParameter<bool>("readMoreMcTruth")),
206  : edm::InputTag()),
208  : edm::InputTag()),
209  TrackingParticleInputTag(readMoreMcTruth_ ? iConfig.getParameter<edm::InputTag>("TrackingParticleInputTag")
210  : edm::InputTag()),
211  bsToken_(consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("BeamSpotSource"))),
212  tokenDTC_(consumes<TTDTC>(edm::InputTag(iConfig.getParameter<edm::InputTag>("InputTagTTDTC")))),
213  magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()),
216  if (readMoreMcTruth_) {
217  ttClusterMCTruthToken_ = consumes<TTClusterAssociationMap<Ref_Phase2TrackerDigi_>>(MCTruthClusterInputTag);
218  TrackingParticleToken_ = consumes<std::vector<TrackingParticle>>(TrackingParticleInputTag);
219  }
220 
221  produces<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>("Level1TTTracks").setBranchAlias("Level1TTTracks");
222 
223  asciiEventOutName_ = iConfig.getUntrackedParameter<string>("asciiFileName", "");
224 
225  fitPatternFile = iConfig.getParameter<edm::FileInPath>("fitPatternFile");
226  processingModulesFile = iConfig.getParameter<edm::FileInPath>("processingModulesFile");
227  memoryModulesFile = iConfig.getParameter<edm::FileInPath>("memoryModulesFile");
228  wiresFile = iConfig.getParameter<edm::FileInPath>("wiresFile");
229 
230  extended_ = iConfig.getParameter<bool>("Extended");
231  nHelixPar_ = iConfig.getParameter<unsigned int>("Hnpar");
232 
233  if (extended_) {
234  tableTEDFile = iConfig.getParameter<edm::FileInPath>("tableTEDFile");
235  tableTREFile = iConfig.getParameter<edm::FileInPath>("tableTREFile");
236  }
237 
238  // book ES product
239  esGetToken_ = esConsumes<trackerDTC::Setup, trackerDTC::SetupRcd, edm::Transition::BeginRun>();
240 
241  // --------------------------------------------------------------------------------
242  // set options in Settings based on inputs from configuration files
243  // --------------------------------------------------------------------------------
244 
245  settings.setExtended(extended_);
246  settings.setNHelixPar(nHelixPar_);
247 
248  settings.setFitPatternFile(fitPatternFile.fullPath());
249  settings.setProcessingModulesFile(processingModulesFile.fullPath());
250  settings.setMemoryModulesFile(memoryModulesFile.fullPath());
251  settings.setWiresFile(wiresFile.fullPath());
252 
253  if (extended_) {
256 
257  //FIXME: The TED and TRE tables are currently disabled by default, so we
258  //need to allow for the additional tracklets that will eventually be
259  //removed by these tables, once they are finalized
261  }
262 
263  eventnum = 0;
264  if (not asciiEventOutName_.empty()) {
265  asciiEventOut_.open(asciiEventOutName_.c_str());
266  }
267 
268  if (settings.debugTracklet()) {
269  edm::LogVerbatim("Tracklet") << "fit pattern : " << fitPatternFile.fullPath()
270  << "\n process modules : " << processingModulesFile.fullPath()
271  << "\n memory modules : " << memoryModulesFile.fullPath()
272  << "\n wires : " << wiresFile.fullPath();
273  if (extended_) {
274  edm::LogVerbatim("Tracklet") << "table_TED : " << tableTEDFile.fullPath()
275  << "\n table_TRE : " << tableTREFile.fullPath();
276  }
277  }
278 
279  trackQuality_ = iConfig.getParameter<bool>("TrackQuality");
280  if (trackQuality_) {
281  trackQualityModel_ = std::make_unique<TrackQuality>(iConfig.getParameter<edm::ParameterSet>("TrackQualityPSet"));
282  }
283 }
Log< level::Info, true > LogVerbatim
void setMemoryModulesFile(std::string memoryModulesFileName)
Definition: Settings.h:77
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag MCTruthStubInputTag
edm::FileInPath tableTREFile
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
void setFitPatternFile(std::string fitPatternFileName)
Definition: Settings.h:73
edm::InputTag MCTruthClusterInputTag
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
bool debugTracklet() const
Definition: Settings.h:182
edm::FileInPath tableTEDFile
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
edm::EDGetTokenT< TTDTC > tokenDTC_
edm::FileInPath processingModulesFile
edm::EDGetTokenT< TTClusterAssociationMap< Ref_Phase2TrackerDigi_ > > ttClusterMCTruthToken_
trklet::Settings settings
edm::EDGetTokenT< std::vector< TrackingParticle > > TrackingParticleToken_
std::unique_ptr< TrackQuality > trackQualityModel_
edm::InputTag TrackingParticleInputTag
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
void setProcessingModulesFile(std::string processingModulesFileName)
Definition: Settings.h:74
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::FileInPath memoryModulesFile
edm::ESGetToken< trackerDTC::Setup, trackerDTC::SetupRcd > esGetToken_
edm::FileInPath fitPatternFile
File path for configuration files.
void setNbitstrackletindex(unsigned int nbitstrackletindex)
Definition: Settings.h:272
void setNHelixPar(unsigned int nHelixPar)
Definition: Settings.h:246
std::string fullPath() const
Definition: FileInPath.cc:161
void setWiresFile(std::string wiresFileName)
Definition: Settings.h:78
void setTableTREFile(std::string tableTREFileName)
Definition: Settings.h:80
edm::ParameterSet config
Containers of parameters passed by python configuration file.
void setTableTEDFile(std::string tableTEDFileName)
Definition: Settings.h:79
void setExtended(bool extended)
Definition: Settings.h:249
L1FPGATrackProducer::~L1FPGATrackProducer ( )
override

Definition at line 287 of file L1FPGATrackProducer.cc.

References asciiEventOut_.

287  {
288  if (asciiEventOut_.is_open()) {
289  asciiEventOut_.close();
290  }
291 }

Member Function Documentation

void L1FPGATrackProducer::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprivate

///////////////// /// MANDATORY METHODS ///

Definition at line 299 of file L1FPGATrackProducer.cc.

References esGetToken_, eventProcessor, edm::EventSetup::getData(), trklet::TrackletEventProcessor::init(), MagneticField::inTesla(), magneticFieldToken_, trklet::Settings::setBfield(), settings, setup_, and PV3DBase< T, PVType, FrameType >::z().

299  {
301  // GET MAGNETIC FIELD //
302  const MagneticField* theMagneticField = &iSetup.getData(magneticFieldToken_);
303  double mMagneticFieldStrength = theMagneticField->inTesla(GlobalPoint(0, 0, 0)).z();
304  settings.setBfield(mMagneticFieldStrength);
305 
306  setup_ = iSetup.getData(esGetToken_);
307 
308  // initialize the tracklet event processing (this sets all the processing & memory modules, wiring, etc)
310 }
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
trklet::TrackletEventProcessor eventProcessor
bool getData(T &iHolder) const
Definition: EventSetup.h:128
void init(Settings const &theSettings)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
T z() const
Definition: PV3DBase.h:61
trklet::Settings settings
edm::ESGetToken< trackerDTC::Setup, trackerDTC::SetupRcd > esGetToken_
void setBfield(double bfield)
Definition: Settings.h:254
trackerDTC::Setup setup_
void L1FPGATrackProducer::endRun ( edm::Run const &  run,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 295 of file L1FPGATrackProducer.cc.

295 {}
void L1FPGATrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Prepare output

LOOP OVER TRACKING PARTICLES & GET SIMTRACKS

READ DTC STUB INFORMATION ///

Get the Inner and Outer TTCluster

Implements edm::one::EDProducerBase.

Definition at line 314 of file L1FPGATrackProducer.cc.

References funct::abs(), trklet::SLHCEvent::addL1SimTrack(), trklet::SLHCEvent::addStub(), asciiEventOut_, asciiEventOutName_, cms::cuda::assert(), trklet::Settings::bfield(), bsToken_, trackerDTC::Setup::dtcId(), ev, trklet::TrackletEventProcessor::event(), eventnum, eventProcessor, edm::Event::getByToken(), StubPtConsistency::getConsistency(), edm::EventSetup::getData(), mps_fire::i, TrackerGeometry::idToDetUnit(), trklet::SLHCEvent::lastStub(), Topology::localPosition(), PV3DBase< T, PVType, FrameType >::mag(), eostools::move(), trklet::Settings::nHelixPar(), trackerDTC::Setup::psModule(), edm::Event::put(), readMoreMcTruth_, HLT_FULL_cff::region, trklet::SLHCEvent::setEventNum(), trklet::SLHCEvent::setIP(), settings, setup_, trackerDTC::Setup::stubPos(), tGeomToken_, tokenDTC_, HLT_FULL_cff::track, TrackingParticleToken_, trackQuality_, trackQualityModel_, trklet::TrackletEventProcessor::tracks(), tracks, ttClusterMCTruthToken_, tTopoToken_, hgcalPerformanceValidation::val, trklet::SLHCEvent::write(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

314  {
315  typedef std::map<trklet::L1TStub,
318  stubMapType;
320  TTClusterRef;
321 
323  auto L1TkTracksForOutput = std::make_unique<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>();
324 
325  stubMapType stubMap;
326 
328  // GET BS //
329  edm::Handle<reco::BeamSpot> beamSpotHandle;
330  iEvent.getByToken(bsToken_, beamSpotHandle);
331  math::XYZPoint bsPosition = beamSpotHandle->position();
332 
333  eventnum++;
335  ev.setEventNum(eventnum);
336  ev.setIP(bsPosition.x(), bsPosition.y());
337 
338  // tracking particles
339  edm::Handle<std::vector<TrackingParticle>> TrackingParticleHandle;
340  if (readMoreMcTruth_)
341  iEvent.getByToken(TrackingParticleToken_, TrackingParticleHandle);
342 
343  // tracker topology
344  const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken_);
345  const TrackerGeometry* const theTrackerGeom = &iSetup.getData(tGeomToken_);
346 
348  // GET THE PRIMITIVES //
349  edm::Handle<TTDTC> handleDTC;
350  iEvent.getByToken<TTDTC>(tokenDTC_, handleDTC);
351 
352  // must be defined for code to compile, even if it's not used unless readMoreMcTruth_ is true
353  map<edm::Ptr<TrackingParticle>, int> translateTP;
354 
355  // MC truth association maps
357  if (readMoreMcTruth_) {
358  iEvent.getByToken(ttClusterMCTruthToken_, MCTruthTTClusterHandle);
359 
362 
363  int ntps = 1; //count from 1 ; 0 will mean invalid
364 
365  int this_tp = 0;
366  for (const auto& iterTP : *TrackingParticleHandle) {
367  edm::Ptr<TrackingParticle> tp_ptr(TrackingParticleHandle, this_tp);
368  this_tp++;
369 
370  // only keep TPs producing a cluster
371  if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
372  continue;
373 
374  if (iterTP.g4Tracks().empty()) {
375  continue;
376  }
377 
378  int sim_eventid = iterTP.g4Tracks().at(0).eventId().event();
379  int sim_type = iterTP.pdgId();
380  float sim_pt = iterTP.pt();
381  float sim_eta = iterTP.eta();
382  float sim_phi = iterTP.phi();
383 
384  float vx = iterTP.vertex().x();
385  float vy = iterTP.vertex().y();
386  float vz = iterTP.vertex().z();
387 
388  if (sim_pt < 1.0 || std::abs(vz) > 100.0 || hypot(vx, vy) > 50.0)
389  continue;
390 
391  ev.addL1SimTrack(sim_eventid, ntps, sim_type, sim_pt, sim_eta, sim_phi, vx, vy, vz);
392 
393  translateTP[tp_ptr] = ntps;
394  ntps++;
395 
396  } //end loop over TPs
397 
398  } // end if (readMoreMcTruth_)
399 
403 
404  // Process stubs in each region and channel within that region
405  for (const int& region : handleDTC->tfpRegions()) {
406  for (const int& channel : handleDTC->tfpChannels()) {
407  // Get the DTC name form the channel
408 
409  static string dtcbasenames[12] = {
410  "PS10G_1", "PS10G_2", "PS10G_3", "PS10G_4", "PS_1", "PS_2", "2S_1", "2S_2", "2S_3", "2S_4", "2S_5", "2S_6"};
411 
412  string dtcname = dtcbasenames[channel % 12];
413 
414  if (channel % 24 >= 12)
415  dtcname = "neg" + dtcname;
416 
417  dtcname += (channel < 24) ? "_A" : "_B";
418 
419  // Get the stubs from the DTC
420  const TTDTC::Stream& streamFromDTC{handleDTC->stream(region, channel)};
421 
422  // Prepare the DTC stubs for the IR
423  for (size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) {
424  const TTDTC::Frame& stub{streamFromDTC[stubIndex]};
425 
426  if (stub.first.isNull()) {
427  continue;
428  }
429 
430  const GlobalPoint& ttPos = setup_.stubPos(stub.first);
431 
432  //Get the 2 bits for the layercode
433  string layerword = stub.second.to_string().substr(61, 2);
434  unsigned int layercode = 2 * (layerword[0] - '0') + layerword[1] - '0';
435  assert(layercode < 4);
436 
437  //translation from the two bit layercode to the layer/disk number of each of the
438  //12 channels (dtcs)
439  static int layerdisktab[12][4] = {{0, 6, 8, 10},
440  {0, 7, 9, -1},
441  {1, 7, -1, -1},
442  {6, 8, 10, -1},
443  {2, 7, -1, -1},
444  {2, 9, -1, -1},
445  {3, 4, -1, -1},
446  {4, -1, -1, -1},
447  {5, -1, -1, -1},
448  {5, 8, -1, -1},
449  {6, 9, -1, -1},
450  {7, 10, -1, -1}};
451 
452  int layerdisk = layerdisktab[channel % 12][layercode];
453  assert(layerdisk != -1);
454 
455  //Get the 36 bit word - skip the lowest 3 buts (status and layer code)
456  constexpr int DTCLinkWordSize = 64;
457  constexpr int StubWordSize = 36;
458  constexpr int LayerandStatusCodeSize = 3;
459  string stubword =
460  stub.second.to_string().substr(DTCLinkWordSize - StubWordSize - LayerandStatusCodeSize, StubWordSize);
461  string stubwordhex = "";
462 
463  //Loop over the 9 words in the 36 bit stub word
464  for (unsigned int i = 0; i < 9; i++) {
465  bitset<4> bits(stubword.substr(i * 4, 4));
466  ulong val = bits.to_ulong();
467  stubwordhex += ((val < 10) ? ('0' + val) : ('A' + val - 10));
468  }
469 
471  edm::Ref<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>, TTCluster<Ref_Phase2TrackerDigi_>>
472  innerCluster = stub.first->clusterRef(0);
473  edm::Ref<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>, TTCluster<Ref_Phase2TrackerDigi_>>
474  outerCluster = stub.first->clusterRef(1);
475 
476  // -----------------------------------------------------
477  // check module orientation, if flipped, need to store that information for track fit
478  // -----------------------------------------------------
479 
480  const DetId innerDetId = innerCluster->getDetId();
481  const GeomDetUnit* det_inner = theTrackerGeom->idToDetUnit(innerDetId);
482  const auto* theGeomDet_inner = dynamic_cast<const PixelGeomDetUnit*>(det_inner);
483  const PixelTopology* topol_inner = dynamic_cast<const PixelTopology*>(&(theGeomDet_inner->specificTopology()));
484 
485  MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered();
486  LocalPoint clustlp_inner = topol_inner->localPosition(coords_inner);
487  GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner);
488 
489  const DetId outerDetId = outerCluster->getDetId();
490  const GeomDetUnit* det_outer = theTrackerGeom->idToDetUnit(outerDetId);
491  const auto* theGeomDet_outer = dynamic_cast<const PixelGeomDetUnit*>(det_outer);
492  const PixelTopology* topol_outer = dynamic_cast<const PixelTopology*>(&(theGeomDet_outer->specificTopology()));
493 
494  MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered();
495  LocalPoint clustlp_outer = topol_outer->localPosition(coords_outer);
496  GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer);
497 
498  bool isFlipped = (posStub_outer.mag() < posStub_inner.mag());
499 
500  vector<int> assocTPs;
501 
502  for (unsigned int iClus = 0; iClus <= 1; iClus++) { // Loop over both clusters that make up stub.
503 
504  const TTClusterRef& ttClusterRef = stub.first->clusterRef(iClus);
505 
506  // Now identify all TP's contributing to either cluster in stub.
507  vector<edm::Ptr<TrackingParticle>> vecTpPtr = MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
508 
509  for (const edm::Ptr<TrackingParticle>& tpPtr : vecTpPtr) {
510  if (translateTP.find(tpPtr) != translateTP.end()) {
511  if (iClus == 0) {
512  assocTPs.push_back(translateTP.at(tpPtr));
513  } else {
514  assocTPs.push_back(-translateTP.at(tpPtr));
515  }
516  // N.B. Since not all tracking particles are stored in InputData::vTPs_, sometimes no match will be found.
517  } else {
518  assocTPs.push_back(0);
519  }
520  }
521  }
522 
523  double stubbend = stub.first->bendFE(); //stub.first->rawBend()
524  if (ttPos.z() < -120) {
525  stubbend = -stubbend;
526  }
527 
528  ev.addStub(dtcname,
529  region,
530  layerdisk,
531  stubwordhex,
532  setup_.psModule(setup_.dtcId(region, channel)),
533  isFlipped,
534  ttPos.x(),
535  ttPos.y(),
536  ttPos.z(),
537  stubbend,
538  stub.first->innerClusterPosition(),
539  assocTPs);
540 
541  const trklet::L1TStub& lastStub = ev.lastStub();
542  stubMap[lastStub] = stub.first;
543  }
544  }
545  }
546 
548  // NOW RUN THE L1 tracking
549 
550  if (!asciiEventOutName_.empty()) {
551  ev.write(asciiEventOut_);
552  }
553 
554  const std::vector<trklet::Track>& tracks = eventProcessor.tracks();
555 
556  // this performs the actual tracklet event processing
557  eventProcessor.event(ev);
558 
559  int ntracks = 0;
560 
561  for (const auto& track : tracks) {
562  if (track.duplicate())
563  continue;
564 
565  ntracks++;
566 
567  // this is where we create the TTTrack object
568  double tmp_rinv = track.rinv(settings);
569  double tmp_phi = track.phi0(settings);
570  double tmp_tanL = track.tanL(settings);
571  double tmp_z0 = track.z0(settings);
572  double tmp_d0 = track.d0(settings);
573  double tmp_chi2rphi = track.chisqrphi();
574  double tmp_chi2rz = track.chisqrz();
575  unsigned int tmp_hit = track.hitpattern();
576 
577  TTTrack<Ref_Phase2TrackerDigi_> aTrack(tmp_rinv,
578  tmp_phi,
579  tmp_tanL,
580  tmp_z0,
581  tmp_d0,
582  tmp_chi2rphi,
583  tmp_chi2rz,
584  0,
585  0,
586  0,
587  tmp_hit,
589  settings.bfield());
590 
591  unsigned int trksector = track.sector();
592  unsigned int trkseed = (unsigned int)abs(track.seed());
593 
594  aTrack.setPhiSector(trksector);
595  aTrack.setTrackSeedType(trkseed);
596 
597  const vector<trklet::L1TStub>& stubptrs = track.stubs();
598  vector<trklet::L1TStub> stubs;
599 
600  stubs.reserve(stubptrs.size());
601  for (const auto& stubptr : stubptrs) {
602  stubs.push_back(stubptr);
603  }
604 
605  stubMapType::const_iterator it;
606  for (const auto& itstubs : stubs) {
607  it = stubMap.find(itstubs);
608  if (it != stubMap.end()) {
609  aTrack.addStubRef(it->second);
610  } else {
611  // could not find stub in stub map
612  }
613  }
614 
615  // pt consistency
616  aTrack.setStubPtConsistency(
617  StubPtConsistency::getConsistency(aTrack, theTrackerGeom, tTopo, settings.bfield(), settings.nHelixPar()));
618 
619  // set TTTrack word
620  aTrack.setTrackWordBits();
621 
622  if (trackQuality_) {
623  trackQualityModel_->setTrackQuality(aTrack);
624  }
625 
626  // test track word
627  //aTrack.testTrackWordBits();
628 
629  L1TkTracksForOutput->push_back(aTrack);
630  }
631 
632  iEvent.put(std::move(L1TkTracksForOutput), "Level1TTTracks");
633 
634 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
unsigned int nHelixPar() const
Definition: Settings.h:245
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void write(std::ofstream &out)
Definition: SLHCEvent.cc:114
T y() const
Definition: PV3DBase.h:60
auto const & tracks
cannot be loose
trklet::TrackletEventProcessor eventProcessor
bool ev
std::vector< Frame > Stream
Definition: TTDTC.h:24
assert(be >=bs)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
GlobalPoint stubPos(bool hybrid, const TTDTC::Frame &frame, int tfpRegion, int tfpChannel) const
Definition: Setup.cc:615
void setIP(double x, double y)
Definition: SLHCEvent.h:46
bool getData(T &iHolder) const
Definition: EventSetup.h:128
T mag() const
Definition: PV3DBase.h:64
const std::vector< Track > & tracks() const
T z() const
Definition: PV3DBase.h:61
double bfield() const
Definition: Settings.h:253
def move
Definition: eostools.py:511
edm::EDGetTokenT< TTDTC > tokenDTC_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< TTClusterAssociationMap< Ref_Phase2TrackerDigi_ > > ttClusterMCTruthToken_
trklet::Settings settings
void setEventNum(int eventnum)
Definition: SLHCEvent.h:26
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
bool addStub(std::string DTClink, int region, int layerdisk, std::string stubword, int isPSmodule, int isFlipped, double x, double y, double z, double bend, double strip, std::vector< int > tps)
Definition: SLHCEvent.cc:13
edm::EDGetTokenT< std::vector< TrackingParticle > > TrackingParticleToken_
int dtcId(int tklId) const
Definition: Setup.cc:272
std::unique_ptr< TrackQuality > trackQualityModel_
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
Definition: DetId.h:17
std::pair< TTStubRef, BV > Frame
Definition: TTDTC.h:22
bool psModule(int dtcId) const
Definition: Setup.cc:300
NOTE: this is needed even if it seems not.
Definition: TTCluster.h:27
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
TTClusterRefT< Ref_Phase2TrackerDigi_ > TTClusterRef
Definition: TTTypes.h:44
Class to store hardware like structured TTStub Collection used by Track Trigger emulators.
Definition: TTDTC.h:17
const L1TStub & lastStub() const
Definition: SLHCEvent.h:44
void addL1SimTrack(int eventid, int trackid, int type, double pt, double eta, double phi, double vx, double vy, double vz)
Definition: SLHCEvent.cc:7
trackerDTC::Setup setup_
T x() const
Definition: PV3DBase.h:59
float getConsistency(TTTrack< Ref_Phase2TrackerDigi_ > aTrack, const TrackerGeometry *theTrackerGeom, const TrackerTopology *tTopo, double mMagneticFieldStrength, int nPar)

Member Data Documentation

std::ofstream L1FPGATrackProducer::asciiEventOut_
private

Definition at line 157 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer(), produce(), and ~L1FPGATrackProducer().

string L1FPGATrackProducer::asciiEventOutName_
private

Definition at line 156 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer(), and produce().

const edm::EDGetTokenT<reco::BeamSpot> L1FPGATrackProducer::bsToken_
private

Definition at line 177 of file L1FPGATrackProducer.cc.

Referenced by produce().

edm::ParameterSet L1FPGATrackProducer::config
private

Containers of parameters passed by python configuration file.

Definition at line 143 of file L1FPGATrackProducer.cc.

Referenced by zMuMuValidation.ZMuMuValidation::trackcollection().

std::map<string, vector<int> > L1FPGATrackProducer::dtclayerdisk
private

Definition at line 171 of file L1FPGATrackProducer.cc.

edm::ESGetToken<trackerDTC::Setup, trackerDTC::SetupRcd> L1FPGATrackProducer::esGetToken_
private

Definition at line 187 of file L1FPGATrackProducer.cc.

Referenced by beginRun(), and L1FPGATrackProducer().

int L1FPGATrackProducer::eventnum
private

Definition at line 140 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer(), and produce().

trklet::TrackletEventProcessor L1FPGATrackProducer::eventProcessor
private

Definition at line 163 of file L1FPGATrackProducer.cc.

Referenced by beginRun(), and produce().

bool L1FPGATrackProducer::extended_
private

Definition at line 166 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().

edm::FileInPath L1FPGATrackProducer::fitPatternFile
private

File path for configuration files.

Definition at line 148 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> L1FPGATrackProducer::magneticFieldToken_
private

Definition at line 188 of file L1FPGATrackProducer.cc.

Referenced by beginRun().

edm::InputTag L1FPGATrackProducer::MCTruthClusterInputTag
private

Definition at line 173 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().

edm::InputTag L1FPGATrackProducer::MCTruthStubInputTag
private

Definition at line 174 of file L1FPGATrackProducer.cc.

edm::FileInPath L1FPGATrackProducer::memoryModulesFile
private

Definition at line 149 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().

unsigned int L1FPGATrackProducer::nHelixPar_
private

Definition at line 165 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().

edm::FileInPath L1FPGATrackProducer::processingModulesFile
private

Definition at line 150 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().

bool L1FPGATrackProducer::readMoreMcTruth_
private

Definition at line 145 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer(), and produce().

trklet::Settings L1FPGATrackProducer::settings
private

Definition at line 160 of file L1FPGATrackProducer.cc.

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

trackerDTC::Setup L1FPGATrackProducer::setup_
private
edm::FileInPath L1FPGATrackProducer::tableTEDFile
private

Definition at line 153 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().

edm::FileInPath L1FPGATrackProducer::tableTREFile
private

Definition at line 154 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> L1FPGATrackProducer::tGeomToken_
private

Definition at line 190 of file L1FPGATrackProducer.cc.

Referenced by produce().

edm::EDGetTokenT<TTDTC> L1FPGATrackProducer::tokenDTC_
private

Definition at line 181 of file L1FPGATrackProducer.cc.

Referenced by produce().

edm::InputTag L1FPGATrackProducer::TrackingParticleInputTag
private

Definition at line 175 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().

edm::EDGetTokenT<std::vector<TrackingParticle> > L1FPGATrackProducer::TrackingParticleToken_
private

Definition at line 180 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer(), and produce().

bool L1FPGATrackProducer::trackQuality_
private

Definition at line 168 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer(), and produce().

std::unique_ptr<TrackQuality> L1FPGATrackProducer::trackQualityModel_
private

Definition at line 169 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer(), and produce().

edm::EDGetTokenT<TTClusterAssociationMap<Ref_Phase2TrackerDigi_> > L1FPGATrackProducer::ttClusterMCTruthToken_
private

Definition at line 179 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer(), and produce().

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> L1FPGATrackProducer::tTopoToken_
private

Definition at line 191 of file L1FPGATrackProducer.cc.

Referenced by produce().

edm::FileInPath L1FPGATrackProducer::wiresFile
private

Definition at line 151 of file L1FPGATrackProducer.cc.

Referenced by L1FPGATrackProducer().