38 #include "CLHEP/Vector/ThreeVector.h"
61 using namespace l1extra;
66 theL1GMTReadoutCollection(iConfig.getParameter<
InputTag>(
"GMTReadoutCollection")),
67 thePropagatorName(iConfig.getParameter<string>(
"Propagator")),
68 theL1MinPt(iConfig.getParameter<double>(
"L1MinPt")),
69 theL1MaxEta(iConfig.getParameter<double>(
"L1MaxEta")),
70 theL1MinQuality(iConfig.getParameter<unsigned int>(
"L1MinQuality")),
71 useOfflineSeed(iConfig.getUntrackedParameter<bool>(
"UseOfflineSeed",
false)){
85 produces<L2MuonTrajectorySeedCollection>();
96 const std::string
metname =
"Muon|RecoMuon|L2MuonSeedGenerator";
108 LogTrace(metname) <<
"Number of muons " << muColl->size() << endl;
111 vector<int> offlineSeedMap;
114 LogTrace(metname) <<
"Number of offline seeds " << offlineSeedHandle->size() << endl;
115 offlineSeedMap = vector<int>(offlineSeedHandle->size(), 0);
118 L1MuonParticleCollection::const_iterator it;
121 for(it = muColl->begin(); it != muColl->end(); ++it,++l1ParticleIndex) {
124 unsigned int quality = 0;
125 bool valid_charge =
false;;
127 if ( muonCand.
empty() ) {
128 LogWarning(metname) <<
"L2MuonSeedGenerator: WARNING, no L1MuGMTCand! " << endl;
129 LogWarning(metname) <<
"L2MuonSeedGenerator: this should make sense only within MC tests" << endl;
139 float pt = (*it).pt();
140 float eta = (*it).eta();
142 float phi = (*it).phi();
143 int charge = (*it).charge();
145 if (!valid_charge) charge = 0;
146 bool barrel = !(*it).isForward();
150 if ( !(muonCand.
empty()) ) {
152 vector<L1MuRegionalCand> rmc;
153 if ( !muonCand.
isRPC() ) {
163 eta = rmc[idx].etaValue();
166 if (!valid_charge) charge = rmc[idx].chargeValue();
172 LogTrace(metname) <<
"New L2 Muon Seed";
173 LogTrace(metname) <<
"Pt = " << pt <<
" GeV/c";
175 LogTrace(metname) <<
"theta = " << theta <<
" rad";
176 LogTrace(metname) <<
"phi = " << phi <<
" rad";
181 LogTrace(metname) <<
"quality = "<< quality;
189 CLHEP::Hep3Vector vec(0.,1.,0.);
195 LogTrace(metname) <<
"The seed is in the barrel";
199 detLayer =
theService->detLayerGeometry()->idToLayer(
id);
209 if ( pt < 3.5 ) pt = 3.5;
212 LogTrace(metname) <<
"The seed is in the endcap";
221 detLayer =
theService->detLayerGeometry()->idToLayer(
id);
226 if( pt < 1.0) pt = 1.0;
238 mat[0][0] = (0.25/pt)*(0.25/pt);
239 if ( !barrel ) mat[0][0] = (0.4/pt)*(0.4/pt);
242 if (!valid_charge) mat[0][0] = (1./pt)*(1./pt);
244 mat[1][1] = 0.05*0.05;
253 LogTrace(metname) <<
"Free trajectory State from the parameters";
259 LogTrace(metname) <<
"State after the propagation on the layer";
265 std::vector< pair<const GeomDet*,TrajectoryStateOnSurface> >
269 if (detsWithStates.size()){
272 const GeomDet *newTSOSDet = detsWithStates.front().first;
274 LogTrace(metname) <<
"Most compatible det";
277 LogDebug(metname) <<
"L1 info: Det and State:";
302 tsci = assoOffseed->
recHits().first,
303 tscie = assoOffseed->
recHits().second;
304 for(; tsci!=tscie; ++tsci) {
334 std::vector<int> & offseedMap,
337 const std::string metlabel =
"Muon|RecoMuon|L2MuonSeedGenerator";
342 double bestDr = 99999.;
343 unsigned int nOffseed(0);
346 for(offseed=offseeds->
begin(); offseed!=endOffseed; ++offseed, ++nOffseed) {
347 if(offseedMap[nOffseed]!=0)
continue;
348 GlobalPoint glbPos =
theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().position());
349 GlobalVector glbMom =
theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().momentum());
353 if(preDr > 1.0)
continue;
357 LogDebug(metlabel) <<
"Offline seed info: Det and State" << std::endl;
358 LogDebug(metlabel) << debugtmp.
dumpMuonId(offseed->startingState().detId()) << std::endl;
361 LogDebug(metlabel) <<
"pos: (r=" << offseedFTS.position().mag() <<
", phi="
362 << offseedFTS.position().phi() <<
", eta=" << offseedFTS.position().eta() <<
")" << std::endl;
363 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedFTS.charge()*offseedFTS.momentum().perp() <<
", phi="
364 << offseedFTS.momentum().phi() <<
", eta=" << offseedFTS.momentum().eta() <<
")" << std::endl << std::endl;
367 if(offseedTsos.isValid()) {
368 LogDebug(metlabel) <<
"Offline seed info after propagation to L1 layer:" << std::endl;
371 LogDebug(metlabel) <<
"pos: (r=" << offseedTsos.globalPosition().mag() <<
", phi="
372 << offseedTsos.globalPosition().phi() <<
", eta=" << offseedTsos.globalPosition().eta() <<
")" << std::endl;
373 LogDebug(metlabel) <<
"mom: (q*pt=" << offseedTsos.charge()*offseedTsos.globalMomentum().perp() <<
", phi="
374 << offseedTsos.globalMomentum().phi() <<
", eta=" << offseedTsos.globalMomentum().eta() <<
")" << std::endl << std::endl;
377 offseedTsos.globalPosition().eta(), offseedTsos.globalPosition().phi() );
378 LogDebug(metlabel) <<
" -- DR = " << newDr << std::endl;
379 if( newDr<0.3 && newDr<bestDr ) {
380 LogDebug(metlabel) <<
" --> OK! " << newDr << std::endl << std::endl;
381 selOffseed = &*offseed;
383 offseedMap[nOffseed] = 1;
384 if(lastOffseed>-1) offseedMap[lastOffseed] = 0;
385 lastOffseed = nOffseed;
388 LogDebug(metlabel) <<
" --> Rejected. " << newDr << std::endl << std::endl;
392 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
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
TrackCharge charge() const
edm::InputTag theL1GMTReadoutCollection
std::string dumpLayer(const DetLayer *layer) const
const std::string metname
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
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
~L2MuonSeedGenerator()
Destructor.
std::string dumpMuonId(const DetId &id) const
std::string dumpFTS(const FreeTrajectoryState &fts) const
std::vector< L1MuRegionalCand > getFwdRPCCands() const
get forward RPC candidates vector
uint32_t rawId() const
get the raw id
const TrajectorySeed * associateOfflineSeedToL1(edm::Handle< edm::View< TrajectorySeed > > &, std::vector< int > &, TrajectoryStateOnSurface &)
const unsigned theL1MinQuality
std::vector< L1MuRegionalCand > getCSCCands() const
get CSC candidates vector
virtual void produce(edm::Event &, const edm::EventSetup &)
bool empty() const
is it an empty muon candidate?
Scalar radius() const
Radius of the cylinder.
bool isRPC() const
get RPC bit (true=RPC, false = DT/CSC or matched)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
recHitContainer::const_iterator const_iterator
std::vector< L2MuonTrajectorySeed > L2MuonTrajectorySeedCollection
bool charge_valid() const
is the charge valid ?
Cos< T >::type cos(const T &t)
unsigned getRPCIndex() const
get index of contributing RPC muon
DetId geographicalId() const
The label of this GeomDet.
tuple Chi2MeasurementEstimator
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double deltaR(double eta1, double eta2, double phi1, double phi2)
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
T const * product() const
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
GlobalVector globalMomentum() const
std::string thePropagatorName
const Surface & surface() const
const_iterator begin() const
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
L2MuonSeedGenerator(const edm::ParameterSet &)
Constructor.
bool isFwd() const
get forward bit (true=forward, false=barrel)
edm::InputTag theOfflineSeedLabel