CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

FSPFProducer Class Reference

#include <FSPFProducer.h>

Inheritance diagram for FSPFProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 FSPFProducer (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &) override
 ~FSPFProducer ()

Private Member Functions

double energy_threshold (double eta)

Private Attributes

double barrel_th
std::vector< double > EM_HF_ScaleFactor
double endcap_th
double HF_Ratio
edm::InputTag labelPFCandidateCollection_
double middle_th
double par1
double par2
bool pfPatchInHF

Detailed Description

Definition at line 17 of file FSPFProducer.h.


Constructor & Destructor Documentation

FSPFProducer::FSPFProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 14 of file FSPFProducer.cc.

References edm::ParameterSet::getParameter().

                                                         {
 
  labelPFCandidateCollection_ = iConfig.getParameter < edm::InputTag > ("pfCandidates");

  pfPatchInHF = iConfig.getParameter<bool>("pfPatchInHF");
  EM_HF_ScaleFactor = iConfig.getParameter< std::vector <double> >("EM_HF_ScaleFactor");
  HF_Ratio   = iConfig.getParameter<double>("HF_Ratio");
  par1       = iConfig.getParameter<double>("par1");
  par2       = iConfig.getParameter<double>("par2");
  barrel_th  = iConfig.getParameter<double>("barrel_th");
  endcap_th  = iConfig.getParameter<double>("endcap_th");
  middle_th  = iConfig.getParameter<double>("middle_th");
  // register products
  produces<reco::PFCandidateCollection>();
  
}
FSPFProducer::~FSPFProducer ( )

Definition at line 31 of file FSPFProducer.cc.

{}

Member Function Documentation

double FSPFProducer::energy_threshold ( double  eta) [private]

Definition at line 108 of file FSPFProducer.cc.

References eta().

                                                {
  if (eta<0) eta = -eta;
  if      (eta < 1.6) return barrel_th;
  else if (eta < 1.8) return middle_th;
  else                return endcap_th;
}
void FSPFProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [override, virtual]

Implements edm::EDProducer.

Definition at line 34 of file FSPFProducer.cc.

References reco::PFCandidate::egamma_HF, edm::Event::getByLabel(), h, reco::PFCandidate::h0, reco::PFCandidate::h_HF, reco::tau::pfCandidates(), edm::Event::put(), and mathSSE::sqrt().

                                                {
  
  Handle < reco::PFCandidateCollection > pfCandidates;
  iEvent.getByLabel (labelPFCandidateCollection_, pfCandidates);
  
  auto_ptr< reco::PFCandidateCollection >  pOutputCandidateCollection(new PFCandidateCollection);   

  /*  
  LogDebug("FSPFProducer")<<"START event: "
                          <<iEvent.id().event()
                          <<" in run "<<iEvent.id().run()<<endl;   
  */  

  double theNeutralFraction, px, py, pz, en;
  int n_hadron_HF = 0; 
  int n_em_HF = 0;
  int vEta=-1;
  reco::PFCandidateCollection::const_iterator  itCand =  pfCandidates->begin();
  reco::PFCandidateCollection::const_iterator  itCandEnd = pfCandidates->end();
  for( ; itCand != itCandEnd; itCand++) {

    // First part: create fake neutral hadrons as a function of charged hadrons and add them to the new collection
    if(itCand->particleId() == reco::PFCandidate::h){
      theNeutralFraction = par1 - par2*itCand->energy();
      if(theNeutralFraction > 0.){
        px = theNeutralFraction*itCand->px();
        py = theNeutralFraction*itCand->py();
        pz = theNeutralFraction*itCand->pz();
        en = sqrt(px*px + py*py + pz*pz); 
        if (en > energy_threshold(itCand->eta())) {
          // create a PFCandidate and add it to the particles Collection
          math::XYZTLorentzVector momentum(px,py,pz,en);
          reco::PFCandidate FakeNeutralHadron(0, momentum,  reco::PFCandidate::h0);
          pOutputCandidateCollection->push_back(FakeNeutralHadron);
        }
      }
    }
    
    // Second part: deal with HF, and put every candidate of the old collection in the new collection
    if(itCand->particleId() == reco::PFCandidate::egamma_HF){
      if (pfPatchInHF) {
        n_em_HF++;
        
        if(fabs(itCand->eta())< 4.) vEta = 0;
        else if(fabs(itCand->eta())<= 5.) vEta = 1;
        
        if (vEta==0 || vEta==1) {
          // copy these PFCandidates after the momentum rescaling
          px = EM_HF_ScaleFactor[vEta]*itCand->px();
          py = EM_HF_ScaleFactor[vEta]*itCand->py();
          pz = EM_HF_ScaleFactor[vEta]*itCand->pz();
          en = sqrt(px*px + py*py + pz*pz); 
          math::XYZTLorentzVector momentum(px,py,pz,en);
          reco::PFCandidate EMHF(itCand->charge(), momentum,  reco::PFCandidate::egamma_HF);
          if(en>0.) pOutputCandidateCollection->push_back(EMHF);
        }
      } else pOutputCandidateCollection->push_back(*itCand);
    }
    
    else if(itCand->particleId() == reco::PFCandidate::h_HF){
      if (pfPatchInHF) {
        // copy these PFCandidates to the new particles Collection only if hadron candidates are currently more than EM candidates
        n_hadron_HF++;
        if(n_em_HF < (n_hadron_HF*HF_Ratio)) pOutputCandidateCollection->push_back(*itCand);
      } else pOutputCandidateCollection->push_back(*itCand);
    }

    else  pOutputCandidateCollection->push_back(*itCand);
    
  }
  iEvent.put(pOutputCandidateCollection);
}

Member Data Documentation

double FSPFProducer::barrel_th [private]

Definition at line 29 of file FSPFProducer.h.

std::vector<double> FSPFProducer::EM_HF_ScaleFactor [private]

Definition at line 33 of file FSPFProducer.h.

double FSPFProducer::endcap_th [private]

Definition at line 29 of file FSPFProducer.h.

double FSPFProducer::HF_Ratio [private]

Definition at line 32 of file FSPFProducer.h.

Definition at line 26 of file FSPFProducer.h.

double FSPFProducer::middle_th [private]

Definition at line 29 of file FSPFProducer.h.

double FSPFProducer::par1 [private]

Definition at line 28 of file FSPFProducer.h.

double FSPFProducer::par2 [private]

Definition at line 28 of file FSPFProducer.h.

bool FSPFProducer::pfPatchInHF [private]

Definition at line 31 of file FSPFProducer.h.