Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:11

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