Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete the implementation of RPC Digi Collection Merger started in PR #24613 #27672

Merged
merged 6 commits into from Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Configuration/Eras/python/Modifier_run3_RPC_cff.py
@@ -0,0 +1,4 @@
import FWCore.ParameterSet.Config as cms

run3_RPC = cms.Modifier()

2 changes: 1 addition & 1 deletion Configuration/StandardSequences/python/Eras.py
Expand Up @@ -57,7 +57,7 @@ def __init__(self):
'peripheralPbPb', 'pA_2016',
'run2_HE_2017', 'stage2L1Trigger', 'stage2L1Trigger_2017',
'run2_HF_2017', 'run2_HCAL_2017', 'run2_HEPlan1_2017', 'run2_HB_2018','run2_HE_2018',
'run3_HB', 'run3_common',
'run3_HB', 'run3_common', 'run3_RPC',
'phase1Pixel', 'run3_GEM', 'run2_GEM_2017',
'run2_CSC_2018',
'phase2_common', 'phase2_tracker',
Expand Down
7 changes: 7 additions & 0 deletions Configuration/StandardSequences/python/RawToDigi_Data_cff.py
Expand Up @@ -6,3 +6,10 @@
ecalDigis.DoRegional = False
#False by default ecalDigis.DoRegional = False

# RPC Merged Digis
from Configuration.Eras.Modifier_run3_RPC_cff import run3_RPC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dilsonjd is this update only for data and not MC? Otherwise why in this configuration and not in RawToDigi_cff?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we run the data, this modification is necessary. Then, we understand that here is the correct place to implement it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dilsonjd but is this supposed to be activated ONLY on data? Do we have a test were this code is practically exercised? Your tests in EventFilter do not seem dependent on this run3 Era.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocos Yes, it is to be actived ONLY on data.
The test was done running over the Run2018A dataset using the eras.Run2_2018 and adding eras.run3_RPC into the conditions of the process. You can find the configs here /afs/cern.ch/work/d/dilson/public/toTestRun3RPCData/

Maybe, the modifier_run3_RPC must be add to Era_Run3_cff.py. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this kind of modifications should be done in the RawToDigi_cff , common to data and simulation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration in the Raw2Digi_Data is due to the two different strategies needed for the MC and Data approach.

run3_RPC.toModify(muonRPCDigis,
inputTagTwinMuxDigis = 'rpcTwinMuxRawToDigi',
inputTagOMTFDigis = 'omtfStage2Digis',
inputTagCPPFDigis = 'rpcCPPFRawToDigi'
)
20 changes: 2 additions & 18 deletions Configuration/StandardSequences/python/RawToDigi_cff.py
Expand Up @@ -24,11 +24,8 @@
import EventFilter.DTRawToDigi.dtunpacker_cfi
muonDTDigis = EventFilter.DTRawToDigi.dtunpacker_cfi.muonDTDigis.clone()

import EventFilter.RPCRawToDigi.rpcUnpacker_cfi
muonRPCDigis = EventFilter.RPCRawToDigi.rpcUnpacker_cfi.rpcunpacker.clone()

import EventFilter.RPCRawToDigi.rpcDigiMerger_cfi
muonRPCNewDigis = EventFilter.RPCRawToDigi.rpcDigiMerger_cfi.rpcDigiMerger.clone()
import EventFilter.RPCRawToDigi.RPCRawToDigi_cfi
muonRPCDigis = EventFilter.RPCRawToDigi.RPCRawToDigi_cfi.muonRPCDigis.clone()

import EventFilter.GEMRawToDigi.muonGEMDigis_cfi
muonGEMDigis = EventFilter.GEMRawToDigi.muonGEMDigis_cfi.muonGEMDigis.clone()
Expand Down Expand Up @@ -116,19 +113,6 @@
from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
phase2_hgcal.toReplaceWith(RawToDigiTask,_hgcal_RawToDigiTask)

# RPC New Readout Validation
from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly, that with this PR for the 2017 and 2018 runs the muonRPCDigis will only consists in the "unpacker" (legacy config), while in the current CMSSW for 2017 and 2018 the muonRPCDigis is "unpacket+digimerger"?
Is this change of past conditions intended? (Not obvious from your description and slides)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you understand correctly. These periods, 2017 ad 2018, should work with legacy only. When the digimerger was implement the muonRPCNewDigis and rpcNewRecHits were introduced as a temporally solution, in the sense that the two implementations work in the same time and let the new one (digimerger) be tested. You pointed out the problem with the MC chain and this PR proposal is to solve it and also to make the new implementation (digimerger) work only for Run3.

_rpc_NewReadoutVal_RawToDigiTask = RawToDigiTask.copy()
_rpc_NewReadoutVal_RawToDigiTask_noTk = RawToDigiTask_noTk.copy()
_rpc_NewReadoutVal_RawToDigiTask.add(muonRPCNewDigis)
_rpc_NewReadoutVal_RawToDigiTask_noTk.add(muonRPCNewDigis)
stage2L1Trigger_2017.toReplaceWith(RawToDigiTask, _rpc_NewReadoutVal_RawToDigiTask)
stage2L1Trigger_2017.toReplaceWith(RawToDigiTask_noTk, _rpc_NewReadoutVal_RawToDigiTask)

from Configuration.Eras.Modifier_fastSim_cff import fastSim
fastSim.toReplaceWith(RawToDigiTask, RawToDigiTask.copyAndExclude([muonRPCNewDigis]))
fastSim.toReplaceWith(RawToDigiTask_noTk, RawToDigiTask_noTk.copyAndExclude([muonRPCNewDigis]))

_hfnose_RawToDigiTask = RawToDigiTask.copy()
_hfnose_RawToDigiTask.add(hfnoseDigis)

Expand Down
172 changes: 123 additions & 49 deletions EventFilter/RPCRawToDigi/plugins/RPCDigiMerger.cc
Expand Up @@ -17,20 +17,42 @@
using namespace edm;
using namespace std;

RPCDigiMerger::RPCDigiMerger(edm::ParameterSet const& config) {
RPCDigiMerger::RPCDigiMerger(edm::ParameterSet const& config)
: bx_minTwinMux_(config.getParameter<int>("bxMinTwinMux")),
bx_maxTwinMux_(config.getParameter<int>("bxMaxTwinMux")),
bx_minOMTF_(config.getParameter<int>("bxMinOMTF")),
bx_maxOMTF_(config.getParameter<int>("bxMaxOMTF")),
bx_minCPPF_(config.getParameter<int>("bxMinCPPF")),
bx_maxCPPF_(config.getParameter<int>("bxMaxCPPF")) {
produces<RPCDigiCollection>();
twinMux_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagTwinMuxDigis"));
omtf_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagOMTFDigis"));
cppf_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagCPPFDigis"));
simRPC_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagSimRPCDigis"));
// protection against empty InputTag to allow for Data/MC compatibility
if (not config.getParameter<edm::InputTag>("inputTagTwinMuxDigis").label().empty()) {
twinMux_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagTwinMuxDigis"));
}
if (not config.getParameter<edm::InputTag>("inputTagOMTFDigis").label().empty()) {
omtf_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagOMTFDigis"));
}
if (not config.getParameter<edm::InputTag>("inputTagCPPFDigis").label().empty()) {
cppf_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagCPPFDigis"));
}
}

RPCDigiMerger::~RPCDigiMerger() {}

void RPCDigiMerger::fillDescriptions(edm::ConfigurationDescriptions& descs) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("inputTagTwinMuxDigis", edm::InputTag("rpcTwinMuxRawToDigi", ""));
desc.add<edm::InputTag>("inputTagOMTFDigis", edm::InputTag("omtfStage2Digis", ""));
desc.add<edm::InputTag>("inputTagCPPFDigis", edm::InputTag("rpcCPPFRawToDigi", ""));
desc.add<edm::InputTag>("inputTagSimRPCDigis", edm::InputTag("simMuonRPCDigis", ""));
desc.add<edm::InputTag>("inputTagTwinMuxDigis", edm::InputTag("", ""));
desc.add<edm::InputTag>("inputTagOMTFDigis", edm::InputTag("", ""));
desc.add<edm::InputTag>("inputTagCPPFDigis", edm::InputTag("", ""));
desc.add<edm::InputTag>("InputLabel", edm::InputTag(" "));
desc.add<int>("bxMinTwinMux", -2);
desc.add<int>("bxMaxTwinMux", 2);
desc.add<int>("bxMinOMTF", -3);
desc.add<int>("bxMaxOMTF", 4);
desc.add<int>("bxMinCPPF", -2);
desc.add<int>("bxMaxCPPF", 2);

descs.add("rpcDigiMerger", desc);
}
Expand All @@ -39,53 +61,105 @@ void RPCDigiMerger::beginRun(edm::Run const& run, edm::EventSetup const& setup)

void RPCDigiMerger::produce(edm::Event& event, edm::EventSetup const& setup) {
// Get the digis
// TwinMux
Handle<RPCDigiCollection> TwinMux_digis;
event.getByToken(twinMux_token_, TwinMux_digis);
// OMTF
Handle<RPCDigiCollection> OMTF_digis;
event.getByToken(omtf_token_, OMTF_digis);
// CPFF
Handle<RPCDigiCollection> CPPF_digis;
event.getByToken(cppf_token_, CPPF_digis);

// new RPCDigiCollection
std::unique_ptr<RPCDigiCollection> rpc_digi_collection(new RPCDigiCollection());

// loop over TwinMux digis
for (const auto& rpcdgIt : (*TwinMux_digis)) {
// The layerId
const RPCDetId& rpcId = rpcdgIt.first;
// Get the iterators over the digis associated with this LayerId
const RPCDigiCollection::Range& range = rpcdgIt.second;

rpc_digi_collection->put(range, rpcId);
}

// loop over CPPF digis
for (const auto&& rpcdgIt : (*CPPF_digis)) {
// The layerId
const RPCDetId& rpcId = rpcdgIt.first;
// Get the iterators over the digis associated with this LayerId
const RPCDigiCollection::Range& range = rpcdgIt.second;

rpc_digi_collection->put(range, rpcId);
}

// loop over OMTF digis
for (const auto& rpcdgIt : (*OMTF_digis)) {
// The layerId
const RPCDetId& rpcId = rpcdgIt.first;
// Get the iterators over the digis associated with this LayerId
const RPCDigiCollection::Range& range = rpcdgIt.second;

// accepts only rings: RE-2_R3 ; RE-1_R3 ; RE+1_R3 ; RE+2_R3 ;
if (((rpcId.region() == -1 || rpcId.region() == 1) && (rpcId.ring() == 3) &&
(rpcId.station() == 1 || rpcId.station() == 2))) {
rpc_digi_collection->put(range, rpcId);
//Check if its Data
if (not(cppf_token_.isUninitialized() && omtf_token_.isUninitialized() && twinMux_token_.isUninitialized())) {
// loop over TwinMux digis
// protection against empty InputTag to allow for Data/MC compatibility
if (not twinMux_token_.isUninitialized()) {
Handle<RPCDigiCollection> TwinMux_digis;
event.getByToken(twinMux_token_, TwinMux_digis);
for (const auto&& rpcdgIt : (*TwinMux_digis)) {
// The layerId
const RPCDetId& rpcId = rpcdgIt.first;
// Get the iterators over the digis associated with this LayerId
const RPCDigiCollection::Range& range = rpcdgIt.second;
rpc_digi_collection->put(range, rpcId);
}
}
// loop over CPPF digis
// protection against empty InputTag to allow for Data/MC compatibility
if (not cppf_token_.isUninitialized()) {
Handle<RPCDigiCollection> CPPF_digis;
event.getByToken(cppf_token_, CPPF_digis);
for (const auto&& rpcdgIt : (*CPPF_digis)) {
// The layerId
const RPCDetId& rpcId = rpcdgIt.first;
// Get the iterators over the digis associated with this LayerId
const RPCDigiCollection::Range& range = rpcdgIt.second;
rpc_digi_collection->put(range, rpcId);
}
}
// loop over OMTF digis
// protection against empty InputTag to allow for Data/MC compatibility
if (not omtf_token_.isUninitialized()) {
Handle<RPCDigiCollection> OMTF_digis;
event.getByToken(omtf_token_, OMTF_digis);
for (const auto& rpcdgIt : (*OMTF_digis)) {
// The layerId
const RPCDetId& rpcId = rpcdgIt.first;
// Get the iterators over the digis associated with this LayerId
const RPCDigiCollection::Range& range = rpcdgIt.second;
// accepts only rings: RE-2_R3 ; RE-1_R3 ; RE+1_R3 ; RE+2_R3 ;
if (((rpcId.region() == -1 || rpcId.region() == 1) && (rpcId.ring() == 3) &&
(rpcId.station() == 1 || rpcId.station() == 2))) {
rpc_digi_collection->put(range, rpcId);
}
}
}
} else { //its MC
// SimRPCDigis collection
Handle<RPCDigiCollection> SimRPC_digis;
event.getByToken(simRPC_token_, SimRPC_digis);

RPCDetId rpc_det_id;
std::vector<RPCDigi> local_rpc_digis;

// loop over SimRPC digis
for (const auto& rpc_digi : (*SimRPC_digis)) {
// The layerId
const RPCDetId& rpcId = rpc_digi.first;
// Get the iterators over the digis associated with this LayerId
const RPCDigiCollection::Range& range = rpc_digi.second;

if (rpcId != rpc_det_id) {
if (!local_rpc_digis.empty()) {
rpc_digi_collection->put(RPCDigiCollection::Range(local_rpc_digis.begin(), local_rpc_digis.end()),
rpc_det_id);
local_rpc_digis.clear();
}
rpc_det_id = rpcId;
}
for (std::vector<RPCDigi>::const_iterator id = range.first; id != range.second; id++) {
const RPCDigi& dit = (*id);
//Barrel
if (rpcId.region() == 0) {
//TwinMux
if (dit.bx() >= bx_minTwinMux_ && dit.bx() <= bx_maxTwinMux_) {
local_rpc_digis.push_back(dit);
}
}
//EndCap
if (rpcId.region() == -1 || rpcId.region() == 1) {
//OMTF
if (rpcId.ring() == 3 && (rpcId.station() == 1 || rpcId.station() == 2) && dit.bx() >= bx_minOMTF_ &&
dit.bx() <= bx_maxOMTF_) {
local_rpc_digis.push_back(dit);
}
//CPPF
if (((rpcId.ring() == 2) || (rpcId.ring() == 3 && (rpcId.station() == 3 || rpcId.station() == 4))) &&
(dit.bx() >= bx_minCPPF_ && dit.bx() <= bx_maxCPPF_)) {
local_rpc_digis.push_back(dit);
}
}
}
}
if (!local_rpc_digis.empty()) {
rpc_digi_collection->put(RPCDigiCollection::Range(local_rpc_digis.begin(), local_rpc_digis.end()), rpc_det_id);
}
}

// "put" into the event
event.put(std::move(rpc_digi_collection));
}
Expand Down
5 changes: 5 additions & 0 deletions EventFilter/RPCRawToDigi/plugins/RPCDigiMerger.h
Expand Up @@ -35,6 +35,11 @@ class RPCDigiMerger : public edm::stream::EDProducer<> {
edm::EDGetTokenT<RPCDigiCollection> twinMux_token_;
edm::EDGetTokenT<RPCDigiCollection> omtf_token_;
edm::EDGetTokenT<RPCDigiCollection> cppf_token_;
edm::EDGetTokenT<RPCDigiCollection> simRPC_token_;

int bx_minTwinMux_, bx_maxTwinMux_;
int bx_minOMTF_, bx_maxOMTF_;
int bx_minCPPF_, bx_maxCPPF_;
};

#endif // EventFilter_RPCRawToDigi_RPCDigiMerger_h
11 changes: 11 additions & 0 deletions EventFilter/RPCRawToDigi/python/RPCRawToDigi_cfi.py
@@ -0,0 +1,11 @@
import FWCore.ParameterSet.Config as cms

import EventFilter.RPCRawToDigi.rpcUnpacker_cfi
muonRPCDigis = EventFilter.RPCRawToDigi.rpcUnpacker_cfi.rpcunpacker.clone()

from Configuration.Eras.Modifier_run3_RPC_cff import run3_RPC
from EventFilter.RPCRawToDigi.rpcDigiMerger_cfi import rpcDigiMerger

run3_RPC.toReplaceWith(muonRPCDigis,rpcDigiMerger)


19 changes: 0 additions & 19 deletions RecoLocalMuon/Configuration/python/RecoLocalMuonCosmics_cff.py
Expand Up @@ -68,22 +68,3 @@
run3_GEM.toReplaceWith( muonlocalrecoTask , _run3_muonlocalrecoTask )
from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
phase2_muon.toReplaceWith( muonlocalrecoTask , _phase2_muonlocalrecoTask )


# RPC New Readout Validation
from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017
_rpc_NewReadoutVal_muonlocalreco_with_2DSegmentsTask = muonlocalreco_with_2DSegmentsTask.copy()
_rpc_NewReadoutVal_muonlocalrecoTask = muonlocalrecoTask.copy()
_rpc_NewReadoutVal_muonlocalrecoT0SegTask = muonlocalrecoT0SegTask.copy()
_rpc_NewReadoutVal_muonlocalreco_with_2DSegmentsTask.add(rpcNewRecHits)
_rpc_NewReadoutVal_muonlocalrecoTask.add(rpcNewRecHits)
_rpc_NewReadoutVal_muonlocalrecoT0SegTask.add(rpcNewRecHits)
stage2L1Trigger_2017.toReplaceWith(muonlocalreco_with_2DSegmentsTask, _rpc_NewReadoutVal_muonlocalreco_with_2DSegmentsTask)
stage2L1Trigger_2017.toReplaceWith(muonlocalrecoTask, _rpc_NewReadoutVal_muonlocalrecoTask)
stage2L1Trigger_2017.toReplaceWith(muonlocalrecoT0SegTask, _rpc_NewReadoutVal_muonlocalrecoT0SegTask)

from Configuration.Eras.Modifier_fastSim_cff import fastSim
fastSim.toReplaceWith(muonlocalreco_with_2DSegmentsTask, muonlocalreco_with_2DSegmentsTask.copyAndExclude([rpcNewRecHits]))
fastSim.toReplaceWith(muonlocalrecoTask, muonlocalrecoTask.copyAndExclude([rpcNewRecHits]))
fastSim.toReplaceWith(muonlocalrecoT0SegTask, muonlocalrecoT0SegTask.copyAndExclude([rpcNewRecHits]))

13 changes: 0 additions & 13 deletions RecoLocalMuon/Configuration/python/RecoLocalMuon_cff.py
Expand Up @@ -60,16 +60,3 @@
run3_GEM.toReplaceWith( muonlocalrecoTask , _run3_muonlocalrecoTask )
from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
phase2_muon.toReplaceWith( muonlocalrecoTask , _phase2_muonlocalrecoTask )

# RPC New Readout Validation
from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017
_rpc_NewReadoutVal_muonlocalreco_with_2DSegmentsTask = muonlocalreco_with_2DSegmentsTask.copy()
_rpc_NewReadoutVal_muonlocalrecoTask = muonlocalrecoTask.copy()
_rpc_NewReadoutVal_muonlocalreco_with_2DSegmentsTask.add(rpcNewRecHits)
_rpc_NewReadoutVal_muonlocalrecoTask.add(rpcNewRecHits)
stage2L1Trigger_2017.toReplaceWith(muonlocalreco_with_2DSegmentsTask, _rpc_NewReadoutVal_muonlocalreco_with_2DSegmentsTask)
stage2L1Trigger_2017.toReplaceWith(muonlocalrecoTask, _rpc_NewReadoutVal_muonlocalrecoTask)

from Configuration.Eras.Modifier_fastSim_cff import fastSim
fastSim.toReplaceWith(muonlocalreco_with_2DSegmentsTask, muonlocalreco_with_2DSegmentsTask.copyAndExclude([rpcNewRecHits]))
fastSim.toReplaceWith(muonlocalrecoTask, muonlocalrecoTask.copyAndExclude([rpcNewRecHits]))
12 changes: 0 additions & 12 deletions RecoLocalMuon/RPCRecHit/python/rpcRecHits_cfi.py
Expand Up @@ -13,18 +13,6 @@
deadvecfile = cms.FileInPath('RecoLocalMuon/RPCRecHit/data/RPCDeadVec.dat')
)

rpcNewRecHits = cms.EDProducer("RPCRecHitProducer",
recAlgoConfig = cms.PSet(

),
recAlgo = cms.string('RPCRecHitStandardAlgo'),
rpcDigiLabel = cms.InputTag('muonRPCNewDigis'),
maskSource = cms.string('File'),
maskvecfile = cms.FileInPath('RecoLocalMuon/RPCRecHit/data/RPCMaskVec.dat'),
deadSource = cms.string('File'),
deadvecfile = cms.FileInPath('RecoLocalMuon/RPCRecHit/data/RPCDeadVec.dat')
)

#disabling DIGI2RAW,RAW2DIGI chain for Phase2
from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
phase2_muon.toModify(rpcRecHits, rpcDigiLabel = cms.InputTag('simMuonRPCDigis'))