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();
227 readMoreMcTruth_(iConfig.getParameter<
bool>(
"readMoreMcTruth")),
238 putTokenTracks_(produces<
Streams>(
"Level1TTTracks")),
240 putTokenStubs_(produces<
StreamsStub>(
"Level1TTTracks")),
253 produces<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>(
"Level1TTTracks").setBranchAlias(
"Level1TTTracks");
327 exception.addContext(
"L1FPGATrackProducer::produce");
329 exception <<
"Storing of TrackBuilder output does not support doMultipleMatches.";
331 exception <<
"Storing of TrackBuilder output does not support duplicate removal.";
382 auto L1TkTracksForOutput = std::make_unique<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>();
385 stubIndexMapType stubIndexMap;
396 ev.setIP(bsPosition.x(), bsPosition.y());
410 if (failScenario_ < 0 || failScenario_ > 9) {
424 map<edm::Ptr<TrackingParticle>,
int> translateTP;
438 for (
const auto& iterTP : *TrackingParticleHandle) {
443 if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
446 if (iterTP.g4Tracks().empty()) {
450 int sim_eventid = iterTP.g4Tracks().at(0).eventId().event();
451 int sim_type = iterTP.pdgId();
452 float sim_pt = iterTP.pt();
453 float sim_eta = iterTP.eta();
454 float sim_phi = iterTP.phi();
456 float vx = iterTP.vertex().x();
457 float vy = iterTP.vertex().y();
458 float vz = iterTP.vertex().z();
463 ev.addL1SimTrack(sim_eventid, ntps, sim_type, sim_pt, sim_eta, sim_phi,
vx,
vy,
vz);
465 translateTP[tp_ptr] = ntps;
478 unsigned int theStubIndex = 0;
480 for (
const int& channel : handleDTC->
tfpChannels()) {
482 unsigned int atcaSlot = channel % 12;
484 if (channel % 24 >= 12)
485 dtcname =
"neg" + dtcname;
486 dtcname += (channel < 24) ?
"_A" :
"_B";
493 for (
size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) {
503 string layerword = stub.second.to_string().substr(61, 2);
504 unsigned int layercode = 2 * (layerword[0] -
'0') + layerword[1] -
'0';
510 static const int layerdisktab[12][4] = {{0, 6, 8, 10},
523 int layerdisk = layerdisktab[channel % 12][layercode];
529 constexpr int LayerandStatusCodeSize = 3;
531 stub.second.to_string().substr(DTCLinkWordSize - StubWordSize - LayerandStatusCodeSize, StubWordSize);
532 string stubwordhex =
"";
535 for (
unsigned int i = 0;
i < 9;
i++) {
536 bitset<4>
bits(stubword.substr(
i * 4, 4));
538 stubwordhex += ((
val < 10) ? (
'0' +
val) : (
'A' +
val - 10));
543 innerCluster = stub.first->clusterRef(0);
545 outerCluster = stub.first->clusterRef(1);
551 const DetId innerDetId = innerCluster->getDetId();
553 const auto* theGeomDet_inner =
dynamic_cast<const PixelGeomDetUnit*
>(det_inner);
556 MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered();
558 GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner);
560 const DetId outerDetId = outerCluster->getDetId();
562 const auto* theGeomDet_outer =
dynamic_cast<const PixelGeomDetUnit*
>(det_outer);
565 MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered();
567 GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer);
569 bool isFlipped = (posStub_outer.
mag() < posStub_inner.
mag());
571 vector<int> assocTPs;
573 for (
unsigned int iClus = 0; iClus <= 1; iClus++) {
575 const TTClusterRef& ttClusterRef = stubRef->clusterRef(iClus);
579 vector<edm::Ptr<TrackingParticle>> vecTpPtr =
580 MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
583 if (translateTP.find(tpPtr) != translateTP.end()) {
585 assocTPs.push_back(translateTP.at(tpPtr));
587 assocTPs.push_back(-translateTP.at(tpPtr));
591 assocTPs.push_back(0);
597 double stubbend = stubRef->bendFE();
598 if (ttPos.
z() < -120) {
599 stubbend = -stubbend;
604 enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 };
605 const TypeBarrel
type =
static_cast<TypeBarrel
>(tTopo->
tobSide(innerDetId));
606 bool tiltedBarrel =
barrel && (
type == tiltedMinus ||
type == tiltedPlus);
607 unsigned int tiltedRingId = 0;
610 tiltedRingId = tTopo->
tobRod(innerDetId);
611 if (
type == tiltedMinus) {
612 unsigned int layp1 = 1 + layerdisk;
614 tiltedRingId = 1 + nTilted - tiltedRingId;
618 unsigned int endcapRingId =
barrel ? 0 : tTopo->
tidRing(innerDetId);
620 const unsigned int intDetId = innerDetId.
rawId();
640 stubRef->innerClusterPosition(),
645 stubMap[lastStub] = stubRef;
671 const unsigned int numStubChannel = maxNumProjectionLayers + numSeedingLayers;
673 const unsigned int numStreamsStubRaw = numStreamsTrack * numStubChannel;
676 vector<vector<string>> streamsTrackRaw(numStreamsTrack);
677 vector<vector<StubStreamData>> streamsStubRaw(numStreamsStubRaw);
683 if (
track.duplicate())
692 double tmp_chi2rphi =
track.chisqrphi();
693 double tmp_chi2rz =
track.chisqrz();
694 unsigned int tmp_hit =
track.hitpattern();
710 unsigned int trksector =
track.sector();
711 unsigned int trkseed = (
unsigned int)
abs(
track.seed());
713 aTrack.setPhiSector(trksector);
714 aTrack.setTrackSeedType(trkseed);
716 const vector<trklet::L1TStub>& stubptrs =
track.stubs();
717 vector<trklet::L1TStub>
stubs;
719 stubs.reserve(stubptrs.size());
720 for (
const auto& stubptr : stubptrs) {
721 stubs.push_back(stubptr);
725 stubMapType::const_iterator
it;
726 stubIndexMapType::const_iterator itIndex;
727 for (
const auto& itstubs :
stubs) {
728 itIndex = stubIndexMap.find(itstubs.uniqueIndex());
729 if (itIndex != stubIndexMap.end()) {
730 aTrack.addStubRef(itIndex->second);
731 countStubs = countStubs + 1;
738 aTrack.setStubPtConsistency(
742 aTrack.setTrackWordBits();
757 aTrack.setTrackWordBits();
761 L1TkTracksForOutput->push_back(aTrack);
770 Streams streamsTrack(numStreamsTrack);
773 for (
unsigned int chanTrk = 0; chanTrk < numStreamsTrack; chanTrk++) {
774 for (
unsigned int itk = 0; itk < streamsTrackRaw[chanTrk].size(); itk++) {
775 std::string bitsTrk = streamsTrackRaw[chanTrk][itk];
777 streamsTrack[chanTrk].emplace_back(bitsTrk);
779 const unsigned int chanStubOffsetIn = chanTrk * numStubChannel;
782 TTBV hitMap(0, numProjLayers + numSeedingLayers);
784 for (
unsigned int iproj = 0; iproj < numStubChannel; iproj++) {
786 const StubStreamData& stubdata = streamsStubRaw[chanStubOffsetIn + iproj][itk];
788 if (!stubdata.
valid())
790 const TTStubRef& ttStubRef = stubMap[stub];
791 const int seedType = stubdata.
iSeed();
794 hitMap.
set(channelId);
795 streamsStub[chanStubOffsetOut + channelId].emplace_back(ttStubRef, stubdata.
dataBits());
797 for (
int layerId : hitMap.
ids(
false)) {
798 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
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
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
int channelId(const TTTrackRef &ttTrackRef) const
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_
int numSeedingLayers() const
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
int layerId(const TTStubRef &ttStubRef) const
const std::string & dataBits() const
void initialise(unsigned int killScenario, const TrackerTopology *trackerTopology, const TrackerGeometry *trackerGeometry)
edm::FileInPath processingModulesFile
Abs< T >::type abs(const T &t)
const std::vector< int > & tfpRegions() const
const ChannelAssignment * channelAssignment_
bool killStub(const TTStub< Ref_Phase2TrackerDigi_ > *stub, const std::vector< int > layersToKill, const double minPhiToKill, const double maxPhiToKill, const double minZToKill, const double maxZToKill, const double minRToKill, const double maxRToKill, const double fractionOfStubsToKillInLayers, const double fractionOfStubsToKillEverywhere)
#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)
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_