00001 #include "RecoJets/JetProducers/plugins/FixedGridRhoProducerFastjet.h" 00002 #include "FWCore/Framework/interface/Event.h" 00003 #include "FWCore/Framework/interface/MakerMacros.h" 00004 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" 00005 00006 using namespace std; 00007 00008 FixedGridRhoProducerFastjet::FixedGridRhoProducerFastjet(const edm::ParameterSet& iConfig) : 00009 bge_( iConfig.getParameter<double>("maxRapidity"), 00010 iConfig.getParameter<double>("gridSpacing") ) 00011 { 00012 pfCandidatesTag_ = iConfig.getParameter<edm::InputTag>("pfCandidatesTag"); 00013 produces<double>(); 00014 } 00015 00016 FixedGridRhoProducerFastjet::~FixedGridRhoProducerFastjet(){} 00017 00018 void FixedGridRhoProducerFastjet::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { 00019 00020 edm::Handle<reco::PFCandidateCollection> pfColl; 00021 iEvent.getByLabel(pfCandidatesTag_,pfColl); 00022 std::vector<fastjet::PseudoJet> inputs; 00023 for ( reco::PFCandidateCollection::const_iterator ibegin = pfColl->begin(), 00024 iend = pfColl->end(), i = ibegin; i != iend; ++i ){ 00025 inputs.push_back( fastjet::PseudoJet(i->px(), i->py(), i->pz(), i->energy()) ); 00026 } 00027 bge_.set_particles(inputs); 00028 std::auto_ptr<double> outputRho(new double(bge_.rho())); 00029 iEvent.put(outputRho); 00030 } 00031 00032 DEFINE_FWK_MODULE(FixedGridRhoProducerFastjet);