Skip to content

Commit

Permalink
Merge pull request #35632 from eyigitba/EMTF_TMB_OTMB_CCLUT_october21
Browse files Browse the repository at this point in the history
EMTF emulator and CSC TP producer changes for the new CCLUT implementation
  • Loading branch information
cmsbuild authored Oct 26, 2021
2 parents ec62bb6 + b3fda88 commit 25b6321
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 25 deletions.
7 changes: 6 additions & 1 deletion L1Trigger/CSCTriggerPrimitives/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# L1Trigger/CSCTriggerPrimitives Documentation

Please refer to https://gitlab.cern.ch/tdr/notes/DN-21-019/blob/master/temp/DN-21-019_temp.pdf
Please refer to this important documentation:
* GEM, CSC, GEM-CSC, and HMT dataformat https://gitlab.cern.ch/tdr/notes/DN-20-016/blob/master/temp/DN-20-016_temp.pdf
* GEM, CSC, GEM-CSC, and HMT trigger algorithm https://gitlab.cern.ch/tdr/notes/DN-21-019/blob/master/temp/DN-21-019_temp.pdf
* CCLUT algorithm https://gitlab.cern.ch/tdr/notes/DN-19-059/blob/master/temp/DN-19-059_temp.pdf
* Hadronic shower trigger algorithm: https://gitlab.cern.ch/tdr/notes/DN-20-033/blob/master/temp/DN-20-033_temp.pdf
* Note describing the CSC firmware and CSC DAQ format https://github.com/csc-fw/otmb_fw_docs
7 changes: 7 additions & 0 deletions L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class CSCBaseboard {
bool isME21_;
bool isME31_;
bool isME41_;
bool isME12_;
bool isME22_;
bool isME32_;
bool isME42_;
bool isME13_;

// CSCDetId for this chamber
CSCDetId cscId_;
Expand Down Expand Up @@ -104,5 +109,7 @@ class CSCBaseboard {
bool runME41Up_;

bool runCCLUT_;
bool runCCLUT_TMB_;
bool runCCLUT_OTMB_;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ class CSCTriggerPrimitivesProducer : public edm::one::EDProducer<> {
// write out showrs
bool keepShowers_;

// switch to enable the integrated local triggers in ME11 and ME21
bool runCCLUT_;
// switches to enable the Run-3 pattern finding
bool runCCLUT_; // 'OR' of the two options below
bool runCCLUT_TMB_; // ME1/2, ME1/3, ME2/2, ME3/2, ME4/2
bool runCCLUT_OTMB_; // ME1/1, ME2/1, ME3/1, ME4/1

bool runILT_; // // 'OR' of the two options below
bool runME11ILT_;
bool runME21ILT_;
};
Expand All @@ -126,13 +130,17 @@ CSCTriggerPrimitivesProducer::CSCTriggerPrimitivesProducer(const edm::ParameterS

// check whether you need to run the integrated local triggers
const edm::ParameterSet commonParam(conf.getParameter<edm::ParameterSet>("commonParam"));
runCCLUT_ = commonParam.getParameter<bool>("runCCLUT");
runCCLUT_TMB_ = commonParam.getParameter<bool>("runCCLUT_TMB");
runCCLUT_OTMB_ = commonParam.getParameter<bool>("runCCLUT_OTMB");
runCCLUT_ = runCCLUT_TMB_ or runCCLUT_OTMB_;

runME11ILT_ = commonParam.getParameter<bool>("runME11ILT");
runME21ILT_ = commonParam.getParameter<bool>("runME21ILT");
runILT_ = runME11ILT_ or runME21ILT_;

wire_token_ = consumes<CSCWireDigiCollection>(wireDigiProducer_);
comp_token_ = consumes<CSCComparatorDigiCollection>(compDigiProducer_);
if (runME11ILT_ or runME21ILT_)
if (runILT_)
gem_pad_cluster_token_ = consumes<GEMPadDigiClusterCollection>(gemPadDigiClusterProducer_);
cscToken_ = esConsumes<CSCGeometry, MuonGeometryRecord>();
gemToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
Expand Down Expand Up @@ -162,7 +170,7 @@ CSCTriggerPrimitivesProducer::CSCTriggerPrimitivesProducer(const edm::ParameterS
produces<CSCShowerDigiCollection>();
produces<CSCShowerDigiCollection>("Anode");
}
if (runME11ILT_ or runME21ILT_) {
if (runILT_) {
produces<GEMCoPadDigiCollection>();
}
// temporarily switch to a "one" module with a CSCTriggerPrimitivesBuilder data member
Expand All @@ -177,7 +185,7 @@ void CSCTriggerPrimitivesProducer::produce(edm::Event& ev, const edm::EventSetup

// get the gem geometry if it's there
edm::ESHandle<GEMGeometry> h_gem = setup.getHandle(gemToken_);
if (runME11ILT_ or runME21ILT_) {
if (runILT_) {
if (h_gem.isValid()) {
builder_->setGEMGeometry(&*h_gem);
} else {
Expand Down Expand Up @@ -241,7 +249,7 @@ void CSCTriggerPrimitivesProducer::produce(edm::Event& ev, const edm::EventSetup

// input GEM pad cluster collection for upgrade scenarios
const GEMPadDigiClusterCollection* gemPadClusters = nullptr;
if (runME11ILT_ or runME21ILT_) {
if (runILT_) {
if (!gemPadDigiClusterProducer_.label().empty()) {
edm::Handle<GEMPadDigiClusterCollection> gemPadDigiClusters;
ev.getByToken(gem_pad_cluster_token_, gemPadDigiClusters);
Expand Down Expand Up @@ -313,7 +321,7 @@ void CSCTriggerPrimitivesProducer::produce(edm::Event& ev, const edm::EventSetup
}
// only put GEM copad collections in the event when the
// integrated local triggers are running
if (runME11ILT_ or runME21ILT_)
if (runILT_)
ev.put(std::move(oc_gemcopad));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@

# comparator-code algorithm to improve
# CLCT position and bending resolution
runCCLUT = cms.bool(False),
# CCLUT for TMB is NOT planned for startup Run-3
runCCLUT_TMB = cms.bool(False),
# CCLUT for OTMB is planned for startup Run-3
runCCLUT_OTMB = cms.bool(False),

## Phase-2 version is not needed for Run-3
enableAlctPhase2 = cms.bool(False)
Expand Down
14 changes: 12 additions & 2 deletions L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ CSCBaseboard::CSCBaseboard(unsigned endcap,
isME21_ = (theStation == 2 && theRing == 1);
isME31_ = (theStation == 3 && theRing == 1);
isME41_ = (theStation == 4 && theRing == 1);

isME12_ = (theStation == 1 && theRing == 2);
isME22_ = (theStation == 2 && theRing == 2);
isME32_ = (theStation == 3 && theRing == 2);
isME42_ = (theStation == 4 && theRing == 2);
isME13_ = (theStation == 1 && theRing == 3);

const bool hasTMB(isME12_ or isME22_ or isME32_ or isME42_ or isME13_);
const bool hasOTMB(isME11_ or isME21_ or isME31_ or isME41_);
cscId_ = CSCDetId(theEndcap, theStation, theRing, theChamber, 0);

commonParams_ = conf.getParameter<edm::ParameterSet>("commonParam");
Expand All @@ -41,7 +48,10 @@ CSCBaseboard::CSCBaseboard(unsigned endcap,
runME11ILT_ = commonParams_.getParameter<bool>("runME11ILT");
runME21ILT_ = commonParams_.getParameter<bool>("runME21ILT");

runCCLUT_ = commonParams_.getParameter<bool>("runCCLUT");
runCCLUT_TMB_ = commonParams_.getParameter<bool>("runCCLUT_TMB");
runCCLUT_OTMB_ = commonParams_.getParameter<bool>("runCCLUT_OTMB");
// check if CCLUT should be on in this chamber
runCCLUT_ = (hasTMB and runCCLUT_TMB_) or (hasOTMB and runCCLUT_OTMB_);

// general case
tmbParams_ = conf.getParameter<edm::ParameterSet>("tmbPhase1");
Expand Down
5 changes: 5 additions & 0 deletions L1Trigger/CSCTriggerPrimitives/src/GEMClusterProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ void GEMClusterProcessor::run(const GEMPadDigiClusterCollection* in_clusters) {
// Step 1: clear the GEMInternalCluster vector
clear();

if (in_clusters == nullptr) {
edm::LogWarning("GEMClusterProcessor") << "Attempt to run without valid in_clusters pointer.";
return;
}

// Step 2: put coincidence clusters in GEMInternalCluster vector
addCoincidenceClusters(in_clusters);

Expand Down
6 changes: 4 additions & 2 deletions L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class PrimitiveConversion {
bool useNewZones,
bool fixME11Edges,
bool bugME11Dupes,
bool useRun3CCLUT);
bool useRun3CCLUT_OTMB,
bool useRun3CCLUT_TMB);

void process(const std::map<int, TriggerPrimitiveCollection>& selected_prim_map, EMTFHitCollection& conv_hits) const;

Expand Down Expand Up @@ -105,7 +106,8 @@ class PrimitiveConversion {
bool duplicateTheta_, fixZonePhi_, useNewZones_, fixME11Edges_;
bool bugME11Dupes_;
// Run 3 CCLUT algorithm
bool useRun3CCLUT_;
bool useRun3CCLUT_OTMB_;
bool useRun3CCLUT_TMB_;
};

#endif
3 changes: 2 additions & 1 deletion L1Trigger/L1TMuonEndCap/interface/VersionControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class VersionControl {
// For primitive conversion
std::vector<int> zoneBoundaries_;
int zoneOverlap_;
bool includeNeighbor_, duplicateTheta_, fixZonePhi_, useNewZones_, fixME11Edges_, useRun3CCLUT_;
bool includeNeighbor_, duplicateTheta_, fixZonePhi_, useNewZones_, fixME11Edges_, useRun3CCLUT_OTMB_,
useRun3CCLUT_TMB_;

// For pattern recognition
std::vector<std::string> pattDefinitions_, symPattDefinitions_;
Expand Down
6 changes: 3 additions & 3 deletions L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
Era = cms.string('Run2_2018'),

# New Run 3 CSC TPs using CCLUT algorithm
UseRun3CCLUT = cms.bool(False),
UseRun3CCLUT_OTMB = cms.bool(False),
UseRun3CCLUT_TMB = cms.bool(False),

# Input collections
# Three options for CSCInput
Expand Down Expand Up @@ -163,5 +164,4 @@

## Era: Run3_2021
from Configuration.Eras.Modifier_stage2L1Trigger_2021_cff import stage2L1Trigger_2021
stage2L1Trigger_2021.toModify(simEmtfDigis, RPCEnable = cms.bool(True), UseRun3CCLUT = cms.bool(False), Era = cms.string('Run3_2021'))

stage2L1Trigger_2021.toModify(simEmtfDigis, RPCEnable = cms.bool(True), UseRun3CCLUT_OTMB = cms.bool(False), Era = cms.string('Run3_2021'))
42 changes: 37 additions & 5 deletions L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ void PrimitiveConversion::configure(const GeometryTranslator* tp_geom,
bool useNewZones,
bool fixME11Edges,
bool bugME11Dupes,
bool useRun3CCLUT) {
bool useRun3CCLUT_OTMB,
bool useRun3CCLUT_TMB) {
emtf_assert(tp_geom != nullptr);
emtf_assert(pc_lut != nullptr);

Expand All @@ -47,7 +48,8 @@ void PrimitiveConversion::configure(const GeometryTranslator* tp_geom,
bugME11Dupes_ = bugME11Dupes;

// Run 3 CCLUT algorithm
useRun3CCLUT_ = useRun3CCLUT;
useRun3CCLUT_OTMB_ = useRun3CCLUT_OTMB;
useRun3CCLUT_TMB_ = useRun3CCLUT_TMB;
}

void PrimitiveConversion::process(const std::map<int, TriggerPrimitiveCollection>& selected_prim_map,
Expand Down Expand Up @@ -127,6 +129,29 @@ void PrimitiveConversion::convert_csc(int pc_sector,
}
}

// Calculate Pattern
unsigned pattern = tp_data.pattern;
const auto& detid(conv_hit.CreateCSCDetId());
const bool isOTMB(detid.isME11() or detid.isME21() or detid.isME31() or detid.isME41());
const bool isTMB((detid.isME12() or detid.isME22() or detid.isME32() or detid.isME42()) or (detid.isME13()));

// check if CCLUT is on for this CSC TP
const bool useRun3CCLUT((useRun3CCLUT_OTMB_ and isOTMB) or (useRun3CCLUT_TMB_ and isTMB));
if (useRun3CCLUT) {
// convert slope to Run-2 pattern for CSC TPs coming from MEX/1 chambers
// where the CCLUT algorithm is enabled
const unsigned slopeList[32] = {10, 10, 10, 8, 8, 8, 6, 6, 6, 4, 4, 4, 2, 2, 2, 2,
10, 10, 10, 9, 9, 9, 7, 7, 7, 5, 5, 5, 3, 3, 3, 3};

// this LUT follows the same convention as in CSCPatternBank.cc
unsigned slope_and_sign(tp_data.slope);
if (tp_data.bend == 0) {
slope_and_sign += 16;
}
unsigned run2_converted_PID = slopeList[slope_and_sign];
pattern = run2_converted_PID;
}

// Set properties
conv_hit.SetCSCDetId(tp_detId);

Expand Down Expand Up @@ -157,7 +182,7 @@ void PrimitiveConversion::convert_csc(int pc_sector,
//conv_hit.set_strip_hi ( tp_data.strip_hi );
conv_hit.set_wire(tp_data.keywire);
conv_hit.set_quality(tp_data.quality);
conv_hit.set_pattern(tp_data.pattern);
conv_hit.set_pattern(pattern);
conv_hit.set_bend(tp_data.bend);
conv_hit.set_time(0.); // No fine resolution timing
conv_hit.set_alct_quality(tp_data.alct_quality);
Expand Down Expand Up @@ -295,16 +320,23 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const {
if (bugStrip0BeforeFW48200 == false && fw_strip == 0 && clct_pat_corr_sign == -1)
clct_pat_corr = 0;

// check if the CCLUT algorithm is on in this chamber
const auto& detid(conv_hit.CreateCSCDetId());
const bool isOTMB(detid.isME11() or detid.isME21() or detid.isME31() or detid.isME41());
const bool isTMB((detid.isME12() or detid.isME22() or detid.isME32() or detid.isME42()) or (detid.isME13()));

const bool useRun3CCLUT((useRun3CCLUT_OTMB_ and isOTMB) or (useRun3CCLUT_TMB_ and isTMB));

if (is_10degree) {
eighth_strip = fw_strip << 2; // full precision, uses only 2 bits of pattern correction
if (useRun3CCLUT_) {
if (useRun3CCLUT) {
eighth_strip += (conv_hit.Strip_quart_bit() << 1 | conv_hit.Strip_eighth_bit() << 0); // Run 3 CCLUT variables
} else {
eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 1);
}
} else {
eighth_strip = fw_strip << 3; // multiply by 2, uses all 3 bits of pattern correction
if (useRun3CCLUT_) {
if (useRun3CCLUT) {
eighth_strip += (conv_hit.Strip_quart_bit() << 2 | conv_hit.Strip_eighth_bit() << 1); // Run 3 CCLUT variables
} else {
eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 0);
Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ void SectorProcessor::process_single_bx(int bx,
cfg.useNewZones_,
cfg.fixME11Edges_,
cfg.bugME11Dupes_,
cfg.useRun3CCLUT_);
cfg.useRun3CCLUT_OTMB_,
cfg.useRun3CCLUT_TMB_);

PatternRecognition patt_recog;
patt_recog.configure(verbose_,
Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/L1TMuonEndCap/src/VersionControl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ VersionControl::VersionControl(const edm::ParameterSet& iConfig) : config_(iConf
useO2O_ = iConfig.getParameter<bool>("FWConfig");
era_ = iConfig.getParameter<std::string>("Era");
// Run 3 CCLUT
useRun3CCLUT_ = iConfig.getParameter<bool>("UseRun3CCLUT");
useRun3CCLUT_OTMB_ = iConfig.getParameter<bool>("UseRun3CCLUT_OTMB");
useRun3CCLUT_TMB_ = iConfig.getParameter<bool>("UseRun3CCLUT_TMB");

useDT_ = iConfig.getParameter<bool>("DTEnable");
useCSC_ = iConfig.getParameter<bool>("CSCEnable");
Expand Down

0 comments on commit 25b6321

Please sign in to comment.