Skip to content

Commit

Permalink
Merge pull request #34435 from dildick/from-CMSSW_12_0_X_2021-07-09-0…
Browse files Browse the repository at this point in the history
…800-test-packing-unpacking

Re-enable suppression of CSC digis without matching pretriggers and triggers
  • Loading branch information
cmsbuild committed Jul 28, 2021
2 parents a746a5b + 1b7d0a7 commit 2398d9b
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 66 deletions.
2 changes: 1 addition & 1 deletion DQM/CSCMonitorModule/test/dqm_repacker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
)

process.cscpacker.usePreTriggers = cms.untracked.bool(False)
process.cscpacker.useFormatVersion = cms.untracked.uint32(2013)
process.cscpacker.formatVersion = cms.untracked.uint32(2013)

#----------------------------
# Event Source
Expand Down
19 changes: 8 additions & 11 deletions EventFilter/CSCRawToDigi/interface/CSCDigiToRaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ class CSCDigiToRaw {
const GEMPadDigiClusterCollection* padDigiClusters,
FEDRawDataCollection& fed_buffers,
const CSCChamberMap* theMapping,
const edm::EventID& eid,
uint16_t theFormatVersion = 2005,
bool packEverything = false) const;
const edm::EventID& eid) const;

private:
struct FindEventDataInfo {
Expand All @@ -59,17 +57,12 @@ class CSCDigiToRaw {
void add(const CSCStripDigiCollection& stripDigis,
const CSCCLCTPreTriggerCollection* preTriggers,
const CSCCLCTPreTriggerDigiCollection* preTriggerDigis,
FindEventDataInfo&,
bool packEverything) const;
void add(const CSCWireDigiCollection& wireDigis,
const CSCALCTDigiCollection& alctDigis,
FindEventDataInfo&,
bool packEverything) const;
FindEventDataInfo&) const;
void add(const CSCWireDigiCollection& wireDigis, const CSCALCTDigiCollection& alctDigis, FindEventDataInfo&) const;
// may require CLCTs to read out comparators. Doesn't add CLCTs.
void add(const CSCComparatorDigiCollection& comparatorDigis,
const CSCCLCTDigiCollection& clctDigis,
FindEventDataInfo&,
bool packEverything) const;
FindEventDataInfo&) const;
void add(const CSCALCTDigiCollection& alctDigis, FindEventDataInfo&) const;
void add(const CSCCLCTDigiCollection& clctDigis, FindEventDataInfo&) const;
void add(const CSCCorrelatedLCTDigiCollection& corrLCTDigis, FindEventDataInfo&) const;
Expand All @@ -84,6 +77,10 @@ class CSCDigiToRaw {
const int clctWindowMax_;
const int preTriggerWindowMin_;
const int preTriggerWindowMax_;

uint16_t formatVersion_;
bool packEverything_;
bool usePreTriggers_;
};

#endif
19 changes: 6 additions & 13 deletions EventFilter/CSCRawToDigi/plugins/CSCDigiToRawModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ class CSCDigiToRawModule : public edm::global::EDProducer<> {
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
unsigned int theFormatVersion; // Select which version of data format to use Pre-LS1: 2005, Post-LS1: 2013
bool usePreTriggers; // Select if to use Pre-Triigers CLCT digis
bool packEverything_; // bypass all cuts and (pre)trigger requirements
bool usePreTriggers_; // Select if to use Pre-Triggers CLCT digis
bool useGEMs_;
bool useCSCShowers_;

Expand All @@ -75,17 +73,14 @@ class CSCDigiToRawModule : public edm::global::EDProducer<> {
};

CSCDigiToRawModule::CSCDigiToRawModule(const edm::ParameterSet& pset) : packer_(std::make_unique<CSCDigiToRaw>(pset)) {
theFormatVersion = pset.getParameter<unsigned int>("useFormatVersion"); // pre-LS1 - '2005'. post-LS1 - '2013'
usePreTriggers = pset.getParameter<bool>("usePreTriggers"); // disable checking CLCT PreTriggers digis
packEverything_ = pset.getParameter<bool>("packEverything"); // don't check for consistency with trig primitives
// overrides usePreTriggers
usePreTriggers_ = pset.getParameter<bool>("usePreTriggers"); // disable checking CLCT PreTriggers digis

useGEMs_ = pset.getParameter<bool>("useGEMs");
useCSCShowers_ = pset.getParameter<bool>("useCSCShowers");
wd_token = consumes<CSCWireDigiCollection>(pset.getParameter<edm::InputTag>("wireDigiTag"));
sd_token = consumes<CSCStripDigiCollection>(pset.getParameter<edm::InputTag>("stripDigiTag"));
cd_token = consumes<CSCComparatorDigiCollection>(pset.getParameter<edm::InputTag>("comparatorDigiTag"));
if (usePreTriggers) {
if (usePreTriggers_) {
pr_token = consumes<CSCCLCTPreTriggerCollection>(pset.getParameter<edm::InputTag>("preTriggerTag"));
prdigi_token = consumes<CSCCLCTPreTriggerDigiCollection>(pset.getParameter<edm::InputTag>("preTriggerDigiTag"));
}
Expand All @@ -105,7 +100,7 @@ CSCDigiToRawModule::CSCDigiToRawModule(const edm::ParameterSet& pset) : packer_(
void CSCDigiToRawModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;

desc.add<unsigned int>("useFormatVersion", 2005)
desc.add<unsigned int>("formatVersion", 2005)
->setComment("Set to 2005 for pre-LS1 CSC data format, 2013 - new post-LS1 CSC data format");
desc.add<bool>("usePreTriggers", true)->setComment("Set to false if CSCCLCTPreTrigger digis are not available");
desc.add<bool>("packEverything", false)
Expand Down Expand Up @@ -160,7 +155,7 @@ void CSCDigiToRawModule::produce(edm::StreamID, edm::Event& e, const edm::EventS
// packing with pre-triggers
CSCCLCTPreTriggerCollection const* preTriggersPtr = nullptr;
CSCCLCTPreTriggerDigiCollection const* preTriggerDigisPtr = nullptr;
if (usePreTriggers) {
if (usePreTriggers_) {
preTriggersPtr = &e.get(pr_token);
preTriggerDigisPtr = &e.get(prdigi_token);
}
Expand Down Expand Up @@ -192,9 +187,7 @@ void CSCDigiToRawModule::produce(edm::StreamID, edm::Event& e, const edm::EventS
padDigiClustersPtr,
fed_buffers,
theMapping,
e.id(),
theFormatVersion,
packEverything_);
e.id());

// put the raw data to the event
e.emplace(put_token_, std::move(fed_buffers));
Expand Down
17 changes: 7 additions & 10 deletions EventFilter/CSCRawToDigi/python/cscPacker_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
from EventFilter.CSCRawToDigi.cscPackerDef_cfi import cscPackerDef
cscpacker = cscPackerDef.clone()

##
## Make changes for running in Run 2
##
# packer - simply get rid of it
## In Run-2 common: update the format version for new OTMBs in ME1/1
## Note: in the past, the packing with triggers and pretriggers was disabled
## for Run-2, Run-3 and Phase-2 scenarios. This should no longer be the case
## as of CMSSW_12_0_0_pre5
from Configuration.Eras.Modifier_run2_common_cff import run2_common
run2_common.toModify( cscpacker,
useFormatVersion = 2013,
usePreTriggers = False,
packEverything = True)
formatVersion = 2013)

## in Run-3 include GEMs
## in Run-3 scenarios with GEM: pack GEM clusters
from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM
run3_GEM.toModify( cscpacker,
padDigiClusterTag = "simMuonGEMPadDigiClusters",
useGEMs = False)
useGEMs = True)
72 changes: 42 additions & 30 deletions EventFilter/CSCRawToDigi/src/CSCDigiToRaw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ namespace cscd2r {
}

template <typename LCTCollection>
bool accept(const CSCDetId& cscId, const LCTCollection& lcts, int bxMin, int bxMax, bool me1abCheck = false) {
bool accept(
const CSCDetId& cscId, const LCTCollection& lcts, int bxMin, int bxMax, int nominalBX, bool me1abCheck = false) {
if (bxMin == -999)
return true;
int nominalBX = 6;
CSCDetId chamberId = chamberID(cscId);
typename LCTCollection::Range lctRange = lcts.get(chamberId);
bool result = false;
Expand Down Expand Up @@ -71,10 +71,14 @@ namespace cscd2r {

// need to specialize for pretriggers, since they don't have a getBX()
template <>
bool accept(const CSCDetId& cscId, const CSCCLCTPreTriggerCollection& lcts, int bxMin, int bxMax, bool me1abCheck) {
bool accept(const CSCDetId& cscId,
const CSCCLCTPreTriggerCollection& lcts,
int bxMin,
int bxMax,
int nominalBX,
bool me1abCheck) {
if (bxMin == -999)
return true;
int nominalBX = 6;
CSCDetId chamberId = chamberID(cscId);
CSCCLCTPreTriggerCollection::Range lctRange = lcts.get(chamberId);
bool result = false;
Expand Down Expand Up @@ -108,7 +112,13 @@ CSCDigiToRaw::CSCDigiToRaw(const edm::ParameterSet& pset)
clctWindowMin_(pset.getParameter<int>("clctWindowMin")),
clctWindowMax_(pset.getParameter<int>("clctWindowMax")),
preTriggerWindowMin_(pset.getParameter<int>("preTriggerWindowMin")),
preTriggerWindowMax_(pset.getParameter<int>("preTriggerWindowMax")) {}
preTriggerWindowMax_(pset.getParameter<int>("preTriggerWindowMax")),
// pre-LS1 - '2005'. post-LS1 - '2013'
formatVersion_(pset.getParameter<unsigned>("formatVersion")),
// don't check for consistency with trig primitives
// overrides usePreTriggers
packEverything_(pset.getParameter<bool>("packEverything")),
usePreTriggers_(pset.getParameter<bool>("usePreTriggers")) {}

CSCEventData& CSCDigiToRaw::findEventData(const CSCDetId& cscDetId, FindEventDataInfo& info) const {
CSCDetId chamberId = cscd2r::chamberID(cscDetId);
Expand Down Expand Up @@ -140,18 +150,22 @@ CSCEventData& CSCDigiToRaw::findEventData(const CSCDetId& cscDetId, FindEventDat
void CSCDigiToRaw::add(const CSCStripDigiCollection& stripDigis,
const CSCCLCTPreTriggerCollection* preTriggers,
const CSCCLCTPreTriggerDigiCollection* preTriggerDigis,
FindEventDataInfo& fedInfo,
bool packEverything) const { //iterate over chambers with strip digis in them
FindEventDataInfo& fedInfo) const {
//iterate over chambers with strip digis in them
for (CSCStripDigiCollection::DigiRangeIterator j = stripDigis.begin(); j != stripDigis.end(); ++j) {
CSCDetId cscDetId = (*j).first;
// only digitize if there are pre-triggers

bool me1abCheck = fedInfo.formatVersion_ == 2013;
/* !!! Testing. Uncomment for production */
const bool usePreTriggers = preTriggers != nullptr;
if (!usePreTriggers || packEverything ||
(usePreTriggers &&
cscd2r::accept(cscDetId, *preTriggers, preTriggerWindowMin_, preTriggerWindowMax_, me1abCheck))) {
// pretrigger flag must be set and the pretrigger collection must be nonzero!
const bool usePreTriggers = usePreTriggers_ and preTriggers != nullptr;
if (!usePreTriggers || packEverything_ ||
(usePreTriggers && cscd2r::accept(cscDetId,
*preTriggerDigis,
preTriggerWindowMin_,
preTriggerWindowMax_,
CSCConstants::CLCT_CENTRAL_BX,
me1abCheck))) {
bool me1a = (cscDetId.station() == 1) && (cscDetId.ring() == 4);
bool zplus = (cscDetId.endcap() == 1);
bool me1b = (cscDetId.station() == 1) && (cscDetId.ring() == 1);
Expand Down Expand Up @@ -197,13 +211,14 @@ void CSCDigiToRaw::add(const CSCStripDigiCollection& stripDigis,

void CSCDigiToRaw::add(const CSCWireDigiCollection& wireDigis,
const CSCALCTDigiCollection& alctDigis,
FindEventDataInfo& fedInfo,
bool packEverything) const {
FindEventDataInfo& fedInfo) const {
add(alctDigis, fedInfo);
for (CSCWireDigiCollection::DigiRangeIterator j = wireDigis.begin(); j != wireDigis.end(); ++j) {
CSCDetId cscDetId = (*j).first;
bool me1abCheck = fedInfo.formatVersion_ == 2013;
if (packEverything || cscd2r::accept(cscDetId, alctDigis, alctWindowMin_, alctWindowMax_, me1abCheck)) {
if (packEverything_ ||
cscd2r::accept(
cscDetId, alctDigis, alctWindowMin_, alctWindowMax_, CSCConstants::ALCT_CENTRAL_BX, me1abCheck)) {
CSCEventData& cscData = findEventData(cscDetId, fedInfo);
std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
Expand All @@ -216,14 +231,15 @@ void CSCDigiToRaw::add(const CSCWireDigiCollection& wireDigis,

void CSCDigiToRaw::add(const CSCComparatorDigiCollection& comparatorDigis,
const CSCCLCTDigiCollection& clctDigis,
FindEventDataInfo& fedInfo,
bool packEverything) const {
FindEventDataInfo& fedInfo) const {
add(clctDigis, fedInfo);
for (auto const& j : comparatorDigis) {
CSCDetId cscDetId = j.first;
CSCEventData& cscData = findEventData(cscDetId, fedInfo);
bool me1abCheck = fedInfo.formatVersion_ == 2013;
if (packEverything || cscd2r::accept(cscDetId, clctDigis, clctWindowMin_, clctWindowMax_, me1abCheck)) {
if (packEverything_ ||
cscd2r::accept(
cscDetId, clctDigis, clctWindowMin_, clctWindowMax_, CSCConstants::CLCT_CENTRAL_BX, me1abCheck)) {
bool me1a = (cscDetId.station() == 1) && (cscDetId.ring() == 4);

/*
Expand Down Expand Up @@ -366,17 +382,13 @@ void CSCDigiToRaw::createFedBuffers(const CSCStripDigiCollection& stripDigis,
const GEMPadDigiClusterCollection* gemPadDigiClusters,
FEDRawDataCollection& fed_buffers,
const CSCChamberMap* mapping,
const EventID& eid,
uint16_t format_version,
bool packEverything) const {
//bits of code from ORCA/Muon/METBFormatter - thanks, Rick:)!

const EventID& eid) const {
//get fed object from fed_buffers
// make a map from the index of a chamber to the event data from it
FindEventDataInfo fedInfo{mapping, format_version};
add(stripDigis, preTriggers, preTriggerDigis, fedInfo, packEverything);
add(wireDigis, alctDigis, fedInfo, packEverything);
add(comparatorDigis, clctDigis, fedInfo, packEverything);
FindEventDataInfo fedInfo{mapping, formatVersion_};
add(stripDigis, preTriggers, preTriggerDigis, fedInfo);
add(wireDigis, alctDigis, fedInfo);
add(comparatorDigis, clctDigis, fedInfo);
add(correlatedLCTDigis, fedInfo);

// Starting Run-3, the CSC DAQ will pack/unpack CSC showers
Expand Down Expand Up @@ -417,7 +429,7 @@ void CSCDigiToRaw::createFedBuffers(const CSCStripDigiCollection& stripDigis,
int dduSlot = mapping->dduSlot(chamberItr->first);
int dduInput = mapping->dduInput(chamberItr->first);
int dmbId = mapping->dmb(chamberItr->first);
dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId, format_version);
dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId, formatVersion_);
}
}
}
Expand All @@ -438,7 +450,7 @@ void CSCDigiToRaw::createFedBuffers(const CSCStripDigiCollection& stripDigis,
}
}
/// Handle post-LS1 format data
else if (format_version == 2013) {
else if (formatVersion_ == 2013) {
std::map<int, CSCDDUEventData> dduMap;
unsigned int ddu_fmt_version = 0x7; /// 2013 Format
const unsigned postLS1_map[] = {841, 842, 843, 844, 845, 846, 847, 848, 849, 831, 832, 833,
Expand Down Expand Up @@ -490,7 +502,7 @@ void CSCDigiToRaw::createFedBuffers(const CSCStripDigiCollection& stripDigis,
int dduInput = mapping->dduInput(chamberItr->first);
int dmbId = mapping->dmb(chamberItr->first);
// int crateId = mapping->crate(chamberItr->first);
dduMapItr->second.add(chamberItr->second, dmbId, dduInput, format_version);
dduMapItr->second.add(chamberItr->second, dmbId, dduInput, formatVersion_);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion SLHCUpgradeSimulations/Configuration/python/muonCustoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def customise_csc_L1Emulator_sim(process):
def customise_csc_Packer(process):
"""Use 2013 a.k.a. post-LS1 version
"""
process.cscpacker.useFormatVersion = cms.uint32(2013)
process.cscpacker.formatVersion = cms.uint32(2013)
process.cscpacker.usePreTriggers = cms.bool(False)
process.cscpacker.packEverything = cms.bool(True)
return process
Expand Down

0 comments on commit 2398d9b

Please sign in to comment.