CMS 3D CMS Logo

CastorJetIDHelper.cc
Go to the documentation of this file.
2 
7 
8 #include "TMath.h"
9 #include <vector>
10 #include <numeric>
11 #include <iostream>
12 
14 
16  emEnergy_ = 0.0;
17  hadEnergy_ = 0.0;
18  fem_ = 0.0;
19  width_ = 0.0;
20  depth_ = 0.0;
21  fhot_ = 0.0;
22  sigmaz_ = 0.0;
23  nTowers_ = 0;
24 }
25 
27  initValues();
28 
29  // calculate Castor JetID properties
30 
31  double zmean = 0.;
32  double z2mean = 0.;
33 
34  std::vector<CandidatePtr> ccp = jet.getJetConstituents();
35  std::vector<CandidatePtr>::const_iterator itParticle;
36  for (itParticle = ccp.begin(); itParticle != ccp.end(); ++itParticle) {
37  const CastorTower* castorcand = dynamic_cast<const CastorTower*>(itParticle->get());
38  emEnergy_ += castorcand->emEnergy();
39  hadEnergy_ += castorcand->hadEnergy();
40  depth_ += castorcand->depth() * castorcand->energy();
41  width_ += pow(phiangle(castorcand->phi() - jet.phi()), 2) * castorcand->energy();
42  fhot_ += castorcand->fhot() * castorcand->energy();
43 
44  // loop over rechits
45  for (edm::RefVector<edm::SortedCollection<CastorRecHit> >::iterator it = castorcand->rechitsBegin();
46  it != castorcand->rechitsEnd();
47  it++) {
49  double Erechit = rechit_p->energy();
50  HcalCastorDetId id = rechit_p->id();
51  int module = id.module();
52  double zrechit = 0;
53  if (module < 3)
54  zrechit = -14390 - 24.75 - 49.5 * (module - 1);
55  if (module > 2)
56  zrechit = -14390 - 99 - 49.5 - 99 * (module - 3);
57  zmean += Erechit * zrechit;
58  z2mean += Erechit * zrechit * zrechit;
59  } // end loop over rechits
60 
61  nTowers_++;
62  }
63  //cout << "" << endl;
64 
65  depth_ = depth_ / jet.energy();
66  width_ = sqrt(width_ / jet.energy());
67  fhot_ = fhot_ / jet.energy();
68  fem_ = emEnergy_ / jet.energy();
69 
70  zmean = zmean / jet.energy();
71  z2mean = z2mean / jet.energy();
72  double sigmaz2 = z2mean - zmean * zmean;
73  if (sigmaz2 > 0)
74  sigmaz_ = sqrt(sigmaz2);
75 }
76 
77 // help function to calculate phi within [-pi,+pi]
79  double phi = testphi;
80  while (phi > M_PI)
81  phi -= (2 * M_PI);
82  while (phi < -M_PI)
83  phi += (2 * M_PI);
84  return phi;
85 }
reco::CastorTower::emEnergy
double emEnergy() const
tower em energy
Definition: CastorTower.h:60
MessageLogger.h
CastorTower.h
reco::CastorTower::hadEnergy
double hadEnergy() const
tower had energy
Definition: CastorTower.h:63
module::module
module()
Definition: vlib.cc:913
reco::helper::CastorJetIDHelper::CastorJetIDHelper
CastorJetIDHelper()
Definition: CastorJetIDHelper.cc:13
reco::CastorTower::depth
double depth() const
tower depth in z
Definition: CastorTower.h:69
edm::SortedCollection
Definition: SortedCollection.h:49
CastorJetIDHelper.h
edm::RefVector
Definition: EDProductfwd.h:27
reco::helper::CastorJetIDHelper::calculate
void calculate(const edm::Event &event, const reco::BasicJet &jet)
Definition: CastorJetIDHelper.cc:26
edm::Ref
Definition: AssociativeIterator.h:58
reco::BasicJet
Jets made from CaloTowers.
Definition: BasicJet.h:19
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::CastorTower::rechitsEnd
CastorRecHitRefs::iterator rechitsEnd() const
last iterator over CastorRecHit constituents
Definition: CastorTower.h:81
reco::helper::CastorJetIDHelper::initValues
void initValues()
Definition: CastorJetIDHelper.cc:15
HcalCastorDetId
Definition: HcalCastorDetId.h:23
reco::CastorTower::fhot
double fhot() const
tower hotcell/tot ratio
Definition: CastorTower.h:72
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
module
Definition: vlib.h:198
reco::helper::CastorJetIDHelper::phiangle
double phiangle(double testphi)
Definition: CastorJetIDHelper.cc:78
edm::Ref::id
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
reco::CastorTower::rechitsBegin
CastorRecHitRefs::iterator rechitsBegin() const
fist iterator over CastorRecHit constituents
Definition: CastorTower.h:78
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
metsig::jet
Definition: SignAlgoResolutions.h:47
reco::CastorTower
Definition: CastorTower.h:26
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
CastorRecHit.h
HcalCastorDetId.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73