37 #include "CLHEP/Vector/ThreeVector.h"
88 static constexpr
float etaBoundary_{1.1};
89 static constexpr
float distMB2_{550.};
90 static constexpr
float distME2_{850.};
91 static constexpr
float phiCorr0_{1.464};
92 static constexpr
float phiCorr1_{1.7};
93 static constexpr
float phiCorr2_{144.};
107 : source_(iConfig.getParameter<
InputTag>(
"InputObjects")),
109 propagatorName_(iConfig.getParameter<
string>(
"Propagator")),
110 l1MinPt_(iConfig.getParameter<double>(
"L1MinPt")),
111 l1MaxEta_(iConfig.getParameter<double>(
"L1MaxEta")),
112 minPtBarrel_(iConfig.getParameter<double>(
"SetMinPtBarrelTo")),
113 minPtEndcap_(iConfig.getParameter<double>(
"SetMinPtEndcapTo")),
114 minPL1Tk_(iConfig.getParameter<double>(
"MinPL1Tk")),
115 minPtL1TkBarrel_(iConfig.getParameter<double>(
"MinPtL1TkBarrel")),
116 useOfflineSeed_(iConfig.getUntrackedParameter<bool>(
"UseOfflineSeed",
false)),
117 useUnassociatedL1_(iConfig.getParameter<bool>(
"UseUnassociatedL1")),
118 matchingDR_(iConfig.getParameter<std::
vector<double>>(
"MatchDR")),
119 etaBins_(iConfig.getParameter<std::
vector<double>>(
"EtaMatchingBins")) {
127 <<
"does not match number of eta bins." << endl;
135 service_ = std::make_unique<MuonServiceProxy>(serviceParameters, consumesCollector());
138 estimator_ = std::make_unique<Chi2MeasurementEstimator>(10000.);
140 produces<L2MuonTrajectorySeedCollection>();
146 desc.
add<
string>(
"Propagator",
"");
147 desc.
add<
double>(
"L1MinPt", -1.);
148 desc.
add<
double>(
"L1MaxEta", 5.0);
149 desc.
add<
double>(
"SetMinPtBarrelTo", 3.5);
150 desc.
add<
double>(
"SetMinPtEndcapTo", 1.0);
151 desc.
add<
double>(
"MinPL1Tk", 3.5);
152 desc.
add<
double>(
"MinPtL1TkBarrel", 3.5);
154 desc.
add<
bool>(
"UseUnassociatedL1",
true);
155 desc.
add<std::vector<double>>(
"MatchDR", {0.3});
156 desc.
add<std::vector<double>>(
"EtaMatchingBins", {0., 2.5});
160 psd0.
addUntracked<std::vector<std::string>>(
"Propagators", {
"SteppingHelixPropagatorAny"});
161 psd0.add<
bool>(
"RPCLayers",
true);
162 psd0.addUntracked<
bool>(
"UseMuonNavigation",
true);
164 descriptions.
add(
"L2MuonSeedGeneratorFromL1TkMu", desc);
171 auto output = std::make_unique<L2MuonTrajectorySeedCollection>();
175 LogDebug(metname) <<
"Number of muons " << muColl->size() << endl;
178 vector<int> offlineSeedMap;
181 offlineSeedMap = vector<int>(offlineSeedHandle->size(), 0);
184 for (
auto const &tkmu : *muColl) {
186 auto const &it = tkmu.trkPtr();
189 auto p3 = it->momentum();
191 float tk_p = p3.mag();
195 float tk_pt = p3.perp();
196 float tk_eta = p3.eta();
203 float tk_phi = p3.phi();
204 float tk_q = it->rInv() > 0 ? 1. : -1.;
205 float tk_z = it->POCA().z();
207 float dzCorrPhi = 1.;
209 float etaProp = tk_aeta;
213 deta = tk_z /
distMB2_ / cosh(tk_aeta);
218 dzCorrPhi = 1. +
delta;
222 deta = zOzs / (1. - zOzs);
224 deta = zOzs / (1. + zOzs);
225 deta = deta * tanh(tk_eta);
231 float eta = tk_eta + deta;
234 int charge = it->rInv() > 0 ? 1 : -1;
239 LogDebug(metname) <<
"New L2 Muon Seed";
240 LogDebug(metname) <<
"Pt = " << pt <<
" GeV/c";
242 LogDebug(metname) <<
"theta = " << theta <<
" rad";
243 LogDebug(metname) <<
"phi = " << phi <<
" rad";
253 CLHEP::Hep3Vector vec(0., 1., 0.);
260 LogDebug(metname) <<
"The seed is in the barrel";
264 detLayer =
service_->detLayerGeometry()->idToLayer(theid);
277 LogDebug(metname) <<
"The seed is in the endcap";
282 detLayer =
service_->detLayerGeometry()->idToLayer(theid);
300 mat[0][0] = (0.25 /
pt) * (0.25 / pt);
302 mat[0][0] = (0.4 /
pt) * (0.4 / pt);
304 mat[1][1] = 0.05 * 0.05;
305 mat[2][2] = 0.2 * 0.2;
306 mat[3][3] = 20. * 20.;
307 mat[4][4] = 20. * 20.;
313 LogDebug(metname) <<
"Free trajectory State from the parameters";
319 LogDebug(metname) <<
"State after the propagation on the layer";
334 std::vector<pair<const GeomDet *, TrajectoryStateOnSurface>> detsWithStates =
337 if (detsWithStates.empty() &&
barrel) {
341 const DetLayer *ME2DetLayer =
service_->detLayerGeometry()->idToLayer(fallback_id);
347 if (!detsWithStates.empty()) {
349 const GeomDet *newTSOSDet = detsWithStates.front().first;
351 LogDebug(metname) <<
"Most compatible det";
365 if (assoOffseed !=
nullptr) {
367 for (
auto const &recHit : assoOffseed->
recHits()) {
398 std::vector<int> &offseedMap,
404 const std::string metlabel =
"Muon|RecoMuon|L2MuonSeedGeneratorFromL1TkMu";
409 double bestDr2 = 99999.;
410 unsigned int nOffseed(0);
413 for (offseed = offseeds->
begin(); offseed != endOffseed; ++offseed, ++nOffseed) {
414 if (offseedMap[nOffseed] != 0)
417 ->idToDet(offseed->startingState().detId())
419 .toGlobal(offseed->startingState().parameters().position());
421 ->idToDet(offseed->startingState().detId())
423 .toGlobal(offseed->startingState().parameters().momentum());
431 glbPos, glbMom, offseed->startingState().parameters().charge(), &*
service_->magneticField());
434 LogDebug(metlabel) <<
"Offline seed info: Det and State" << std::endl;
435 LogDebug(metlabel) << debugtmp.
dumpMuonId(offseed->startingState().detId()) << std::endl;
436 LogDebug(metlabel) <<
"pos: (r=" << offseedFTS.position().mag() <<
", phi=" << offseedFTS.position().phi()
437 <<
", eta=" << offseedFTS.position().eta() <<
")" << std::endl;
438 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedFTS.charge() * offseedFTS.momentum().perp()
439 <<
", phi=" << offseedFTS.momentum().phi() <<
", eta=" << offseedFTS.momentum().eta() <<
")"
443 if (offseedTsos.isValid()) {
444 LogDebug(metlabel) <<
"Offline seed info after propagation to L1 layer:" << std::endl;
445 LogDebug(metlabel) <<
"pos: (r=" << offseedTsos.globalPosition().mag()
446 <<
", phi=" << offseedTsos.globalPosition().phi()
447 <<
", eta=" << offseedTsos.globalPosition().eta() <<
")" << std::endl;
448 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedTsos.charge() * offseedTsos.globalMomentum().perp()
449 <<
", phi=" << offseedTsos.globalMomentum().phi()
450 <<
", eta=" << offseedTsos.globalMomentum().eta() <<
")" << std::endl
454 offseedTsos.globalPosition().eta(),
455 offseedTsos.globalPosition().
phi());
456 LogDebug(metlabel) <<
" -- DR = " << newDr2 << std::endl;
457 if (newDr2 < bestDr2 && newDr2 < dRcone * dRcone) {
458 LogDebug(metlabel) <<
" --> OK! " << newDr2 << std::endl << std::endl;
459 selOffseed = &*offseed;
461 offseedMap[nOffseed] = 1;
462 if (lastOffseed > -1)
463 offseedMap[lastOffseed] = 0;
464 lastOffseed = nOffseed;
466 LogDebug(metlabel) <<
" --> Rejected. " << newDr2 << std::endl << std::endl;
469 LogDebug(metlabel) <<
"Invalid offline seed TSOS after propagation!" << std::endl << std::endl;
T getUntrackedParameter(std::string const &, T const &) const
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
TrackCharge charge() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
constexpr T reduceRange(T x)
std::string dumpLayer(const DetLayer *layer) const
static constexpr float phiCorr1_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string metname
#define DEFINE_FWK_MODULE(type)
static constexpr float distMB2_
static constexpr float phiCorr0_
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
constexpr uint32_t rawId() const
get the raw id
Geom::Theta< T > theta() const
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
GlobalPoint globalPosition() const
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
Exp< T >::type exp(const T &t)
std::string propagatorName_
edm::InputTag offlineSeedLabel_
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
const TrajectorySeed * associateOfflineSeedToL1(edm::Handle< edm::View< TrajectorySeed >> &, std::vector< int > &, TrajectoryStateOnSurface &, double)
std::string dumpMuonId(const DetId &id) const
std::string dumpFTS(const FreeTrajectoryState &fts) const
const bool useUnassociatedL1_
std::string dumpTSOS(const TrajectoryStateOnSurface &tsos) const
const SurfaceType & surface() const
const_iterator begin() const
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< double > etaBins_
std::unique_ptr< MuonServiceProxy > service_
the event setup proxy, it takes care the services update
Cos< T >::type cos(const T &t)
std::unique_ptr< MeasurementEstimator > estimator_
Abs< T >::type abs(const T &t)
DetId geographicalId() const
The label of this GeomDet.
const double minPtEndcap_
std::vector< TkMuon > TkMuonCollection
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const bool useOfflineSeed_
std::vector< double > matchingDR_
static constexpr float distME2_
RecHitRange recHits() const
static constexpr float etaBoundary_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
PTrajectoryStateOnDet const & startingState() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual const Surface::PositionType & position() const
Returns position of the surface.
T getParameter(std::string const &) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const double minPtBarrel_
L2MuonSeedGeneratorFromL1TkMu(const edm::ParameterSet &)
Constructor.
const double minPtL1TkBarrel_
static constexpr float phiCorr2_
GlobalVector globalMomentum() const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
edm::EDGetTokenT< l1t::TkMuonCollection > muCollToken_