132 return (
b.x() >
a.x());
133 else if (
a.y() !=
b.y())
134 return (
b.y() >
a.y());
135 else if (
a.z() !=
b.z())
136 return (
a.z() >
b.z());
138 return a.bend() >
b.bend();
228 readMoreMcTruth_(iConfig.getParameter<
bool>(
"readMoreMcTruth")),
239 putTokenTracks_(produces<
Streams>(
"Level1TTTracks")),
241 putTokenStubs_(produces<
StreamsStub>(
"Level1TTTracks")),
254 produces<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>(
"Level1TTTracks").setBranchAlias(
"Level1TTTracks");
328 exception.addContext(
"L1FPGATrackProducer::produce");
330 exception <<
"Storing of TrackBuilder output does not support doMultipleMatches.";
332 exception <<
"Storing of TrackBuilder output does not support duplicate removal.";
383 auto L1TkTracksForOutput = std::make_unique<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>();
386 stubIndexMapType stubIndexMap;
397 ev.setIP(bsPosition.x(), bsPosition.y());
411 if (failScenario_ < 0 || failScenario_ > 9) {
425 map<edm::Ptr<TrackingParticle>,
int> translateTP;
439 for (
const auto& iterTP : *TrackingParticleHandle) {
444 if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
447 if (iterTP.g4Tracks().empty()) {
451 int sim_eventid = iterTP.g4Tracks().at(0).eventId().event();
452 int sim_type = iterTP.pdgId();
453 float sim_pt = iterTP.pt();
454 float sim_eta = iterTP.eta();
455 float sim_phi = iterTP.phi();
457 float vx = iterTP.vertex().x();
458 float vy = iterTP.vertex().y();
459 float vz = iterTP.vertex().z();
464 ev.addL1SimTrack(sim_eventid, ntps, sim_type, sim_pt, sim_eta, sim_phi,
vx,
vy,
vz);
466 translateTP[tp_ptr] = ntps;
479 unsigned int theStubIndex = 0;
481 for (
const int& channel : handleDTC->
tfpChannels()) {
483 unsigned int atcaSlot = channel % 12;
485 if (channel % 24 >= 12)
486 dtcname =
"neg" + dtcname;
487 dtcname += (channel < 24) ?
"_A" :
"_B";
494 for (
size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) {
504 string layerword = stub.second.to_string().substr(61, 2);
505 unsigned int layercode = 2 * (layerword[0] -
'0') + layerword[1] -
'0';
511 static const int layerdisktab[12][4] = {{0, 6, 8, 10},
524 int layerdisk = layerdisktab[channel % 12][layercode];
530 constexpr int LayerandStatusCodeSize = 3;
532 stub.second.to_string().substr(DTCLinkWordSize - StubWordSize - LayerandStatusCodeSize, StubWordSize);
533 string stubwordhex =
"";
536 for (
unsigned int i = 0;
i < 9;
i++) {
537 bitset<4>
bits(stubword.substr(
i * 4, 4));
539 stubwordhex += ((
val < 10) ? (
'0' +
val) : (
'A' +
val - 10));
544 innerCluster = stub.first->clusterRef(0);
546 outerCluster = stub.first->clusterRef(1);
552 const DetId innerDetId = innerCluster->getDetId();
554 const auto* theGeomDet_inner =
dynamic_cast<const PixelGeomDetUnit*
>(det_inner);
557 MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered();
559 GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner);
561 const DetId outerDetId = outerCluster->getDetId();
563 const auto* theGeomDet_outer =
dynamic_cast<const PixelGeomDetUnit*
>(det_outer);
566 MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered();
568 GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer);
570 bool isFlipped = (posStub_outer.
mag() < posStub_inner.
mag());
572 vector<int> assocTPs;
574 for (
unsigned int iClus = 0; iClus <= 1; iClus++) {
576 const TTClusterRef& ttClusterRef = stubRef->clusterRef(iClus);
580 vector<edm::Ptr<TrackingParticle>> vecTpPtr =
581 MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
584 if (translateTP.find(tpPtr) != translateTP.end()) {
586 assocTPs.push_back(translateTP.at(tpPtr));
588 assocTPs.push_back(-translateTP.at(tpPtr));
592 assocTPs.push_back(0);
598 double stubbend = stubRef->bendFE();
599 if (ttPos.
z() < -120) {
600 stubbend = -stubbend;
605 enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 };
606 const TypeBarrel
type =
static_cast<TypeBarrel
>(tTopo->
tobSide(innerDetId));
607 bool tiltedBarrel =
barrel && (
type == tiltedMinus ||
type == tiltedPlus);
608 unsigned int tiltedRingId = 0;
611 tiltedRingId = tTopo->
tobRod(innerDetId);
612 if (
type == tiltedMinus) {
613 unsigned int layp1 = 1 + layerdisk;
615 tiltedRingId = 1 + nTilted - tiltedRingId;
619 unsigned int endcapRingId =
barrel ? 0 : tTopo->
tidRing(innerDetId);
621 const unsigned int intDetId = innerDetId.
rawId();
641 stubRef->innerClusterPosition(),
646 stubMap[lastStub] = stubRef;
672 const unsigned int numStubChannel = maxNumProjectionLayers + numSeedingLayers;
674 const unsigned int numStreamsStubRaw = numStreamsTrack * numStubChannel;
677 vector<vector<string>> streamsTrackRaw(numStreamsTrack);
678 vector<vector<StubStreamData>> streamsStubRaw(numStreamsStubRaw);
684 if (
track.duplicate())
693 double tmp_chi2rphi =
track.chisqrphi();
694 double tmp_chi2rz =
track.chisqrz();
695 unsigned int tmp_hit =
track.hitpattern();
711 unsigned int trksector =
track.sector();
712 unsigned int trkseed = (
unsigned int)
abs(
track.seed());
714 aTrack.setPhiSector(trksector);
715 aTrack.setTrackSeedType(trkseed);
717 const vector<trklet::L1TStub>& stubptrs =
track.stubs();
718 vector<trklet::L1TStub> stubs;
720 stubs.reserve(stubptrs.size());
721 for (
const auto& stubptr : stubptrs) {
722 stubs.push_back(stubptr);
726 stubMapType::const_iterator
it;
727 stubIndexMapType::const_iterator itIndex;
728 for (
const auto& itstubs : stubs) {
729 itIndex = stubIndexMap.find(itstubs.uniqueIndex());
730 if (itIndex != stubIndexMap.end()) {
731 aTrack.addStubRef(itIndex->second);
732 countStubs = countStubs + 1;
739 aTrack.setStubPtConsistency(
743 aTrack.setTrackWordBits();
757 L1TkTracksForOutput->push_back(aTrack);
766 Streams streamsTrack(numStreamsTrack);
769 for (
unsigned int chanTrk = 0; chanTrk < numStreamsTrack; chanTrk++) {
770 for (
unsigned int itk = 0; itk < streamsTrackRaw[chanTrk].size(); itk++) {
771 std::string bitsTrk = streamsTrackRaw[chanTrk][itk];
773 streamsTrack[chanTrk].emplace_back(bitsTrk);
775 const unsigned int chanStubOffsetIn = chanTrk * numStubChannel;
778 TTBV hitMap(0, numProjLayers + numSeedingLayers);
780 for (
unsigned int iproj = 0; iproj < numStubChannel; iproj++) {
782 const StubStreamData& stubdata = streamsStubRaw[chanStubOffsetIn + iproj][itk];
784 if (!stubdata.
valid())
786 const TTStubRef& ttStubRef = stubMap[stub];
787 const int seedType = stubdata.
iSeed();
790 hitMap.
set(channelId);
791 streamsStub[chanStubOffsetOut + channelId].emplace_back(ttStubRef, stubdata.
dataBits());
793 for (
int layerId : hitMap.
ids(
false)) {
794 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_