CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetSpecific.cc
Go to the documentation of this file.
1 //
3 // JetSpecific
4 // -----------
5 //
7 
8 
10 
11 
25 
26 #include <cmath>
27 
28 
29 using namespace std;
30 
31 
33 // implementation of global functions
35 
36 //______________________________________________________________________________
37 // Overloaded methods to write out specific types
38 
39 
40 // CaloJet
44  std::vector<reco::CandidatePtr> const & constituents,
45  edm::EventSetup const & c )
46 {
47  // Get geometry
49  c.get<CaloGeometryRecord>().get(geometry);
50  const CaloSubdetectorGeometry* towerGeometry =
51  geometry->getSubdetectorGeometry(DetId::Calo, CaloTowerDetId::SubdetId);
52 
53  // Make the specific
55  makeSpecific (constituents, *towerGeometry, &specific);
56  // Set the calo jet
57  jet = reco::CaloJet( p4, point, specific, constituents);
58 }
59 
60 
61 
62 // BasicJet
66  std::vector<reco::CandidatePtr> const & constituents,
67  edm::EventSetup const & c )
68 {
69  jet = reco::BasicJet( p4, point, constituents);
70 }
71 
72 // GenJet
76  std::vector<reco::CandidatePtr> const & constituents,
77  edm::EventSetup const & c )
78 {
79 
80  // Make the specific
82  makeSpecific (constituents, &specific);
83  // Set to the jet
84  jet = reco::GenJet( p4, point, specific, constituents);
85 }
86 
87 // PFJet
91  std::vector<reco::CandidatePtr> const & constituents,
92  edm::EventSetup const & c )
93 {
94  // Make the specific
96  makeSpecific (constituents, &specific);
97  // now make jet charge
98  int charge = 0.;
99  for ( std::vector<reco::CandidatePtr>::const_iterator ic = constituents.begin(),
100  icend = constituents.end();
101  ic != icend; ++ic ) {
102  charge += (*ic)->charge();
103  }
104  jet = reco::PFJet( p4, point, specific, constituents);
105  jet.setCharge( charge );
106 }
107 
108 
109 // TrackJet
112  reco::Particle::Point const & point,
113  std::vector<reco::CandidatePtr> const & constituents,
114  edm::EventSetup const & c )
115 {
116  jet = reco::TrackJet(p4, point, constituents);
117 }
118 
119 // PFClusterJet
122  reco::Particle::Point const & point,
123  std::vector<reco::CandidatePtr> const & constituents,
124  edm::EventSetup const & c )
125 {
126  jet = reco::PFClusterJet( p4, point, constituents);
127 }
128 
129 
130 
131 //______________________________________________________________________________
132 bool reco::makeSpecific(vector<reco::CandidatePtr> const & towers,
133  const CaloSubdetectorGeometry& towerGeometry,
134  CaloJet::Specific* caloJetSpecific)
135 {
136  if (0==caloJetSpecific) return false;
137 
138  // 1.- Loop over the tower Ids,
139  // 2.- Get the corresponding CaloTower
140  // 3.- Calculate the different CaloJet specific quantities
141  vector<double> eECal_i;
142  vector<double> eHCal_i;
143  double eInHad = 0.;
144  double eInEm = 0.;
145  double eInHO = 0.;
146  double eInHB = 0.;
147  double eInHE = 0.;
148  double eHadInHF = 0.;
149  double eEmInHF = 0.;
150  double eInEB = 0.;
151  double eInEE = 0.;
152  double jetArea = 0.;
153 
154  vector<reco::CandidatePtr>::const_iterator itTower;
155  for (itTower=towers.begin();itTower!=towers.end();++itTower) {
156  if ( itTower->isNull() || !itTower->isAvailable() ) {
157  edm::LogWarning("DataNotFound") << " JetSpecific: Tower is invalid\n";
158  continue;
159  }
160  const CaloTower* tower = dynamic_cast<const CaloTower*>(itTower->get());
161  if (tower) {
162  //Array of energy in EM Towers:
163  eECal_i.push_back(tower->emEnergy());
164  eInEm += tower->emEnergy();
165  //Array of energy in HCAL Towers:
166  eHCal_i.push_back(tower->hadEnergy());
167  eInHad += tower->hadEnergy();
168 
169  // figure out contributions
170  switch (reco::hcalSubdetector(tower->id().ieta())) {
171  case HcalBarrel:
172  eInHB += tower->hadEnergy();
173  eInHO += tower->outerEnergy();
174  eInEB += tower->emEnergy();
175  break;
176  case HcalEndcap:
177  eInHE += tower->hadEnergy();
178  eInEE += tower->emEnergy();
179  break;
180  case HcalForward:
181  eHadInHF += tower->hadEnergy();
182  eEmInHF += tower->emEnergy();
183  break;
184  default:
185  break;
186  }
187  // get area of the tower (++ minus --)
188  const CaloCellGeometry* geometry = towerGeometry.getGeometry(tower->id());
189  if (geometry) {
190  float dEta = fabs(geometry->getCorners()[0].eta()-
191  geometry->getCorners()[2].eta());
192  float dPhi = fabs(geometry->getCorners()[0].phi() -
193  geometry->getCorners()[2].phi());
194  jetArea += dEta * dPhi;
195  }
196  else {
197  edm::LogWarning("DataNotFound") <<"reco::makeCaloJetSpecific: Geometry for cell "
198  <<tower->id()<<" can not be found. Ignoring cell\n";
199  }
200  }
201  else {
202  edm::LogWarning("DataNotFound")<<"reco::makeCaloJetSpecific: Constituent is not of "
203  <<"CaloTower type\n";
204  }
205  }
206 
207  double towerEnergy = eInHad + eInEm;
208  caloJetSpecific->mHadEnergyInHO = eInHO;
209  caloJetSpecific->mHadEnergyInHB = eInHB;
210  caloJetSpecific->mHadEnergyInHE = eInHE;
211  caloJetSpecific->mHadEnergyInHF = eHadInHF;
212  caloJetSpecific->mEmEnergyInHF = eEmInHF;
213  caloJetSpecific->mEmEnergyInEB = eInEB;
214  caloJetSpecific->mEmEnergyInEE = eInEE;
215  if (towerEnergy > 0) {
216  caloJetSpecific->mEnergyFractionHadronic = eInHad / towerEnergy;
217  caloJetSpecific->mEnergyFractionEm = eInEm / towerEnergy;
218  }
219  else { // HO only jet
220  caloJetSpecific->mEnergyFractionHadronic = 1.;
221  caloJetSpecific->mEnergyFractionEm = 0.;
222  }
223  caloJetSpecific->mTowersArea = jetArea;
224  caloJetSpecific->mMaxEInEmTowers = 0;
225  caloJetSpecific->mMaxEInHadTowers = 0;
226 
227  //Sort the arrays
228  sort(eECal_i.begin(), eECal_i.end(), greater<double>());
229  sort(eHCal_i.begin(), eHCal_i.end(), greater<double>());
230 
231  if (!towers.empty()) {
232  //Highest value in the array is the first element of the array
233  caloJetSpecific->mMaxEInEmTowers = eECal_i.front();
234  caloJetSpecific->mMaxEInHadTowers = eHCal_i.front();
235  }
236 
237  return true;
238 }
239 
240 
241 //______________________________________________________________________________
242 bool reco::makeSpecific(vector<reco::CandidatePtr> const & particles,
243  PFJet::Specific* pfJetSpecific)
244 {
245  if (0==pfJetSpecific) return false;
246 
247  // 1.- Loop over PFCandidates,
248  // 2.- Get the corresponding PFCandidate
249  // 3.- Calculate the different PFJet specific quantities
250 
251  float chargedHadronEnergy=0.;
252  float neutralHadronEnergy=0.;
253  float photonEnergy=0.;
254  float electronEnergy=0.;
255  float muonEnergy=0.;
256  float HFHadronEnergy=0.;
257  float HFEMEnergy=0.;
260  int photonMultiplicity=0;
261  int electronMultiplicity=0;
262  int muonMultiplicity=0;
263  int HFHadronMultiplicity=0;
264  int HFEMMultiplicity=0;
265 
266  float chargedEmEnergy=0.;
267  float neutralEmEnergy=0.;
268  float chargedMuEnergy=0.;
269  int chargedMultiplicity=0;
270  int neutralMultiplicity=0;
271 
272  vector<reco::CandidatePtr>::const_iterator itParticle;
273  for (itParticle=particles.begin();itParticle!=particles.end();++itParticle){
274  if ( itParticle->isNull() || !itParticle->isAvailable() ) {
275  edm::LogWarning("DataNotFound") << " JetSpecific: PF Particle is invalid\n";
276  continue;
277  }
278  const PFCandidate* pfCand = dynamic_cast<const PFCandidate*> (itParticle->get());
279  if (pfCand) {
280  switch (PFCandidate::ParticleType(pfCand->particleId())) {
281  case PFCandidate::h: // charged hadron
282  chargedHadronEnergy += pfCand->energy();
283  chargedHadronMultiplicity++;
284  chargedMultiplicity++;
285  break;
286 
287  case PFCandidate::h0 : // neutral hadron
288  neutralHadronEnergy += pfCand->energy();
289  neutralHadronMultiplicity++;
290  neutralMultiplicity++;
291  break;
292 
293  case PFCandidate::gamma: // photon
294  photonEnergy += pfCand->energy();
295  photonMultiplicity++;
296  neutralEmEnergy += pfCand->energy();
297  neutralMultiplicity++;
298  break;
299 
300  case PFCandidate::e: // electron
301  electronEnergy += pfCand->energy();
302  electronMultiplicity++;
303  chargedEmEnergy += pfCand->energy();
304  chargedMultiplicity++;
305  break;
306 
307  case PFCandidate::mu: // muon
308  muonEnergy += pfCand->energy();
309  muonMultiplicity++;
310  chargedMuEnergy += pfCand->energy();
311  chargedMultiplicity++;
312  break;
313 
314  case PFCandidate::h_HF : // hadron in HF
315  HFHadronEnergy += pfCand->energy();
316  HFHadronMultiplicity++;
317  neutralMultiplicity++;
318  break;
319 
320  case PFCandidate::egamma_HF : // electromagnetic in HF
321  HFEMEnergy += pfCand->energy();
322  HFEMMultiplicity++;
323  neutralEmEnergy += pfCand->energy();
324  neutralMultiplicity++;
325  break;
326 
327 
328  default:
329  edm::LogWarning("DataNotFound") <<"reco::makePFJetSpecific: Unknown PFCandidate::ParticleType: "
330  <<pfCand->particleId()<<" is ignored\n";
331  break;
332  }
333  }
334  else {
335  edm::LogWarning("DataNotFound") <<"reco::makePFJetSpecific: Referred constituent is not "
336  <<"a PFCandidate\n";
337  }
338  }
339 
340  pfJetSpecific->mChargedHadronEnergy=chargedHadronEnergy;
341  pfJetSpecific->mNeutralHadronEnergy= neutralHadronEnergy;
342  pfJetSpecific->mPhotonEnergy= photonEnergy;
343  pfJetSpecific->mElectronEnergy= electronEnergy;
344  pfJetSpecific->mMuonEnergy= muonEnergy;
345  pfJetSpecific->mHFHadronEnergy= HFHadronEnergy;
346  pfJetSpecific->mHFEMEnergy= HFEMEnergy;
347 
350  pfJetSpecific->mPhotonMultiplicity= photonMultiplicity;
352  pfJetSpecific->mMuonMultiplicity= muonMultiplicity;
353  pfJetSpecific->mHFHadronMultiplicity= HFHadronMultiplicity;
354  pfJetSpecific->mHFEMMultiplicity= HFEMMultiplicity;
355 
356  pfJetSpecific->mChargedEmEnergy=chargedEmEnergy;
357  pfJetSpecific->mChargedMuEnergy=chargedMuEnergy;
358  pfJetSpecific->mNeutralEmEnergy=neutralEmEnergy;
359  pfJetSpecific->mChargedMultiplicity=chargedMultiplicity;
360  pfJetSpecific->mNeutralMultiplicity=neutralMultiplicity;
361 
362  return true;
363 }
364 
365 
366 //______________________________________________________________________________
367 bool reco::makeSpecific(vector<reco::CandidatePtr> const & mcparticles,
368  GenJet::Specific* genJetSpecific)
369 {
370  if (0==genJetSpecific) return false;
371 
372  vector<reco::CandidatePtr>::const_iterator itMcParticle=mcparticles.begin();
373  for (;itMcParticle!=mcparticles.end();++itMcParticle) {
374  if ( itMcParticle->isNull() || !itMcParticle->isAvailable() ) {
375  edm::LogWarning("DataNotFound") << " JetSpecific: MC Particle is invalid\n";
376  continue;
377  }
378  const Candidate* candidate = itMcParticle->get();
379  if (candidate->hasMasterClone()) candidate = candidate->masterClone().get();
380  const GenParticle* genParticle = GenJet::genParticle(candidate);
381  if (genParticle) {
382  double e = genParticle->energy();
383  switch (abs (genParticle->pdgId ())) {
384  case 22: // photon
385  case 11: // e
386  genJetSpecific->m_EmEnergy += e;
387  break;
388  case 211: // pi
389  case 321: // K
390  case 130: // KL
391  case 2212: // p
392  case 2112: // n
393  genJetSpecific->m_HadEnergy += e;
394  break;
395  case 13: // muon
396  case 12: // nu_e
397  case 14: // nu_mu
398  case 16: // nu_tau
399 
400  genJetSpecific->m_InvisibleEnergy += e;
401  break;
402  default:
403  genJetSpecific->m_AuxiliaryEnergy += e;
404  }
405  }
406  else {
407  edm::LogWarning("DataNotFound") <<"reco::makeGenJetSpecific: Referred GenParticleCandidate "
408  <<"is not available in the event\n";
409  }
410  }
411 
412  return true;
413 }
414 
415 
416 //______________________________________________________________________________
418 {
419  static const HcalTopology topology;
420  int eta = std::abs(iEta);
421  if (eta <= topology.lastHBRing()) return HcalBarrel;
422  else if (eta <= topology.lastHERing()) return HcalEndcap;
423  else if (eta <= topology.lastHFRing()) return HcalForward;
424  return HcalEmpty;
425 }
426 
427 
428 
float mMaxEInEmTowers
Maximum energy in EM towers.
Definition: CaloJet.h:49
virtual int pdgId() const
PDG identifier.
dictionary specific
ParticleType
particle types
Definition: PFCandidate.h:38
Jets made from CaloTowers.
Definition: CaloJet.h:30
float mEmEnergyInHF
Em energy in HF.
Definition: CaloJet.h:65
float mEnergyFractionHadronic
Hadronic energy fraction.
Definition: CaloJet.h:67
int mChargedMultiplicity
Definition: PFJet.h:70
virtual void setCharge(Charge q)
set electric charge
float mEmEnergyInEB
Em energy in EB.
Definition: CaloJet.h:61
bool makeSpecific(std::vector< reco::CandidatePtr > const &towers, const CaloSubdetectorGeometry &towerGeometry, reco::CaloJet::Specific *caloJetSpecific)
Make CaloJet specifics. Assumes PseudoJet is made from CaloTowerCandidates.
Definition: JetSpecific.cc:132
#define abs(x)
Definition: mlp_lapack.h:159
int lastHBRing() const
Definition: HcalTopology.h:62
int mPhotonMultiplicity
Definition: PFJet.h:59
float mNeutralHadronEnergy
Definition: PFJet.h:50
float mChargedMuEnergy
Definition: PFJet.h:68
float mHadEnergyInHB
Hadronic energy in HB.
Definition: CaloJet.h:55
T eta() const
Jets made from CaloTowers.
Definition: BasicJet.h:21
double charge(const std::vector< uint8_t > &Ampls)
Jets made from PFObjects.
Definition: PFJet.h:22
float mChargedHadronEnergy
Definition: PFJet.h:49
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
float mChargedEmEnergy
Definition: PFJet.h:67
virtual double energy() const
energy
virtual bool hasMasterClone() const =0
Jets made out of PFClusters.
Definition: PFClusterJet.h:27
double emEnergy() const
Definition: CaloTower.h:79
float mElectronEnergy
Definition: PFJet.h:52
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
static const int SubdetId
double p4[4]
Definition: TauolaWrapper.h:92
int mChargedHadronMultiplicity
Definition: PFJet.h:57
float mPhotonEnergy
Definition: PFJet.h:51
float mNeutralEmEnergy
Definition: PFJet.h:69
int lastHFRing() const
Definition: HcalTopology.h:66
HcalSubdetector
Definition: HcalAssistant.h:32
math::XYZPoint Point
point in the space
Definition: Particle.h:29
Jets made from MC generator particles.
Definition: GenJet.h:25
float mEnergyFractionEm
Em energy fraction.
Definition: CaloJet.h:69
float mHadEnergyInHF
Hadronic energy in HF.
Definition: CaloJet.h:57
const int mu
Definition: Constants.h:23
float m_InvisibleEnergy
Invisible energy (mu, nu, ...)
Definition: GenJet.h:39
float mMaxEInHadTowers
Maximum energy in HCAL towers.
Definition: CaloJet.h:51
int mElectronMultiplicity
Definition: PFJet.h:60
Jets made out of tracks.
Definition: TrackJet.h:28
double hadEnergy() const
Definition: CaloTower.h:80
CaloTowerDetId id() const
Definition: CaloTower.h:72
int mNeutralHadronMultiplicity
Definition: PFJet.h:58
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
const T & get() const
Definition: EventSetup.h:55
float m_AuxiliaryEnergy
Anything else (undecayed Sigmas etc.)
Definition: GenJet.h:41
float mHadEnergyInHO
Hadronic nergy fraction in HO.
Definition: CaloJet.h:53
ESHandle< TrackerGeometry > geometry
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
float mHFHadronEnergy
Definition: PFJet.h:54
float m_HadEnergy
Energy of Hadrons.
Definition: GenJet.h:37
T get() const
get a component
Definition: Candidate.h:216
float mTowersArea
Area of contributing CaloTowers.
Definition: CaloJet.h:71
HcalSubdetector hcalSubdetector(int iEta)
converts eta to the corresponding HCAL subdetector.
Definition: JetSpecific.cc:417
int ieta() const
get the tower ieta
virtual ParticleType particleId() const
Definition: PFCandidate.h:324
int mHFHadronMultiplicity
Definition: PFJet.h:62
float m_EmEnergy
Energy of EM particles.
Definition: GenJet.h:35
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
value_type const * get() const
Definition: RefToBase.h:212
float mEmEnergyInEE
Em energy in EE.
Definition: CaloJet.h:63
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
double outerEnergy() const
Definition: CaloTower.h:81
int lastHERing() const
Definition: HcalTopology.h:64
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
void writeSpecific(reco::CaloJet &jet, reco::Particle::LorentzVector const &p4, reco::Particle::Point const &point, std::vector< reco::CandidatePtr > const &constituents, edm::EventSetup const &c)
Definition: JetSpecific.cc:41
virtual const CandidateBaseRef & masterClone() const =0