Skip to content

Commit ddcf4ec

Browse files
authored
Merge pull request cms-sw#33974 from dildick/from-CMSSW_12_0_X_2021-05-28-1100
Prep work for the Run-3 GEM-CSC integrated local trigger (III)
2 parents 11aaf20 + 9b89607 commit ddcf4ec

20 files changed

+990
-315
lines changed

DataFormats/CSCDigi/interface/CSCConstants.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ class CSCConstants {
9494
NUM_HALF_STRIPS_ME32 = NUM_CFEBS_ME32 * NUM_HALF_STRIPS_PER_CFEB, // 160
9595
NUM_HALF_STRIPS_ME41 = NUM_CFEBS_ME41 * NUM_HALF_STRIPS_PER_CFEB, // 160
9696
NUM_HALF_STRIPS_ME42 = NUM_CFEBS_ME42 * NUM_HALF_STRIPS_PER_CFEB, // 160
97+
// useful for the comparator code algorithm
98+
INVALID_HALF_STRIP = 65535
9799
};
98100

99101
// CSCs have 6 layers. The key (reference) layer is the third layer
@@ -103,7 +105,10 @@ class CSCConstants {
103105
enum Pattern_Info {
104106
NUM_ALCT_PATTERNS = 3,
105107
ALCT_PATTERN_WIDTH = 5,
108+
// Run-1 and Run-2 CSC trigger patterns
106109
NUM_CLCT_PATTERNS = 11,
110+
// Run-3 CSC trigger patterns
111+
NUM_CLCT_PATTERNS_RUN3 = 5,
107112
CLCT_PATTERN_WIDTH = 11,
108113
// Max number of wires participating in a pattern
109114
MAX_WIRES_IN_PATTERN = 14,

L1Trigger/CSCTriggerPrimitives/interface/CSCALCTCrossCLCT.h

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,50 @@ class CSCCLCTDigi;
3232

3333
class CSCALCTCrossCLCT {
3434
public:
35-
CSCALCTCrossCLCT(unsigned endcap, unsigned station, unsigned ring, bool isganged, const edm::ParameterSet& luts);
35+
CSCALCTCrossCLCT(
36+
unsigned endcap, unsigned station, unsigned ring, bool ignoreAlctCrossClct, const edm::ParameterSet& conf);
3637

37-
// check if an ALCT can cross a CLCT. Not always the case for ME1/1
38-
bool doesALCTCrossCLCT(const CSCALCTDigi& a, const CSCCLCTDigi& c, bool ignoreAlctCrossClct) const;
38+
/*
39+
Calculate the 4-bit code for the best LCT and second LCT. Each code corresponds
40+
to a unique combination for best and second best. Not each combation is valid.
41+
Valid best LCT codes are: 11, 12, 21, 22, and 0
42+
Valid second LCT codes are: 12, 21, 22, and 0
43+
When a code is nonzero, the first index is the ALCT. The second index is the CLCT.
44+
45+
This feature was originally added by Vadim Khotilovich in LS1 to potentially improve the
46+
quality of the LCTs sent to the track-finder. Generally the track-finders
47+
request all information to be sent. Even if the resulting LCT is potentially
48+
unphysical. Therefore, this function is not used.
49+
*/
50+
void calculateLCTCodes(const CSCALCTDigi& a1,
51+
const CSCCLCTDigi& c1,
52+
const CSCALCTDigi& a2,
53+
const CSCCLCTDigi& c2,
54+
unsigned& bestLCTCode,
55+
unsigned& secondLCTCode) const;
56+
57+
/*
58+
Check if an ALCT can cross a CLCT. Most of the time it can. Only in ME1/1 there are
59+
special cases when they do not. This function is typically not used though, as the
60+
EMTF prefers to receive all stubs. However, there is an option to discard unphysical matches.
61+
*/
62+
bool doesALCTCrossCLCT(const CSCALCTDigi& a, const CSCCLCTDigi& c) const;
3963

4064
private:
65+
// check if a wiregroup cross a halfstrip
4166
bool doesWiregroupCrossHalfStrip(int wg, int keystrip) const;
4267

4368
unsigned endcap_;
4469
unsigned station_;
4570
unsigned ring_;
46-
bool isganged_;
71+
bool gangedME1a_;
72+
bool ignoreAlctCrossClct_;
4773

4874
// strings to paths of LUTs
4975
std::vector<std::string> wgCrossHsME1aFiles_;
5076
std::vector<std::string> wgCrossHsME1aGangedFiles_;
5177
std::vector<std::string> wgCrossHsME1bFiles_;
78+
std::vector<std::string> lctCombinationCodeFiles_;
5279

5380
// unique pointers to the luts
5481
std::unique_ptr<CSCLUTReader> wg_cross_min_hs_ME1a_;
@@ -57,6 +84,8 @@ class CSCALCTCrossCLCT {
5784
std::unique_ptr<CSCLUTReader> wg_cross_max_hs_ME1a_ganged_;
5885
std::unique_ptr<CSCLUTReader> wg_cross_min_hs_ME1b_;
5986
std::unique_ptr<CSCLUTReader> wg_cross_max_hs_ME1b_;
87+
std::unique_ptr<CSCLUTReader> code_to_best_lct_;
88+
std::unique_ptr<CSCLUTReader> code_to_second_lct_;
6089
};
6190

6291
#endif

L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ class CSCAnodeLCTProcessor : public CSCBaseboard {
7474
void run(const std::vector<int> wire[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIREGROUPS]);
7575

7676
/** Returns vector of ALCTs in the read-out time window, if any. */
77-
std::vector<CSCALCTDigi> readoutALCTs(int nMaxALCTs = CSCConstants::MAX_ALCTS_READOUT) const;
77+
std::vector<CSCALCTDigi> readoutALCTs() const;
7878

7979
/** Returns vector of all found ALCTs, if any. */
80-
std::vector<CSCALCTDigi> getALCTs(unsigned nMaxALCTs = CSCConstants::MAX_ALCTS_READOUT) const;
80+
std::vector<CSCALCTDigi> getALCTs() const;
8181

8282
/** read out pre-ALCTs */
8383
std::vector<CSCALCTPreTriggerDigi> preTriggerDigis() const { return thePreTriggerDigis; }
@@ -104,9 +104,6 @@ class CSCAnodeLCTProcessor : public CSCBaseboard {
104104
/** Second best LCTs in this chamber, as found by the processor. */
105105
CSCALCTDigi secondALCT[CSCConstants::MAX_ALCT_TBINS];
106106

107-
/** LCTs in this chamber, as found by the processor. */
108-
std::vector<std::vector<CSCALCTDigi> > ALCTContainer_;
109-
110107
CSCShowerDigi shower_;
111108

112109
/** Access routines to wire digis. */

L1Trigger/CSCTriggerPrimitives/interface/CSCCathodeLCTProcessor.h

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h"
3737
#include "L1Trigger/CSCTriggerPrimitives/interface/CSCLUTReader.h"
3838
#include "L1Trigger/CSCTriggerPrimitives/interface/LCTQualityControl.h"
39+
#include "L1Trigger/CSCTriggerPrimitives/interface/ComparatorCodeLUT.h"
3940

4041
#include <vector>
4142
#include <array>
@@ -99,11 +100,6 @@ class CSCCathodeLCTProcessor : public CSCBaseboard {
99100
/** Second best LCT in this chamber, as found by the processor. */
100101
CSCCLCTDigi secondCLCT[CSCConstants::MAX_CLCT_TBINS];
101102

102-
// unique pointers to the luts
103-
std::array<std::unique_ptr<CSCLUTReader>, 5> lutpos_;
104-
std::array<std::unique_ptr<CSCLUTReader>, 5> lutslope_;
105-
std::array<std::unique_ptr<CSCLUTReader>, 5> lutpatconv_;
106-
107103
/** Access routines to comparator digis. */
108104
bool getDigis(const CSCComparatorDigiCollection* compdc);
109105
void getDigis(const CSCComparatorDigiCollection* compdc, const CSCDetId& id);
@@ -138,9 +134,6 @@ class CSCCathodeLCTProcessor : public CSCBaseboard {
138134
const unsigned int bx_time,
139135
std::map<int, std::map<int, CSCCLCTDigi::ComparatorContainer> >& hits_in_patterns);
140136

141-
// enum used in the comparator code logic
142-
enum CLCT_CompCode { INVALID_HALFSTRIP = 65535 };
143-
144137
void cleanComparatorContainer(CSCCLCTDigi& lct) const;
145138

146139
/* Mark the half-strips around the best half-strip as busy */
@@ -156,17 +149,6 @@ class CSCCathodeLCTProcessor : public CSCBaseboard {
156149
void dumpDigis(
157150
const std::vector<int> strip[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_HALF_STRIPS_RUN2_TRIGGER]) const;
158151

159-
// --------Functions for the comparator code algorith for Run-3 ---------//
160-
//calculates the id based on location of hits
161-
int calculateComparatorCode(const std::array<std::array<int, 3>, 6>& halfStripPattern) const;
162-
163-
// sets the 1/4 and 1/8 strip bits given a floating point position offset
164-
void assignPositionCC(const unsigned offset, std::tuple<int16_t, bool, bool>& returnValue) const;
165-
166-
// runs the CCLUT procedure
167-
void runCCLUT(CSCCLCTDigi& digi) const;
168-
169-
unsigned convertSlopeToRun2Pattern(const unsigned slope) const;
170152
//--------------------------- Member variables -----------------------------
171153

172154
/* best pattern Id for a given half-strip */
@@ -249,6 +231,9 @@ class CSCCathodeLCTProcessor : public CSCBaseboard {
249231

250232
/* quality control */
251233
std::unique_ptr<LCTQualityControl> qualityControl_;
234+
235+
/* comparator-code lookup table algorithm */
236+
std::unique_ptr<ComparatorCodeLUT> cclut_;
252237
};
253238

254239
#endif
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#ifndef L1Trigger_CSCTriggerPrimitives_CSCGEMMatcher
2+
#define L1Trigger_CSCTriggerPrimitives_CSCGEMMatcher
3+
4+
/** \class CSCGEMMatcher
5+
*
6+
* Helper class to check if an ALCT or CLCT matches with a GEMInternalCluster
7+
*
8+
* \author Sven Dildick (Rice University)
9+
*
10+
*/
11+
12+
#include "FWCore/Framework/interface/Frameworkfwd.h"
13+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
14+
15+
#include <string>
16+
#include <vector>
17+
18+
class CSCLUTReader;
19+
class CSCALCTDigi;
20+
class CSCCLCTDigi;
21+
class GEMInternalCluster;
22+
23+
class CSCGEMMatcher {
24+
public:
25+
typedef std::vector<GEMInternalCluster> GEMInternalClusters;
26+
27+
CSCGEMMatcher(int endcap,
28+
unsigned station,
29+
unsigned chamber,
30+
const edm::ParameterSet& tmbParams,
31+
const edm::ParameterSet& luts);
32+
33+
// calculate the bending angle
34+
unsigned calculateGEMCSCBending(const CSCCLCTDigi& clct, const GEMInternalCluster& cluster) const;
35+
36+
// match by BX
37+
38+
// coincidences
39+
void matchingClustersBX(const CSCALCTDigi& alct,
40+
const GEMInternalClusters& clusters,
41+
GEMInternalClusters& selected) const;
42+
43+
// coincidences
44+
void matchingClustersBX(const CSCCLCTDigi& clct,
45+
const GEMInternalClusters& clusters,
46+
GEMInternalClusters& selected) const;
47+
48+
// coincidences or single clusters
49+
void matchingClustersBX(const CSCALCTDigi& alct,
50+
const CSCCLCTDigi& clct,
51+
const GEMInternalClusters& clusters,
52+
GEMInternalClusters& selected) const;
53+
54+
// match by location
55+
56+
// coincidences
57+
void matchingClustersLoc(const CSCALCTDigi& alct,
58+
const GEMInternalClusters& clusters,
59+
GEMInternalClusters& selected) const;
60+
61+
// coincidences
62+
void matchingClustersLoc(const CSCCLCTDigi& clct,
63+
const GEMInternalClusters& clusters,
64+
GEMInternalClusters& selected) const;
65+
66+
// match by 1/2-strip
67+
bool matchedClusterLocHS(const CSCCLCTDigi& clct, const GEMInternalCluster& cluster) const;
68+
69+
// match by 1/8-strip
70+
bool matchedClusterLocES(const CSCCLCTDigi& clct, const GEMInternalCluster& cluster) const;
71+
72+
// coincidences or single clusters
73+
void matchingClustersLoc(const CSCALCTDigi& alct,
74+
const CSCCLCTDigi& clct,
75+
const GEMInternalClusters& clusters,
76+
GEMInternalClusters& selected) const;
77+
78+
// match by BX and location
79+
80+
// coincidences
81+
void matchingClustersBXLoc(const CSCALCTDigi& alct,
82+
const GEMInternalClusters& clusters,
83+
GEMInternalClusters& selected) const;
84+
85+
// coincidences
86+
void matchingClustersBXLoc(const CSCCLCTDigi& clct,
87+
const GEMInternalClusters& clusters,
88+
GEMInternalClusters& selected) const;
89+
90+
// coincidences or single clusters
91+
void matchingClustersBXLoc(const CSCALCTDigi& alct,
92+
const CSCCLCTDigi& clct,
93+
const GEMInternalClusters& clusters,
94+
GEMInternalClusters& selected) const;
95+
96+
// best matching clusters
97+
void bestClusterBXLoc(const CSCALCTDigi& alct, const GEMInternalClusters& clusters, GEMInternalCluster& best) const;
98+
99+
// coincidences
100+
void bestClusterBXLoc(const CSCCLCTDigi& clct, const GEMInternalClusters& clusters, GEMInternalCluster& best) const;
101+
102+
// coincidences or single clusters
103+
void bestClusterBXLoc(const CSCALCTDigi& alct,
104+
const CSCCLCTDigi& clct,
105+
const GEMInternalClusters& clusters,
106+
GEMInternalCluster& best) const;
107+
108+
private:
109+
// calculate slope correction
110+
int CSCGEMSlopeCorrector(const bool isFacing, const bool isL1orCopad, const int cscSlope) const;
111+
112+
unsigned endcap_;
113+
unsigned station_;
114+
unsigned ring_;
115+
unsigned chamber_;
116+
bool isEven_;
117+
118+
unsigned maxDeltaBXALCTGEM_;
119+
unsigned maxDeltaBXCLCTGEM_;
120+
121+
unsigned maxDeltaHsEven_;
122+
unsigned maxDeltaHsOdd_;
123+
unsigned maxDeltaHsEvenME1a_;
124+
unsigned maxDeltaHsOddME1a_;
125+
126+
bool assign_gem_csc_bending_;
127+
128+
// strings to paths of LUTs
129+
std::vector<std::string> gemCscSlopeCorrectionFiles_;
130+
std::vector<std::string> esDiffToSlopeME1aFiles_;
131+
std::vector<std::string> esDiffToSlopeME1bFiles_;
132+
std::vector<std::string> esDiffToSlopeME21Files_;
133+
134+
// unique pointers to the luts
135+
std::unique_ptr<CSCLUTReader> gem_csc_slope_corr_L1_ME11_even_;
136+
std::unique_ptr<CSCLUTReader> gem_csc_slope_corr_L2_ME11_even_;
137+
std::unique_ptr<CSCLUTReader> gem_csc_slope_corr_L1_ME11_odd_;
138+
std::unique_ptr<CSCLUTReader> gem_csc_slope_corr_L2_ME11_odd_;
139+
140+
std::unique_ptr<CSCLUTReader> es_diff_slope_L1_ME1b_even_;
141+
std::unique_ptr<CSCLUTReader> es_diff_slope_L2_ME1b_even_;
142+
143+
std::unique_ptr<CSCLUTReader> es_diff_slope_L1_ME1b_odd_;
144+
std::unique_ptr<CSCLUTReader> es_diff_slope_L2_ME1b_odd_;
145+
146+
std::unique_ptr<CSCLUTReader> es_diff_slope_L1_ME1a_even_;
147+
std::unique_ptr<CSCLUTReader> es_diff_slope_L2_ME1a_even_;
148+
149+
std::unique_ptr<CSCLUTReader> es_diff_slope_L1_ME1a_odd_;
150+
std::unique_ptr<CSCLUTReader> es_diff_slope_L2_ME1a_odd_;
151+
152+
std::unique_ptr<CSCLUTReader> es_diff_slope_L1_ME21_even_;
153+
std::unique_ptr<CSCLUTReader> es_diff_slope_L2_ME21_even_;
154+
155+
std::unique_ptr<CSCLUTReader> es_diff_slope_L1_ME21_odd_;
156+
std::unique_ptr<CSCLUTReader> es_diff_slope_L2_ME21_odd_;
157+
};
158+
159+
#endif

L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ class CSCTriggerPrimitivesBuilder {
6969
const CSCComparatorDigiCollection* compdc,
7070
const GEMPadDigiClusterCollection* gemPadClusters,
7171
CSCALCTDigiCollection& oc_alct,
72-
CSCALCTDigiCollection& oc_alct_all,
7372
CSCCLCTDigiCollection& oc_clct,
74-
CSCCLCTDigiCollection& oc_clct_all,
7573
CSCALCTPreTriggerDigiCollection& oc_alctpretrigger,
7674
CSCCLCTPreTriggerDigiCollection& oc_clctpretrigger,
7775
CSCCLCTPreTriggerCollection& oc_pretrig,
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#ifndef L1Trigger_CSCTriggerPrimitives_ComparatorCodeLUT
2+
#define L1Trigger_CSCTriggerPrimitives_ComparatorCodeLUT
3+
4+
/** \class ComparatorCodeLUT
5+
*
6+
* Helper class to calculate for the comparator code
7+
* algorithm for Phase-2.
8+
*
9+
* \author Sven Dildick (Rice University)
10+
*
11+
*/
12+
13+
#include "FWCore/Framework/interface/Frameworkfwd.h"
14+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
15+
#include "DataFormats/CSCDigi/interface/CSCConstants.h"
16+
#include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h"
17+
#include "L1Trigger/CSCTriggerPrimitives/interface/CSCLUTReader.h"
18+
#include "L1Trigger/CSCTriggerPrimitives/interface/CSCPatternBank.h"
19+
20+
#include <vector>
21+
#include <string>
22+
23+
class CSCCLCTDigi;
24+
25+
class ComparatorCodeLUT {
26+
public:
27+
typedef std::array<std::array<int, 3>, CSCConstants::NUM_LAYERS> pattern;
28+
29+
// constructor
30+
ComparatorCodeLUT(const edm::ParameterSet& conf);
31+
32+
// runs the CCLUT procedure
33+
void run(CSCCLCTDigi& digi, unsigned numCFEBs) const;
34+
35+
private:
36+
//calculates the id based on location of hits
37+
int calculateComparatorCode(const pattern& halfStripPattern) const;
38+
39+
unsigned convertSlopeToRun2Pattern(const unsigned slope) const;
40+
41+
// sets the 1/4 and 1/8 strip bits given a floating point position offset
42+
void assignPositionCC(const unsigned offset, std::tuple<int16_t, bool, bool>& returnValue) const;
43+
44+
// actual LUT used
45+
CSCPatternBank::LCTPatterns clct_pattern_ = {};
46+
47+
std::vector<std::string> positionLUTFiles_;
48+
std::vector<std::string> slopeLUTFiles_;
49+
std::vector<std::string> patternConversionLUTFiles_;
50+
51+
// unique pointers to the luts
52+
std::array<std::unique_ptr<CSCLUTReader>, CSCConstants::NUM_CLCT_PATTERNS_RUN3> lutpos_;
53+
std::array<std::unique_ptr<CSCLUTReader>, CSCConstants::NUM_CLCT_PATTERNS_RUN3> lutslope_;
54+
std::array<std::unique_ptr<CSCLUTReader>, CSCConstants::NUM_CLCT_PATTERNS_RUN3> lutpatconv_;
55+
56+
// verbosity level
57+
unsigned infoV_;
58+
};
59+
60+
#endif

0 commit comments

Comments
 (0)