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::L2MuonSeedGeneratorFromL1T ( const edm::ParameterSet iConfig)
explicit

Constructor.

Definition at line 68 of file L2MuonSeedGeneratorFromL1T.cc.

69  : theSource(iConfig.getParameter<InputTag>("InputObjects")),
70  theL1GMTReadoutCollection(iConfig.getParameter<InputTag>("GMTReadoutCollection")), // to be removed
71  thePropagatorName(iConfig.getParameter<string>("Propagator")),
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")),
80  etaBins(iConfig.getParameter<std::vector<double>>("EtaMatchingBins")),
81  centralBxOnly_(iConfig.getParameter<bool>("CentralBxOnly")),
82  matchType(iConfig.getParameter<unsigned int>("MatchType")),
83  sortType(iConfig.getParameter<unsigned int>("SortType")) {
84  muCollToken_ = consumes<MuonBxCollection>(theSource);
85 
86  if (useOfflineSeed) {
87  theOfflineSeedLabel = iConfig.getUntrackedParameter<InputTag>("OfflineSeedLabel");
88  offlineSeedToken_ = consumes<edm::View<TrajectorySeed>>(theOfflineSeedLabel);
89 
90  // check that number of eta bins -1 matches number of dR cones
91  if (matchingDR.size() != etaBins.size() - 1) {
92  throw cms::Exception("Configuration") << "Size of MatchDR "
93  << "does not match number of eta bins." << endl;
94  }
95  }
96 
97  if (matchType > 4 || sortType > 3) {
98  throw cms::Exception("Configuration") << "Wrong MatchType or SortType" << endl;
99  }
100 
101  // service parameters
102  ParameterSet serviceParameters = iConfig.getParameter<ParameterSet>("ServiceParameters");
103 
104  // the services
105  theService = new MuonServiceProxy(serviceParameters, consumesCollector());
106 
107  // the estimator
109 
110  produces<L2MuonTrajectorySeedCollection>();
111 }

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.

◆ ~L2MuonSeedGeneratorFromL1T()

L2MuonSeedGeneratorFromL1T::~L2MuonSeedGeneratorFromL1T ( )
override

Destructor.

Definition at line 114 of file L2MuonSeedGeneratorFromL1T.cc.

114  {
115  if (theService)
116  delete theService;
117  if (theEstimator)
118  delete theEstimator;
119 }

References theEstimator, and theService.

Member Function Documentation

◆ associateOfflineSeedToL1()

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

Definition at line 910 of file L2MuonSeedGeneratorFromL1T.cc.

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

References edm::View< T >::begin(), PbPb_ZMuSkimMuonDPG_cff::deltaR, PFRecoTauChargedHadronBuilderPlugins_cfi::dRcone, 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().

◆ fillDescriptions()

void L2MuonSeedGeneratorFromL1T::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 121 of file L2MuonSeedGeneratorFromL1T.cc.

121  {
123  desc.add<edm::InputTag>("GMTReadoutCollection", edm::InputTag("")); // to be removed
124  desc.add<edm::InputTag>("InputObjects", edm::InputTag("hltGmtStage2Digis"));
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)
137  ->setComment(
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");
140  desc.addUntracked<edm::InputTag>("OfflineSeedLabel", edm::InputTag(""));
141 
143  psd0.addUntracked<std::vector<std::string>>("Propagators", {"SteppingHelixPropagatorAny"});
144  psd0.add<bool>("RPCLayers", true);
145  psd0.addUntracked<bool>("UseMuonNavigation", true);
146  desc.add<edm::ParameterSetDescription>("ServiceParameters", psd0);
147  descriptions.add("L2MuonSeedGeneratorFromL1T", desc);
148 }

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

◆ isAssociateOfflineSeedToL1()

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 987 of file L2MuonSeedGeneratorFromL1T.cc.

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

References edm::View< T >::begin(), PbPb_ZMuSkimMuonDPG_cff::deltaR, PFRecoTauChargedHadronBuilderPlugins_cfi::dRcone, 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().

◆ produce()

void L2MuonSeedGeneratorFromL1T::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 150 of file L2MuonSeedGeneratorFromL1T.cc.

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

References alongMomentum, associateOfflineSeedToL1(), Reference_intrackfit_cff::barrel, BXVector< T >::begin(), centralBxOnly_, ALCARECOTkAlJpsiMuMu_cff::charge, TrajectoryStateOnSurface::charge(), GeometricSearchDet::compatibleDets(), funct::cos(), debug, HLT_2018_cff::distance, PFRecoTauChargedHadronBuilderPlugins_cfi::dRcone, BXVector< T >::end(), relativeConstraints::error, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), etaBins, JetChargeProducer_cfi::exp, GeomDet::geographicalId(), BXVector< T >::getFirstBX(), BXVector< T >::getLastBX(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, iEvent, 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(), qcdUeDQM_cfi::quality, CosmicsPD_Skims::radius, DetId::rawId(), TrajectorySeed::recHits(), funct::sin(), BXVector< T >::size(), sortByL1Pt(), sortByL1QandPt(), sortType, TrajectorySeed::startingState(), AlCaHLTBitMon_QueryRunRegistry::string, GeometricSearchDet::surface(), theEstimator, theL1MaxEta, theL1MinPt, theL1MinQuality, theMinPtBarrel, theMinPtEndcap, thePropagatorName, theService, theta(), cuda_std::upper_bound(), useOfflineSeed, useUnassociatedL1, and PV3DBase< T, PVType, FrameType >::z().

Member Data Documentation

◆ centralBxOnly_

bool L2MuonSeedGeneratorFromL1T::centralBxOnly_
private

use central bx only muons

Definition at line 83 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

◆ etaBins

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

Definition at line 80 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

◆ matchingDR

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

Definition at line 79 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

◆ matchType

const unsigned L2MuonSeedGeneratorFromL1T::matchType
private

Definition at line 84 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

◆ muCollToken_

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

Definition at line 69 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

◆ offlineSeedToken_

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

Definition at line 70 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

◆ sortType

const unsigned L2MuonSeedGeneratorFromL1T::sortType
private

Definition at line 85 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

◆ theEstimator

MeasurementEstimator* L2MuonSeedGeneratorFromL1T::theEstimator
private

◆ theL1GMTReadoutCollection

edm::InputTag L2MuonSeedGeneratorFromL1T::theL1GMTReadoutCollection
private

Definition at line 65 of file L2MuonSeedGeneratorFromL1T.h.

◆ theL1MaxEta

const double L2MuonSeedGeneratorFromL1T::theL1MaxEta
private

Definition at line 73 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

◆ theL1MinPt

const double L2MuonSeedGeneratorFromL1T::theL1MinPt
private

Definition at line 72 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

◆ theL1MinQuality

const unsigned L2MuonSeedGeneratorFromL1T::theL1MinQuality
private

Definition at line 74 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

◆ theMinPtBarrel

const double L2MuonSeedGeneratorFromL1T::theMinPtBarrel
private

Definition at line 75 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

◆ theMinPtEndcap

const double L2MuonSeedGeneratorFromL1T::theMinPtEndcap
private

Definition at line 76 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

◆ theOfflineSeedLabel

edm::InputTag L2MuonSeedGeneratorFromL1T::theOfflineSeedLabel
private

Definition at line 66 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T().

◆ thePropagatorName

std::string L2MuonSeedGeneratorFromL1T::thePropagatorName
private

◆ theService

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().

◆ theSource

edm::InputTag L2MuonSeedGeneratorFromL1T::theSource
private

Definition at line 64 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T().

◆ useOfflineSeed

const bool L2MuonSeedGeneratorFromL1T::useOfflineSeed
private

Definition at line 77 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

◆ useUnassociatedL1

const bool L2MuonSeedGeneratorFromL1T::useUnassociatedL1
private

Definition at line 78 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

Vector3DBase
Definition: Vector3DBase.h:8
L2MuonSeedGeneratorFromL1T::muCollToken_
edm::EDGetTokenT< l1t::MuonBxCollection > muCollToken_
Definition: L2MuonSeedGeneratorFromL1T.h:69
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
GeomDet
Definition: GeomDet.h:27
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
DetLayer
Definition: DetLayer.h:21
MuonPatternRecoDumper::dumpMuonId
std::string dumpMuonId(const DetId &id) const
Definition: MuonPatternRecoDumper.cc:66
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
pos
Definition: PixelAliasList.h:18
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
L2MuonSeedGeneratorFromL1T::useUnassociatedL1
const bool useUnassociatedL1
Definition: L2MuonSeedGeneratorFromL1T.h:78
TrajectoryStateOnSurface::charge
TrackCharge charge() const
Definition: TrajectoryStateOnSurface.h:68
sortByL1Pt
bool sortByL1Pt(L2MuonTrajectorySeed &A, L2MuonTrajectorySeed &B)
Definition: L2MuonSeedGeneratorFromL1T.cc:47
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
TrajectorySeed::const_iterator
recHitContainer::const_iterator const_iterator
Definition: TrajectorySeed.h:20
Surface
Definition: Surface.h:36
L2MuonSeedGeneratorFromL1T::associateOfflineSeedToL1
const TrajectorySeed * associateOfflineSeedToL1(edm::Handle< edm::View< TrajectorySeed > > &, std::vector< int > &, TrajectoryStateOnSurface &, double)
Definition: L2MuonSeedGeneratorFromL1T.cc:910
GeometricSearchDet::compatibleDets
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: GeometricSearchDet.cc:35
L2MuonSeedGeneratorFromL1T::theEstimator
MeasurementEstimator * theEstimator
Definition: L2MuonSeedGeneratorFromL1T.h:90
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
L2MuonSeedGeneratorFromL1T::theService
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
Definition: L2MuonSeedGeneratorFromL1T.h:88
GeometricSearchDet::position
virtual const Surface::PositionType & position() const
Returns position of the surface.
Definition: GeometricSearchDet.h:31
edm::Handle
Definition: AssociativeIterator.h:50
relativeConstraints.error
error
Definition: relativeConstraints.py:53
MuonServiceProxy_cff.MuonServiceProxy
MuonServiceProxy
Definition: MuonServiceProxy_cff.py:15
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
L2MuonSeedGeneratorFromL1T::sortType
const unsigned sortType
Definition: L2MuonSeedGeneratorFromL1T.h:85
L2MuonSeedGeneratorFromL1T::theOfflineSeedLabel
edm::InputTag theOfflineSeedLabel
Definition: L2MuonSeedGeneratorFromL1T.h:66
BXVector::getFirstBX
int getFirstBX() const
DetId
Definition: DetId.h:17
L2MuonSeedGeneratorFromL1T::theMinPtBarrel
const double theMinPtBarrel
Definition: L2MuonSeedGeneratorFromL1T.h:75
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
debug
#define debug
Definition: HDRShower.cc:19
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
MuonPatternRecoDumper
Definition: MuonPatternRecoDumper.h:18
cuda_std::upper_bound
__host__ constexpr __device__ RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:45
L2MuonSeedGeneratorFromL1T::theL1MinQuality
const unsigned theL1MinQuality
Definition: L2MuonSeedGeneratorFromL1T.h:74
PVValHelper::eta
Definition: PVValidationHelpers.h:69
L2MuonSeedGeneratorFromL1T::isAssociateOfflineSeedToL1
bool isAssociateOfflineSeedToL1(edm::Handle< edm::View< TrajectorySeed > > &, std::vector< std::vector< double > > &, TrajectoryStateOnSurface &, unsigned int, std::vector< std::vector< const TrajectorySeed * > > &, double)
Definition: L2MuonSeedGeneratorFromL1T.cc:987
Chi2MeasurementEstimator_cfi.Chi2MeasurementEstimator
Chi2MeasurementEstimator
Definition: Chi2MeasurementEstimator_cfi.py:3
Geom::pi
constexpr double pi()
Definition: Pi.h:31
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
L2MuonSeedGeneratorFromL1T::thePropagatorName
std::string thePropagatorName
Definition: L2MuonSeedGeneratorFromL1T.h:67
Point3DBase< float, GlobalTag >
BXVector::begin
const_iterator begin(int bx) const
L2MuonSeedGeneratorFromL1T::matchingDR
std::vector< double > matchingDR
Definition: L2MuonSeedGeneratorFromL1T.h:79
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L2MuonSeedGeneratorFromL1T::theL1GMTReadoutCollection
edm::InputTag theL1GMTReadoutCollection
Definition: L2MuonSeedGeneratorFromL1T.h:65
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
L2MuonSeedGeneratorFromL1T::centralBxOnly_
bool centralBxOnly_
use central bx only muons
Definition: L2MuonSeedGeneratorFromL1T.h:83
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
BXVector::end
const_iterator end(int bx) const
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
l1t::MuonRef
edm::Ref< MuonBxCollection > MuonRef
Definition: Muon.h:13
L2MuonSeedGeneratorFromL1T::theL1MaxEta
const double theL1MaxEta
Definition: L2MuonSeedGeneratorFromL1T.h:73
sortByL1QandPt
bool sortByL1QandPt(L2MuonTrajectorySeed &A, L2MuonTrajectorySeed &B)
Definition: L2MuonSeedGeneratorFromL1T.cc:53
CSCDetId
Definition: CSCDetId.h:26
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
L2MuonSeedGeneratorFromL1T::offlineSeedToken_
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
Definition: L2MuonSeedGeneratorFromL1T.h:70
L2MuonSeedGeneratorFromL1T::theL1MinPt
const double theL1MinPt
Definition: L2MuonSeedGeneratorFromL1T.h:72
DDAxes::phi
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
L2MuonTrajectorySeed
Definition: L2MuonTrajectorySeed.h:17
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
qcdUeDQM_cfi.quality
quality
Definition: qcdUeDQM_cfi.py:31
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
L2MuonSeedGeneratorFromL1T::matchType
const unsigned matchType
Definition: L2MuonSeedGeneratorFromL1T.h:84
L2MuonSeedGeneratorFromL1T::etaBins
std::vector< double > etaBins
Definition: L2MuonSeedGeneratorFromL1T.h:80
Exception
Definition: hltDiff.cc:246
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
TrajectorySeed::recHits
range recHits() const
Definition: TrajectorySeed.h:52
GeometricSearchDet::surface
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
TrajectorySeed
Definition: TrajectorySeed.h:17
BoundCylinder
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
L2MuonSeedGeneratorFromL1T::useOfflineSeed
const bool useOfflineSeed
Definition: L2MuonSeedGeneratorFromL1T.h:77
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
TrajectorySeed::startingState
PTrajectoryStateOnDet const & startingState() const
Definition: TrajectorySeed.h:55
BXVector::size
unsigned size(int bx) const
L2MuonSeedGeneratorFromL1T::theSource
edm::InputTag theSource
Definition: L2MuonSeedGeneratorFromL1T.h:64
PFRecoTauChargedHadronBuilderPlugins_cfi.dRcone
dRcone
Definition: PFRecoTauChargedHadronBuilderPlugins_cfi.py:46
DTChamberId
Definition: DTChamberId.h:14
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
BXVector::getLastBX
int getLastBX() const
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
edm::InputTag
Definition: InputTag.h:15
alongMomentum
Definition: PropagationDirection.h:4
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
L2MuonSeedGeneratorFromL1T::theMinPtEndcap
const double theMinPtEndcap
Definition: L2MuonSeedGeneratorFromL1T.h:76
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
edm::OwnVector< TrackingRecHit >
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:43