CMS 3D CMS Logo

Public Member Functions | Public Attributes

SortMuonSegmentMatches Struct Reference

functor predicate for standard library sort algorithm More...

#include <MuonArbitrationMethods.h>

List of all members.

Public Member Functions

bool operator() (std::pair< reco::MuonChamberMatch *, reco::MuonSegmentMatch * > p1, std::pair< reco::MuonChamberMatch *, reco::MuonSegmentMatch * > p2)
 sorts vector of pairs of chamber and segment pointers
 SortMuonSegmentMatches (unsigned int flag)
 constructor takes arbitration type

Public Attributes

unsigned int flag_

Detailed Description

functor predicate for standard library sort algorithm

Definition at line 9 of file MuonArbitrationMethods.h.


Constructor & Destructor Documentation

SortMuonSegmentMatches::SortMuonSegmentMatches ( unsigned int  flag) [inline]

constructor takes arbitration type

Definition at line 11 of file MuonArbitrationMethods.h.

References flag_.

                                               {
      flag_ = flag;
   }

Member Function Documentation

bool SortMuonSegmentMatches::operator() ( std::pair< reco::MuonChamberMatch *, reco::MuonSegmentMatch * >  p1,
std::pair< reco::MuonChamberMatch *, reco::MuonSegmentMatch * >  p2 
) [inline]

sorts vector of pairs of chamber and segment pointers

Definition at line 15 of file MuonArbitrationMethods.h.

References reco::MuonSegmentMatch::BelongsToTrackByDR, reco::MuonSegmentMatch::BelongsToTrackByDRSlope, reco::MuonSegmentMatch::BelongsToTrackByDX, reco::MuonSegmentMatch::BelongsToTrackByDXSlope, reco::MuonSegmentMatch::BestInChamberByDR, reco::MuonSegmentMatch::BestInChamberByDRSlope, reco::MuonSegmentMatch::BestInChamberByDX, reco::MuonSegmentMatch::BestInChamberByDXSlope, reco::MuonSegmentMatch::BestInStationByDR, reco::MuonSegmentMatch::BestInStationByDRSlope, reco::MuonSegmentMatch::BestInStationByDX, reco::MuonSegmentMatch::BestInStationByDXSlope, reco::MuonSegmentMatch::dXdZ, reco::MuonChamberMatch::dXdZ, reco::MuonSegmentMatch::dYdZ, reco::MuonChamberMatch::dYdZ, flag_, reco::MuonSegmentMatch::hasZed(), funct::pow(), mathSSE::sqrt(), reco::MuonSegmentMatch::x, reco::MuonChamberMatch::x, reco::MuonSegmentMatch::y, and reco::MuonChamberMatch::y.

   {
      reco::MuonChamberMatch* cm1 = p1.first;
      reco::MuonSegmentMatch* sm1 = p1.second;
      reco::MuonChamberMatch* cm2 = p2.first;
      reco::MuonSegmentMatch* sm2 = p2.second;

      if(flag_ == reco::MuonSegmentMatch::BestInChamberByDX ||
         flag_ == reco::MuonSegmentMatch::BestInStationByDX ||
         flag_ == reco::MuonSegmentMatch::BelongsToTrackByDX)
         return fabs(sm1->x-cm1->x) < fabs(sm2->x-cm2->x);
      if(flag_ == reco::MuonSegmentMatch::BestInChamberByDR ||
         flag_ == reco::MuonSegmentMatch::BestInStationByDR || 
         flag_ == reco::MuonSegmentMatch::BelongsToTrackByDR)
      {
         if((! sm1->hasZed()) || (! sm2->hasZed())) // no y information so return dx
            return fabs(sm1->x-cm1->x) < fabs(sm2->x-cm2->x);
         return sqrt(pow(sm1->x-cm1->x,2)+pow(sm1->y-cm1->y,2)) <
            sqrt(pow(sm2->x-cm2->x,2)+pow(sm2->y-cm2->y,2)); 
      }
      if(flag_ == reco::MuonSegmentMatch::BestInChamberByDXSlope ||
         flag_ == reco::MuonSegmentMatch::BestInStationByDXSlope ||
         flag_ == reco::MuonSegmentMatch::BelongsToTrackByDXSlope)
         return fabs(sm1->dXdZ-cm1->dXdZ) < fabs(sm2->dXdZ-cm2->dXdZ);
      if(flag_ == reco::MuonSegmentMatch::BestInChamberByDRSlope ||
         flag_ == reco::MuonSegmentMatch::BestInStationByDRSlope ||
         flag_ == reco::MuonSegmentMatch::BelongsToTrackByDRSlope)
      {
         if((! sm1->hasZed()) || (! sm2->hasZed())) // no y information so return dx
            return fabs(sm1->dXdZ-cm1->dXdZ) < fabs(sm2->dXdZ-cm2->dXdZ);
         return sqrt(pow(sm1->dXdZ-cm1->dXdZ,2)+pow(sm1->dYdZ-cm1->dYdZ,2)) <
            sqrt(pow(sm2->dXdZ-cm2->dXdZ,2)+pow(sm2->dYdZ-cm2->dYdZ,2)); 
      }

      return false; // is this appropriate? fix this
   }

Member Data Documentation

Definition at line 53 of file MuonArbitrationMethods.h.

Referenced by operator()(), and SortMuonSegmentMatches().