40 produces<TrajectorySeedCollection>();
43 theEnableDTFlag = pset.
getParameter<
bool>(
"EnableDTMeasurement");
45 theEnableCSCFlag = pset.
getParameter<
bool>(
"EnableCSCMeasurement");
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());
151 LogTrace(category) <<
"all RecHits: " << allHits.size();
160 createSeeds(seeds, mb42, eSetup);
166 createSeeds(seeds, mb31, eSetup);
171 if (!allHits.empty()) {
173 LogTrace(category) <<
"good RecHits: " << goodhits.size();
175 if (goodhits.empty()) {
176 LogTrace(category) <<
"No qualified Segments in Event! ";
177 LogTrace(category) <<
"Use 2D RecHit";
179 createSeeds(seeds, allHits, eSetup);
182 createSeeds(seeds, goodhits, eSetup);
186 LogTrace(category) <<
"Seeds built: " << seeds.size();
188 for (std::vector<TrajectorySeed>::iterator
seed = seeds.begin();
seed != seeds.end(); ++
seed) {
203 if (hit->dimension() < 4) {
208 if (hit->isDT() && (hit->chi2() > theMaxDTChi2)) {
209 LogTrace(category) <<
"DT chi2 too large";
211 }
else if (hit->isCSC() && (hit->chi2() > theMaxCSCChi2)) {
212 LogTrace(category) <<
"CSC chi2 too large";
223 for (MuonRecHitContainer::const_iterator
hit = hits.begin();
hit != hits.end();
hit++) {
224 if (checkQuality(*
hit))
225 result.push_back(*
hit);
228 if (result.size() < 2)
234 for (MuonRecHitContainer::iterator
hit = result.begin();
hit != result.end();
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);
274 if (hits.empty() || results.size() >= theMaxSeeds)
276 for (MuonRecHitContainer::const_iterator ihit = hits.begin(); ihit != hits.end(); ihit++) {
277 const std::vector<TrajectorySeed>& sds = createSeed((*ihit), eSetup);
278 LogTrace(category) <<
"created seeds from rechit " << sds.size();
279 results.insert(results.end(), sds.begin(), sds.end());
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);
297 LogTrace(category) <<
"created seeds from rechit " << sds.size();
298 results.insert(results.end(), sds.begin(), sds.end());
299 if (results.size() >= theMaxSeeds)
307 std::vector<TrajectorySeed>
result;
324 if (theForcePointDownFlag) {
325 if (hit->geographicalId().subdetId() ==
MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 &&
326 hit->globalDirection().phi() > 0)
329 if (hit->geographicalId().subdetId() ==
MuonSubdetId::CSC && fabs(hit->globalDirection().eta()) > 2.3)
333 polar *= fabs(pt) / polar.
perp();
343 mat = hit->parametersError().similarityT(hit->projectionMatrix());
354 LogTrace(category) <<
"Trajectory State on Surface of Seed";
355 LogTrace(category) <<
"mom: " << tsos.globalMomentum() <<
" phi: " << tsos.globalMomentum().phi();
356 LogTrace(category) <<
"pos: " << tsos.globalPosition();
357 LogTrace(category) <<
"The RecSegment relies on: ";
361 container.
push_back(hit->hit()->clone());
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 ||
380 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 ||
385 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) {
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) {
490 if (hit->geographicalId().subdetId() ==
MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 &&
491 hit->globalDirection().phi() > 0)
494 if (hit->geographicalId().subdetId() ==
MuonSubdetId::CSC && fabs(hit->globalDirection().eta()) > 2.3)
498 polar *= fabs(pt) / polar.
perp();
504 mat = hit->parametersError().similarityT(hit->projectionMatrix());
506 float p_err = 0.004 / paraC;
516 LogTrace(category) <<
"Trajectory State on Surface of Seed";
517 LogTrace(category) <<
"mom: " << tsos.globalMomentum() <<
" phi: " << tsos.globalMomentum().phi();
518 LogTrace(category) <<
"pos: " << tsos.globalPosition();
519 LogTrace(category) <<
"The RecSegment relies on: ";
526 result.push_back(tsosToSeed(tsos, hit->geographicalId().rawId(), container));
533 return tsosToSeed(tsos,
id, container);
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
MuonTransientTrackingRecHit::MuonRecHitContainer selectSegments(const MuonTransientTrackingRecHit::MuonRecHitContainer &) const
select seed candidates from Segments in Event
static const char category[]
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
Geom::Phi< T > phi() const
MuonTransientTrackingRecHit::MuonRecHitPointer first
std::string dumpMuonId(const DetId &id) const
Geom::Theta< T > theta() const
bool areCorrelated(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
check if two rechits are correlated
std::vector< TrajectorySeed > TrajectorySeedCollection
std::shared_ptr< MuonTransientTrackingRecHit > MuonRecHitPointer
bool leftIsBetter(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
compare quality of two rechits
std::vector< TrajectorySeed > createSeed(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const edm::EventSetup &) const
create TrajectorySeed from MuonTransientTrackingRecHit
std::vector< MuonRecHitPair > MuonRecHitPairVector
CLHEP::HepVector AlgebraicVector
bool checkQuality(const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
determine if a MuonTransientTrackingRecHit is qualified to build seed
auto const good
min quality of good
T getParameter(std::string const &) const
MuonTransientTrackingRecHit::MuonRecHitPointer second
~CosmicMuonSeedGenerator() override
Destructor.
CLHEP::HepSymMatrix AlgebraicSymMatrix
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
void produce(edm::Event &, const edm::EventSetup &) override
reconstruct muon's seeds
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::vector< MuonRecHitPair > makeSegPairs(const MuonTransientTrackingRecHit::MuonRecHitContainer &, const MuonTransientTrackingRecHit::MuonRecHitContainer &, std::string) const
TrajectorySeed tsosToSeed(const TrajectoryStateOnSurface &, uint32_t) const
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)
void createSeeds(TrajectorySeedCollection &results, const MuonTransientTrackingRecHit::MuonRecHitContainer &hits, const edm::EventSetup &eSetup) const
generate TrajectorySeeds and put them into results
std::vector< MuonRecHitPointer > MuonRecHitContainer
CosmicMuonSeedGenerator(const edm::ParameterSet &)
Constructor.