CMS 3D CMS Logo

DTSC.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: DTSC.cpp
4 //
5 // Description: Implementation of DTSectColl trigger algorithm
6 //
7 //
8 // Author List:
9 // S. Marcellini
10 // Modifications:
11 // 11/11/06 C. Battilana : theta cand added
12 // 12/12/06 C. Battilana : _stat added
13 // 09/01/07 C. Battilana : updated to local conf
14 //
15 //
16 //--------------------------------------------------
17 
18 //-----------------------
19 // This Class's Header --
20 //-----------------------
22 
23 //-------------------------------
24 // Collaborating Class Headers --
25 //-------------------------------
30 
31 //---------------
32 // C++ Headers --
33 //---------------
34 #include <iostream>
35 #include <algorithm>
36 
37 //----------------
38 // Constructors --
39 //----------------
40 
41 DTSC::DTSC(int istat) : _ignoreSecondTrack(0), _stat(istat) {
42  // reserve the appropriate amount of space for vectors
43  // test _incand[0].reserve(DTConfigSectColl::NTSMSC);
44  // test_incand[1].reserve(DTConfigSectColl::NTSMSC);
45  // test _outcand.reserve(2);
46 }
47 
48 //--------------
49 // Destructor --
50 //--------------
52 
53 //--------------
54 // Operations --
55 //--------------
56 
57 void DTSC::clear() {
59 
60  for (int itk = 0; itk <= 1; itk++) {
61  _incand_ph[itk].clear();
62  }
63 
64  _outcand_ph.clear();
65  _cand_th.clear();
66 }
67 
68 //
69 void DTSC::run() {
70  if (config()->debug()) {
71  std::cout << "DTSC::run: Processing DTSectColl: ";
72  std::cout << nFirstTPh() << " first & " << nSecondTPh() << " second Phi tracks ";
73  std::cout << " - " << nCandTh() << " Theta tracks" << std::endl;
74  }
75 
76  if (nFirstTPh() < 1)
77  return; // skip if no first tracks
78  //
79  // SORT 1
80  //
81 
82  // debugging
83  if (config()->debug()) {
84  std::cout << "Vector of first Phi tracks in DTSectColl: " << std::endl;
85  std::vector<DTSectCollPhCand*>::const_iterator p;
86  for (p = _incand_ph[0].begin(); p != _incand_ph[0].end(); p++) {
87  (*p)->print();
88  }
89  }
90  // end debugging
91 
93  if (config()->debug()) {
94  std::cout << "SC: DTSC::run: first Phi track is = " << first << std::endl;
95  }
96  if (first != nullptr) {
97  _outcand_ph.push_back(first);
98  }
99  if (nSecondTPh() < 1)
100  return; // skip if no second tracks
101 
102  //
103  // SORT 2
104  //
105 
106  // debugging
107  if (config()->debug()) {
108  std::vector<DTSectCollPhCand*>::const_iterator p;
109  std::cout << "Vector of second Phi tracks in DTSectColl: " << std::endl;
110  for (p = _incand_ph[1].begin(); p != _incand_ph[1].end(); p++) {
111  (*p)->print();
112  }
113  }
114  // end debugging
115 
117  if (second != nullptr) {
118  _outcand_ph.push_back(second);
119  }
120 }
121 
123  // Do a sort 1
124  DTSectCollPhCand* best = nullptr;
125  DTSectCollPhCand* carry = nullptr;
126  std::vector<DTSectCollPhCand*>::iterator p;
127  for (p = _incand_ph[0].begin(); p != _incand_ph[0].end(); p++) {
128  DTSectCollPhCand* curr = (*p);
129 
130  curr->setBitsSectColl(); // SM sector collector set bits in dataword to make SC sorting
131 
132  // NO Carry in Sector Collector sorting in default
133  if (config()->SCGetCarryFlag(_stat)) { // get carry
134 
135  if (best == nullptr) {
136  best = curr;
137  } else if ((*curr) < (*best)) {
138  carry = best;
139  best = curr;
140  } else if (carry == nullptr) {
141  carry = curr;
142  } else if ((*curr) < (*carry)) {
143  carry = curr;
144  }
145 
146  } else if (config()->SCGetCarryFlag(_stat) == 0) { // no carry (default)
147  if (best == nullptr) {
148  best = curr;
149  } else if ((*curr) < (*best)) {
150  best = curr;
151  }
152  }
153 
154  if (carry != nullptr && config()->SCGetCarryFlag(_stat)) { // reassign carry to sort 2 candidates
155  carry->setSecondTrack(); // change value of 1st/2nd track bit
156  _incand_ph[1].push_back(carry); // add to list of 2nd track
157  }
158  }
159 
160  return best;
161 }
162 
164  // Check if there are second tracks
165 
166  if (nTracksPh() < 1) {
167  std::cout << "DTSC::DTSectCollsort2: called with no first Phi track.";
168  std::cout << " empty pointer returned!" << std::endl;
169  return nullptr;
170  }
171  // If a first track at the following BX is present, ignore second tracks of any kind
172  if (_ignoreSecondTrack) {
173  for (std::vector<DTSectCollPhCand*>::iterator p = _incand_ph[1].begin(); p != _incand_ph[1].end(); p++) {
174  }
175  return nullptr;
176  }
177 
178  // If no first tracks at the following BX, do a sort 2
179  // DTSectCollCand* best=getTrack(1); ! not needed as lons as there is no comparison with best in sort 2
180  DTSectCollPhCand* second = nullptr;
181  std::vector<DTSectCollPhCand*>::iterator p;
182  for (p = _incand_ph[1].begin(); p != _incand_ph[1].end(); p++) {
183  DTSectCollPhCand* curr = (*p);
184  curr->setBitsSectColl(); // SM sector collector set bits in dataword to make SC sorting
185 
186  if (second == nullptr) {
187  second = curr;
188  } else if ((*curr) < (*second)) {
189  second = curr;
190  }
191  }
192 
193  return second;
194 }
195 
196 void DTSC::addPhCand(DTSectCollPhCand* cand) { _incand_ph[(1 - cand->isFirst())].push_back(cand); }
197 
199 
200 unsigned DTSC::nCandPh(int ifs) const {
201  if (ifs < 1 || ifs > 2) {
202  std::cout << "DTSC::nCandPh: wrong track number: " << ifs;
203  std::cout << " 0 returned!" << std::endl;
204  return 0;
205  }
206  return _incand_ph[ifs - 1].size();
207 }
208 
209 unsigned DTSC::nCandTh() const { return _cand_th.size(); }
210 
211 DTSectCollPhCand* DTSC::getDTSectCollPhCand(int ifs, unsigned n) const {
212  if (ifs < 1 || ifs > 2) {
213  std::cout << "DTSC::getDTSectCollPhCand: wrong track number: " << ifs;
214  std::cout << " empty pointer returned!" << std::endl;
215  return nullptr;
216  }
217  if (n < 1 || n > nCandPh(ifs)) {
218  std::cout << "DTSC::getDTSectCollPhCand: requested trigger not present: " << n;
219  std::cout << " empty pointer returned!" << std::endl;
220  return nullptr;
221  }
222 
223  std::vector<DTSectCollPhCand*>::const_iterator p = _incand_ph[ifs - 1].begin() + n - 1;
224  return (*p);
225 }
226 
228  if (n < 1 || n > nCandTh()) {
229  std::cout << "DTSC::getDTSectCollThCand: requested trigger not present: " << n;
230  std::cout << " empty pointer returned!" << std::endl;
231  return nullptr;
232  }
233 
234  std::vector<DTSectCollThCand*>::const_iterator p = _cand_th.begin() + n - 1;
235  return (*p);
236 }
237 
239  int ifs = (cand->isFirst()) ? 0 : 1;
240 
241  _incand_ph[ifs].push_back(cand);
242 }
243 
245  if (n < 1 || n > nTracksPh()) {
246  std::cout << "DTSC::getTrackPh: requested track not present: " << n;
247  std::cout << " empty pointer returned!" << std::endl;
248  return nullptr;
249  }
250 
251  std::vector<DTSectCollPhCand*>::const_iterator p = _outcand_ph.begin() + n - 1;
252 
253  return (*p);
254 }
255 
257  if (n < 1 || n > nTracksTh()) {
258  std::cout << "DTSC::getTrackTh: requested track not present: " << n;
259  std::cout << " empty pointer returned!" << std::endl;
260  return nullptr;
261  }
262 
263  std::vector<DTSectCollThCand*>::const_iterator p = _cand_th.begin() + n - 1;
264 
265  return (*p);
266 }
DTSC::_ignoreSecondTrack
int _ignoreSecondTrack
Definition: DTSC.h:128
DTSC::~DTSC
~DTSC()
Destructor.
Definition: DTSC.cc:51
DTSC::getDTSectCollPhCand
DTSectCollPhCand * getDTSectCollPhCand(int ifs, unsigned n) const
Return requested TSS candidate.
Definition: DTSC.cc:211
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DTSC::addThCand
void addThCand(DTSectCollThCand *cand)
Add a Theta candidate to sect coll.
Definition: DTSC.cc:198
DTSectCollPhCand::setBitsSectColl
void setBitsSectColl()
Set the bits for DTTSM analysis.
Definition: DTSectCollPhCand.cc:69
DTSC::addDTSectCollPhCand
void addDTSectCollPhCand(DTSectCollPhCand *cand)
Add a Sector Collector.
Definition: DTSC.cc:238
DTSectCollPhCand
Definition: DTSectCollPhCand.h:32
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
DTSC::nFirstTPh
int nFirstTPh() const
Return the number of input first tracks.
Definition: DTSC.h:91
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DTSC::run
void run()
Run the Sector Collector algorithm.
Definition: DTSC.cc:69
DTSC::DTSectCollsort1
DTSectCollPhCand * DTSectCollsort1()
Phi Sort 1.
Definition: DTSC.cc:122
dqmdumpme.first
first
Definition: dqmdumpme.py:55
DTSC::clear
void clear()
Clear.
Definition: DTSC.cc:57
DTSC::nSecondTPh
int nSecondTPh() const
Return the number of input second tracks.
Definition: DTSC.h:94
debug
#define debug
Definition: HDRShower.cc:19
DTSC::getDTSectCollThCand
DTSectCollThCand * getDTSectCollThCand(unsigned n) const
Return requested Theta candidate.
Definition: DTSC.cc:227
DTSC::getTrackPh
DTSectCollPhCand * getTrackPh(int n) const
Return the requested Phi track.
Definition: DTSC.cc:244
DTSC::config
const DTConfigSectColl * config() const
Configuration set.
Definition: DTSC.h:82
DTSC::_stat
int _stat
Definition: DTSC.h:131
DTSC::_incand_ph
std::vector< DTSectCollPhCand * > _incand_ph[2]
Definition: DTSC.h:119
DTSC::DTSectCollsort2
DTSectCollPhCand * DTSectCollsort2()
Phi Sort 2.
Definition: DTSC.cc:163
DTSectColl.h
cand
Definition: decayParser.h:32
DTSectCollThCand
Definition: DTSectCollThCand.h:31
DTSC::_cand_th
std::vector< DTSectCollThCand * > _cand_th
Definition: DTSC.h:125
DTSectCollPhCand::setSecondTrack
void setSecondTrack()
Set the first track bit to second track (used for carry)
Definition: DTSectCollPhCand.h:61
DTSC::DTSC
DTSC(int istat)
Constructor.
Definition: DTSC.cc:41
DTSC::nTracksPh
int nTracksPh() const
Return the number of output Phi tracks.
Definition: DTSC.h:103
DTSC::getTrackTh
DTSectCollThCand * getTrackTh(int n) const
Return the requested Theta track.
Definition: DTSC.cc:256
DTSC::nTracksTh
int nTracksTh() const
Return the number of output Theta tracks.
Definition: DTSC.h:106
DTSC::nCandTh
unsigned nCandTh() const
Return the number of Theta input tracks.
Definition: DTSC.cc:209
DTSC::_outcand_ph
std::vector< DTSectCollPhCand * > _outcand_ph
Definition: DTSC.h:122
DTSectCollThCand.h
DTSectCollPhCand.h
DTSC::nCandPh
unsigned nCandPh(int ifs) const
Return the number of Phi input tracks (first/second)
Definition: DTSC.cc:200
DTSC.h
DTConfigSectColl.h
DTSC::addPhCand
void addPhCand(DTSectCollPhCand *cand)
Add a TSM candidate to the Sect Coll, ifs is first/second track flag.
Definition: DTSC.cc:196