43 category_ =
"Muon|RecoMuon|CosmicMuon|GlobalCosmicMuonTrajectoryBuilder";
96 LogTrace(
category_) <<
"TrackMatcher found " << matched.size() <<
"tracker tracks matched";
98 if ( matched.empty())
return result;
101 if ( tkTrack.
isNull() )
return result;
106 if (muCand.first == 0 || !muCand.first->isValid()) {
109 muRecHits = muCand.first->recHits();
128 sortHits(hits, muRecHits, tkRecHits);
143 ( muonState1.
globalPosition().
y() > tkState1.globalPosition().y() )? muonState1 : tkState1;
145 ( muonState2.globalPosition().y() > tkState2.globalPosition().y() )? muonState2 : tkState2;
148 ( firstState1.globalPosition().y() > firstState2.
globalPosition().
y() )? firstState1 : firstState2;
152 front=hits.front()->globalPosition();
153 back=hits.back()->globalPosition();
154 if ( (front.
perp()<130 && fabs(front.
z())<300)|| (back.
perp() <130 && fabs(back.
z())<300)){
155 if (hits.front()->globalPosition().perp()>hits.back()->globalPosition().perp()) reverse(hits.begin(), hits.end());
158 firstState =( tkState1.globalPosition().perp() < tkState2.globalPosition().perp() )? tkState1 : tkState2;
161 if (!firstState.
isValid())
return result;
169 if ( refitted.empty() ) {
174 if (refitted.empty()) {
181 const std::vector<TrajectoryMeasurement>& mytms = myTraj->
measurements();
183 LogTrace(
category_) <<
"Orignally there are "<<tkTrack->found()<<
" tk rhs and "<<muTrack->found()<<
" mu rhs.";
185 if ( mytms.size() <= tkTrack->found() ) {
191 result.push_back(myCand);
193 for (std::vector<TrajectoryMeasurement>::const_iterator itm = mytms.begin();
194 itm != mytms.end(); ++itm ) {
196 <<
"mom "<<itm->updatedState().globalMomentum();
203 if ( tkHits.empty() ) {
207 if ( muonHits.empty() ) {
212 ConstRecHitContainer::const_iterator frontTkHit = tkHits.begin();
213 ConstRecHitContainer::const_iterator backTkHit = tkHits.end() - 1;
214 while ( !(*frontTkHit)->isValid() && frontTkHit != backTkHit) {frontTkHit++;}
215 while ( !(*backTkHit)->isValid() && backTkHit != frontTkHit) {backTkHit--;}
217 ConstRecHitContainer::const_iterator frontMuHit = muonHits.begin();
218 ConstRecHitContainer::const_iterator backMuHit = muonHits.end() - 1;
219 while ( !(*frontMuHit)->isValid() && frontMuHit != backMuHit) {frontMuHit++;}
220 while ( !(*backMuHit)->isValid() && backMuHit != frontMuHit) {backMuHit--;}
222 if ( frontTkHit == backTkHit ) {
226 if ( frontMuHit == backMuHit ) {
231 GlobalPoint frontTkPos = (*frontTkHit)->globalPosition();
232 GlobalPoint backTkPos = (*backTkHit)->globalPosition();
234 GlobalPoint frontMuPos = (*frontMuHit)->globalPosition();
235 GlobalPoint backMuPos = (*backMuHit)->globalPosition();
238 if ( frontTkPos.
y() < backTkPos.
y() ) {
239 reverse(tkHits.begin(), tkHits.end());
242 if ( frontMuPos.
y() < backMuPos.
y() ) {
243 reverse(muonHits.begin(), muonHits.end());
255 ConstRecHitContainer::iterator middlepoint = muonHits.begin();
256 bool insertInMiddle =
false;
258 for (ConstRecHitContainer::iterator ihit = muonHits.begin();
259 ihit != muonHits.end() - 1; ihit++ ) {
261 GlobalPoint nextpos = (*(ihit+1))->globalPosition();
262 if ( (ipos-nextpos).
mag() < 100.0 )
continue;
264 GlobalPoint middle((ipos.
x()+nextpos.
x())/2, (ipos.
y()+nextpos.
y())/2, (ipos.
z()+nextpos.
z())/2);
265 LogTrace(
category_)<<
"ipos "<<ipos<<
"nextpos"<<nextpos<<
" middle "<<middle<<endl;
269 insertInMiddle =
true;
275 if ( insertInMiddle ) {
276 GlobalPoint jointpointpos = (*middlepoint)->globalPosition();
278 if ((frontTkPos - jointpointpos).
mag() > (backTkPos - jointpointpos).
mag() ) {
279 reverse(tkHits.begin(), tkHits.end());
281 muonHits.insert(middlepoint+1, tkHits.begin(), tkHits.end());
284 if ( frontTkPos.
y() < frontMuPos.
y() ) {
288 hits.insert(hits.end(), tkHits.begin(), tkHits.end());
290 LogTrace(
category_)<<
"insert at the beginning "<<frontTkPos << frontMuPos <<endl;
292 hits.insert(hits.end(), muonHits.begin(), muonHits.end());
309 if((*hit)->isValid()) {
310 DetId recoid = (*hit)->geographicalId();
316 result.emplace_back(hitCloner(**
hit,predTsos));
328 std::vector<TrackCand>
result;
334 vector<TrackCand> tkTrackCands;
338 tkTrackCands.push_back(tkCand);
345 if (tkTrackCands.size() <= 1 ) {
356 outerPos.
basicVector().
dot(outerTsos.globalMomentum().basicVector() ) > 0 ) ) {
358 GlobalPoint geoInnerPos = (innerPos.
mag() < outerPos.
mag()) ? innerPos : outerPos;
364 for(vector<TrackCand>::const_iterator itkCand = tkTrackCands.begin(); itkCand != tkTrackCands.end(); ++itkCand) {
368 GlobalPoint tkInnerPos(tkTrack->innerPosition().x(), tkTrack->innerPosition().y(), tkTrack->innerPosition().z());
369 GlobalPoint tkOuterPos(tkTrack->outerPosition().x(), tkTrack->outerPosition().y(), tkTrack->outerPosition().z());
372 float closetDistance11 = (geoInnerPos - tkInnerPos).
mag() ;
373 float closetDistance12 = (geoInnerPos - tkOuterPos).
mag() ;
374 float closetDistance1 = (closetDistance11 < closetDistance12) ? closetDistance11 : closetDistance12;
379 for(vector<TrackCand>::const_iterator itkCand2 = tkTrackCands.begin(); itkCand2 != tkTrackCands.end(); ++itkCand2) {
380 if (itkCand2 == itkCand )
continue;
383 GlobalPoint tkInnerPos2(tkTrack2->innerPosition().x(), tkTrack2->innerPosition().y(), tkTrack2->innerPosition().z());
384 GlobalPoint tkOuterPos2(tkTrack2->outerPosition().x(), tkTrack2->outerPosition().y(), tkTrack2->outerPosition().z());
387 float farthestDistance21 = (geoInnerPos - tkInnerPos2).
mag() ;
388 float farthestDistance22 = (geoInnerPos - tkOuterPos2).
mag() ;
389 float farthestDistance2 = (farthestDistance21 > farthestDistance22) ? farthestDistance21 : farthestDistance22;
392 if (closetDistance1 > farthestDistance2 - 1
e-3) {
397 if (keep) result.push_back(*itkCand);
400 result.push_back(*itkCand);
403 if ( result.empty() ) {
405 result = tkTrackCands;
408 result = tkTrackCands;
414 LogTrace(
category_) <<
"TrackMatcher found " << matched_trackerTracks.size() <<
"tracker tracks matched";
417 if( matched_trackerTracks.size() < 2 ) {
418 return matched_trackerTracks;
426 double quality = 1e6;
427 double max_quality = 1e6;
428 for( vector<TrackCand>::const_iterator
iter = matched_trackerTracks.begin();
iter != matched_trackerTracks.end();
iter++) {
431 if( quality < max_quality ) {
437 result.push_back(bestMatch);
447 if((*hit)->isValid()) {
455 if((*hit)->isValid()) {
465 GlobalPoint middle((posFirst.
x()+posLast.
x())/2, (posFirst.
y()+posLast.
y())/2, (posFirst.
z()+posLast.
z())/2);
467 if ( (middle.
mag() < posFirst.
mag()) && (middle.
mag() < posLast.
mag() ) ) {
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
virtual TrajectoryContainer trajectories(const Trajectory &traj) const override
edm::ESHandle< TransientTrackingRecHitBuilder > theTrackerRecHitBuilder
edm::EDGetTokenT< reco::TrackCollection > theTkTrackToken
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
std::vector< Track > TrackCollection
collection of Tracks
GlobalPoint globalPosition() const
GlobalMuonTrackMatcher * theTrackMatcher
std::string thePropagatorName
std::vector< Trajectory * > trajectories(const TrajectorySeed &)
dummy implementation, unused in this class
std::string theMuonRecHitBuilderName
GlobalCosmicMuonTrajectoryBuilder(const edm::ParameterSet &, const MuonServiceProxy *service, edm::ConsumesCollector &iC)
Constructor.
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
DataContainer const & measurements() const
ConstRecHitContainer getTransientRecHits(const reco::Track &) const
bool isNull() const
Checks for null.
CosmicMuonSmoother * theSmoother
std::pair< const Trajectory *, reco::TrackRef > TrackCand
bool isTraversing(const reco::Track &tk) const
std::string theTrackerRecHitBuilderName
void sortHits(ConstRecHitContainer &, ConstRecHitContainer &, ConstRecHitContainer &)
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
std::vector< MuonCandidate * > CandidateContainer
double match(const TrackCand &sta, const TrackCand &track, int matchOption=0, int surfaceOption=1) const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual ~GlobalCosmicMuonTrajectoryBuilder()
Destructor.
std::vector< ConstRecHitPointer > ConstRecHitContainer
std::vector< Trajectory > fit(const Trajectory &) const
const MuonServiceProxy * theService
T const * product() const
std::vector< TrackCand > match(const TrackCand &, const edm::Handle< reco::TrackCollection > &)
check if tk and muon Tracks are matched
tuple GlobalMuonTrackMatcher
GlobalVector globalMomentum() const
static int position[264][3]
Detector det() const
get the detector field from this detid
const BasicVectorType & basicVector() const
edm::Handle< reco::TrackCollection > theTrackerTracks
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.