CMS 3D CMS Logo

L1EmulBias.cc
Go to the documentation of this file.
2 
6 
7 using namespace dedefs;
8 
10  verbose_ = iConfig.getUntrackedParameter<int>("VerboseFlag", 0);
11 
12  for (int sys = 0; sys < DEnsys; sys++) {
13  std::string label = SystLabel[sys] + "source";
14  m_DEsource[sys][0] = iConfig.getParameter<edm::InputTag>(label);
15  if (sys == CTF) {
16  std::string label = "CTTsource";
17  m_DEsource[sys][1] = iConfig.getParameter<edm::InputTag>(label);
18  }
19  }
20 
21  std::vector<unsigned int> compColls = iConfig.getUntrackedParameter<std::vector<unsigned int> >("DO_SYSTEM");
22  for (int i = 0; i < DEnsys; i++)
23  m_doSys[i] = compColls[i];
24 
25  if (verbose()) {
26  std::cout << "[L1EmulBias] do sys? ";
27  for (int i = 0; i < DEnsys; i++)
28  std::cout << m_doSys[i];
29  std::cout << "\n\t";
30  for (int i = 0; i < DEnsys; i++)
31  if (m_doSys[i])
32  std::cout << SystLabel[i] << " ";
33  std::cout << std::endl;
34  }
35 
36  std::string CollInstName[DEnsys][5];
37  for (int i = 0; i < DEnsys; i++)
38  for (int j = 0; j < 5; j++)
39  CollInstName[i][j] = std::string("");
40 
41  CollInstName[GCT][0] += "isoEm";
42  CollInstName[GCT][1] += "nonIsoEm";
43  CollInstName[GCT][2] += "cenJets";
44  CollInstName[GCT][3] += "forJets";
45  CollInstName[GCT][4] += "tauJets";
46  CollInstName[DTF][0] += "DT";
47  CollInstName[DTF][1] += "DTTF";
48  CollInstName[CTF][0] += "CSC";
49  CollInstName[CTF][1] += "";
50  CollInstName[RPC][0] += "RPCb";
51  CollInstName[RPC][1] += "RPCf";
52 
53  for (int i = 0; i < DEnsys; i++)
54  for (int j = 0; j < 5; j++)
55  instName[i][j] = CollInstName[i][j];
56 
57  if (verbose())
58  for (int i = 0; i < DEnsys; i++)
59  for (int j = 0; j < 5; j++)
60  if (!instName[i][j].empty())
61  std::cout << "[emulbias] " << i << " " << SystLabel[i] << " " << j << " " << instName[i][j] << std::endl;
62 
64  assert(ETP == 0);
65  assert(HTP == 1);
66  assert(RCT == 2);
67  assert(GCT == 3);
68  assert(DTP == 4);
69  assert(DTF == 5);
70  assert(CTP == 6);
71  assert(CTF == 7);
72  assert(RPC == 8);
73  assert(LTC == 9);
74  assert(GMT == 10);
75  assert(GLT == 11);
76 
78  if (m_doSys[ETP])
79  produces<EcalTrigPrimDigiCollection>(instName[ETP][0]);
80  if (m_doSys[HTP])
81  produces<HcalTrigPrimDigiCollection>(instName[HTP][0]);
82  if (m_doSys[RCT])
83  produces<L1CaloEmCollection>(instName[RCT][0]);
84  if (m_doSys[RCT])
85  produces<L1CaloRegionCollection>(instName[RCT][0]);
86  if (m_doSys[GCT])
87  produces<L1GctEmCandCollection>(instName[GCT][0]);
88  if (m_doSys[GCT])
89  produces<L1GctEmCandCollection>(instName[GCT][1]);
90  if (m_doSys[GCT])
91  produces<L1GctJetCandCollection>(instName[GCT][2]);
92  if (m_doSys[GCT])
93  produces<L1GctJetCandCollection>(instName[GCT][3]);
94  if (m_doSys[GCT])
95  produces<L1GctJetCandCollection>(instName[GCT][4]);
96  if (m_doSys[DTP])
97  produces<L1MuDTChambPhContainer>(instName[DTP][0]);
98  if (m_doSys[DTP])
99  produces<L1MuDTChambThContainer>(instName[DTP][0]);
100  if (m_doSys[DTF])
101  produces<L1MuRegionalCandCollection>(instName[DTF][0]);
102  if (m_doSys[DTF])
103  produces<L1MuDTTrackContainer>(instName[DTF][1]);
104  if (m_doSys[CTP])
105  produces<CSCCorrelatedLCTDigiCollection>(instName[CTP][0]);
106  if (m_doSys[CTF])
107  produces<L1MuRegionalCandCollection>(instName[CTF][0]);
108  if (m_doSys[CTF])
109  produces<L1CSCTrackCollection>(instName[CTF][1]);
110  if (m_doSys[RPC])
111  produces<L1MuRegionalCandCollection>(instName[RPC][0]);
112  if (m_doSys[RPC])
113  produces<L1MuRegionalCandCollection>(instName[RPC][1]);
114  if (m_doSys[LTC])
115  produces<LTCDigiCollection>(instName[LTC][0]);
116  if (m_doSys[GMT])
117  produces<L1MuGMTCandCollection>(instName[GMT][0]);
118  if (m_doSys[GMT])
119  produces<L1MuGMTReadoutCollection>(instName[GMT][0]);
120  if (m_doSys[GLT])
121  produces<L1GlobalTriggerReadoutRecord>(instName[GLT][0]);
122  if (m_doSys[GLT])
123  produces<L1GlobalTriggerEvmReadoutRecord>(instName[GLT][0]);
124  if (m_doSys[GLT])
125  produces<L1GlobalTriggerObjectMapRecord>(instName[GLT][0]);
126 
128  if (!rng.isAvailable()) {
129  throw cms::Exception("Configuration")
130  << "L1EmulBias requires the RandomNumberGeneratorService\n"
131  "which is not present in the configuration file. You must add the service\n"
132  "in the configuration file or remove the modules that require it.";
133  }
134 
135  if (verbose())
136  std::cout << "L1EmulBias::L1EmulBias()... done." << std::endl;
137 }
138 
140 
141 // ------------ method called to produce the data ------------
144  CLHEP::HepRandomEngine* engine = &rng->getEngine(iEvent.streamID());
145 
146  if (verbose())
147  std::cout << "L1EmulBias::produce...\n" << std::flush;
148 
154  edm::Handle<L1GctEmCandCollection> gct_isolaem_emul;
155  edm::Handle<L1GctEmCandCollection> gct_noisoem_emul;
156  edm::Handle<L1GctJetCandCollection> gct_cenjets_emul;
157  edm::Handle<L1GctJetCandCollection> gct_forjets_emul;
158  edm::Handle<L1GctJetCandCollection> gct_taujets_emul;
175 
177  if (m_doSys[ETP])
178  iEvent.getByLabel(m_DEsource[ETP][0].label(), instName[ETP][0], ecal_tp_emul);
179  if (m_doSys[HTP])
180  iEvent.getByLabel(m_DEsource[HTP][0].label(), instName[HTP][0], hcal_tp_emul);
181  if (m_doSys[RCT])
182  iEvent.getByLabel(m_DEsource[RCT][0].label(), instName[RCT][0], rct_em_emul);
183  if (m_doSys[RCT])
184  iEvent.getByLabel(m_DEsource[RCT][0].label(), instName[RCT][0], rct_rgn_emul);
185  if (m_doSys[GCT])
186  iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][0], gct_isolaem_emul);
187  if (m_doSys[GCT])
188  iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][1], gct_noisoem_emul);
189  if (m_doSys[GCT])
190  iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][2], gct_cenjets_emul);
191  if (m_doSys[GCT])
192  iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][3], gct_forjets_emul);
193  if (m_doSys[GCT])
194  iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][4], gct_taujets_emul);
195  if (m_doSys[DTP])
196  iEvent.getByLabel(m_DEsource[DTP][0].label(), instName[DTP][0], dtp_ph_emul);
197  if (m_doSys[DTP])
198  iEvent.getByLabel(m_DEsource[DTP][0].label(), instName[DTP][0], dtp_th_emul);
199  if (m_doSys[DTF])
200  iEvent.getByLabel(m_DEsource[DTF][0].label(), instName[DTF][0], dtf_emul);
201  if (m_doSys[DTF])
202  iEvent.getByLabel(m_DEsource[DTF][0].label(), instName[DTF][1], dtf_trk_emul);
203  if (m_doSys[CTP])
204  iEvent.getByLabel(m_DEsource[CTP][0].label(), instName[CTP][0], ctp_emul);
205  if (m_doSys[CTF])
206  iEvent.getByLabel(m_DEsource[CTF][0].label(), instName[CTF][0], ctf_emul);
207  if (m_doSys[CTF])
208  iEvent.getByLabel(m_DEsource[CTF][1].label(), instName[CTF][1], ctf_trk_emul);
209  if (m_doSys[RPC])
210  iEvent.getByLabel(m_DEsource[RPC][0].label(), instName[RPC][0], rpc_cen_emul);
211  if (m_doSys[RPC])
212  iEvent.getByLabel(m_DEsource[RPC][0].label(), instName[RPC][1], rpc_for_emul);
213  if (m_doSys[LTC])
214  iEvent.getByLabel(m_DEsource[LTC][0].label(), instName[LTC][0], ltc_emul);
215  if (m_doSys[GMT])
216  iEvent.getByLabel(m_DEsource[GMT][0].label(), instName[GMT][0], gmt_emul);
217  if (m_doSys[GMT])
218  iEvent.getByLabel(m_DEsource[GMT][0].label(), instName[GMT][0], gmt_rdt_emul);
219  if (m_doSys[GLT])
220  iEvent.getByLabel(m_DEsource[GLT][0].label(), instName[GLT][0], glt_rdt_emul);
221  if (m_doSys[GLT])
222  iEvent.getByLabel(m_DEsource[GLT][0].label(), instName[GLT][0], glt_evm_emul);
223  if (m_doSys[GLT])
224  iEvent.getByLabel(m_DEsource[GLT][0].label(), instName[GLT][0], glt_obj_emul);
225 
227  if (m_doSys[ETP])
228  assert(ecal_tp_emul.isValid());
229  if (m_doSys[HTP])
230  assert(hcal_tp_emul.isValid());
231  if (m_doSys[RCT])
232  assert(rct_em_emul.isValid());
233  if (m_doSys[RCT])
234  assert(rct_rgn_emul.isValid());
235  if (m_doSys[GCT])
236  assert(gct_isolaem_emul.isValid());
237  if (m_doSys[GCT])
238  assert(gct_noisoem_emul.isValid());
239  if (m_doSys[GCT])
240  assert(gct_cenjets_emul.isValid());
241  if (m_doSys[GCT])
242  assert(gct_forjets_emul.isValid());
243  if (m_doSys[GCT])
244  assert(gct_taujets_emul.isValid());
245  if (m_doSys[DTP])
246  assert(dtp_ph_emul.isValid());
247  if (m_doSys[DTP])
248  assert(dtp_th_emul.isValid());
249  if (m_doSys[DTF])
250  assert(dtf_emul.isValid());
251  if (m_doSys[DTF])
252  assert(dtf_trk_emul.isValid());
253  if (m_doSys[CTP])
254  assert(ctp_emul.isValid());
255  if (m_doSys[CTF])
256  assert(ctf_emul.isValid());
257  if (m_doSys[CTF])
258  assert(ctf_trk_emul.isValid());
259  if (m_doSys[RPC])
260  assert(rpc_cen_emul.isValid());
261  if (m_doSys[RPC])
262  assert(rpc_for_emul.isValid());
263  if (m_doSys[LTC])
264  assert(ltc_emul.isValid());
265  if (m_doSys[GMT])
266  assert(gmt_emul.isValid());
267  if (m_doSys[GMT])
268  assert(gmt_rdt_emul.isValid());
269  if (m_doSys[GLT])
270  assert(glt_rdt_emul.isValid());
271  if (m_doSys[GLT])
272  assert(glt_evm_emul.isValid());
273  if (m_doSys[GLT])
274  assert(glt_obj_emul.isValid());
275 
277  std::unique_ptr<EcalTrigPrimDigiCollection> ecal_tp_data(new EcalTrigPrimDigiCollection);
278  std::unique_ptr<HcalTrigPrimDigiCollection> hcal_tp_data(new HcalTrigPrimDigiCollection);
279  std::unique_ptr<L1CaloEmCollection> rct_em_data(new L1CaloEmCollection);
280  std::unique_ptr<L1CaloRegionCollection> rct_rgn_data(new L1CaloRegionCollection);
281  std::unique_ptr<L1GctEmCandCollection> gct_isolaem_data(new L1GctEmCandCollection);
282  std::unique_ptr<L1GctEmCandCollection> gct_noisoem_data(new L1GctEmCandCollection);
283  std::unique_ptr<L1GctJetCandCollection> gct_cenjets_data(new L1GctJetCandCollection);
284  std::unique_ptr<L1GctJetCandCollection> gct_forjets_data(new L1GctJetCandCollection);
285  std::unique_ptr<L1GctJetCandCollection> gct_taujets_data(new L1GctJetCandCollection);
286  std::unique_ptr<L1MuDTChambPhContainer> dtp_ph_data(new L1MuDTChambPhContainer);
287  std::unique_ptr<L1MuDTChambThContainer> dtp_th_data(new L1MuDTChambThContainer);
288  std::unique_ptr<L1MuRegionalCandCollection> dtf_data(new L1MuRegionalCandCollection);
289  std::unique_ptr<L1MuDTTrackContainer> dtf_trk_data(new L1MuDTTrackContainer);
290  std::unique_ptr<CSCCorrelatedLCTDigiCollection> ctp_data(new CSCCorrelatedLCTDigiCollection);
291  std::unique_ptr<L1MuRegionalCandCollection> ctf_data(new L1MuRegionalCandCollection);
292  std::unique_ptr<L1CSCTrackCollection> ctf_trk_data(new L1CSCTrackCollection);
293  std::unique_ptr<L1MuRegionalCandCollection> rpc_cen_data(new L1MuRegionalCandCollection);
294  std::unique_ptr<L1MuRegionalCandCollection> rpc_for_data(new L1MuRegionalCandCollection);
295  std::unique_ptr<LTCDigiCollection> ltc_data(new LTCDigiCollection);
296  std::unique_ptr<L1MuGMTCandCollection> gmt_data(new L1MuGMTCandCollection);
297  std::unique_ptr<L1MuGMTReadoutCollection> gmt_rdt_data(new L1MuGMTReadoutCollection);
298  std::unique_ptr<L1GlobalTriggerReadoutRecord> glt_rdt_data(new L1GlobalTriggerReadoutRecord);
299  std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> glt_evm_data(new L1GlobalTriggerEvmReadoutRecord);
300  std::unique_ptr<L1GlobalTriggerObjectMapRecord> glt_obj_data(new L1GlobalTriggerObjectMapRecord);
301 
302  if (verbose())
303  std::cout << "L1EmulBias::produce - modify...\n" << std::flush;
304 
306  if (m_doSys[ETP])
307  ModifyCollection(ecal_tp_data, ecal_tp_emul, engine);
308  if (m_doSys[HTP])
309  ModifyCollection(hcal_tp_data, hcal_tp_emul, engine);
310  if (m_doSys[RCT])
311  ModifyCollection(rct_em_data, rct_em_emul, engine);
312  if (m_doSys[RCT])
313  ModifyCollection(rct_rgn_data, rct_rgn_emul, engine);
314  if (m_doSys[GCT])
315  ModifyCollection(gct_isolaem_data, gct_isolaem_emul, engine);
316  if (m_doSys[GCT])
317  ModifyCollection(gct_noisoem_data, gct_noisoem_emul, engine);
318  if (m_doSys[GCT])
319  ModifyCollection(gct_cenjets_data, gct_cenjets_emul, engine);
320  if (m_doSys[GCT])
321  ModifyCollection(gct_forjets_data, gct_forjets_emul, engine);
322  if (m_doSys[GCT])
323  ModifyCollection(gct_taujets_data, gct_taujets_emul, engine);
324  if (m_doSys[DTP])
325  ModifyCollection(dtp_ph_data, dtp_ph_emul, engine);
326  if (m_doSys[DTP])
327  ModifyCollection(dtp_th_data, dtp_th_emul, engine);
328  if (m_doSys[DTF])
329  ModifyCollection(dtf_data, dtf_emul, engine);
330  if (m_doSys[DTF])
331  ModifyCollection(dtf_trk_data, dtf_trk_emul, engine);
332  if (m_doSys[CTP])
333  ModifyCollection(ctp_data, ctp_emul, engine);
334  if (m_doSys[CTF])
335  ModifyCollection(ctf_data, ctf_emul, engine);
336  if (m_doSys[CTF])
337  ModifyCollection(ctf_trk_data, ctf_trk_emul, engine);
338  if (m_doSys[RPC])
339  ModifyCollection(rpc_cen_data, rpc_cen_emul, engine);
340  if (m_doSys[RPC])
341  ModifyCollection(rpc_for_data, rpc_for_emul, engine);
342  if (m_doSys[LTC])
343  ModifyCollection(ltc_data, ltc_emul, engine);
344  if (m_doSys[GMT])
345  ModifyCollection(gmt_data, gmt_emul, engine);
346  if (m_doSys[GMT])
347  ModifyCollection(gmt_rdt_data, gmt_rdt_emul, engine);
348  if (m_doSys[GLT])
349  ModifyCollection(glt_rdt_data, glt_rdt_emul, engine);
350  if (m_doSys[GLT])
351  ModifyCollection(glt_evm_data, glt_evm_emul, engine);
352  if (m_doSys[GLT])
353  ModifyCollection(glt_obj_data, glt_obj_emul, engine);
354 
355  if (verbose())
356  std::cout << "L1EmulBias::produce - put...\n" << std::flush;
357 
359  if (m_doSys[ETP])
360  iEvent.put(std::move(ecal_tp_data), instName[ETP][0]);
361  if (m_doSys[HTP])
362  iEvent.put(std::move(hcal_tp_data), instName[HTP][0]);
363  if (m_doSys[RCT])
364  iEvent.put(std::move(rct_em_data), instName[RCT][0]);
365  if (m_doSys[RCT])
366  iEvent.put(std::move(rct_rgn_data), instName[RCT][0]);
367  if (m_doSys[GCT])
368  iEvent.put(std::move(gct_isolaem_data), instName[GCT][0]);
369  if (m_doSys[GCT])
370  iEvent.put(std::move(gct_noisoem_data), instName[GCT][1]);
371  if (m_doSys[GCT])
372  iEvent.put(std::move(gct_cenjets_data), instName[GCT][2]);
373  if (m_doSys[GCT])
374  iEvent.put(std::move(gct_forjets_data), instName[GCT][3]);
375  if (m_doSys[GCT])
376  iEvent.put(std::move(gct_taujets_data), instName[GCT][4]);
377  if (m_doSys[DTP])
378  iEvent.put(std::move(dtp_ph_data), instName[DTP][0]);
379  if (m_doSys[DTP])
380  iEvent.put(std::move(dtp_th_data), instName[DTP][0]);
381  if (m_doSys[DTF])
382  iEvent.put(std::move(dtf_data), instName[DTF][0]);
383  if (m_doSys[DTF])
384  iEvent.put(std::move(dtf_trk_data), instName[DTF][1]);
385  if (m_doSys[CTP])
386  iEvent.put(std::move(ctp_data), instName[CTP][0]);
387  if (m_doSys[CTF])
388  iEvent.put(std::move(ctf_data), instName[CTF][0]);
389  if (m_doSys[CTF])
390  iEvent.put(std::move(ctf_trk_data), instName[CTF][1]);
391  if (m_doSys[RPC])
392  iEvent.put(std::move(rpc_cen_data), instName[RPC][0]);
393  if (m_doSys[RPC])
394  iEvent.put(std::move(rpc_for_data), instName[RPC][1]);
395  if (m_doSys[LTC])
396  iEvent.put(std::move(ltc_data), instName[LTC][0]);
397  if (m_doSys[GMT])
398  iEvent.put(std::move(gmt_data), instName[GMT][0]);
399  if (m_doSys[GMT])
400  iEvent.put(std::move(gmt_rdt_data), instName[GMT][0]);
401  if (m_doSys[GLT])
402  iEvent.put(std::move(glt_rdt_data), instName[GLT][0]);
403  if (m_doSys[GLT])
404  iEvent.put(std::move(glt_evm_data), instName[GLT][0]);
405  if (m_doSys[GLT])
406  iEvent.put(std::move(glt_obj_data), instName[GLT][0]);
407 
408  if (verbose())
409  std::cout << "L1EmulBias::produce...done.\n" << std::flush;
410 }
~L1EmulBias() override
Definition: L1EmulBias.cc:139
std::vector< L1CaloEmCand > L1CaloEmCollection
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const int DEnsys
Definition: DEtrait.h:38
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: L1EmulBias.cc:142
bool verbose
assert(be >=bs)
std::vector< L1CSCTrack > L1CSCTrackCollection
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
L1EmulBias(const edm::ParameterSet &)
Definition: L1EmulBias.cc:9
T getUntrackedParameter(std::string const &, T const &) const
std::vector< L1GctJetCand > L1GctJetCandCollection
char const * label
int iEvent
Definition: GenABIO.cc:224
std::vector< LTCDigi > LTCDigiCollection
Definition: LTCDigi.h:91
std::vector< L1MuRegionalCand > L1MuRegionalCandCollection
bool isValid() const
Definition: HandleBase.h:70
const std::string SystLabel[DEnsys]
Definition: DEtrait.h:42
Definition: DEtrait.h:36
std::vector< L1CaloRegion > L1CaloRegionCollection
def move(src, dest)
Definition: eostools.py:511
std::vector< L1MuGMTCand > L1MuGMTCandCollection
Definition: DEtrait.h:99
std::vector< L1GctEmCand > L1GctEmCandCollection