CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/L1Trigger/HardwareValidation/plugins/L1EmulBias.cc

Go to the documentation of this file.
00001 #include "L1Trigger/HardwareValidation/plugins/L1EmulBias.h"
00002 
00003 using namespace dedefs;
00004 
00005 L1EmulBias::L1EmulBias(const edm::ParameterSet& iConfig) {
00006 
00007   verbose_ = iConfig.getUntrackedParameter<int>("VerboseFlag",0);
00008 
00009   for(int sys=0; sys<DEnsys; sys++) {
00010     std::string label = SystLabel[sys] + "source";
00011     m_DEsource[sys][0] = iConfig.getParameter<edm::InputTag>(label);
00012     if(sys==CTF) {
00013       std::string label = "CTTsource";
00014       m_DEsource[sys][1] = iConfig.getParameter<edm::InputTag>(label);
00015     }
00016   }
00017   
00018   std::vector<unsigned int> compColls  
00019     = iConfig.getUntrackedParameter<std::vector<unsigned int> >("DO_SYSTEM");
00020   for(int i=0; i<DEnsys; i++)
00021     m_doSys[i] = compColls[i];
00022 
00023   if(verbose()) {
00024     std::cout << "[L1EmulBias] do sys? ";
00025     for(int i=0; i<DEnsys; i++)
00026       std::cout << m_doSys[i];
00027     std::cout << "\n\t";  
00028     for(int i=0; i<DEnsys; i++)
00029       if(m_doSys[i]) 
00030         std::cout << SystLabel[i] << " ";
00031     std::cout << std::endl;  
00032   }
00033   
00034   std::string CollInstName[DEnsys][5];
00035   for(int i=0; i<DEnsys; i++)
00036     for(int j=0; j<5; j++)
00037       CollInstName[i][j]=std::string("");
00038 
00039   CollInstName[GCT][0]+="isoEm"   ;
00040   CollInstName[GCT][1]+="nonIsoEm";
00041   CollInstName[GCT][2]+="cenJets" ;
00042   CollInstName[GCT][3]+="forJets" ;
00043   CollInstName[GCT][4]+="tauJets" ;
00044   CollInstName[DTF][0]+="DT"      ;
00045   CollInstName[DTF][1]+="DTTF"    ;
00046   CollInstName[CTF][0]+="CSC"     ;
00047   CollInstName[CTF][1]+=""        ;
00048   CollInstName[RPC][0]+="RPCb"    ;
00049   CollInstName[RPC][1]+="RPCf"    ;
00050   
00051   for(int i=0; i<DEnsys; i++)
00052     for(int j=0; j<5; j++)
00053       instName[i][j] = CollInstName[i][j];
00054   
00055   if(verbose())
00056     for(int i=0; i<DEnsys; i++)
00057       for(int j=0; j<5; j++)
00058         if(instName[i][j] != "")
00059           std::cout << "[emulbias] " << i << " " << SystLabel[i] 
00060                     << " " << j << " " << instName[i][j] 
00061                     << std::endl;  
00062   
00064   assert(ETP==0); assert(HTP==1); assert(RCT== 2); assert(GCT== 3);
00065   assert(DTP==4); assert(DTF==5); assert(CTP== 6); assert(CTF== 7);
00066   assert(RPC==8); assert(LTC==9); assert(GMT==10); assert(GLT==11);
00067 
00069   if(m_doSys[ETP])  produces<EcalTrigPrimDigiCollection>     (instName[ETP][0]);
00070   if(m_doSys[HTP])  produces<HcalTrigPrimDigiCollection>     (instName[HTP][0]);
00071   if(m_doSys[RCT])  produces<L1CaloEmCollection>             (instName[RCT][0]);
00072   if(m_doSys[RCT])  produces<L1CaloRegionCollection>         (instName[RCT][0]);
00073   if(m_doSys[GCT])  produces<L1GctEmCandCollection>          (instName[GCT][0]);
00074   if(m_doSys[GCT])  produces<L1GctEmCandCollection>          (instName[GCT][1]);
00075   if(m_doSys[GCT])  produces<L1GctJetCandCollection>         (instName[GCT][2]);
00076   if(m_doSys[GCT])  produces<L1GctJetCandCollection>         (instName[GCT][3]);
00077   if(m_doSys[GCT])  produces<L1GctJetCandCollection>         (instName[GCT][4]);
00078   if(m_doSys[DTP])  produces<L1MuDTChambPhContainer>         (instName[DTP][0]);
00079   if(m_doSys[DTP])  produces<L1MuDTChambThContainer>         (instName[DTP][0]);
00080   if(m_doSys[DTF])  produces<L1MuRegionalCandCollection>     (instName[DTF][0]);
00081   if(m_doSys[DTF])  produces<L1MuDTTrackContainer>           (instName[DTF][1]);
00082   if(m_doSys[CTP])  produces<CSCCorrelatedLCTDigiCollection> (instName[CTP][0]);
00083   if(m_doSys[CTF])  produces<L1MuRegionalCandCollection>     (instName[CTF][0]);
00084   if(m_doSys[CTF])  produces<L1CSCTrackCollection>           (instName[CTF][1]);
00085   if(m_doSys[RPC])  produces<L1MuRegionalCandCollection>     (instName[RPC][0]);
00086   if(m_doSys[RPC])  produces<L1MuRegionalCandCollection>     (instName[RPC][1]);
00087   if(m_doSys[LTC])  produces<LTCDigiCollection>              (instName[LTC][0]);
00088   if(m_doSys[GMT])  produces<L1MuGMTCandCollection>          (instName[GMT][0]);
00089   if(m_doSys[GMT])  produces<L1MuGMTReadoutCollection>       (instName[GMT][0]);
00090   if(m_doSys[GLT])  produces<L1GlobalTriggerReadoutRecord>   (instName[GLT][0]);
00091   if(m_doSys[GLT])  produces<L1GlobalTriggerEvmReadoutRecord>(instName[GLT][0]);
00092   if(m_doSys[GLT])  produces<L1GlobalTriggerObjectMapRecord> (instName[GLT][0]);
00093 
00094   edm::Service<edm::RandomNumberGenerator> rng;
00095   CLHEP::HepRandomEngine& engine = rng->getEngine();
00096   rndFlat_ = new CLHEP::RandFlat  (engine, 0., 1.);
00097   rndGaus_ = new CLHEP::RandGaussQ(engine, 0., 1.);
00098 
00099   if(verbose())
00100     std::cout << "L1EmulBias::L1EmulBias()... done." << std::endl; 
00101 }
00102   
00103 L1EmulBias::~L1EmulBias() {
00104   delete rndFlat_;
00105   delete rndGaus_;
00106 }
00107 
00108 // ------------ method called to produce the data  ------------
00109 void
00110 L1EmulBias::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00111   
00112   if(verbose())
00113     std::cout << "L1EmulBias::produce...\n" << std::flush; 
00114 
00116   edm::Handle<EcalTrigPrimDigiCollection>       ecal_tp_emul;
00117   edm::Handle<HcalTrigPrimDigiCollection>       hcal_tp_emul;
00118   edm::Handle<L1CaloEmCollection>               rct_em_emul;
00119   edm::Handle<L1CaloRegionCollection>           rct_rgn_emul;
00120   edm::Handle<L1GctEmCandCollection>            gct_isolaem_emul;
00121   edm::Handle<L1GctEmCandCollection>            gct_noisoem_emul;
00122   edm::Handle<L1GctJetCandCollection>           gct_cenjets_emul;
00123   edm::Handle<L1GctJetCandCollection>           gct_forjets_emul;
00124   edm::Handle<L1GctJetCandCollection>           gct_taujets_emul;
00125   edm::Handle<L1MuDTChambPhContainer>           dtp_ph_emul;
00126   edm::Handle<L1MuDTChambThContainer>           dtp_th_emul;
00127   edm::Handle<L1MuRegionalCandCollection>       dtf_emul;
00128   edm::Handle<L1MuDTTrackContainer>             dtf_trk_emul;
00129   edm::Handle<CSCCorrelatedLCTDigiCollection>   ctp_emul;
00130   edm::Handle<L1MuRegionalCandCollection>       ctf_emul;
00131   edm::Handle<L1CSCTrackCollection>             ctf_trk_emul;
00132   edm::Handle<L1MuRegionalCandCollection>       rpc_cen_emul;
00133   edm::Handle<L1MuRegionalCandCollection>       rpc_for_emul;
00134   edm::Handle<LTCDigiCollection>                ltc_emul;
00135   edm::Handle<L1MuGMTCandCollection>            gmt_emul;
00136   edm::Handle<L1MuGMTReadoutCollection>         gmt_rdt_emul;    
00137   edm::Handle<L1GlobalTriggerReadoutRecord>     gt_em_emul;
00138   edm::Handle<L1GlobalTriggerReadoutRecord>     glt_rdt_emul;
00139   edm::Handle<L1GlobalTriggerEvmReadoutRecord>  glt_evm_emul;
00140   edm::Handle<L1GlobalTriggerObjectMapRecord>   glt_obj_emul;
00141 
00143   if(m_doSys[ETP]) iEvent.getByLabel(m_DEsource[ETP][0].label(),instName[ETP][0],    ecal_tp_emul);
00144   if(m_doSys[HTP]) iEvent.getByLabel(m_DEsource[HTP][0].label(),instName[HTP][0],    hcal_tp_emul);
00145   if(m_doSys[RCT]) iEvent.getByLabel(m_DEsource[RCT][0].label(),instName[RCT][0],     rct_em_emul);
00146   if(m_doSys[RCT]) iEvent.getByLabel(m_DEsource[RCT][0].label(),instName[RCT][0],    rct_rgn_emul);
00147   if(m_doSys[GCT]) iEvent.getByLabel(m_DEsource[GCT][0].label(),instName[GCT][0],gct_isolaem_emul);
00148   if(m_doSys[GCT]) iEvent.getByLabel(m_DEsource[GCT][0].label(),instName[GCT][1],gct_noisoem_emul);
00149   if(m_doSys[GCT]) iEvent.getByLabel(m_DEsource[GCT][0].label(),instName[GCT][2],gct_cenjets_emul);
00150   if(m_doSys[GCT]) iEvent.getByLabel(m_DEsource[GCT][0].label(),instName[GCT][3],gct_forjets_emul);
00151   if(m_doSys[GCT]) iEvent.getByLabel(m_DEsource[GCT][0].label(),instName[GCT][4],gct_taujets_emul);
00152   if(m_doSys[DTP]) iEvent.getByLabel(m_DEsource[DTP][0].label(),instName[DTP][0],     dtp_ph_emul);
00153   if(m_doSys[DTP]) iEvent.getByLabel(m_DEsource[DTP][0].label(),instName[DTP][0],     dtp_th_emul);
00154   if(m_doSys[DTF]) iEvent.getByLabel(m_DEsource[DTF][0].label(),instName[DTF][0],        dtf_emul);
00155   if(m_doSys[DTF]) iEvent.getByLabel(m_DEsource[DTF][0].label(),instName[DTF][1],    dtf_trk_emul);
00156   if(m_doSys[CTP]) iEvent.getByLabel(m_DEsource[CTP][0].label(),instName[CTP][0],        ctp_emul);
00157   if(m_doSys[CTF]) iEvent.getByLabel(m_DEsource[CTF][0].label(),instName[CTF][0],        ctf_emul);
00158   if(m_doSys[CTF]) iEvent.getByLabel(m_DEsource[CTF][1].label(),instName[CTF][1],    ctf_trk_emul);
00159   if(m_doSys[RPC]) iEvent.getByLabel(m_DEsource[RPC][0].label(),instName[RPC][0],    rpc_cen_emul);
00160   if(m_doSys[RPC]) iEvent.getByLabel(m_DEsource[RPC][0].label(),instName[RPC][1],    rpc_for_emul);
00161   if(m_doSys[LTC]) iEvent.getByLabel(m_DEsource[LTC][0].label(),instName[LTC][0],        ltc_emul);
00162   if(m_doSys[GMT]) iEvent.getByLabel(m_DEsource[GMT][0].label(),instName[GMT][0],        gmt_emul);
00163   if(m_doSys[GMT]) iEvent.getByLabel(m_DEsource[GMT][0].label(),instName[GMT][0],    gmt_rdt_emul);
00164   if(m_doSys[GLT]) iEvent.getByLabel(m_DEsource[GLT][0].label(),instName[GLT][0],    glt_rdt_emul);
00165   if(m_doSys[GLT]) iEvent.getByLabel(m_DEsource[GLT][0].label(),instName[GLT][0],    glt_evm_emul);
00166   if(m_doSys[GLT]) iEvent.getByLabel(m_DEsource[GLT][0].label(),instName[GLT][0],    glt_obj_emul);
00167 
00169   if(m_doSys[ETP]) assert(    ecal_tp_emul.isValid());
00170   if(m_doSys[HTP]) assert(    hcal_tp_emul.isValid());
00171   if(m_doSys[RCT]) assert(     rct_em_emul.isValid());
00172   if(m_doSys[RCT]) assert(    rct_rgn_emul.isValid());
00173   if(m_doSys[GCT]) assert(gct_isolaem_emul.isValid());
00174   if(m_doSys[GCT]) assert(gct_noisoem_emul.isValid());
00175   if(m_doSys[GCT]) assert(gct_cenjets_emul.isValid());
00176   if(m_doSys[GCT]) assert(gct_forjets_emul.isValid());
00177   if(m_doSys[GCT]) assert(gct_taujets_emul.isValid());
00178   if(m_doSys[DTP]) assert(     dtp_ph_emul.isValid());
00179   if(m_doSys[DTP]) assert(     dtp_th_emul.isValid());
00180   if(m_doSys[DTF]) assert(        dtf_emul.isValid());
00181   if(m_doSys[DTF]) assert(    dtf_trk_emul.isValid());
00182   if(m_doSys[CTP]) assert(        ctp_emul.isValid());
00183   if(m_doSys[CTF]) assert(        ctf_emul.isValid());
00184   if(m_doSys[CTF]) assert(    ctf_trk_emul.isValid());
00185   if(m_doSys[RPC]) assert(    rpc_cen_emul.isValid());
00186   if(m_doSys[RPC]) assert(    rpc_for_emul.isValid());
00187   if(m_doSys[LTC]) assert(        ltc_emul.isValid());
00188   if(m_doSys[GMT]) assert(        gmt_emul.isValid());
00189   if(m_doSys[GMT]) assert(    gmt_rdt_emul.isValid());
00190   if(m_doSys[GLT]) assert(    glt_rdt_emul.isValid());
00191   if(m_doSys[GLT]) assert(    glt_evm_emul.isValid());
00192   if(m_doSys[GLT]) assert(    glt_obj_emul.isValid());
00193 
00195   std::auto_ptr<EcalTrigPrimDigiCollection>         ecal_tp_data(new EcalTrigPrimDigiCollection     );
00196   std::auto_ptr<HcalTrigPrimDigiCollection>         hcal_tp_data(new HcalTrigPrimDigiCollection     );
00197   std::auto_ptr<L1CaloEmCollection>                  rct_em_data(new L1CaloEmCollection             );
00198   std::auto_ptr<L1CaloRegionCollection>             rct_rgn_data(new L1CaloRegionCollection         );
00199   std::auto_ptr<L1GctEmCandCollection>          gct_isolaem_data(new L1GctEmCandCollection          ); 
00200   std::auto_ptr<L1GctEmCandCollection>          gct_noisoem_data(new L1GctEmCandCollection          ); 
00201   std::auto_ptr<L1GctJetCandCollection>         gct_cenjets_data(new L1GctJetCandCollection         ); 
00202   std::auto_ptr<L1GctJetCandCollection>         gct_forjets_data(new L1GctJetCandCollection         ); 
00203   std::auto_ptr<L1GctJetCandCollection>         gct_taujets_data(new L1GctJetCandCollection         ); 
00204   std::auto_ptr<L1MuDTChambPhContainer>              dtp_ph_data(new L1MuDTChambPhContainer         );
00205   std::auto_ptr<L1MuDTChambThContainer>              dtp_th_data(new L1MuDTChambThContainer         );
00206   std::auto_ptr<L1MuRegionalCandCollection>             dtf_data(new L1MuRegionalCandCollection     );
00207   std::auto_ptr<L1MuDTTrackContainer>               dtf_trk_data(new L1MuDTTrackContainer           );
00208   std::auto_ptr<CSCCorrelatedLCTDigiCollection>         ctp_data(new CSCCorrelatedLCTDigiCollection );
00209   std::auto_ptr<L1MuRegionalCandCollection>             ctf_data(new L1MuRegionalCandCollection     );
00210   std::auto_ptr<L1CSCTrackCollection>               ctf_trk_data(new L1CSCTrackCollection           );
00211   std::auto_ptr<L1MuRegionalCandCollection>         rpc_cen_data(new L1MuRegionalCandCollection     );
00212   std::auto_ptr<L1MuRegionalCandCollection>         rpc_for_data(new L1MuRegionalCandCollection     );
00213   std::auto_ptr<LTCDigiCollection>                      ltc_data(new LTCDigiCollection              );
00214   std::auto_ptr<L1MuGMTCandCollection>                  gmt_data(new L1MuGMTCandCollection          );
00215   std::auto_ptr<L1MuGMTReadoutCollection>           gmt_rdt_data(new L1MuGMTReadoutCollection       ); 
00216   std::auto_ptr<L1GlobalTriggerReadoutRecord>       glt_rdt_data(new L1GlobalTriggerReadoutRecord   );
00217   std::auto_ptr<L1GlobalTriggerEvmReadoutRecord>    glt_evm_data(new L1GlobalTriggerEvmReadoutRecord);
00218   std::auto_ptr<L1GlobalTriggerObjectMapRecord>     glt_obj_data(new L1GlobalTriggerObjectMapRecord );
00219 
00220   if(verbose())
00221     std::cout << "L1EmulBias::produce - modify...\n" << std::flush; 
00222 
00224   if(m_doSys[ETP]) ModifyCollection(    ecal_tp_data,    ecal_tp_emul);
00225   if(m_doSys[HTP]) ModifyCollection(    hcal_tp_data,    hcal_tp_emul);
00226   if(m_doSys[RCT]) ModifyCollection(     rct_em_data,     rct_em_emul);
00227   if(m_doSys[RCT]) ModifyCollection(    rct_rgn_data,    rct_rgn_emul);
00228   if(m_doSys[GCT]) ModifyCollection(gct_isolaem_data,gct_isolaem_emul);
00229   if(m_doSys[GCT]) ModifyCollection(gct_noisoem_data,gct_noisoem_emul);
00230   if(m_doSys[GCT]) ModifyCollection(gct_cenjets_data,gct_cenjets_emul);
00231   if(m_doSys[GCT]) ModifyCollection(gct_forjets_data,gct_forjets_emul);
00232   if(m_doSys[GCT]) ModifyCollection(gct_taujets_data,gct_taujets_emul);
00233   if(m_doSys[DTP]) ModifyCollection(     dtp_ph_data,     dtp_ph_emul);
00234   if(m_doSys[DTP]) ModifyCollection(     dtp_th_data,     dtp_th_emul);
00235   if(m_doSys[DTF]) ModifyCollection(        dtf_data,        dtf_emul);
00236   if(m_doSys[DTF]) ModifyCollection(    dtf_trk_data,    dtf_trk_emul);
00237   if(m_doSys[CTP]) ModifyCollection(        ctp_data,        ctp_emul);
00238   if(m_doSys[CTF]) ModifyCollection(        ctf_data,        ctf_emul);
00239   if(m_doSys[CTF]) ModifyCollection(    ctf_trk_data,    ctf_trk_emul);
00240   if(m_doSys[RPC]) ModifyCollection(    rpc_cen_data,    rpc_cen_emul);
00241   if(m_doSys[RPC]) ModifyCollection(    rpc_for_data,    rpc_for_emul);
00242   if(m_doSys[LTC]) ModifyCollection(        ltc_data,        ltc_emul);
00243   if(m_doSys[GMT]) ModifyCollection(        gmt_data,        gmt_emul);
00244   if(m_doSys[GMT]) ModifyCollection(    gmt_rdt_data,    gmt_rdt_emul);
00245   if(m_doSys[GLT]) ModifyCollection(    glt_rdt_data,    glt_rdt_emul);
00246   if(m_doSys[GLT]) ModifyCollection(    glt_evm_data,    glt_evm_emul);
00247   if(m_doSys[GLT]) ModifyCollection(    glt_obj_data,    glt_obj_emul);
00248 
00249   if(verbose())
00250     std::cout << "L1EmulBias::produce - put...\n" << std::flush; 
00251 
00253   if(m_doSys[ETP]) iEvent.put(    ecal_tp_data, instName[ETP][0]);
00254   if(m_doSys[HTP]) iEvent.put(    hcal_tp_data, instName[HTP][0]);
00255   if(m_doSys[RCT]) iEvent.put(     rct_em_data, instName[RCT][0]);
00256   if(m_doSys[RCT]) iEvent.put(    rct_rgn_data, instName[RCT][0]);
00257   if(m_doSys[GCT]) iEvent.put(gct_isolaem_data, instName[GCT][0]);
00258   if(m_doSys[GCT]) iEvent.put(gct_noisoem_data, instName[GCT][1]);
00259   if(m_doSys[GCT]) iEvent.put(gct_cenjets_data, instName[GCT][2]);
00260   if(m_doSys[GCT]) iEvent.put(gct_forjets_data, instName[GCT][3]);
00261   if(m_doSys[GCT]) iEvent.put(gct_taujets_data, instName[GCT][4]);
00262   if(m_doSys[DTP]) iEvent.put(     dtp_ph_data, instName[DTP][0]);
00263   if(m_doSys[DTP]) iEvent.put(     dtp_th_data, instName[DTP][0]);
00264   if(m_doSys[DTF]) iEvent.put(        dtf_data, instName[DTF][0]);
00265   if(m_doSys[DTF]) iEvent.put(    dtf_trk_data, instName[DTF][1]);
00266   if(m_doSys[CTP]) iEvent.put(        ctp_data, instName[CTP][0]);
00267   if(m_doSys[CTF]) iEvent.put(        ctf_data, instName[CTF][0]);
00268   if(m_doSys[CTF]) iEvent.put(    ctf_trk_data, instName[CTF][1]);
00269   if(m_doSys[RPC]) iEvent.put(    rpc_cen_data, instName[RPC][0]);
00270   if(m_doSys[RPC]) iEvent.put(    rpc_for_data, instName[RPC][1]);
00271   if(m_doSys[LTC]) iEvent.put(        ltc_data, instName[LTC][0]);
00272   if(m_doSys[GMT]) iEvent.put(        gmt_data, instName[GMT][0]);
00273   if(m_doSys[GMT]) iEvent.put(    gmt_rdt_data, instName[GMT][0]);
00274   if(m_doSys[GLT]) iEvent.put(    glt_rdt_data, instName[GLT][0]);
00275   if(m_doSys[GLT]) iEvent.put(    glt_evm_data, instName[GLT][0]);
00276   if(m_doSys[GLT]) iEvent.put(    glt_obj_data, instName[GLT][0]);
00277 
00278   if(verbose())
00279     std::cout << "L1EmulBias::produce...done.\n" << std::flush; 
00280 
00281 }