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 Member Functions | Private Attributes
Basic2DGenericPFlowPositionCalc Class Reference

#include <Basic2DGenericPFlowPositionCalc.h>

Inheritance diagram for Basic2DGenericPFlowPositionCalc:
PFCPositionCalculatorBase

Public Member Functions

 Basic2DGenericPFlowPositionCalc (const edm::ParameterSet &conf)
 
 Basic2DGenericPFlowPositionCalc (const Basic2DGenericPFlowPositionCalc &)=delete
 
void calculateAndSetPosition (reco::PFCluster &)
 
void calculateAndSetPositions (reco::PFClusterCollection &)
 
Basic2DGenericPFlowPositionCalcoperator= (const Basic2DGenericPFlowPositionCalc &)=delete
 
- Public Member Functions inherited from PFCPositionCalculatorBase
const std::string & name () const
 
PosCalcoperator= (const PosCalc &)=delete
 
 PFCPositionCalculatorBase (const edm::ParameterSet &conf)
 
 PFCPositionCalculatorBase (const PosCalc &)=delete
 
virtual void update (const edm::EventSetup &)
 
 ~PFCPositionCalculatorBase ()
 

Private Member Functions

void calculateAndSetPositionActual (reco::PFCluster &) const
 

Private Attributes

const double _logWeightDenom
 
const double _minAllowedNorm
 
const int _posCalcNCrystals
 
std::unique_ptr
< CaloRecHitResolutionProvider
_timeResolutionCalcBarrel
 
std::unique_ptr
< CaloRecHitResolutionProvider
_timeResolutionCalcEndcap
 

Additional Inherited Members

- Protected Attributes inherited from PFCPositionCalculatorBase
const float _minFractionInCalc
 

Detailed Description

Definition at line 10 of file Basic2DGenericPFlowPositionCalc.h.

Constructor & Destructor Documentation

Basic2DGenericPFlowPositionCalc::Basic2DGenericPFlowPositionCalc ( const edm::ParameterSet conf)
inline

Definition at line 12 of file Basic2DGenericPFlowPositionCalc.h.

References _timeResolutionCalcBarrel, _timeResolutionCalcEndcap, edm::ParameterSet::exists(), edm::ParameterSet::getParameterSet(), and NULL.

12  :
14  _posCalcNCrystals(conf.getParameter<int>("posCalcNCrystals")),
15  _logWeightDenom(conf.getParameter<double>("logWeightDenominator")),
16  _minAllowedNorm(conf.getParameter<double>("minAllowedNormalization"))
17 
18  {
20  if( conf.exists("timeResolutionCalcBarrel") ) {
21  const edm::ParameterSet& timeResConf =
22  conf.getParameterSet("timeResolutionCalcBarrel");
24  }
26  if( conf.exists("timeResolutionCalcEndcap") ) {
27  const edm::ParameterSet& timeResConf =
28  conf.getParameterSet("timeResolutionCalcEndcap");
30  }
31  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
#define NULL
Definition: scimark2.h:8
ParameterSet const & getParameterSet(std::string const &) const
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcBarrel
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcEndcap
PFCPositionCalculatorBase(const edm::ParameterSet &conf)
Basic2DGenericPFlowPositionCalc::Basic2DGenericPFlowPositionCalc ( const Basic2DGenericPFlowPositionCalc )
delete

Member Function Documentation

void Basic2DGenericPFlowPositionCalc::calculateAndSetPosition ( reco::PFCluster cluster)
virtual

Implements PFCPositionCalculatorBase.

Definition at line 12 of file Basic2DGenericPFlowPositionCalc.cc.

References calculateAndSetPositionActual().

12  {
14 }
void calculateAndSetPositionActual(reco::PFCluster &) const
void Basic2DGenericPFlowPositionCalc::calculateAndSetPositionActual ( reco::PFCluster cluster) const
private

Definition at line 24 of file Basic2DGenericPFlowPositionCalc.cc.

References _logWeightDenom, _minAllowedNorm, PFCPositionCalculatorBase::_minFractionInCalc, _posCalcNCrystals, _timeResolutionCalcBarrel, _timeResolutionCalcEndcap, edm::RefVector< C, T, F >::begin(), reco::PFCluster::calculatePositionREP(), HLT_25ns14e33_v1_cff::depth, PFLayer::ECAL_BARREL, edm::RefVector< C, T, F >::end(), edm::hlt::Exception, spr::find(), PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, edm::isNotFinite(), bookConverter::max, PFLayer::NONE, NULL, reco::PFCluster::recHitFractions(), reco::CaloCluster::seed(), reco::PFCluster::setDepth(), reco::CaloCluster::setEnergy(), reco::PFCluster::setLayer(), reco::CaloCluster::setPosition(), reco::PFCluster::setTime(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by calculateAndSetPosition(), and calculateAndSetPositions().

24  {
25  if( !cluster.seed() ) {
26  throw cms::Exception("ClusterWithNoSeed")
27  << " Found a cluster with no seed: " << cluster;
28  }
29  double cl_energy = 0;
30  double cl_time = 0;
31  double cl_timeweight=0.0;
32  double max_e = 0.0;
33  PFLayer::Layer max_e_layer = PFLayer::NONE;
34  reco::PFRecHitRef refseed;
35  // find the seed and max layer and also calculate time
36  //Michalis : Even if we dont use timing in clustering here we should fill
37  //the time information for the cluster. This should use the timing resolution(1/E)
38  //so the weight should be fraction*E^2
39  //calculate a simplistic depth now. The log weighted will be done
40  //in different stage
41  for( const reco::PFRecHitFraction& rhf : cluster.recHitFractions() ) {
42  const reco::PFRecHitRef& refhit = rhf.recHitRef();
43  if( refhit->detId() == cluster.seed() ) refseed = refhit;
44  const double rh_fraction = rhf.fraction();
45  const double rh_rawenergy = refhit->energy();
46  const double rh_energy = rh_rawenergy * rh_fraction;
47  if( edm::isNotFinite(rh_energy) ) {
48  throw cms::Exception("PFClusterAlgo")
49  <<"rechit " << refhit->detId() << " has a NaN energy... "
50  << "The input of the particle flow clustering seems to be corrupted.";
51  }
52  cl_energy += rh_energy;
53  // If time resolution is given, calculated weighted average
55  double res2 = 10000.;
56  int cell_layer = (int)refhit->layer();
57  if (cell_layer == PFLayer::HCAL_BARREL1 ||
58  cell_layer == PFLayer::HCAL_BARREL2 ||
59  cell_layer == PFLayer::ECAL_BARREL)
60  res2 = _timeResolutionCalcBarrel->timeResolution2(rh_rawenergy);
61  else
62  res2 = _timeResolutionCalcEndcap->timeResolution2(rh_rawenergy);
63  cl_time += rh_fraction*refhit->time()/res2;
64  cl_timeweight += rh_fraction/res2;
65  }
66  else { // assume resolution = 1/E**2
67  const double rh_rawenergy2 = rh_rawenergy*rh_rawenergy;
68  cl_timeweight+=rh_rawenergy2*rh_fraction;
69  cl_time += rh_rawenergy2*rh_fraction*refhit->time();
70  }
71 
72  if( rh_energy > max_e ) {
73  max_e = rh_energy;
74  max_e_layer = rhf.recHitRef()->layer();
75  }
76  }
77  cluster.setEnergy(cl_energy);
78  cluster.setTime(cl_time/cl_timeweight);
79  cluster.setLayer(max_e_layer);
80  // calculate the position
81 
82  double depth = 0.0;
83  double position_norm = 0.0;
84  double x(0.0),y(0.0),z(0.0);
85  const reco::PFRecHitRefVector* seedNeighbours = NULL;
86  switch( _posCalcNCrystals ) {
87  case 5:
88  seedNeighbours = &refseed->neighbours4();
89  break;
90  case 9:
91  seedNeighbours = &refseed->neighbours8();
92  break;
93  default:
94  break;
95  }
96 
97  for( const reco::PFRecHitFraction& rhf : cluster.recHitFractions() ) {
98  const reco::PFRecHitRef& refhit = rhf.recHitRef();
99 
100  if( refhit != refseed && _posCalcNCrystals != -1 ) {
101  auto pos = std::find(seedNeighbours->begin(),seedNeighbours->end(),
102  refhit);
103  if( pos == seedNeighbours->end() ) continue;
104  }
105 
106  const double rh_energy = refhit->energy() * ((float)rhf.fraction());
107  const double norm = ( rhf.fraction() < _minFractionInCalc ?
108  0.0 :
109  std::max(0.0,vdt::fast_log(rh_energy/_logWeightDenom)) );
110  const math::XYZPoint& rhpos_xyz = refhit->position();
111  x += rhpos_xyz.X() * norm;
112  y += rhpos_xyz.Y() * norm;
113  z += rhpos_xyz.Z() * norm;
114  depth += refhit->depth()*norm;
115 
116  position_norm += norm;
117  }
118  if( position_norm < _minAllowedNorm ) {
119  edm::LogError("WeirdClusterNormalization")
120  << "PFCluster too far from seeding cell: set position to (0,0,0).";
121  cluster.setPosition(math::XYZPoint(0,0,0));
122  cluster.calculatePositionREP();
123  } else {
124  const double norm_inverse = 1.0/position_norm;
125  x *= norm_inverse;
126  y *= norm_inverse;
127  z *= norm_inverse;
128  depth *= norm_inverse;
129  cluster.setPosition(math::XYZPoint(x,y,z));
130  cluster.setDepth(depth);
131  cluster.calculatePositionREP();
132  }
133 }
void setLayer(PFLayer::Layer layer)
set layer
Definition: PFCluster.cc:78
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:112
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
void setEnergy(double energy)
Definition: CaloCluster.h:108
#define NULL
Definition: scimark2.h:8
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
float float float z
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
bool isNotFinite(T x)
Definition: isFinite.h:10
void setTime(double time)
Definition: PFCluster.h:89
void calculatePositionREP()
computes posrep_ once and for all
Definition: PFCluster.h:96
Layer
layer definition
Definition: PFLayer.h:31
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:202
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcBarrel
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcEndcap
void setDepth(double depth)
Definition: PFCluster.h:90
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
Definition: DDAxes.h:10
void Basic2DGenericPFlowPositionCalc::calculateAndSetPositions ( reco::PFClusterCollection clusters)
virtual

Implements PFCPositionCalculatorBase.

Definition at line 17 of file Basic2DGenericPFlowPositionCalc.cc.

References calculateAndSetPositionActual().

17  {
18  for( reco::PFCluster& cluster : clusters ) {
20  }
21 }
void calculateAndSetPositionActual(reco::PFCluster &) const
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
Basic2DGenericPFlowPositionCalc& Basic2DGenericPFlowPositionCalc::operator= ( const Basic2DGenericPFlowPositionCalc )
delete

Member Data Documentation

const double Basic2DGenericPFlowPositionCalc::_logWeightDenom
private

Definition at line 40 of file Basic2DGenericPFlowPositionCalc.h.

Referenced by calculateAndSetPositionActual().

const double Basic2DGenericPFlowPositionCalc::_minAllowedNorm
private

Definition at line 41 of file Basic2DGenericPFlowPositionCalc.h.

Referenced by calculateAndSetPositionActual().

const int Basic2DGenericPFlowPositionCalc::_posCalcNCrystals
private

Definition at line 39 of file Basic2DGenericPFlowPositionCalc.h.

Referenced by calculateAndSetPositionActual().

std::unique_ptr<CaloRecHitResolutionProvider> Basic2DGenericPFlowPositionCalc::_timeResolutionCalcBarrel
private
std::unique_ptr<CaloRecHitResolutionProvider> Basic2DGenericPFlowPositionCalc::_timeResolutionCalcEndcap
private