131 return (
b.x() >
a.x());
134 return (
b.y() >
a.y());
136 return (
a.z() >
b.z());
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.";
373 auto L1TkTracksForOutput = std::make_unique<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>();
386 ev.setIP(bsPosition.x(), bsPosition.y());
403 map<edm::Ptr<TrackingParticle>,
int> translateTP;
417 for (
const auto& iterTP : *TrackingParticleHandle) {
422 if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
425 if (iterTP.g4Tracks().empty()) {
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();
435 float vx = iterTP.vertex().x();
436 float vy = iterTP.vertex().y();
437 float vz = iterTP.vertex().z();
439 if (sim_pt < 1.0 ||
std::abs(vz) > 100.0 || hypot(vx, vy) > 50.0)
442 ev.addL1SimTrack(sim_eventid, ntps, sim_type, sim_pt, sim_eta, sim_phi, vx, vy, vz);
444 translateTP[tp_ptr] = ntps;
458 for (
const int& channel : handleDTC->
tfpChannels()) {
460 unsigned int atcaSlot = channel % 12;
462 if (channel % 24 >= 12)
463 dtcname =
"neg" + dtcname;
464 dtcname += (channel < 24) ?
"_A" :
"_B";
471 for (
size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) {
481 string layerword = stub.second.to_string().substr(61, 2);
482 unsigned int layercode = 2 * (layerword[0] -
'0') + layerword[1] -
'0';
488 static const int layerdisktab[12][4] = {{0, 6, 8, 10},
501 int layerdisk = layerdisktab[channel % 12][layercode];
505 constexpr
int DTCLinkWordSize = 64;
506 constexpr
int StubWordSize = 36;
507 constexpr
int LayerandStatusCodeSize = 3;
509 stub.second.to_string().substr(DTCLinkWordSize - StubWordSize - LayerandStatusCodeSize, StubWordSize);
510 string stubwordhex =
"";
513 for (
unsigned int i = 0;
i < 9;
i++) {
514 bitset<4>
bits(stubword.substr(
i * 4, 4));
516 stubwordhex += ((
val < 10) ? (
'0' +
val) : (
'A' +
val - 10));
521 innerCluster = stub.first->clusterRef(0);
523 outerCluster = stub.first->clusterRef(1);
529 const DetId innerDetId = innerCluster->getDetId();
531 const auto* theGeomDet_inner =
dynamic_cast<const PixelGeomDetUnit*
>(det_inner);
534 MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered();
536 GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner);
538 const DetId outerDetId = outerCluster->getDetId();
540 const auto* theGeomDet_outer =
dynamic_cast<const PixelGeomDetUnit*
>(det_outer);
543 MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered();
545 GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer);
547 bool isFlipped = (posStub_outer.
mag() < posStub_inner.
mag());
549 vector<int> assocTPs;
551 for (
unsigned int iClus = 0; iClus <= 1; iClus++) {
553 const TTClusterRef& ttClusterRef = stubRef->clusterRef(iClus);
557 vector<edm::Ptr<TrackingParticle>> vecTpPtr =
558 MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
561 if (translateTP.find(tpPtr) != translateTP.end()) {
563 assocTPs.push_back(translateTP.at(tpPtr));
565 assocTPs.push_back(-translateTP.at(tpPtr));
569 assocTPs.push_back(0);
575 double stubbend = stubRef->bendFE();
576 if (ttPos.
z() < -120) {
577 stubbend = -stubbend;
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;
588 tiltedRingId = tTopo->
tobRod(innerDetId);
589 if (
type == tiltedMinus) {
590 unsigned int layp1 = 1 + layerdisk;
592 tiltedRingId = 1 + nTilted - tiltedRingId;
596 unsigned int endcapRingId =
barrel ? 0 : tTopo->
tidRing(innerDetId);
598 const unsigned int intDetId = innerDetId.
rawId();
614 stubRef->innerClusterPosition(),
618 stubMap[lastStub] = stubRef;
638 const unsigned int numStreamsStubRaw = numStreamsTrack * maxNumProjectionLayers;
641 vector<vector<string>> streamsTrackRaw(numStreamsTrack);
642 vector<vector<StubStreamData>> streamsStubRaw(numStreamsStubRaw);
650 if (
track.duplicate())
661 double tmp_chi2rphi =
track.chisqrphi();
662 double tmp_chi2rz =
track.chisqrz();
663 unsigned int tmp_hit =
track.hitpattern();
679 unsigned int trksector =
track.sector();
680 unsigned int trkseed = (
unsigned int)
abs(
track.seed());
682 aTrack.setPhiSector(trksector);
683 aTrack.setTrackSeedType(trkseed);
685 const vector<trklet::L1TStub>& stubptrs =
track.stubs();
686 vector<trklet::L1TStub> stubs;
688 stubs.reserve(stubptrs.size());
689 for (
const auto& stubptr : stubptrs) {
690 stubs.push_back(stubptr);
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);
704 aTrack.setStubPtConsistency(
708 aTrack.setTrackWordBits();
717 L1TkTracksForOutput->push_back(aTrack);
726 Streams streamsTrack(numStreamsTrack);
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];
733 streamsTrack[chanTrk].emplace_back(bitsTrk);
735 const unsigned int chanStubOffsetIn = chanTrk * maxNumProjectionLayers;
738 TTBV hitMap(0, numProjLayers);
740 for (
unsigned int iproj = 0; iproj < maxNumProjectionLayers; iproj++) {
742 const StubStreamData& stubdata = streamsStubRaw[chanStubOffsetIn + iproj][itk];
744 if (stubdata.
valid()) {
745 const TTStubRef ttStubRef = stubMap[stub];
750 streamsStub[chanStubOffsetOut + layerId].emplace_back(ttStubRef, stubdata.
dataBits());
753 for (
int layerId : hitMap.
ids(
false)) {
754 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)
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)
float getConsistency(TTTrack< Ref_Phase2TrackerDigi_ > aTrack, const TrackerGeometry *theTrackerGeom, const TrackerTopology *tTopo, double mMagneticFieldStrength, int nPar)
const ESGetToken< ChannelAssignment, ChannelAssignmentRcd > esGetTokenChannelAssignment_