Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 ///
0002 /// \class l1t::FakeInputProducer
0003 ///
0004 /// Description: Create Fake Input Collections for the GT.  Allows testing of emulation
0005 ///
0006 ///
0007 /// \author: B. Winer OSU
0008 ///
0009 ///  Modeled after FakeInputProducer
0010 
0011 // system include files
0012 #include <memory>
0013 
0014 // user include files
0015 
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 #include "FWCore/Framework/interface/Frameworkfwd.h"
0018 #include "FWCore/Framework/interface/global/EDProducer.h"
0019 #include "FWCore/Framework/interface/Event.h"
0020 #include "FWCore/Framework/interface/MakerMacros.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 #include "FWCore/Utilities/interface/EDGetToken.h"
0023 #include "FWCore/Utilities/interface/InputTag.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 
0026 //#include <vector>
0027 #include "DataFormats/L1Trigger/interface/BXVector.h"
0028 
0029 #include "DataFormats/L1Trigger/interface/EGamma.h"
0030 #include "DataFormats/L1Trigger/interface/Muon.h"
0031 #include "DataFormats/L1Trigger/interface/Tau.h"
0032 #include "DataFormats/L1Trigger/interface/Jet.h"
0033 #include "DataFormats/L1Trigger/interface/EtSum.h"
0034 
0035 using namespace std;
0036 using namespace edm;
0037 
0038 namespace l1t {
0039 
0040   //
0041   // class declaration
0042   //
0043 
0044   class FakeInputProducer : public global::EDProducer<> {
0045   public:
0046     explicit FakeInputProducer(const ParameterSet&);
0047     ~FakeInputProducer() override;
0048 
0049     static void fillDescriptions(ConfigurationDescriptions& descriptions);
0050 
0051   private:
0052     void produce(StreamID, Event&, EventSetup const&) const override;
0053 
0054     // ----------member data ---------------------------
0055     //std::shared_ptr<const CaloParams> m_dbpars; // Database parameters for the trigger, to be updated as needed.
0056     //std::shared_ptr<const FirmwareVersion> m_fwv;
0057     //std::shared_ptr<FirmwareVersion> m_fwv; //not const during testing.
0058 
0059     // Parameters for EG
0060     std::vector<int> fEgBx;
0061     std::vector<int> fEgHwPt;
0062     std::vector<int> fEgHwPhi;
0063     std::vector<int> fEgHwEta;
0064     std::vector<int> fEgIso;
0065 
0066     // Parameters for Mu
0067     std::vector<int> fMuBx;
0068     std::vector<int> fMuHwPt;
0069     std::vector<int> fMuHwPhi;
0070     std::vector<int> fMuHwEta;
0071     std::vector<int> fMuIso;
0072 
0073     // Parameters for Tau
0074     std::vector<int> fTauBx;
0075     std::vector<int> fTauHwPt;
0076     std::vector<int> fTauHwPhi;
0077     std::vector<int> fTauHwEta;
0078     std::vector<int> fTauIso;
0079 
0080     // Parameters for Jet
0081     std::vector<int> fJetBx;
0082     std::vector<int> fJetHwPt;
0083     std::vector<int> fJetHwPhi;
0084     std::vector<int> fJetHwEta;
0085 
0086     // Parameters for EtSum
0087     std::vector<int> fEtSumBx;
0088     std::vector<int> fEtSumHwPt;
0089     std::vector<int> fEtSumHwPhi;
0090   };
0091 
0092   //
0093   // constructors and destructor
0094   //
0095   FakeInputProducer::FakeInputProducer(const ParameterSet& iConfig) {
0096     // register what you produce
0097     produces<BXVector<l1t::EGamma>>();
0098     produces<BXVector<l1t::Muon>>();
0099     produces<BXVector<l1t::Tau>>();
0100     produces<BXVector<l1t::Jet>>();
0101     produces<BXVector<l1t::EtSum>>();
0102 
0103     // Setup Parameter Set for EG
0104     ParameterSet eg_params = iConfig.getUntrackedParameter<ParameterSet>("egParams");
0105 
0106     fEgBx = eg_params.getUntrackedParameter<vector<int>>("egBx");
0107     fEgHwPt = eg_params.getUntrackedParameter<vector<int>>("egHwPt");
0108     fEgHwPhi = eg_params.getUntrackedParameter<vector<int>>("egHwPhi");
0109     fEgHwEta = eg_params.getUntrackedParameter<vector<int>>("egHwEta");
0110     fEgIso = eg_params.getUntrackedParameter<vector<int>>("egIso");
0111 
0112     // Setup Parameter Set for Muon
0113     ParameterSet mu_params = iConfig.getUntrackedParameter<ParameterSet>("muParams");
0114 
0115     fMuBx = mu_params.getUntrackedParameter<vector<int>>("muBx");
0116     fMuHwPt = mu_params.getUntrackedParameter<vector<int>>("muHwPt");
0117     fMuHwPhi = mu_params.getUntrackedParameter<vector<int>>("muHwPhi");
0118     fMuHwEta = mu_params.getUntrackedParameter<vector<int>>("muHwEta");
0119     fMuIso = mu_params.getUntrackedParameter<vector<int>>("muIso");
0120 
0121     // Setup Parameter Set for taus
0122     ParameterSet tau_params = iConfig.getUntrackedParameter<ParameterSet>("tauParams");
0123 
0124     fTauBx = tau_params.getUntrackedParameter<vector<int>>("tauBx");
0125     fTauHwPt = tau_params.getUntrackedParameter<vector<int>>("tauHwPt");
0126     fTauHwPhi = tau_params.getUntrackedParameter<vector<int>>("tauHwPhi");
0127     fTauHwEta = tau_params.getUntrackedParameter<vector<int>>("tauHwEta");
0128     fTauIso = tau_params.getUntrackedParameter<vector<int>>("tauIso");
0129 
0130     // Setup Parameter Set for jet
0131     ParameterSet jet_params = iConfig.getUntrackedParameter<ParameterSet>("jetParams");
0132 
0133     fJetBx = jet_params.getUntrackedParameter<vector<int>>("jetBx");
0134     fJetHwPt = jet_params.getUntrackedParameter<vector<int>>("jetHwPt");
0135     fJetHwPhi = jet_params.getUntrackedParameter<vector<int>>("jetHwPhi");
0136     fJetHwEta = jet_params.getUntrackedParameter<vector<int>>("jetHwEta");
0137 
0138     // Setup Parameter Set for EtSums
0139     ParameterSet etsum_params = iConfig.getUntrackedParameter<ParameterSet>("etsumParams");
0140 
0141     fEtSumBx = etsum_params.getUntrackedParameter<vector<int>>("etsumBx");
0142     fEtSumHwPt = etsum_params.getUntrackedParameter<vector<int>>("etsumHwPt");
0143     fEtSumHwPhi = etsum_params.getUntrackedParameter<vector<int>>("etsumHwPhi");
0144   }
0145 
0146   FakeInputProducer::~FakeInputProducer() {}
0147 
0148   //
0149   // member functions
0150   //
0151 
0152   // ------------ method called to produce the data ------------
0153   void FakeInputProducer::produce(StreamID, Event& iEvent, const EventSetup& iSetup) const {
0154     LogDebug("l1t|Global") << "FakeInputProducer::produce function called...\n";
0155 
0156     // Set the range of BX....TO DO...move to Params or determine from param set.
0157     int bxFirst = -2;
0158     int bxLast = 2;
0159 
0160     //outputs
0161     std::unique_ptr<l1t::EGammaBxCollection> egammas(new l1t::EGammaBxCollection(0, bxFirst, bxLast));
0162     std::unique_ptr<l1t::MuonBxCollection> muons(new l1t::MuonBxCollection(0, bxFirst, bxLast));
0163     std::unique_ptr<l1t::TauBxCollection> taus(new l1t::TauBxCollection(0, bxFirst, bxLast));
0164     std::unique_ptr<l1t::JetBxCollection> jets(new l1t::JetBxCollection(0, bxFirst, bxLast));
0165     std::unique_ptr<l1t::EtSumBxCollection> etsums(new l1t::EtSumBxCollection(0, bxFirst, bxLast));
0166 
0167     // Put EG into Collections
0168     for (unsigned int it = 0; it < fEgBx.size(); it++) {
0169       ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>* egLorentz =
0170           new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>();
0171       l1t::EGamma fakeEG(*egLorentz, fEgHwPt.at(it), fEgHwEta.at(it), fEgHwPhi.at(it), 0, fEgIso.at(it));
0172       egammas->push_back(fEgBx.at(it), fakeEG);
0173     }
0174 
0175     // Put Muons into Collections
0176     for (unsigned int it = 0; it < fMuBx.size(); it++) {
0177       ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>* muLorentz =
0178           new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>();
0179       l1t::Muon fakeMU(*muLorentz, fMuHwPt.at(it), fMuHwEta.at(it), fMuHwPhi.at(it), 4, 0, 0, fMuIso.at(it));
0180       muons->push_back(fMuBx.at(it), fakeMU);
0181     }
0182 
0183     // Put Taus into Collections
0184     for (unsigned int it = 0; it < fTauBx.size(); it++) {
0185       ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>* tauLorentz =
0186           new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>();
0187       l1t::Tau fakeTAU(*tauLorentz, fTauHwPt.at(it), fTauHwEta.at(it), fTauHwPhi.at(it), 0, fTauIso.at(it));
0188       taus->push_back(fTauBx.at(it), fakeTAU);
0189     }
0190 
0191     // Put Jets into Collections
0192     for (unsigned int it = 0; it < fJetBx.size(); it++) {
0193       ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>* jetLorentz =
0194           new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>();
0195       l1t::Jet fakeJET(*jetLorentz, fJetHwPt.at(it), fJetHwEta.at(it), fJetHwPhi.at(it), 0);
0196       jets->push_back(fJetBx.at(it), fakeJET);
0197     }
0198 
0199     // Put EtSums into Collections
0200     for (unsigned int it = 0; it < fEtSumBx.size(); it++) {
0201       ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>* etsumLorentz =
0202           new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>>();
0203       l1t::EtSum fakeETSUM(
0204           *etsumLorentz, l1t::EtSum::EtSumType::kMissingEt, fEtSumHwPt.at(it), 0, fEtSumHwPhi.at(it), 0);
0205       etsums->push_back(fEtSumBx.at(it), fakeETSUM);
0206     }
0207 
0208     iEvent.put(std::move(egammas));
0209     iEvent.put(std::move(muons));
0210     iEvent.put(std::move(taus));
0211     iEvent.put(std::move(jets));
0212     iEvent.put(std::move(etsums));
0213   }
0214 
0215   // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
0216   void FakeInputProducer::fillDescriptions(ConfigurationDescriptions& descriptions) {
0217     //The following says we do not know what parameters are allowed so do no validation
0218     // Please change this to state exactly what you do use, even if it is no parameters
0219     ParameterSetDescription desc;
0220     desc.setUnknown();
0221     descriptions.addDefault(desc);
0222   }
0223 
0224 }  // namespace l1t
0225 
0226 //define this as a plug-in
0227 DEFINE_FWK_MODULE(l1t::FakeInputProducer);