CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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

Public Member Functions

 FSPFProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
 ~FSPFProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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().

14  {
15 
16  labelPFCandidateCollection_ = iConfig.getParameter < edm::InputTag > ("pfCandidates");
17 
18  pfPatchInHF = iConfig.getParameter<bool>("pfPatchInHF");
19  EM_HF_ScaleFactor = iConfig.getParameter< std::vector <double> >("EM_HF_ScaleFactor");
20  HF_Ratio = iConfig.getParameter<double>("HF_Ratio");
21  par1 = iConfig.getParameter<double>("par1");
22  par2 = iConfig.getParameter<double>("par2");
23  barrel_th = iConfig.getParameter<double>("barrel_th");
24  endcap_th = iConfig.getParameter<double>("endcap_th");
25  middle_th = iConfig.getParameter<double>("middle_th");
26  // register products
27  produces<reco::PFCandidateCollection>();
28 
29 }
T getParameter(std::string const &) const
bool pfPatchInHF
Definition: FSPFProducer.h:31
edm::InputTag labelPFCandidateCollection_
Definition: FSPFProducer.h:26
std::vector< double > EM_HF_ScaleFactor
Definition: FSPFProducer.h:33
double HF_Ratio
Definition: FSPFProducer.h:32
double endcap_th
Definition: FSPFProducer.h:29
double barrel_th
Definition: FSPFProducer.h:29
double middle_th
Definition: FSPFProducer.h:29
FSPFProducer::~FSPFProducer ( )

Definition at line 31 of file FSPFProducer.cc.

31 {}

Member Function Documentation

double FSPFProducer::energy_threshold ( double  eta)
private

Definition at line 108 of file FSPFProducer.cc.

References eta().

108  {
109  if (eta<0) eta = -eta;
110  if (eta < 1.6) return barrel_th;
111  else if (eta < 1.8) return middle_th;
112  else return endcap_th;
113 }
T eta() const
double endcap_th
Definition: FSPFProducer.h:29
double barrel_th
Definition: FSPFProducer.h:29
double middle_th
Definition: FSPFProducer.h:29
void FSPFProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 34 of file FSPFProducer.cc.

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

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

35  {
36 
38  iEvent.getByLabel (labelPFCandidateCollection_, pfCandidates);
39 
40  auto_ptr< reco::PFCandidateCollection > pOutputCandidateCollection(new PFCandidateCollection);
41 
42  /*
43  LogDebug("FSPFProducer")<<"START event: "
44  <<iEvent.id().event()
45  <<" in run "<<iEvent.id().run()<<endl;
46  */
47 
48  double theNeutralFraction, px, py, pz, en;
49  int n_hadron_HF = 0;
50  int n_em_HF = 0;
51  int vEta=-1;
52  reco::PFCandidateCollection::const_iterator itCand = pfCandidates->begin();
53  reco::PFCandidateCollection::const_iterator itCandEnd = pfCandidates->end();
54  for( ; itCand != itCandEnd; itCand++) {
55 
56  // First part: create fake neutral hadrons as a function of charged hadrons and add them to the new collection
57  if(itCand->particleId() == reco::PFCandidate::h){
58  theNeutralFraction = par1 - par2*itCand->energy();
59  if(theNeutralFraction > 0.){
60  px = theNeutralFraction*itCand->px();
61  py = theNeutralFraction*itCand->py();
62  pz = theNeutralFraction*itCand->pz();
63  en = sqrt(px*px + py*py + pz*pz);
64  if (en > energy_threshold(itCand->eta())) {
65  // create a PFCandidate and add it to the particles Collection
66  math::XYZTLorentzVector momentum(px,py,pz,en);
67  reco::PFCandidate FakeNeutralHadron(0, momentum, reco::PFCandidate::h0);
68  pOutputCandidateCollection->push_back(FakeNeutralHadron);
69  }
70  }
71  }
72 
73  // Second part: deal with HF, and put every candidate of the old collection in the new collection
74  if(itCand->particleId() == reco::PFCandidate::egamma_HF){
75  if (pfPatchInHF) {
76  n_em_HF++;
77 
78  if(fabs(itCand->eta())< 4.) vEta = 0;
79  else if(fabs(itCand->eta())<= 5.) vEta = 1;
80 
81  if (vEta==0 || vEta==1) {
82  // copy these PFCandidates after the momentum rescaling
83  px = EM_HF_ScaleFactor[vEta]*itCand->px();
84  py = EM_HF_ScaleFactor[vEta]*itCand->py();
85  pz = EM_HF_ScaleFactor[vEta]*itCand->pz();
86  en = sqrt(px*px + py*py + pz*pz);
87  math::XYZTLorentzVector momentum(px,py,pz,en);
88  reco::PFCandidate EMHF(itCand->charge(), momentum, reco::PFCandidate::egamma_HF);
89  if(en>0.) pOutputCandidateCollection->push_back(EMHF);
90  }
91  } else pOutputCandidateCollection->push_back(*itCand);
92  }
93 
94  else if(itCand->particleId() == reco::PFCandidate::h_HF){
95  if (pfPatchInHF) {
96  // copy these PFCandidates to the new particles Collection only if hadron candidates are currently more than EM candidates
97  n_hadron_HF++;
98  if(n_em_HF < (n_hadron_HF*HF_Ratio)) pOutputCandidateCollection->push_back(*itCand);
99  } else pOutputCandidateCollection->push_back(*itCand);
100  }
101 
102  else pOutputCandidateCollection->push_back(*itCand);
103 
104  }
105  iEvent.put(pOutputCandidateCollection);
106 }
bool pfPatchInHF
Definition: FSPFProducer.h:31
edm::InputTag labelPFCandidateCollection_
Definition: FSPFProducer.h:26
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
T sqrt(T t)
Definition: SSEVec.h:48
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::vector< double > EM_HF_ScaleFactor
Definition: FSPFProducer.h:33
double HF_Ratio
Definition: FSPFProducer.h:32
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:38
double energy_threshold(double eta)

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.

edm::InputTag FSPFProducer::labelPFCandidateCollection_
private

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.