@@ -169,21 +169,31 @@ void L1TdeCSCTPG::analyze(const edm::Event& e, const edm::EventSetup& c) {
169169 // ignore non-ME1/1 chambers when using B904 test-stand data
170170 if (B904Setup_ and !((*it).first ).isME11 ())
171171 continue ;
172+
173+ // remove the duplicate CLCTs
174+ // these are CLCTs that have the same properties as CLCTs found
175+ // before by the emulator, except for the BX, which is off by +1
176+ std::vector<CSCCLCTDigi> cleanedemul;
172177 for (auto clct = range.first ; clct != range.second ; clct++) {
173- if (clct->isValid ()) {
174- chamberHistos[type][" clct_pattern_emul" ]->Fill (clct->getPattern ());
175- chamberHistos[type][" clct_quality_emul" ]->Fill (clct->getQuality ());
176- chamberHistos[type][" clct_halfstrip_emul" ]->Fill (clct->getKeyStrip ());
177- chamberHistos[type][" clct_bend_emul" ]->Fill (clct->getBend ());
178+ if (not isDuplicateCLCT (*clct, cleanedemul))
179+ cleanedemul.push_back (*clct);
180+ }
181+
182+ for (const auto & clct : cleanedemul) {
183+ if (clct.isValid ()) {
184+ chamberHistos[type][" clct_pattern_emul" ]->Fill (clct.getPattern ());
185+ chamberHistos[type][" clct_quality_emul" ]->Fill (clct.getQuality ());
186+ chamberHistos[type][" clct_halfstrip_emul" ]->Fill (clct.getKeyStrip ());
187+ chamberHistos[type][" clct_bend_emul" ]->Fill (clct.getBend ());
178188 if (isRun3_) {
179- chamberHistos[type][" clct_run3pattern_emul" ]->Fill (clct-> getRun3Pattern ());
180- chamberHistos[type][" clct_quartstrip_emul" ]->Fill (clct-> getKeyStrip (4 ));
181- chamberHistos[type][" clct_eighthstrip_emul" ]->Fill (clct-> getKeyStrip (8 ));
182- chamberHistos[type][" clct_slope_emul" ]->Fill (clct-> getSlope ());
183- chamberHistos[type][" clct_compcode_emul" ]->Fill (clct-> getCompCode ());
189+ chamberHistos[type][" clct_run3pattern_emul" ]->Fill (clct. getRun3Pattern ());
190+ chamberHistos[type][" clct_quartstrip_emul" ]->Fill (clct. getKeyStrip (4 ));
191+ chamberHistos[type][" clct_eighthstrip_emul" ]->Fill (clct. getKeyStrip (8 ));
192+ chamberHistos[type][" clct_slope_emul" ]->Fill (clct. getSlope ());
193+ chamberHistos[type][" clct_compcode_emul" ]->Fill (clct. getCompCode ());
184194 if (B904Setup_) {
185- chamberHistos[type][" clct_quartstripbit_emul" ]->Fill (clct-> getQuartStripBit ());
186- chamberHistos[type][" clct_eighthstripbit_emul" ]->Fill (clct-> getEighthStripBit ());
195+ chamberHistos[type][" clct_quartstripbit_emul" ]->Fill (clct. getQuartStripBit ());
196+ chamberHistos[type][" clct_eighthstripbit_emul" ]->Fill (clct. getEighthStripBit ());
187197 }
188198 }
189199 }
@@ -223,24 +233,86 @@ void L1TdeCSCTPG::analyze(const edm::Event& e, const edm::EventSetup& c) {
223233 // ignore non-ME1/1 chambers when using B904 test-stand data
224234 if (B904Setup_ and !((*it).first ).isME11 ())
225235 continue ;
236+
237+ // remove the duplicate LCTs
238+ // these are LCTs that have the same properties as LCTs found
239+ // before by the emulator, except for the BX, which is off by +1
240+ std::vector<CSCCorrelatedLCTDigi> cleanedemul;
226241 for (auto lct = range.first ; lct != range.second ; lct++) {
227- if (lct->isValid ()) {
228- chamberHistos[type][" lct_pattern_emul" ]->Fill (lct->getPattern ());
229- chamberHistos[type][" lct_quality_emul" ]->Fill (lct->getQuality ());
230- chamberHistos[type][" lct_wiregroup_emul" ]->Fill (lct->getKeyWG ());
231- chamberHistos[type][" lct_halfstrip_emul" ]->Fill (lct->getStrip ());
232- chamberHistos[type][" lct_bend_emul" ]->Fill (lct->getBend ());
242+ if (not isDuplicateLCT (*lct, cleanedemul))
243+ cleanedemul.push_back (*lct);
244+ }
245+
246+ for (const auto & lct : cleanedemul) {
247+ if (lct.isValid ()) {
248+ chamberHistos[type][" lct_pattern_emul" ]->Fill (lct.getPattern ());
249+ chamberHistos[type][" lct_quality_emul" ]->Fill (lct.getQuality ());
250+ chamberHistos[type][" lct_wiregroup_emul" ]->Fill (lct.getKeyWG ());
251+ chamberHistos[type][" lct_halfstrip_emul" ]->Fill (lct.getStrip ());
252+ chamberHistos[type][" lct_bend_emul" ]->Fill (lct.getBend ());
233253 if (isRun3_) {
234- chamberHistos[type][" lct_run3pattern_emul" ]->Fill (lct-> getRun3Pattern ());
235- chamberHistos[type][" lct_slope_emul" ]->Fill (lct-> getSlope ());
236- chamberHistos[type][" lct_quartstrip_emul" ]->Fill (lct-> getStrip (4 ));
237- chamberHistos[type][" lct_eighthstrip_emul" ]->Fill (lct-> getStrip (8 ));
254+ chamberHistos[type][" lct_run3pattern_emul" ]->Fill (lct. getRun3Pattern ());
255+ chamberHistos[type][" lct_slope_emul" ]->Fill (lct. getSlope ());
256+ chamberHistos[type][" lct_quartstrip_emul" ]->Fill (lct. getStrip (4 ));
257+ chamberHistos[type][" lct_eighthstrip_emul" ]->Fill (lct. getStrip (8 ));
238258 if (B904Setup_) {
239- chamberHistos[type][" lct_quartstripbit_emul" ]->Fill (lct-> getQuartStripBit ());
240- chamberHistos[type][" lct_eighthstripbit_emul" ]->Fill (lct-> getEighthStripBit ());
259+ chamberHistos[type][" lct_quartstripbit_emul" ]->Fill (lct. getQuartStripBit ());
260+ chamberHistos[type][" lct_eighthstripbit_emul" ]->Fill (lct. getEighthStripBit ());
241261 }
242262 }
243263 }
244264 }
245265 }
246266}
267+
268+ bool L1TdeCSCTPG::isDuplicateCLCT (const CSCCLCTDigi& clct, const std::vector<CSCCLCTDigi>& container) const {
269+ // if the temporary container is empty, the TP cannot be a duplicate
270+ if (container.empty ())
271+ return false ;
272+ else {
273+ for (const auto & rhs : container) {
274+ if (isCLCTOffByOneBX (clct, rhs))
275+ return true ;
276+ }
277+ return false ;
278+ }
279+ }
280+
281+ bool L1TdeCSCTPG::isDuplicateLCT (const CSCCorrelatedLCTDigi& lct,
282+ const std::vector<CSCCorrelatedLCTDigi>& container) const {
283+ // if the temporary container is empty, the TP cannot be a duplicate
284+ if (container.empty ())
285+ return false ;
286+ else {
287+ for (const auto & rhs : container) {
288+ if (isLCTOffByOneBX (lct, rhs))
289+ return true ;
290+ }
291+ return false ;
292+ }
293+ }
294+
295+ bool L1TdeCSCTPG::isCLCTOffByOneBX (const CSCCLCTDigi& lhs, const CSCCLCTDigi& rhs) const {
296+ // because the comparator code is degenerate (several comparator codes can produce the
297+ // same slope and position), we leave it out of the comparison
298+ bool returnValue = false ;
299+ if (lhs.isValid () == rhs.isValid () && lhs.getQuality () == rhs.getQuality () && lhs.getPattern () == rhs.getPattern () &&
300+ lhs.getRun3Pattern () == rhs.getRun3Pattern () && lhs.getKeyStrip () == rhs.getKeyStrip () &&
301+ lhs.getStripType () == rhs.getStripType () && lhs.getBend () == rhs.getBend () && lhs.getBX () == rhs.getBX () + 1 &&
302+ lhs.getQuartStripBit () == rhs.getQuartStripBit () && lhs.getEighthStripBit () == rhs.getEighthStripBit ()) {
303+ returnValue = true ;
304+ }
305+ return returnValue;
306+ }
307+
308+ bool L1TdeCSCTPG::isLCTOffByOneBX (const CSCCorrelatedLCTDigi& lhs, const CSCCorrelatedLCTDigi& rhs) const {
309+ bool returnValue = false ;
310+ if (lhs.isValid () == rhs.isValid () && lhs.getQuality () == rhs.getQuality () && lhs.getPattern () == rhs.getPattern () &&
311+ lhs.getRun3Pattern () == rhs.getRun3Pattern () && lhs.getStrip () == rhs.getStrip () &&
312+ lhs.getStripType () == rhs.getStripType () && lhs.getBend () == rhs.getBend () && lhs.getBX () == rhs.getBX () + 1 &&
313+ lhs.getQuartStripBit () == rhs.getQuartStripBit () && lhs.getEighthStripBit () == rhs.getEighthStripBit () &&
314+ lhs.getKeyWG () == rhs.getKeyWG ()) {
315+ returnValue = true ;
316+ }
317+ return returnValue;
318+ }
0 commit comments