CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/L1Trigger/RPCTechnicalTrigger/interface/TTUTrackingAlg.h

Go to the documentation of this file.
00001 // $Id: TTUTrackingAlg.h,v 1.5 2009/08/09 11:11:36 aosorio Exp $
00002 #ifndef TTUTRACKINGALG_H 
00003 #define TTUTRACKINGALG_H 1
00004 
00005 // Include files
00006 #include "L1Trigger/RPCTechnicalTrigger/interface/TTULogic.h"
00007 #include "L1Trigger/RPCTechnicalTrigger/interface/TTUInput.h"
00008 
00009 #include <iostream>
00010 #include <vector>
00011 
00026 class TTUTrackingAlg : public TTULogic {
00027 public: 
00029   TTUTrackingAlg( ); 
00030   
00031   virtual ~TTUTrackingAlg( ); 
00032 
00033   //... from TTULogic interface:
00034   
00035   bool process( const TTUInput & );
00036   
00037   void setBoardSpecs( const TTUBoardSpecs::TTUBoardConfig & );
00038   
00039   //...
00040   
00041   class Seed 
00042   {
00043   public:
00044     
00045     Seed() {m_sectorId = -9; m_stationId = -1; m_tkLength = 0;};
00046     Seed( int _seId, int _stId, int _tl)
00047     {
00048       m_sectorId  = _seId;
00049       m_stationId = _stId;
00050       m_tkLength  = _tl;
00051     };
00052   
00053     ~Seed() {};
00054     
00055     Seed( const Seed & _seed) 
00056     {
00057       m_sectorId  = _seed.m_sectorId;
00058       m_stationId = _seed.m_stationId;
00059       m_tkLength  = _seed.m_tkLength;
00060     };
00061     
00062     bool operator==(const Seed & rhs) 
00063     {
00064       return (m_sectorId == rhs.m_sectorId) 
00065         && (m_stationId == rhs.m_stationId);
00066     };
00067     
00068     int m_sectorId;
00069     int m_stationId;
00070     int m_tkLength;
00071     
00072   };
00073   
00074   class Track
00075   {
00076   public:
00077     
00078     Track() { m_tracklength = 0; };
00079     ~Track() { 
00080       if ( m_tracklength < 0 ) delete m_seeds[0];
00081       m_seeds.clear();
00082     };
00083     
00084     Track( const Track & trk ) 
00085     {
00086       m_seeds = trk.m_seeds;
00087       m_tracklength = trk.m_tracklength;
00088     };
00089     
00090     void add( Seed * sd ) { 
00091       m_seeds.push_back(sd); 
00092       ++m_tracklength;
00093     };
00094     
00095     void addnone() { 
00096       Seed *_sd = new Seed(0,0,0);
00097       m_seeds.push_back(_sd); 
00098       m_tracklength = -1;
00099     };
00100 
00101     void updateTrkLength() {
00102       m_tracklength = m_seeds.size();
00103     };
00104     
00105     bool operator<(const Track &rhs) {
00106       return m_tracklength < rhs.m_tracklength;
00107     };
00108     
00109     int length() { return m_tracklength;};
00110     
00111     std::vector<Seed*> m_seeds;
00112     
00113   private:
00114     
00115     int m_tracklength;
00116         
00117   };
00118   
00119   typedef std::vector<Seed*>::iterator SeedsItr;
00120   typedef std::vector<Track*>::iterator TracksItr;
00121 
00122   void setMinTrkLength( int val ) 
00123   {
00124     m_mintrklength = val;
00125   };
00126   
00127   template< class T>
00128   struct CompareMechanism
00129   {
00130     bool operator()( T* a, T* b ) { return (*a) < (*b) ; }
00131   };
00132     
00133 protected:
00134   
00135 private:
00136   
00137   void runSeedBuster( const TTUInput & );
00138   
00139   void findNeighbors( Seed * , std::vector<Seed*> & );
00140   
00141   int  executeTracker( Track *, std::vector<Seed*> & );
00142   
00143   void filter( Track * , std::vector<Seed*>  & );
00144 
00145   void ghostBuster( Track * );
00146     
00147   void alignTracks();
00148 
00149   void cleanUp();
00150     
00151   int m_STscanorder[6];
00152   
00153   int m_SEscanorder[12];
00154 
00155   int m_mintrklength;
00156 
00157   std::vector<Track*> m_tracks;
00158   
00159   std::vector<Seed*>  m_initialseeds;
00160   
00161   struct CompareSeeds {
00162     bool operator()( const Seed * a, const Seed * b )
00163     {
00164       //std::cout << (*a).m_sectorId << " " << (*b).m_sectorId << " " 
00165       //<< (*a).m_stationId << " " << (*b).m_stationId << std::endl;
00166       return ((*a).m_sectorId == (*b).m_sectorId ) && ((*a).m_stationId == (*b).m_stationId );
00167     }
00168   };
00169   
00170   struct SortBySector {
00171     bool operator()( const Seed * a, const Seed * b )
00172     {
00173       return ((*a).m_sectorId <= (*b).m_sectorId );
00174     }
00175   };
00176   
00177   struct SortByLayer {
00178     bool operator()( const Seed * a, const Seed * b )
00179     {
00180       return ((*a).m_stationId <= (*b).m_stationId );
00181       
00182     }
00183   };
00184 
00185 
00186 
00187   inline void print( const std::vector<Seed*> & seeds ) 
00188   {
00189     std::vector<Seed*>::const_iterator itr;
00190     for( itr = seeds.begin(); itr != seeds.end(); ++itr)
00191       std::cout << (*itr) << '\t';
00192     std::cout << '\n';
00193   };
00194 
00195   bool m_debug;
00196     
00197 };
00198 #endif // TTUTRACKINGALG_H