CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L2MuonSeedGeneratorFromL1T Class Reference

#include <L2MuonSeedGeneratorFromL1T.h>

Inheritance diagram for L2MuonSeedGeneratorFromL1T:
edm::stream::EDProducer<>

Public Member Functions

 L2MuonSeedGeneratorFromL1T (const edm::ParameterSet &)
 Constructor. More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~L2MuonSeedGeneratorFromL1T () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

const TrajectorySeedassociateOfflineSeedToL1 (edm::Handle< edm::View< TrajectorySeed > > &, std::vector< int > &, TrajectoryStateOnSurface &, double)
 
bool isAssociateOfflineSeedToL1 (edm::Handle< edm::View< TrajectorySeed > > &, std::vector< std::vector< double > > &, TrajectoryStateOnSurface &, unsigned int, std::vector< std::vector< const TrajectorySeed * > > &, double)
 

Private Attributes

bool centralBxOnly_
 use central bx only muons More...
 
std::vector< double > etaBins
 
std::vector< double > matchingDR
 
const unsigned matchType
 
edm::EDGetTokenT< l1t::MuonBxCollectionmuCollToken_
 
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
 
const unsigned sortType
 
MeasurementEstimatortheEstimator
 
edm::InputTag theL1GMTReadoutCollection
 
const double theL1MaxEta
 
const double theL1MinPt
 
const unsigned theL1MinQuality
 
const double theMinPtBarrel
 
const double theMinPtEndcap
 
edm::InputTag theOfflineSeedLabel
 
std::string thePropagatorName
 
MuonServiceProxytheService
 the event setup proxy, it takes care the services update More...
 
edm::InputTag theSource
 
const bool useOfflineSeed
 
const bool useUnassociatedL1
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

L2 muon seed generator: Transform the L1 informations in seeds for the L2 muon reconstruction

Author
A.Everett, R.Bellan, J. Alcaraz

ORCA's author: N. Neumeister

Modified by M.Oh

L2 muon seed generator: Transform the L1 informations in seeds for the L2 muon reconstruction

Author
A.Everett, R.Bellan

ORCA's author: N. Neumeister

Modified by M.Oh

Definition at line 52 of file L2MuonSeedGeneratorFromL1T.h.

Constructor & Destructor Documentation

L2MuonSeedGeneratorFromL1T::L2MuonSeedGeneratorFromL1T ( const edm::ParameterSet iConfig)
explicit

Constructor.

Definition at line 67 of file L2MuonSeedGeneratorFromL1T.cc.

References Chi2MeasurementEstimator_cfi::Chi2MeasurementEstimator, etaBins, Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), matchingDR, matchType, muCollToken_, MuonServiceProxy_cff::MuonServiceProxy, offlineSeedToken_, sortType, theEstimator, theOfflineSeedLabel, theService, theSource, and useOfflineSeed.

68  : theSource(iConfig.getParameter<InputTag>("InputObjects")),
69  theL1GMTReadoutCollection(iConfig.getParameter<InputTag>("GMTReadoutCollection")), // to be removed
70  thePropagatorName(iConfig.getParameter<string>("Propagator")),
71  theL1MinPt(iConfig.getParameter<double>("L1MinPt")),
72  theL1MaxEta(iConfig.getParameter<double>("L1MaxEta")),
73  theL1MinQuality(iConfig.getParameter<unsigned int>("L1MinQuality")),
74  theMinPtBarrel(iConfig.getParameter<double>("SetMinPtBarrelTo")),
75  theMinPtEndcap(iConfig.getParameter<double>("SetMinPtEndcapTo")),
76  useOfflineSeed(iConfig.getUntrackedParameter<bool>("UseOfflineSeed", false)),
77  useUnassociatedL1(iConfig.getParameter<bool>("UseUnassociatedL1")),
78  matchingDR(iConfig.getParameter<std::vector<double>>("MatchDR")),
79  etaBins(iConfig.getParameter<std::vector<double>>("EtaMatchingBins")),
80  centralBxOnly_(iConfig.getParameter<bool>("CentralBxOnly")),
81  matchType(iConfig.getParameter<unsigned int>("MatchType")),
82  sortType(iConfig.getParameter<unsigned int>("SortType")) {
83  muCollToken_ = consumes<MuonBxCollection>(theSource);
84 
85  if (useOfflineSeed) {
86  theOfflineSeedLabel = iConfig.getUntrackedParameter<InputTag>("OfflineSeedLabel");
87  offlineSeedToken_ = consumes<edm::View<TrajectorySeed>>(theOfflineSeedLabel);
88 
89  // check that number of eta bins -1 matches number of dR cones
90  if (matchingDR.size() != etaBins.size() - 1) {
91  throw cms::Exception("Configuration") << "Size of MatchDR "
92  << "does not match number of eta bins." << endl;
93  }
94  }
95 
96  if (matchType > 4 || sortType > 3) {
97  throw cms::Exception("Configuration") << "Wrong MatchType or SortType" << endl;
98  }
99 
100  // service parameters
101  ParameterSet serviceParameters = iConfig.getParameter<ParameterSet>("ServiceParameters");
102 
103  // the services
104  theService = new MuonServiceProxy(serviceParameters);
105 
106  // the estimator
108 
109  produces<L2MuonTrajectorySeedCollection>();
110 }
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool centralBxOnly_
use central bx only muons
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
edm::EDGetTokenT< l1t::MuonBxCollection > muCollToken_
L2MuonSeedGeneratorFromL1T::~L2MuonSeedGeneratorFromL1T ( )
override

Destructor.

Definition at line 113 of file L2MuonSeedGeneratorFromL1T.cc.

References theEstimator, and theService.

113  {
114  if (theService)
115  delete theService;
116  if (theEstimator)
117  delete theEstimator;
118 }
MuonServiceProxy * theService
the event setup proxy, it takes care the services update

Member Function Documentation

const TrajectorySeed * L2MuonSeedGeneratorFromL1T::associateOfflineSeedToL1 ( edm::Handle< edm::View< TrajectorySeed > > &  ,
std::vector< int > &  ,
TrajectoryStateOnSurface ,
double   
)
private

Definition at line 909 of file L2MuonSeedGeneratorFromL1T.cc.

References edm::View< T >::begin(), PbPb_ZMuSkimMuonDPG_cff::deltaR, MuonPatternRecoDumper::dumpMuonId(), PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::globalPosition(), LogDebug, PV3DBase< T, PVType, FrameType >::phi(), Geom::Phi< T1, Range >::phi(), AlCaHLTBitMon_QueryRunRegistry::string, TrajectoryStateOnSurface::surface(), thePropagatorName, and theService.

Referenced by produce().

913  {
914  const std::string metlabel = "Muon|RecoMuon|L2MuonSeedGeneratorFromL1T";
915  MuonPatternRecoDumper debugtmp;
916 
917  edm::View<TrajectorySeed>::const_iterator offseed, endOffseed = offseeds->end();
918  const TrajectorySeed *selOffseed = nullptr;
919  double bestDr = 99999.;
920  unsigned int nOffseed(0);
921  int lastOffseed(-1);
922 
923  for (offseed = offseeds->begin(); offseed != endOffseed; ++offseed, ++nOffseed) {
924  if (offseedMap[nOffseed] != 0)
925  continue;
926  GlobalPoint glbPos = theService->trackingGeometry()
927  ->idToDet(offseed->startingState().detId())
928  ->surface()
929  .toGlobal(offseed->startingState().parameters().position());
930  GlobalVector glbMom = theService->trackingGeometry()
931  ->idToDet(offseed->startingState().detId())
932  ->surface()
933  .toGlobal(offseed->startingState().parameters().momentum());
934 
935  // Preliminary check
936  double preDr = deltaR(newTsos.globalPosition().eta(), newTsos.globalPosition().phi(), glbPos.eta(), glbPos.phi());
937  if (preDr > 1.0)
938  continue;
939 
940  const FreeTrajectoryState offseedFTS(
941  glbPos, glbMom, offseed->startingState().parameters().charge(), &*theService->magneticField());
942  TrajectoryStateOnSurface offseedTsos =
943  theService->propagator(thePropagatorName)->propagate(offseedFTS, newTsos.surface());
944  LogDebug(metlabel) << "Offline seed info: Det and State" << std::endl;
945  LogDebug(metlabel) << debugtmp.dumpMuonId(offseed->startingState().detId()) << std::endl;
946  LogDebug(metlabel) << "pos: (r=" << offseedFTS.position().mag() << ", phi=" << offseedFTS.position().phi()
947  << ", eta=" << offseedFTS.position().eta() << ")" << std::endl;
948  LogDebug(metlabel) << "mom: (q*pt=" << offseedFTS.charge() * offseedFTS.momentum().perp()
949  << ", phi=" << offseedFTS.momentum().phi() << ", eta=" << offseedFTS.momentum().eta() << ")"
950  << std::endl
951  << std::endl;
952 
953  if (offseedTsos.isValid()) {
954  LogDebug(metlabel) << "Offline seed info after propagation to L1 layer:" << std::endl;
955  LogDebug(metlabel) << "pos: (r=" << offseedTsos.globalPosition().mag()
956  << ", phi=" << offseedTsos.globalPosition().phi()
957  << ", eta=" << offseedTsos.globalPosition().eta() << ")" << std::endl;
958  LogDebug(metlabel) << "mom: (q*pt=" << offseedTsos.charge() * offseedTsos.globalMomentum().perp()
959  << ", phi=" << offseedTsos.globalMomentum().phi()
960  << ", eta=" << offseedTsos.globalMomentum().eta() << ")" << std::endl
961  << std::endl;
962  double newDr = deltaR(newTsos.globalPosition().eta(),
963  newTsos.globalPosition().phi(),
964  offseedTsos.globalPosition().eta(),
965  offseedTsos.globalPosition().phi());
966  LogDebug(metlabel) << " -- DR = " << newDr << std::endl;
967  if (newDr < dRcone && newDr < bestDr) {
968  LogDebug(metlabel) << " --> OK! " << newDr << std::endl << std::endl;
969  selOffseed = &*offseed;
970  bestDr = newDr;
971  offseedMap[nOffseed] = 1;
972  if (lastOffseed > -1)
973  offseedMap[lastOffseed] = 0;
974  lastOffseed = nOffseed;
975  } else {
976  LogDebug(metlabel) << " --> Rejected. " << newDr << std::endl << std::endl;
977  }
978  } else {
979  LogDebug(metlabel) << "Invalid offline seed TSOS after propagation!" << std::endl << std::endl;
980  }
981  }
982 
983  return selOffseed;
984 }
#define LogDebug(id)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
std::string dumpMuonId(const DetId &id) const
const_iterator begin() const
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
T eta() const
Definition: PV3DBase.h:73
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void L2MuonSeedGeneratorFromL1T::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 120 of file L2MuonSeedGeneratorFromL1T.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and HLT_2018_cff::InputTag.

120  {
122  desc.add<edm::InputTag>("GMTReadoutCollection", edm::InputTag("")); // to be removed
123  desc.add<edm::InputTag>("InputObjects", edm::InputTag("hltGmtStage2Digis"));
124  desc.add<string>("Propagator", "");
125  desc.add<double>("L1MinPt", -1.);
126  desc.add<double>("L1MaxEta", 5.0);
127  desc.add<unsigned int>("L1MinQuality", 0);
128  desc.add<double>("SetMinPtBarrelTo", 3.5);
129  desc.add<double>("SetMinPtEndcapTo", 1.0);
130  desc.addUntracked<bool>("UseOfflineSeed", false);
131  desc.add<bool>("UseUnassociatedL1", true);
132  desc.add<std::vector<double>>("MatchDR", {0.3});
133  desc.add<std::vector<double>>("EtaMatchingBins", {0., 2.5});
134  desc.add<bool>("CentralBxOnly", true);
135  desc.add<unsigned int>("MatchType", 0)
136  ->setComment(
137  "MatchType : 0 Old matching, 1 L1 Order(1to1), 2 Min dR(1to1), 3 Higher Q(1to1), 4 All matched L1");
138  desc.add<unsigned int>("SortType", 0)->setComment("SortType : 0 not sort, 1 Pt, 2 Q and Pt");
139  desc.addUntracked<edm::InputTag>("OfflineSeedLabel", edm::InputTag(""));
140 
142  psd0.addUntracked<std::vector<std::string>>("Propagators", {"SteppingHelixPropagatorAny"});
143  psd0.add<bool>("RPCLayers", true);
144  psd0.addUntracked<bool>("UseMuonNavigation", true);
145  desc.add<edm::ParameterSetDescription>("ServiceParameters", psd0);
146  descriptions.add("L2MuonSeedGeneratorFromL1T", desc);
147 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool L2MuonSeedGeneratorFromL1T::isAssociateOfflineSeedToL1 ( edm::Handle< edm::View< TrajectorySeed > > &  ,
std::vector< std::vector< double > > &  ,
TrajectoryStateOnSurface ,
unsigned  int,
std::vector< std::vector< const TrajectorySeed * > > &  ,
double   
)
private

Definition at line 986 of file L2MuonSeedGeneratorFromL1T.cc.

References edm::View< T >::begin(), PbPb_ZMuSkimMuonDPG_cff::deltaR, MuonPatternRecoDumper::dumpMuonId(), PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::globalPosition(), LogDebug, PV3DBase< T, PVType, FrameType >::phi(), Geom::Phi< T1, Range >::phi(), AlCaHLTBitMon_QueryRunRegistry::string, TrajectoryStateOnSurface::surface(), thePropagatorName, and theService.

Referenced by produce().

992  {
993  const std::string metlabel = "Muon|RecoMuon|L2MuonSeedGeneratorFromL1T";
994  bool isAssociated = false;
995  MuonPatternRecoDumper debugtmp;
996 
997  edm::View<TrajectorySeed>::const_iterator offseed, endOffseed = offseeds->end();
998  unsigned int nOffseed(0);
999 
1000  for (offseed = offseeds->begin(); offseed != endOffseed; ++offseed, ++nOffseed) {
1001  GlobalPoint glbPos = theService->trackingGeometry()
1002  ->idToDet(offseed->startingState().detId())
1003  ->surface()
1004  .toGlobal(offseed->startingState().parameters().position());
1005  GlobalVector glbMom = theService->trackingGeometry()
1006  ->idToDet(offseed->startingState().detId())
1007  ->surface()
1008  .toGlobal(offseed->startingState().parameters().momentum());
1009 
1010  // Preliminary check
1011  double preDr = deltaR(newTsos.globalPosition().eta(), newTsos.globalPosition().phi(), glbPos.eta(), glbPos.phi());
1012  if (preDr > 1.0)
1013  continue;
1014 
1015  const FreeTrajectoryState offseedFTS(
1016  glbPos, glbMom, offseed->startingState().parameters().charge(), &*theService->magneticField());
1017  TrajectoryStateOnSurface offseedTsos =
1018  theService->propagator(thePropagatorName)->propagate(offseedFTS, newTsos.surface());
1019  LogDebug(metlabel) << "Offline seed info: Det and State" << std::endl;
1020  LogDebug(metlabel) << debugtmp.dumpMuonId(offseed->startingState().detId()) << std::endl;
1021  LogDebug(metlabel) << "pos: (r=" << offseedFTS.position().mag() << ", phi=" << offseedFTS.position().phi()
1022  << ", eta=" << offseedFTS.position().eta() << ")" << std::endl;
1023  LogDebug(metlabel) << "mom: (q*pt=" << offseedFTS.charge() * offseedFTS.momentum().perp()
1024  << ", phi=" << offseedFTS.momentum().phi() << ", eta=" << offseedFTS.momentum().eta() << ")"
1025  << std::endl
1026  << std::endl;
1027 
1028  if (offseedTsos.isValid()) {
1029  LogDebug(metlabel) << "Offline seed info after propagation to L1 layer:" << std::endl;
1030  LogDebug(metlabel) << "pos: (r=" << offseedTsos.globalPosition().mag()
1031  << ", phi=" << offseedTsos.globalPosition().phi()
1032  << ", eta=" << offseedTsos.globalPosition().eta() << ")" << std::endl;
1033  LogDebug(metlabel) << "mom: (q*pt=" << offseedTsos.charge() * offseedTsos.globalMomentum().perp()
1034  << ", phi=" << offseedTsos.globalMomentum().phi()
1035  << ", eta=" << offseedTsos.globalMomentum().eta() << ")" << std::endl
1036  << std::endl;
1037  double newDr = deltaR(newTsos.globalPosition().eta(),
1038  newTsos.globalPosition().phi(),
1039  offseedTsos.globalPosition().eta(),
1040  offseedTsos.globalPosition().phi());
1041 
1042  LogDebug(metlabel) << " -- DR = " << newDr << std::endl;
1043  if (newDr < dRcone) {
1044  LogDebug(metlabel) << " --> OK! " << newDr << std::endl << std::endl;
1045 
1046  dRmtx[imu][nOffseed] = newDr;
1047  selOffseeds[imu][nOffseed] = &*offseed;
1048 
1049  isAssociated = true;
1050  } else {
1051  LogDebug(metlabel) << " --> Rejected. " << newDr << std::endl << std::endl;
1052  }
1053  } else {
1054  LogDebug(metlabel) << "Invalid offline seed TSOS after propagation!" << std::endl << std::endl;
1055  }
1056  }
1057 
1058  return isAssociated;
1059 }
#define LogDebug(id)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
std::string dumpMuonId(const DetId &id) const
const_iterator begin() const
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
T eta() const
Definition: PV3DBase.h:73
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void L2MuonSeedGeneratorFromL1T::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 149 of file L2MuonSeedGeneratorFromL1T.cc.

References alongMomentum, associateOfflineSeedToL1(), Reference_intrackfit_cff::barrel, centralBxOnly_, ALCARECOTkAlJpsiMuMu_cff::charge, TrajectoryStateOnSurface::charge(), GeometricSearchDet::compatibleDets(), funct::cos(), debug, HLT_2018_cff::distance, PFRecoTauChargedHadronBuilderPlugins_cfi::dRcone, MuonPatternRecoDumper::dumpFTS(), MuonPatternRecoDumper::dumpLayer(), MuonPatternRecoDumper::dumpMuonId(), MuonPatternRecoDumper::dumpTSOS(), relativeConstraints::error, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), etaBins, JetChargeProducer_cfi::exp, GeomDet::geographicalId(), edm::Event::getByToken(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, createfilelist::int, isAssociateOfflineSeedToL1(), TrajectoryStateOnSurface::isValid(), dqmiolumiharvest::j, MainPageGenerator::link, LogDebug, PV3DBase< T, PVType, FrameType >::mag(), matchingDR, matchType, metname, eostools::move(), muCollToken_, offlineSeedToken_, convertSQLitetoXML_cfg::output, PV3DBase< T, PVType, FrameType >::perp(), trajectoryStateTransform::persistentState(), phi, PV3DBase< T, PVType, FrameType >::phi(), Geom::pi(), GeometricSearchDet::position(), DiDispStaMuonMonitor_cfi::pt, edm::OwnVector< T, P >::push_back(), edm::Event::put(), qcdUeDQM_cfi::quality, CosmicsPD_Skims::radius, DetId::rawId(), TrajectorySeed::recHits(), funct::sin(), sortByL1Pt(), sortByL1QandPt(), sortType, TrajectorySeed::startingState(), AlCaHLTBitMon_QueryRunRegistry::string, GeometricSearchDet::surface(), theEstimator, theL1MaxEta, theL1MinPt, theL1MinQuality, theMinPtBarrel, theMinPtEndcap, thePropagatorName, theService, theta(), useOfflineSeed, useUnassociatedL1, and PV3DBase< T, PVType, FrameType >::z().

149  {
150  const std::string metname = "Muon|RecoMuon|L2MuonSeedGeneratorFromL1T";
152 
153  auto output = std::make_unique<L2MuonTrajectorySeedCollection>();
154 
156  iEvent.getByToken(muCollToken_, muColl);
157  LogDebug(metname) << "Number of muons " << muColl->size() << endl;
158 
159  //--- matchType 0 : Old logic
160  if (matchType == 0) {
161  edm::Handle<edm::View<TrajectorySeed>> offlineSeedHandle;
162  vector<int> offlineSeedMap;
163  if (useOfflineSeed) {
164  iEvent.getByToken(offlineSeedToken_, offlineSeedHandle);
165  LogDebug(metname) << "Number of offline seeds " << offlineSeedHandle->size() << endl;
166  offlineSeedMap = vector<int>(offlineSeedHandle->size(), 0);
167  }
168 
169  for (int ibx = muColl->getFirstBX(); ibx <= muColl->getLastBX(); ++ibx) {
170  if (centralBxOnly_ && (ibx != 0))
171  continue;
172  for (auto it = muColl->begin(ibx); it != muColl->end(ibx); it++) {
173  unsigned int quality = it->hwQual();
174  int valid_charge = it->hwChargeValid();
175 
176  float pt = it->pt();
177  float eta = it->eta();
178  float theta = 2 * atan(exp(-eta));
179  float phi = it->phi();
180  int charge = it->charge();
181  // Set charge=0 for the time being if the valid charge bit is zero
182  if (!valid_charge)
183  charge = 0;
184 
185  // link number indices of the optical fibres that connect the uGMT with the track finders
186  //EMTF+ : 36-41, OMTF+ : 42-47, BMTF : 48-59, OMTF- : 60-65, EMTF- : 66-71
187  int link = 36 + (int)(it->tfMuonIndex() / 3.);
188  bool barrel = true;
189  if ((link >= 36 && link <= 41) || (link >= 66 && link <= 71))
190  barrel = false;
191 
192  if (pt < theL1MinPt || fabs(eta) > theL1MaxEta)
193  continue;
194 
195  LogDebug(metname) << "New L2 Muon Seed";
196  LogDebug(metname) << "Pt = " << pt << " GeV/c";
197  LogDebug(metname) << "eta = " << eta;
198  LogDebug(metname) << "theta = " << theta << " rad";
199  LogDebug(metname) << "phi = " << phi << " rad";
200  LogDebug(metname) << "charge = " << charge;
201  LogDebug(metname) << "In Barrel? = " << barrel;
202 
203  if (quality <= theL1MinQuality)
204  continue;
205  LogDebug(metname) << "quality = " << quality;
206 
207  // Update the services
208  theService->update(iSetup);
209 
210  const DetLayer *detLayer = nullptr;
211  float radius = 0.;
212 
213  CLHEP::Hep3Vector vec(0., 1., 0.);
214  vec.setTheta(theta);
215  vec.setPhi(phi);
216 
217  DetId theid;
218  // Get the det layer on which the state should be put
219  if (barrel) {
220  LogDebug(metname) << "The seed is in the barrel";
221 
222  // MB2
223  theid = DTChamberId(0, 2, 0);
224  detLayer = theService->detLayerGeometry()->idToLayer(theid);
225  LogDebug(metname) << "L2 Layer: " << debug.dumpLayer(detLayer);
226 
227  const BoundSurface *sur = &(detLayer->surface());
228  const BoundCylinder *bc = dynamic_cast<const BoundCylinder *>(sur);
229 
230  radius = fabs(bc->radius() / sin(theta));
231 
232  LogDebug(metname) << "radius " << radius;
233 
234  if (pt < theMinPtBarrel)
235  pt = theMinPtBarrel;
236  } else {
237  LogDebug(metname) << "The seed is in the endcap";
238 
239  // ME2
240  theid = theta < Geom::pi() / 2. ? CSCDetId(1, 2, 0, 0, 0) : CSCDetId(2, 2, 0, 0, 0);
241 
242  detLayer = theService->detLayerGeometry()->idToLayer(theid);
243  LogDebug(metname) << "L2 Layer: " << debug.dumpLayer(detLayer);
244 
245  radius = fabs(detLayer->position().z() / cos(theta));
246 
247  if (pt < theMinPtEndcap)
248  pt = theMinPtEndcap;
249  }
250 
251  vec.setMag(radius);
252 
253  GlobalPoint pos(vec.x(), vec.y(), vec.z());
254 
255  GlobalVector mom(pt * cos(phi), pt * sin(phi), pt * cos(theta) / sin(theta));
256 
257  GlobalTrajectoryParameters param(pos, mom, charge, &*theService->magneticField());
259 
260  mat[0][0] = (0.25 / pt) * (0.25 / pt); // sigma^2(charge/abs_momentum)
261  if (!barrel)
262  mat[0][0] = (0.4 / pt) * (0.4 / pt);
263 
264  //Assign q/pt = 0 +- 1/pt if charge has been declared invalid
265  if (!valid_charge)
266  mat[0][0] = (1. / pt) * (1. / pt);
267 
268  mat[1][1] = 0.05 * 0.05; // sigma^2(lambda)
269  mat[2][2] = 0.2 * 0.2; // sigma^2(phi)
270  mat[3][3] = 20. * 20.; // sigma^2(x_transverse))
271  mat[4][4] = 20. * 20.; // sigma^2(y_transverse))
272 
274 
275  const FreeTrajectoryState state(param, error);
276 
277  LogDebug(metname) << "Free trajectory State from the parameters";
278  LogDebug(metname) << debug.dumpFTS(state);
279 
280  // Propagate the state on the MB2/ME2 surface
282  theService->propagator(thePropagatorName)->propagate(state, detLayer->surface());
283 
284  LogDebug(metname) << "State after the propagation on the layer";
285  LogDebug(metname) << debug.dumpLayer(detLayer);
286  LogDebug(metname) << debug.dumpTSOS(tsos);
287 
288  double dRcone = matchingDR[0];
289  if (fabs(eta) < etaBins.back()) {
290  std::vector<double>::iterator lowEdge = std::upper_bound(etaBins.begin(), etaBins.end(), fabs(eta));
291  dRcone = matchingDR.at(lowEdge - etaBins.begin() - 1);
292  }
293 
294  if (tsos.isValid()) {
296 
297  if (useOfflineSeed && (!valid_charge || charge == 0)) {
298  const TrajectorySeed *assoOffseed =
299  associateOfflineSeedToL1(offlineSeedHandle, offlineSeedMap, tsos, dRcone);
300 
301  if (assoOffseed != nullptr) {
302  PTrajectoryStateOnDet const &seedTSOS = assoOffseed->startingState();
303  TrajectorySeed::const_iterator tsci = assoOffseed->recHits().first, tscie = assoOffseed->recHits().second;
304  for (; tsci != tscie; ++tsci) {
305  container.push_back(*tsci);
306  }
307  output->push_back(
308  L2MuonTrajectorySeed(seedTSOS,
309  container,
311  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
312  } else {
313  if (useUnassociatedL1) {
314  // convert the TSOS into a PTSOD
316  output->push_back(
317  L2MuonTrajectorySeed(seedTSOS,
318  container,
320  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
321  }
322  }
323  } else if (useOfflineSeed && valid_charge) {
324  // Get the compatible dets on the layer
325  std::vector<pair<const GeomDet *, TrajectoryStateOnSurface>> detsWithStates =
326  detLayer->compatibleDets(tsos, *theService->propagator(thePropagatorName), *theEstimator);
327 
328  if (detsWithStates.empty() && barrel) {
329  // Fallback solution using ME2, try again to propagate but using ME2 as reference
330  DetId fallback_id;
331  theta < Geom::pi() / 2. ? fallback_id = CSCDetId(1, 2, 0, 0, 0) : fallback_id = CSCDetId(2, 2, 0, 0, 0);
332  const DetLayer *ME2DetLayer = theService->detLayerGeometry()->idToLayer(fallback_id);
333 
334  tsos = theService->propagator(thePropagatorName)->propagate(state, ME2DetLayer->surface());
335  detsWithStates =
336  ME2DetLayer->compatibleDets(tsos, *theService->propagator(thePropagatorName), *theEstimator);
337  }
338 
339  if (!detsWithStates.empty()) {
340  TrajectoryStateOnSurface newTSOS = detsWithStates.front().second;
341  const GeomDet *newTSOSDet = detsWithStates.front().first;
342 
343  LogDebug(metname) << "Most compatible det";
344  LogDebug(metname) << debug.dumpMuonId(newTSOSDet->geographicalId());
345 
346  if (newTSOS.isValid()) {
347  LogDebug(metname) << "pos: (r=" << newTSOS.globalPosition().mag()
348  << ", phi=" << newTSOS.globalPosition().phi()
349  << ", eta=" << newTSOS.globalPosition().eta() << ")";
350  LogDebug(metname) << "mom: (q*pt=" << newTSOS.charge() * newTSOS.globalMomentum().perp()
351  << ", phi=" << newTSOS.globalMomentum().phi()
352  << ", eta=" << newTSOS.globalMomentum().eta() << ")";
353 
354  const TrajectorySeed *assoOffseed =
355  associateOfflineSeedToL1(offlineSeedHandle, offlineSeedMap, newTSOS, dRcone);
356 
357  if (assoOffseed != nullptr) {
358  PTrajectoryStateOnDet const &seedTSOS = assoOffseed->startingState();
359  TrajectorySeed::const_iterator tsci = assoOffseed->recHits().first,
360  tscie = assoOffseed->recHits().second;
361  for (; tsci != tscie; ++tsci) {
362  container.push_back(*tsci);
363  }
364  output->push_back(
365  L2MuonTrajectorySeed(seedTSOS,
366  container,
368  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
369  } else {
370  if (useUnassociatedL1) {
371  // convert the TSOS into a PTSOD
372  PTrajectoryStateOnDet const &seedTSOS =
374  output->push_back(
375  L2MuonTrajectorySeed(seedTSOS,
376  container,
378  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
379  }
380  }
381  }
382  }
383  } else {
384  // convert the TSOS into a PTSOD
386  output->push_back(L2MuonTrajectorySeed(
387  seedTSOS, container, alongMomentum, MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
388  }
389  }
390  }
391  }
392 
393  } // End of matchType 0
394 
395  //--- matchType > 0 : Updated logics
396  else if (matchType > 0) {
397  unsigned int nMuColl = muColl->size();
398 
399  vector<vector<double>> dRmtx;
400  vector<vector<const TrajectorySeed *>> selOffseeds;
401 
402  edm::Handle<edm::View<TrajectorySeed>> offlineSeedHandle;
403  if (useOfflineSeed) {
404  iEvent.getByToken(offlineSeedToken_, offlineSeedHandle);
405  unsigned int nOfflineSeed = offlineSeedHandle->size();
406  LogDebug(metname) << "Number of offline seeds " << nOfflineSeed << endl;
407 
408  // Initialize dRmtx and selOffseeds
409  dRmtx = vector<vector<double>>(nMuColl, vector<double>(nOfflineSeed, 999.0));
410  selOffseeds =
411  vector<vector<const TrajectorySeed *>>(nMuColl, vector<const TrajectorySeed *>(nOfflineSeed, nullptr));
412  }
413 
414  // At least one L1 muons are associated with offSeed
415  bool isAsso = false;
416 
417  //--- Fill dR matrix
418  for (int ibx = muColl->getFirstBX(); ibx <= muColl->getLastBX(); ++ibx) {
419  if (centralBxOnly_ && (ibx != 0))
420  continue;
421  for (auto it = muColl->begin(ibx); it != muColl->end(ibx); it++) {
422  //Position of given L1mu
423  unsigned int imu = distance(muColl->begin(muColl->getFirstBX()), it);
424 
425  unsigned int quality = it->hwQual();
426  int valid_charge = it->hwChargeValid();
427 
428  float pt = it->pt();
429  float eta = it->eta();
430  float theta = 2 * atan(exp(-eta));
431  float phi = it->phi();
432  int charge = it->charge();
433  // Set charge=0 for the time being if the valid charge bit is zero
434  if (!valid_charge)
435  charge = 0;
436 
437  // link number indices of the optical fibres that connect the uGMT with the track finders
438  //EMTF+ : 36-41, OMTF+ : 42-47, BMTF : 48-59, OMTF- : 60-65, EMTF- : 66-71
439  int link = 36 + (int)(it->tfMuonIndex() / 3.);
440  bool barrel = true;
441  if ((link >= 36 && link <= 41) || (link >= 66 && link <= 71))
442  barrel = false;
443 
444  if (pt < theL1MinPt || fabs(eta) > theL1MaxEta)
445  continue;
446 
447  LogDebug(metname) << "New L2 Muon Seed";
448  LogDebug(metname) << "Pt = " << pt << " GeV/c";
449  LogDebug(metname) << "eta = " << eta;
450  LogDebug(metname) << "theta = " << theta << " rad";
451  LogDebug(metname) << "phi = " << phi << " rad";
452  LogDebug(metname) << "charge = " << charge;
453  LogDebug(metname) << "In Barrel? = " << barrel;
454 
455  if (quality <= theL1MinQuality)
456  continue;
457  LogDebug(metname) << "quality = " << quality;
458 
459  // Update the services
460  theService->update(iSetup);
461 
462  const DetLayer *detLayer = nullptr;
463  float radius = 0.;
464 
465  CLHEP::Hep3Vector vec(0., 1., 0.);
466  vec.setTheta(theta);
467  vec.setPhi(phi);
468 
469  DetId theid;
470  // Get the det layer on which the state should be put
471  if (barrel) {
472  LogDebug(metname) << "The seed is in the barrel";
473 
474  // MB2
475  theid = DTChamberId(0, 2, 0);
476  detLayer = theService->detLayerGeometry()->idToLayer(theid);
477  LogDebug(metname) << "L2 Layer: " << debug.dumpLayer(detLayer);
478 
479  const BoundSurface *sur = &(detLayer->surface());
480  const BoundCylinder *bc = dynamic_cast<const BoundCylinder *>(sur);
481 
482  radius = fabs(bc->radius() / sin(theta));
483 
484  LogDebug(metname) << "radius " << radius;
485 
486  if (pt < theMinPtBarrel)
487  pt = theMinPtBarrel;
488  } else {
489  LogDebug(metname) << "The seed is in the endcap";
490 
491  // ME2
492  theid = theta < Geom::pi() / 2. ? CSCDetId(1, 2, 0, 0, 0) : CSCDetId(2, 2, 0, 0, 0);
493 
494  detLayer = theService->detLayerGeometry()->idToLayer(theid);
495  LogDebug(metname) << "L2 Layer: " << debug.dumpLayer(detLayer);
496 
497  radius = fabs(detLayer->position().z() / cos(theta));
498 
499  if (pt < theMinPtEndcap)
500  pt = theMinPtEndcap;
501  }
502 
503  vec.setMag(radius);
504 
505  GlobalPoint pos(vec.x(), vec.y(), vec.z());
506 
507  GlobalVector mom(pt * cos(phi), pt * sin(phi), pt * cos(theta) / sin(theta));
508 
509  GlobalTrajectoryParameters param(pos, mom, charge, &*theService->magneticField());
511 
512  mat[0][0] = (0.25 / pt) * (0.25 / pt); // sigma^2(charge/abs_momentum)
513  if (!barrel)
514  mat[0][0] = (0.4 / pt) * (0.4 / pt);
515 
516  //Assign q/pt = 0 +- 1/pt if charge has been declared invalid
517  if (!valid_charge)
518  mat[0][0] = (1. / pt) * (1. / pt);
519 
520  mat[1][1] = 0.05 * 0.05; // sigma^2(lambda)
521  mat[2][2] = 0.2 * 0.2; // sigma^2(phi)
522  mat[3][3] = 20. * 20.; // sigma^2(x_transverse))
523  mat[4][4] = 20. * 20.; // sigma^2(y_transverse))
524 
526 
527  const FreeTrajectoryState state(param, error);
528 
529  LogDebug(metname) << "Free trajectory State from the parameters";
530  LogDebug(metname) << debug.dumpFTS(state);
531 
532  // Propagate the state on the MB2/ME2 surface
534  theService->propagator(thePropagatorName)->propagate(state, detLayer->surface());
535 
536  LogDebug(metname) << "State after the propagation on the layer";
537  LogDebug(metname) << debug.dumpLayer(detLayer);
538  LogDebug(metname) << debug.dumpTSOS(tsos);
539 
540  double dRcone = matchingDR[0];
541  if (fabs(eta) < etaBins.back()) {
542  std::vector<double>::iterator lowEdge = std::upper_bound(etaBins.begin(), etaBins.end(), fabs(eta));
543  dRcone = matchingDR.at(lowEdge - etaBins.begin() - 1);
544  }
545 
546  if (tsos.isValid()) {
548 
549  if (useOfflineSeed) {
550  if ((!valid_charge || charge == 0)) {
551  bool isAssoOffseed = isAssociateOfflineSeedToL1(offlineSeedHandle, dRmtx, tsos, imu, selOffseeds, dRcone);
552 
553  if (isAssoOffseed) {
554  isAsso = true;
555  }
556 
557  // Using old way
558  else {
559  if (useUnassociatedL1) {
560  // convert the TSOS into a PTSOD
561  PTrajectoryStateOnDet const &seedTSOS =
563  output->push_back(
564  L2MuonTrajectorySeed(seedTSOS,
565  container,
567  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
568  }
569  }
570 
571  }
572 
573  else if (valid_charge) {
574  // Get the compatible dets on the layer
575  std::vector<pair<const GeomDet *, TrajectoryStateOnSurface>> detsWithStates =
576  detLayer->compatibleDets(tsos, *theService->propagator(thePropagatorName), *theEstimator);
577 
578  if (detsWithStates.empty() && barrel) {
579  // Fallback solution using ME2, try again to propagate but using ME2 as reference
580  DetId fallback_id;
581  theta < Geom::pi() / 2. ? fallback_id = CSCDetId(1, 2, 0, 0, 0) : fallback_id = CSCDetId(2, 2, 0, 0, 0);
582  const DetLayer *ME2DetLayer = theService->detLayerGeometry()->idToLayer(fallback_id);
583 
584  tsos = theService->propagator(thePropagatorName)->propagate(state, ME2DetLayer->surface());
585  detsWithStates =
586  ME2DetLayer->compatibleDets(tsos, *theService->propagator(thePropagatorName), *theEstimator);
587  }
588 
589  if (!detsWithStates.empty()) {
590  TrajectoryStateOnSurface newTSOS = detsWithStates.front().second;
591  const GeomDet *newTSOSDet = detsWithStates.front().first;
592 
593  LogDebug(metname) << "Most compatible det";
594  LogDebug(metname) << debug.dumpMuonId(newTSOSDet->geographicalId());
595 
596  if (newTSOS.isValid()) {
597  LogDebug(metname) << "pos: (r=" << newTSOS.globalPosition().mag()
598  << ", phi=" << newTSOS.globalPosition().phi()
599  << ", eta=" << newTSOS.globalPosition().eta() << ")";
600  LogDebug(metname) << "mom: (q*pt=" << newTSOS.charge() * newTSOS.globalMomentum().perp()
601  << ", phi=" << newTSOS.globalMomentum().phi()
602  << ", eta=" << newTSOS.globalMomentum().eta() << ")";
603 
604  bool isAssoOffseed =
605  isAssociateOfflineSeedToL1(offlineSeedHandle, dRmtx, newTSOS, imu, selOffseeds, dRcone);
606 
607  if (isAssoOffseed) {
608  isAsso = true;
609  }
610 
611  // Using old way
612  else {
613  if (useUnassociatedL1) {
614  // convert the TSOS into a PTSOD
615  PTrajectoryStateOnDet const &seedTSOS =
617  output->push_back(
618  L2MuonTrajectorySeed(seedTSOS,
619  container,
621  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
622  }
623  }
624  }
625  }
626  }
627  } // useOfflineSeed
628 
629  else {
630  // convert the TSOS into a PTSOD
632  output->push_back(L2MuonTrajectorySeed(
633  seedTSOS, container, alongMomentum, MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
634  }
635  }
636  }
637  }
638 
639  // MatchType : 0 Old matching, 1 L1 Order(1to1), 2 Min dR(1to1), 3 Higher Q(1to1), 4 All matched L1
640  if (useOfflineSeed && isAsso) {
641  unsigned int nOfflineSeed1 = offlineSeedHandle->size();
642  unsigned int nL1;
643  unsigned int i, j; // for the matrix element
644 
645  if (matchType == 1) {
646  vector<bool> removed_col = vector<bool>(nOfflineSeed1, false);
647 
648  for (nL1 = 0; nL1 < nMuColl; ++nL1) {
649  double tempDR = 99.;
650  unsigned int theOffs = 0;
651 
652  for (j = 0; j < nOfflineSeed1; ++j) {
653  if (removed_col[j])
654  continue;
655  if (tempDR > dRmtx[nL1][j]) {
656  tempDR = dRmtx[nL1][j];
657  theOffs = j;
658  }
659  }
660 
661  auto it = muColl->begin(muColl->getFirstBX()) + nL1;
662 
663  double newDRcone = matchingDR[0];
664  if (fabs(it->eta()) < etaBins.back()) {
665  std::vector<double>::iterator lowEdge = std::upper_bound(etaBins.begin(), etaBins.end(), fabs(it->eta()));
666  newDRcone = matchingDR.at(lowEdge - etaBins.begin() - 1);
667  }
668 
669  if (!(tempDR < newDRcone))
670  continue;
671 
672  // Remove column for given offSeed
673  removed_col[theOffs] = true;
674 
675  if (selOffseeds[nL1][theOffs] != nullptr) {
676  //put given L1mu and offSeed to output
677  edm::OwnVector<TrackingRecHit> newContainer;
678 
679  PTrajectoryStateOnDet const &seedTSOS = selOffseeds[nL1][theOffs]->startingState();
680  TrajectorySeed::const_iterator tsci = selOffseeds[nL1][theOffs]->recHits().first,
681  tscie = selOffseeds[nL1][theOffs]->recHits().second;
682  for (; tsci != tscie; ++tsci) {
683  newContainer.push_back(*tsci);
684  }
685  output->push_back(L2MuonTrajectorySeed(seedTSOS,
686  newContainer,
688  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
689  }
690  }
691  }
692 
693  else if (matchType == 2) {
694  vector<bool> removed_row = vector<bool>(nMuColl, false);
695  vector<bool> removed_col = vector<bool>(nOfflineSeed1, false);
696 
697  for (nL1 = 0; nL1 < nMuColl; ++nL1) {
698  double tempDR = 99.;
699  unsigned int theL1 = 0;
700  unsigned int theOffs = 0;
701 
702  for (i = 0; i < nMuColl; ++i) {
703  if (removed_row[i])
704  continue;
705  for (j = 0; j < nOfflineSeed1; ++j) {
706  if (removed_col[j])
707  continue;
708  if (tempDR > dRmtx[i][j]) {
709  tempDR = dRmtx[i][j];
710  theL1 = i;
711  theOffs = j;
712  }
713  }
714  }
715 
716  auto it = muColl->begin(muColl->getFirstBX()) + theL1;
717 
718  double newDRcone = matchingDR[0];
719  if (fabs(it->eta()) < etaBins.back()) {
720  std::vector<double>::iterator lowEdge = std::upper_bound(etaBins.begin(), etaBins.end(), fabs(it->eta()));
721  newDRcone = matchingDR.at(lowEdge - etaBins.begin() - 1);
722  }
723 
724  if (!(tempDR < newDRcone))
725  continue;
726 
727  // Remove row and column for given (L1mu, offSeed)
728  removed_col[theOffs] = true;
729  removed_row[theL1] = true;
730 
731  if (selOffseeds[theL1][theOffs] != nullptr) {
732  //put given L1mu and offSeed to output
733  edm::OwnVector<TrackingRecHit> newContainer;
734 
735  PTrajectoryStateOnDet const &seedTSOS = selOffseeds[theL1][theOffs]->startingState();
736  TrajectorySeed::const_iterator tsci = selOffseeds[theL1][theOffs]->recHits().first,
737  tscie = selOffseeds[theL1][theOffs]->recHits().second;
738  for (; tsci != tscie; ++tsci) {
739  newContainer.push_back(*tsci);
740  }
741  output->push_back(L2MuonTrajectorySeed(seedTSOS,
742  newContainer,
744  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
745  }
746  }
747  }
748 
749  else if (matchType == 3) {
750  vector<bool> removed_row = vector<bool>(nMuColl, false);
751  vector<bool> removed_col = vector<bool>(nOfflineSeed1, false);
752 
753  for (nL1 = 0; nL1 < nMuColl; ++nL1) {
754  double tempDR = 99.;
755  unsigned int theL1 = 0;
756  unsigned int theOffs = 0;
757  auto theit = muColl->begin(muColl->getFirstBX());
758 
759  // L1Q > 10 (L1Q = 12)
760  for (i = 0; i < nMuColl; ++i) {
761  if (removed_row[i])
762  continue;
763  theit = muColl->begin(muColl->getFirstBX()) + i;
764  if (theit->hwQual() > 10) {
765  for (j = 0; j < nOfflineSeed1; ++j) {
766  if (removed_col[j])
767  continue;
768  if (tempDR > dRmtx[i][j]) {
769  tempDR = dRmtx[i][j];
770  theL1 = i;
771  theOffs = j;
772  }
773  }
774  }
775  }
776 
777  // 6 < L1Q <= 10 (L1Q = 8)
778  if (tempDR == 99.) {
779  for (i = 0; i < nMuColl; ++i) {
780  if (removed_row[i])
781  continue;
782  theit = muColl->begin(muColl->getFirstBX()) + i;
783  if ((theit->hwQual() <= 10) && (theit->hwQual() > 6)) {
784  for (j = 0; j < nOfflineSeed1; ++j) {
785  if (removed_col[j])
786  continue;
787  if (tempDR > dRmtx[i][j]) {
788  tempDR = dRmtx[i][j];
789  theL1 = i;
790  theOffs = j;
791  }
792  }
793  }
794  }
795  }
796 
797  // L1Q <= 6 (L1Q = 4)
798  if (tempDR == 99.) {
799  for (i = 0; i < nMuColl; ++i) {
800  if (removed_row[i])
801  continue;
802  theit = muColl->begin(muColl->getFirstBX()) + i;
803  if (theit->hwQual() <= 6) {
804  for (j = 0; j < nOfflineSeed1; ++j) {
805  if (removed_col[j])
806  continue;
807  if (tempDR > dRmtx[i][j]) {
808  tempDR = dRmtx[i][j];
809  theL1 = i;
810  theOffs = j;
811  }
812  }
813  }
814  }
815  }
816 
817  auto it = muColl->begin(muColl->getFirstBX()) + theL1;
818 
819  double newDRcone = matchingDR[0];
820  if (fabs(it->eta()) < etaBins.back()) {
821  std::vector<double>::iterator lowEdge = std::upper_bound(etaBins.begin(), etaBins.end(), fabs(it->eta()));
822  newDRcone = matchingDR.at(lowEdge - etaBins.begin() - 1);
823  }
824 
825  if (!(tempDR < newDRcone))
826  continue;
827 
828  // Remove row and column for given (L1mu, offSeed)
829  removed_col[theOffs] = true;
830  removed_row[theL1] = true;
831 
832  if (selOffseeds[theL1][theOffs] != nullptr) {
833  //put given L1mu and offSeed to output
834  edm::OwnVector<TrackingRecHit> newContainer;
835 
836  PTrajectoryStateOnDet const &seedTSOS = selOffseeds[theL1][theOffs]->startingState();
837  TrajectorySeed::const_iterator tsci = selOffseeds[theL1][theOffs]->recHits().first,
838  tscie = selOffseeds[theL1][theOffs]->recHits().second;
839  for (; tsci != tscie; ++tsci) {
840  newContainer.push_back(*tsci);
841  }
842  output->push_back(L2MuonTrajectorySeed(seedTSOS,
843  newContainer,
845  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
846  }
847  }
848  }
849 
850  else if (matchType == 4) {
851  for (i = 0; i < nMuColl; ++i) {
852  auto it = muColl->begin(muColl->getFirstBX()) + i;
853 
854  double tempDR = 99.;
855  unsigned int theOffs = 0;
856 
857  double newDRcone = matchingDR[0];
858  if (fabs(it->eta()) < etaBins.back()) {
859  std::vector<double>::iterator lowEdge = std::upper_bound(etaBins.begin(), etaBins.end(), fabs(it->eta()));
860  newDRcone = matchingDR.at(lowEdge - etaBins.begin() - 1);
861  }
862 
863  for (j = 0; j < nOfflineSeed1; ++j) {
864  if (tempDR > dRmtx[i][j]) {
865  tempDR = dRmtx[i][j];
866  theOffs = j;
867  }
868  }
869 
870  if (!(tempDR < newDRcone))
871  continue;
872 
873  if (selOffseeds[i][theOffs] != nullptr) {
874  //put given L1mu and offSeed to output
875  edm::OwnVector<TrackingRecHit> newContainer;
876 
877  PTrajectoryStateOnDet const &seedTSOS = selOffseeds[i][theOffs]->startingState();
878  TrajectorySeed::const_iterator tsci = selOffseeds[i][theOffs]->recHits().first,
879  tscie = selOffseeds[i][theOffs]->recHits().second;
880  for (; tsci != tscie; ++tsci) {
881  newContainer.push_back(*tsci);
882  }
883  output->push_back(L2MuonTrajectorySeed(seedTSOS,
884  newContainer,
886  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()), it))));
887  }
888  }
889  }
890 
891  } // useOfflineSeed && isAsso
892 
893  } // matchType > 0
894 
895  //--- SortType 1 : by L1 pT
896  if (sortType == 1) {
897  sort(output->begin(), output->end(), sortByL1Pt);
898  }
899 
900  //--- SortType 2 : by L1 quality and pT
901  else if (sortType == 2) {
902  sort(output->begin(), output->end(), sortByL1QandPt);
903  }
904 
905  iEvent.put(std::move(output));
906 }
#define LogDebug(id)
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
T perp() const
Definition: PV3DBase.h:69
bool centralBxOnly_
use central bx only muons
std::string dumpLayer(const DetLayer *layer) const
const TrajectorySeed * associateOfflineSeedToL1(edm::Handle< edm::View< TrajectorySeed > > &, std::vector< int > &, TrajectoryStateOnSurface &, double)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
bool sortByL1Pt(L2MuonTrajectorySeed &A, L2MuonTrajectorySeed &B)
const std::string metname
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Geom::Theta< T > theta() const
GlobalPoint globalPosition() const
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
std::string dumpMuonId(const DetId &id) const
std::string dumpFTS(const FreeTrajectoryState &fts) const
std::string dumpTSOS(const TrajectoryStateOnSurface &tsos) const
void push_back(D *&d)
Definition: OwnVector.h:326
T mag() const
Definition: PV3DBase.h:64
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
recHitContainer::const_iterator const_iterator
T z() const
Definition: PV3DBase.h:61
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool isAssociateOfflineSeedToL1(edm::Handle< edm::View< TrajectorySeed > > &, std::vector< std::vector< double > > &, TrajectoryStateOnSurface &, unsigned int, std::vector< std::vector< const TrajectorySeed * > > &, double)
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
bool sortByL1QandPt(L2MuonTrajectorySeed &A, L2MuonTrajectorySeed &B)
Definition: DetId.h:17
PTrajectoryStateOnDet const & startingState() const
#define debug
Definition: HDRShower.cc:19
virtual const Surface::PositionType & position() const
Returns position of the surface.
range recHits() const
edm::EDGetTokenT< l1t::MuonBxCollection > muCollToken_
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
T eta() const
Definition: PV3DBase.h:73
GlobalVector globalMomentum() const
edm::Ref< MuonBxCollection > MuonRef
Definition: Muon.h:13
constexpr double pi()
Definition: Pi.h:31
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool L2MuonSeedGeneratorFromL1T::centralBxOnly_
private

use central bx only muons

Definition at line 83 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

std::vector<double> L2MuonSeedGeneratorFromL1T::etaBins
private

Definition at line 80 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

std::vector<double> L2MuonSeedGeneratorFromL1T::matchingDR
private

Definition at line 79 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

const unsigned L2MuonSeedGeneratorFromL1T::matchType
private

Definition at line 84 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

edm::EDGetTokenT<l1t::MuonBxCollection> L2MuonSeedGeneratorFromL1T::muCollToken_
private

Definition at line 69 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

edm::EDGetTokenT<edm::View<TrajectorySeed> > L2MuonSeedGeneratorFromL1T::offlineSeedToken_
private

Definition at line 70 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

const unsigned L2MuonSeedGeneratorFromL1T::sortType
private

Definition at line 85 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

MeasurementEstimator* L2MuonSeedGeneratorFromL1T::theEstimator
private
edm::InputTag L2MuonSeedGeneratorFromL1T::theL1GMTReadoutCollection
private

Definition at line 65 of file L2MuonSeedGeneratorFromL1T.h.

const double L2MuonSeedGeneratorFromL1T::theL1MaxEta
private

Definition at line 73 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

const double L2MuonSeedGeneratorFromL1T::theL1MinPt
private

Definition at line 72 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

const unsigned L2MuonSeedGeneratorFromL1T::theL1MinQuality
private

Definition at line 74 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

const double L2MuonSeedGeneratorFromL1T::theMinPtBarrel
private

Definition at line 75 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

const double L2MuonSeedGeneratorFromL1T::theMinPtEndcap
private

Definition at line 76 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

edm::InputTag L2MuonSeedGeneratorFromL1T::theOfflineSeedLabel
private

Definition at line 66 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T().

std::string L2MuonSeedGeneratorFromL1T::thePropagatorName
private
MuonServiceProxy* L2MuonSeedGeneratorFromL1T::theService
private

the event setup proxy, it takes care the services update

Definition at line 88 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by associateOfflineSeedToL1(), isAssociateOfflineSeedToL1(), L2MuonSeedGeneratorFromL1T(), produce(), and ~L2MuonSeedGeneratorFromL1T().

edm::InputTag L2MuonSeedGeneratorFromL1T::theSource
private

Definition at line 64 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T().

const bool L2MuonSeedGeneratorFromL1T::useOfflineSeed
private

Definition at line 77 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

const bool L2MuonSeedGeneratorFromL1T::useUnassociatedL1
private

Definition at line 78 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().