45 category_ =
"Muon|RecoMuon|CosmicMuon|GlobalCosmicMuonTrajectoryBuilder";
98 LogTrace(
category_) <<
"TrackMatcher found " << matched.size() <<
"tracker tracks matched";
100 if ( matched.empty())
return result;
103 if ( tkTrack.
isNull() )
return result;
108 if (muCand.first == 0 || !muCand.first->isValid()) {
111 muRecHits = muCand.first->recHits();
130 sortHits(hits, muRecHits, tkRecHits);
154 front=hits.front()->globalPosition();
155 back=hits.back()->globalPosition();
156 if ( (front.
perp()<130 && fabs(front.
z())<300)|| (back.
perp() <130 && fabs(back.
z())<300)){
157 if (hits.front()->globalPosition().perp()>hits.back()->globalPosition().perp()) reverse(hits.begin(), hits.end());
163 if (!firstState.
isValid())
return result;
171 if ( refitted.empty() ) {
176 if (refitted.empty()) {
183 const std::vector<TrajectoryMeasurement>& mytms = myTraj->
measurements();
185 LogTrace(
category_) <<
"Orignally there are "<<tkTrack->found()<<
" tk rhs and "<<muTrack->found()<<
" mu rhs.";
187 if ( mytms.size() <= tkTrack->found() ) {
193 result.push_back(myCand);
195 for (std::vector<TrajectoryMeasurement>::const_iterator itm = mytms.begin();
196 itm != mytms.end(); ++itm ) {
198 <<
"mom "<<itm->updatedState().globalMomentum();
205 if ( tkHits.empty() ) {
209 if ( muonHits.empty() ) {
214 ConstRecHitContainer::const_iterator frontTkHit = tkHits.begin();
215 ConstRecHitContainer::const_iterator backTkHit = tkHits.end() - 1;
216 while ( !(*frontTkHit)->isValid() && frontTkHit != backTkHit) {frontTkHit++;}
217 while ( !(*backTkHit)->isValid() && backTkHit != frontTkHit) {backTkHit--;}
219 ConstRecHitContainer::const_iterator frontMuHit = muonHits.begin();
220 ConstRecHitContainer::const_iterator backMuHit = muonHits.end() - 1;
221 while ( !(*frontMuHit)->isValid() && frontMuHit != backMuHit) {frontMuHit++;}
222 while ( !(*backMuHit)->isValid() && backMuHit != frontMuHit) {backMuHit--;}
224 if ( frontTkHit == backTkHit ) {
228 if ( frontMuHit == backMuHit ) {
233 GlobalPoint frontTkPos = (*frontTkHit)->globalPosition();
234 GlobalPoint backTkPos = (*backTkHit)->globalPosition();
236 GlobalPoint frontMuPos = (*frontMuHit)->globalPosition();
237 GlobalPoint backMuPos = (*backMuHit)->globalPosition();
240 if ( frontTkPos.
y() < backTkPos.
y() ) {
241 reverse(tkHits.begin(), tkHits.end());
244 if ( frontMuPos.
y() < backMuPos.
y() ) {
245 reverse(muonHits.begin(), muonHits.end());
257 ConstRecHitContainer::iterator middlepoint = muonHits.begin();
258 bool insertInMiddle =
false;
260 for (ConstRecHitContainer::iterator ihit = muonHits.begin();
261 ihit != muonHits.end() - 1; ihit++ ) {
263 GlobalPoint nextpos = (*(ihit+1))->globalPosition();
264 if ( (ipos-nextpos).
mag() < 100.0 )
continue;
266 GlobalPoint middle((ipos.
x()+nextpos.
x())/2, (ipos.
y()+nextpos.
y())/2, (ipos.
z()+nextpos.
z())/2);
267 LogTrace(
category_)<<
"ipos "<<ipos<<
"nextpos"<<nextpos<<
" middle "<<middle<<endl;
271 insertInMiddle =
true;
277 if ( insertInMiddle ) {
278 GlobalPoint jointpointpos = (*middlepoint)->globalPosition();
280 if ((frontTkPos - jointpointpos).
mag() > (backTkPos - jointpointpos).
mag() ) {
281 reverse(tkHits.begin(), tkHits.end());
283 muonHits.insert(middlepoint+1, tkHits.begin(), tkHits.end());
286 if ( frontTkPos.
y() < frontMuPos.
y() ) {
290 hits.insert(hits.end(), tkHits.begin(), tkHits.end());
292 LogTrace(
category_)<<
"insert at the beginning "<<frontTkPos << frontMuPos <<endl;
294 hits.insert(hits.end(), muonHits.begin(), muonHits.end());
309 if((*hit)->isValid()) {
310 DetId recoid = (*hit)->geographicalId();
318 result.push_back(preciseHit);
330 std::vector<TrackCand>
result;
336 vector<TrackCand> tkTrackCands;
340 tkTrackCands.push_back(tkCand);
347 if (tkTrackCands.size() <= 1 ) {
360 GlobalPoint geoInnerPos = (innerPos.
mag() < outerPos.
mag()) ? innerPos : outerPos;
366 for(vector<TrackCand>::const_iterator itkCand = tkTrackCands.begin(); itkCand != tkTrackCands.end(); ++itkCand) {
370 GlobalPoint tkInnerPos(tkTrack->innerPosition().x(), tkTrack->innerPosition().y(), tkTrack->innerPosition().z());
371 GlobalPoint tkOuterPos(tkTrack->outerPosition().x(), tkTrack->outerPosition().y(), tkTrack->outerPosition().z());
374 float closetDistance11 = (geoInnerPos - tkInnerPos).
mag() ;
375 float closetDistance12 = (geoInnerPos - tkOuterPos).
mag() ;
376 float closetDistance1 = (closetDistance11 < closetDistance12) ? closetDistance11 : closetDistance12;
381 for(vector<TrackCand>::const_iterator itkCand2 = tkTrackCands.begin(); itkCand2 != tkTrackCands.end(); ++itkCand2) {
382 if (itkCand2 == itkCand )
continue;
385 GlobalPoint tkInnerPos2(tkTrack2->innerPosition().x(), tkTrack2->innerPosition().y(), tkTrack2->innerPosition().z());
386 GlobalPoint tkOuterPos2(tkTrack2->outerPosition().x(), tkTrack2->outerPosition().y(), tkTrack2->outerPosition().z());
389 float farthestDistance21 = (geoInnerPos - tkInnerPos2).
mag() ;
390 float farthestDistance22 = (geoInnerPos - tkOuterPos2).
mag() ;
391 float farthestDistance2 = (farthestDistance21 > farthestDistance22) ? farthestDistance21 : farthestDistance22;
394 if (closetDistance1 > farthestDistance2 - 1e-3) {
399 if (keep) result.push_back(*itkCand);
402 result.push_back(*itkCand);
405 if ( result.empty() ) {
407 result = tkTrackCands;
410 result = tkTrackCands;
416 LogTrace(
category_) <<
"TrackMatcher found " << matched_trackerTracks.size() <<
"tracker tracks matched";
419 if( matched_trackerTracks.size() < 2 ) {
420 return matched_trackerTracks;
428 double quality = 1e6;
429 double max_quality = 1e6;
430 for( vector<TrackCand>::const_iterator iter = matched_trackerTracks.begin(); iter != matched_trackerTracks.end(); iter++) {
433 if( quality < max_quality ) {
439 result.push_back(bestMatch);
449 if((*hit)->isValid()) {
457 if((*hit)->isValid()) {
467 GlobalPoint middle((posFirst.
x()+posLast.
x())/2, (posFirst.
y()+posLast.
y())/2, (posFirst.
z()+posLast.
z())/2);
469 if ( (middle.
mag() < posFirst.
mag()) && (middle.
mag() < posLast.
mag() ) ) {
T getParameter(std::string const &) const
edm::ESHandle< TransientTrackingRecHitBuilder > theTrackerRecHitBuilder
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
GlobalPoint globalPosition() const
GlobalMuonTrackMatcher * theTrackMatcher
std::string thePropagatorName
std::vector< Trajectory * > trajectories(const TrajectorySeed &)
dummy implementation, unused in this class
std::string theMuonRecHitBuilderName
static int position[TOTALCHAMBERS][3]
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
edm::InputTag theTkTrackLabel
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
std::vector< TrackCand > match(const TrackCand &, const edm::Handle< reco::TrackCollection > &)
check if tk and muon Tracks are matched
tuple GlobalMuonTrackMatcher
GlobalVector globalMomentum() const
virtual std::vector< Trajectory > trajectories(const Trajectory &) const
Detector det() const
get the detector field from this detid
const BasicVectorType & basicVector() const
edm::Handle< reco::TrackCollection > theTrackerTracks
GlobalCosmicMuonTrajectoryBuilder(const edm::ParameterSet &, const MuonServiceProxy *service)
Constructor.
const double par[8 *NPar][4]
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.