CMS 3D CMS Logo

RPCDigiMerger.cc
Go to the documentation of this file.
2 
3 #include <memory>
4 
14 
16 
17 using namespace edm;
18 using namespace std;
19 
21  : bx_minTwinMux_(config.getParameter<int>("bxMinTwinMux")),
22  bx_maxTwinMux_(config.getParameter<int>("bxMaxTwinMux")),
23  bx_minOMTF_(config.getParameter<int>("bxMinOMTF")),
24  bx_maxOMTF_(config.getParameter<int>("bxMaxOMTF")),
25  bx_minCPPF_(config.getParameter<int>("bxMinCPPF")),
26  bx_maxCPPF_(config.getParameter<int>("bxMaxCPPF")) {
27  produces<RPCDigiCollection>();
28  simRPC_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagSimRPCDigis"));
29  // protection against empty InputTag to allow for Data/MC compatibility
30  if (not config.getParameter<edm::InputTag>("inputTagTwinMuxDigis").label().empty()) {
31  twinMux_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagTwinMuxDigis"));
32  }
33  if (not config.getParameter<edm::InputTag>("inputTagOMTFDigis").label().empty()) {
34  omtf_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagOMTFDigis"));
35  }
36  if (not config.getParameter<edm::InputTag>("inputTagCPPFDigis").label().empty()) {
37  cppf_token_ = consumes<RPCDigiCollection>(config.getParameter<edm::InputTag>("inputTagCPPFDigis"));
38  }
39 }
40 
42 
45  desc.add<edm::InputTag>("inputTagSimRPCDigis", edm::InputTag("simMuonRPCDigis", ""));
46  desc.add<edm::InputTag>("inputTagTwinMuxDigis", edm::InputTag("", ""));
47  desc.add<edm::InputTag>("inputTagOMTFDigis", edm::InputTag("", ""));
48  desc.add<edm::InputTag>("inputTagCPPFDigis", edm::InputTag("", ""));
49  desc.add<edm::InputTag>("InputLabel", edm::InputTag(" "));
50  desc.add<int>("bxMinTwinMux", -2);
51  desc.add<int>("bxMaxTwinMux", 2);
52  desc.add<int>("bxMinOMTF", -3);
53  desc.add<int>("bxMaxOMTF", 4);
54  desc.add<int>("bxMinCPPF", -2);
55  desc.add<int>("bxMaxCPPF", 2);
56 
57  descs.add("rpcDigiMerger", desc);
58 }
59 
61 
63  // Get the digis
64  // new RPCDigiCollection
65  std::unique_ptr<RPCDigiCollection> rpc_digi_collection(new RPCDigiCollection());
66 
67  //Check if its Data
69  // loop over TwinMux digis
70  // protection against empty InputTag to allow for Data/MC compatibility
71  if (not twinMux_token_.isUninitialized()) {
72  Handle<RPCDigiCollection> TwinMux_digis;
73  event.getByToken(twinMux_token_, TwinMux_digis);
74  for (const auto&& rpcdgIt : (*TwinMux_digis)) {
75  // The layerId
76  const RPCDetId& rpcId = rpcdgIt.first;
77  // Get the iterators over the digis associated with this LayerId
78  const RPCDigiCollection::Range& range = rpcdgIt.second;
79  rpc_digi_collection->put(range, rpcId);
80  }
81  }
82  // loop over CPPF digis
83  // protection against empty InputTag to allow for Data/MC compatibility
84  if (not cppf_token_.isUninitialized()) {
85  Handle<RPCDigiCollection> CPPF_digis;
86  event.getByToken(cppf_token_, CPPF_digis);
87  for (const auto&& rpcdgIt : (*CPPF_digis)) {
88  // The layerId
89  const RPCDetId& rpcId = rpcdgIt.first;
90  // Get the iterators over the digis associated with this LayerId
91  const RPCDigiCollection::Range& range = rpcdgIt.second;
92  rpc_digi_collection->put(range, rpcId);
93  }
94  }
95  // loop over OMTF digis
96  // protection against empty InputTag to allow for Data/MC compatibility
97  if (not omtf_token_.isUninitialized()) {
98  Handle<RPCDigiCollection> OMTF_digis;
99  event.getByToken(omtf_token_, OMTF_digis);
100  for (const auto& rpcdgIt : (*OMTF_digis)) {
101  // The layerId
102  const RPCDetId& rpcId = rpcdgIt.first;
103  // Get the iterators over the digis associated with this LayerId
104  const RPCDigiCollection::Range& range = rpcdgIt.second;
105  // accepts only rings: RE-2_R3 ; RE-1_R3 ; RE+1_R3 ; RE+2_R3 ;
106  if (((rpcId.region() == -1 || rpcId.region() == 1) && (rpcId.ring() == 3) &&
107  (rpcId.station() == 1 || rpcId.station() == 2))) {
108  rpc_digi_collection->put(range, rpcId);
109  }
110  }
111  }
112  } else { //its MC
113  // SimRPCDigis collection
114  Handle<RPCDigiCollection> SimRPC_digis;
115  event.getByToken(simRPC_token_, SimRPC_digis);
116 
117  RPCDetId rpc_det_id;
118  std::vector<RPCDigi> local_rpc_digis;
119 
120  // loop over SimRPC digis
121  for (const auto& rpc_digi : (*SimRPC_digis)) {
122  // The layerId
123  const RPCDetId& rpcId = rpc_digi.first;
124  // Get the iterators over the digis associated with this LayerId
125  const RPCDigiCollection::Range& range = rpc_digi.second;
126 
127  if (rpcId != rpc_det_id) {
128  if (!local_rpc_digis.empty()) {
129  rpc_digi_collection->put(RPCDigiCollection::Range(local_rpc_digis.begin(), local_rpc_digis.end()),
130  rpc_det_id);
131  local_rpc_digis.clear();
132  }
133  rpc_det_id = rpcId;
134  }
135  for (std::vector<RPCDigi>::const_iterator id = range.first; id != range.second; id++) {
136  const RPCDigi& dit = (*id);
137  //Barrel
138  if (rpcId.region() == 0) {
139  //TwinMux
140  if (dit.bx() >= bx_minTwinMux_ && dit.bx() <= bx_maxTwinMux_) {
141  local_rpc_digis.push_back(dit);
142  }
143  }
144  //EndCap
145  if (rpcId.region() == -1 || rpcId.region() == 1) {
146  //OMTF
147  if (rpcId.ring() == 3 && (rpcId.station() == 1 || rpcId.station() == 2) && dit.bx() >= bx_minOMTF_ &&
148  dit.bx() <= bx_maxOMTF_) {
149  local_rpc_digis.push_back(dit);
150  }
151  //CPPF
152  if (((rpcId.ring() == 2) || (rpcId.ring() == 3 && (rpcId.station() == 3 || rpcId.station() == 4))) &&
153  (dit.bx() >= bx_minCPPF_ && dit.bx() <= bx_maxCPPF_)) {
154  local_rpc_digis.push_back(dit);
155  }
156  }
157  }
158  }
159  if (!local_rpc_digis.empty()) {
160  rpc_digi_collection->put(RPCDigiCollection::Range(local_rpc_digis.begin(), local_rpc_digis.end()), rpc_det_id);
161  }
162  }
163  // "put" into the event
164  event.put(std::move(rpc_digi_collection));
165 }
166 
ConfigurationDescriptions.h
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
Handle.h
MessageLogger.h
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
RPCDigiMerger::omtf_token_
edm::EDGetTokenT< RPCDigiCollection > omtf_token_
Definition: RPCDigiMerger.h:36
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
RPCDetId
Definition: RPCDetId.h:16
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
RPCDigiMerger::RPCDigiMerger
RPCDigiMerger(edm::ParameterSet const &config)
Definition: RPCDigiMerger.cc:20
RPCDigiMerger::bx_minCPPF_
int bx_minCPPF_
Definition: RPCDigiMerger.h:42
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
edm::Handle< RPCDigiCollection >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
RPCDigi::bx
int bx() const
Definition: RPCDigi.h:28
RPCDigiMerger.h
config
Definition: config.py:1
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
MakerMacros.h
RPCDigiMerger::twinMux_token_
edm::EDGetTokenT< RPCDigiCollection > twinMux_token_
Definition: RPCDigiMerger.h:35
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
RPCDigiMerger::bx_minOMTF_
int bx_minOMTF_
Definition: RPCDigiMerger.h:41
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
RPCDigiMerger::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &setup) override
Definition: RPCDigiMerger.cc:60
RPCDigiMerger::bx_maxTwinMux_
int bx_maxTwinMux_
Definition: RPCDigiMerger.h:40
RPCDigiCollection
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
Definition: RPCDigiCollection.h:13
RPCDigiMerger::simRPC_token_
edm::EDGetTokenT< RPCDigiCollection > simRPC_token_
Definition: RPCDigiMerger.h:38
RPCDigiMerger::produce
void produce(edm::Event &event, edm::EventSetup const &setup) override
Definition: RPCDigiMerger.cc:62
createfilelist.int
int
Definition: createfilelist.py:10
RPCDigiMerger::bx_maxOMTF_
int bx_maxOMTF_
Definition: RPCDigiMerger.h:41
RPCDigiMerger::cppf_token_
edm::EDGetTokenT< RPCDigiCollection > cppf_token_
Definition: RPCDigiMerger.h:37
edm::EventSetup
Definition: EventSetup.h:58
InputTag.h
RPCDetId::ring
int ring() const
Definition: RPCDetId.h:59
RPCDigiMerger::bx_maxCPPF_
int bx_maxCPPF_
Definition: RPCDigiMerger.h:42
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
RPCDigiMerger::~RPCDigiMerger
~RPCDigiMerger() override
Definition: RPCDigiMerger.cc:41
RPCDigi
Definition: RPCDigi.h:19
RPCDigiMerger::bx_minTwinMux_
int bx_minTwinMux_
Definition: RPCDigiMerger.h:40
EventSetup.h
MuonDigiCollection< RPCDetId, RPCDigi >::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
RPCDigiCollection.h
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
RPCDigiMerger
Definition: RPCDigiMerger.h:24
CRC16.h
RPCDigiMerger::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descs)
Definition: RPCDigiMerger.cc:43