test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterTools.cc
Go to the documentation of this file.
2 
7 
9 
13 
14 using namespace hgcal;
15 
17  edm::ConsumesCollector& sumes):
18  eetok( sumes.consumes<HGCRecHitCollection>(conf.getParameter<edm::InputTag>("HGCEEInput")) ),
19  fhtok( sumes.consumes<HGCRecHitCollection>(conf.getParameter<edm::InputTag>("HGCFHInput")) ),
20  bhtok( sumes.consumes<HGCRecHitCollection>(conf.getParameter<edm::InputTag>("HGCBHInput")) ) {
21 }
22 
24  rhtools_.getEvent(ev);
26  ev.getByToken(eetok, temp);
27  eerh_ = temp.product();
28  ev.getByToken(fhtok, temp);
29  fhrh_ = temp.product();
30  ev.getByToken(bhtok, temp);
31  bhrh_ = temp.product();
32 }
33 
36 }
37 
39  float energy=0.f, energyHad=0.f;
40  const auto& hits = clus.hitsAndFractions();
41  for( const auto& hit : hits ) {
42  const auto& id = hit.first;
43  const float fraction = hit.second;
44  if( id.det() == DetId::Forward ) {
45  switch( id.subdetId() ) {
46  case HGCEE:
47  energy += eerh_->find(id)->energy()*fraction;
48  break;
49  case HGCHEF:
50  {
51  const float temp = fhrh_->find(id)->energy();
52  energy += temp*fraction;
53  energyHad += temp*fraction;
54  }
55  break;
56  default:
57  throw cms::Exception("HGCalClusterTools")
58  << " Cluster contains hits that are not from HGCal! " << std::endl;
59  }
60  } else if ( id.det() == DetId::Hcal && id.subdetId() == HcalEndcap ) {
61  const float temp = bhrh_->find(id)->energy();
62  energy += temp*fraction;
63  energyHad += temp*fraction;
64  } else {
65  throw cms::Exception("HGCalClusterTools")
66  << " Cluster contains hits that are not from HGCal! " << std::endl;
67  }
68  }
69  float fraction = -1.f;
70  if( energy > 0.f ) {
71  fraction = energyHad/energy;
72  }
73  return fraction;
74 }
75 
76 
78  if( clu.clusters().size() == 0 ) return math::XYZPoint();
79  double acc_rho = 0.0;
80  double acc_eta = 0.0;
81  double acc_phi = 0.0;
82  double totweight = 0.;
83  for( const auto& ptr : clu.clusters() ) {
84  const double x = ptr->x();
85  const double y = ptr->y();
86  const float point_r = std::sqrt(x*x + y*y);
87  const double point_z = ptr->z()-vz;
88  const double weight = ptr->energy() * ptr->size();
89  assert((y != 0. || x != 0.) && "Cluster position somehow in beampipe.");
90  assert(point_z != 0. && "Layer-cluster position given as reference point.");
91  acc_rho += point_r * weight;
92  acc_phi += std::atan2(y,x) * weight;
93  acc_eta += -1. * std::log(std::tan(0.5*std::atan2(point_r,point_z))) * weight;
94  totweight += weight;
95  }
96  const double invweight = 1.0/totweight;
97  reco::PFCluster::REPPoint temp(acc_rho*invweight,acc_eta*invweight,acc_phi*invweight);
98  return math::XYZPoint(temp.x(),temp.y(),temp.z());
99 }
100 
102  double acc = 0.0;
103  for(const auto& ptr : clu.clusters() ) {
104  acc += ptr->energy();
105  }
106  return acc;
107 }
void getEvent(const edm::Event &)
Definition: RecHitTools.cc:63
void getEvent(const edm::Event &)
Definition: ClusterTools.cc:23
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
assert(m_qm.get())
ClusterTools(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: ClusterTools.cc:16
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:192
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:77
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
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:38
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
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
int weight
Definition: histoStyle.py:50
void getEventSetup(const edm::EventSetup &)
Definition: ClusterTools.cc:34