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::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:107
static const int NTSSTSM
Constant: maximum number of TSS in input to the TSM.
Definition: DTConfigTSPhi.h:39
int _ignoreSecondTrack
Definition: DTTSM.h:110
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:104
int _n
Definition: DTTSM.h:101

◆ ~DTTSM()

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

◆ addCand()

void DTTSM::addCand ( DTTSCand cand)

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

Definition at line 256 of file DTTSM.cc.

References _incand, and push_back().

Referenced by DTTSPhi::runTSPhi().

256  {
257  // NEW DESIGN: DTTSM is not configurable!
258  // cand->resetCarry(); // reset carry information
259  // cand->setBitsTsm(); // set quality bits for DTTSM sorting
260  _incand[(1 - cand->isFirst())].push_back(cand);
261 }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:104
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})

◆ clear()

void DTTSM::clear ( void  )

Clear.

Definition at line 54 of file DTTSM.cc.

References _ignoreSecondTrack, _incand, and _outcand.

Referenced by ~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:107
int _ignoreSecondTrack
Definition: DTTSM.h:110
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:104

◆ config()

const DTConfigTSPhi* DTTSM::config ( void  ) const
inline

Configuration set.

Definition at line 73 of file DTTSM.h.

References _config.

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

73 { return _config; }
const DTConfigTSPhi * _config
Definition: DTTSM.h:97

◆ getDTTSCand()

DTTSCand * DTTSM::getDTTSCand ( int  ifs,
unsigned  n 
) const

Return requested TS candidate.

Definition at line 273 of file DTTSM.cc.

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

Referenced by getTracoT().

273  {
274  if (ifs < 1 || ifs > 2) {
275  std::cout << "DTTSM::getDTTSCand: wrong track number: " << ifs;
276  std::cout << " empty pointer returned!" << std::endl;
277  return nullptr;
278  }
279  if (n < 1 || n > nCand(ifs)) {
280  std::cout << "DTTSM::getDTTSCand: requested trigger not present: " << n;
281  std::cout << " empty pointer returned!" << std::endl;
282  return nullptr;
283  }
284  std::vector<DTTSCand *>::const_iterator p = _incand[ifs - 1].begin() + n - 1;
285  return (*p);
286 }
unsigned nCand(int ifs) const
Return the number of input tracks (first/second)
Definition: DTTSM.cc:263
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:104

◆ getTrack()

DTTSCand * DTTSM::getTrack ( int  n) const

Return the requested track.

Definition at line 302 of file DTTSM.cc.

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

Referenced by sortTSM2().

302  {
303  if (n < 1 || n > nTracks()) {
304  std::cout << "DTTSM::getTrack: requested track not present: " << n;
305  std::cout << " empty pointer returned!" << std::endl;
306  return nullptr;
307  }
308  std::vector<DTTSCand *>::const_iterator p = _outcand.begin() + n - 1;
309  return (*p);
310 }
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:107
int nTracks() const
Return the number of sorted tracks.
Definition: DTTSM.h:91

◆ getTracoT()

const DTTracoTrigData * DTTSM::getTracoT ( int  ifs,
unsigned  n 
) const

Return requested TRACO trigger.

Definition at line 288 of file DTTSM.cc.

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

288  {
289  if (ifs < 1 || ifs > 2) {
290  std::cout << "DTTSM::getTracoT: wrong track number: " << ifs;
291  std::cout << " empty pointer returned!" << std::endl;
292  return nullptr;
293  }
294  if (n < 1 || n > nCand(ifs)) {
295  std::cout << "DTTSM::getTracoT: requested trigger not present: " << n;
296  std::cout << " empty pointer returned!" << std::endl;
297  return nullptr;
298  }
299  return getDTTSCand(ifs, n)->tracoTr();
300 }
unsigned nCand(int ifs) const
Return the number of input tracks (first/second)
Definition: DTTSM.cc:263
const DTTracoTrigData * tracoTr() const
Return associated TRACO trigger.
Definition: DTTSCand.h:84
DTTSCand * getDTTSCand(int ifs, unsigned n) const
Return requested TS candidate.
Definition: DTTSM.cc:273

◆ ignoreSecondTrack()

void DTTSM::ignoreSecondTrack ( )
inline

Set a flag to skip sort2.

Definition at line 57 of file DTTSM.h.

References _ignoreSecondTrack.

Referenced by DTTSPhi::ignoreSecondTrack().

57 { _ignoreSecondTrack = 1; }
int _ignoreSecondTrack
Definition: DTTSM.h:110

◆ nCand()

unsigned DTTSM::nCand ( int  ifs) const

Return the number of input tracks (first/second)

Definition at line 263 of file DTTSM.cc.

References _incand, and gather_cfg::cout.

Referenced by getDTTSCand(), and getTracoT().

263  {
264  if (ifs < 1 || ifs > 2) {
265  std::cout << "DTTSM::nCand: wrong track number: " << ifs;
266  std::cout << " 0 returned!" << std::endl;
267  return 0;
268  }
269 
270  return _incand[ifs - 1].size();
271 }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:104

◆ nFirstT()

int DTTSM::nFirstT ( ) const
inline

Return the number of input first tracks.

Definition at line 79 of file DTTSM.h.

References _incand.

Referenced by run().

79 { return _incand[0].size(); }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:104

◆ nSecondT()

int DTTSM::nSecondT ( ) const
inline

Return the number of input second tracks.

Definition at line 82 of file DTTSM.h.

References _incand.

Referenced by run().

82 { return _incand[1].size(); }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:104

◆ nTracks()

int DTTSM::nTracks ( ) const
inline

Return the number of sorted tracks.

Definition at line 91 of file DTTSM.h.

References _outcand.

Referenced by getTrack(), and sortTSM2().

91 { return _outcand.size(); }
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:107

◆ number()

int DTTSM::number ( ) const
inline

Return identifier.

Definition at line 48 of file DTTSM.h.

References _n.

48 { return _n; }
int _n
Definition: DTTSM.h:101

◆ run()

void DTTSM::run ( int  bkmod)

Run the TSM algorithm.

Definition at line 64 of file DTTSM.cc.

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

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

◆ setConfig()

void DTTSM::setConfig ( const DTConfigTSPhi config)
inline

Set configuration.

Definition at line 51 of file DTTSM.h.

References _config, and config().

51 { _config = config; }
const DTConfigTSPhi * _config
Definition: DTTSM.h:97
const DTConfigTSPhi * config() const
Configuration set.
Definition: DTTSM.h:73

◆ sortTSM1()

DTTSCand * DTTSM::sortTSM1 ( int  bkmod)

Sort 1.

Definition at line 113 of file DTTSM.cc.

References _incand, funct::abs(), 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 run().

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

◆ sortTSM2()

DTTSCand * DTTSM::sortTSM2 ( int  bkmod)

Sort 2.

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

Definition at line 179 of file DTTSM.cc.

References _ignoreSecondTrack, _incand, 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 run().

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

Member Data Documentation

◆ _config

const DTConfigTSPhi* DTTSM::_config
private

Definition at line 97 of file DTTSM.h.

Referenced by config(), and setConfig().

◆ _ignoreSecondTrack

int DTTSM::_ignoreSecondTrack
private

Definition at line 110 of file DTTSM.h.

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

◆ _incand

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

Definition at line 104 of file DTTSM.h.

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

◆ _n

int DTTSM::_n
private

Definition at line 101 of file DTTSM.h.

Referenced by number().

◆ _outcand

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

Definition at line 107 of file DTTSM.h.

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