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

This is EGM version of the ECAL position + depth correction calculation. More...

#include <ECAL2DPositionCalcWithDepthCorr.h>

Inheritance diagram for ECAL2DPositionCalcWithDepthCorr:
PFCPositionCalculatorBase

Public Member Functions

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

Private Member Functions

void calculateAndSetPositionActual (reco::PFCluster &) const
 

Private Attributes

const CaloGeometryRecord_caloGeom
 
const CaloSubdetectorGeometry_ebGeom
 
const CaloSubdetectorGeometry_eeGeom
 
const CaloSubdetectorGeometry_esGeom
 
bool _esMinus
 
bool _esPlus
 
const double _minAllowedNorm
 
const double _param_T0_EB
 
const double _param_T0_EE
 
const double _param_T0_ES
 
const double _param_W0
 
const double _param_X0
 
std::unique_ptr
< ECALRecHitResolutionProvider
_timeResolutionCalc
 

Additional Inherited Members

- Protected Attributes inherited from PFCPositionCalculatorBase
const float _minFractionInCalc
 

Detailed Description

This is EGM version of the ECAL position + depth correction calculation.

Definition at line 17 of file ECAL2DPositionCalcWithDepthCorr.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file ECAL2DPositionCalcWithDepthCorr.h.

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

19  :
21  _param_T0_EB(conf.getParameter<double>("T0_EB")),
22  _param_T0_EE(conf.getParameter<double>("T0_EE")),
23  _param_T0_ES(conf.getParameter<double>("T0_ES")),
24  _param_W0(conf.getParameter<double>("W0")),
25  _param_X0(conf.getParameter<double>("X0")),
26  _minAllowedNorm(conf.getParameter<double>("minAllowedNormalization")),
27  _caloGeom(NULL),
28  _ebGeom(NULL),
29  _eeGeom(NULL),
30  _esGeom(NULL),
31  _esPlus(false),
32  _esMinus(false) {
34  if( conf.exists("timeResolutionCalc") ) {
35  const edm::ParameterSet& timeResConf =
36  conf.getParameterSet("timeResolutionCalc");
37  _timeResolutionCalc.reset(new ECALRecHitResolutionProvider(timeResConf));
38  }
39  }
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
const CaloSubdetectorGeometry * _ebGeom
std::unique_ptr< ECALRecHitResolutionProvider > _timeResolutionCalc
const CaloSubdetectorGeometry * _esGeom
const CaloSubdetectorGeometry * _eeGeom
PFCPositionCalculatorBase(const edm::ParameterSet &conf)
ECAL2DPositionCalcWithDepthCorr::ECAL2DPositionCalcWithDepthCorr ( const ECAL2DPositionCalcWithDepthCorr )
delete

Member Function Documentation

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

Implements PFCPositionCalculatorBase.

Definition at line 41 of file ECAL2DPositionCalcWithDepthCorr.cc.

References calculateAndSetPositionActual().

41  {
43 }
void calculateAndSetPositionActual(reco::PFCluster &) const
void ECAL2DPositionCalcWithDepthCorr::calculateAndSetPositionActual ( reco::PFCluster cluster) const
private

Definition at line 53 of file ECAL2DPositionCalcWithDepthCorr.cc.

References _ebGeom, _eeGeom, _esMinus, _esPlus, _minAllowedNorm, _param_T0_EB, _param_T0_EE, _param_T0_ES, _param_W0, _param_X0, _timeResolutionCalc, funct::abs(), reco::PFCluster::calculatePositionREP(), constexpr, PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, PV3DBase< T, PVType, FrameType >::eta(), edm::hlt::Exception, CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), edm::isFinite(), PV3DBase< T, PVType, FrameType >::mag(), bookConverter::max, PFLayer::NONE, NULL, reco::PFCluster::recHitFractions(), reco::CaloCluster::seed(), reco::CaloCluster::setEnergy(), reco::PFCluster::setLayer(), reco::CaloCluster::setPosition(), reco::PFCluster::setTime(), histoStyle::weight, x, PV3DBase< T, PVType, FrameType >::x(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), detailsBasic3DVector::z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by calculateAndSetPosition(), and calculateAndSetPositions().

53  {
54  constexpr double preshowerStartEta = 1.653;
55  constexpr double preshowerEndEta = 2.6;
56  if( !cluster.seed() ) {
57  throw cms::Exception("ClusterWithNoSeed")
58  << " Found a cluster with no seed: " << cluster;
59  }
60  double cl_energy = 0;
61  double cl_energy_float = 0;
62  double cl_time = 0;
63  double cl_timeweight=0.0;
64  double max_e = 0.0;
65  double clusterT0 = 0.0;
66  PFLayer::Layer max_e_layer = PFLayer::NONE;
67  reco::PFRecHitRef refmax;
68  // find the seed and max layer
69  for( const reco::PFRecHitFraction& rhf : cluster.recHitFractions() ) {
70  const reco::PFRecHitRef& refhit = rhf.recHitRef();
71  const double rh_fraction = rhf.fraction();
72  const double rh_rawenergy = refhit->energy();
73  const double rh_energy = rh_rawenergy * rh_fraction;
74  const double rh_energyf = ((float)rh_rawenergy) * ((float) rh_fraction);
75  if( !edm::isFinite(rh_energy) ) {
76  throw cms::Exception("PFClusterAlgo")
77  <<"rechit " << refhit->detId() << " has non-finite energy... "
78  << "The input of the particle flow clustering seems to be corrupted.";
79  }
80  cl_energy += rh_energy;
81  cl_energy_float += rh_energyf;
82  // If time resolution is given, calculate weighted average
83  if (_timeResolutionCalc) {
84  const double res2 = _timeResolutionCalc->timeResolution2(rh_rawenergy);
85  cl_time += rh_fraction*refhit->time()/res2;
86  cl_timeweight += rh_fraction/res2;
87  }
88  else { // assume resolution ~ 1/E**2
89  const double rh_rawenergy2 = rh_rawenergy*rh_rawenergy;
90  cl_timeweight+=rh_rawenergy2*rh_fraction;
91  cl_time += rh_rawenergy2*rh_fraction*refhit->time();
92  }
93  if( rh_energy > max_e ) {
94  max_e = rh_energy;
95  max_e_layer = rhf.recHitRef()->layer();
96  refmax = refhit;
97  }
98  }
99  cluster.setEnergy(cl_energy);
100  cluster.setTime(cl_time/cl_timeweight);
101  cluster.setLayer(max_e_layer);
102  const CaloSubdetectorGeometry* ecal_geom = NULL;
103  // get seed geometry information
104  switch(max_e_layer){
106  ecal_geom = _ebGeom;
107  clusterT0 = _param_T0_EB;
108  break;
110  ecal_geom = _eeGeom;
111  clusterT0 = _param_T0_EE;
112  break;
113  default:
114  throw cms::Exception("InvalidLayer")
115  << "ECAL Position Calc only accepts ECAL_BARREL or ECAL_ENDCAP";
116  }
117  const CaloCellGeometry* center_cell =
118  ecal_geom->getGeometry(refmax->detId());
119  const double ctreta = center_cell->getPosition().eta();
120  const double actreta = std::abs(ctreta);
121  // need to change T0 if in ES
122  if( actreta > preshowerStartEta && actreta < preshowerEndEta ) {
123  if(ctreta > 0 && _esPlus ) clusterT0 = _param_T0_ES;
124  if(ctreta < 0 && _esMinus) clusterT0 = _param_T0_ES;
125  }
126  // floats to reproduce exactly the EGM code
127  const float maxDepth = _param_X0*(clusterT0 + vdt::fast_log(cl_energy_float));
128  const float maxToFront = center_cell->getPosition().mag();
129  // calculate the position
130  const double logETot_inv = -vdt::fast_log(cl_energy_float);
131  double position_norm = 0.0;
132  double x(0.0),y(0.0),z(0.0);
133  for( const reco::PFRecHitFraction& rhf : cluster.recHitFractions() ) {
134  double weight = 0.0;
135  const reco::PFRecHitRef& refhit = rhf.recHitRef();
136  const double rh_energy = ((float)refhit->energy()) * ((float)rhf.fraction());
137  if( rh_energy > 0.0 ) weight = std::max(0.0,( _param_W0 +
138  vdt::fast_log(rh_energy) +
139  logETot_inv ));
140  const CaloCellGeometry* cell = ecal_geom->getGeometry(refhit->detId());
141  const float depth = maxDepth + maxToFront - cell->getPosition().mag();
142  const GlobalPoint pos =
143  static_cast<const TruncatedPyramid*>(cell)->getPosition(depth);
144 
145  x += weight*pos.x() ;
146  y += weight*pos.y() ;
147  z += weight*pos.z() ;
148 
149  position_norm += weight ;
150  }
151  if( position_norm < _minAllowedNorm ) {
152  edm::LogError("WeirdClusterNormalization")
153  << "PFCluster too far from seeding cell: set position to (0,0,0).";
154  cluster.setPosition(math::XYZPoint(0,0,0));
155  } else {
156  const double norm_inverse = 1.0/position_norm;
157  x *= norm_inverse;
158  y *= norm_inverse;
159  z *= norm_inverse;
160  cluster.setPosition(math::XYZPoint(x,y,z));
161  cluster.calculatePositionREP();
162  }
163 }
void setLayer(PFLayer::Layer layer)
set layer
Definition: PFCluster.cc:77
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:111
T y() const
Definition: PV3DBase.h:63
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
#define constexpr
float float float z
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
bool isFinite(T x)
T mag() const
Definition: PV3DBase.h:67
void setTime(double time)
Definition: PFCluster.h:84
void calculatePositionREP()
computes posrep_ once and for all
Definition: PFCluster.h:90
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Layer
layer definition
Definition: PFLayer.h:31
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:200
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const CaloSubdetectorGeometry * _ebGeom
std::unique_ptr< ECALRecHitResolutionProvider > _timeResolutionCalc
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
T eta() const
Definition: PV3DBase.h:76
const CaloSubdetectorGeometry * _eeGeom
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:69
Definition: DDAxes.h:10
int weight
Definition: histoStyle.py:50
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
T x() const
Definition: PV3DBase.h:62
void ECAL2DPositionCalcWithDepthCorr::calculateAndSetPositions ( reco::PFClusterCollection clusters)
virtual

Implements PFCPositionCalculatorBase.

Definition at line 46 of file ECAL2DPositionCalcWithDepthCorr.cc.

References calculateAndSetPositionActual().

46  {
47  for( reco::PFCluster& cluster : clusters ) {
49  }
50 }
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
void calculateAndSetPositionActual(reco::PFCluster &) const
ECAL2DPositionCalcWithDepthCorr& ECAL2DPositionCalcWithDepthCorr::operator= ( const ECAL2DPositionCalcWithDepthCorr )
delete
void ECAL2DPositionCalcWithDepthCorr::update ( const edm::EventSetup es)
virtual

Reimplemented from PFCPositionCalculatorBase.

Definition at line 19 of file ECAL2DPositionCalcWithDepthCorr.cc.

References _caloGeom, _ebGeom, _eeGeom, _esGeom, _esMinus, _esPlus, edm::eventsetup::EventSetupRecord::cacheIdentifier(), DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, edm::EventSetup::get(), edm::eventsetup::EventSetupRecord::get(), CaloSubdetectorGeometry::getGeometry(), CaloSubdetectorGeometry::getValidDetIds(), NULL, groupFilesInBlocks::temp, and detailsBasic3DVector::z.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

19  {
21  if( _caloGeom == NULL ||
22  ( _caloGeom->cacheIdentifier() != temp.cacheIdentifier() ) ) {
23  _caloGeom = &temp;
25  _caloGeom->get(geohandle);
26  _ebGeom = geohandle->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);
27  _eeGeom = geohandle->getSubdetectorGeometry(DetId::Ecal,EcalEndcap);
28  _esGeom = geohandle->getSubdetectorGeometry(DetId::Ecal,EcalPreshower);
29  // ripped from RecoEcal/EgammaCoreTools
30  for( uint32_t ic = 0;
31  ic < _esGeom->getValidDetIds().size() &&
32  ( !_esPlus || !_esMinus ); ++ic ) {
33  const double z = _esGeom->getGeometry( _esGeom->getValidDetIds()[ic] )->getPosition().z();
34  _esPlus = _esPlus || ( 0 < z ) ;
35  _esMinus = _esMinus || ( 0 > z ) ;
36  }
37  }
38 }
unsigned long long cacheIdentifier() const
#define NULL
Definition: scimark2.h:8
float float float z
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
void get(HolderT &iHolder) const
const T & get() const
Definition: EventSetup.h:55
const CaloSubdetectorGeometry * _ebGeom
const CaloSubdetectorGeometry * _esGeom
const CaloSubdetectorGeometry * _eeGeom

Member Data Documentation

const CaloGeometryRecord* ECAL2DPositionCalcWithDepthCorr::_caloGeom
private

Definition at line 57 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by update().

const CaloSubdetectorGeometry* ECAL2DPositionCalcWithDepthCorr::_ebGeom
private

Definition at line 58 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual(), and update().

const CaloSubdetectorGeometry* ECAL2DPositionCalcWithDepthCorr::_eeGeom
private

Definition at line 59 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual(), and update().

const CaloSubdetectorGeometry* ECAL2DPositionCalcWithDepthCorr::_esGeom
private

Definition at line 60 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by update().

bool ECAL2DPositionCalcWithDepthCorr::_esMinus
private

Definition at line 61 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual(), and update().

bool ECAL2DPositionCalcWithDepthCorr::_esPlus
private

Definition at line 61 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual(), and update().

const double ECAL2DPositionCalcWithDepthCorr::_minAllowedNorm
private

Definition at line 54 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual().

const double ECAL2DPositionCalcWithDepthCorr::_param_T0_EB
private

Definition at line 49 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual().

const double ECAL2DPositionCalcWithDepthCorr::_param_T0_EE
private

Definition at line 50 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual().

const double ECAL2DPositionCalcWithDepthCorr::_param_T0_ES
private

Definition at line 51 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual().

const double ECAL2DPositionCalcWithDepthCorr::_param_W0
private

Definition at line 52 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual().

const double ECAL2DPositionCalcWithDepthCorr::_param_X0
private

Definition at line 53 of file ECAL2DPositionCalcWithDepthCorr.h.

Referenced by calculateAndSetPositionActual().

std::unique_ptr<ECALRecHitResolutionProvider> ECAL2DPositionCalcWithDepthCorr::_timeResolutionCalc
private