45 produces<TrajectorySeedCollection>();
48 theEnableDTFlag = pset.
getParameter<
bool>(
"EnableDTMeasurement");
50 theEnableCSCFlag = pset.
getParameter<
bool>(
"EnableCSCMeasurement");
62 theForcePointDownFlag = pset.
existsAs<
bool>(
"ForcePointDown") ? pset.
getParameter<
bool>(
"ForcePointDown") :
true;
65 theParameters[
"topmb41"] = 0.87;
66 theParameters[
"bottommb41"] = 1.2;
67 theParameters[
"topmb42"] = 0.67;
68 theParameters[
"bottommb42"] = 0.98;
69 theParameters[
"topmb43"] = 0.34;
70 theParameters[
"bottommb43"] = 0.58;
71 theParameters[
"topmb31"] = 0.54;
72 theParameters[
"bottommb31"] = 0.77;
73 theParameters[
"topmb32"] = 0.35;
74 theParameters[
"bottommb32"] = 0.55;
75 theParameters[
"topmb21"] = 0.21;
76 theParameters[
"bottommb21"] = 0.31;
83 theEnableDTFlag,theEnableCSCFlag,
false,
false,
false);
92 delete muonMeasurements;
101 auto output = std::make_unique<TrajectorySeedCollection>();
111 vector<const DetLayer*> dtLayers = theMuonLayers->allDTLayers();
114 vector<const DetLayer*> cscForwardLayers = theMuonLayers->forwardCSCLayers();
115 vector<const DetLayer*> cscBackwardLayers = theMuonLayers->backwardCSCLayers();
119 muonMeasurements->setEvent(event);
123 vector<MuonRecHitContainer> RHMBs;
124 vector<MuonRecHitContainer> RHMEFs;
125 vector<MuonRecHitContainer> RHMEBs;
129 for (vector<const DetLayer*>::reverse_iterator icsclayer = cscForwardLayers.rbegin();
130 icsclayer != cscForwardLayers.rend() - 1; ++icsclayer) {
133 allHits.insert(allHits.end(),RHMF.begin(),RHMF.end());
137 for (vector<const DetLayer*>::reverse_iterator icsclayer = cscBackwardLayers.rbegin();
138 icsclayer != cscBackwardLayers.rend() - 1; ++icsclayer) {
141 allHits.insert(allHits.end(),RHMF.begin(),RHMF.end());
145 for (vector<const DetLayer*>::reverse_iterator idtlayer = dtLayers.rbegin();
146 idtlayer != dtLayers.rend(); ++idtlayer) {
149 RHMBs.push_back(RHMB);
151 if ( idtlayer != dtLayers.rbegin() ) allHits.insert(allHits.end(),RHMB.begin(),RHMB.end());
157 LogTrace(category)<<
"all RecHits: "<<allHits.size();
166 createSeeds(seeds, mb42, eSetup);
172 createSeeds(seeds, mb31, eSetup);
177 if ( !allHits.empty() ) {
180 LogTrace(category)<<
"good RecHits: "<<goodhits.size();
182 if ( goodhits.empty() ) {
183 LogTrace(category)<<
"No qualified Segments in Event! ";
184 LogTrace(category)<<
"Use 2D RecHit";
186 createSeeds(seeds,allHits,eSetup);
190 createSeeds(seeds,goodhits,eSetup);
194 LogTrace(category)<<
"Seeds built: "<<seeds.size();
196 for(std::vector<TrajectorySeed>::iterator
seed = seeds.begin();
212 if ( !hit->isValid() )
return false;
214 if (hit->dimension() < 4) {
219 if (hit->isDT() && ( hit->chi2()> theMaxDTChi2 )) {
220 LogTrace(category)<<
"DT chi2 too large";
223 else if (hit->isCSC() &&( hit->chi2()> theMaxCSCChi2 ) ) {
224 LogTrace(category)<<
"CSC chi2 too large";
237 for (MuonRecHitContainer::const_iterator
hit = hits.begin();
hit != hits.end();
hit++) {
238 if ( checkQuality(*
hit) ) result.push_back(*
hit);
241 if ( result.size() < 2 )
return result;
246 for (MuonRecHitContainer::iterator
hit = result.begin();
hit != result.end();
hit++) {
247 if (*
hit ==
nullptr)
continue;
248 if ( !(*hit)->isValid() )
continue;
252 for (MuonRecHitContainer::iterator hit2 =
hit + 1; hit2 != result.end(); hit2++) {
253 if (*hit2 ==
nullptr)
continue;
254 if ( !(*hit2)->isValid() )
continue;
259 if ( !areCorrelated((*
hit),(*hit2)) )
continue;
261 if ( !leftIsBetter((*
hit),(*hit2)) ) {
263 }
else (*hit2) =
nullptr;
266 if ( good ) result2.push_back(*
hit);
281 if (hits.empty() || results.size() >= theMaxSeeds )
return;
282 for (MuonRecHitContainer::const_iterator ihit = hits.begin(); ihit != hits.end(); ihit++) {
283 const std::vector<TrajectorySeed>& sds = createSeed((*ihit),eSetup);
284 LogTrace(category)<<
"created seeds from rechit "<<sds.size();
285 results.insert(results.end(),sds.begin(),sds.end());
286 if ( results.size() >= theMaxSeeds )
break;
297 if (hitpairs.empty() || results.size() >= theMaxSeeds )
return;
298 for (CosmicMuonSeedGenerator::MuonRecHitPairVector::const_iterator ihitpair = hitpairs.begin(); ihitpair != hitpairs.end(); ihitpair++) {
299 const std::vector<TrajectorySeed>& sds = createSeed((*ihitpair),eSetup);
300 LogTrace(category)<<
"created seeds from rechit "<<sds.size();
301 results.insert(results.end(),sds.begin(),sds.end());
302 if ( results.size() >= theMaxSeeds )
break;
310 std::vector<TrajectorySeed>
result;
326 hit->globalDirection().phi(),
329 if(theForcePointDownFlag){
330 if (hit->geographicalId().subdetId() ==
MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 && hit->globalDirection().phi() > 0 )
333 if (hit->geographicalId().subdetId() ==
MuonSubdetId::CSC && fabs(hit->globalDirection().eta()) > 2.3 )
337 polar *=fabs(pt)/polar.
perp();
347 mat = hit->parametersError().similarityT( hit->projectionMatrix() );
358 LogTrace(category)<<
"Trajectory State on Surface of Seed";
359 LogTrace(category)<<
"mom: "<<tsos.globalMomentum()<<
" phi: "<<tsos.globalMomentum().phi();
360 LogTrace(category)<<
"pos: " << tsos.globalPosition();
361 LogTrace(category) <<
"The RecSegment relies on: ";
365 container.
push_back(hit->hit()->clone());
367 result.push_back( tsosToSeed(tsos, hit->geographicalId().rawId(), container) );
368 result.push_back( tsosToSeed(tsos2, hit->geographicalId().rawId(), container) );
383 if ( (deltaR<double>(dir1.
eta(), dir1.
phi(), dir2.
eta(), dir2.
phi()) < 0.1 || deltaR<double>(dir1.
eta(), dir1.
phi(), -dir2.
eta(), -dir2.
phi()) < 0.1 )
387 if ( (deltaR<double>(dir1.
eta(), dir1.
phi(), dir2.
eta(), dir2.
phi()) < 0.1 || deltaR<double>(dir1.
eta(), dir1.
phi(), -dir2.
eta(), -dir2.
phi()) < 0.1 ) &&
388 (deltaR<double>(dir1.
eta(), dir1.
phi(), dis.
eta(), dis.
phi()) < 0.1 || deltaR<double>(dir2.
eta(), dir2.
phi(), dis.
eta(), dis.
phi()) < 0.1 ) )
391 if ( fabs(dir1.
eta()) > 4.0 || fabs(dir2.
eta()) > 4.0 ) {
392 if ( (fabs(dir1.
theta() - dir2.
theta()) < 0.07 ||
408 if ( (lhs->degreesOfFreedom() > rhs->degreesOfFreedom() ) ||
409 ( (lhs->degreesOfFreedom() == rhs->degreesOfFreedom() ) &&
410 (lhs)->chi2() < (rhs)->
chi2() ) )
return true;
422 if (hits1.empty() || hits2.empty() )
return result;
424 for (MuonRecHitContainer::const_iterator ihit1 = hits1.begin(); ihit1 != hits1.end(); ihit1++) {
425 if ( !checkQuality(*ihit1) )
continue;
427 for (MuonRecHitContainer::const_iterator ihit2 = hits2.begin(); ihit2 != hits2.end(); ihit2++) {
428 if ( !checkQuality(*ihit2) )
continue;
430 float dphi =
deltaPhi((*ihit1)->globalPosition().barePhi(), (*ihit2)->globalPosition().barePhi());
432 if ((*ihit1)->globalPosition().y() > 0.0 && ( (*ihit1)->globalPosition().y() > (*ihit2)->globalPosition().y() ) ) {
436 }
else if ((*ihit1)->globalPosition().y() < 0.0 && ( (*ihit1)->globalPosition().y() < (*ihit2)->globalPosition().y() ) ) {
450 std::vector<TrajectorySeed>
result;
456 float dphi =
deltaPhi((hitpair.
first)->globalDirection().barePhi(), (hitpair.
second)->globalDirection().barePhi());
460 map<string, float>::const_iterator iterPar = theParameters.find(hitpair.
type);
461 if ( iterPar == theParameters.end() ) {
466 int charge = (dphi > 0) ? -1 : 1;
469 float paraC = (iterPar->second);
471 if (fabs(dphi) > 1
e-5) {
472 pt = paraC/fabs(dphi);
475 if (pt < 10.0 ) {
return result; }
487 hit->globalDirection().phi(),
490 if(theForcePointDownFlag){
491 if (hit->geographicalId().subdetId() ==
MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 && 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;
507 if (pt < 10.01) p_err = 0.1;
515 LogTrace(category)<<
"Trajectory State on Surface of Seed";
516 LogTrace(category)<<
"mom: "<<tsos.globalMomentum()<<
" phi: "<<tsos.globalMomentum().phi();
517 LogTrace(category)<<
"pos: " << tsos.globalPosition();
518 LogTrace(category) <<
"The RecSegment relies on: ";
525 result.push_back( tsosToSeed(tsos, hit->geographicalId().rawId(), container) );
533 return tsosToSeed(tsos,
id, container);
T getParameter(std::string const &) const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
MuonTransientTrackingRecHit::MuonRecHitContainer selectSegments(const MuonTransientTrackingRecHit::MuonRecHitContainer &) const
select seed candidates from Segments in Event
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
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
MuonTransientTrackingRecHit::MuonRecHitPointer second
~CosmicMuonSeedGenerator() override
Destructor.
CLHEP::HepSymMatrix AlgebraicSymMatrix
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
void produce(edm::Event &, const edm::EventSetup &) override
reconstruct muon's seeds
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.