CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoJets/JetProducers/plugins/CastorJetIDProducer.cc

Go to the documentation of this file.
00001 #include "RecoJets/JetProducers/plugins/CastorJetIDProducer.h"
00002 #include "DataFormats/JetReco/interface/CastorJetID.h"
00003 
00004 #include <vector>
00005 
00006 //
00007 // constants, enums and typedefs
00008 //
00009 
00010 
00011 //
00012 // static data member definitions
00013 //
00014 
00015 //
00016 // constructors and destructor
00017 //
00018 CastorJetIDProducer::CastorJetIDProducer(const edm::ParameterSet& iConfig) :
00019   src_       ( iConfig.getParameter<edm::InputTag>("src") ),
00020   helper_    ( )
00021 {
00022   produces< reco::CastorJetIDValueMap >();
00023 }
00024 
00025 
00026 CastorJetIDProducer::~CastorJetIDProducer()
00027 {
00028 }
00029 
00030 
00031 //
00032 // member functions
00033 //
00034 
00035 // ------------ method called to produce the data  ------------
00036 void
00037 CastorJetIDProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00038 {
00039 
00040   // get the input jets
00041   edm::Handle< edm::View<reco::BasicJet> > h_jets;
00042   iEvent.getByLabel( src_, h_jets );
00043 
00044   // allocate the jet--->jetid value map
00045   std::auto_ptr<reco::CastorJetIDValueMap> castorjetIdValueMap( new reco::CastorJetIDValueMap );
00046   // instantiate the filler with the map
00047   reco::CastorJetIDValueMap::Filler filler(*castorjetIdValueMap);
00048   
00049   // allocate the vector of ids
00050   size_t njets = h_jets->size();
00051   std::vector<reco::CastorJetID>  ids (njets);
00052    
00053   // loop over the jets
00054   for ( edm::View<reco::BasicJet>::const_iterator jetsBegin = h_jets->begin(),
00055           jetsEnd = h_jets->end(),
00056           ijet = jetsBegin;
00057         ijet != jetsEnd; ++ijet ) {
00058 
00059     // get the id from each jet
00060     helper_.calculate( iEvent, *ijet );
00061 
00062     ids[ijet-jetsBegin].emEnergy               =  helper_.emEnergy();
00063     ids[ijet-jetsBegin].hadEnergy               =  helper_.hadEnergy();
00064     ids[ijet-jetsBegin].fem            =  helper_.fem();
00065     ids[ijet-jetsBegin].depth      =  helper_.depth();
00066     ids[ijet-jetsBegin].width      =  helper_.width();
00067     ids[ijet-jetsBegin].fhot      =  helper_.fhot();
00068     ids[ijet-jetsBegin].sigmaz      =  helper_.sigmaz();
00069     ids[ijet-jetsBegin].nTowers      =  helper_.nTowers(); 
00070 
00071 
00072   }
00073   
00074   // set up the map
00075   filler.insert( h_jets, ids.begin(), ids.end() );
00076  
00077   // fill the vals
00078   filler.fill();
00079 
00080   // write map to the event
00081   iEvent.put( castorjetIdValueMap );
00082 }
00083 
00084 // ------------ method called once each job just before starting event loop  ------------
00085 void 
00086 CastorJetIDProducer::beginJob()
00087 {
00088 }
00089 
00090 // ------------ method called once each job just after ending the event loop  ------------
00091 void 
00092 CastorJetIDProducer::endJob() {
00093 }
00094 
00095 //define this as a plug-in
00096 DEFINE_FWK_MODULE(CastorJetIDProducer);