122 return (y.x() > x.x());
125 return (y.y() > x.y());
127 return (x.z() > y.z());
204 readMoreMcTruth_(iConfig.getParameter<
bool>(
"readMoreMcTruth")),
225 produces<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>(
"Level1TTTracks").setBranchAlias(
"Level1TTTracks");
324 auto L1TkTracksForOutput = std::make_unique<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>();
346 ev.setIPx(bsPosition.x());
347 ev.setIPy(bsPosition.y());
367 map<edm::Ptr<TrackingParticle>,
int> translateTP;
382 for (
const auto& iterTP : *TrackingParticleHandle) {
387 if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
390 if (iterTP.g4Tracks().empty()) {
394 int sim_eventid = iterTP.g4Tracks().at(0).eventId().event();
395 int sim_type = iterTP.pdgId();
396 float sim_pt = iterTP.pt();
397 float sim_eta = iterTP.eta();
398 float sim_phi = iterTP.phi();
400 float vx = iterTP.vertex().x();
401 float vy = iterTP.vertex().y();
402 float vz = iterTP.vertex().z();
404 if (sim_pt < 1.0 ||
std::abs(vz) > 100.0 || hypot(vx, vy) > 50.0)
407 ev.addL1SimTrack(sim_eventid, ntps, sim_type, sim_pt, sim_eta, sim_phi, vx, vy, vz);
409 translateTP[tp_ptr] = ntps;
423 for (
const auto& gd : theTrackerGeom->
dets()) {
424 DetId detid = (*gd).geographicalId();
431 if (Phase2TrackerDigiTTStubHandle->find(stackDetid) == Phase2TrackerDigiTTStubHandle->end())
437 const auto* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(det0);
438 const PixelTopology* topol = dynamic_cast<const PixelTopology*>(&(theGeomDet->specificTopology()));
443 if (isPSmodule && firstPS) {
449 if (!isPSmodule && first2S) {
457 for (
auto stubIter = stubs.
begin(); stubIter != stubs.
end(); ++stubIter) {
461 vector<int> assocTPs;
464 for (
unsigned int iClus = 0; iClus <= 1; iClus++) {
466 const TTClusterRef& ttClusterRef = tempStubPtr->clusterRef(iClus);
469 vector<edm::Ptr<TrackingParticle>> vecTpPtr = MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
472 if (translateTP.find(tpPtr) != translateTP.end()) {
474 assocTPs.push_back(translateTP.at(tpPtr));
476 assocTPs.push_back(-translateTP.at(tpPtr));
480 assocTPs.push_back(0);
486 MeasurementPoint coords = tempStubPtr->clusterRef(0)->findAverageLocalCoordinatesCentered();
488 GlobalPoint posStub = theGeomDet->surface().toGlobal(clustlp);
498 int module = -999999;
503 layer = static_cast<int>(tTopo->
layer(detid));
504 module = static_cast<int>(tTopo->
module(detid));
511 enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 };
512 const TypeBarrel
type = static_cast<TypeBarrel>(tTopo->
tobSide(detid));
519 if (
type == tiltedMinus) {
520 module = static_cast<int>(tTopo->
tobRod(detid));
523 if (
type == tiltedPlus) {
533 layer = 1000 + static_cast<int>(tTopo->
tidRing(detid));
535 module = static_cast<int>(tTopo->
tidWheel(detid));
540 tempStubPtr->clusterRef(0);
542 tempStubPtr->clusterRef(1);
544 std::vector<int> irphi;
545 std::vector<int> innerrows = innerCluster->getRows();
546 irphi.reserve(innerrows.size());
547 for (
int innerrow : innerrows) {
548 irphi.push_back(innerrow);
550 std::vector<int> outerrows = outerCluster->getRows();
551 for (
int outerrow : outerrows) {
552 irphi.push_back(outerrow);
559 const DetId innerDetId = innerCluster->getDetId();
561 const auto* theGeomDet_inner = dynamic_cast<const PixelGeomDetUnit*>(det_inner);
562 const PixelTopology* topol_inner = dynamic_cast<const PixelTopology*>(&(theGeomDet_inner->specificTopology()));
564 MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered();
566 GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner);
568 const DetId outerDetId = outerCluster->getDetId();
570 const auto* theGeomDet_outer = dynamic_cast<const PixelGeomDetUnit*>(det_outer);
571 const PixelTopology* topol_outer = dynamic_cast<const PixelTopology*>(&(theGeomDet_outer->specificTopology()));
573 MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered();
575 GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer);
577 bool isFlipped = (posStub_outer.
mag() < posStub_inner.
mag());
581 float stub_bend = tempStubPtr->bendFE();
583 if (layer > 999 && posStub.
z() < 0.0) {
584 stub_bend = -stub_bend;
586 if (!irphi.empty()) {
591 if ((tempStubPtr->rawBend() < 100.) && (
ev.addStub(layer,
605 stubMap[lastStub] = tempStubPtr;
627 if (
track->duplicate())
638 double tmp_chi2rphi =
track->chisqrphi();
639 double tmp_chi2rz =
track->chisqrz();
640 unsigned int tmp_hit =
track->hitpattern();
656 unsigned int trksector =
track->sector();
657 unsigned int trkseed = (
unsigned int)
abs(
track->seed());
659 aTrack.setPhiSector(trksector);
660 aTrack.setTrackSeedType(trkseed);
662 const vector<const trklet::L1TStub*>& stubptrs =
track->stubs();
663 vector<trklet::L1TStub> stubs;
665 stubs.reserve(stubptrs.size());
666 for (
auto stubptr : stubptrs) {
667 stubs.push_back(*stubptr);
670 stubMapType::const_iterator it;
671 for (
const auto& itstubs : stubs) {
672 it = stubMap.find(itstubs);
673 if (it != stubMap.end()) {
674 aTrack.addStubRef(it->second);
681 aTrack.setStubPtConsistency(
685 aTrack.setTrackWordBits();
690 L1TkTracksForOutput->push_back(aTrack);