47 theL1GMTReadoutCollection(iConfig.getParameter<
InputTag>(
"GMTReadoutCollection")),
49 theL1MinPt(iConfig.getParameter<double>(
"L1MinPt")),
50 theL1MaxEta(iConfig.getParameter<double>(
"L1MaxEta")),
51 theL1MinQuality(iConfig.getParameter<unsigned
int>(
"L1MinQuality")),
52 useOfflineSeed(iConfig.getUntrackedParameter<
bool>(
"UseOfflineSeed",
false)),
53 useUnassociatedL1(iConfig.existsAs<
bool>(
"UseUnassociatedL1") ?
54 iConfig.getParameter<
bool>(
"UseUnassociatedL1") :
true),
55 matchingDR(iConfig.getParameter<
std::vector<double> >(
"MatchDR")),
56 etaBins(iConfig.getParameter<
std::vector<double> >(
"EtaMatchingBins")),
57 centralBxOnly_( iConfig.getParameter<
bool>(
"CentralBxOnly") )
69 <<
"does not match number of eta bins." << endl;
85 produces<L2MuonTrajectorySeedCollection>();
99 desc.
add<
string>(
"Propagator",
"");
100 desc.
add<
double>(
"L1MinPt",-1.);
101 desc.
add<
double>(
"L1MaxEta",5.0);
102 desc.
add<
unsigned int>(
"L1MinQuality",0);
104 desc.
add<
bool>(
"UseUnassociatedL1",
true);
105 desc.
add<std::vector<double>>(
"MatchDR", {0.3});
106 desc.
add<std::vector<double>>(
"EtaMatchingBins", {0., 2.5});
107 desc.
add<
bool>(
"CentralBxOnly",
true);
111 psd0.
addUntracked<std::vector<std::string>>(
"Propagators", {
112 "SteppingHelixPropagatorAny" 114 psd0.add<
bool>(
"RPCLayers",
true);
115 psd0.addUntracked<
bool>(
"UseMuonNavigation",
true);
117 descriptions.
add(
"L2MuonSeedGeneratorFromL1T",desc);
125 auto output = std::make_unique<L2MuonTrajectorySeedCollection>();
129 LogTrace(metname) <<
"Number of muons " << muColl->size() << endl;
132 vector<int> offlineSeedMap;
135 LogTrace(metname) <<
"Number of offline seeds " << offlineSeedHandle->size() << endl;
136 offlineSeedMap = vector<int>(offlineSeedHandle->size(), 0);
139 for (
int ibx = muColl->getFirstBX(); ibx <= muColl->getLastBX(); ++ibx) {
141 for (
auto it = muColl->begin(ibx); it != muColl->end(ibx); it++){
143 unsigned int quality = it->hwQual();
144 int valid_charge = it->hwChargeValid();
147 float eta = it->eta();
149 float phi = it->phi();
150 int charge = it->charge();
152 if (!valid_charge) charge = 0;
154 int link = 36 + (
int)(it -> tfMuonIndex() / 3.);
156 if ( (link >= 36 && link <= 41) || (link >= 66 && link <= 71)) barrel =
false;
160 LogTrace(metname) <<
"New L2 Muon Seed" ;
161 LogTrace(metname) <<
"Pt = " << pt <<
" GeV/c";
163 LogTrace(metname) <<
"theta = " << theta <<
" rad";
164 LogTrace(metname) <<
"phi = " << phi <<
" rad";
177 CLHEP::Hep3Vector vec(0.,1.,0.);
184 LogTrace(metname) <<
"The seed is in the barrel";
188 detLayer =
theService->detLayerGeometry()->idToLayer(
id);
194 radius = fabs(bc->radius()/
sin(theta));
199 if ( pt < 3.5 ) pt = 3.5;
202 LogTrace(metname) <<
"The seed is in the endcap";
211 detLayer =
theService->detLayerGeometry()->idToLayer(
id);
217 if( pt < 1.0) pt = 1.0;
234 mat[0][0] = (0.25/
pt)*(0.25/pt);
235 if ( !barrel ) mat[0][0] = (0.4/
pt)*(0.4/pt);
238 if (!valid_charge) mat[0][0] = (1./
pt)*(1./pt);
240 mat[1][1] = 0.05*0.05;
249 LogTrace(metname) <<
"Free trajectory State from the parameters";
255 LogTrace(metname) <<
"State after the propagation on the layer";
260 if ( fabs(eta) <
etaBins.back() ){
261 std::vector<double>::iterator lowEdge = std::upper_bound (
etaBins.begin(),
etaBins.end(), fabs(eta));
274 if(assoOffseed!=
nullptr) {
277 tsci = assoOffseed->
recHits().first,
278 tscie = assoOffseed->
recHits().second;
279 for(; tsci!=tscie; ++tsci) {
296 std::vector< pair<const GeomDet*,TrajectoryStateOnSurface> >
301 if (detsWithStates.empty() &&
barrel ) {
309 if (!detsWithStates.empty()){
312 const GeomDet *newTSOSDet = detsWithStates.front().first;
314 LogTrace(metname) <<
"Most compatible det";
317 LogDebug(metname) <<
"L1 info: Det and State:";
335 if(assoOffseed!=
nullptr) {
338 tsci = assoOffseed->
recHits().first,
339 tscie = assoOffseed->
recHits().second;
340 for(; tsci!=tscie; ++tsci) {
373 std::vector<int> & offseedMap,
377 const std::string metlabel =
"Muon|RecoMuon|L2MuonSeedGeneratorFromL1T";
382 double bestDr = 99999.;
383 unsigned int nOffseed(0);
386 for(offseed=offseeds->
begin(); offseed!=endOffseed; ++offseed, ++nOffseed) {
387 if(offseedMap[nOffseed]!=0)
continue;
388 GlobalPoint glbPos =
theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().position());
389 GlobalVector glbMom =
theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().momentum());
393 if(preDr > 1.0)
continue;
397 LogDebug(metlabel) <<
"Offline seed info: Det and State" << std::endl;
398 LogDebug(metlabel) << debugtmp.
dumpMuonId(offseed->startingState().detId()) << std::endl;
401 LogDebug(metlabel) <<
"pos: (r=" << offseedFTS.position().mag() <<
", phi=" 402 << offseedFTS.position().phi() <<
", eta=" << offseedFTS.position().eta() <<
")" << std::endl;
403 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedFTS.charge()*offseedFTS.momentum().perp() <<
", phi=" 404 << offseedFTS.momentum().phi() <<
", eta=" << offseedFTS.momentum().eta() <<
")" << std::endl << std::endl;
407 if(offseedTsos.isValid()) {
408 LogDebug(metlabel) <<
"Offline seed info after propagation to L1 layer:" << std::endl;
411 LogDebug(metlabel) <<
"pos: (r=" << offseedTsos.globalPosition().mag() <<
", phi=" 412 << offseedTsos.globalPosition().phi() <<
", eta=" << offseedTsos.globalPosition().eta() <<
")" << std::endl;
413 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedTsos.charge()*offseedTsos.globalMomentum().perp() <<
", phi=" 414 << offseedTsos.globalMomentum().phi() <<
", eta=" << offseedTsos.globalMomentum().eta() <<
")" << std::endl << std::endl;
417 offseedTsos.globalPosition().eta(), offseedTsos.globalPosition().phi() );
418 LogDebug(metlabel) <<
" -- DR = " << newDr << std::endl;
419 if( newDr < dRcone && newDr<bestDr ) {
420 LogDebug(metlabel) <<
" --> OK! " << newDr << std::endl << std::endl;
421 selOffseed = &*offseed;
423 offseedMap[nOffseed] = 1;
424 if(lastOffseed>-1) offseedMap[lastOffseed] = 0;
425 lastOffseed = nOffseed;
428 LogDebug(metlabel) <<
" --> Rejected. " << newDr << std::endl << std::endl;
432 LogDebug(metlabel) <<
"Invalid offline seed TSOS after propagation!" << std::endl << std::endl;
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TrackCharge charge() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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
const std::string metname
const bool useOfflineSeed
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
Geom::Theta< T > theta() const
GlobalPoint globalPosition() const
L2MuonSeedGeneratorFromL1T(const edm::ParameterSet &)
Constructor.
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
edm::Ref< MuonBxCollection > MuonRef
std::string dumpMuonId(const DetId &id) const
std::string dumpFTS(const FreeTrajectoryState &fts) const
uint32_t rawId() const
get the raw id
~L2MuonSeedGeneratorFromL1T() override
Destructor.
std::string dumpTSOS(const TrajectoryStateOnSurface &tsos) const
const SurfaceType & surface() const
const_iterator begin() const
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
const unsigned theL1MinQuality
recHitContainer::const_iterator const_iterator
Cos< T >::type cos(const T &t)
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
DetId geographicalId() const
The label of this GeomDet.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const bool useUnassociatedL1
double deltaR(double eta1, double eta2, double phi1, double phi2)
PTrajectoryStateOnDet const & startingState() const
virtual const Surface::PositionType & position() const
Returns position of the surface.
edm::EDGetTokenT< l1t::MuonBxCollection > muCollToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
GlobalVector globalMomentum() const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
MeasurementEstimator * theEstimator
void produce(edm::Event &, const edm::EventSetup &) override
std::string thePropagatorName
edm::InputTag theOfflineSeedLabel
std::vector< double > etaBins
std::vector< double > matchingDR