50 return (Ref_L1A->pt() > Ref_L1B->pt());
58 if (Ref_L1A->hwQual() > Ref_L1B->hwQual())
60 if (Ref_L1A->hwQual() < Ref_L1B->hwQual())
64 return (Ref_L1A->pt() > Ref_L1B->pt());
70 theL1GMTReadoutCollection(iConfig.getParameter<
InputTag>(
"GMTReadoutCollection")),
72 theL1MinPt(iConfig.getParameter<double>(
"L1MinPt")),
73 theL1MaxEta(iConfig.getParameter<double>(
"L1MaxEta")),
74 theL1MinQuality(iConfig.getParameter<unsigned
int>(
"L1MinQuality")),
75 theMinPtBarrel(iConfig.getParameter<double>(
"SetMinPtBarrelTo")),
76 theMinPtEndcap(iConfig.getParameter<double>(
"SetMinPtEndcapTo")),
77 useOfflineSeed(iConfig.getUntrackedParameter<
bool>(
"UseOfflineSeed",
false)),
78 useUnassociatedL1(iConfig.getParameter<
bool>(
"UseUnassociatedL1")),
79 matchingDR(iConfig.getParameter<
std::
vector<double>>(
"MatchDR")),
81 centralBxOnly_(iConfig.getParameter<
bool>(
"CentralBxOnly")),
82 matchType(iConfig.getParameter<unsigned
int>(
"MatchType")),
83 sortType(iConfig.getParameter<unsigned
int>(
"SortType")) {
93 <<
"does not match number of eta bins." << endl;
98 throw cms::Exception(
"Configuration") <<
"Wrong MatchType or SortType" << endl;
110 produces<L2MuonTrajectorySeedCollection>();
125 desc.add<
string>(
"Propagator",
"");
126 desc.add<
double>(
"L1MinPt", -1.);
127 desc.add<
double>(
"L1MaxEta", 5.0);
128 desc.add<
unsigned int>(
"L1MinQuality", 0);
129 desc.add<
double>(
"SetMinPtBarrelTo", 3.5);
130 desc.add<
double>(
"SetMinPtEndcapTo", 1.0);
131 desc.addUntracked<
bool>(
"UseOfflineSeed",
false);
132 desc.add<
bool>(
"UseUnassociatedL1",
true);
133 desc.add<std::vector<double>>(
"MatchDR", {0.3});
134 desc.add<std::vector<double>>(
"EtaMatchingBins", {0., 2.5});
135 desc.add<
bool>(
"CentralBxOnly",
true);
136 desc.add<
unsigned int>(
"MatchType", 0)
138 "MatchType : 0 Old matching, 1 L1 Order(1to1), 2 Min dR(1to1), 3 Higher Q(1to1), 4 All matched L1");
139 desc.add<
unsigned int>(
"SortType", 0)->setComment(
"SortType : 0 not sort, 1 Pt, 2 Q and Pt");
143 psd0.
addUntracked<std::vector<std::string>>(
"Propagators", {
"SteppingHelixPropagatorAny"});
144 psd0.add<
bool>(
"RPCLayers",
true);
145 psd0.addUntracked<
bool>(
"UseMuonNavigation",
true);
147 descriptions.
add(
"L2MuonSeedGeneratorFromL1T",
desc);
154 auto output = std::make_unique<L2MuonTrajectorySeedCollection>();
163 vector<int> offlineSeedMap;
166 LogDebug(
metname) <<
"Number of offline seeds " << offlineSeedHandle->size() << endl;
167 offlineSeedMap = vector<int>(offlineSeedHandle->size(), 0);
173 for (
auto it = muColl->
begin(ibx); it != muColl->
end(ibx); it++) {
174 unsigned int quality = it->hwQual();
175 int valid_charge = it->hwChargeValid();
178 float eta = it->eta();
180 float phi = it->phi();
181 int charge = it->charge();
188 int link = 36 + (
int)(it->tfMuonIndex() / 3.);
214 CLHEP::Hep3Vector vec(0., 1., 0.);
225 detLayer =
theService->detLayerGeometry()->idToLayer(theid);
229 const BoundCylinder *bc = dynamic_cast<const BoundCylinder *>(sur);
243 detLayer =
theService->detLayerGeometry()->idToLayer(theid);
261 mat[0][0] = (0.25 /
pt) * (0.25 /
pt);
263 mat[0][0] = (0.4 /
pt) * (0.4 /
pt);
267 mat[0][0] = (1. /
pt) * (1. /
pt);
269 mat[1][1] = 0.05 * 0.05;
270 mat[2][2] = 0.2 * 0.2;
271 mat[3][3] = 20. * 20.;
272 mat[4][4] = 20. * 20.;
302 if (assoOffseed !=
nullptr) {
325 std::vector<pair<const GeomDet *, TrajectoryStateOnSurface>> detsWithStates =
328 if (detsWithStates.empty() &&
barrel) {
339 if (!detsWithStates.empty()) {
341 const GeomDet *newTSOSDet = detsWithStates.front().first;
357 if (assoOffseed !=
nullptr) {
395 unsigned int nMuColl = muColl->
size();
397 vector<vector<double>> dRmtx;
398 vector<vector<const TrajectorySeed *>> selOffseeds;
403 unsigned int nOfflineSeed = offlineSeedHandle->size();
404 LogDebug(
metname) <<
"Number of offline seeds " << nOfflineSeed << endl;
407 dRmtx = vector<vector<double>>(nMuColl, vector<double>(nOfflineSeed, 999.0));
409 vector<vector<const TrajectorySeed *>>(nMuColl, vector<const TrajectorySeed *>(nOfflineSeed,
nullptr));
419 for (
auto it = muColl->
begin(ibx); it != muColl->
end(ibx); it++) {
423 unsigned int quality = it->hwQual();
424 int valid_charge = it->hwChargeValid();
427 float eta = it->eta();
429 float phi = it->phi();
430 int charge = it->charge();
437 int link = 36 + (
int)(it->tfMuonIndex() / 3.);
463 CLHEP::Hep3Vector vec(0., 1., 0.);
474 detLayer =
theService->detLayerGeometry()->idToLayer(theid);
478 const BoundCylinder *bc = dynamic_cast<const BoundCylinder *>(sur);
492 detLayer =
theService->detLayerGeometry()->idToLayer(theid);
510 mat[0][0] = (0.25 /
pt) * (0.25 /
pt);
512 mat[0][0] = (0.4 /
pt) * (0.4 /
pt);
516 mat[0][0] = (1. /
pt) * (1. /
pt);
518 mat[1][1] = 0.05 * 0.05;
519 mat[2][2] = 0.2 * 0.2;
520 mat[3][3] = 20. * 20.;
521 mat[4][4] = 20. * 20.;
548 if ((!valid_charge ||
charge == 0)) {
571 else if (valid_charge) {
573 std::vector<pair<const GeomDet *, TrajectoryStateOnSurface>> detsWithStates =
576 if (detsWithStates.empty() &&
barrel) {
587 if (!detsWithStates.empty()) {
589 const GeomDet *newTSOSDet = detsWithStates.front().first;
639 unsigned int nOfflineSeed1 = offlineSeedHandle->size();
644 vector<bool> removed_col = vector<bool>(nOfflineSeed1,
false);
646 for (nL1 = 0; nL1 < nMuColl; ++nL1) {
648 unsigned int theOffs = 0;
650 for (
j = 0;
j < nOfflineSeed1; ++
j) {
653 if (tempDR > dRmtx[nL1][
j]) {
654 tempDR = dRmtx[nL1][
j];
662 if (fabs(it->eta()) <
etaBins.back()) {
667 if (!(tempDR < newDRcone))
671 removed_col[theOffs] =
true;
673 if (selOffseeds[nL1][theOffs] !=
nullptr) {
678 for (
auto const &
recHit : selOffseeds[nL1][theOffs]->
recHits()) {
690 vector<bool> removed_row = vector<bool>(nMuColl,
false);
691 vector<bool> removed_col = vector<bool>(nOfflineSeed1,
false);
693 for (nL1 = 0; nL1 < nMuColl; ++nL1) {
695 unsigned int theL1 = 0;
696 unsigned int theOffs = 0;
698 for (
i = 0;
i < nMuColl; ++
i) {
701 for (
j = 0;
j < nOfflineSeed1; ++
j) {
704 if (tempDR > dRmtx[
i][
j]) {
705 tempDR = dRmtx[
i][
j];
715 if (fabs(it->eta()) <
etaBins.back()) {
720 if (!(tempDR < newDRcone))
724 removed_col[theOffs] =
true;
725 removed_row[theL1] =
true;
727 if (selOffseeds[theL1][theOffs] !=
nullptr) {
732 for (
auto const &
recHit : selOffseeds[theL1][theOffs]->
recHits()) {
744 vector<bool> removed_row = vector<bool>(nMuColl,
false);
745 vector<bool> removed_col = vector<bool>(nOfflineSeed1,
false);
747 for (nL1 = 0; nL1 < nMuColl; ++nL1) {
749 unsigned int theL1 = 0;
750 unsigned int theOffs = 0;
754 for (
i = 0;
i < nMuColl; ++
i) {
758 if (theit->hwQual() > 10) {
759 for (
j = 0;
j < nOfflineSeed1; ++
j) {
762 if (tempDR > dRmtx[
i][
j]) {
763 tempDR = dRmtx[
i][
j];
773 for (
i = 0;
i < nMuColl; ++
i) {
777 if ((theit->hwQual() <= 10) && (theit->hwQual() > 6)) {
778 for (
j = 0;
j < nOfflineSeed1; ++
j) {
781 if (tempDR > dRmtx[
i][
j]) {
782 tempDR = dRmtx[
i][
j];
793 for (
i = 0;
i < nMuColl; ++
i) {
797 if (theit->hwQual() <= 6) {
798 for (
j = 0;
j < nOfflineSeed1; ++
j) {
801 if (tempDR > dRmtx[
i][
j]) {
802 tempDR = dRmtx[
i][
j];
814 if (fabs(it->eta()) <
etaBins.back()) {
819 if (!(tempDR < newDRcone))
823 removed_col[theOffs] =
true;
824 removed_row[theL1] =
true;
826 if (selOffseeds[theL1][theOffs] !=
nullptr) {
831 for (
auto const &
recHit : selOffseeds[theL1][theOffs]->
recHits()) {
843 for (
i = 0;
i < nMuColl; ++
i) {
847 unsigned int theOffs = 0;
850 if (fabs(it->eta()) <
etaBins.back()) {
855 for (
j = 0;
j < nOfflineSeed1; ++
j) {
856 if (tempDR > dRmtx[
i][
j]) {
857 tempDR = dRmtx[
i][
j];
862 if (!(tempDR < newDRcone))
865 if (selOffseeds[
i][theOffs] !=
nullptr) {
901 std::vector<int> &offseedMap,
904 const std::string metlabel =
"Muon|RecoMuon|L2MuonSeedGeneratorFromL1T";
909 double bestDr = 99999.;
910 unsigned int nOffseed(0);
913 for (offseed = offseeds->
begin(); offseed != endOffseed; ++offseed, ++nOffseed) {
914 if (offseedMap[nOffseed] != 0)
917 ->idToDet(offseed->startingState().detId())
919 .toGlobal(offseed->startingState().parameters().position());
921 ->idToDet(offseed->startingState().detId())
923 .toGlobal(offseed->startingState().parameters().momentum());
931 glbPos, glbMom, offseed->startingState().parameters().charge(), &*
theService->magneticField());
934 LogDebug(metlabel) <<
"Offline seed info: Det and State" << std::endl;
935 LogDebug(metlabel) << debugtmp.
dumpMuonId(offseed->startingState().detId()) << std::endl;
936 LogDebug(metlabel) <<
"pos: (r=" << offseedFTS.position().mag() <<
", phi=" << offseedFTS.position().phi()
937 <<
", eta=" << offseedFTS.position().eta() <<
")" << std::endl;
938 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedFTS.charge() * offseedFTS.momentum().perp()
939 <<
", phi=" << offseedFTS.momentum().phi() <<
", eta=" << offseedFTS.momentum().eta() <<
")"
943 if (offseedTsos.isValid()) {
944 LogDebug(metlabel) <<
"Offline seed info after propagation to L1 layer:" << std::endl;
945 LogDebug(metlabel) <<
"pos: (r=" << offseedTsos.globalPosition().mag()
946 <<
", phi=" << offseedTsos.globalPosition().phi()
947 <<
", eta=" << offseedTsos.globalPosition().eta() <<
")" << std::endl;
948 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedTsos.charge() * offseedTsos.globalMomentum().perp()
949 <<
", phi=" << offseedTsos.globalMomentum().phi()
950 <<
", eta=" << offseedTsos.globalMomentum().eta() <<
")" << std::endl
954 offseedTsos.globalPosition().eta(),
955 offseedTsos.globalPosition().
phi());
956 LogDebug(metlabel) <<
" -- DR = " << newDr << std::endl;
957 if (newDr <
dRcone && newDr < bestDr) {
958 LogDebug(metlabel) <<
" --> OK! " << newDr << std::endl << std::endl;
959 selOffseed = &*offseed;
961 offseedMap[nOffseed] = 1;
962 if (lastOffseed > -1)
963 offseedMap[lastOffseed] = 0;
964 lastOffseed = nOffseed;
966 LogDebug(metlabel) <<
" --> Rejected. " << newDr << std::endl << std::endl;
969 LogDebug(metlabel) <<
"Invalid offline seed TSOS after propagation!" << std::endl << std::endl;
981 std::vector<std::vector<const TrajectorySeed *>> &selOffseeds,
983 const std::string metlabel =
"Muon|RecoMuon|L2MuonSeedGeneratorFromL1T";
984 bool isAssociated =
false;
988 unsigned int nOffseed(0);
990 for (offseed = offseeds->
begin(); offseed != endOffseed; ++offseed, ++nOffseed) {
992 ->idToDet(offseed->startingState().detId())
994 .toGlobal(offseed->startingState().parameters().position());
996 ->idToDet(offseed->startingState().detId())
998 .toGlobal(offseed->startingState().parameters().momentum());
1006 glbPos, glbMom, offseed->startingState().parameters().charge(), &*
theService->magneticField());
1009 LogDebug(metlabel) <<
"Offline seed info: Det and State" << std::endl;
1010 LogDebug(metlabel) << debugtmp.
dumpMuonId(offseed->startingState().detId()) << std::endl;
1011 LogDebug(metlabel) <<
"pos: (r=" << offseedFTS.position().mag() <<
", phi=" << offseedFTS.position().phi()
1012 <<
", eta=" << offseedFTS.position().eta() <<
")" << std::endl;
1013 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedFTS.charge() * offseedFTS.momentum().perp()
1014 <<
", phi=" << offseedFTS.momentum().phi() <<
", eta=" << offseedFTS.momentum().eta() <<
")"
1018 if (offseedTsos.isValid()) {
1019 LogDebug(metlabel) <<
"Offline seed info after propagation to L1 layer:" << std::endl;
1020 LogDebug(metlabel) <<
"pos: (r=" << offseedTsos.globalPosition().mag()
1021 <<
", phi=" << offseedTsos.globalPosition().phi()
1022 <<
", eta=" << offseedTsos.globalPosition().eta() <<
")" << std::endl;
1023 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedTsos.charge() * offseedTsos.globalMomentum().perp()
1024 <<
", phi=" << offseedTsos.globalMomentum().phi()
1025 <<
", eta=" << offseedTsos.globalMomentum().eta() <<
")" << std::endl
1029 offseedTsos.globalPosition().eta(),
1030 offseedTsos.globalPosition().
phi());
1032 LogDebug(metlabel) <<
" -- DR = " << newDr << std::endl;
1034 LogDebug(metlabel) <<
" --> OK! " << newDr << std::endl << std::endl;
1036 dRmtx[imu][nOffseed] = newDr;
1037 selOffseeds[imu][nOffseed] = &*offseed;
1039 isAssociated =
true;
1041 LogDebug(metlabel) <<
" --> Rejected. " << newDr << std::endl << std::endl;
1044 LogDebug(metlabel) <<
"Invalid offline seed TSOS after propagation!" << std::endl << std::endl;
1048 return isAssociated;