131 return (
b.x() >
a.x());
132 else if (
a.y() !=
b.y())
133 return (
b.y() >
a.y());
134 else if (
a.z() !=
b.z())
135 return (
a.z() >
b.z());
137 return a.bend() >
b.bend();
223 readMoreMcTruth_(iConfig.getParameter<
bool>(
"readMoreMcTruth")),
234 putTokenTracks_(produces<
Streams>(
"Level1TTTracks")),
236 putTokenStubs_(produces<
StreamsStub>(
"Level1TTTracks")),
249 produces<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>(
"Level1TTTracks").setBranchAlias(
"Level1TTTracks");
321 exception.addContext(
"L1FPGATrackProducer::produce");
323 exception <<
"Storing of TrackBuilder output does not support doMultipleMatches.";
325 exception <<
"Storing of TrackBuilder output does not support duplicate removal.";
376 auto L1TkTracksForOutput = std::make_unique<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>();
379 stubIndexMapType stubIndexMap;
390 ev.setIP(bsPosition.x(), bsPosition.y());
407 map<edm::Ptr<TrackingParticle>,
int> translateTP;
421 for (
const auto& iterTP : *TrackingParticleHandle) {
426 if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
429 if (iterTP.g4Tracks().empty()) {
433 int sim_eventid = iterTP.g4Tracks().at(0).eventId().event();
434 int sim_type = iterTP.pdgId();
435 float sim_pt = iterTP.pt();
436 float sim_eta = iterTP.eta();
437 float sim_phi = iterTP.phi();
439 float vx = iterTP.vertex().x();
440 float vy = iterTP.vertex().y();
441 float vz = iterTP.vertex().z();
443 if (sim_pt < 1.0 ||
std::abs(vz) > 100.0 || hypot(vx, vy) > 50.0)
446 ev.addL1SimTrack(sim_eventid, ntps, sim_type, sim_pt, sim_eta, sim_phi, vx, vy, vz);
448 translateTP[tp_ptr] = ntps;
461 unsigned int theStubIndex = 0;
463 for (
const int& channel : handleDTC->
tfpChannels()) {
465 unsigned int atcaSlot = channel % 12;
467 if (channel % 24 >= 12)
468 dtcname =
"neg" + dtcname;
469 dtcname += (channel < 24) ?
"_A" :
"_B";
476 for (
size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) {
486 string layerword = stub.second.to_string().substr(61, 2);
487 unsigned int layercode = 2 * (layerword[0] -
'0') + layerword[1] -
'0';
493 static const int layerdisktab[12][4] = {{0, 6, 8, 10},
506 int layerdisk = layerdisktab[channel % 12][layercode];
510 constexpr
int DTCLinkWordSize = 64;
511 constexpr
int StubWordSize = 36;
512 constexpr
int LayerandStatusCodeSize = 3;
514 stub.second.to_string().substr(DTCLinkWordSize - StubWordSize - LayerandStatusCodeSize, StubWordSize);
515 string stubwordhex =
"";
518 for (
unsigned int i = 0;
i < 9;
i++) {
519 bitset<4>
bits(stubword.substr(
i * 4, 4));
521 stubwordhex += ((
val < 10) ? (
'0' +
val) : (
'A' +
val - 10));
526 innerCluster = stub.first->clusterRef(0);
528 outerCluster = stub.first->clusterRef(1);
534 const DetId innerDetId = innerCluster->getDetId();
536 const auto* theGeomDet_inner =
dynamic_cast<const PixelGeomDetUnit*
>(det_inner);
539 MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered();
541 GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner);
543 const DetId outerDetId = outerCluster->getDetId();
545 const auto* theGeomDet_outer =
dynamic_cast<const PixelGeomDetUnit*
>(det_outer);
548 MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered();
550 GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer);
552 bool isFlipped = (posStub_outer.
mag() < posStub_inner.
mag());
554 vector<int> assocTPs;
556 for (
unsigned int iClus = 0; iClus <= 1; iClus++) {
558 const TTClusterRef& ttClusterRef = stubRef->clusterRef(iClus);
562 vector<edm::Ptr<TrackingParticle>> vecTpPtr =
563 MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
566 if (translateTP.find(tpPtr) != translateTP.end()) {
568 assocTPs.push_back(translateTP.at(tpPtr));
570 assocTPs.push_back(-translateTP.at(tpPtr));
574 assocTPs.push_back(0);
580 double stubbend = stubRef->bendFE();
581 if (ttPos.
z() < -120) {
582 stubbend = -stubbend;
587 enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 };
588 const TypeBarrel
type =
static_cast<TypeBarrel
>(tTopo->
tobSide(innerDetId));
589 bool tiltedBarrel =
barrel && (
type == tiltedMinus ||
type == tiltedPlus);
590 unsigned int tiltedRingId = 0;
593 tiltedRingId = tTopo->
tobRod(innerDetId);
594 if (
type == tiltedMinus) {
595 unsigned int layp1 = 1 + layerdisk;
597 tiltedRingId = 1 + nTilted - tiltedRingId;
601 unsigned int endcapRingId =
barrel ? 0 : tTopo->
tidRing(innerDetId);
603 const unsigned int intDetId = innerDetId.
rawId();
619 stubRef->innerClusterPosition(),
624 stubMap[lastStub] = stubRef;
646 const unsigned int numStreamsStubRaw = numStreamsTrack * maxNumProjectionLayers;
649 vector<vector<string>> streamsTrackRaw(numStreamsTrack);
650 vector<vector<StubStreamData>> streamsStubRaw(numStreamsStubRaw);
656 if (
track.duplicate())
665 double tmp_chi2rphi =
track.chisqrphi();
666 double tmp_chi2rz =
track.chisqrz();
667 unsigned int tmp_hit =
track.hitpattern();
683 unsigned int trksector =
track.sector();
684 unsigned int trkseed = (
unsigned int)
abs(
track.seed());
686 aTrack.setPhiSector(trksector);
687 aTrack.setTrackSeedType(trkseed);
689 const vector<trklet::L1TStub>& stubptrs =
track.stubs();
690 vector<trklet::L1TStub> stubs;
692 stubs.reserve(stubptrs.size());
693 for (
const auto& stubptr : stubptrs) {
694 stubs.push_back(stubptr);
698 stubMapType::const_iterator it;
699 stubIndexMapType::const_iterator itIndex;
700 for (
const auto& itstubs : stubs) {
701 itIndex = stubIndexMap.find(itstubs.uniqueIndex());
702 if (itIndex != stubIndexMap.end()) {
703 aTrack.addStubRef(itIndex->second);
704 countStubs = countStubs + 1;
711 aTrack.setStubPtConsistency(
715 aTrack.setTrackWordBits();
729 L1TkTracksForOutput->push_back(aTrack);
738 Streams streamsTrack(numStreamsTrack);
741 for (
unsigned int chanTrk = 0; chanTrk < numStreamsTrack; chanTrk++) {
742 for (
unsigned int itk = 0; itk < streamsTrackRaw[chanTrk].size(); itk++) {
743 std::string bitsTrk = streamsTrackRaw[chanTrk][itk];
745 streamsTrack[chanTrk].emplace_back(bitsTrk);
747 const unsigned int chanStubOffsetIn = chanTrk * maxNumProjectionLayers;
750 TTBV hitMap(0, numProjLayers);
752 for (
unsigned int iproj = 0; iproj < maxNumProjectionLayers; iproj++) {
754 const StubStreamData& stubdata = streamsStubRaw[chanStubOffsetIn + iproj][itk];
756 if (stubdata.
valid()) {
757 const TTStubRef ttStubRef = stubMap[stub];
762 streamsStub[chanStubOffsetOut + layerId].emplace_back(ttStubRef, stubdata.
dataBits());
765 for (
int layerId : hitMap.
ids(
false)) {
766 streamsStub[chanStubOffsetOut + layerId].emplace_back(
tt::FrameStub());
Log< level::Info, true > LogVerbatim
void setMemoryModulesFile(std::string memoryModulesFileName)
T getParameter(std::string const &) const
edm::InputTag MCTruthStubInputTag
unsigned int tobSide(const DetId &id) const
void setStoreTrackBuilderOutput(bool storeTrackBuilderOutput)
edm::FileInPath tableTREFile
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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
string asciiEventOutName_
const Point & position() const
position
void init(Settings const &theSettings, const tt::Setup *setup=nullptr)
std::string fullPath() const
void setFitPatternFile(std::string fitPatternFileName)
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
std::pair< TTStubRef, Frame > FrameStub
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.
std::vector< StreamStub > StreamsStub
std::vector< FrameStub > StreamStub
int numChannelsTrack() const
std::string slotToDTCname(unsigned int slot) const
Global3DPoint GlobalPoint
const edm::EDGetTokenT< reco::BeamSpot > getTokenBS_
edm::InputTag MCTruthClusterInputTag
void setReduced(bool reduced)
trklet::TrackletEventProcessor eventProcessor
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
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)
edm::EDGetTokenT< std::vector< TrackingParticle > > getTokenTrackingParticle_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > esGetTokenTTopo_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > esGetTokenTGeom_
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > esGetTokenBfield_
std::ofstream asciiEventOut_
const edm::ESGetToken< hph::Setup, hph::SetupRcd > esGetTokenHPH_
GlobalPoint stubPos(const TTStubRef &ttStubRef) const
std::vector< int > ids(bool b=true, bool singed=false) const
const std::string & dataBits() const
edm::FileInPath processingModulesFile
Abs< T >::type abs(const T &t)
const std::vector< int > & tfpRegions() const
const ChannelAssignment * channelAssignment_
#define DEFINE_FWK_MODULE(type)
std::string removalType() const
const edm::ESGetToken< tt::Setup, tt::SetupRcd > esGetToken_
bool doMultipleMatches() const
int maxNumProjectionLayers() const
const edm::EDPutTokenT< Streams > putTokenTracks_
void setFakefit(bool fakefit)
Class to store the L1 Track Trigger stubs.
bool isNull() const
Checks for null.
const std::vector< Track > & tracks() const
bool operator()(const trklet::L1TStub &a, const trklet::L1TStub &b) const
edm::FileInPath wiresFile
edm::InputTag TrackingParticleInputTag
bool debugTracklet() const
constexpr unsigned int N_SECTOR
void endRun(edm::Run const &, edm::EventSetup const &) override
int numProjectionLayers(int seedType) const
const L1TStub & stub() const
bool storeTrackBuilderOutput() const
bool psModule(int dtcId) const
~L1FPGATrackProducer() override
NOTE: this is needed even if it seems not.
constexpr uint32_t rawId() const
get the raw id
XYZPointD XYZPoint
point in space with cartesian internal representation
Class to store the L1 Track Trigger tracks.
void setProcessingModulesFile(std::string processingModulesFileName)
unsigned int nHelixPar() const
L1FPGATrackProducer(const edm::ParameterSet &iConfig)
Constructor/destructor.
const edm::EDGetTokenT< TTDTC > getTokenDTC_
Class to store hardware like structured TTStub Collection used by Track Trigger emulators.
std::vector< Stream > Streams
unsigned int tobRod(const DetId &id) const
void setDoMultipleMatches(bool doMultipleMatches)
edm::FileInPath memoryModulesFile
std::map< string, vector< int > > dtclayerdisk
const edm::EDPutTokenT< StreamsStub > putTokenStubs_
int numChannelsStub() const
double numTiltedLayerRing(int layerId) const
std::unique_ptr< L1TrackQuality > trackQualityModel_
edm::FileInPath fitPatternFile
File path for configuration files.
edm::EDGetTokenT< TTClusterAssociationMap< Ref_Phase2TrackerDigi_ > > getTokenTTClusterMCTruth_
void setNbitstrackletindex(unsigned int nbitstrackletindex)
void setNHelixPar(unsigned int nHelixPar)
unsigned int tidRing(const DetId &id) const
void setWiresFile(std::string wiresFileName)
bool layerId(int seedType, const TTStubRef &ttStubRef, int &layerId) const
void setBfield(double bfield)
void setTableTREFile(std::string tableTREFileName)
void passSetup(const tt::Setup *setup)
edm::ParameterSet config
Containers of parameters passed by python configuration file.
int dtcId(int tklId) const
void setTableTEDFile(std::string tableTEDFileName)
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
void setExtended(bool extended)
unsigned int uniqueIndex() const
float getConsistency(TTTrack< Ref_Phase2TrackerDigi_ > aTrack, const TrackerGeometry *theTrackerGeom, const TrackerTopology *tTopo, double mMagneticFieldStrength, int nPar)
const ESGetToken< ChannelAssignment, ChannelAssignmentRcd > esGetTokenChannelAssignment_