File indexing completed on 2024-04-06 12:21:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021 #include <iostream>
0022
0023
0024 #include "FWCore/Framework/interface/EventSetup.h"
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 #include "FWCore/Framework/interface/stream/EDProducer.h"
0027 #include "FWCore/Framework/interface/ESHandle.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 #include "FWCore/Utilities/interface/EDGetToken.h"
0032 #include "FWCore/Utilities/interface/EDPutToken.h"
0033 #include "FWCore/Utilities/interface/InputTag.h"
0034 #include "FWCore/Utilities/interface/ESGetToken.h"
0035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0036
0037 #include "L1Trigger/L1TCalorimeter/interface/Stage2Layer2FirmwareFactory.h"
0038 #include "L1Trigger/L1TCalorimeter/interface/Stage2MainProcessor.h"
0039 #include "L1Trigger/L1TCalorimeter/interface/CaloTools.h"
0040
0041 #include "L1Trigger/L1TCalorimeter/interface/CaloParamsHelper.h"
0042 #include "CondFormats/DataRecord/interface/L1TCaloParamsRcd.h"
0043 #include "CondFormats/DataRecord/interface/L1TCaloParamsO2ORcd.h"
0044
0045 #include "DataFormats/L1TCalorimeter/interface/CaloTower.h"
0046 #include "DataFormats/L1Trigger/interface/EGamma.h"
0047 #include "DataFormats/L1Trigger/interface/Tau.h"
0048 #include "DataFormats/L1Trigger/interface/Jet.h"
0049 #include "DataFormats/L1Trigger/interface/EtSum.h"
0050
0051 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
0052
0053
0054
0055
0056
0057 using namespace l1t;
0058
0059 class L1TZDCProducer : public edm::stream::EDProducer<> {
0060 public:
0061 explicit L1TZDCProducer(const edm::ParameterSet& ps);
0062 ~L1TZDCProducer() override = default;
0063
0064 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0065
0066 private:
0067 void produce(edm::Event&, const edm::EventSetup&) override;
0068
0069
0070
0071
0072
0073 edm::EDGetTokenT<HcalTrigPrimDigiCollection> hcalTPSource;
0074
0075
0076 int bxFirst_;
0077 int bxLast_;
0078
0079
0080 edm::EDPutTokenT<EtSumBxCollection> etToken_;
0081 };
0082
0083 L1TZDCProducer::L1TZDCProducer(const edm::ParameterSet& ps)
0084 : hcalTPSource(consumes<HcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("hcalTPDigis"))) {
0085
0086 etToken_ = produces<EtSumBxCollection>();
0087
0088 bxFirst_ = ps.getParameter<int>("bxFirst");
0089 bxLast_ = ps.getParameter<int>("bxLast");
0090 }
0091
0092
0093 void L1TZDCProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0094 using namespace edm;
0095 using namespace l1t;
0096
0097 LogDebug("L1TZDCProducer") << "L1TZDCProducer::produce function called..." << std::endl;
0098
0099
0100 EtSumBxCollection etsumsReduced(0, bxFirst_, bxLast_);
0101
0102 edm::Handle<HcalTrigPrimDigiCollection> hcalTPs;
0103 iEvent.getByToken(hcalTPSource, hcalTPs);
0104
0105
0106 if (hcalTPs.isValid()) {
0107
0108 for (const auto& hcalTp : *hcalTPs) {
0109 int ieta = hcalTp.id().ieta();
0110 uint32_t absIEta = std::abs(ieta);
0111
0112
0113 if (absIEta != 42)
0114 continue;
0115
0116 int iphi = hcalTp.id().iphi();
0117
0118 if (iphi != 99)
0119 continue;
0120
0121
0122 int nSamples = hcalTp.size();
0123 int nPresamples = hcalTp.presamples();
0124
0125 for (int ibx = 0; ibx < nSamples; ibx++) {
0126 if (ibx >= nPresamples + bxFirst_ && ibx <= nPresamples + bxLast_) {
0127 HcalTriggerPrimitiveSample hcalTpSample = hcalTp.sample(ibx);
0128 int ietIn = hcalTpSample.compressedEt();
0129
0130 l1t::EtSum tempEt = l1t::EtSum();
0131 tempEt.setHwPt(ietIn);
0132 tempEt.setHwPhi(0.);
0133
0134
0135 if (ieta < 0) {
0136 tempEt.setHwEta(-1.);
0137 tempEt.setType(EtSum::EtSumType::kZDCM);
0138 } else {
0139 tempEt.setHwEta(1.);
0140 tempEt.setType(EtSum::EtSumType::kZDCP);
0141 }
0142
0143
0144 etsumsReduced.push_back(ibx - nPresamples, CaloTools::etSumP4Demux(tempEt));
0145 }
0146 }
0147 }
0148 } else {
0149
0150 edm::LogWarning("L1TZDCProducer") << "hcalTps not valid; return empty ZDC Et Sum BXCollection" << std::endl;
0151 }
0152
0153
0154
0155 iEvent.emplace(etToken_, std::move(etsumsReduced));
0156 }
0157
0158
0159 void L1TZDCProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0160 edm::ParameterSetDescription desc;
0161 desc.add<edm::InputTag>("hcalTPDigis", edm::InputTag("simHcalTriggerPrimitiveDigis"));
0162 desc.add<int>("bxFirst", -2);
0163 desc.add<int>("bxLast", 2);
0164 descriptions.add("l1tZDCProducer", desc);
0165 }
0166
0167
0168 DEFINE_FWK_MODULE(L1TZDCProducer);