Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:59

0001 // -*- C++ -*-

0002 //

0003 // Package:    L1GctInternJetProducer

0004 // Class:      L1GctInternJetProducer

0005 //

0006 /**\class L1GctInternJetProducer \file L1GctInternJetProducer.cc EventFilter/GctRawToDigi/plugins/L1GctInternJetProducer.cc

0007 */
0008 //

0009 // Original Author:  Alex Tapper

0010 //

0011 //

0012 
0013 // system include files

0014 #include <memory>
0015 
0016 // user include files

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 L1GctInternJetProducer::~L1GctInternJetProducer() {}
0037 
0038 void L1GctInternJetProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0039   //std::cout << "ARGGHHH!" << std::endl;

0040   using namespace edm;
0041   using namespace l1extra;
0042   using namespace std;
0043 
0044   unique_ptr<L1JetParticleCollection> internJetColl(new L1JetParticleCollection);
0045 
0046   ESHandle<L1CaloGeometry> caloGeomESH = iSetup.getHandle(caloGeomToken_);
0047   const L1CaloGeometry* caloGeom = &(*caloGeomESH);
0048 
0049   ESHandle<L1CaloEtScale> jetScale = iSetup.getHandle(jetScaleToken_);
0050 
0051   double etSumLSB = jetScale->linearLsb();
0052   //std::cout << "Inside the Jet producer " << etSumLSB << std::endl;

0053 
0054   Handle<L1GctInternJetDataCollection> hwIntJetCands;
0055   iEvent.getByLabel(internalJetSource_, hwIntJetCands);
0056   //std::cout << "At leas Something is happening" <<std::endl;

0057   if (!hwIntJetCands.isValid()) {
0058     std::cout << "These aren't the Jets you're looking for" << std::endl;
0059 
0060     LogDebug("L1GctInternJetProducer") << "\nWarning: L1GctJetCandCollection with " << internalJetSource_
0061                                        << "\nrequested in configuration, but not found in the event." << std::endl;
0062 
0063   } else {
0064     //std::cout << "apparently the collection was found" <<std::endl;

0065     L1GctInternJetDataCollection::const_iterator jetItr = hwIntJetCands->begin();
0066     L1GctInternJetDataCollection::const_iterator jetEnd = hwIntJetCands->end();
0067     int i;
0068     for (i = 0; jetItr != jetEnd; ++jetItr, ++i) {
0069       //std::cout << " JetS a plenty" <<std::endl;

0070       if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
0071         double et = (jetItr->oflow() ? (double)0xfff : (double)jetItr->et()) * etSumLSB + 1.e-6;
0072 
0073         //double et = 10.;

0074         //std::cout << "jetET: " << jetItr->et() <<std::endl;

0075         //std::cout << "ET was: " << et << std::endl;

0076         double eta = caloGeom->etaBinCenter(jetItr->regionId());
0077         double phi = caloGeom->emJetPhiBinCenter(jetItr->regionId());
0078 
0079         internJetColl->push_back(
0080             L1JetParticle(math::PtEtaPhiMLorentzVector(et, eta, phi, 0.), Ref<L1GctJetCandCollection>(), jetItr->bx()));
0081       }
0082     }
0083   }
0084 
0085   OrphanHandle<L1JetParticleCollection> internalJetHandle = iEvent.put(std::move(internJetColl), "Internal");
0086 }
0087 
0088 void L1GctInternJetProducer::beginJob() {}
0089 
0090 void L1GctInternJetProducer::endJob() {}
0091 
0092 //define this as a plug-in

0093 DEFINE_FWK_MODULE(L1GctInternJetProducer);