40 produces<TrajectorySeedCollection>();
43 theEnableDTFlag =
pset.getParameter<
bool>(
"EnableDTMeasurement");
45 theEnableCSCFlag =
pset.getParameter<
bool>(
"EnableCSCMeasurement");
47 theDTRecSegmentLabel =
pset.getParameter<
InputTag>(
"DTRecSegmentLabel");
49 theCSCRecSegmentLabel =
pset.getParameter<
InputTag>(
"CSCRecSegmentLabel");
52 theMaxSeeds =
pset.getParameter<
int>(
"MaxSeeds");
54 theMaxDTChi2 =
pset.getParameter<
double>(
"MaxDTChi2");
55 theMaxCSCChi2 =
pset.getParameter<
double>(
"MaxCSCChi2");
57 theForcePointDownFlag =
pset.existsAs<
bool>(
"ForcePointDown") ?
pset.getParameter<
bool>(
"ForcePointDown") :
true;
60 theParameters[
"topmb41"] = 0.87;
61 theParameters[
"bottommb41"] = 1.2;
62 theParameters[
"topmb42"] = 0.67;
63 theParameters[
"bottommb42"] = 0.98;
64 theParameters[
"topmb43"] = 0.34;
65 theParameters[
"bottommb43"] = 0.58;
66 theParameters[
"topmb31"] = 0.54;
67 theParameters[
"bottommb31"] = 0.77;
68 theParameters[
"topmb32"] = 0.35;
69 theParameters[
"bottommb32"] = 0.55;
70 theParameters[
"topmb21"] = 0.21;
71 theParameters[
"bottommb21"] = 0.31;
75 theCSCRecSegmentLabel,
86 muonLayersToken = esConsumes<MuonDetLayerGeometry, MuonRecoGeometryRecord>();
87 magFieldToken = esConsumes<MagneticField, IdealMagneticFieldRecord>();
93 delete muonMeasurements;
98 theField = eSetup.
getHandle(magFieldToken);
100 auto output = std::make_unique<TrajectorySeedCollection>();
107 theMuonLayers = eSetup.
getHandle(muonLayersToken);
110 vector<const DetLayer*> dtLayers = theMuonLayers->allDTLayers();
113 vector<const DetLayer*> cscForwardLayers = theMuonLayers->forwardCSCLayers();
114 vector<const DetLayer*> cscBackwardLayers = theMuonLayers->backwardCSCLayers();
116 muonMeasurements->setEvent(
event);
120 vector<MuonRecHitContainer> RHMBs;
121 vector<MuonRecHitContainer> RHMEFs;
122 vector<MuonRecHitContainer> RHMEBs;
126 for (vector<const DetLayer*>::reverse_iterator icsclayer = cscForwardLayers.rbegin();
127 icsclayer != cscForwardLayers.rend() - 1;
130 allHits.insert(allHits.end(), RHMF.begin(), RHMF.end());
133 for (vector<const DetLayer*>::reverse_iterator icsclayer = cscBackwardLayers.rbegin();
134 icsclayer != cscBackwardLayers.rend() - 1;
137 allHits.insert(allHits.end(), RHMF.begin(), RHMF.end());
140 for (vector<const DetLayer*>::reverse_iterator idtlayer = dtLayers.rbegin(); idtlayer != dtLayers.rend();
143 RHMBs.push_back(RHMB);
145 if (idtlayer != dtLayers.rbegin())
146 allHits.insert(allHits.end(), RHMB.begin(), RHMB.end());
160 createSeeds(
seeds, mb42, eSetup);
166 createSeeds(
seeds, mb31, eSetup);
171 if (!allHits.empty()) {
175 if (goodhits.empty()) {
179 createSeeds(
seeds, allHits, eSetup);
182 createSeeds(
seeds, goodhits, eSetup);
203 if (
hit->dimension() < 4) {
208 if (
hit->isDT() && (
hit->chi2() > theMaxDTChi2)) {
211 }
else if (
hit->isCSC() && (
hit->chi2() > theMaxCSCChi2)) {
223 for (MuonRecHitContainer::const_iterator
hit =
hits.begin();
hit !=
hits.end();
hit++) {
224 if (checkQuality(*
hit))
237 if (!(*hit)->isValid())
242 for (MuonRecHitContainer::iterator hit2 =
hit + 1; hit2 !=
result.end(); hit2++) {
243 if (*hit2 ==
nullptr)
245 if (!(*hit2)->isValid())
251 if (!areCorrelated((*
hit), (*hit2)))
254 if (!leftIsBetter((*
hit), (*hit2))) {
261 result2.push_back(*
hit);
276 for (MuonRecHitContainer::const_iterator ihit =
hits.begin(); ihit !=
hits.end(); ihit++) {
277 const std::vector<TrajectorySeed>& sds = createSeed((*ihit), eSetup);
280 if (
results.size() >= theMaxSeeds)
291 if (hitpairs.empty() ||
results.size() >= theMaxSeeds)
293 for (CosmicMuonSeedGenerator::MuonRecHitPairVector::const_iterator ihitpair = hitpairs.begin();
294 ihitpair != hitpairs.end();
296 const std::vector<TrajectorySeed>& sds = createSeed((*ihitpair), eSetup);
299 if (
results.size() >= theMaxSeeds)
307 std::vector<TrajectorySeed>
result;
324 if (theForcePointDownFlag) {
326 hit->globalDirection().phi() > 0)
333 polar *= fabs(
pt) / polar.
perp();
343 mat =
hit->parametersError().similarityT(
hit->projectionMatrix());
355 LogTrace(
category) <<
"mom: " << tsos.globalMomentum() <<
" phi: " << tsos.globalMomentum().phi();
363 result.push_back(tsosToSeed(tsos,
hit->geographicalId().rawId(), container));
364 result.push_back(tsosToSeed(tsos2,
hit->geographicalId().rawId(), container));
379 if ((deltaR<double>(
dir1.eta(),
dir1.phi(),
dir2.eta(),
dir2.phi()) < 0.1 ||
384 if ((deltaR<double>(
dir1.eta(),
dir1.phi(),
dir2.eta(),
dir2.phi()) < 0.1 ||
386 (deltaR<double>(
dir1.eta(),
dir1.phi(), dis.
eta(), dis.
phi()) < 0.1 ||
387 deltaR<double>(
dir2.eta(),
dir2.phi(), dis.
eta(), dis.
phi()) < 0.1))
390 if (fabs(
dir1.eta()) > 4.0 || fabs(
dir2.eta()) > 4.0) {
391 if ((fabs(
dir1.theta() -
dir2.theta()) < 0.07 || fabs(
dir1.theta() +
dir2.theta()) > 3.07) &&
392 (fabs(
dir1.theta() - dis.
theta()) < 0.07 || fabs(
dir1.theta() - dis.
theta()) < 0.07 ||
403 if ((lhs->degreesOfFreedom() > rhs->degreesOfFreedom()) ||
404 ((lhs->degreesOfFreedom() == rhs->degreesOfFreedom()) && (lhs)->chi2() < (rhs)->
chi2()))
417 if (hits1.empty() || hits2.empty())
420 for (MuonRecHitContainer::const_iterator ihit1 = hits1.begin(); ihit1 != hits1.end(); ihit1++) {
421 if (!checkQuality(*ihit1))
424 for (MuonRecHitContainer::const_iterator ihit2 = hits2.begin(); ihit2 != hits2.end(); ihit2++) {
425 if (!checkQuality(*ihit2))
428 float dphi =
deltaPhi((*ihit1)->globalPosition().barePhi(), (*ihit2)->globalPosition().barePhi());
430 if ((*ihit1)->globalPosition().y() > 0.0 && ((*ihit1)->globalPosition().y() > (*ihit2)->globalPosition().y())) {
434 }
else if ((*ihit1)->globalPosition().y() < 0.0 &&
435 ((*ihit1)->globalPosition().y() < (*ihit2)->globalPosition().y())) {
448 std::vector<TrajectorySeed>
result;
454 float dphi =
deltaPhi((hitpair.
first)->globalDirection().barePhi(), (hitpair.
second)->globalDirection().barePhi());
458 map<string, float>::const_iterator iterPar = theParameters.find(hitpair.
type);
459 if (iterPar == theParameters.end()) {
464 int charge = (dphi > 0) ? -1 : 1;
467 float paraC = (iterPar->second);
469 if (fabs(dphi) > 1
e-5) {
470 pt = paraC / fabs(dphi);
489 if (theForcePointDownFlag) {
491 hit->globalDirection().phi() > 0)
498 polar *= fabs(
pt) / polar.
perp();
504 mat =
hit->parametersError().similarityT(
hit->projectionMatrix());
506 float p_err = 0.004 / paraC;
517 LogTrace(
category) <<
"mom: " << tsos.globalMomentum() <<
" phi: " << tsos.globalMomentum().phi();
526 result.push_back(tsosToSeed(tsos,
hit->geographicalId().rawId(), container));
533 return tsosToSeed(tsos,
id, container);
std::string dumpMuonId(const DetId &id) const
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
Geom::Phi< T > phi() const
MuonTransientTrackingRecHit::MuonRecHitPointer first
bool checkQuality(const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
determine if a MuonTransientTrackingRecHit is qualified to build seed
std::vector< MuonRecHitPair > makeSegPairs(const MuonTransientTrackingRecHit::MuonRecHitContainer &, const MuonTransientTrackingRecHit::MuonRecHitContainer &, std::string) const
TrajectorySeed tsosToSeed(const TrajectoryStateOnSurface &, uint32_t) const
std::vector< TrajectorySeed > TrajectorySeedCollection
std::shared_ptr< MuonTransientTrackingRecHit > MuonRecHitPointer
MuonTransientTrackingRecHit::MuonRecHitContainer selectSegments(const MuonTransientTrackingRecHit::MuonRecHitContainer &) const
select seed candidates from Segments in Event
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::vector< TrajectorySeed > createSeed(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const edm::EventSetup &) const
create TrajectorySeed from MuonTransientTrackingRecHit
std::vector< MuonRecHitPair > MuonRecHitPairVector
CLHEP::HepVector AlgebraicVector
auto const good
min quality of good
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
MuonTransientTrackingRecHit::MuonRecHitPointer second
~CosmicMuonSeedGenerator() override
Destructor.
bool leftIsBetter(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
compare quality of two rechits
CLHEP::HepSymMatrix AlgebraicSymMatrix
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
void produce(edm::Event &, const edm::EventSetup &) override
reconstruct muon's seeds
bool areCorrelated(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
check if two rechits are correlated
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)
std::vector< MuonRecHitPointer > MuonRecHitContainer
void createSeeds(TrajectorySeedCollection &results, const MuonTransientTrackingRecHit::MuonRecHitContainer &hits, const edm::EventSetup &eSetup) const
generate TrajectorySeeds and put them into results
CosmicMuonSeedGenerator(const edm::ParameterSet &)
Constructor.
Geom::Theta< T > theta() const