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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) 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
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pfCandidateToken
 
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 19 of file FSPFProducer.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file FSPFProducer.cc.

References edm::ParameterSet::getParameter().

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

Definition at line 32 of file FSPFProducer.cc.

32 {}

Member Function Documentation

double FSPFProducer::energy_threshold ( double  eta)
private

Definition at line 109 of file FSPFProducer.cc.

References eta().

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

Implements edm::EDProducer.

Definition at line 35 of file FSPFProducer.cc.

References reco::PFCandidate::egamma_HF, edm::Event::getByToken(), 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().

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

Member Data Documentation

double FSPFProducer::barrel_th
private

Definition at line 31 of file FSPFProducer.h.

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

Definition at line 35 of file FSPFProducer.h.

double FSPFProducer::endcap_th
private

Definition at line 31 of file FSPFProducer.h.

double FSPFProducer::HF_Ratio
private

Definition at line 34 of file FSPFProducer.h.

edm::InputTag FSPFProducer::labelPFCandidateCollection_
private

Definition at line 28 of file FSPFProducer.h.

double FSPFProducer::middle_th
private

Definition at line 31 of file FSPFProducer.h.

double FSPFProducer::par1
private

Definition at line 30 of file FSPFProducer.h.

double FSPFProducer::par2
private

Definition at line 30 of file FSPFProducer.h.

edm::EDGetTokenT<reco::PFCandidateCollection> FSPFProducer::pfCandidateToken
private

Definition at line 39 of file FSPFProducer.h.

bool FSPFProducer::pfPatchInHF
private

Definition at line 33 of file FSPFProducer.h.