CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/EventFilter/GctRawToDigi/plugins/L1GctInternJetProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1GctInternJetProducer
00004 // Class:      L1GctInternJetProducer
00005 // 
00008 //
00009 // Original Author:  Alex Tapper
00010 //
00011 //
00012 
00013 
00014 // system include files
00015 #include <memory>
00016 
00017 // user include files
00018 #include "EventFilter/GctRawToDigi/plugins/L1GctInternJetProducer.h"
00019 
00020 #include "FWCore/Framework/interface/Frameworkfwd.h"
00021 #include "FWCore/Framework/interface/MakerMacros.h"
00022 
00023 #include "DataFormats/Common/interface/Handle.h"
00024 #include "FWCore/Framework/interface/ESHandle.h"
00025 #include "DataFormats/Common/interface/OrphanHandle.h"
00026 
00027 #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
00028 #include "CondFormats/DataRecord/interface/L1CaloGeometryRecord.h"
00029 
00030 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
00031 #include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h"
00032 
00033 L1GctInternJetProducer::L1GctInternJetProducer(const edm::ParameterSet& iConfig):
00034      internalJetSource_(iConfig.getParameter<edm::InputTag>("internalJetSource")),
00035      centralBxOnly_(iConfig.getParameter<bool>("centralBxOnly"))
00036 {
00037    using namespace l1extra ;
00038 
00039    produces< L1JetParticleCollection >( "Internal" ) ;
00040 }
00041 
00042 
00043 L1GctInternJetProducer::~L1GctInternJetProducer(){}
00044 
00045 void L1GctInternJetProducer::produce( edm::Event& iEvent, const edm::EventSetup& iSetup)
00046 {
00047 
00048    //std::cout << "ARGGHHH!" << std::endl;
00049    using namespace edm ;
00050    using namespace l1extra ;
00051    using namespace std ;
00052 
00053    auto_ptr< L1JetParticleCollection > internJetColl(new L1JetParticleCollection );
00054 
00055    ESHandle< L1CaloGeometry > caloGeomESH ;
00056    iSetup.get< L1CaloGeometryRecord >().get( caloGeomESH ) ;
00057    const L1CaloGeometry* caloGeom = &( *caloGeomESH ) ;
00058 
00059    ESHandle< L1CaloEtScale > jetScale ;
00060    iSetup.get< L1JetEtScaleRcd >().get( jetScale ) ;
00061 
00062    double etSumLSB = jetScale->linearLsb() ;
00063    //std::cout << "Inside the Jet producer " << etSumLSB << std::endl;  
00064 
00065    Handle< L1GctInternJetDataCollection > hwIntJetCands ;
00066    iEvent.getByLabel( internalJetSource_, hwIntJetCands ) ;
00067    //std::cout << "At leas Something is happening" <<std::endl;
00068    if( !hwIntJetCands.isValid() ) {
00069         std::cout << "These aren't the Jets you're looking for" << std::endl;
00070 
00071        LogDebug("L1GctInternJetProducer")
00072          << "\nWarning: L1GctJetCandCollection with " << internalJetSource_
00073          << "\nrequested in configuration, but not found in the event."
00074          << std::endl;
00075 
00076      } else {
00077         //std::cout << "apparently the collection was found" <<std::endl;
00078        L1GctInternJetDataCollection::const_iterator jetItr = hwIntJetCands->begin() ;
00079        L1GctInternJetDataCollection::const_iterator jetEnd = hwIntJetCands->end() ;
00080         int i;
00081        for( i = 0 ; jetItr != jetEnd ; ++jetItr, ++i ){
00082          //std::cout << " JetS a plenty" <<std::endl;
00083          if( !jetItr->empty() && 
00084              ( !centralBxOnly_ || jetItr->bx() == 0 ) ) {
00085             
00086                  
00087              double et = (jetItr->oflow() ? 
00088                           (double) 0xfff: 
00089                           (double) jetItr->et() ) * etSumLSB + 1.e-6;
00090              
00091              //double et = 10.;  
00092              //std::cout << "jetET: " << jetItr->et() <<std::endl;               
00093              //std::cout << "ET was: " << et << std::endl;    
00094              double eta = caloGeom->etaBinCenter( jetItr->regionId() );
00095              double phi = caloGeom->emJetPhiBinCenter( jetItr->regionId() );
00096 
00097              internJetColl->push_back(L1JetParticle( math::PtEtaPhiMLorentzVector( et, eta, phi, 0.),
00098                                                      Ref< L1GctJetCandCollection >(),
00099                                                      jetItr->bx() ) ) ;
00100            }
00101         }
00102      }
00103 
00104    OrphanHandle< L1JetParticleCollection > internalJetHandle = iEvent.put( internJetColl, "Internal" ) ;
00105 }
00106 
00107 void L1GctInternJetProducer::beginJob(){}
00108 
00109 void L1GctInternJetProducer::endJob(){}
00110 
00111 //define this as a plug-in
00112 DEFINE_FWK_MODULE(L1GctInternJetProducer);