CMS 3D CMS Logo

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

#include <DTTSS.h>

Public Member Functions

void addDTTSCand (DTTSCand *cand)
 Add a TS candidate to the TSS, ifs is first/second track flag. More...
 
void clear ()
 Clear. More...
 
const DTConfigTSPhiconfig () const
 Configuration set. More...
 
 DTTSS (int)
 Constructor. More...
 
DTTSCandgetCarry () const
 Return the carry (for debugging) 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...
 
std::string logWord (int n) const
 Return the requested log word. 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...
 
unsigned nTracoT (int ifs) const
 Return the number of input tracks (first/second) More...
 
int number () const
 Return identifier. More...
 
void run ()
 Run the TSS algorithm. More...
 
void setConfig (const DTConfigTSPhi *config)
 Set configuration. More...
 
DTTSCandsortTSS1 ()
 Sort 1. More...
 
DTTSCandsortTSS2 ()
 Sort 2. More...
 
 ~DTTSS ()
 Destructor. More...
 

Private Attributes

const DTConfigTSPhi_config
 
int _ignoreSecondTrack
 
std::string _logWord1
 
std::string _logWord2
 
int _n
 
std::vector< DTTSCand * > _outcand
 
std::vector< DTTSCand * > _tctrig [2]
 

Detailed Description

Implementation of TSS trigger algorithm

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

Definition at line 36 of file DTTSS.h.

Constructor & Destructor Documentation

◆ DTTSS()

DTTSS::DTTSS ( int  n)

Constructor.

Definition at line 36 of file DTTSS.cc.

36  : _n(n), _ignoreSecondTrack(0) {
37  // reserve the appropriate amount of space for vectors
38  //_tctrig[0].reserve(DTConfigTSPhi::NTCTSS);
39  //_tctrig[1].reserve(DTConfigTSPhi::NTCTSS);
40  //_outcand.reserve(2);
41  _logWord1 = "1/----";
42  _logWord2 = "2/----";
43 }

References _logWord1, and _logWord2.

◆ ~DTTSS()

DTTSS::~DTTSS ( )

Destructor.

Definition at line 48 of file DTTSS.cc.

48 { clear(); }

References clear().

Member Function Documentation

◆ addDTTSCand()

void DTTSS::addDTTSCand ( DTTSCand cand)

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

Definition at line 274 of file DTTSS.cc.

274  {
275  int ifs = (cand->isFirst()) ? 0 : 1;
276  // std::cout << "SM DTTSS::addDTTSCand ifs = " << ifs << std::endl;
277  _tctrig[ifs].push_back(cand);
278 }

References _tctrig.

Referenced by DTTSPhi::addTracoT().

◆ clear()

void DTTSS::clear ( void  )

Clear.

Definition at line 54 of file DTTSS.cc.

54  {
56  for (int itk = 0; itk <= 1; itk++) {
57  // content of _tctrig is deleted in the DTTSPhi
58  _tctrig[itk].clear();
59  }
60  // content of _outcand is deleted in the DTTSPhi
61  _outcand.clear();
62 
63  // log words
64  _logWord1 = "1/----";
65  _logWord2 = "2/----";
66 }

References _ignoreSecondTrack, _logWord1, _logWord2, _outcand, and _tctrig.

Referenced by ~DTTSS().

◆ config()

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

Configuration set.

Definition at line 69 of file DTTSS.h.

69 { return _config; }

References _config.

Referenced by DTTSCand::config(), run(), setConfig(), sortTSS1(), and sortTSS2().

◆ getCarry()

DTTSCand * DTTSS::getCarry ( ) const

Return the carry (for debugging)

Definition at line 328 of file DTTSS.cc.

328  {
329  std::vector<DTTSCand *>::const_iterator p;
330  for (p = _tctrig[1].begin(); p != _tctrig[1].end(); p++)
331  if ((*p)->isCarry())
332  return (*p);
333  return nullptr;
334 }

References _tctrig, begin, and AlCaHLTBitMon_ParallelJobs::p.

◆ getDTTSCand()

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

Return requested TS candidate.

Definition at line 289 of file DTTSS.cc.

289  {
290  if (ifs < 1 || ifs > 2) {
291  std::cout << "DTTSS::getDTTSCand: wrong track number: " << ifs;
292  std::cout << " empty pointer returned!" << std::endl;
293  return nullptr;
294  }
295  if (n < 1 || n > nTracoT(ifs)) {
296  std::cout << "DTTSS::getDTTSCand: requested trigger not present: " << n;
297  std::cout << " empty pointer returned!" << std::endl;
298  return nullptr;
299  }
300  std::vector<DTTSCand *>::const_iterator p = _tctrig[ifs - 1].begin() + n - 1;
301  return (*p);
302 }

References _tctrig, gather_cfg::cout, dqmiodumpmetadata::n, nTracoT(), and AlCaHLTBitMon_ParallelJobs::p.

Referenced by getTracoT().

◆ getTrack()

DTTSCand * DTTSS::getTrack ( int  n) const

Return the requested track.

Definition at line 318 of file DTTSS.cc.

318  {
319  if (n < 1 || n > nTracks()) {
320  std::cout << "DTTSS::getTrack: requested track not present: " << n;
321  std::cout << " empty pointer returned!" << std::endl;
322  return nullptr;
323  }
324  std::vector<DTTSCand *>::const_iterator p = _outcand.begin() + n - 1;
325  return (*p);
326 }

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

Referenced by sortTSS2().

◆ getTracoT()

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

Return requested TRACO trigger.

Definition at line 304 of file DTTSS.cc.

304  {
305  if (ifs < 1 || ifs > 2) {
306  std::cout << "DTTSS::getTracoT: wrong track number: " << ifs;
307  std::cout << " empty pointer returned!" << std::endl;
308  return nullptr;
309  }
310  if (n < 1 || n > nTracoT(ifs)) {
311  std::cout << "DTTSS::getTracoT: requested trigger not present: " << n;
312  std::cout << " empty pointer returned!" << std::endl;
313  return nullptr;
314  }
315  return getDTTSCand(ifs, n)->tracoTr();
316 }

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

◆ ignoreSecondTrack()

void DTTSS::ignoreSecondTrack ( )
inline

Set a flag to skip sort2.

Definition at line 51 of file DTTSS.h.

51 { _ignoreSecondTrack = 1; }

References _ignoreSecondTrack.

Referenced by DTTSPhi::ignoreSecondTrack().

◆ logWord()

std::string DTTSS::logWord ( int  n) const

Return the requested log word.

Definition at line 336 of file DTTSS.cc.

336  {
337  std::string lw = "";
338  switch (n) {
339  case 1:
340  lw = _logWord1;
341  break;
342  case 2:
343  lw = _logWord2;
344  break;
345  default:
346  std::cout << "DTTSS::logWord: requested track not present: " << n;
347  std::cout << " empty string returned!" << std::endl;
348  }
349  return lw;
350 }

References _logWord1, _logWord2, gather_cfg::cout, dqmiodumpmetadata::n, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ nFirstT()

int DTTSS::nFirstT ( ) const
inline

Return the number of input first tracks.

Definition at line 75 of file DTTSS.h.

75 { return _tctrig[0].size(); }

References _tctrig.

Referenced by run().

◆ nSecondT()

int DTTSS::nSecondT ( ) const
inline

Return the number of input second tracks.

Definition at line 78 of file DTTSS.h.

78 { return _tctrig[1].size(); }

References _tctrig.

Referenced by run().

◆ nTracks()

int DTTSS::nTracks ( ) const
inline

Return the number of sorted tracks.

Definition at line 90 of file DTTSS.h.

90 { return _outcand.size(); }

References _outcand.

Referenced by getTrack(), and sortTSS2().

◆ nTracoT()

unsigned DTTSS::nTracoT ( int  ifs) const

Return the number of input tracks (first/second)

Definition at line 280 of file DTTSS.cc.

280  {
281  if (ifs < 1 || ifs > 2) {
282  std::cout << "DTTSS::nTracoT: wrong track number: " << ifs;
283  std::cout << " 0 returned!" << std::endl;
284  return 0;
285  }
286  return _tctrig[ifs - 1].size();
287 }

References _tctrig, and gather_cfg::cout.

Referenced by getDTTSCand(), and getTracoT().

◆ number()

int DTTSS::number ( ) const
inline

Return identifier.

Definition at line 66 of file DTTSS.h.

66 { return _n; }

References _n.

Referenced by DTTSPhi::addTracoT(), and DTTSCand::tssNumber().

◆ run()

void DTTSS::run ( )

Run the TSS algorithm.

Definition at line 68 of file DTTSS.cc.

68  {
69  if (config()->debug()) {
70  std::cout << "DTTSS::run: Processing DTTSS number " << _n << " : ";
71  std::cout << nFirstT() << " first & " << nSecondT() << " second tracks" << std::endl;
72  }
73 
74  if (nFirstT() < 1)
75  return; // skip if no first tracks
76  //
77  // SORT 1
78  //
79  // debugging
80  if (config()->debug()) {
81  std::cout << "Vector of first tracks in DTTSS: " << std::endl;
82  std::vector<DTTSCand *>::const_iterator p;
83  for (p = _tctrig[0].begin(); p != _tctrig[0].end(); p++) {
84  (*p)->print();
85  }
86  }
87  // end debugging
88 
89  DTTSCand *first = sortTSS1();
90  if (first != nullptr) {
91  _outcand.push_back(first);
92  }
93 
94  if (nSecondT() < 1)
95  return; // skip if no second tracks
96  //
97  // SORT 2
98  //
99  // debugging
100  if (config()->debug()) {
101  std::vector<DTTSCand *>::const_iterator p;
102  std::cout << "Vector of second tracks (including carry) in DTTSS: " << std::endl;
103  for (p = _tctrig[1].begin(); p != _tctrig[1].end(); p++) {
104  (*p)->print();
105  }
106  }
107  // end debugging
108 
109  DTTSCand *second = sortTSS2();
110  if (second != nullptr) {
111  _outcand.push_back(second);
112  }
113 }

References _n, _outcand, _tctrig, begin, config(), gather_cfg::cout, debug, dqmdumpme::first, nFirstT(), nSecondT(), AlCaHLTBitMon_ParallelJobs::p, edm::second(), sortTSS1(), and sortTSS2().

◆ setConfig()

void DTTSS::setConfig ( const DTConfigTSPhi config)
inline

Set configuration.

Definition at line 48 of file DTTSS.h.

48 { _config = config; }

References _config, and config().

◆ sortTSS1()

DTTSCand * DTTSS::sortTSS1 ( )

Sort 1.

Definition at line 115 of file DTTSS.cc.

115  {
116  // Do a sort 1
117  DTTSCand *best = nullptr;
118  DTTSCand *carry = nullptr;
119  std::vector<DTTSCand *>::iterator p;
120  for (p = _tctrig[0].begin(); p != _tctrig[0].end(); p++) {
121  DTTSCand *curr = (*p) ? (*p) : nullptr;
122  // SM sector collector Set bits for tss
123  curr->setBitsTss();
124  if (curr->dataword() == 0x1ff)
125  continue;
126  _logWord1[1 + curr->TcPos()] = (curr->isFirst()) ? '1' : '2';
127  // std::cout << "Running TSS: --->curr->dataword() sort 1 " <<
128  // curr->dataword() << std::endl;
129  if (best == nullptr) {
130  best = curr;
131  } else if ((*curr) <= (*best)) {
132  carry = best;
133  best = curr;
134  } else if (carry == nullptr) {
135  carry = curr;
136  } else if ((*curr) <= (*carry)) {
137  carry = curr;
138  }
139  }
140 
141  // Ghost 1 suppression: use carry only if not suppressed
142 
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()->TssGhost1Corr()) {
148  inner_or_corr = carry->isInner() || carry->isCorr();
149 
150  } else {
151  inner_or_corr = carry->isInner();
152  }
153  if (config()->TssGhost1Flag() < 2 && ( // Carry isn't always suppressed
154  config()->TssGhost1Flag() == 0 || // Carry always enabled
155  // carry->isInner() || // Carry is inner
156  inner_or_corr || // carry is inner or corr
157  abs(carry->TcPos() - best->TcPos()) != 1) // Carry not adj. to best
158  ) {
159  // add carry to second tracks for sort 2
160  carry->setSecondTrack(); // change value of first/second track bit
161  carry->setBitsTss(); // set quality bits as for second tracks
162  _tctrig[1].push_back(carry); // add to list of second tracks
163  } else {
164  _logWord1[1 + carry->TcPos()] = 'g';
165  }
166  }
167 
168  /*
169  if(carry!=0 && config()->TssGhost1Flag()<2){ // Carry isn't always suppressed
170  if(config()->TssGhost1Flag()==0 || // Carry always enabled
171  carry->isInner() || // Carry is inner
172  abs(carry->TcPos()-best->TcPos())!=1) { // Carry not adj. to best
173  // add carry to second tracks to for sort 2
174  carry->setSecondTrack(); // change value of first/second track bit
175  carry->setBitsTss(); // set quality bits as for second tracks
176  _tctrig[1].push_back(carry); // add to list of second tracks
177  }
178  }
179  */
180  // std::cout << " best TSS sort 1 = " << best->dataword() << std::endl;
181  // std::cout << " SM end of TSS sort 1: best = " << std::endl;
182  // best->print();
183 
184  return best;
185 }

References _logWord1, _tctrig, funct::abs(), begin, config(), DTTSCand::dataword(), DTTSCand::isCorr(), DTTSCand::isFirst(), DTTSCand::isInner(), AlCaHLTBitMon_ParallelJobs::p, DTTSCand::setBitsTss(), DTTSCand::setSecondTrack(), DTTSCand::TcPos(), and DTConfigTSPhi::TssGhost1Corr().

Referenced by run().

◆ sortTSS2()

DTTSCand * DTTSS::sortTSS2 ( )

Sort 2.

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

Definition at line 187 of file DTTSS.cc.

187  {
188  // Check if there are second tracks
189  if (nTracks() < 1) {
190  std::cout << "DTTSS::DTTSSsort2: called with no first track.";
191  std::cout << " empty pointer returned!" << std::endl;
192  return nullptr;
193  }
194 
195  if (_ignoreSecondTrack) {
196  // At the time being if a a first track at the following BX is present,
197  // the carry is thrown
198  // std::vector<DTTSCand*>::iterator p;
199  // for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++) {
200  // if((*p)->isCarry()) return (*p);
201  // }
202  // Fill log word
203  std::vector<DTTSCand *>::iterator p;
204  for (p = _tctrig[1].begin(); p != _tctrig[1].end(); p++)
205  if (!(*p)->isCarry())
206  _logWord2[1 + (*p)->TcPos()] = 'o'; // out of time
207  return nullptr;
208  }
209 
210  // If second tracks are always suppressed skip processing
211  if (config()->TssGhost2Flag() == 3) {
212  // Fill log word
213  std::vector<DTTSCand *>::iterator p;
214  for (p = _tctrig[1].begin(); p != _tctrig[1].end(); p++)
215  _logWord2[1 + (*p)->TcPos()] = 'G';
216  return nullptr;
217  }
218 
219  // If no first tracks at the following BX, do a sort 2
220  DTTSCand *best = getTrack(1);
221  DTTSCand *second = nullptr;
222  std::vector<DTTSCand *>::iterator p;
223  for (p = _tctrig[1].begin(); p != _tctrig[1].end(); p++) {
224  DTTSCand *curr = (*p);
225  // SM sector collector set bits for tss
226  curr->setBitsTss();
227  // std::cout << "Running TSS sort 2: --- curr->dataword() " <<
228  // curr->dataword() << std::endl;
229  if (!curr->isCarry()) {
230  _logWord2[1 + curr->TcPos()] = (curr->isFirst()) ? '1' : '2';
231  if (curr->dataword() == 0x1ff)
232  continue;
233  }
234  // ghost 2 suppression: skip track if suppressed
235  if (config()->TssGhost2Flag() != 0) { // 2nd tracks not always enabled
236 
237  bool inner_or_corr;
238  if (config()->TssGhost2Corr()) {
239  inner_or_corr = curr->isInner() || curr->isCorr();
240 
241  } else {
242  inner_or_corr = curr->isInner();
243  }
244 
245  if (
247  !inner_or_corr && // outer and not corr
248  curr->TcPos() == best->TcPos()) { // same correlator of 1st track
249  if (config()->TssGhost2Flag() == 2 || // do not look to corr bit of 1st
250  ((!best->isCorr()) && config()->TssGhost2Flag() != 4) || // skip if best is not corr
251  ((!best->isCorr()) && best->isInner() &&
252  config()->TssGhost2Flag() == 4)) // skip only if best is inner and not corr
253  {
254  _logWord2[1 + curr->TcPos()] = 'G';
255  // std::cout << " skip sort 2 in TSS" << std::endl;
256  continue; // skip track
257  }
258  }
259  }
260  if (second == nullptr) {
261  second = curr;
262  } else if ((*curr) <= (*second)) {
263  second = curr;
264  }
265  }
266  // if(!second==0) {std::cout << " best sort 2 = " << second->dataword() <<
267  // std::endl;
268  // std::cout << " SM end of TSS sort 2: second = " << std::endl;
269  // second->print(); }
270 
271  return second;
272 }

References _ignoreSecondTrack, _logWord2, _tctrig, begin, config(), gather_cfg::cout, DTTSCand::dataword(), getTrack(), DTTSCand::isCarry(), DTTSCand::isCorr(), DTTSCand::isFirst(), DTTSCand::isInner(), nTracks(), AlCaHLTBitMon_ParallelJobs::p, edm::second(), DTTSCand::setBitsTss(), DTTSCand::TcPos(), DTConfigTSPhi::TssGhost2Corr(), and DTConfigTSPhi::TssGhost2Flag().

Referenced by run().

Member Data Documentation

◆ _config

const DTConfigTSPhi* DTTSS::_config
private

Definition at line 99 of file DTTSS.h.

Referenced by config(), and setConfig().

◆ _ignoreSecondTrack

int DTTSS::_ignoreSecondTrack
private

Definition at line 111 of file DTTSS.h.

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

◆ _logWord1

std::string DTTSS::_logWord1
private

Definition at line 114 of file DTTSS.h.

Referenced by clear(), DTTSS(), logWord(), and sortTSS1().

◆ _logWord2

std::string DTTSS::_logWord2
private

Definition at line 115 of file DTTSS.h.

Referenced by clear(), DTTSS(), logWord(), and sortTSS2().

◆ _n

int DTTSS::_n
private

Definition at line 102 of file DTTSS.h.

Referenced by number(), and run().

◆ _outcand

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

Definition at line 108 of file DTTSS.h.

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

◆ _tctrig

std::vector<DTTSCand *> DTTSS::_tctrig[2]
private
DTTSS::_n
int _n
Definition: DTTSS.h:102
DTTSCand
Definition: DTTSCand.h:35
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DTTSS::nTracoT
unsigned nTracoT(int ifs) const
Return the number of input tracks (first/second)
Definition: DTTSS.cc:280
DTTSS::nFirstT
int nFirstT() const
Return the number of input first tracks.
Definition: DTTSS.h:75
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DTTSCand::isCarry
int isCarry() const
Return the carry bit.
Definition: DTTSCand.h:110
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DTTSCand::isInner
int isInner() const
Return Inner/Outer bit.
Definition: DTTSCand.h:104
DTConfigTSPhi::TssGhost2Corr
bool TssGhost2Corr() const
Correlated ghost 2 suppression option in TSS.
Definition: DTConfigTSPhi.h:120
dqmdumpme.first
first
Definition: dqmdumpme.py:55
DTTSS::_config
const DTConfigTSPhi * _config
Definition: DTTSS.h:99
DTTSCand::setSecondTrack
void setSecondTrack()
Set the first track bit to second track (used for carry)
Definition: DTTSCand.h:63
debug
#define debug
Definition: HDRShower.cc:19
DTTSCand::isCorr
int isCorr() const
Return correlation bit.
Definition: DTTSCand.h:107
DTTSS::_ignoreSecondTrack
int _ignoreSecondTrack
Definition: DTTSS.h:111
DTTSCand::dataword
unsigned dataword() const
Return an uint16 with the content of the data word (for debugging)
Definition: DTTSCand.h:132
DTTSS::config
const DTConfigTSPhi * config() const
Configuration set.
Definition: DTTSS.h:69
DTTSS::getDTTSCand
DTTSCand * getDTTSCand(int ifs, unsigned n) const
Return requested TS candidate.
Definition: DTTSS.cc:289
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTTSS::nSecondT
int nSecondT() const
Return the number of input second tracks.
Definition: DTTSS.h:78
cand
Definition: decayParser.h:34
DTTSS::nTracks
int nTracks() const
Return the number of sorted tracks.
Definition: DTTSS.h:90
DTTSS::sortTSS2
DTTSCand * sortTSS2()
Sort 2.
Definition: DTTSS.cc:187
DTTSCand::setBitsTss
void setBitsTss()
Set the quality bits for DTTSS analysis.
Definition: DTTSCand.cc:78
DTTSS::_outcand
std::vector< DTTSCand * > _outcand
Definition: DTTSS.h:108
DTTSS::sortTSS1
DTTSCand * sortTSS1()
Sort 1.
Definition: DTTSS.cc:115
DTTSCand::tracoTr
const DTTracoTrigData * tracoTr() const
Return associated TRACO trigger.
Definition: DTTSCand.h:84
DTTSCand::TcPos
int TcPos() const
Retrun the TRACO position inside the TSS.
Definition: DTTSCand.h:87
DTTSS::getTrack
DTTSCand * getTrack(int n) const
Return the requested track.
Definition: DTTSS.cc:318
DTConfigTSPhi::TssGhost1Corr
bool TssGhost1Corr() const
Correlated ghost 1 suppression option in TSS.
Definition: DTConfigTSPhi.h:117
DTTSS::_logWord1
std::string _logWord1
Definition: DTTSS.h:114
DTConfigTSPhi::TssGhost2Flag
int TssGhost2Flag() const
Ghost 2 suppression option in TSS.
Definition: DTConfigTSPhi.h:108
DTTSS::clear
void clear()
Clear.
Definition: DTTSS.cc:54
DTTSS::_logWord2
std::string _logWord2
Definition: DTTSS.h:115
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
begin
#define begin
Definition: vmac.h:32
DTTSS::_tctrig
std::vector< DTTSCand * > _tctrig[2]
Definition: DTTSS.h:105
DTTSCand::isFirst
int isFirst() const
Return the first/second track bit.
Definition: DTTSCand.h:99