CMS 3D CMS Logo

ClusterTools.cc
Go to the documentation of this file.
2 
7 
9 
13 
14 #include "vdt/vdtMath.h"
15 
16 using namespace hgcal;
17 
19  edm::ConsumesCollector& sumes):
20  eetok( sumes.consumes<HGCRecHitCollection>(conf.getParameter<edm::InputTag>("HGCEEInput")) ),
21  fhtok( sumes.consumes<HGCRecHitCollection>(conf.getParameter<edm::InputTag>("HGCFHInput")) ),
22  bhtok( sumes.consumes<HGCRecHitCollection>(conf.getParameter<edm::InputTag>("HGCBHInput")) ) {
23 }
24 
26  rhtools_.getEvent(ev);
28  ev.getByToken(eetok, temp);
29  eerh_ = temp.product();
30  ev.getByToken(fhtok, temp);
31  fhrh_ = temp.product();
32  ev.getByToken(bhtok, temp);
33  bhrh_ = temp.product();
34 }
35 
38 }
39 
41  float energy=0.f, energyHad=0.f;
42  const auto& hits = clus.hitsAndFractions();
43  for( const auto& hit : hits ) {
44  const auto& id = hit.first;
45  const float fraction = hit.second;
46  if( id.det() == DetId::Forward ) {
47  switch( id.subdetId() ) {
48  case HGCEE:
49  energy += eerh_->find(id)->energy()*fraction;
50  break;
51  case HGCHEF:
52  {
53  const float temp = fhrh_->find(id)->energy();
54  energy += temp*fraction;
55  energyHad += temp*fraction;
56  }
57  break;
58  default:
59  throw cms::Exception("HGCalClusterTools")
60  << " Cluster contains hits that are not from HGCal! " << std::endl;
61  }
62  } else if ( id.det() == DetId::Hcal && id.subdetId() == HcalEndcap ) {
63  const float temp = bhrh_->find(id)->energy();
64  energy += temp*fraction;
65  energyHad += temp*fraction;
66  } else {
67  throw cms::Exception("HGCalClusterTools")
68  << " Cluster contains hits that are not from HGCal! " << std::endl;
69  }
70  }
71  float fraction = -1.f;
72  if( energy > 0.f ) {
73  fraction = energyHad/energy;
74  }
75  return fraction;
76 }
77 
78 
80  if( clu.clusters().size() == 0 ) return math::XYZPoint();
81  double acc_rho = 0.0;
82  double acc_eta = 0.0;
83  double acc_phi = 0.0;
84  double totweight = 0.;
85  for( const auto& ptr : clu.clusters() ) {
86  const double x = ptr->x();
87  const double y = ptr->y();
88  const double point_r2 = (x*x + y*y);
89  const double point_z = ptr->z()-vz;
90  const double point_h = std::sqrt(point_r2 + point_z*point_z);
91  const double weight = ptr->energy() * ptr->size();
92  assert((y != 0. || x != 0.) && "Cluster position somehow in beampipe.");
93  assert(point_z != 0.f && "Layer-cluster position given as reference point.");
94  const double point_r = std::sqrt(point_r2);
95  acc_rho += point_r * weight;
96  acc_phi += vdt::fast_atan2(y,x) * weight;
97  acc_eta += -1. * vdt::fast_log(point_r/(point_z + point_h)) * weight;
98  totweight += weight;
99  }
100  const double invweight = 1.0/totweight;
101  reco::PFCluster::REPPoint temp(acc_rho*invweight,acc_eta*invweight,acc_phi*invweight);
102  return math::XYZPoint(temp.x(),temp.y(),temp.z());
103 }
104 
106  double acc = 0.0;
107  for(const auto& ptr : clu.clusters() ) {
108  acc += ptr->energy();
109  }
110  return acc;
111 }
void getEvent(const edm::Event &)
Definition: RecHitTools.cc:63
void getEvent(const edm::Event &)
Definition: ClusterTools.cc:25
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
ClusterTools(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: ClusterTools.cc:18
Definition: weight.py:1
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:195
bool ev
void getEventSetup(const edm::EventSetup &)
Definition: RecHitTools.cc:66
T x() const
Cartesian x coordinate.
RecHitTools rhtools_
Definition: ClusterTools.h:42
const edm::PtrVector< reco::BasicCluster > & clusters() const
T sqrt(T t)
Definition: SSEVec.h:18
math::XYZPoint getMultiClusterPosition(const reco::HGCalMultiCluster &, double vz=0.) const
Definition: ClusterTools.cc:79
double f[11][100]
const HGCRecHitCollection * eerh_
Definition: ClusterTools.h:44
double getMultiClusterEnergy(const reco::HGCalMultiCluster &) const
T const * product() const
Definition: Handle.h:81
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
float getClusterHadronFraction(const reco::CaloCluster &) const
Definition: ClusterTools.cc:40
const edm::EDGetTokenT< HGCRecHitCollection > fhtok
Definition: ClusterTools.h:43
const edm::EDGetTokenT< HGCRecHitCollection > eetok
Definition: ClusterTools.h:43
iterator find(key_type k)
const HGCRecHitCollection * bhrh_
Definition: ClusterTools.h:44
HLT enums.
const edm::EDGetTokenT< HGCRecHitCollection > bhtok
Definition: ClusterTools.h:43
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:54
const HGCRecHitCollection * fhrh_
Definition: ClusterTools.h:44
void getEventSetup(const edm::EventSetup &)
Definition: ClusterTools.cc:36