Go to the documentation of this file.00001 #include "FastSimulation/ParticleFlow/plugins/FSPFProducer.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004
00005 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00006 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00007 #include "DataFormats/Math/interface/LorentzVector.h"
00008
00009 using namespace std;
00010 using namespace edm;
00011 using namespace reco;
00012
00013
00014 FSPFProducer::FSPFProducer(const edm::ParameterSet& iConfig) {
00015
00016 labelPFCandidateCollection_ = iConfig.getParameter < edm::InputTag > ("pfCandidates");
00017
00018 par1 = iConfig.getParameter<double>("par1");
00019 par2 = iConfig.getParameter<double>("par2");
00020 barrel_th = iConfig.getParameter<double>("barrel_th");
00021 endcap_th = iConfig.getParameter<double>("endcap_th");
00022 middle_th = iConfig.getParameter<double>("middle_th");
00023
00024 produces<reco::PFCandidateCollection>();
00025
00026 }
00027
00028 FSPFProducer::~FSPFProducer() {}
00029
00030 void
00031 FSPFProducer::beginJob() {}
00032
00033 void
00034 FSPFProducer::beginRun(edm::Run & iRun,
00035 const edm::EventSetup & iSetup) {}
00036
00037 void
00038 FSPFProducer::produce(Event& iEvent,
00039 const EventSetup& iSetup) {
00040
00041 Handle < reco::PFCandidateCollection > pfCandidates;
00042 iEvent.getByLabel (labelPFCandidateCollection_, pfCandidates);
00043
00044 auto_ptr< reco::PFCandidateCollection > pOutputCandidateCollection(new PFCandidateCollection);
00045
00046 LogDebug("FSPFProducer")<<"START event: "
00047 <<iEvent.id().event()
00048 <<" in run "<<iEvent.id().run()<<endl;
00049
00050 double theNeutralFraction, px, py, pz, en;
00051 reco::PFCandidateCollection::const_iterator itCand = pfCandidates->begin();
00052 reco::PFCandidateCollection::const_iterator itCandEnd = pfCandidates->end();
00053 for( ; itCand != itCandEnd; itCand++) {
00054 pOutputCandidateCollection->push_back(*itCand);
00055 if(itCand->particleId() == reco::PFCandidate::h){
00056 theNeutralFraction = par1 - par2*itCand->energy();
00057 if(theNeutralFraction > 0.){
00058 px = theNeutralFraction*itCand->px();
00059 py = theNeutralFraction*itCand->py();
00060 pz = theNeutralFraction*itCand->pz();
00061 en = sqrt(px*px + py*py + pz*pz);
00062 if (en > energy_threshold(itCand->eta())) {
00063
00064 math::XYZTLorentzVector momentum(px,py,pz,en);
00065 reco::PFCandidate FakeNeutralHadron(0, momentum, reco::PFCandidate::h0);
00066 pOutputCandidateCollection->push_back(FakeNeutralHadron);
00067 }
00068 }
00069 }
00070 }
00071 iEvent.put(pOutputCandidateCollection);
00072 }
00073
00074 double FSPFProducer::energy_threshold(double eta) {
00075 if (eta<0) eta = -eta;
00076 if (eta < 1.6) return barrel_th;
00077 else if (eta < 1.8) return middle_th;
00078 else return endcap_th;
00079 }
00080
00081
00082
00083 DEFINE_FWK_MODULE (FSPFProducer);