CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

DTSegmentCleaner Class Reference

#include <DTSegmentCleaner.h>

List of all members.

Public Types

typedef std::pair
< DTHitPairForFit
*, DTEnums::DTCellSide
AssPoint
typedef std::set< AssPoint,
DTSegmentCand::AssPointLessZ
AssPointCont

Public Member Functions

std::vector< DTSegmentCand * > clean (std::vector< DTSegmentCand * > inputCands) const
 do the cleaning
 DTSegmentCleaner (const edm::ParameterSet &pset)
 ~DTSegmentCleaner ()

Private Member Functions

std::vector< DTSegmentCand * > ghostBuster (std::vector< DTSegmentCand * > inputCands) const
 ghost suppression
std::vector< DTSegmentCand * > solveConflict (std::vector< DTSegmentCand * > inputCands) const
 solve the conflicts

Private Attributes

int nSharedHitsMax
int nUnSharedHitsMin
int segmCleanerMode

Detailed Description

Definition at line 33 of file DTSegmentCleaner.h.


Member Typedef Documentation

Definition at line 37 of file DTSegmentCleaner.h.

Definition at line 38 of file DTSegmentCleaner.h.


Constructor & Destructor Documentation

DTSegmentCleaner::DTSegmentCleaner ( const edm::ParameterSet pset)

Definition at line 22 of file DTSegmentCleaner.cc.

References edm::ParameterSet::getParameter().

                                                              {
  nSharedHitsMax = pset.getParameter<int>("nSharedHitsMax");

  nUnSharedHitsMin = pset.getParameter<int>("nUnSharedHitsMin");

  segmCleanerMode = pset.getParameter<int>("segmCleanerMode");
 
  if((segmCleanerMode!=1)&&(segmCleanerMode!=2)&&(segmCleanerMode!=3))
    edm::LogError("Muon|RecoLocalMuon|DTSegmentCleaner")
      << "Wrong segmCleanerMode! It must be 1,2 or 3. The default is 1";
}
DTSegmentCleaner::~DTSegmentCleaner ( )

Definition at line 35 of file DTSegmentCleaner.cc.

                                    {
}

Member Function Documentation

std::vector<DTSegmentCand*> DTSegmentCleaner::clean ( std::vector< DTSegmentCand * >  inputCands) const
vector< DTSegmentCand * > DTSegmentCleaner::ghostBuster ( std::vector< DTSegmentCand * >  inputCands) const [private]

ghost suppression

Definition at line 132 of file DTSegmentCleaner.cc.

References query::result.

                                                                     {
  vector<DTSegmentCand*> ghosts;
  for (vector<DTSegmentCand*>::iterator cand=inputCands.begin();
       cand!=inputCands.end(); ++cand) {
    for (vector<DTSegmentCand*>::iterator cand2=cand+1;
         cand2!=inputCands.end(); ++cand2) {
      unsigned int nSharedHits=(*cand)->nSharedHitPairs(*(*cand2));
      // cout << "Sharing " << (**cand) << " " << (**cand2) << " " << nSharedHits
      //   << " (first or second) " << ((**cand)<(**cand2)) << endl;
      if ((nSharedHits==((*cand)->nHits())) && (nSharedHits==((*cand2)->nHits()))
          &&(fabs((*cand)->chi2()-(*cand2)->chi2())<0.1)
          &&(segmCleanerMode==3))
      {
        continue;
      }

      // remove the worst segment if too many shared hits or too few unshared
      if ((int)nSharedHits >= nSharedHitsMax ||
          (int)((*cand)->nHits()-nSharedHits)<=nUnSharedHitsMin ||
          (int)((*cand2)->nHits()-nSharedHits)<=nUnSharedHitsMin) {

        if ((**cand)<(**cand2)) {
          ghosts.push_back(*cand);
        }
        else {
          ghosts.push_back(*cand2);
        }
        continue;
      }

    }
  }

  vector<DTSegmentCand*> result;
  for (vector<DTSegmentCand*>::const_iterator cand=inputCands.begin();
       cand!=inputCands.end(); ++cand) {
    bool isGhost=false;
    for (vector<DTSegmentCand*>::const_iterator ghost=ghosts.begin();
         ghost!=ghosts.end(); ++ghost) {
      if ((*cand)==(*ghost)) {
        isGhost=true;
        break;
      }
    }
    if (!isGhost) result.push_back(*cand);
    else delete *cand;
  }
  // cout << "No Ghosts ------" << endl;
  // for (vector<DTSegmentCand*>::iterator cand=result.begin();
  //      cand!=result.end(); ++cand) {
  //   cout << "cand " << *cand << " nH " <<(*cand)->nHits() << " chi2 " << (*cand)->chi2() << endl;
  // }
  // cout << "----------------" << endl;

  return result;
}
vector< DTSegmentCand * > DTSegmentCleaner::solveConflict ( std::vector< DTSegmentCand * >  inputCands) const [private]

solve the conflicts

treatment of LR ambiguity cases: 1 chooses the best chi2 2 chooses the smaller angle 3 keeps both candidates

Definition at line 49 of file DTSegmentCleaner.cc.

References DTSegmentCand::removeHit(), query::result, PV3DBase< T, PVType, FrameType >::theta(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::z().

                                                                                              {
  vector<DTSegmentCand*> result;

  vector<DTSegmentCand*> ghosts;


  for (vector<DTSegmentCand*>::iterator cand=inputCands.begin();
       cand!=inputCands.end(); ++cand) {
    for (vector<DTSegmentCand*>::iterator cand2 = cand+1 ; cand2!=inputCands.end() ; ++cand2) {

      DTSegmentCand::AssPointCont confHits=(*cand)->conflictingHitPairs(*(*cand2));

      if (confHits.size()) {
        if((confHits.size())==((*cand)->nHits()) && (confHits.size())==((*cand2)->nHits())
           && (fabs((*cand)->chi2()-(*cand2)->chi2())<0.1) ) { // cannot choose on the basis of # of hits or chi2

          if(segmCleanerMode == 2) { // mode 2: choose on the basis of the angle

            DTSegmentCand* badCand = 0;
            if((*cand)->superLayer()->id().superlayer() != 2) { // we are in the phi view

              LocalVector dir1 = (*cand)->direction();
              LocalVector dir2 = (*cand2)->direction();
              float phi1=(atan((dir1.x())/(dir1.z())));
              float phi2=(atan((dir2.x())/(dir2.z())));

              badCand = (fabs(phi1) > fabs(phi2)) ? (*cand) : (*cand2);

            } else {  // we are in the theta view: choose the most pointing one

              GlobalPoint IP;

              GlobalVector cand1GlobDir = (*cand)->superLayer()->toGlobal((*cand)->direction());
              GlobalPoint cand1GlobPos =  (*cand)->superLayer()->toGlobal((*cand)->position());
              GlobalVector cand1GlobVecIP = cand1GlobPos-IP;
              float DAlpha1 = fabs(cand1GlobDir.theta()-cand1GlobVecIP.theta());


              GlobalVector cand2GlobDir = (*cand2)->superLayer()->toGlobal((*cand2)->direction());
              GlobalPoint cand2GlobPos = (*cand2)->superLayer()->toGlobal((*cand2)->position());
              GlobalVector cand2GlobVecIP = cand2GlobPos-IP;
              float DAlpha2 = fabs(cand2GlobDir.theta()-cand2GlobVecIP.theta());

              badCand = (DAlpha1 > DAlpha2) ? (*cand) : (*cand2);
                
            }

            for (DTSegmentCand::AssPointCont::const_iterator cHit=confHits.begin() ;
                 cHit!=confHits.end(); ++cHit) {
              badCand->removeHit(*cHit);
            }
              
          } else { // mode 3: keep both candidates
            continue;
          }     

        } else { // mode 1: take > # hits or best chi2
          DTSegmentCand* badCand = (**cand) < (**cand2) ? (*cand) : (*cand2);
          for (DTSegmentCand::AssPointCont::const_iterator cHit=confHits.begin() ;
               cHit!=confHits.end(); ++cHit) badCand->removeHit(*cHit);
        }

      }
    }
  }

 
  vector<DTSegmentCand*>::iterator cand=inputCands.begin();
  while ( cand < inputCands.end() ) {
    if ((*cand)->good()) result.push_back(*cand);
    else {
      vector<DTSegmentCand*>::iterator badCand=cand;
      delete *badCand;
    }
    ++cand;
  }
  return result;
}

Member Data Documentation

Definition at line 57 of file DTSegmentCleaner.h.

Definition at line 58 of file DTSegmentCleaner.h.

treatment of LR ambiguity cases: 1 chooses the best chi2 2 chooses the smaller angle 3 keeps both candidates

Definition at line 62 of file DTSegmentCleaner.h.