CMS 3D CMS Logo

L1FPGATrackProducer.cc
Go to the documentation of this file.
1 // Producer by Anders //
3 // and Emmanuele //
4 // july 2012 @ CU //
6 
8 // FRAMEWORK HEADERS
11 //
18 //
22 
24 // DATA FORMATS HEADERS
27 //
33 //
36 
45 //
48 //
56 //
59 //
64 
66 // DETECTOR GEOMETRY HEADERS
77 //
79 
81 // Tracklet emulation
91 
93 // PHYSICS TOOLS
96 
99 
103 
105 // STD HEADERS
106 #include <memory>
107 #include <string>
108 #include <iostream>
109 #include <fstream>
110 
112 // NAMESPACES
113 using namespace edm;
114 using namespace std;
115 using namespace tt;
116 using namespace trklet;
117 
119 // //
120 // CLASS DEFINITION //
121 // //
123 
125 // this class is needed to make a map
126 // between different types of stubs
128 public:
129  bool operator()(const trklet::L1TStub& a, const trklet::L1TStub& b) const {
130  if (a.x() != b.x())
131  return (b.x() > a.x());
132  else {
133  if (a.y() != b.y())
134  return (b.y() > a.y());
135  else
136  return (a.z() > b.z());
137  }
138  }
139 };
140 
141 class L1FPGATrackProducer : public edm::one::EDProducer<edm::one::WatchRuns> {
142 public:
144  explicit L1FPGATrackProducer(const edm::ParameterSet& iConfig);
145  ~L1FPGATrackProducer() override;
146 
147 private:
148  int eventnum;
149 
152 
154 
160 
163 
165  std::ofstream asciiEventOut_;
166 
167  // settings containing various constants for the tracklet processing
169 
170  // event processor for the tracklet track finding
172 
173  unsigned int nHelixPar_;
174  bool extended_;
175  bool reduced_;
176 
178  std::unique_ptr<L1TrackQuality> trackQualityModel_;
179 
180  std::map<string, vector<int>> dtclayerdisk;
181 
185 
190 
191  // ED output token for clock and bit accurate tracks
193  // ED output token for clock and bit accurate stubs
195  // ChannelAssignment token
197  // helper class to assign tracks to channel
199 
200  // helper class to store DTC configuration
201  const Setup* setup_;
202  // helper class to store configuration needed by HitPatternHelper
204 
205  // Setup token
211 
214  void beginRun(const edm::Run& run, const edm::EventSetup& iSetup) override;
215  void endRun(edm::Run const&, edm::EventSetup const&) override;
216  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
217 };
218 
220 // CONSTRUCTOR
222  : config(iConfig),
223  readMoreMcTruth_(iConfig.getParameter<bool>("readMoreMcTruth")),
224  MCTruthClusterInputTag(readMoreMcTruth_ ? config.getParameter<edm::InputTag>("MCTruthClusterInputTag")
225  : edm::InputTag()),
226  MCTruthStubInputTag(readMoreMcTruth_ ? config.getParameter<edm::InputTag>("MCTruthStubInputTag")
227  : edm::InputTag()),
228  TrackingParticleInputTag(readMoreMcTruth_ ? iConfig.getParameter<edm::InputTag>("TrackingParticleInputTag")
229  : edm::InputTag()),
230  // book ED products
231  getTokenBS_(consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("BeamSpotSource"))),
232  getTokenDTC_(consumes<TTDTC>(edm::InputTag(iConfig.getParameter<edm::InputTag>("InputTagTTDTC")))),
233  // book ED output token for clock and bit accurate tracks
234  putTokenTracks_(produces<Streams>("Level1TTTracks")),
235  // book ED output token for clock and bit accurate stubs
236  putTokenStubs_(produces<StreamsStub>("Level1TTTracks")),
237  // book ES products
238  esGetTokenChannelAssignment_(esConsumes<ChannelAssignment, ChannelAssignmentRcd, Transition::BeginRun>()),
239  esGetTokenBfield_(esConsumes<edm::Transition::BeginRun>()),
240  esGetTokenTGeom_(esConsumes()),
241  esGetTokenTTopo_(esConsumes()),
242  esGetToken_(esConsumes<tt::Setup, tt::SetupRcd, edm::Transition::BeginRun>()),
243  esGetTokenHPH_(esConsumes<hph::Setup, hph::SetupRcd, edm::Transition::BeginRun>()) {
244  if (readMoreMcTruth_) {
245  getTokenTTClusterMCTruth_ = consumes<TTClusterAssociationMap<Ref_Phase2TrackerDigi_>>(MCTruthClusterInputTag);
246  getTokenTrackingParticle_ = consumes<std::vector<TrackingParticle>>(TrackingParticleInputTag);
247  }
248 
249  produces<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>("Level1TTTracks").setBranchAlias("Level1TTTracks");
250 
251  asciiEventOutName_ = iConfig.getUntrackedParameter<string>("asciiFileName", "");
252 
253  fitPatternFile = iConfig.getParameter<edm::FileInPath>("fitPatternFile");
254  processingModulesFile = iConfig.getParameter<edm::FileInPath>("processingModulesFile");
255  memoryModulesFile = iConfig.getParameter<edm::FileInPath>("memoryModulesFile");
256  wiresFile = iConfig.getParameter<edm::FileInPath>("wiresFile");
257 
258  extended_ = iConfig.getParameter<bool>("Extended");
259  reduced_ = iConfig.getParameter<bool>("Reduced");
260  nHelixPar_ = iConfig.getParameter<unsigned int>("Hnpar");
261 
262  if (extended_) {
263  tableTEDFile = iConfig.getParameter<edm::FileInPath>("tableTEDFile");
264  tableTREFile = iConfig.getParameter<edm::FileInPath>("tableTREFile");
265  }
266 
267  // initial ES products
268  channelAssignment_ = nullptr;
269  setup_ = nullptr;
270 
271  // --------------------------------------------------------------------------------
272  // set options in Settings based on inputs from configuration files
273  // --------------------------------------------------------------------------------
274 
278 
283 
284  settings_.setFakefit(iConfig.getParameter<bool>("Fakefit"));
285  settings_.setStoreTrackBuilderOutput(iConfig.getParameter<bool>("StoreTrackBuilderOutput"));
286  settings_.setRemovalType(iConfig.getParameter<string>("RemovalType"));
287  settings_.setDoMultipleMatches(iConfig.getParameter<bool>("DoMultipleMatches"));
288 
289  if (extended_) {
292 
293  //FIXME: The TED and TRE tables are currently disabled by default, so we
294  //need to allow for the additional tracklets that will eventually be
295  //removed by these tables, once they are finalized
297  }
298 
299  eventnum = 0;
300  if (not asciiEventOutName_.empty()) {
301  asciiEventOut_.open(asciiEventOutName_.c_str());
302  }
303 
304  if (settings_.debugTracklet()) {
305  edm::LogVerbatim("Tracklet") << "fit pattern : " << fitPatternFile.fullPath()
306  << "\n process modules : " << processingModulesFile.fullPath()
307  << "\n memory modules : " << memoryModulesFile.fullPath()
308  << "\n wires : " << wiresFile.fullPath();
309  if (extended_) {
310  edm::LogVerbatim("Tracklet") << "table_TED : " << tableTEDFile.fullPath()
311  << "\n table_TRE : " << tableTREFile.fullPath();
312  }
313  }
314 
315  trackQuality_ = iConfig.getParameter<bool>("TrackQuality");
316  if (trackQuality_) {
317  trackQualityModel_ = std::make_unique<L1TrackQuality>(iConfig.getParameter<edm::ParameterSet>("TrackQualityPSet"));
318  }
320  cms::Exception exception("ConfigurationNotSupported.");
321  exception.addContext("L1FPGATrackProducer::produce");
323  exception << "Storing of TrackBuilder output does not support doMultipleMatches.";
324  if (!settings_.removalType().empty())
325  exception << "Storing of TrackBuilder output does not support duplicate removal.";
326  throw exception;
327  }
328 }
329 
331 // DESTRUCTOR
333  if (asciiEventOut_.is_open()) {
334  asciiEventOut_.close();
335  }
336 }
337 
339 //
341 
343 // BEGIN JOB
346  // GET MAGNETIC FIELD //
347  const MagneticField* theMagneticField = &iSetup.getData(esGetTokenBfield_);
348  double mMagneticFieldStrength = theMagneticField->inTesla(GlobalPoint(0, 0, 0)).z();
349  settings_.setBfield(mMagneticFieldStrength);
350 
351  setup_ = &iSetup.getData(esGetToken_);
352  setupHPH_ = &iSetup.getData(esGetTokenHPH_);
353  if (trackQuality_) {
354  trackQualityModel_->beginRun(setupHPH_);
355  }
356  // Tracklet pattern reco output channel info.
358  // initialize the tracklet event processing (this sets all the processing & memory modules, wiring, etc)
360 }
361 
363 // PRODUCE
365  typedef std::map<trklet::L1TStub,
368  stubMapType;
370  TTClusterRef;
371 
373  auto L1TkTracksForOutput = std::make_unique<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>();
374 
375  stubMapType stubMap;
376 
378  // GET BS //
379  edm::Handle<reco::BeamSpot> beamSpotHandle;
380  iEvent.getByToken(getTokenBS_, beamSpotHandle);
381  math::XYZPoint bsPosition = beamSpotHandle->position();
382 
383  eventnum++;
385  ev.setEventNum(eventnum);
386  ev.setIP(bsPosition.x(), bsPosition.y());
387 
388  // tracking particles
389  edm::Handle<std::vector<TrackingParticle>> TrackingParticleHandle;
390  if (readMoreMcTruth_)
391  iEvent.getByToken(getTokenTrackingParticle_, TrackingParticleHandle);
392 
393  // tracker topology
394  const TrackerTopology* const tTopo = &iSetup.getData(esGetTokenTTopo_);
395  const TrackerGeometry* const theTrackerGeom = &iSetup.getData(esGetTokenTGeom_);
396 
398  // GET THE PRIMITIVES //
399  edm::Handle<TTDTC> handleDTC;
400  iEvent.getByToken<TTDTC>(getTokenDTC_, handleDTC);
401 
402  // must be defined for code to compile, even if it's not used unless readMoreMcTruth_ is true
403  map<edm::Ptr<TrackingParticle>, int> translateTP;
404 
405  // MC truth association maps
407  if (readMoreMcTruth_) {
408  iEvent.getByToken(getTokenTTClusterMCTruth_, MCTruthTTClusterHandle);
409 
412 
413  int ntps = 1; //count from 1 ; 0 will mean invalid
414 
415  int this_tp = 0;
416  if (readMoreMcTruth_) {
417  for (const auto& iterTP : *TrackingParticleHandle) {
418  edm::Ptr<TrackingParticle> tp_ptr(TrackingParticleHandle, this_tp);
419  this_tp++;
420 
421  // only keep TPs producing a cluster
422  if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
423  continue;
424 
425  if (iterTP.g4Tracks().empty()) {
426  continue;
427  }
428 
429  int sim_eventid = iterTP.g4Tracks().at(0).eventId().event();
430  int sim_type = iterTP.pdgId();
431  float sim_pt = iterTP.pt();
432  float sim_eta = iterTP.eta();
433  float sim_phi = iterTP.phi();
434 
435  float vx = iterTP.vertex().x();
436  float vy = iterTP.vertex().y();
437  float vz = iterTP.vertex().z();
438 
439  if (sim_pt < 1.0 || std::abs(vz) > 100.0 || hypot(vx, vy) > 50.0)
440  continue;
441 
442  ev.addL1SimTrack(sim_eventid, ntps, sim_type, sim_pt, sim_eta, sim_phi, vx, vy, vz);
443 
444  translateTP[tp_ptr] = ntps;
445  ntps++;
446 
447  } //end loop over TPs
448  }
449 
450  } // end if (readMoreMcTruth_)
451 
455 
456  // Process stubs in each region and channel within that tracking region
457  for (const int& region : handleDTC->tfpRegions()) {
458  for (const int& channel : handleDTC->tfpChannels()) {
459  // Get the DTC name & ID from the channel
460  unsigned int atcaSlot = channel % 12;
461  string dtcname = settings_.slotToDTCname(atcaSlot);
462  if (channel % 24 >= 12)
463  dtcname = "neg" + dtcname;
464  dtcname += (channel < 24) ? "_A" : "_B"; // which detector region
465  int dtcId = setup_->dtcId(region, channel);
466 
467  // Get the stubs from the DTC
468  const tt::StreamStub& streamFromDTC{handleDTC->stream(region, channel)};
469 
470  // Prepare the DTC stubs for the IR
471  for (size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) {
472  const tt::FrameStub& stub{streamFromDTC[stubIndex]};
473  const TTStubRef& stubRef = stub.first;
474 
475  if (stubRef.isNull())
476  continue;
477 
478  const GlobalPoint& ttPos = setup_->stubPos(stubRef);
479 
480  //Get the 2 bits for the layercode
481  string layerword = stub.second.to_string().substr(61, 2);
482  unsigned int layercode = 2 * (layerword[0] - '0') + layerword[1] - '0';
483  assert(layercode < 4);
484 
485  //translation from the two bit layercode to the layer/disk number of each of the
486  //12 channels (dtcs)
487  // FIX: take this from DTC cabling map.
488  static const int layerdisktab[12][4] = {{0, 6, 8, 10},
489  {0, 7, 9, -1},
490  {1, 7, -1, -1},
491  {6, 8, 10, -1},
492  {2, 7, -1, -1},
493  {2, 9, -1, -1},
494  {3, 4, -1, -1},
495  {4, -1, -1, -1},
496  {5, -1, -1, -1},
497  {5, 8, -1, -1},
498  {6, 9, -1, -1},
499  {7, 10, -1, -1}};
500 
501  int layerdisk = layerdisktab[channel % 12][layercode];
502  assert(layerdisk != -1);
503 
504  //Get the 36 bit word - skip the lowest 3 buts (status and layer code)
505  constexpr int DTCLinkWordSize = 64;
506  constexpr int StubWordSize = 36;
507  constexpr int LayerandStatusCodeSize = 3;
508  string stubword =
509  stub.second.to_string().substr(DTCLinkWordSize - StubWordSize - LayerandStatusCodeSize, StubWordSize);
510  string stubwordhex = "";
511 
512  //Loop over the 9 words in the 36 bit stub word
513  for (unsigned int i = 0; i < 9; i++) {
514  bitset<4> bits(stubword.substr(i * 4, 4));
515  ulong val = bits.to_ulong();
516  stubwordhex += ((val < 10) ? ('0' + val) : ('A' + val - 10));
517  }
518 
521  innerCluster = stub.first->clusterRef(0);
523  outerCluster = stub.first->clusterRef(1);
524 
525  // -----------------------------------------------------
526  // check module orientation, if flipped, need to store that information for track fit
527  // -----------------------------------------------------
528 
529  const DetId innerDetId = innerCluster->getDetId();
530  const GeomDetUnit* det_inner = theTrackerGeom->idToDetUnit(innerDetId);
531  const auto* theGeomDet_inner = dynamic_cast<const PixelGeomDetUnit*>(det_inner);
532  const PixelTopology* topol_inner = dynamic_cast<const PixelTopology*>(&(theGeomDet_inner->specificTopology()));
533 
534  MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered();
535  LocalPoint clustlp_inner = topol_inner->localPosition(coords_inner);
536  GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner);
537 
538  const DetId outerDetId = outerCluster->getDetId();
539  const GeomDetUnit* det_outer = theTrackerGeom->idToDetUnit(outerDetId);
540  const auto* theGeomDet_outer = dynamic_cast<const PixelGeomDetUnit*>(det_outer);
541  const PixelTopology* topol_outer = dynamic_cast<const PixelTopology*>(&(theGeomDet_outer->specificTopology()));
542 
543  MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered();
544  LocalPoint clustlp_outer = topol_outer->localPosition(coords_outer);
545  GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer);
546 
547  bool isFlipped = (posStub_outer.mag() < posStub_inner.mag());
548 
549  vector<int> assocTPs;
550 
551  for (unsigned int iClus = 0; iClus <= 1; iClus++) { // Loop over both clusters that make up stub.
552 
553  const TTClusterRef& ttClusterRef = stubRef->clusterRef(iClus);
554 
555  // Now identify all TP's contributing to either cluster in stub.
556  if (readMoreMcTruth_) {
557  vector<edm::Ptr<TrackingParticle>> vecTpPtr =
558  MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
559 
560  for (const edm::Ptr<TrackingParticle>& tpPtr : vecTpPtr) {
561  if (translateTP.find(tpPtr) != translateTP.end()) {
562  if (iClus == 0) {
563  assocTPs.push_back(translateTP.at(tpPtr));
564  } else {
565  assocTPs.push_back(-translateTP.at(tpPtr));
566  }
567  // N.B. Since not all tracking particles are stored in InputData::vTPs_, sometimes no match will be found.
568  } else {
569  assocTPs.push_back(0);
570  }
571  }
572  }
573  }
574 
575  double stubbend = stubRef->bendFE(); //stubRef->rawBend()
576  if (ttPos.z() < -120) {
577  stubbend = -stubbend;
578  }
579 
580  bool barrel = (layerdisk < N_LAYER);
581  // See https://github.com/cms-sw/cmssw/tree/master/Geometry/TrackerNumberingBuilder
582  enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 };
583  const TypeBarrel type = static_cast<TypeBarrel>(tTopo->tobSide(innerDetId));
584  bool tiltedBarrel = barrel && (type == tiltedMinus || type == tiltedPlus);
585  unsigned int tiltedRingId = 0;
586  // Tilted module ring no. (Increasing 1 to 12 as |z| increases).
587  if (tiltedBarrel) {
588  tiltedRingId = tTopo->tobRod(innerDetId);
589  if (type == tiltedMinus) {
590  unsigned int layp1 = 1 + layerdisk; // Setup counts from 1
591  unsigned int nTilted = setup_->numTiltedLayerRing(layp1);
592  tiltedRingId = 1 + nTilted - tiltedRingId;
593  }
594  }
595  // Endcap module ring number (1-15) in endcap disks.
596  unsigned int endcapRingId = barrel ? 0 : tTopo->tidRing(innerDetId);
597 
598  const unsigned int intDetId = innerDetId.rawId();
599 
600  ev.addStub(dtcname,
601  region,
602  layerdisk,
603  stubwordhex,
604  setup_->psModule(dtcId),
605  isFlipped,
606  tiltedBarrel,
607  tiltedRingId,
608  endcapRingId,
609  intDetId,
610  ttPos.x(),
611  ttPos.y(),
612  ttPos.z(),
613  stubbend,
614  stubRef->innerClusterPosition(),
615  assocTPs);
616 
617  const trklet::L1TStub& lastStub = ev.lastStub();
618  stubMap[lastStub] = stubRef;
619  }
620  }
621  }
622 
624  // NOW RUN THE L1 tracking
625 
626  if (!asciiEventOutName_.empty()) {
627  ev.write(asciiEventOut_);
628  }
629 
630  const std::vector<trklet::Track>& tracks = eventProcessor.tracks();
631 
632  const unsigned int maxNumProjectionLayers = channelAssignment_->maxNumProjectionLayers();
633  // number of track channels
634  const unsigned int numStreamsTrack = N_SECTOR * channelAssignment_->numChannelsTrack();
635  // number of stub channels
636  const unsigned int numStreamsStub = N_SECTOR * channelAssignment_->numChannelsStub();
637  // number of stub channels if all seed types streams padded to have same number of stub channels (for coding simplicity)
638  const unsigned int numStreamsStubRaw = numStreamsTrack * maxNumProjectionLayers;
639 
640  // Streams formatted to allow this code to run outside CMSSW.
641  vector<vector<string>> streamsTrackRaw(numStreamsTrack);
642  vector<vector<StubStreamData>> streamsStubRaw(numStreamsStubRaw);
643 
644  // this performs the actual tracklet event processing
645  eventProcessor.event(ev, streamsTrackRaw, streamsStubRaw);
646 
647  int ntracks = 0;
648 
649  for (const auto& track : tracks) {
650  if (track.duplicate())
651  continue;
652 
653  ntracks++;
654 
655  // this is where we create the TTTrack object
656  double tmp_rinv = track.rinv(settings_);
657  double tmp_phi = track.phi0(settings_);
658  double tmp_tanL = track.tanL(settings_);
659  double tmp_z0 = track.z0(settings_);
660  double tmp_d0 = track.d0(settings_);
661  double tmp_chi2rphi = track.chisqrphi();
662  double tmp_chi2rz = track.chisqrz();
663  unsigned int tmp_hit = track.hitpattern();
664 
665  TTTrack<Ref_Phase2TrackerDigi_> aTrack(tmp_rinv,
666  tmp_phi,
667  tmp_tanL,
668  tmp_z0,
669  tmp_d0,
670  tmp_chi2rphi,
671  tmp_chi2rz,
672  0,
673  0,
674  0,
675  tmp_hit,
677  settings_.bfield());
678 
679  unsigned int trksector = track.sector();
680  unsigned int trkseed = (unsigned int)abs(track.seed());
681 
682  aTrack.setPhiSector(trksector);
683  aTrack.setTrackSeedType(trkseed);
684 
685  const vector<trklet::L1TStub>& stubptrs = track.stubs();
686  vector<trklet::L1TStub> stubs;
687 
688  stubs.reserve(stubptrs.size());
689  for (const auto& stubptr : stubptrs) {
690  stubs.push_back(stubptr);
691  }
692 
693  stubMapType::const_iterator it;
694  for (const auto& itstubs : stubs) {
695  it = stubMap.find(itstubs);
696  if (it != stubMap.end()) {
697  aTrack.addStubRef(it->second);
698  } else {
699  // could not find stub in stub map
700  }
701  }
702 
703  // pt consistency
704  aTrack.setStubPtConsistency(
705  StubPtConsistency::getConsistency(aTrack, theTrackerGeom, tTopo, settings_.bfield(), settings_.nHelixPar()));
706 
707  // set TTTrack word
708  aTrack.setTrackWordBits();
709 
710  if (trackQuality_) {
711  trackQualityModel_->setL1TrackQuality(aTrack);
712  }
713 
714  // test track word
715  //aTrack.testTrackWordBits();
716 
717  L1TkTracksForOutput->push_back(aTrack);
718  }
719 
720  iEvent.put(std::move(L1TkTracksForOutput), "Level1TTTracks");
721 
722  // produce clock and bit accurate stream output tracks and stubs.
723  // from end of tracklet pattern recognition.
724  // Convertion here is from stream format that allows this code to run
725  // outside CMSSW to the EDProduct one.
726  Streams streamsTrack(numStreamsTrack);
727  StreamsStub streamsStub(numStreamsStub);
728 
729  for (unsigned int chanTrk = 0; chanTrk < numStreamsTrack; chanTrk++) {
730  for (unsigned int itk = 0; itk < streamsTrackRaw[chanTrk].size(); itk++) {
731  std::string bitsTrk = streamsTrackRaw[chanTrk][itk];
732  int iSeed = chanTrk % channelAssignment_->numChannelsTrack(); // seed type
733  streamsTrack[chanTrk].emplace_back(bitsTrk);
734 
735  const unsigned int chanStubOffsetIn = chanTrk * maxNumProjectionLayers;
736  const unsigned int chanStubOffsetOut = channelAssignment_->offsetStub(chanTrk);
737  const unsigned int numProjLayers = channelAssignment_->numProjectionLayers(iSeed);
738  TTBV hitMap(0, numProjLayers);
739  // remove padding from stub stream
740  for (unsigned int iproj = 0; iproj < maxNumProjectionLayers; iproj++) {
741  // FW current has one (perhaps invalid) stub per layer per track.
742  const StubStreamData& stubdata = streamsStubRaw[chanStubOffsetIn + iproj][itk];
743  const L1TStub& stub = stubdata.stub();
744  if (stubdata.valid()) {
745  const TTStubRef ttStubRef = stubMap[stub];
746  int layerId(-1);
747  if (!channelAssignment_->layerId(stubdata.iSeed(), ttStubRef, layerId))
748  continue;
749  hitMap.set(layerId);
750  streamsStub[chanStubOffsetOut + layerId].emplace_back(ttStubRef, stubdata.dataBits());
751  }
752  }
753  for (int layerId : hitMap.ids(false)) { // invalid stubs
754  streamsStub[chanStubOffsetOut + layerId].emplace_back(tt::FrameStub());
755  }
756  }
757  }
758 
759  iEvent.emplace(putTokenTracks_, move(streamsTrack));
760  iEvent.emplace(putTokenStubs_, move(streamsStub));
761 
762 }
763 
764 // ///////////////////////////
765 // // DEFINE THIS AS A PLUG-IN
Log< level::Info, true > LogVerbatim
void setMemoryModulesFile(std::string memoryModulesFileName)
Definition: Settings.h:77
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::InputTag MCTruthStubInputTag
unsigned int tobSide(const DetId &id) const
void setStoreTrackBuilderOutput(bool storeTrackBuilderOutput)
Definition: Settings.h:246
edm::FileInPath tableTREFile
trklet::Settings settings_
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 Point & position() const
position
Definition: BeamSpot.h:59
void init(Settings const &theSettings, const tt::Setup *setup=nullptr)
std::string fullPath() const
Definition: FileInPath.cc:161
void setFitPatternFile(std::string fitPatternFileName)
Definition: Settings.h:73
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
T z() const
Definition: PV3DBase.h:61
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Class to process and provide run-time constants used by Track Trigger emulators.
Definition: Setup.h:44
std::vector< StreamStub > StreamsStub
Definition: TTTypes.h:66
std::vector< FrameStub > StreamStub
Definition: TTTypes.h:63
constexpr uint32_t bits
Definition: gpuClustering.h:23
std::string slotToDTCname(unsigned int slot) const
Definition: Settings.h:434
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const edm::EDGetTokenT< reco::BeamSpot > getTokenBS_
edm::InputTag MCTruthClusterInputTag
void setReduced(bool reduced)
Definition: Settings.h:261
trklet::TrackletEventProcessor eventProcessor
Definition: config.py:1
void beginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
Class to assign tracklet tracks and stubs to output channel based on their Pt or seed type as well as...
const std::vector< int > & tfpChannels() const
Definition: TTDTC.h:26
assert(be >=bs)
const hph::Setup * setupHPH_
int offsetStub(int channelTrack) const
T getUntrackedParameter(std::string const &, T const &) const
edm::FileInPath tableTEDFile
void setRemovalType(std::string removalType)
Definition: Settings.h:249
edm::EDGetTokenT< std::vector< TrackingParticle > > getTokenTrackingParticle_
T x() const
Definition: PV3DBase.h:59
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > esGetTokenTTopo_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > esGetTokenTGeom_
T y() const
Definition: PV3DBase.h:60
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > esGetTokenBfield_
int iEvent
Definition: GenABIO.cc:224
Definition: TTTypes.h:54
const edm::ESGetToken< hph::Setup, hph::SetupRcd > esGetTokenHPH_
GlobalPoint stubPos(const TTStubRef &ttStubRef) const
Definition: Setup.cc:820
std::vector< int > ids(bool b=true, bool singed=false) const
Definition: TTBV.h:334
TTClusterRefT< Ref_Phase2TrackerDigi_ > TTClusterRef
Definition: TTTypes.h:45
double bfield() const
Definition: Settings.h:263
const std::string & dataBits() const
edm::FileInPath processingModulesFile
T mag() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< int > & tfpRegions() const
Definition: TTDTC.h:24
Transition
Definition: Transition.h:12
const ChannelAssignment * channelAssignment_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::string removalType() const
Definition: Settings.h:239
const edm::ESGetToken< tt::Setup, tt::SetupRcd > esGetToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
bool doMultipleMatches() const
Definition: Settings.h:242
const edm::EDPutTokenT< Streams > putTokenTracks_
void setFakefit(bool fakefit)
Definition: Settings.h:244
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
bool isNull() const
Checks for null.
Definition: Ref.h:235
TTBV & set()
Definition: TTBV.h:187
const std::vector< Track > & tracks() const
bool operator()(const trklet::L1TStub &a, const trklet::L1TStub &b) const
edm::InputTag TrackingParticleInputTag
bool debugTracklet() const
Definition: Settings.h:182
constexpr unsigned int N_SECTOR
Definition: Settings.h:19
void endRun(edm::Run const &, edm::EventSetup const &) override
int numProjectionLayers(int seedType) const
Definition: DetId.h:17
const L1TStub & stub() const
auto const & tracks
cannot be loose
bool storeTrackBuilderOutput() const
Definition: Settings.h:245
bool psModule(int dtcId) const
Definition: Setup.cc:318
NOTE: this is needed even if it seems not.
Definition: TTCluster.h:27
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
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
void setProcessingModulesFile(std::string processingModulesFileName)
Definition: Settings.h:74
unsigned int nHelixPar() const
Definition: Settings.h:253
L1FPGATrackProducer(const edm::ParameterSet &iConfig)
Constructor/destructor.
const edm::EDGetTokenT< TTDTC > getTokenDTC_
double b
Definition: hdecay.h:118
Class to store hardware like structured TTStub Collection used by Track Trigger emulators.
Definition: TTDTC.h:17
std::vector< Stream > Streams
Definition: TTTypes.h:68
unsigned int tobRod(const DetId &id) const
void setDoMultipleMatches(bool doMultipleMatches)
Definition: Settings.h:250
edm::FileInPath memoryModulesFile
std::map< string, vector< int > > dtclayerdisk
const edm::EDPutTokenT< StreamsStub > putTokenStubs_
double numTiltedLayerRing(int layerId) const
Definition: Setup.h:309
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:119
std::unique_ptr< L1TrackQuality > trackQualityModel_
edm::FileInPath fitPatternFile
File path for configuration files.
edm::EDGetTokenT< TTClusterAssociationMap< Ref_Phase2TrackerDigi_ > > getTokenTTClusterMCTruth_
void setNbitstrackletindex(unsigned int nbitstrackletindex)
Definition: Settings.h:282
void setNHelixPar(unsigned int nHelixPar)
Definition: Settings.h:254
unsigned int tidRing(const DetId &id) const
void setWiresFile(std::string wiresFileName)
Definition: Settings.h:78
bool layerId(int seedType, const TTStubRef &ttStubRef, int &layerId) const
void setBfield(double bfield)
Definition: Settings.h:264
void setTableTREFile(std::string tableTREFileName)
Definition: Settings.h:80
edm::ParameterSet config
Containers of parameters passed by python configuration file.
int dtcId(int tklId) const
Definition: Setup.cc:290
void setTableTEDFile(std::string tableTEDFileName)
Definition: Settings.h:79
void event(SLHCEvent &ev, std::vector< std::vector< std::string >> &streamsTrackRaw, std::vector< std::vector< StubStreamData >> &streamsStubRaw)
const tt::StreamStub & stream(int tfpRegion, int tfpChannel) const
Definition: TTDTC.cc:48
def move(src, dest)
Definition: eostools.py:511
void setExtended(bool extended)
Definition: Settings.h:257
Definition: Run.h:45
float getConsistency(TTTrack< Ref_Phase2TrackerDigi_ > aTrack, const TrackerGeometry *theTrackerGeom, const TrackerTopology *tTopo, double mMagneticFieldStrength, int nPar)
constexpr int N_LAYER
Definition: Settings.h:21
const ESGetToken< ChannelAssignment, ChannelAssignmentRcd > esGetTokenChannelAssignment_