CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
TTUTrackingAlg Class Reference

#include <TTUTrackingAlg.h>

Inheritance diagram for TTUTrackingAlg:
TTULogic

Classes

struct  CompareMechanism
 
class  Seed
 
class  Track
 

Public Member Functions

bool process (const TTUInput &) override
 
void setBoardSpecs (const TTUBoardSpecs::TTUBoardConfig &) override
 
void setMinTrkLength (int val)
 
 TTUTrackingAlg ()
 Standard constructor. More...
 
 ~TTUTrackingAlg () override
 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< std::unique_ptr< Seed > > m_initialseeds
 
int m_mintrklength
 
int m_SEscanorder [12]
 
int m_STscanorder [6]
 
std::vector< std::unique_ptr< 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 25 of file TTUTrackingAlg.h.

Constructor & Destructor Documentation

TTUTrackingAlg::TTUTrackingAlg ( )

Standard constructor.

Definition at line 18 of file TTUTrackingAlg.cc.

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

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

Destructor.

Definition at line 40 of file TTUTrackingAlg.cc.

40  {
41 }

Member Function Documentation

void TTUTrackingAlg::alignTracks ( )
private

Definition at line 276 of file TTUTrackingAlg.cc.

References compare(), gather_cfg::cout, m_debug, m_tracks, groupFilesInBlocks::reverse, and jetUpdater_cfi::sort.

Referenced by TTUTrackingAlg::CompareMechanism< T >::operator()(), and process().

277 {
278 
279  CompareMechanism<std::unique_ptr<Track>> compare;
280 
281  std::sort( m_tracks.begin(), m_tracks.end(), compare );
282  std::reverse( m_tracks.begin(), m_tracks.end() );
283 
284  if( m_debug ) {
285  for( auto& tr : m_tracks)
286  std::cout << "Align tracks> trk len: " << tr->length() << " ";
287  std::cout << std::endl;
288  }
289 
290 }
bool compare(const P &i, const P &j)
std::vector< std::unique_ptr< Track > > m_tracks
void TTUTrackingAlg::cleanUp ( )
private

Definition at line 292 of file TTUTrackingAlg.cc.

References m_initialseeds, and m_tracks.

Referenced by TTUTrackingAlg::CompareMechanism< T >::operator()(), and process().

293 {
294 
295  m_tracks.clear();
296  m_initialseeds.clear();
297 
298 }
std::vector< std::unique_ptr< Seed > > m_initialseeds
std::vector< std::unique_ptr< Track > > m_tracks
int TTUTrackingAlg::executeTracker ( Track _trk,
std::vector< Seed * > &  neighbors 
)
private

Definition at line 161 of file TTUTrackingAlg.cc.

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

Referenced by TTUTrackingAlg::CompareMechanism< T >::operator()(), and process().

162 {
163 
164  if ( m_debug ) std::cout << "executeTracker: " << neighbors.size() << std::endl;
165 
166  //...
167 
168  auto _itr = neighbors.begin();
169 
170  while( _itr != neighbors.end() ) {
171 
172  _trk->add( (*_itr) );
173 
174  std::vector<Seed*> _nextneighbors;
175 
176  findNeighbors( (*_itr) , _nextneighbors );
177 
178  filter( _trk, _nextneighbors );
179 
180  if ( _nextneighbors.size() == 1 )
181  executeTracker( _trk, _nextneighbors );
182 
183  //... bifurcation not considered at the moment
184 
185  ++_itr;
186 
187  }
188 
189  //...
190 
191 
192 
193  return 1;
194 
195 }
void findNeighbors(Seed *, std::vector< Seed * > &)
void filter(Track *, std::vector< Seed * > &)
int executeTracker(Track *, std::vector< Seed * > &)
void TTUTrackingAlg::filter ( Track _trk,
std::vector< Seed * > &  _nbrs 
)
private

Definition at line 231 of file TTUTrackingAlg.cc.

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

Referenced by executeTracker(), TTUTrackingAlg::CompareMechanism< T >::operator()(), and process().

233 {
234 
235  //... filter: removes from neighbors list, seeds already present
236  //... in tracks
237 
238  for( auto _itr = _trk->m_seeds.begin();_itr != _trk->m_seeds.end(); ++_itr)
239  {
240  auto _isalready = std::find( _nbrs.begin(),_nbrs.end(), (*_itr) );
241 
242  if( _isalready != _nbrs.end() ) {
243  _nbrs.erase( _isalready );
244  if( m_debug ) std::cout << "removing ..." << std::endl;
245  }
246 
247 
248  }
249 
250 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void TTUTrackingAlg::findNeighbors ( Seed _seed,
std::vector< Seed * > &  neighbors 
)
private

Definition at line 197 of file TTUTrackingAlg.cc.

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

Referenced by executeTracker(), TTUTrackingAlg::CompareMechanism< T >::operator()(), and process().

198 {
199 
200  neighbors.clear();
201 
202  int _xo = _seed->m_sectorId;
203  int _yo = _seed->m_stationId;
204 
205  if( m_debug ) std::cout << "X: " << _xo+1 << " Y: " << _yo+1 << std::endl;
206 
207  auto _itr = m_initialseeds.begin();
208 
209  while( _itr != m_initialseeds.end() ) {
210 
211  int _difx = std::abs( _xo - (*_itr)->m_sectorId );
212  int _dify = std::abs( _yo - (*_itr)->m_stationId );
213 
214  if (m_debug) std::cout << "difference (x,y): " << _difx << "," << _dify << "\t";
215 
216  if ( _difx == 11 ) _difx = 1;
217 
218  if ( ((_difx == 1) && (_dify == 1)) ||
219  ((_difx == 1) && (_dify == 0)) ||
220  ((_difx == 0) && (_dify == 1)) )
221 
222  neighbors.push_back( (*_itr).get() );
223 
224  ++_itr;
225  }
226 
227  if (m_debug) std::cout << std::endl;
228 
229 }
std::vector< std::unique_ptr< Seed > > m_initialseeds
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void TTUTrackingAlg::ghostBuster ( Track currentTrk)
private

Definition at line 252 of file TTUTrackingAlg.cc.

References a, b, TTUTrackingAlg::Seed::m_sectorId, TTUTrackingAlg::Track::m_seeds, TTUTrackingAlg::Seed::m_stationId, jetUpdater_cfi::sort, tier0::unique(), and TTUTrackingAlg::Track::updateTrkLength().

Referenced by TTUTrackingAlg::CompareMechanism< T >::operator()(), and process().

253 {
254 
255  //...do a final check to make sure there are no repeated seeds in track
256 
257  std::vector<Seed*>::iterator seedItr;
258 
259  std::sort( currentTrk->m_seeds.begin(), currentTrk->m_seeds.end(), [](const Seed* a, const Seed* b) {
260  if (a->m_sectorId == b->m_sectorId) {
261  return a->m_stationId < b->m_stationId;
262  }
263  return a->m_sectorId < b->m_sectorId;
264  });
265 
266  seedItr = std::unique (currentTrk->m_seeds.begin(), currentTrk->m_seeds.end(), [](const Seed* a, const Seed *b) {
267  return a->m_sectorId == b->m_sectorId and a->m_stationId == b->m_stationId;
268  });
269 
270  currentTrk->m_seeds.resize(seedItr - currentTrk->m_seeds.begin());
271 
272  currentTrk->updateTrkLength();
273 
274 }
def unique(seq, keepstr=True)
Definition: tier0.py:25
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void TTUTrackingAlg::print ( const std::vector< Seed * > &  seeds)
inlineprivate

Definition at line 145 of file TTUTrackingAlg.h.

References gather_cfg::cout.

146  {
147  std::vector<Seed*>::const_iterator itr;
148  for( itr = seeds.begin(); itr != seeds.end(); ++itr)
149  std::cout << (*itr) << '\t';
150  std::cout << '\n';
151  };
bool TTUTrackingAlg::process ( const TTUInput inmap)
overridevirtual

Implements TTULogic.

Definition at line 51 of file TTUTrackingAlg.cc.

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

Referenced by TTUTwoORLogic::process().

52 {
53 
54  if( m_debug) std::cout << "TTUTrackingAlg>process() starts + bx= " << inmap.m_bx << std::endl;
55 
56  m_triggersignal = false;
57 
58  auto initTrk =std::make_unique<Track>();
59 
60  //.
61  runSeedBuster( inmap );
62 
63  if ( !m_initialseeds.empty() && m_initialseeds.size() < 20 ) // if too much hits, then cannot process
64  initTrk->add( m_initialseeds[0].get() );
65  else {
66  initTrk->addnone();
67  if( m_debug) std::cout << "TTUTrackingAlg>process() ends: no initialseeds" << std::endl;
68  return false;
69  }
70 
71  auto trk = m_tracks.emplace_back( std::move(initTrk) ).get();
72 
73  //..
74  auto _seed = m_initialseeds.begin();
75  std::vector<Seed*> neighbors;
76 
77  while ( _seed != m_initialseeds.end() ) {
78 
79  findNeighbors( (*_seed).get() , neighbors );
80  filter( trk, neighbors );
81  executeTracker( trk, neighbors );
82  ghostBuster( trk );
83 
84  ++_seed;
85 
86  if ( _seed != m_initialseeds.end() ) {
87  auto initTrk = std::make_unique<Track>();
88  initTrk->add((*_seed).get());
89  m_tracks.emplace_back( std::move(initTrk) );
90 
91  }
92 
93  }
94 
95  if( m_debug) {
96  std::cout << "Total tracks: " << m_tracks.size() << std::endl;
97  for( auto& tr : m_tracks)
98  std::cout << "length: " << tr->length() << '\t';
99  std::cout << std::endl;
100  }
101 
102  //...
103  alignTracks();
104 
105  //.... Look at the first track and compare its track length
106 
107  int tracklen(0);
108  auto itr = m_tracks.begin();
109  if ( itr != m_tracks.end() ) tracklen = (*itr)->length();
110 
111  if ( tracklen >= m_mintrklength )
112  m_triggersignal = true;
113 
114  if( m_debug ) {
115  std::cout << "TTUTrackingAlg> trk len= "
116  << tracklen << '\t' << "triggered: "
117  << m_triggersignal << std::endl;
118  }
119 
120  //..... Clean up for next run
121 
122  cleanUp();
123 
124  //.......................................................
125 
126  if( m_debug ) std::cout << "TTUTrackingAlg>process ends" << std::endl;
127 
128  return true;
129 
130 }
int m_bx
Definition: TTUInput.h:31
std::vector< std::unique_ptr< Seed > > m_initialseeds
void findNeighbors(Seed *, std::vector< Seed * > &)
void ghostBuster(Track *)
std::vector< std::unique_ptr< Track > > m_tracks
void filter(Track *, std::vector< Seed * > &)
int executeTracker(Track *, std::vector< Seed * > &)
bool m_triggersignal
Definition: TTULogic.h:34
void runSeedBuster(const TTUInput &)
def move(src, dest)
Definition: eostools.py:511
void TTUTrackingAlg::runSeedBuster ( const TTUInput inmap)
private

Definition at line 132 of file TTUTrackingAlg.cc.

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

Referenced by TTUTrackingAlg::CompareMechanism< T >::operator()(), and process().

133 {
134 
135  int idx(0);
136  int idy(0);
137 
138  for(int i=0; i < 12; ++i)
139  {
140  idx = (m_SEscanorder[i] - 1);
141  std::bitset<6> station = inmap.input_sec[idx];
142 
143  if ( ! station.any() ) continue;
144 
145  for(int k=0; k < 6; ++k ) {
146 
147  idy = (m_STscanorder[k] - 1);
148  bool _hit = station[idy];
149 
150  if ( _hit ) {
151  m_initialseeds.emplace_back(std::make_unique<Seed>(idx, idy, 0) );
152  }
153  }
154  }
155 
156  //...
157  if ( m_debug ) std::cout << "SeedBuster: " << m_initialseeds.size() << std::endl;
158 
159 }
std::vector< std::unique_ptr< Seed > > m_initialseeds
int m_SEscanorder[12]
std::array< std::bitset< 6 >, 12 > input_sec
Definition: TTUInput.h:37
int k[5][pyjets_maxn]
void TTUTrackingAlg::setBoardSpecs ( const TTUBoardSpecs::TTUBoardConfig boardspecs)
overridevirtual

Implements TTULogic.

Definition at line 44 of file TTUTrackingAlg.cc.

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

Referenced by TTUTwoORLogic::setBoardSpecs().

45 {
46 
47  m_mintrklength = boardspecs.m_TrackLength;
48 
49 }
void TTUTrackingAlg::setMinTrkLength ( int  val)
inline

Definition at line 106 of file TTUTrackingAlg.h.

References m_mintrklength, and heppy_batch::val.

107  {
109  };

Member Data Documentation

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

Definition at line 143 of file TTUTrackingAlg.h.

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

int TTUTrackingAlg::m_mintrklength
private

Definition at line 139 of file TTUTrackingAlg.h.

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

int TTUTrackingAlg::m_SEscanorder[12]
private

Definition at line 137 of file TTUTrackingAlg.h.

Referenced by runSeedBuster(), and TTUTrackingAlg().

int TTUTrackingAlg::m_STscanorder[6]
private

Definition at line 135 of file TTUTrackingAlg.h.

Referenced by runSeedBuster(), and TTUTrackingAlg().

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

Definition at line 141 of file TTUTrackingAlg.h.

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