CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
TTUTrackingAlg Class Reference

#include <TTUTrackingAlg.h>

Inheritance diagram for TTUTrackingAlg:
TTULogic

Classes

struct  CompareMechanism
 
struct  CompareSeeds
 
class  Seed
 
struct  SortByLayer
 
struct  SortBySector
 
class  Track
 

Public Types

typedef std::vector< Seed * >
::iterator 
SeedsItr
 
typedef std::vector< Track * >
::iterator 
TracksItr
 

Public Member Functions

bool process (const TTUInput &)
 
void setBoardSpecs (const TTUBoardSpecs::TTUBoardConfig &)
 
void setMinTrkLength (int val)
 
 TTUTrackingAlg ()
 Standard constructor. More...
 
virtual ~TTUTrackingAlg ()
 Destructor. More...
 
- Public Member Functions inherited from TTULogic
virtual void setOption (int option)
 
virtual ~TTULogic ()
 

Private Member Functions

void alignTracks ()
 
void cleanUp ()
 
int executeTracker (Track *, std::vector< Seed * > &)
 
void filter (Track *, std::vector< Seed * > &)
 
void findNeighbors (Seed *, std::vector< Seed * > &)
 
void ghostBuster (Track *)
 
void print (const std::vector< Seed * > &seeds)
 
void runSeedBuster (const TTUInput &)
 

Private Attributes

bool m_debug
 
std::vector< Seed * > m_initialseeds
 
int m_mintrklength
 
int m_SEscanorder [12]
 
int m_STscanorder [6]
 
std::vector< Track * > m_tracks
 

Additional Inherited Members

- Public Attributes inherited from TTULogic
int m_option
 
bool m_triggersignal
 

Detailed Description

Tracking Algorithm [ref 2]

ref 2: "A configurable Tracking Algorithm to detect cosmic muon tracks for the CMS-RPC based Technical Trigger", R.T.Rajan et al

Author
Andres Osorio

email: aosor.nosp@m.io@u.nosp@m.niand.nosp@m.es.e.nosp@m.du.co

Date
2008-10-18

Definition at line 26 of file TTUTrackingAlg.h.

Member Typedef Documentation

typedef std::vector<Seed*>::iterator TTUTrackingAlg::SeedsItr

Definition at line 119 of file TTUTrackingAlg.h.

typedef std::vector<Track*>::iterator TTUTrackingAlg::TracksItr

Definition at line 120 of file TTUTrackingAlg.h.

Constructor & Destructor Documentation

TTUTrackingAlg::TTUTrackingAlg ( )

Standard constructor.

Definition at line 19 of file TTUTrackingAlg.cc.

References i, m_debug, m_mintrklength, m_SEscanorder, m_STscanorder, and TTULogic::m_triggersignal.

19  {
20 
21  int StOrder[6]={6,5,4,3,2,1};
22  int SeOrder[12]={4,5,3,6,2,7,1,8,12,9,11,10};
23 
24  for(int i=0; i < 6; ++i)
25  {
26  m_STscanorder[i] = StOrder[i];
27  m_SEscanorder[i*2] = SeOrder[i*2];
28  m_SEscanorder[(i*2)+1] = SeOrder[(i*2)+1];
29  }
30 
31  m_triggersignal = false;
32  m_mintrklength = 4;
33 
34  m_debug = false;
35 
36 }
int i
Definition: DBlmapReader.cc:9
int m_SEscanorder[12]
bool m_triggersignal
Definition: TTULogic.h:35
TTUTrackingAlg::~TTUTrackingAlg ( )
virtual

Destructor.

Definition at line 41 of file TTUTrackingAlg.cc.

References m_initialseeds, and m_tracks.

41  {
42 
43  TracksItr itr1;
44  for (itr1=m_tracks.begin(); itr1!=m_tracks.end(); ++itr1)
45  delete (*itr1);
46 
47  SeedsItr itr2;
48  for (itr2=m_initialseeds.begin(); itr2!=m_initialseeds.end(); ++itr2)
49  delete (*itr2);
50 
51  //m_tracks.clear();
52  //m_initialseeds.clear();
53 
54 }
std::vector< Seed * > m_initialseeds
std::vector< Seed * >::iterator SeedsItr
std::vector< Track * >::iterator TracksItr
std::vector< Track * > m_tracks

Member Function Documentation

void TTUTrackingAlg::alignTracks ( )
private

Definition at line 292 of file TTUTrackingAlg.cc.

References compare_using_db::compare, gather_cfg::cout, m_debug, m_tracks, and python.multivaluedict::sort().

Referenced by process().

293 {
294 
295  TracksItr itr;
296  CompareMechanism<Track> compare;
297 
298  std::sort( m_tracks.begin(), m_tracks.end(), compare );
299  std::reverse( m_tracks.begin(), m_tracks.end() );
300 
301  if( m_debug ) {
302  for( itr = m_tracks.begin(); itr != m_tracks.end(); ++itr )
303  std::cout << "Align tracks> trk len: " << (*itr)->length() << " ";
304  std::cout << std::endl;
305  }
306 
307 }
tuple cout
Definition: gather_cfg.py:121
std::vector< Track * >::iterator TracksItr
std::vector< Track * > m_tracks
void TTUTrackingAlg::cleanUp ( )
private

Definition at line 309 of file TTUTrackingAlg.cc.

References m_initialseeds, and m_tracks.

Referenced by process().

310 {
311 
312  TracksItr itr1;
313  for (itr1=m_tracks.begin(); itr1!=m_tracks.end(); ++itr1)
314  delete (*itr1);
315 
316  SeedsItr itr2;
317  for (itr2=m_initialseeds.begin(); itr2!=m_initialseeds.end(); ++itr2)
318  delete (*itr2);
319 
320  m_tracks.clear();
321  m_initialseeds.clear();
322 
323 }
std::vector< Seed * > m_initialseeds
std::vector< Seed * >::iterator SeedsItr
std::vector< Track * >::iterator TracksItr
std::vector< Track * > m_tracks
int TTUTrackingAlg::executeTracker ( Track _trk,
std::vector< Seed * > &  neighbors 
)
private

Definition at line 181 of file TTUTrackingAlg.cc.

References TTUTrackingAlg::Track::add(), gather_cfg::cout, filter(), findNeighbors(), and m_debug.

Referenced by process().

182 {
183 
184  if ( m_debug ) std::cout << "executeTracker: " << neighbors.size() << std::endl;
185 
186  //...
187 
188  SeedsItr _itr = neighbors.begin();
189 
190  while( _itr != neighbors.end() ) {
191 
192  _trk->add( (*_itr) );
193 
194  std::vector<Seed*> _nextneighbors;
195 
196  findNeighbors( (*_itr) , _nextneighbors );
197 
198  filter( _trk, _nextneighbors );
199 
200  if ( _nextneighbors.size() == 1 )
201  executeTracker( _trk, _nextneighbors );
202 
203  //... bifurcation not considered at the moment
204 
205  ++_itr;
206 
207  }
208 
209  //...
210 
211 
212 
213  return 1;
214 
215 }
void findNeighbors(Seed *, std::vector< Seed * > &)
std::vector< Seed * >::iterator SeedsItr
void filter(Track *, std::vector< Seed * > &)
int executeTracker(Track *, std::vector< Seed * > &)
tuple cout
Definition: gather_cfg.py:121
void TTUTrackingAlg::filter ( Track _trk,
std::vector< Seed * > &  _nbrs 
)
private

Definition at line 251 of file TTUTrackingAlg.cc.

References gather_cfg::cout, spr::find(), m_debug, and TTUTrackingAlg::Track::m_seeds.

Referenced by executeTracker(), and process().

253 {
254 
255  //... filter: removes from neighbors list, seeds already present
256  //... in tracks
257 
258  SeedsItr _itr;
259 
260  for( _itr = _trk->m_seeds.begin();_itr != _trk->m_seeds.end(); ++_itr)
261  {
262  SeedsItr _isalready = std::find( _nbrs.begin(),_nbrs.end(), (*_itr) );
263 
264  if( _isalready != _nbrs.end() ) {
265  _nbrs.erase( _isalready );
266  if( m_debug ) std::cout << "removing ..." << std::endl;
267  }
268 
269 
270  }
271 
272 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< Seed * >::iterator SeedsItr
tuple cout
Definition: gather_cfg.py:121
void TTUTrackingAlg::findNeighbors ( Seed _seed,
std::vector< Seed * > &  neighbors 
)
private

Definition at line 217 of file TTUTrackingAlg.cc.

References abs, gather_cfg::cout, m_debug, m_initialseeds, TTUTrackingAlg::Seed::m_sectorId, and TTUTrackingAlg::Seed::m_stationId.

Referenced by executeTracker(), and process().

218 {
219 
220  neighbors.clear();
221 
222  int _xo = _seed->m_sectorId;
223  int _yo = _seed->m_stationId;
224 
225  if( m_debug ) std::cout << "X: " << _xo+1 << " Y: " << _yo+1 << std::endl;
226 
227  SeedsItr _itr = m_initialseeds.begin();
228 
229  while( _itr != m_initialseeds.end() ) {
230 
231  int _difx = std::abs( _xo - (*_itr)->m_sectorId );
232  int _dify = std::abs( _yo - (*_itr)->m_stationId );
233 
234  if (m_debug) std::cout << "difference (x,y): " << _difx << "," << _dify << "\t";
235 
236  if ( _difx == 11 ) _difx = 1;
237 
238  if ( ((_difx == 1) && (_dify == 1)) ||
239  ((_difx == 1) && (_dify == 0)) ||
240  ((_difx == 0) && (_dify == 1)) )
241 
242  neighbors.push_back( (*_itr) );
243 
244  ++_itr;
245  }
246 
247  if (m_debug) std::cout << std::endl;
248 
249 }
#define abs(x)
Definition: mlp_lapack.h:159
std::vector< Seed * > m_initialseeds
std::vector< Seed * >::iterator SeedsItr
tuple cout
Definition: gather_cfg.py:121
void TTUTrackingAlg::ghostBuster ( Track currentTrk)
private

Definition at line 274 of file TTUTrackingAlg.cc.

References TTUTrackingAlg::Track::m_seeds, python.multivaluedict::sort(), and TTUTrackingAlg::Track::updateTrkLength().

Referenced by process().

275 {
276 
277  //...do a final check to make sure there are no repeated seeds in track
278 
279  std::vector<Seed*>::iterator seedItr;
280 
281  std::sort( currentTrk->m_seeds.begin(), currentTrk->m_seeds.end(), SortBySector() );
282  std::sort( currentTrk->m_seeds.begin(), currentTrk->m_seeds.end(), SortByLayer() );
283 
284  seedItr = std::unique (currentTrk->m_seeds.begin(), currentTrk->m_seeds.end(), CompareSeeds() );
285 
286  currentTrk->m_seeds.resize(seedItr - currentTrk->m_seeds.begin());
287 
288  currentTrk->updateTrkLength();
289 
290 }
void TTUTrackingAlg::print ( const std::vector< Seed * > &  seeds)
inlineprivate

Definition at line 187 of file TTUTrackingAlg.h.

References gather_cfg::cout.

188  {
189  std::vector<Seed*>::const_iterator itr;
190  for( itr = seeds.begin(); itr != seeds.end(); ++itr)
191  std::cout << (*itr) << '\t';
192  std::cout << '\n';
193  };
tuple cout
Definition: gather_cfg.py:121
bool TTUTrackingAlg::process ( const TTUInput inmap)
virtual

Implements TTULogic.

Definition at line 64 of file TTUTrackingAlg.cc.

References TTUTrackingAlg::Track::add(), TTUTrackingAlg::Track::addnone(), alignTracks(), cleanUp(), gather_cfg::cout, executeTracker(), filter(), findNeighbors(), ghostBuster(), TTUInput::m_bx, m_debug, m_initialseeds, m_mintrklength, m_tracks, TTULogic::m_triggersignal, and runSeedBuster().

Referenced by ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), and TTUTwoORLogic::process().

65 {
66 
67  if( m_debug) std::cout << "TTUTrackingAlg>process() starts + bx= " << inmap.m_bx << std::endl;
68 
69  m_triggersignal = false;
70 
71  Track * initTrk = new Track();
72 
73  //.
74  runSeedBuster( inmap );
75 
76  if ( m_initialseeds.size() > 0 && m_initialseeds.size() < 20 ) // if too much hits, then cannot process
77  initTrk->add( m_initialseeds[0] );
78  else {
79  initTrk->addnone();
80  if( m_debug) std::cout << "TTUTrackingAlg>process() ends: no initialseeds" << std::endl;
81  return false;
82  }
83 
84 
85 
86 
87 
88  m_tracks.push_back( initTrk );
89 
90  //..
91  SeedsItr _seed = m_initialseeds.begin();
92  std::vector<Seed*> neighbors;
93 
94  while ( _seed != m_initialseeds.end() ) {
95 
96  findNeighbors( (*_seed) , neighbors );
97  filter( initTrk, neighbors );
98  executeTracker( initTrk, neighbors );
99  ghostBuster( initTrk );
100 
101  ++_seed;
102 
103  if ( _seed != m_initialseeds.end() ) {
104  initTrk = new Track();
105  initTrk->add((*_seed));
106  m_tracks.push_back( initTrk );
107 
108  }
109 
110  }
111 
112  TracksItr itr;
113 
114  if( m_debug) {
115  std::cout << "Total tracks: " << m_tracks.size() << std::endl;
116  for( itr = m_tracks.begin(); itr != m_tracks.end(); ++itr)
117  std::cout << "length: " << (*itr)->length() << '\t';
118  std::cout << std::endl;
119  }
120 
121  //...
122  alignTracks();
123 
124  //.... Look at the first track and compare its track length
125 
126  int tracklen(0);
127  itr = m_tracks.begin();
128  if ( itr != m_tracks.end() ) tracklen = (*itr)->length();
129 
130  if ( tracklen >= m_mintrklength )
131  m_triggersignal = true;
132 
133  if( m_debug ) {
134  std::cout << "TTUTrackingAlg> trk len= "
135  << tracklen << '\t' << "triggered: "
136  << m_triggersignal << std::endl;
137  }
138 
139  //..... Clean up for next run
140 
141  cleanUp();
142 
143  //.......................................................
144 
145  if( m_debug ) std::cout << "TTUTrackingAlg>process ends" << std::endl;
146 
147  return true;
148 
149 }
int m_bx
Definition: TTUInput.h:53
void findNeighbors(Seed *, std::vector< Seed * > &)
std::vector< Seed * > m_initialseeds
void ghostBuster(Track *)
std::vector< Seed * >::iterator SeedsItr
void filter(Track *, std::vector< Seed * > &)
int executeTracker(Track *, std::vector< Seed * > &)
bool m_triggersignal
Definition: TTULogic.h:35
void runSeedBuster(const TTUInput &)
tuple cout
Definition: gather_cfg.py:121
std::vector< Track * >::iterator TracksItr
std::vector< Track * > m_tracks
void TTUTrackingAlg::runSeedBuster ( const TTUInput inmap)
private

Definition at line 151 of file TTUTrackingAlg.cc.

References gather_cfg::cout, i, TTUInput::input_sec, gen::k, m_debug, m_initialseeds, m_SEscanorder, m_STscanorder, and relativeConstraints::station.

Referenced by process().

152 {
153 
154  int idx(0);
155  int idy(0);
156 
157  for(int i=0; i < 12; ++i)
158  {
159  idx = (m_SEscanorder[i] - 1);
160  std::bitset<6> station = inmap.input_sec[idx];
161 
162  if ( ! station.any() ) continue;
163 
164  for(int k=0; k < 6; ++k ) {
165 
166  idy = (m_STscanorder[k] - 1);
167  bool _hit = station[idy];
168 
169  if ( _hit ) {
170  Seed *_seed = new Seed( idx, idy, 0 );
171  m_initialseeds.push_back(_seed);
172  }
173  }
174  }
175 
176  //...
177  if ( m_debug ) std::cout << "SeedBuster: " << m_initialseeds.size() << std::endl;
178 
179 }
int i
Definition: DBlmapReader.cc:9
int m_SEscanorder[12]
std::vector< Seed * > m_initialseeds
int k[5][pyjets_maxn]
tuple cout
Definition: gather_cfg.py:121
std::bitset< 6 > * input_sec
Definition: TTUInput.h:59
void TTUTrackingAlg::setBoardSpecs ( const TTUBoardSpecs::TTUBoardConfig boardspecs)
virtual

Implements TTULogic.

Definition at line 57 of file TTUTrackingAlg.cc.

References m_mintrklength, and TTUBoardSpecs::TTUBoardConfig::m_TrackLength.

Referenced by TTUTwoORLogic::setBoardSpecs().

58 {
59 
60  m_mintrklength = boardspecs.m_TrackLength;
61 
62 }
void TTUTrackingAlg::setMinTrkLength ( int  val)
inline

Definition at line 122 of file TTUTrackingAlg.h.

References m_mintrklength.

123  {
124  m_mintrklength = val;
125  };

Member Data Documentation

bool TTUTrackingAlg::m_debug
private
std::vector<Seed*> TTUTrackingAlg::m_initialseeds
private

Definition at line 159 of file TTUTrackingAlg.h.

Referenced by cleanUp(), findNeighbors(), process(), runSeedBuster(), and ~TTUTrackingAlg().

int TTUTrackingAlg::m_mintrklength
private

Definition at line 155 of file TTUTrackingAlg.h.

Referenced by process(), setBoardSpecs(), setMinTrkLength(), and TTUTrackingAlg().

int TTUTrackingAlg::m_SEscanorder[12]
private

Definition at line 153 of file TTUTrackingAlg.h.

Referenced by runSeedBuster(), and TTUTrackingAlg().

int TTUTrackingAlg::m_STscanorder[6]
private

Definition at line 151 of file TTUTrackingAlg.h.

Referenced by runSeedBuster(), and TTUTrackingAlg().

std::vector<Track*> TTUTrackingAlg::m_tracks
private

Definition at line 157 of file TTUTrackingAlg.h.

Referenced by alignTracks(), cleanUp(), process(), and ~TTUTrackingAlg().