CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
13 
15 {
16 
17  initValues();
18 }
19 
21 {
22  emEnergy_ = 0.0;
23  hadEnergy_ = 0.0;
24  fem_ = 0.0;
25  width_ = 0.0;
26  depth_ = 0.0;
27  fhot_ = 0.0;
28  sigmaz_ = 0.0;
29  nTowers_ = 0;
30 }
31 
32 
34 {
35  initValues();
36 
37  // calculate Castor JetID properties
38 
39  double zmean = 0.;
40  double z2mean = 0.;
41 
42  std::vector<CandidatePtr> ccp = jet.getJetConstituents();
43  std::vector<CandidatePtr>::const_iterator itParticle;
44  for (itParticle=ccp.begin();itParticle!=ccp.end();++itParticle){
45  const CastorTower* castorcand = dynamic_cast<const CastorTower*>(itParticle->get());
46  emEnergy_ += castorcand->emEnergy();
47  hadEnergy_ += castorcand->hadEnergy();
48  depth_ += castorcand->depth()*castorcand->energy();
49  width_ += pow(phiangle(castorcand->phi() - jet.phi()),2)*castorcand->energy();
50  fhot_ += castorcand->fhot()*castorcand->energy();
51 
52  // loop over rechits
53  for (edm::RefVector<edm::SortedCollection<CastorRecHit> >::iterator it = castorcand->rechitsBegin(); it != castorcand->rechitsEnd(); it++) {
55  double Erechit = rechit_p->energy();
56  HcalCastorDetId id = rechit_p->id();
57  int module = id.module();
58  double zrechit = 0;
59  if (module < 3) zrechit = -14390 - 24.75 - 49.5*(module-1);
60  if (module > 2) zrechit = -14390 - 99 - 49.5 - 99*(module-3);
61  zmean += Erechit*zrechit;
62  z2mean += Erechit*zrechit*zrechit;
63  } // end loop over rechits
64 
65  nTowers_++;
66  }
67  //cout << "" << endl;
68 
69  depth_ = depth_/jet.energy();
70  width_ = sqrt(width_/jet.energy());
71  fhot_ = fhot_/jet.energy();
72  fem_ = emEnergy_/jet.energy();
73 
74  zmean = zmean/jet.energy();
75  z2mean = z2mean/jet.energy();
76  double sigmaz2 = z2mean - zmean*zmean;
77  if(sigmaz2 > 0) sigmaz_ = sqrt(sigmaz2);
78 
79 
80 }
81 
82 // help function to calculate phi within [-pi,+pi]
84  double phi = testphi;
85  while (phi>M_PI) phi -= (2*M_PI);
86  while (phi<-M_PI) phi += (2*M_PI);
87  return phi;
88 }
89 
90 
91 
double emEnergy() const
tower em energy
Definition: CastorTower.h:52
module()
Definition: vlib.cc:994
CastorRecHitRefs::iterator rechitsBegin() const
fist iterator over CastorRecHit constituents
Definition: CastorTower.h:70
Jets made from CaloTowers.
Definition: BasicJet.h:21
virtual double energy() const
energy
void calculate(const edm::Event &event, const reco::BasicJet &jet)
T sqrt(T t)
Definition: SSEVec.h:46
double phiangle(double testphi)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
double energy() const
tower energy
Definition: CastorTower.h:46
#define M_PI
Definition: BFit3D.cc:3
double fhot() const
tower hotcell/tot ratio
Definition: CastorTower.h:64
double depth() const
tower depth in z
Definition: CastorTower.h:61
double hadEnergy() const
tower had energy
Definition: CastorTower.h:55
CastorRecHitRefs::iterator rechitsEnd() const
last iterator over CastorRecHit constituents
Definition: CastorTower.h:73
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
virtual double phi() const
momentum azimuthal angle
Definition: vlib.h:209
double phi() const
azimuthal angle of tower centroid
Definition: CastorTower.h:97
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual Constituents getJetConstituents() const
list of constituents
Definition: Jet.cc:351
Definition: DDAxes.h:10