CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
JetMaker Namespace Reference

Make Jets from protoobjects. More...

Functions

HcalSubdetector hcalSubdetector (int fEta)
 converts eta to the corresponding HCAL subdetector. More...
 
bool makeSpecific (const JetReco::InputCollection &fConstituents, const CaloSubdetectorGeometry &fTowerGeometry, reco::CaloJet::Specific *fJetSpecific)
 Make CaloJet specifics. Assumes ProtoJet is made from CaloTowerCandidates. More...
 
bool makeSpecific (const JetReco::InputCollection &fConstituents, reco::PFJet::Specific *fJetSpecific)
 Make PFlowJet specifics. Assumes ProtoJet is made from ParticleFlowCandidates. More...
 
bool makeSpecific (const JetReco::InputCollection &fConstituents, reco::GenJet::Specific *fJetSpecific)
 Make GenJet specifics. Assumes ProtoJet is made from HepMCCandidate. More...
 

Detailed Description

Make Jets from protoobjects.

Function Documentation

HcalSubdetector JetMaker::hcalSubdetector ( int  fEta)

converts eta to the corresponding HCAL subdetector.

Referenced by makeSpecific().

bool JetMaker::makeSpecific ( const JetReco::InputCollection fConstituents,
const CaloSubdetectorGeometry fTowerGeometry,
reco::CaloJet::Specific fJetSpecific 
)

Make CaloJet specifics. Assumes ProtoJet is made from CaloTowerCandidates.

Definition at line 21 of file JetMaker.cc.

References dtNoiseDBValidation_cfg::cerr, dPhi(), CaloTower::emEnergy(), reco::LeafCandidate::energy(), geometry, reco::Candidate::get(), CaloCellGeometry::getCorners(), CaloSubdetectorGeometry::getGeometry(), CaloTower::hadEnergy(), HcalBarrel, HcalEndcap, HcalForward, hcalSubdetector(), CaloTower::id(), CaloTowerDetId::ieta(), reco::CaloJet::Specific::mEmEnergyInEB, reco::CaloJet::Specific::mEmEnergyInEE, reco::CaloJet::Specific::mEmEnergyInHF, reco::CaloJet::Specific::mEnergyFractionEm, reco::CaloJet::Specific::mEnergyFractionHadronic, reco::CaloJet::Specific::mHadEnergyInHB, reco::CaloJet::Specific::mHadEnergyInHE, reco::CaloJet::Specific::mHadEnergyInHF, reco::CaloJet::Specific::mHadEnergyInHO, reco::CaloJet::Specific::mMaxEInEmTowers, reco::CaloJet::Specific::mMaxEInHadTowers, reco::CaloJet::Specific::mTowersArea, CaloTower::outerEnergy(), and python.multivaluedict::sort().

Referenced by PFRootEventManager::reconstructGenJets(), and PFRootEventManager::reconstructPFJets().

23  {
24  if (!fJetSpecific) return false;
25 
26  // 1.- Loop over the tower Ids,
27  // 2.- Get the corresponding CaloTower
28  // 3.- Calculate the different CaloJet specific quantities
29  vector<double> eECal_i;
30  vector<double> eHCal_i;
31  double eInHad = 0.;
32  double eInEm = 0.;
33  double eInHO = 0.;
34  double eInHB = 0.;
35  double eInHE = 0.;
36  double eHadInHF = 0.;
37  double eEmInHF = 0.;
38  double eInEB = 0.;
39  double eInEE = 0.;
40  double jetArea = 0.;
41 
42  for (JetReco::InputCollection::const_iterator towerCand = fTowers.begin(); towerCand != fTowers.end(); ++towerCand) {
43  const Candidate* candidate = towerCand->get ();
44  if (candidate) {
45  const CaloTower* tower = dynamic_cast<const CaloTower*> (candidate);
46  if (tower) {
47  //Array of energy in EM Towers:
48  eECal_i.push_back(tower->emEnergy());
49  eInEm += tower->emEnergy();
50  //Array of energy in HCAL Towers:
51  eHCal_i.push_back(tower->hadEnergy());
52  eInHad += tower->hadEnergy();
53 
54  // figure out contributions
55  switch (JetMaker::hcalSubdetector (tower->id().ieta())) {
56  case HcalBarrel:
57  eInHB += tower->hadEnergy();
58  eInHO += tower->outerEnergy();
59  eInEB += tower->emEnergy();
60  break;
61  case HcalEndcap:
62  eInHE += tower->hadEnergy();
63  eInEE += tower->emEnergy();
64  break;
65  case HcalForward:
66  eHadInHF += tower->hadEnergy();
67  eEmInHF += tower->emEnergy();
68  break;
69  default:
70  break;
71  }
72  // get area of the tower (++ minus --)
73  if ( tower->energy() > 0 ) {
74  const CaloCellGeometry* geometry = fTowerGeometry.getGeometry(tower->id());
75  if (geometry) {
76  float dEta = fabs (geometry->getCorners() [0].eta() - geometry->getCorners() [2].eta());
77  float dPhi = fabs (geometry->getCorners() [0].phi() - geometry->getCorners() [2].phi());
78  jetArea += dEta * dPhi;
79  }
80  }
81  else {
82  std::cerr << "JetMaker::makeSpecific (CaloJet)-> Geometry for cell " << tower->id() << " can not be found. Ignoring cell" << std::endl;
83  }
84  }
85  else {
86  std::cerr << "JetMaker::makeSpecific (CaloJet)-> Constituent is not of CaloTower type" << std::endl;
87  }
88  }
89  else {
90  std::cerr << "JetMaker::makeSpecific (CaloJet)-> Referred constituent is not available in the event" << std::endl;
91  }
92  }
93  double towerEnergy = eInHad + eInEm;
94  fJetSpecific->mHadEnergyInHO = eInHO;
95  fJetSpecific->mHadEnergyInHB = eInHB;
96  fJetSpecific->mHadEnergyInHE = eInHE;
97  fJetSpecific->mHadEnergyInHF = eHadInHF;
98  fJetSpecific->mEmEnergyInHF = eEmInHF;
99  fJetSpecific->mEmEnergyInEB = eInEB;
100  fJetSpecific->mEmEnergyInEE = eInEE;
101  if (towerEnergy > 0) {
102  fJetSpecific->mEnergyFractionHadronic = eInHad / towerEnergy;
103  fJetSpecific->mEnergyFractionEm = eInEm / towerEnergy;
104  }
105  else { // HO only jet
106  fJetSpecific->mEnergyFractionHadronic = 1.;
107  fJetSpecific->mEnergyFractionEm = 0.;
108  }
109  fJetSpecific->mTowersArea = jetArea;
110  fJetSpecific->mMaxEInEmTowers = 0;
111  fJetSpecific->mMaxEInHadTowers = 0;
112 
113  //Sort the arrays
114  sort(eECal_i.begin(), eECal_i.end(), greater<double>());
115  sort(eHCal_i.begin(), eHCal_i.end(), greater<double>());
116 
117  if (!fTowers.empty ()) {
118  //Highest value in the array is the first element of the array
119  fJetSpecific->mMaxEInEmTowers = eECal_i.front();
120  fJetSpecific->mMaxEInHadTowers = eHCal_i.front();
121 
122  }
123  return true;
124 }
float mMaxEInEmTowers
Maximum energy in EM towers.
Definition: CaloJet.h:49
float mEmEnergyInHF
Em energy in HF.
Definition: CaloJet.h:65
float mEnergyFractionHadronic
Hadronic energy fraction.
Definition: CaloJet.h:67
float mEmEnergyInEB
Em energy in EB.
Definition: CaloJet.h:61
HcalSubdetector hcalSubdetector(int fEta)
converts eta to the corresponding HCAL subdetector.
float mHadEnergyInHB
Hadronic energy in HB.
Definition: CaloJet.h:55
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
virtual double energy() const
energy
double emEnergy() const
Definition: CaloTower.h:79
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
float mEnergyFractionEm
Em energy fraction.
Definition: CaloJet.h:69
float mHadEnergyInHF
Hadronic energy in HF.
Definition: CaloJet.h:57
float mMaxEInHadTowers
Maximum energy in HCAL towers.
Definition: CaloJet.h:51
double hadEnergy() const
Definition: CaloTower.h:80
CaloTowerDetId id() const
Definition: CaloTower.h:72
float mHadEnergyInHO
Hadronic nergy fraction in HO.
Definition: CaloJet.h:53
ESHandle< TrackerGeometry > geometry
T get() const
get a component
Definition: Candidate.h:216
float mTowersArea
Area of contributing CaloTowers.
Definition: CaloJet.h:71
int ieta() const
get the tower ieta
float mEmEnergyInEE
Em energy in EE.
Definition: CaloJet.h:63
double outerEnergy() const
Definition: CaloTower.h:81
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell&#39;s volume.
float mHadEnergyInHE
Hadronic energy in HE.
Definition: CaloJet.h:59
bool JetMaker::makeSpecific ( const JetReco::InputCollection fConstituents,
reco::PFJet::Specific fJetSpecific 
)

Make PFlowJet specifics. Assumes ProtoJet is made from ParticleFlowCandidates.

@@ PFJET *************************

Definition at line 127 of file JetMaker.cc.

References dtNoiseDBValidation_cfg::cerr, alignCSCRings::e, reco::LeafCandidate::energy(), reco::Candidate::get(), h, reco::PFJet::Specific::mChargedEmEnergy, reco::PFJet::Specific::mChargedHadronEnergy, reco::PFJet::Specific::mChargedMuEnergy, reco::PFJet::Specific::mChargedMultiplicity, reco::PFJet::Specific::mMuonMultiplicity, reco::PFJet::Specific::mNeutralEmEnergy, reco::PFJet::Specific::mNeutralHadronEnergy, reco::PFJet::Specific::mNeutralMultiplicity, RPCpg::mu, and reco::PFCandidate::particleId().

128  {
129  if (!fJetSpecific) return false;
130 
131  // 1.- Loop over PFCandidates,
132  // 2.- Get the corresponding PFCandidate
133  // 3.- Calculate the different PFJet specific quantities
134 
135  float chargedHadronEnergy=0.;
136  float neutralHadronEnergy=0.;
137  float chargedEmEnergy=0.;
138  float neutralEmEnergy=0.;
139  float chargedMuEnergy=0.;
140  int chargedMultiplicity=0;
141  int neutralMultiplicity=0;
142  int muonMultiplicity=0;
143 
144  JetReco::InputCollection::const_iterator constituent = fPFCandidates.begin();
145  for (; constituent != fPFCandidates.end(); ++constituent) {
146  const Candidate* candidate = constituent->get ();
147  if (candidate) {
148  const PFCandidate* pfCand = dynamic_cast<const PFCandidate*> (candidate);
149  if (pfCand) {
150  switch ( PFCandidate::ParticleType (pfCand->particleId())) {
151  case PFCandidate::h: // charged hadron
152  chargedHadronEnergy += pfCand->energy();
153  chargedMultiplicity++;
154  break;
155 
156  case PFCandidate::e: // electron
157  chargedEmEnergy += pfCand->energy();
158  chargedMultiplicity++;
159  break;
160 
161  case PFCandidate::mu: // muon
162  chargedMuEnergy += pfCand->energy();
163  chargedMultiplicity++;
164  muonMultiplicity++;
165  break;
166 
167  case PFCandidate::gamma: // photon
168  case PFCandidate::egamma_HF : // electromagnetic in HF
169  neutralEmEnergy += pfCand->energy();
170  neutralMultiplicity++;
171  break;
172 
173  case PFCandidate::h0 : // neutral hadron
174  case PFCandidate::h_HF : // hadron in HF
175  neutralHadronEnergy += pfCand->energy();
176  neutralMultiplicity++;
177  break;
178 
179  default:
180  std::cerr << "JetMaker::makeSpecific (PFJetJet)-> Unknown PFCandidate::ParticleType: " << pfCand->particleId() << " is ignored" << std::endl;
181  break;
182  }
183  }
184  else {
185  std::cerr << "JetMaker::makeSpecific (PFJetJet)-> Referred constituent is not PFCandidate" << std::endl;
186  }
187  }
188  else {
189  std::cerr << "JetMaker::makeSpecific (PFJetJet)-> Referred constituent is not available in the event" << std::endl;
190  }
191  }
192  fJetSpecific->mChargedHadronEnergy=chargedHadronEnergy;
193  fJetSpecific->mNeutralHadronEnergy= neutralHadronEnergy;
194  fJetSpecific->mChargedEmEnergy=chargedEmEnergy;
195  fJetSpecific->mChargedMuEnergy=chargedMuEnergy;
196  fJetSpecific->mNeutralEmEnergy=neutralEmEnergy;
197  fJetSpecific->mChargedMultiplicity=chargedMultiplicity;
198  fJetSpecific->mNeutralMultiplicity=neutralMultiplicity;
199  fJetSpecific->mMuonMultiplicity=muonMultiplicity;
200  return true;
201 }
ParticleType
particle types
Definition: PFCandidate.h:38
int mChargedMultiplicity
Definition: PFJet.h:70
float mNeutralHadronEnergy
Definition: PFJet.h:50
float mChargedMuEnergy
Definition: PFJet.h:68
float mChargedHadronEnergy
Definition: PFJet.h:49
float mChargedEmEnergy
Definition: PFJet.h:67
virtual double energy() const
energy
float mNeutralEmEnergy
Definition: PFJet.h:69
const int mu
Definition: Constants.h:23
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
int mNeutralMultiplicity
Definition: PFJet.h:71
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
T get() const
get a component
Definition: Candidate.h:216
virtual ParticleType particleId() const
Definition: PFCandidate.h:324
bool JetMaker::makeSpecific ( const JetReco::InputCollection fConstituents,
reco::GenJet::Specific fJetSpecific 
)

Make GenJet specifics. Assumes ProtoJet is made from HepMCCandidate.

Definition at line 204 of file JetMaker.cc.

References abs, dtNoiseDBValidation_cfg::cerr, alignCSCRings::e, reco::LeafCandidate::energy(), edm::RefToBase< T >::get(), reco::Candidate::get(), reco::Candidate::hasMasterClone(), reco::GenJet::Specific::m_AuxiliaryEnergy, reco::GenJet::Specific::m_EmEnergy, reco::GenJet::Specific::m_HadEnergy, reco::GenJet::Specific::m_InvisibleEnergy, reco::Candidate::masterClone(), and reco::LeafCandidate::pdgId().

205  {
206  for (JetReco::InputCollection::const_iterator genCand = fMcParticles.begin(); genCand != fMcParticles.end(); ++genCand) {
207  const Candidate* candidate = genCand->get ();
208  if (candidate->hasMasterClone ()) candidate = candidate->masterClone().get ();
209  if (candidate) {
210  const GenParticle* genParticle = GenJet::genParticle (candidate);
211  if (genParticle) {
212  double e = genParticle->energy();
213  switch (std::abs (genParticle->pdgId ())) {
214  case 22: // photon
215  case 11: // e
216  fJetSpecific->m_EmEnergy += e;
217  break;
218  case 211: // pi
219  case 321: // K
220  case 130: // KL
221  case 2212: // p
222  case 2112: // n
223  fJetSpecific->m_HadEnergy += e;
224  break;
225  case 13: // muon
226  case 12: // nu_e
227  case 14: // nu_mu
228  case 16: // nu_tau
229 
230  fJetSpecific->m_InvisibleEnergy += e;
231  break;
232  default:
233  fJetSpecific->m_AuxiliaryEnergy += e;
234  }
235  }
236  else {
237  std::cerr << "JetMaker::makeSpecific (GenJet)-> Referred GenParticleCandidate is not available in the event" << std::endl;
238  }
239  }
240  else {
241  std::cerr << "JetMaker::makeSpecific (GenJet)-> Referred constituent is not available in the event" << std::endl;
242  }
243  }
244  return true;
245 }
virtual int pdgId() const
PDG identifier.
#define abs(x)
Definition: mlp_lapack.h:159
virtual double energy() const
energy
virtual bool hasMasterClone() const =0
float m_InvisibleEnergy
Invisible energy (mu, nu, ...)
Definition: GenJet.h:39
float m_AuxiliaryEnergy
Anything else (undecayed Sigmas etc.)
Definition: GenJet.h:41
float m_HadEnergy
Energy of Hadrons.
Definition: GenJet.h:37
T get() const
get a component
Definition: Candidate.h:216
float m_EmEnergy
Energy of EM particles.
Definition: GenJet.h:35
value_type const * get() const
Definition: RefToBase.h:212
virtual const CandidateBaseRef & masterClone() const =0