46 theL1GMTReadoutCollection(iConfig.getParameter<
InputTag>(
"GMTReadoutCollection")),
48 theL1MinPt(iConfig.getParameter<double>(
"L1MinPt")),
49 theL1MaxEta(iConfig.getParameter<double>(
"L1MaxEta")),
50 theL1MinQuality(iConfig.getParameter<unsigned
int>(
"L1MinQuality")),
51 useOfflineSeed(iConfig.getUntrackedParameter<
bool>(
"UseOfflineSeed",
false)),
52 useUnassociatedL1(iConfig.existsAs<
bool>(
"UseUnassociatedL1") ?
53 iConfig.getParameter<
bool>(
"UseUnassociatedL1") :
true){
73 produces<L2MuonTrajectorySeedCollection>();
87 auto output = std::make_unique<L2MuonTrajectorySeedCollection>();
96 LogTrace(metname) <<
"Number of muons " << muColl->size() << endl;
99 vector<int> offlineSeedMap;
102 LogTrace(metname) <<
"Number of offline seeds " << offlineSeedHandle->size() << endl;
103 offlineSeedMap = vector<int>(offlineSeedHandle->size(), 0);
106 L1MuonParticleCollection::const_iterator it;
109 for(it = muColl->begin(); it != muColl->end(); ++it,++l1ParticleIndex) {
113 bool valid_charge =
false;;
115 if ( muonCand.
empty() ) {
116 LogWarning(metname) <<
"L2MuonSeedGenerator: WARNING, no L1MuGMTCand! " << endl;
117 LogWarning(metname) <<
"L2MuonSeedGenerator: this should make sense only within MC tests" << endl;
127 float pt = (*it).pt();
128 float eta = (*it).eta();
130 float phi = (*it).phi();
131 int charge = (*it).charge();
133 if (!valid_charge) charge = 0;
134 bool barrel = !(*it).isForward();
138 if ( !(muonCand.
empty()) ) {
140 vector<L1MuRegionalCand> rmc;
141 if ( !muonCand.
isRPC() ) {
151 eta = rmc[
idx].etaValue();
154 if (!valid_charge) charge = rmc[
idx].chargeValue();
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.);
183 LogTrace(metname) <<
"The seed is in the barrel";
187 detLayer =
theService->detLayerGeometry()->idToLayer(
id);
193 radius = fabs(bc->radius()/
sin(theta));
197 if ( pt < 3.5 ) pt = 3.5;
200 LogTrace(metname) <<
"The seed is in the endcap";
209 detLayer =
theService->detLayerGeometry()->idToLayer(
id);
214 if( pt < 1.0) pt = 1.0;
226 mat[0][0] = (0.25/
pt)*(0.25/pt);
227 if ( !barrel ) mat[0][0] = (0.4/
pt)*(0.4/pt);
230 if (!valid_charge) mat[0][0] = (1./
pt)*(1./pt);
232 mat[1][1] = 0.05*0.05;
241 LogTrace(metname) <<
"Free trajectory State from the parameters";
247 LogTrace(metname) <<
"State after the propagation on the layer";
253 std::vector< pair<const GeomDet*,TrajectoryStateOnSurface> >
257 if (!detsWithStates.empty()){
260 const GeomDet *newTSOSDet = detsWithStates.front().first;
262 LogTrace(metname) <<
"Most compatible det";
265 LogDebug(metname) <<
"L1 info: Det and State:";
287 if(assoOffseed!=
nullptr) {
290 tsci = assoOffseed->
recHits().first,
291 tscie = assoOffseed->
recHits().second;
292 for(; tsci!=tscie; ++tsci) {
324 std::vector<int> & offseedMap,
327 const std::string metlabel =
"Muon|RecoMuon|L2MuonSeedGenerator";
332 double bestDr = 99999.;
333 unsigned int nOffseed(0);
336 for(offseed=offseeds->
begin(); offseed!=endOffseed; ++offseed, ++nOffseed) {
337 if(offseedMap[nOffseed]!=0)
continue;
338 GlobalPoint glbPos =
theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().position());
339 GlobalVector glbMom =
theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().momentum());
343 if(preDr > 1.0)
continue;
347 LogDebug(metlabel) <<
"Offline seed info: Det and State" << std::endl;
348 LogDebug(metlabel) << debugtmp.
dumpMuonId(offseed->startingState().detId()) << std::endl;
351 LogDebug(metlabel) <<
"pos: (r=" << offseedFTS.position().mag() <<
", phi=" 352 << offseedFTS.position().phi() <<
", eta=" << offseedFTS.position().eta() <<
")" << std::endl;
353 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedFTS.charge()*offseedFTS.momentum().perp() <<
", phi=" 354 << offseedFTS.momentum().phi() <<
", eta=" << offseedFTS.momentum().eta() <<
")" << std::endl << std::endl;
357 if(offseedTsos.isValid()) {
358 LogDebug(metlabel) <<
"Offline seed info after propagation to L1 layer:" << std::endl;
361 LogDebug(metlabel) <<
"pos: (r=" << offseedTsos.globalPosition().mag() <<
", phi=" 362 << offseedTsos.globalPosition().phi() <<
", eta=" << offseedTsos.globalPosition().eta() <<
")" << std::endl;
363 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedTsos.charge()*offseedTsos.globalMomentum().perp() <<
", phi=" 364 << offseedTsos.globalMomentum().phi() <<
", eta=" << offseedTsos.globalMomentum().eta() <<
")" << std::endl << std::endl;
367 offseedTsos.globalPosition().eta(), offseedTsos.globalPosition().phi() );
368 LogDebug(metlabel) <<
" -- DR = " << newDr << std::endl;
369 if( newDr<0.3 && newDr<bestDr ) {
370 LogDebug(metlabel) <<
" --> OK! " << newDr << std::endl << std::endl;
371 selOffseed = &*offseed;
373 offseedMap[nOffseed] = 1;
374 if(lastOffseed>-1) offseedMap[lastOffseed] = 0;
375 lastOffseed = nOffseed;
378 LogDebug(metlabel) <<
" --> Rejected. " << newDr << std::endl << std::endl;
382 LogDebug(metlabel) <<
"Invalid offline seed TSOS after propagation!" << std::endl << std::endl;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< l1extra::L1MuonParticleCollection > muCollToken_
TrackCharge charge() const
edm::InputTag theL1GMTReadoutCollection
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
std::string dumpLayer(const DetLayer *layer) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string metname
void produce(edm::Event &, const edm::EventSetup &) override
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
GlobalPoint globalPosition() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
std::vector< L1MuRegionalCand > getBrlRPCCands() const
get barrel RPC candidates vector
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::vector< L1MuRegionalCand > getFwdRPCCands() const
get forward RPC candidates vector
const TrajectorySeed * associateOfflineSeedToL1(edm::Handle< edm::View< TrajectorySeed > > &, std::vector< int > &, TrajectoryStateOnSurface &)
const unsigned theL1MinQuality
std::vector< L1MuRegionalCand > getCSCCands() const
get CSC candidates vector
bool empty() const
is it an empty muon candidate?
const SurfaceType & surface() const
const_iterator begin() const
bool isRPC() const
get RPC bit (true=RPC, false = DT/CSC or matched)
recHitContainer::const_iterator const_iterator
bool charge_valid() const
is the charge valid ?
Cos< T >::type cos(const T &t)
unsigned getRPCIndex() const
get index of contributing RPC muon
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
DetId geographicalId() const
The label of this GeomDet.
unsigned int quality() const
get quality
PTrajectoryStateOnDet const & startingState() const
unsigned getDTCSCIndex() const
get index of contributing DT/CSC muon
const bool useOfflineSeed
MeasurementEstimator * theEstimator
virtual const Surface::PositionType & position() const
Returns position of the surface.
std::vector< L1MuRegionalCand > getDTBXCands() const
get DT candidates vector
~L2MuonSeedGenerator() override
Destructor.
const bool useUnassociatedL1
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
GlobalVector globalMomentum() const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
std::string thePropagatorName
edm::EDGetTokenT< L1MuGMTReadoutCollection > gmtToken_
L2MuonSeedGenerator(const edm::ParameterSet &)
Constructor.
bool isFwd() const
get forward bit (true=forward, false=barrel)
edm::InputTag theOfflineSeedLabel