CMS 3D CMS Logo

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

#include <DTTSM.h>

Public Member Functions

void addCand (DTTSCand *cand)
 Add a TSS candidate to the TSM, ifs is first/second track flag. More...
 
void clear ()
 Clear. More...
 
const DTConfigTSPhiconfig () const
 Configuration set. More...
 
 DTTSM (int)
 Constructor. More...
 
DTTSCandgetDTTSCand (int ifs, unsigned n) const
 Return requested TS candidate. More...
 
DTTSCandgetTrack (int n) const
 Return the requested track. More...
 
const DTTracoTrigDatagetTracoT (int ifs, unsigned n) const
 Return requested TRACO trigger. More...
 
void ignoreSecondTrack ()
 Set a flag to skip sort2. More...
 
unsigned nCand (int ifs) const
 Return the number of input tracks (first/second) More...
 
int nFirstT () const
 Return the number of input first tracks. More...
 
int nSecondT () const
 Return the number of input second tracks. More...
 
int nTracks () const
 Return the number of sorted tracks. More...
 
int number () const
 Return identifier. More...
 
void run (int bkmod)
 Run the TSM algorithm. More...
 
void setConfig (const DTConfigTSPhi *config)
 Set configuration. More...
 
DTTSCandsortTSM1 (int bkmod)
 Sort 1. More...
 
DTTSCandsortTSM2 (int bkmod)
 Sort 2. More...
 
 ~DTTSM ()
 Destructor. More...
 

Private Attributes

const DTConfigTSPhi_config
 
int _ignoreSecondTrack
 
std::vector< DTTSCand * > _incand [2]
 
int _n
 
std::vector< DTTSCand * > _outcand
 

Detailed Description

Implementation of TSM trigger algorithm

Author
C. Grandi, D. Bonacorsi, S. Marcellini

Definition at line 38 of file DTTSM.h.

Constructor & Destructor Documentation

DTTSM::DTTSM ( int  n)

Constructor.

Definition at line 38 of file DTTSM.cc.

References _incand, _outcand, and DTConfigTSPhi::NTSSTSM.

38  : _n(n), _ignoreSecondTrack(0) {
39  // reserve the appropriate amount of space for vectors
40  _incand[0].reserve(DTConfigTSPhi::NTSSTSM);
41  _incand[1].reserve(DTConfigTSPhi::NTSSTSM);
42  _outcand.reserve(2);
43 }
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:108
static const int NTSSTSM
Constant: maximum number of TSS in input to the TSM.
Definition: DTConfigTSPhi.h:42
int _ignoreSecondTrack
Definition: DTTSM.h:111
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
int _n
Definition: DTTSM.h:102
DTTSM::~DTTSM ( )

Destructor.

Definition at line 48 of file DTTSM.cc.

References clear().

48 { clear(); }
void clear()
Clear.
Definition: DTTSM.cc:54

Member Function Documentation

void DTTSM::addCand ( DTTSCand cand)

Add a TSS candidate to the TSM, ifs is first/second track flag.

Definition at line 268 of file DTTSM.cc.

References _incand, and DTTSCand::isFirst().

Referenced by DTTSPhi::runTSPhi(), and setConfig().

268  {
269  // NEW DESIGN: DTTSM is not configurable!
270  // cand->resetCarry(); // reset carry information
271  // cand->setBitsTsm(); // set quality bits for DTTSM sorting
272  _incand[(1 - cand->isFirst())].push_back(cand);
273 }
int isFirst() const
Return the first/second track bit.
Definition: DTTSCand.h:100
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
void DTTSM::clear ( void  )

Clear.

Definition at line 54 of file DTTSM.cc.

References _ignoreSecondTrack, _incand, and _outcand.

Referenced by ignoreSecondTrack(), and ~DTTSM().

54  {
56  for (int itk = 0; itk <= 1; itk++) {
57  // content of _incand is deleted by DTTSPhi
58  _incand[itk].clear();
59  }
60  // content of _outcand is deleted by DTTSPhi
61  _outcand.clear();
62 }
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:108
int _ignoreSecondTrack
Definition: DTTSM.h:111
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
const DTConfigTSPhi* DTTSM::config ( void  ) const
inline

Configuration set.

Definition at line 74 of file DTTSM.h.

References _config, and nCand().

Referenced by run(), setConfig(), sortTSM1(), and sortTSM2().

74 { return _config; }
const DTConfigTSPhi * _config
Definition: DTTSM.h:98
DTTSCand * DTTSM::getDTTSCand ( int  ifs,
unsigned  n 
) const

Return requested TS candidate.

Definition at line 285 of file DTTSM.cc.

References _incand, gather_cfg::cout, gen::n, nCand(), and AlCaHLTBitMon_ParallelJobs::p.

Referenced by getTracoT(), and nSecondT().

285  {
286  if (ifs < 1 || ifs > 2) {
287  std::cout << "DTTSM::getDTTSCand: wrong track number: " << ifs;
288  std::cout << " empty pointer returned!" << std::endl;
289  return nullptr;
290  }
291  if (n < 1 || n > nCand(ifs)) {
292  std::cout << "DTTSM::getDTTSCand: requested trigger not present: " << n;
293  std::cout << " empty pointer returned!" << std::endl;
294  return nullptr;
295  }
296  std::vector<DTTSCand *>::const_iterator p = _incand[ifs - 1].begin() + n - 1;
297  return (*p);
298 }
unsigned nCand(int ifs) const
Return the number of input tracks (first/second)
Definition: DTTSM.cc:275
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
DTTSCand * DTTSM::getTrack ( int  n) const

Return the requested track.

Definition at line 314 of file DTTSM.cc.

References _outcand, gather_cfg::cout, gen::n, nTracks(), and AlCaHLTBitMon_ParallelJobs::p.

Referenced by nTracks(), and sortTSM2().

314  {
315 
316  if (n < 1 || n > nTracks()) {
317  std::cout << "DTTSM::getTrack: requested track not present: " << n;
318  std::cout << " empty pointer returned!" << std::endl;
319  return nullptr;
320  }
321  std::vector<DTTSCand *>::const_iterator p = _outcand.begin() + n - 1;
322  return (*p);
323 }
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:108
int nTracks() const
Return the number of sorted tracks.
Definition: DTTSM.h:92
const DTTracoTrigData * DTTSM::getTracoT ( int  ifs,
unsigned  n 
) const

Return requested TRACO trigger.

Definition at line 300 of file DTTSM.cc.

References gather_cfg::cout, getDTTSCand(), gen::n, nCand(), and DTTSCand::tracoTr().

Referenced by nSecondT().

300  {
301  if (ifs < 1 || ifs > 2) {
302  std::cout << "DTTSM::getTracoT: wrong track number: " << ifs;
303  std::cout << " empty pointer returned!" << std::endl;
304  return nullptr;
305  }
306  if (n < 1 || n > nCand(ifs)) {
307  std::cout << "DTTSM::getTracoT: requested trigger not present: " << n;
308  std::cout << " empty pointer returned!" << std::endl;
309  return nullptr;
310  }
311  return getDTTSCand(ifs, n)->tracoTr();
312 }
DTTSCand * getDTTSCand(int ifs, unsigned n) const
Return requested TS candidate.
Definition: DTTSM.cc:285
unsigned nCand(int ifs) const
Return the number of input tracks (first/second)
Definition: DTTSM.cc:275
const DTTracoTrigData * tracoTr() const
Return associated TRACO trigger.
Definition: DTTSCand.h:85
void DTTSM::ignoreSecondTrack ( )
inline

Set a flag to skip sort2.

Definition at line 58 of file DTTSM.h.

References _ignoreSecondTrack, clear(), run(), sortTSM1(), and sortTSM2().

Referenced by DTTSPhi::ignoreSecondTrack().

58 { _ignoreSecondTrack = 1; }
int _ignoreSecondTrack
Definition: DTTSM.h:111
unsigned DTTSM::nCand ( int  ifs) const

Return the number of input tracks (first/second)

Definition at line 275 of file DTTSM.cc.

References _incand, and gather_cfg::cout.

Referenced by config(), getDTTSCand(), and getTracoT().

275  {
276  if (ifs < 1 || ifs > 2) {
277  std::cout << "DTTSM::nCand: wrong track number: " << ifs;
278  std::cout << " 0 returned!" << std::endl;
279  return 0;
280  }
281 
282  return _incand[ifs - 1].size();
283 }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
int DTTSM::nFirstT ( ) const
inline

Return the number of input first tracks.

Definition at line 80 of file DTTSM.h.

References _incand.

Referenced by run().

80 { return _incand[0].size(); }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
int DTTSM::nSecondT ( ) const
inline

Return the number of input second tracks.

Definition at line 83 of file DTTSM.h.

References _incand, getDTTSCand(), getTracoT(), and gen::n.

Referenced by run().

83 { return _incand[1].size(); }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
int DTTSM::nTracks ( ) const
inline

Return the number of sorted tracks.

Definition at line 92 of file DTTSM.h.

References _outcand, and getTrack().

Referenced by getTrack(), and sortTSM2().

92 { return _outcand.size(); }
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:108
int DTTSM::number ( ) const
inline

Return identifier.

Definition at line 49 of file DTTSM.h.

References _n.

49 { return _n; }
int _n
Definition: DTTSM.h:102
void DTTSM::run ( int  bkmod)

Run the TSM algorithm.

Definition at line 64 of file DTTSM.cc.

References _incand, _outcand, begin, config(), gather_cfg::cout, debug, plotBeamSpotDB::first, nFirstT(), nSecondT(), AlCaHLTBitMon_ParallelJobs::p, edm::second(), sortTSM1(), and sortTSM2().

Referenced by ignoreSecondTrack().

64  {
65 
66  if (config()->debug()) {
67  std::cout << "DTTSM::run: Processing DTTSM: ";
68  std::cout << nFirstT() << " first & " << nSecondT() << " second tracks"
69  << std::endl;
70  }
71 
72  if (nFirstT() < 1)
73  return; // skip if no first tracks
74  //
75  // SORT 1
76  //
77 
78  // debugging
79  if (config()->debug()) {
80  std::cout << "Vector of first tracks in DTTSM: " << std::endl;
81  std::vector<DTTSCand *>::const_iterator p;
82  for (p = _incand[0].begin(); p != _incand[0].end(); p++) {
83  (*p)->print();
84  }
85  }
86  // end debugging
87 
88  DTTSCand *first = sortTSM1(bkmod);
89  if (first != nullptr) {
90  _outcand.push_back(first);
91  }
92  if (nSecondT() < 1)
93  return; // skip if no second tracks
94 
95  //
96  // SORT 2
97  //
98 
99  // debugging
100  if (config()->debug()) {
101  std::vector<DTTSCand *>::const_iterator p;
102  std::cout << "Vector of second tracks (including carry) in DTTSM: "
103  << std::endl;
104  for (p = _incand[1].begin(); p != _incand[1].end(); p++) {
105  (*p)->print();
106  }
107  }
108  // end debugging
109 
110  DTTSCand *second = sortTSM2(bkmod);
111  if (second != nullptr) {
112 
113  _outcand.push_back(second);
114  }
115 }
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:108
DTTSCand * sortTSM2(int bkmod)
Sort 2.
Definition: DTTSM.cc:186
U second(std::pair< T, U > const &p)
int nSecondT() const
Return the number of input second tracks.
Definition: DTTSM.h:83
int nFirstT() const
Return the number of input first tracks.
Definition: DTTSM.h:80
#define debug
Definition: HDRShower.cc:19
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
#define begin
Definition: vmac.h:32
DTTSCand * sortTSM1(int bkmod)
Sort 1.
Definition: DTTSM.cc:117
const DTConfigTSPhi * config() const
Configuration set.
Definition: DTTSM.h:74
void DTTSM::setConfig ( const DTConfigTSPhi config)
inline

Set configuration.

Definition at line 52 of file DTTSM.h.

References _config, addCand(), and config().

52 { _config = config; }
const DTConfigTSPhi * _config
Definition: DTTSM.h:98
const DTConfigTSPhi * config() const
Configuration set.
Definition: DTTSM.h:74
DTTSCand * DTTSM::sortTSM1 ( int  bkmod)

Sort 1.

Definition at line 117 of file DTTSM.cc.

References _incand, funct::abs(), begin, config(), gather_cfg::cout, DTTSCand::isCorr(), DTTSCand::isInner(), DTConfig::NTCTSS, AlCaHLTBitMon_ParallelJobs::p, DTTSCand::setBitsBkmod(), DTTSCand::setBitsTss(), DTTSCand::setSecondTrack(), DTTSCand::TcPos(), DTConfigTSPhi::TsmGhost1Flag(), and DTTSCand::tssNumber().

Referenced by ignoreSecondTrack(), and run().

117  {
118  // Do a sort 1
119  DTTSCand *best = nullptr;
120  DTTSCand *carry = nullptr;
121  std::vector<DTTSCand *>::iterator p;
122  for (p = _incand[0].begin(); p != _incand[0].end(); p++) {
123  DTTSCand *curr = (*p);
124 
125  if (bkmod == 1) { // NORMAL mode ---> sorting on dataword
126  curr->setBitsTss(); // maybe not necessary, as they are the same as for
127  // TSS in the default
128  } else if (bkmod ==
129  0) { // { // BACKUP mode ---> sorting on modified dataword
130  curr->setBitsBkmod();
131  } else {
132  std::cout << "DTTSM::sortTSM1: bkmod not properly assigned!"
133  << std::endl;
134  }
135 
136  if (best == nullptr) {
137  best = curr;
138  } else if ((*curr) < (*best)) {
139  carry = best;
140  best = curr;
141  } else if (carry == nullptr) {
142  carry = curr;
143  } else if ((*curr) < (*carry)) {
144  carry = curr;
145  } // else { }
146  }
147 
148  // Ghost 1 suppression: use carry only if not suppressed
149  if (carry != nullptr) { // A carry is present
150 
151  // Carry enabled if correlated and TRACO is next to best
152  bool inner_or_corr;
153  if (config()->TsmGhost1Corr()) {
154  inner_or_corr = carry->isInner() || carry->isCorr();
155  } else {
156  inner_or_corr = carry->isInner();
157  }
158 
159  if (config()->TsmGhost1Flag() < 2) { // Carry isn't always suppressed
160  // check if adjacent DTTracoChips
161  int adj =
162  (carry->tssNumber() == best->tssNumber() + 1 && // next DTTracoChip
163  best->TcPos() == DTConfigTSPhi::NTCTSS && carry->TcPos() == 1) ||
164  (carry->tssNumber() == best->tssNumber() - 1 && // prev DTTracoChip
165  best->TcPos() == 1 && carry->TcPos() == DTConfigTSPhi::NTCTSS) ||
166  (carry->tssNumber() == best->tssNumber() && // same DTTracoChip
167  abs(carry->TcPos() - best->TcPos()) == 1);
168 
169  if (config()->TsmGhost1Flag() == 0 || // Carry always enabled
170  // carry->isInner() || //
171  // Carry is inner
172  inner_or_corr || // Carry is inner or corr
173  !adj) { // Carry not adj. to best
174  // add carry to second tracks to for sort 2
175  carry->setSecondTrack(); // change value of first/second track bit
176  // NEW DESIGN: DTTSM is not configurable!
177  // carry->setBitsTsm(); // set quality bits as for second tracks
178  _incand[1].push_back(carry); // add to list of second tracks
179  }
180  }
181  }
182  // best->print();
183  return best;
184 }
void setBitsTss()
Set the quality bits for DTTSS analysis.
Definition: DTTSCand.cc:80
int tssNumber() const
Return the DTTSS number.
Definition: DTTSCand.h:94
static const int NTCTSS
Constant: number of TRACOs in input to a TSS.
Definition: DTConfig.h:41
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int TsmGhost1Flag() const
Ghost 1 suppression option in TSM.
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
int isInner() const
Return Inner/Outer bit.
Definition: DTTSCand.h:107
void setSecondTrack()
Set the first track bit to second track (used for carry)
Definition: DTTSCand.h:64
#define begin
Definition: vmac.h:32
int TcPos() const
Retrun the TRACO position inside the TSS.
Definition: DTTSCand.h:88
const DTConfigTSPhi * config() const
Configuration set.
Definition: DTTSM.h:74
void setBitsBkmod()
Set the bits for TSM back-up mode.
Definition: DTTSCand.cc:154
int isCorr() const
Return correlation bit.
Definition: DTTSCand.h:110
DTTSCand * DTTSM::sortTSM2 ( int  bkmod)

Sort 2.

curr->isInner() && // outer track

Definition at line 186 of file DTTSM.cc.

References _ignoreSecondTrack, _incand, begin, config(), gather_cfg::cout, getTrack(), DTTSCand::isCorr(), DTTSCand::isInner(), nTracks(), AlCaHLTBitMon_ParallelJobs::p, edm::second(), DTTSCand::setBitsBkmod(), DTTSCand::setBitsTss(), DTTSCand::TcPos(), DTConfigTSPhi::TsmGhost2Corr(), DTConfigTSPhi::TsmGhost2Flag(), and DTTSCand::tssNumber().

Referenced by ignoreSecondTrack(), and run().

186  {
187 
188  // If second tracks are always suppressed skip processing
189  if (config()->TsmGhost2Flag() == 3)
190  return nullptr;
191 
192  // Check if there are second tracks
193  if (nTracks() < 1) {
194  std::cout << "DTTSM::sortTSM2: called with no first track.";
195  std::cout << " empty pointer returned!" << std::endl;
196  return nullptr;
197  }
198 
199  // If a first track at the following BX is present, ignore second tracks of
200  // any kind
201  if (_ignoreSecondTrack) {
202  std::vector<DTTSCand *>::iterator p;
203  for (p = _incand[1].begin(); p != _incand[1].end(); p++) {
204  if ((*p)->isCarry())
205  return (*p);
206  }
207  return nullptr;
208  }
209 
210  // If no first tracks at the following BX, do a sort 2
211  DTTSCand *best = getTrack(1);
212  DTTSCand *second = nullptr;
213  std::vector<DTTSCand *>::iterator p;
214  for (p = _incand[1].begin(); p != _incand[1].end(); p++) {
215  DTTSCand *curr = (*p);
216  // ghost 2 suppression: skip track if suppressed
217  // this is not needed if config of DTTSM == config of DTTSS
218 
219  bool inner_or_corr;
220  if (config()->TsmGhost2Corr()) {
221  inner_or_corr = curr->isInner() || curr->isCorr();
222  } else {
223  inner_or_corr = curr->isInner();
224  }
225 
226  if (config()->TsmGhost2Flag() != 0) { // 2nd tracks not always enabled
227  if (
229  !inner_or_corr && // outer and not corr
230  (curr->tssNumber() == best->tssNumber() &&
231  curr->TcPos() == best->TcPos())) { // same correlator of 1st track
232  if (config()->TsmGhost2Flag() == 2 || // do not look to corr bit of 1st
233  ((!best->isCorr()) &&
234  config()->TsmGhost2Flag() != 4) || // skip if best is not corr
235  ((!best->isCorr()) && best->isInner() &&
236  config()->TsmGhost2Flag() ==
237  4)) // skip only if best is inner and not corr
238  {
239  continue; // skip track
240  }
241  }
242  }
243 
244  // added DBSM
245  // SM double TSM if ( bkmod == 1 ) { // NORMAL mode ---> sorting with <
246  if (bkmod == 1) { // NORMAL mode ---> sorting on dataword
247  curr->setBitsTss(); // maybe not necessary, as they are the same as for
248  // TSS in the default
249  } else if (bkmod ==
250  0) { // { // BACKUP mode ---> sorting on modified dataword
251  curr->setBitsBkmod();
252  } else {
253  std::cout << " DTTSM::sortTSM2 bkmod not properly assigned!" << std::endl;
254  }
255 
256  // added DBSM
257  // SM double TSM if ( bkmod == 1 ) { // NORMAL mode ---> sorting with <
258 
259  if (second == nullptr) {
260  second = curr;
261  } else if ((*curr) < (*second)) {
262  second = curr;
263  }
264  }
265  return second;
266 }
void setBitsTss()
Set the quality bits for DTTSS analysis.
Definition: DTTSCand.cc:80
DTTSCand * getTrack(int n) const
Return the requested track.
Definition: DTTSM.cc:314
bool TsmGhost2Corr() const
Correlated ghost 2 suppression option in TSM.
U second(std::pair< T, U > const &p)
int tssNumber() const
Return the DTTSS number.
Definition: DTTSCand.h:94
int nTracks() const
Return the number of sorted tracks.
Definition: DTTSM.h:92
int _ignoreSecondTrack
Definition: DTTSM.h:111
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:105
int TsmGhost2Flag() const
Ghost 2 suppression option in TSM.
int isInner() const
Return Inner/Outer bit.
Definition: DTTSCand.h:107
#define begin
Definition: vmac.h:32
int TcPos() const
Retrun the TRACO position inside the TSS.
Definition: DTTSCand.h:88
const DTConfigTSPhi * config() const
Configuration set.
Definition: DTTSM.h:74
void setBitsBkmod()
Set the bits for TSM back-up mode.
Definition: DTTSCand.cc:154
int isCorr() const
Return correlation bit.
Definition: DTTSCand.h:110

Member Data Documentation

const DTConfigTSPhi* DTTSM::_config
private

Definition at line 98 of file DTTSM.h.

Referenced by config(), and setConfig().

int DTTSM::_ignoreSecondTrack
private

Definition at line 111 of file DTTSM.h.

Referenced by clear(), ignoreSecondTrack(), and sortTSM2().

std::vector<DTTSCand *> DTTSM::_incand[2]
private

Definition at line 105 of file DTTSM.h.

Referenced by addCand(), clear(), DTTSM(), getDTTSCand(), nCand(), nFirstT(), nSecondT(), run(), sortTSM1(), and sortTSM2().

int DTTSM::_n
private

Definition at line 102 of file DTTSM.h.

Referenced by number().

std::vector<DTTSCand *> DTTSM::_outcand
private

Definition at line 108 of file DTTSM.h.

Referenced by clear(), DTTSM(), getTrack(), nTracks(), and run().