Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:06

0001 #include "L1Trigger/HardwareValidation/plugins/L1EmulBias.h"
0002 
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "FWCore/Utilities/interface/Exception.h"
0005 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0006 
0007 using namespace dedefs;
0008 
0009 L1EmulBias::L1EmulBias(const edm::ParameterSet& iConfig) {
0010   verbose_ = iConfig.getUntrackedParameter<int>("VerboseFlag", 0);
0011 
0012   for (int sys = 0; sys < DEnsys; sys++) {
0013     std::string label = SystLabel[sys] + "source";
0014     m_DEsource[sys][0] = iConfig.getParameter<edm::InputTag>(label);
0015     if (sys == CTF) {
0016       std::string label = "CTTsource";
0017       m_DEsource[sys][1] = iConfig.getParameter<edm::InputTag>(label);
0018     }
0019   }
0020 
0021   std::vector<unsigned int> compColls = iConfig.getUntrackedParameter<std::vector<unsigned int> >("DO_SYSTEM");
0022   for (int i = 0; i < DEnsys; i++)
0023     m_doSys[i] = compColls[i];
0024 
0025   if (verbose()) {
0026     std::cout << "[L1EmulBias] do sys? ";
0027     for (int i = 0; i < DEnsys; i++)
0028       std::cout << m_doSys[i];
0029     std::cout << "\n\t";
0030     for (int i = 0; i < DEnsys; i++)
0031       if (m_doSys[i])
0032         std::cout << SystLabel[i] << " ";
0033     std::cout << std::endl;
0034   }
0035 
0036   std::string CollInstName[DEnsys][5];
0037   for (int i = 0; i < DEnsys; i++)
0038     for (int j = 0; j < 5; j++)
0039       CollInstName[i][j] = std::string("");
0040 
0041   CollInstName[GCT][0] += "isoEm";
0042   CollInstName[GCT][1] += "nonIsoEm";
0043   CollInstName[GCT][2] += "cenJets";
0044   CollInstName[GCT][3] += "forJets";
0045   CollInstName[GCT][4] += "tauJets";
0046   CollInstName[DTF][0] += "DT";
0047   CollInstName[DTF][1] += "DTTF";
0048   CollInstName[CTF][0] += "CSC";
0049   CollInstName[CTF][1] += "";
0050   CollInstName[RPC][0] += "RPCb";
0051   CollInstName[RPC][1] += "RPCf";
0052 
0053   for (int i = 0; i < DEnsys; i++)
0054     for (int j = 0; j < 5; j++)
0055       instName[i][j] = CollInstName[i][j];
0056 
0057   if (verbose())
0058     for (int i = 0; i < DEnsys; i++)
0059       for (int j = 0; j < 5; j++)
0060         if (!instName[i][j].empty())
0061           std::cout << "[emulbias] " << i << " " << SystLabel[i] << " " << j << " " << instName[i][j] << std::endl;
0062 
0063   ///assertion/temporary
0064   assert(ETP == 0);
0065   assert(HTP == 1);
0066   assert(RCT == 2);
0067   assert(GCT == 3);
0068   assert(DTP == 4);
0069   assert(DTF == 5);
0070   assert(CTP == 6);
0071   assert(CTF == 7);
0072   assert(RPC == 8);
0073   assert(LTC == 9);
0074   assert(GMT == 10);
0075   assert(GLT == 11);
0076 
0077   ///List of collections to be produced
0078   if (m_doSys[ETP])
0079     produces<EcalTrigPrimDigiCollection>(instName[ETP][0]);
0080   if (m_doSys[HTP])
0081     produces<HcalTrigPrimDigiCollection>(instName[HTP][0]);
0082   if (m_doSys[RCT])
0083     produces<L1CaloEmCollection>(instName[RCT][0]);
0084   if (m_doSys[RCT])
0085     produces<L1CaloRegionCollection>(instName[RCT][0]);
0086   if (m_doSys[GCT])
0087     produces<L1GctEmCandCollection>(instName[GCT][0]);
0088   if (m_doSys[GCT])
0089     produces<L1GctEmCandCollection>(instName[GCT][1]);
0090   if (m_doSys[GCT])
0091     produces<L1GctJetCandCollection>(instName[GCT][2]);
0092   if (m_doSys[GCT])
0093     produces<L1GctJetCandCollection>(instName[GCT][3]);
0094   if (m_doSys[GCT])
0095     produces<L1GctJetCandCollection>(instName[GCT][4]);
0096   if (m_doSys[DTP])
0097     produces<L1MuDTChambPhContainer>(instName[DTP][0]);
0098   if (m_doSys[DTP])
0099     produces<L1MuDTChambThContainer>(instName[DTP][0]);
0100   if (m_doSys[DTF])
0101     produces<L1MuRegionalCandCollection>(instName[DTF][0]);
0102   if (m_doSys[DTF])
0103     produces<L1MuDTTrackContainer>(instName[DTF][1]);
0104   if (m_doSys[CTP])
0105     produces<CSCCorrelatedLCTDigiCollection>(instName[CTP][0]);
0106   if (m_doSys[CTF])
0107     produces<L1MuRegionalCandCollection>(instName[CTF][0]);
0108   if (m_doSys[CTF])
0109     produces<L1CSCTrackCollection>(instName[CTF][1]);
0110   if (m_doSys[RPC])
0111     produces<L1MuRegionalCandCollection>(instName[RPC][0]);
0112   if (m_doSys[RPC])
0113     produces<L1MuRegionalCandCollection>(instName[RPC][1]);
0114   if (m_doSys[LTC])
0115     produces<LTCDigiCollection>(instName[LTC][0]);
0116   if (m_doSys[GMT])
0117     produces<L1MuGMTCandCollection>(instName[GMT][0]);
0118   if (m_doSys[GMT])
0119     produces<L1MuGMTReadoutCollection>(instName[GMT][0]);
0120   if (m_doSys[GLT])
0121     produces<L1GlobalTriggerReadoutRecord>(instName[GLT][0]);
0122   if (m_doSys[GLT])
0123     produces<L1GlobalTriggerEvmReadoutRecord>(instName[GLT][0]);
0124   if (m_doSys[GLT])
0125     produces<L1GlobalTriggerObjectMapRecord>(instName[GLT][0]);
0126 
0127   edm::Service<edm::RandomNumberGenerator> rng;
0128   if (!rng.isAvailable()) {
0129     throw cms::Exception("Configuration")
0130         << "L1EmulBias requires the RandomNumberGeneratorService\n"
0131            "which is not present in the configuration file.  You must add the service\n"
0132            "in the configuration file or remove the modules that require it.";
0133   }
0134 
0135   if (verbose())
0136     std::cout << "L1EmulBias::L1EmulBias()... done." << std::endl;
0137 }
0138 
0139 L1EmulBias::~L1EmulBias() {}
0140 
0141 // ------------ method called to produce the data  ------------
0142 void L1EmulBias::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0143   edm::Service<edm::RandomNumberGenerator> rng;
0144   CLHEP::HepRandomEngine* engine = &rng->getEngine(iEvent.streamID());
0145 
0146   if (verbose())
0147     std::cout << "L1EmulBias::produce...\n" << std::flush;
0148 
0149   /// list the emulated collections
0150   edm::Handle<EcalTrigPrimDigiCollection> ecal_tp_emul;
0151   edm::Handle<HcalTrigPrimDigiCollection> hcal_tp_emul;
0152   edm::Handle<L1CaloEmCollection> rct_em_emul;
0153   edm::Handle<L1CaloRegionCollection> rct_rgn_emul;
0154   edm::Handle<L1GctEmCandCollection> gct_isolaem_emul;
0155   edm::Handle<L1GctEmCandCollection> gct_noisoem_emul;
0156   edm::Handle<L1GctJetCandCollection> gct_cenjets_emul;
0157   edm::Handle<L1GctJetCandCollection> gct_forjets_emul;
0158   edm::Handle<L1GctJetCandCollection> gct_taujets_emul;
0159   edm::Handle<L1MuDTChambPhContainer> dtp_ph_emul;
0160   edm::Handle<L1MuDTChambThContainer> dtp_th_emul;
0161   edm::Handle<L1MuRegionalCandCollection> dtf_emul;
0162   edm::Handle<L1MuDTTrackContainer> dtf_trk_emul;
0163   edm::Handle<CSCCorrelatedLCTDigiCollection> ctp_emul;
0164   edm::Handle<L1MuRegionalCandCollection> ctf_emul;
0165   edm::Handle<L1CSCTrackCollection> ctf_trk_emul;
0166   edm::Handle<L1MuRegionalCandCollection> rpc_cen_emul;
0167   edm::Handle<L1MuRegionalCandCollection> rpc_for_emul;
0168   edm::Handle<LTCDigiCollection> ltc_emul;
0169   edm::Handle<L1MuGMTCandCollection> gmt_emul;
0170   edm::Handle<L1MuGMTReadoutCollection> gmt_rdt_emul;
0171   edm::Handle<L1GlobalTriggerReadoutRecord> gt_em_emul;
0172   edm::Handle<L1GlobalTriggerReadoutRecord> glt_rdt_emul;
0173   edm::Handle<L1GlobalTriggerEvmReadoutRecord> glt_evm_emul;
0174   edm::Handle<L1GlobalTriggerObjectMapRecord> glt_obj_emul;
0175 
0176   /// get the emulated collections
0177   if (m_doSys[ETP])
0178     iEvent.getByLabel(m_DEsource[ETP][0].label(), instName[ETP][0], ecal_tp_emul);
0179   if (m_doSys[HTP])
0180     iEvent.getByLabel(m_DEsource[HTP][0].label(), instName[HTP][0], hcal_tp_emul);
0181   if (m_doSys[RCT])
0182     iEvent.getByLabel(m_DEsource[RCT][0].label(), instName[RCT][0], rct_em_emul);
0183   if (m_doSys[RCT])
0184     iEvent.getByLabel(m_DEsource[RCT][0].label(), instName[RCT][0], rct_rgn_emul);
0185   if (m_doSys[GCT])
0186     iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][0], gct_isolaem_emul);
0187   if (m_doSys[GCT])
0188     iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][1], gct_noisoem_emul);
0189   if (m_doSys[GCT])
0190     iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][2], gct_cenjets_emul);
0191   if (m_doSys[GCT])
0192     iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][3], gct_forjets_emul);
0193   if (m_doSys[GCT])
0194     iEvent.getByLabel(m_DEsource[GCT][0].label(), instName[GCT][4], gct_taujets_emul);
0195   if (m_doSys[DTP])
0196     iEvent.getByLabel(m_DEsource[DTP][0].label(), instName[DTP][0], dtp_ph_emul);
0197   if (m_doSys[DTP])
0198     iEvent.getByLabel(m_DEsource[DTP][0].label(), instName[DTP][0], dtp_th_emul);
0199   if (m_doSys[DTF])
0200     iEvent.getByLabel(m_DEsource[DTF][0].label(), instName[DTF][0], dtf_emul);
0201   if (m_doSys[DTF])
0202     iEvent.getByLabel(m_DEsource[DTF][0].label(), instName[DTF][1], dtf_trk_emul);
0203   if (m_doSys[CTP])
0204     iEvent.getByLabel(m_DEsource[CTP][0].label(), instName[CTP][0], ctp_emul);
0205   if (m_doSys[CTF])
0206     iEvent.getByLabel(m_DEsource[CTF][0].label(), instName[CTF][0], ctf_emul);
0207   if (m_doSys[CTF])
0208     iEvent.getByLabel(m_DEsource[CTF][1].label(), instName[CTF][1], ctf_trk_emul);
0209   if (m_doSys[RPC])
0210     iEvent.getByLabel(m_DEsource[RPC][0].label(), instName[RPC][0], rpc_cen_emul);
0211   if (m_doSys[RPC])
0212     iEvent.getByLabel(m_DEsource[RPC][0].label(), instName[RPC][1], rpc_for_emul);
0213   if (m_doSys[LTC])
0214     iEvent.getByLabel(m_DEsource[LTC][0].label(), instName[LTC][0], ltc_emul);
0215   if (m_doSys[GMT])
0216     iEvent.getByLabel(m_DEsource[GMT][0].label(), instName[GMT][0], gmt_emul);
0217   if (m_doSys[GMT])
0218     iEvent.getByLabel(m_DEsource[GMT][0].label(), instName[GMT][0], gmt_rdt_emul);
0219   if (m_doSys[GLT])
0220     iEvent.getByLabel(m_DEsource[GLT][0].label(), instName[GLT][0], glt_rdt_emul);
0221   if (m_doSys[GLT])
0222     iEvent.getByLabel(m_DEsource[GLT][0].label(), instName[GLT][0], glt_evm_emul);
0223   if (m_doSys[GLT])
0224     iEvent.getByLabel(m_DEsource[GLT][0].label(), instName[GLT][0], glt_obj_emul);
0225 
0226   /// assert collection validity
0227   if (m_doSys[ETP])
0228     assert(ecal_tp_emul.isValid());
0229   if (m_doSys[HTP])
0230     assert(hcal_tp_emul.isValid());
0231   if (m_doSys[RCT])
0232     assert(rct_em_emul.isValid());
0233   if (m_doSys[RCT])
0234     assert(rct_rgn_emul.isValid());
0235   if (m_doSys[GCT])
0236     assert(gct_isolaem_emul.isValid());
0237   if (m_doSys[GCT])
0238     assert(gct_noisoem_emul.isValid());
0239   if (m_doSys[GCT])
0240     assert(gct_cenjets_emul.isValid());
0241   if (m_doSys[GCT])
0242     assert(gct_forjets_emul.isValid());
0243   if (m_doSys[GCT])
0244     assert(gct_taujets_emul.isValid());
0245   if (m_doSys[DTP])
0246     assert(dtp_ph_emul.isValid());
0247   if (m_doSys[DTP])
0248     assert(dtp_th_emul.isValid());
0249   if (m_doSys[DTF])
0250     assert(dtf_emul.isValid());
0251   if (m_doSys[DTF])
0252     assert(dtf_trk_emul.isValid());
0253   if (m_doSys[CTP])
0254     assert(ctp_emul.isValid());
0255   if (m_doSys[CTF])
0256     assert(ctf_emul.isValid());
0257   if (m_doSys[CTF])
0258     assert(ctf_trk_emul.isValid());
0259   if (m_doSys[RPC])
0260     assert(rpc_cen_emul.isValid());
0261   if (m_doSys[RPC])
0262     assert(rpc_for_emul.isValid());
0263   if (m_doSys[LTC])
0264     assert(ltc_emul.isValid());
0265   if (m_doSys[GMT])
0266     assert(gmt_emul.isValid());
0267   if (m_doSys[GMT])
0268     assert(gmt_rdt_emul.isValid());
0269   if (m_doSys[GLT])
0270     assert(glt_rdt_emul.isValid());
0271   if (m_doSys[GLT])
0272     assert(glt_evm_emul.isValid());
0273   if (m_doSys[GLT])
0274     assert(glt_obj_emul.isValid());
0275 
0276   /// declare the data collections
0277   std::unique_ptr<EcalTrigPrimDigiCollection> ecal_tp_data(new EcalTrigPrimDigiCollection);
0278   std::unique_ptr<HcalTrigPrimDigiCollection> hcal_tp_data(new HcalTrigPrimDigiCollection);
0279   std::unique_ptr<L1CaloEmCollection> rct_em_data(new L1CaloEmCollection);
0280   std::unique_ptr<L1CaloRegionCollection> rct_rgn_data(new L1CaloRegionCollection);
0281   std::unique_ptr<L1GctEmCandCollection> gct_isolaem_data(new L1GctEmCandCollection);
0282   std::unique_ptr<L1GctEmCandCollection> gct_noisoem_data(new L1GctEmCandCollection);
0283   std::unique_ptr<L1GctJetCandCollection> gct_cenjets_data(new L1GctJetCandCollection);
0284   std::unique_ptr<L1GctJetCandCollection> gct_forjets_data(new L1GctJetCandCollection);
0285   std::unique_ptr<L1GctJetCandCollection> gct_taujets_data(new L1GctJetCandCollection);
0286   std::unique_ptr<L1MuDTChambPhContainer> dtp_ph_data(new L1MuDTChambPhContainer);
0287   std::unique_ptr<L1MuDTChambThContainer> dtp_th_data(new L1MuDTChambThContainer);
0288   std::unique_ptr<L1MuRegionalCandCollection> dtf_data(new L1MuRegionalCandCollection);
0289   std::unique_ptr<L1MuDTTrackContainer> dtf_trk_data(new L1MuDTTrackContainer);
0290   std::unique_ptr<CSCCorrelatedLCTDigiCollection> ctp_data(new CSCCorrelatedLCTDigiCollection);
0291   std::unique_ptr<L1MuRegionalCandCollection> ctf_data(new L1MuRegionalCandCollection);
0292   std::unique_ptr<L1CSCTrackCollection> ctf_trk_data(new L1CSCTrackCollection);
0293   std::unique_ptr<L1MuRegionalCandCollection> rpc_cen_data(new L1MuRegionalCandCollection);
0294   std::unique_ptr<L1MuRegionalCandCollection> rpc_for_data(new L1MuRegionalCandCollection);
0295   std::unique_ptr<LTCDigiCollection> ltc_data(new LTCDigiCollection);
0296   std::unique_ptr<L1MuGMTCandCollection> gmt_data(new L1MuGMTCandCollection);
0297   std::unique_ptr<L1MuGMTReadoutCollection> gmt_rdt_data(new L1MuGMTReadoutCollection);
0298   std::unique_ptr<L1GlobalTriggerReadoutRecord> glt_rdt_data(new L1GlobalTriggerReadoutRecord);
0299   std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> glt_evm_data(new L1GlobalTriggerEvmReadoutRecord);
0300   std::unique_ptr<L1GlobalTriggerObjectMapRecord> glt_obj_data(new L1GlobalTriggerObjectMapRecord);
0301 
0302   if (verbose())
0303     std::cout << "L1EmulBias::produce - modify...\n" << std::flush;
0304 
0305   /// fill data as modified emul collections
0306   if (m_doSys[ETP])
0307     ModifyCollection(ecal_tp_data, ecal_tp_emul, engine);
0308   if (m_doSys[HTP])
0309     ModifyCollection(hcal_tp_data, hcal_tp_emul, engine);
0310   if (m_doSys[RCT])
0311     ModifyCollection(rct_em_data, rct_em_emul, engine);
0312   if (m_doSys[RCT])
0313     ModifyCollection(rct_rgn_data, rct_rgn_emul, engine);
0314   if (m_doSys[GCT])
0315     ModifyCollection(gct_isolaem_data, gct_isolaem_emul, engine);
0316   if (m_doSys[GCT])
0317     ModifyCollection(gct_noisoem_data, gct_noisoem_emul, engine);
0318   if (m_doSys[GCT])
0319     ModifyCollection(gct_cenjets_data, gct_cenjets_emul, engine);
0320   if (m_doSys[GCT])
0321     ModifyCollection(gct_forjets_data, gct_forjets_emul, engine);
0322   if (m_doSys[GCT])
0323     ModifyCollection(gct_taujets_data, gct_taujets_emul, engine);
0324   if (m_doSys[DTP])
0325     ModifyCollection(dtp_ph_data, dtp_ph_emul, engine);
0326   if (m_doSys[DTP])
0327     ModifyCollection(dtp_th_data, dtp_th_emul, engine);
0328   if (m_doSys[DTF])
0329     ModifyCollection(dtf_data, dtf_emul, engine);
0330   if (m_doSys[DTF])
0331     ModifyCollection(dtf_trk_data, dtf_trk_emul, engine);
0332   if (m_doSys[CTP])
0333     ModifyCollection(ctp_data, ctp_emul, engine);
0334   if (m_doSys[CTF])
0335     ModifyCollection(ctf_data, ctf_emul, engine);
0336   if (m_doSys[CTF])
0337     ModifyCollection(ctf_trk_data, ctf_trk_emul, engine);
0338   if (m_doSys[RPC])
0339     ModifyCollection(rpc_cen_data, rpc_cen_emul, engine);
0340   if (m_doSys[RPC])
0341     ModifyCollection(rpc_for_data, rpc_for_emul, engine);
0342   if (m_doSys[LTC])
0343     ModifyCollection(ltc_data, ltc_emul, engine);
0344   if (m_doSys[GMT])
0345     ModifyCollection(gmt_data, gmt_emul, engine);
0346   if (m_doSys[GMT])
0347     ModifyCollection(gmt_rdt_data, gmt_rdt_emul, engine);
0348   if (m_doSys[GLT])
0349     ModifyCollection(glt_rdt_data, glt_rdt_emul, engine);
0350   if (m_doSys[GLT])
0351     ModifyCollection(glt_evm_data, glt_evm_emul, engine);
0352   if (m_doSys[GLT])
0353     ModifyCollection(glt_obj_data, glt_obj_emul, engine);
0354 
0355   if (verbose())
0356     std::cout << "L1EmulBias::produce - put...\n" << std::flush;
0357 
0358   /// append data into event
0359   if (m_doSys[ETP])
0360     iEvent.put(std::move(ecal_tp_data), instName[ETP][0]);
0361   if (m_doSys[HTP])
0362     iEvent.put(std::move(hcal_tp_data), instName[HTP][0]);
0363   if (m_doSys[RCT])
0364     iEvent.put(std::move(rct_em_data), instName[RCT][0]);
0365   if (m_doSys[RCT])
0366     iEvent.put(std::move(rct_rgn_data), instName[RCT][0]);
0367   if (m_doSys[GCT])
0368     iEvent.put(std::move(gct_isolaem_data), instName[GCT][0]);
0369   if (m_doSys[GCT])
0370     iEvent.put(std::move(gct_noisoem_data), instName[GCT][1]);
0371   if (m_doSys[GCT])
0372     iEvent.put(std::move(gct_cenjets_data), instName[GCT][2]);
0373   if (m_doSys[GCT])
0374     iEvent.put(std::move(gct_forjets_data), instName[GCT][3]);
0375   if (m_doSys[GCT])
0376     iEvent.put(std::move(gct_taujets_data), instName[GCT][4]);
0377   if (m_doSys[DTP])
0378     iEvent.put(std::move(dtp_ph_data), instName[DTP][0]);
0379   if (m_doSys[DTP])
0380     iEvent.put(std::move(dtp_th_data), instName[DTP][0]);
0381   if (m_doSys[DTF])
0382     iEvent.put(std::move(dtf_data), instName[DTF][0]);
0383   if (m_doSys[DTF])
0384     iEvent.put(std::move(dtf_trk_data), instName[DTF][1]);
0385   if (m_doSys[CTP])
0386     iEvent.put(std::move(ctp_data), instName[CTP][0]);
0387   if (m_doSys[CTF])
0388     iEvent.put(std::move(ctf_data), instName[CTF][0]);
0389   if (m_doSys[CTF])
0390     iEvent.put(std::move(ctf_trk_data), instName[CTF][1]);
0391   if (m_doSys[RPC])
0392     iEvent.put(std::move(rpc_cen_data), instName[RPC][0]);
0393   if (m_doSys[RPC])
0394     iEvent.put(std::move(rpc_for_data), instName[RPC][1]);
0395   if (m_doSys[LTC])
0396     iEvent.put(std::move(ltc_data), instName[LTC][0]);
0397   if (m_doSys[GMT])
0398     iEvent.put(std::move(gmt_data), instName[GMT][0]);
0399   if (m_doSys[GMT])
0400     iEvent.put(std::move(gmt_rdt_data), instName[GMT][0]);
0401   if (m_doSys[GLT])
0402     iEvent.put(std::move(glt_rdt_data), instName[GLT][0]);
0403   if (m_doSys[GLT])
0404     iEvent.put(std::move(glt_evm_data), instName[GLT][0]);
0405   if (m_doSys[GLT])
0406     iEvent.put(std::move(glt_obj_data), instName[GLT][0]);
0407 
0408   if (verbose())
0409     std::cout << "L1EmulBias::produce...done.\n" << std::flush;
0410 }