CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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...
 
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 (DTConfigTSPhi *config)
 Set configuration. More...
 
DTTSCandsortTSM1 (int bkmod)
 Sort 1. More...
 
DTTSCandsortTSM2 (int bkmod)
 Sort 2. More...
 
 ~DTTSM ()
 Destructor. More...
 

Private Attributes

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

Detailed Description

Implementation of TSM trigger algorithm

Date:
2008/09/05 15:59:57
Revision:
1.3
Author
C. Grandi, D. Bonacorsi, S. Marcellini

Definition at line 40 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 }
static const int NTSSTSM
Constant: maximum number of TSS in input to the TSM.
Definition: DTConfigTSPhi.h:42
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:110
int _ignoreSecondTrack
Definition: DTTSM.h:116
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:113
int _n
Definition: DTTSM.h:107
DTTSM::~DTTSM ( )

Destructor.

Definition at line 49 of file DTTSM.cc.

References clear().

49  {
50  clear();
51 }
void clear()
Clear.
Definition: DTTSM.cc:59

Member Function Documentation

void DTTSM::addCand ( DTTSCand cand)

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

Definition at line 276 of file DTTSM.cc.

References _incand, and DTTSCand::isFirst().

Referenced by DTTSPhi::runTSPhi().

276  {
277  // NEW DESIGN: DTTSM is not configurable!
278  // cand->resetCarry(); // reset carry information
279  // cand->setBitsTsm(); // set quality bits for DTTSM sorting
280  _incand[(1-cand->isFirst())].push_back(cand);
281 }
int isFirst() const
Return the first/second track bit.
Definition: DTTSCand.h:100
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:110
void DTTSM::clear ( void  )

Clear.

Definition at line 59 of file DTTSM.cc.

References _ignoreSecondTrack, _incand, and _outcand.

Referenced by ~DTTSM().

59  {
61  for(int itk=0;itk<=1;itk++){
62  // content of _incand is deleted by DTTSPhi
63  _incand[itk].clear();
64  }
65  // content of _outcand is deleted by DTTSPhi
66  _outcand.clear();
67 }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:110
int _ignoreSecondTrack
Definition: DTTSM.h:116
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:113
DTConfigTSPhi* DTTSM::config ( void  ) const
inline

Configuration set.

Definition at line 77 of file DTTSM.h.

References _config.

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

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

Return requested TS candidate.

Definition at line 295 of file DTTSM.cc.

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

Referenced by getTracoT().

295  {
296  if(ifs<1||ifs>2){
297  std::cout << "DTTSM::getDTTSCand: wrong track number: " << ifs;
298  std::cout << " empty pointer returned!" << std::endl;
299  return 0;
300  }
301  if(n<1 || n>nCand(ifs)) {
302  std::cout << "DTTSM::getDTTSCand: requested trigger not present: " << n;
303  std::cout << " empty pointer returned!" << std::endl;
304  return 0;
305  }
306  std::vector<DTTSCand*>::const_iterator p = _incand[ifs-1].begin()+n-1;
307  return (*p);
308 }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:110
unsigned nCand(int ifs) const
Return the number of input tracks (first/second)
Definition: DTTSM.cc:284
tuple cout
Definition: gather_cfg.py:121
DTTSCand * DTTSM::getTrack ( int  n) const

Return the requested track.

Definition at line 326 of file DTTSM.cc.

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

Referenced by sortTSM2().

326  {
327 
328  if(n<1 || n>nTracks()) {
329  std::cout << "DTTSM::getTrack: requested track not present: " << n;
330  std::cout << " empty pointer returned!" << std::endl;
331  return 0;
332  }
333  std::vector<DTTSCand*>::const_iterator p = _outcand.begin()+n-1;
334  return (*p);
335 }
int nTracks() const
Return the number of sorted tracks.
Definition: DTTSM.h:95
std::vector< DTTSCand * > _outcand
Definition: DTTSM.h:113
tuple cout
Definition: gather_cfg.py:121
const DTTracoTrigData * DTTSM::getTracoT ( int  ifs,
unsigned  n 
) const

Return requested TRACO trigger.

Definition at line 311 of file DTTSM.cc.

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

311  {
312  if(ifs<1||ifs>2){
313  std::cout << "DTTSM::getTracoT: wrong track number: " << ifs;
314  std::cout << " empty pointer returned!" << std::endl;
315  return 0;
316  }
317  if(n<1 || n>nCand(ifs)) {
318  std::cout << "DTTSM::getTracoT: requested trigger not present: " << n;
319  std::cout << " empty pointer returned!" << std::endl;
320  return 0;
321  }
322  return getDTTSCand(ifs, n)->tracoTr();
323 }
DTTSCand * getDTTSCand(int ifs, unsigned n) const
Return requested TS candidate.
Definition: DTTSM.cc:295
unsigned nCand(int ifs) const
Return the number of input tracks (first/second)
Definition: DTTSM.cc:284
const DTTracoTrigData * tracoTr() const
Return associated TRACO trigger.
Definition: DTTSCand.h:85
tuple cout
Definition: gather_cfg.py:121
void DTTSM::ignoreSecondTrack ( )
inline

Set a flag to skip sort2.

Definition at line 61 of file DTTSM.h.

References _ignoreSecondTrack.

Referenced by DTTSPhi::ignoreSecondTrack().

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

Return the number of input tracks (first/second)

Definition at line 284 of file DTTSM.cc.

References _incand, and gather_cfg::cout.

Referenced by getDTTSCand(), and getTracoT().

284  {
285  if(ifs<1||ifs>2){
286  std::cout << "DTTSM::nCand: wrong track number: " << ifs;
287  std::cout << " 0 returned!" << std::endl;
288  return 0;
289  }
290 
291  return _incand[ifs-1].size();
292 }
std::vector< DTTSCand * > _incand[2]
Definition: DTTSM.h:110
tuple cout
Definition: gather_cfg.py:121
int DTTSM::nFirstT ( ) const
inline

Return the number of input first tracks.

Definition at line 83 of file DTTSM.h.

References _incand.

Referenced by run().

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

Return the number of input second tracks.

Definition at line 86 of file DTTSM.h.

References _incand.

Referenced by run().

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

Return the number of sorted tracks.

Definition at line 95 of file DTTSM.h.

References _outcand.

Referenced by getTrack(), and sortTSM2().

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

Return identifier.

Definition at line 52 of file DTTSM.h.

References _n.

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

Run the TSM algorithm.

Definition at line 70 of file DTTSM.cc.

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

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

Set configuration.

Definition at line 55 of file DTTSM.h.

References _config, and config().

55 { _config=config; }
DTConfigTSPhi * _config
Definition: DTTSM.h:102
DTConfigTSPhi * config() const
Configuration set.
Definition: DTTSM.h:77
DTTSCand * DTTSM::sortTSM1 ( int  bkmod)

Sort 1.

Definition at line 122 of file DTTSM.cc.

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

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

Sort 2.

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

Definition at line 195 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 run().

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

Member Data Documentation

DTConfigTSPhi* DTTSM::_config
private

Definition at line 102 of file DTTSM.h.

Referenced by config(), and setConfig().

int DTTSM::_ignoreSecondTrack
private

Definition at line 116 of file DTTSM.h.

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

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

Definition at line 110 of file DTTSM.h.

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

int DTTSM::_n
private

Definition at line 107 of file DTTSM.h.

Referenced by number().

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

Definition at line 113 of file DTTSM.h.

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