CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 }
double emEnergy() const
tower em energy
Definition: CastorTower.h:60
CastorRecHitRefs::iterator rechitsBegin() const
fist iterator over CastorRecHit constituents
Definition: CastorTower.h:78
virtual Constituents getJetConstituents() const
list of constituents
Jets made from CaloTowers.
Definition: BasicJet.h:19
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
void calculate(const edm::Event &event, const reco::BasicJet &jet)
T sqrt(T t)
Definition: SSEVec.h:19
double phiangle(double testphi)
#define M_PI
double fhot() const
tower hotcell/tot ratio
Definition: CastorTower.h:72
double depth() const
tower depth in z
Definition: CastorTower.h:69
double hadEnergy() const
tower had energy
Definition: CastorTower.h:63
CastorRecHitRefs::iterator rechitsEnd() const
last iterator over CastorRecHit constituents
Definition: CastorTower.h:81
double phi() const final
momentum azimuthal angle
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
tuple module
Definition: callgraph.py:69
double energy() const final
energy