test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
hgcal::ClusterTools Class Reference

#include <ClusterTools.h>

Public Member Functions

 ClusterTools (const edm::ParameterSet &, edm::ConsumesCollector &)
 
float getClusterHadronFraction (const reco::CaloCluster &) const
 
void getEvent (const edm::Event &)
 
void getEventSetup (const edm::EventSetup &)
 
double getMultiClusterEnergy (const reco::HGCalMultiCluster &) const
 
math::XYZPoint getMultiClusterPosition (const reco::HGCalMultiCluster &, double vz=0.) const
 
 ~ClusterTools ()
 

Private Attributes

const HGCRecHitCollectionbhrh_
 
const edm::EDGetTokenT
< HGCRecHitCollection
bhtok
 
const HGCRecHitCollectioneerh_
 
const edm::EDGetTokenT
< HGCRecHitCollection
eetok
 
const HGCRecHitCollectionfhrh_
 
const edm::EDGetTokenT
< HGCRecHitCollection
fhtok
 
RecHitTools rhtools_
 

Detailed Description

Definition at line 26 of file ClusterTools.h.

Constructor & Destructor Documentation

ClusterTools::ClusterTools ( const edm::ParameterSet conf,
edm::ConsumesCollector sumes 
)

Definition at line 16 of file ClusterTools.cc.

17  :
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 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
const edm::EDGetTokenT< HGCRecHitCollection > fhtok
Definition: ClusterTools.h:43
const edm::EDGetTokenT< HGCRecHitCollection > eetok
Definition: ClusterTools.h:43
const edm::EDGetTokenT< HGCRecHitCollection > bhtok
Definition: ClusterTools.h:43
hgcal::ClusterTools::~ClusterTools ( )
inline

Definition at line 29 of file ClusterTools.h.

29 {}

Member Function Documentation

float ClusterTools::getClusterHadronFraction ( const reco::CaloCluster clus) const

Definition at line 38 of file ClusterTools.cc.

References bhrh_, eerh_, relval_parameters_module::energy, Exception, f, fhrh_, edm::SortedCollection< T, SORT >::find(), DetId::Forward, HLT_25ns10e33_v2_cff::fraction, DetId::Hcal, HcalEndcap, HGCEE, HGCHEF, reco::CaloCluster::hitsAndFractions(), and groupFilesInBlocks::temp.

38  {
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 }
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:192
double f[11][100]
const HGCRecHitCollection * eerh_
Definition: ClusterTools.h:44
iterator find(key_type k)
const HGCRecHitCollection * bhrh_
Definition: ClusterTools.h:44
const HGCRecHitCollection * fhrh_
Definition: ClusterTools.h:44
void ClusterTools::getEvent ( const edm::Event ev)

Definition at line 23 of file ClusterTools.cc.

References bhrh_, bhtok, eerh_, eetok, fhrh_, fhtok, edm::Event::getByToken(), hgcal::RecHitTools::getEvent(), edm::Handle< T >::product(), rhtools_, and groupFilesInBlocks::temp.

23  {
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 }
void getEvent(const edm::Event &)
Definition: RecHitTools.cc:63
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
RecHitTools rhtools_
Definition: ClusterTools.h:42
const HGCRecHitCollection * eerh_
Definition: ClusterTools.h:44
T const * product() const
Definition: Handle.h:81
const edm::EDGetTokenT< HGCRecHitCollection > fhtok
Definition: ClusterTools.h:43
const edm::EDGetTokenT< HGCRecHitCollection > eetok
Definition: ClusterTools.h:43
const HGCRecHitCollection * bhrh_
Definition: ClusterTools.h:44
const edm::EDGetTokenT< HGCRecHitCollection > bhtok
Definition: ClusterTools.h:43
const HGCRecHitCollection * fhrh_
Definition: ClusterTools.h:44
void ClusterTools::getEventSetup ( const edm::EventSetup es)

Definition at line 34 of file ClusterTools.cc.

References hgcal::RecHitTools::getEventSetup(), and rhtools_.

34  {
36 }
void getEventSetup(const edm::EventSetup &)
Definition: RecHitTools.cc:66
RecHitTools rhtools_
Definition: ClusterTools.h:42
double ClusterTools::getMultiClusterEnergy ( const reco::HGCalMultiCluster clu) const

Definition at line 101 of file ClusterTools.cc.

References reco::HGCalMultiCluster::clusters().

101  {
102  double acc = 0.0;
103  for(const auto& ptr : clu.clusters() ) {
104  acc += ptr->energy();
105  }
106  return acc;
107 }
const edm::PtrVector< reco::BasicCluster > & clusters() const
math::XYZPoint ClusterTools::getMultiClusterPosition ( const reco::HGCalMultiCluster clu,
double  vz = 0. 
) const

Definition at line 77 of file ClusterTools.cc.

References assert(), reco::HGCalMultiCluster::clusters(), dqm-mbProfile::log, mathSSE::sqrt(), funct::tan(), groupFilesInBlocks::temp, histoStyle::weight, and x().

77  {
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 }
assert(m_qm.get())
const edm::PtrVector< reco::BasicCluster > & clusters() const
T sqrt(T t)
Definition: SSEVec.h:18
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:54
int weight
Definition: histoStyle.py:50

Member Data Documentation

const HGCRecHitCollection * hgcal::ClusterTools::bhrh_
private

Definition at line 44 of file ClusterTools.h.

Referenced by getClusterHadronFraction(), and getEvent().

const edm::EDGetTokenT<HGCRecHitCollection> hgcal::ClusterTools::bhtok
private

Definition at line 43 of file ClusterTools.h.

Referenced by getEvent().

const HGCRecHitCollection* hgcal::ClusterTools::eerh_
private

Definition at line 44 of file ClusterTools.h.

Referenced by getClusterHadronFraction(), and getEvent().

const edm::EDGetTokenT<HGCRecHitCollection> hgcal::ClusterTools::eetok
private

Definition at line 43 of file ClusterTools.h.

Referenced by getEvent().

const HGCRecHitCollection * hgcal::ClusterTools::fhrh_
private

Definition at line 44 of file ClusterTools.h.

Referenced by getClusterHadronFraction(), and getEvent().

const edm::EDGetTokenT<HGCRecHitCollection> hgcal::ClusterTools::fhtok
private

Definition at line 43 of file ClusterTools.h.

Referenced by getEvent().

RecHitTools hgcal::ClusterTools::rhtools_
private

Definition at line 42 of file ClusterTools.h.

Referenced by getEvent(), and getEventSetup().