File indexing completed on 2024-04-06 12:10:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <memory>
0015
0016
0017 #include "EventFilter/GctRawToDigi/plugins/L1GctInternJetProducer.h"
0018
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/MakerMacros.h"
0021
0022 #include "DataFormats/Common/interface/Handle.h"
0023 #include "FWCore/Framework/interface/ESHandle.h"
0024 #include "DataFormats/Common/interface/OrphanHandle.h"
0025
0026 L1GctInternJetProducer::L1GctInternJetProducer(const edm::ParameterSet& iConfig)
0027 : internalJetSource_(iConfig.getParameter<edm::InputTag>("internalJetSource")),
0028 caloGeomToken_(esConsumes<L1CaloGeometry, L1CaloGeometryRecord>()),
0029 jetScaleToken_(esConsumes<L1CaloEtScale, L1JetEtScaleRcd>()),
0030 centralBxOnly_(iConfig.getParameter<bool>("centralBxOnly")) {
0031 using namespace l1extra;
0032
0033 produces<L1JetParticleCollection>("Internal");
0034 }
0035
0036 void L1GctInternJetProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0037
0038 using namespace edm;
0039 using namespace l1extra;
0040 using namespace std;
0041
0042 unique_ptr<L1JetParticleCollection> internJetColl(new L1JetParticleCollection);
0043
0044 ESHandle<L1CaloGeometry> caloGeomESH = iSetup.getHandle(caloGeomToken_);
0045 const L1CaloGeometry* caloGeom = &(*caloGeomESH);
0046
0047 ESHandle<L1CaloEtScale> jetScale = iSetup.getHandle(jetScaleToken_);
0048
0049 double etSumLSB = jetScale->linearLsb();
0050
0051
0052 Handle<L1GctInternJetDataCollection> hwIntJetCands;
0053 iEvent.getByLabel(internalJetSource_, hwIntJetCands);
0054
0055 if (!hwIntJetCands.isValid()) {
0056 std::cout << "These aren't the Jets you're looking for" << std::endl;
0057
0058 LogDebug("L1GctInternJetProducer") << "\nWarning: L1GctJetCandCollection with " << internalJetSource_
0059 << "\nrequested in configuration, but not found in the event." << std::endl;
0060
0061 } else {
0062
0063 L1GctInternJetDataCollection::const_iterator jetItr = hwIntJetCands->begin();
0064 L1GctInternJetDataCollection::const_iterator jetEnd = hwIntJetCands->end();
0065 int i;
0066 for (i = 0; jetItr != jetEnd; ++jetItr, ++i) {
0067
0068 if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
0069 double et = (jetItr->oflow() ? (double)0xfff : (double)jetItr->et()) * etSumLSB + 1.e-6;
0070
0071
0072
0073
0074 double eta = caloGeom->etaBinCenter(jetItr->regionId());
0075 double phi = caloGeom->emJetPhiBinCenter(jetItr->regionId());
0076
0077 internJetColl->push_back(
0078 L1JetParticle(math::PtEtaPhiMLorentzVector(et, eta, phi, 0.), Ref<L1GctJetCandCollection>(), jetItr->bx()));
0079 }
0080 }
0081 }
0082
0083 OrphanHandle<L1JetParticleCollection> internalJetHandle = iEvent.put(std::move(internJetColl), "Internal");
0084 }
0085
0086
0087 DEFINE_FWK_MODULE(L1GctInternJetProducer);