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 26 of file TTUTrackingAlg.h.

Constructor & Destructor Documentation

◆ TTUTrackingAlg()

TTUTrackingAlg::TTUTrackingAlg ( )

Standard constructor.

Definition at line 16 of file TTUTrackingAlg.cc.

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

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

◆ ~TTUTrackingAlg()

TTUTrackingAlg::~TTUTrackingAlg ( )
override

Destructor.

Definition at line 35 of file TTUTrackingAlg.cc.

35 {}

Member Function Documentation

◆ alignTracks()

void TTUTrackingAlg::alignTracks ( )
private

Definition at line 243 of file TTUTrackingAlg.cc.

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

Referenced by process().

243  {
244  CompareMechanism<std::unique_ptr<Track>> compare;
245 
246  std::sort(m_tracks.begin(), m_tracks.end(), compare);
247  std::reverse(m_tracks.begin(), m_tracks.end());
248 
249  if (m_debug) {
250  for (auto& tr : m_tracks)
251  std::cout << "Align tracks> trk len: " << tr->length() << " ";
252  std::cout << std::endl;
253  }
254 }
bool compare(const P &i, const P &j)
std::vector< std::unique_ptr< Track > > m_tracks

◆ cleanUp()

void TTUTrackingAlg::cleanUp ( )
private

Definition at line 256 of file TTUTrackingAlg.cc.

References m_initialseeds, and m_tracks.

Referenced by process().

256  {
257  m_tracks.clear();
258  m_initialseeds.clear();
259 }
std::vector< std::unique_ptr< Seed > > m_initialseeds
std::vector< std::unique_ptr< Track > > m_tracks

◆ executeTracker()

int TTUTrackingAlg::executeTracker ( Track _trk,
std::vector< Seed *> &  neighbors 
)
private

Definition at line 145 of file TTUTrackingAlg.cc.

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

Referenced by process().

145  {
146  if (m_debug)
147  std::cout << "executeTracker: " << neighbors.size() << std::endl;
148 
149  //...
150 
151  auto _itr = neighbors.begin();
152 
153  while (_itr != neighbors.end()) {
154  _trk->add((*_itr));
155 
156  std::vector<Seed*> _nextneighbors;
157 
158  findNeighbors((*_itr), _nextneighbors);
159 
160  filter(_trk, _nextneighbors);
161 
162  if (_nextneighbors.size() == 1)
163  executeTracker(_trk, _nextneighbors);
164 
165  //... bifurcation not considered at the moment
166 
167  ++_itr;
168  }
169 
170  //...
171 
172  return 1;
173 }
int executeTracker(Track *, std::vector< Seed *> &)
void filter(Track *, std::vector< Seed *> &)
void findNeighbors(Seed *, std::vector< Seed *> &)

◆ filter()

void TTUTrackingAlg::filter ( Track _trk,
std::vector< Seed *> &  _nbrs 
)
private

Definition at line 207 of file TTUTrackingAlg.cc.

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

Referenced by executeTracker(), and process().

207  {
208  //... filter: removes from neighbors list, seeds already present
209  //... in tracks
210 
211  for (auto _itr = _trk->m_seeds.begin(); _itr != _trk->m_seeds.end(); ++_itr) {
212  auto _isalready = std::find(_nbrs.begin(), _nbrs.end(), (*_itr));
213 
214  if (_isalready != _nbrs.end()) {
215  _nbrs.erase(_isalready);
216  if (m_debug)
217  std::cout << "removing ..." << std::endl;
218  }
219  }
220 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19

◆ findNeighbors()

void TTUTrackingAlg::findNeighbors ( Seed _seed,
std::vector< Seed *> &  neighbors 
)
private

Definition at line 175 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(), and process().

175  {
176  neighbors.clear();
177 
178  int _xo = _seed->m_sectorId;
179  int _yo = _seed->m_stationId;
180 
181  if (m_debug)
182  std::cout << "X: " << _xo + 1 << " Y: " << _yo + 1 << std::endl;
183 
184  auto _itr = m_initialseeds.begin();
185 
186  while (_itr != m_initialseeds.end()) {
187  int _difx = std::abs(_xo - (*_itr)->m_sectorId);
188  int _dify = std::abs(_yo - (*_itr)->m_stationId);
189 
190  if (m_debug)
191  std::cout << "difference (x,y): " << _difx << "," << _dify << "\t";
192 
193  if (_difx == 11)
194  _difx = 1;
195 
196  if (((_difx == 1) && (_dify == 1)) || ((_difx == 1) && (_dify == 0)) || ((_difx == 0) && (_dify == 1)))
197 
198  neighbors.push_back((*_itr).get());
199 
200  ++_itr;
201  }
202 
203  if (m_debug)
204  std::cout << std::endl;
205 }
std::vector< std::unique_ptr< Seed > > m_initialseeds
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ ghostBuster()

void TTUTrackingAlg::ghostBuster ( Track currentTrk)
private

Definition at line 222 of file TTUTrackingAlg.cc.

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

Referenced by process().

222  {
223  //...do a final check to make sure there are no repeated seeds in track
224 
225  std::vector<Seed*>::iterator seedItr;
226 
227  std::sort(currentTrk->m_seeds.begin(), currentTrk->m_seeds.end(), [](const Seed* a, const Seed* b) {
228  if (a->m_sectorId == b->m_sectorId) {
229  return a->m_stationId < b->m_stationId;
230  }
231  return a->m_sectorId < b->m_sectorId;
232  });
233 
234  seedItr = std::unique(currentTrk->m_seeds.begin(), currentTrk->m_seeds.end(), [](const Seed* a, const Seed* b) {
235  return a->m_sectorId == b->m_sectorId and a->m_stationId == b->m_stationId;
236  });
237 
238  currentTrk->m_seeds.resize(seedItr - currentTrk->m_seeds.begin());
239 
240  currentTrk->updateTrkLength();
241 }
def unique(seq, keepstr=True)
Definition: tier0.py:24
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ print()

void TTUTrackingAlg::print ( const std::vector< Seed *> &  seeds)
inlineprivate

Definition at line 129 of file TTUTrackingAlg.h.

References gather_cfg::cout, and HLT_2024v14_cff::seeds.

129  {
130  std::vector<Seed*>::const_iterator itr;
131  for (itr = seeds.begin(); itr != seeds.end(); ++itr)
132  std::cout << (*itr) << '\t';
133  std::cout << '\n';
134  };

◆ process()

bool TTUTrackingAlg::process ( const TTUInput inmap)
overridevirtual

Implements TTULogic.

Definition at line 42 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(), runSeedBuster(), and trk.

Referenced by TTUTwoORLogic::process().

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

◆ runSeedBuster()

void TTUTrackingAlg::runSeedBuster ( const TTUInput inmap)
private

Definition at line 119 of file TTUTrackingAlg.cc.

References gather_cfg::cout, mps_fire::i, heavyIonCSV_trainingSettings::idx, gpuPixelDoublets::idy, TTUInput::input_sec, isotrackApplyRegressor::k, m_debug, m_initialseeds, m_SEscanorder, m_STscanorder, and relativeConstraints::station.

Referenced by process().

119  {
120  int idx(0);
121  int idy(0);
122 
123  for (int i = 0; i < 12; ++i) {
124  idx = (m_SEscanorder[i] - 1);
125  std::bitset<6> station = inmap.input_sec[idx];
126 
127  if (!station.any())
128  continue;
129 
130  for (int k = 0; k < 6; ++k) {
131  idy = (m_STscanorder[k] - 1);
132  bool _hit = station[idy];
133 
134  if (_hit) {
135  m_initialseeds.emplace_back(std::make_unique<Seed>(idx, idy, 0));
136  }
137  }
138  }
139 
140  //...
141  if (m_debug)
142  std::cout << "SeedBuster: " << m_initialseeds.size() << std::endl;
143 }
std::vector< std::unique_ptr< Seed > > m_initialseeds
int m_SEscanorder[12]
std::array< std::bitset< 6 >, 12 > input_sec
Definition: TTUInput.h:36

◆ setBoardSpecs()

void TTUTrackingAlg::setBoardSpecs ( const TTUBoardSpecs::TTUBoardConfig boardspecs)
overridevirtual

Implements TTULogic.

Definition at line 38 of file TTUTrackingAlg.cc.

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

Referenced by TTUTwoORLogic::setBoardSpecs().

38  {
39  m_mintrklength = boardspecs.m_TrackLength;
40 }

◆ setMinTrkLength()

void TTUTrackingAlg::setMinTrkLength ( int  val)
inline

Definition at line 96 of file TTUTrackingAlg.h.

References m_mintrklength, and heppy_batch::val.

Member Data Documentation

◆ m_debug

bool TTUTrackingAlg::m_debug
private

◆ m_initialseeds

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

Definition at line 127 of file TTUTrackingAlg.h.

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

◆ m_mintrklength

int TTUTrackingAlg::m_mintrklength
private

Definition at line 123 of file TTUTrackingAlg.h.

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

◆ m_SEscanorder

int TTUTrackingAlg::m_SEscanorder[12]
private

Definition at line 121 of file TTUTrackingAlg.h.

Referenced by runSeedBuster(), and TTUTrackingAlg().

◆ m_STscanorder

int TTUTrackingAlg::m_STscanorder[6]
private

Definition at line 119 of file TTUTrackingAlg.h.

Referenced by runSeedBuster(), and TTUTrackingAlg().

◆ m_tracks

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

Definition at line 125 of file TTUTrackingAlg.h.

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