Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:53

0001 #include "L1Trigger/GlobalCaloTrigger/test/FakeGctInputProducer.h"
0002 
0003 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0004 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
0005 
0006 #include <memory>
0007 #include <iostream>
0008 
0009 FakeGctInputProducer::FakeGctInputProducer(const edm::ParameterSet& iConfig) {
0010   produces<L1CaloEmCollection>();
0011   produces<L1CaloRegionCollection>();
0012 
0013   rgnMode_ = iConfig.getUntrackedParameter<int>("regionMode", 0);
0014   iemMode_ = iConfig.getUntrackedParameter<int>("isoEmMode", 0);
0015   niemMode_ = iConfig.getUntrackedParameter<int>("nonIsoEmMode", 0);
0016 }
0017 
0018 void FakeGctInputProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0019   using namespace edm;
0020 
0021   // containers
0022   std::unique_ptr<L1CaloEmCollection> emCands(new L1CaloEmCollection);
0023   std::unique_ptr<L1CaloRegionCollection> regions(new L1CaloRegionCollection);
0024 
0025   /// REGIONS ///
0026 
0027   // decide which region to fill for mode 1
0028   int nCrt = rand() % 18;
0029   int nCrd = rand() % 7;
0030   int nRgn = rand() % 2;
0031 
0032   //  std::cout << "Making region at crt=" << nCrt << " crd=" << nCrd << " rgn=" << nRgn << std::endl;
0033 
0034   // make regions
0035   for (int iCrt = 0; iCrt < 18; iCrt++) {
0036     for (int iCrd = 0; iCrd < 7; iCrd++) {
0037       for (int iRgn = 0; iRgn < 2; iRgn++) {
0038         unsigned et = 0;
0039 
0040         if (rgnMode_ == 1) {
0041           // throw random Et
0042           et = int(100 * rand() / (RAND_MAX + 1.));
0043         } else if (rgnMode_ == 2 && iCrt == nCrt && iCrd == nCrd && iRgn == nRgn) {
0044           et = 10;
0045         }
0046 
0047         regions->push_back(L1CaloRegion(et, false, false, false, false, iCrt, iCrd, iRgn));
0048       }
0049     }
0050   }
0051 
0052   /// ISO EM ///
0053 
0054   // decide where single candidate will go (mode 2)
0055   nCrt = rand() % 18;
0056   nCrd = rand() % 7;
0057   nRgn = rand() % 2;
0058 
0059   //  std::cout << "Making iso cand at crt=" << nCrt << " crd=" << nCrd << " rgn=" << nRgn << std::endl;
0060 
0061   // loop over crates and candidates
0062   for (int iCrt = 0; iCrt < 18; iCrt++) {
0063     for (int iCand = 0; iCand < 4; iCand++) {
0064       if (iemMode_ == 1) {
0065         // multiple EM candidates not yet implemented
0066       } else if (iemMode_ == 2) {
0067         if (iCand == 0 && iCrt == nCrt) {
0068           emCands->push_back(L1CaloEmCand(1, nRgn, nCrd, nCrt, true));
0069         } else {
0070           emCands->push_back(L1CaloEmCand(0, 0, iCand, iCrt, true));
0071         }
0072       }
0073     }
0074   }
0075 
0076   /// NON-ISO EM ///
0077 
0078   // decide where single candidate will go (mode 2)
0079   nCrt = rand() % 18;
0080   nCrd = rand() % 7;
0081   nRgn = rand() % 2;
0082 
0083   //  std::cout << "Making non-iso cand at crt=" << nCrt << " crd=" << nCrd << " rgn=" << nRgn << std::endl;
0084 
0085   // loop over crates and candidates
0086   for (int iCrt = 0; iCrt < 18; iCrt++) {
0087     for (int iCand = 0; iCand < 4; iCand++) {
0088       if (niemMode_ == 1) {
0089         // multiple EM candidates not yet implemented
0090       } else if (niemMode_ == 2) {
0091         if (iCand == 0 && iCrt == nCrt) {
0092           emCands->push_back(L1CaloEmCand(1, nRgn, nCrd, nCrt, false));
0093         } else {
0094           emCands->push_back(L1CaloEmCand(0, 0, iCand, iCrt, false));
0095         }
0096       }
0097     }
0098   }
0099 
0100   // put everything in the event
0101   iEvent.put(std::move(emCands));
0102   iEvent.put(std::move(regions));
0103 }