CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
hgcal::EGammaPCAHelper Class Reference

#include <EgammaPCAHelper.h>

Public Types

typedef ROOT::Math::Transform3D::Point Point
 
typedef ROOT::Math::Transform3D Transform3D
 

Public Member Functions

const math::XYZVectoraxis () const
 
const math::XYZPointbarycenter () const
 
void clear ()
 
float clusterDepthCompatibility (const LongDeps &, float &measuredDepth, float &expectedDepth, float &expectedSigma)
 
void computePCA (float radius, bool withHalo=true)
 
void computeShowerWidth (float radius, bool withHalo=true)
 
 EGammaPCAHelper ()
 
const TVectorD & eigenValues () const
 
LongDeps energyPerLayer (float radius, bool withHalo=true)
 
const std::unordered_map< DetId, const unsigned int > * getHitMap ()
 
void pcaInitialComputation ()
 
const TPrincipal & pcaResult ()
 
void printHits (float radius) const
 
void setdEdXWeights (const std::vector< double > &dEdX)
 
void setHitMap (const std::unordered_map< DetId, const unsigned int > *hitMap)
 to set once per event More...
 
void setRecHits (edm::Handle< HGCRecHitCollection > recHitHandleEE, edm::Handle< HGCRecHitCollection > recHitHandleFH, edm::Handle< HGCRecHitCollection > recHitHandleBH)
 
void setRecHitTools (const hgcal::RecHitTools *recHitTools)
 
double sigmaEE () const
 
double sigmaPP () const
 
const TVectorD & sigmas () const
 
double sigmaUU () const
 
double sigmaVV () const
 
void storeRecHits (const reco::CaloCluster &theCluster)
 
void storeRecHits (const reco::HGCalMultiCluster &cluster)
 

Private Member Functions

bool checkIteration () const
 
float findZFirstLayer (const LongDeps &) const
 
void storeRecHits (const std::vector< std::pair< DetId, float >> &hf)
 

Private Attributes

math::XYZVector axis_
 
math::XYZPoint barycenter_
 
bool debug_
 
std::vector< double > dEdXWeights_
 
const std::unordered_map< DetId, const unsigned int > * hitMap_
 
std::vector< const HGCRecHit * > hits_
 
std::vector< double > invThicknessCorrection_
 
unsigned int maxlayer_
 
std::unique_ptr< TPrincipal > pca_
 
int pcaIteration_
 
bool recHitsStored_
 
const hgcal::RecHitToolsrecHitTools_
 
ShowerDepth showerDepth_
 
double sige_
 
double sigp_
 
double sigu_
 
double sigv_
 
const reco::CaloClustertheCluster_
 
std::vector< SpottheSpots_
 
Transform3D trans_
 

Detailed Description

Definition at line 33 of file EgammaPCAHelper.h.

Member Typedef Documentation

◆ Point

typedef ROOT::Math::Transform3D::Point hgcal::EGammaPCAHelper::Point

Definition at line 36 of file EgammaPCAHelper.h.

◆ Transform3D

typedef ROOT::Math::Transform3D hgcal::EGammaPCAHelper::Transform3D

Definition at line 35 of file EgammaPCAHelper.h.

Constructor & Destructor Documentation

◆ EGammaPCAHelper()

EGammaPCAHelper::EGammaPCAHelper ( )

Definition at line 17 of file EgammaPCAHelper.cc.

18  : // Thickness correction to dEdx weights
19  // (100um, 200um, 300um silicon)
20  // See RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi
21  invThicknessCorrection_({1. / 1.132, 1. / 1.092, 1. / 1.084}),
22  pca_(new TPrincipal(3, "D")) {
23  hitMap_ = nullptr;
24  debug_ = false;
25 }
std::unique_ptr< TPrincipal > pca_
const std::unordered_map< DetId, const unsigned int > * hitMap_
std::vector< double > invThicknessCorrection_

Member Function Documentation

◆ axis()

const math::XYZVector& hgcal::EGammaPCAHelper::axis ( ) const
inline

Definition at line 60 of file EgammaPCAHelper.h.

References axis_.

Referenced by HGCalEgammaIDHelper::axis().

60 { return axis_; }
math::XYZVector axis_

◆ barycenter()

const math::XYZPoint& hgcal::EGammaPCAHelper::barycenter ( ) const
inline

Definition at line 59 of file EgammaPCAHelper.h.

References barycenter_.

Referenced by HGCalEgammaIDHelper::barycenter().

59 { return barycenter_; }
math::XYZPoint barycenter_

◆ checkIteration()

bool EGammaPCAHelper::checkIteration ( ) const
private

Definition at line 234 of file EgammaPCAHelper.cc.

References gather_cfg::cout, debug_, and pcaIteration_.

Referenced by clusterDepthCompatibility(), energyPerLayer(), sigmaEE(), sigmaPP(), sigmaUU(), and sigmaVV().

234  {
235  if (pcaIteration_ == 0) {
236  if (debug_)
237  std::cout << " The PCA has not been run yet " << std::endl;
238  return false;
239  } else if (pcaIteration_ == 1) {
240  if (debug_)
241  std::cout << " The PCA has been run only once - careful " << std::endl;
242  return false;
243  } else if (pcaIteration_ == -1) {
244  if (debug_)
245  std::cout << " Not enough layers to perform PCA " << std::endl;
246  return false;
247  }
248  return true;
249 }

◆ clear()

void EGammaPCAHelper::clear ( void  )

Definition at line 251 of file EgammaPCAHelper.cc.

References pcaIteration_, sige_, sigp_, sigu_, sigv_, and theSpots_.

Referenced by HGCalEgammaIDHelper::computeHGCAL().

251  {
252  theSpots_.clear();
253  pcaIteration_ = 0;
254  sigu_ = 0.;
255  sigv_ = 0.;
256  sigp_ = 0.;
257  sige_ = 0.;
258 }
std::vector< Spot > theSpots_

◆ clusterDepthCompatibility()

float EGammaPCAHelper::clusterDepthCompatibility ( const LongDeps ld,
float &  measuredDepth,
float &  expectedDepth,
float &  expectedSigma 
)

Definition at line 326 of file EgammaPCAHelper.cc.

References funct::abs(), axis_, barycenter_, checkIteration(), DeadROC_duringRun::dir, hgcal::LongDeps::energyEE(), findZFirstLayer(), hgcal::ShowerDepth::getClusterDepthCompatibility(), and showerDepth_.

Referenced by HGCalEgammaIDHelper::clusterDepthCompatibility().

329  {
330  expectedDepth = -999.;
331  expectedSigma = -999.;
332  measuredDepth = -999.;
333  if (!checkIteration())
334  return -999.;
335 
336  float z = findZFirstLayer(ld);
337  math::XYZVector dir = axis_.unit();
338  measuredDepth = std::abs((z - std::abs(barycenter_.z())) / dir.z());
339  return showerDepth_.getClusterDepthCompatibility(measuredDepth, ld.energyEE(), expectedDepth, expectedSigma);
340 }
math::XYZPoint barycenter_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float getClusterDepthCompatibility(float measuredDepth, float emEnergy, float &expectedDepth, float &expectedSigma) const
Definition: ShowerDepth.cc:6
float findZFirstLayer(const LongDeps &) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
math::XYZVector axis_
float energyEE() const
Definition: LongDeps.h:25

◆ computePCA()

void EGammaPCAHelper::computePCA ( float  radius,
bool  withHalo = true 
)

Definition at line 125 of file EgammaPCAHelper.cc.

References axis_, barycenter_, gather_cfg::cout, debug_, mps_fire::i, hgcal::RecHitTools::lastLayerEE(), hgcalTBTopologyTester_cfi::layers, DTRecHitClients_cfi::local, compareTotals::means, pca_, pcaIteration_, CosmicsPD_Skims::radius, recHitTools_, theSpots_, and trans_.

Referenced by HGCalEgammaIDHelper::computeHGCAL(), and pcaInitialComputation().

125  {
126  // very important - to reset
127  pca_ = std::make_unique<TPrincipal>(3, "D");
128  bool initialCalculation = radius < 0;
129  if (debug_)
130  std::cout << " Initial calculation " << initialCalculation << std::endl;
131  if (initialCalculation && withHalo) {
132  edm::LogWarning("EGammaPCAHelper") << "Warning - in the first iteration, the halo hits are excluded " << std::endl;
133  withHalo = false;
134  }
135 
136  float radius2 = radius * radius;
137  if (!initialCalculation) {
138  math::XYZVector mainAxis(axis_);
139  mainAxis.unit();
140  math::XYZVector phiAxis(barycenter_.x(), barycenter_.y(), 0);
141  math::XYZVector udir(mainAxis.Cross(phiAxis));
142  udir = udir.unit();
145  Point(barycenter_ + udir),
146  Point(0, 0, 0),
147  Point(0., 0., 1.),
148  Point(1., 0., 0.));
149  }
150 
151  std::set<int> layers;
152  for (const auto& spot : theSpots_) {
153  if (spot.layer() > recHitTools_->lastLayerEE())
154  continue;
155  if (!withHalo && (!spot.isCore()))
156  continue;
157  if (initialCalculation) {
158  // initial calculation, take only core hits
159  if (!spot.isCore())
160  continue;
161  layers.insert(spot.layer());
162  for (int i = 0; i < spot.multiplicity(); ++i)
163  pca_->AddRow(spot.row());
164  } else {
165  // use a cylinder, include all hits
166  math::XYZPoint local = trans_(Point(spot.row()[0], spot.row()[1], spot.row()[2]));
167  if (local.Perp2() > radius2)
168  continue;
169  layers.insert(spot.layer());
170  for (int i = 0; i < spot.multiplicity(); ++i)
171  pca_->AddRow(spot.row());
172  }
173  }
174  if (debug_)
175  std::cout << " Nlayers " << layers.size() << std::endl;
176  if (layers.size() < 3) {
177  pcaIteration_ = -1;
178  return;
179  }
180  pca_->MakePrincipals();
181  ++pcaIteration_;
182  const TVectorD& means = *(pca_->GetMeanValues());
183  const TMatrixD& eigens = *(pca_->GetEigenVectors());
184 
186  axis_ = math::XYZVector(eigens(0, 0), eigens(1, 0), eigens(2, 0));
187  if (axis_.z() * barycenter_.z() < 0.0) {
188  axis_ = -1. * axis_;
189  }
190 }
math::XYZPoint barycenter_
std::unique_ptr< TPrincipal > pca_
std::vector< Spot > theSpots_
ROOT::Math::Transform3D Transform3D
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
math::XYZVector axis_
Log< level::Warning, false > LogWarning
ROOT::Math::Transform3D::Point Point
const hgcal::RecHitTools * recHitTools_
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:76

◆ computeShowerWidth()

void EGammaPCAHelper::computeShowerWidth ( float  radius,
bool  withHalo = true 
)

Definition at line 192 of file EgammaPCAHelper.cc.

References SiPixelRawToDigiRegional_cfi::deltaPhi, reco::CaloCluster::eta(), DTRecHitClients_cfi::local, reco::CaloCluster::phi(), CosmicsPD_Skims::radius, sige_, sigp_, sigu_, sigv_, mathSSE::sqrt(), theCluster_, theSpots_, and trans_.

Referenced by HGCalEgammaIDHelper::computeHGCAL().

192  {
193  sigu_ = 0.;
194  sigv_ = 0.;
195  sigp_ = 0.;
196  sige_ = 0.;
197  double cyl_ene = 0.;
198 
199  float radius2 = radius * radius;
200  for (const auto& spot : theSpots_) {
201  Point globalPoint(spot.row()[0], spot.row()[1], spot.row()[2]);
202  math::XYZPoint local = trans_(globalPoint);
203  if (local.Perp2() > radius2)
204  continue;
205 
206  // Select halo hits or not
207  if (withHalo && spot.fraction() < 0)
208  continue;
209  if (!withHalo && !(spot.isCore()))
210  continue;
211 
212  sige_ += (globalPoint.eta() - theCluster_->eta()) * (globalPoint.eta() - theCluster_->eta()) * spot.energy();
213  sigp_ += deltaPhi(globalPoint.phi(), theCluster_->phi()) * deltaPhi(globalPoint.phi(), theCluster_->phi()) *
214  spot.energy();
215 
216  sigu_ += local.x() * local.x() * spot.energy();
217  sigv_ += local.y() * local.y() * spot.energy();
218  cyl_ene += spot.energy();
219  }
220 
221  if (cyl_ene > 0.) {
222  const double inv_cyl_ene = 1. / cyl_ene;
223  sigu_ = sigu_ * inv_cyl_ene;
224  sigv_ = sigv_ * inv_cyl_ene;
225  sigp_ = sigp_ * inv_cyl_ene;
226  sige_ = sige_ * inv_cyl_ene;
227  }
228  sigu_ = std::sqrt(sigu_);
229  sigv_ = std::sqrt(sigv_);
230  sigp_ = std::sqrt(sigp_);
231  sige_ = std::sqrt(sige_);
232 }
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:184
T sqrt(T t)
Definition: SSEVec.h:23
std::vector< Spot > theSpots_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Structure Point Contains parameters of Gaussian fits to DMRs.
const reco::CaloCluster * theCluster_
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181

◆ eigenValues()

const TVectorD& hgcal::EGammaPCAHelper::eigenValues ( ) const
inline

Definition at line 69 of file EgammaPCAHelper.h.

References pca_.

Referenced by HGCalEgammaIDHelper::eigenValues().

69 { return *pca_->GetEigenValues(); }
std::unique_ptr< TPrincipal > pca_

◆ energyPerLayer()

LongDeps EGammaPCAHelper::energyPerLayer ( float  radius,
bool  withHalo = true 
)

Definition at line 260 of file EgammaPCAHelper.cc.

References axis_, barycenter_, checkIteration(), debug_, f, DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, HGCEE, HGCHEB, HGCHEF, hgcalTBTopologyTester_cfi::layers, DTRecHitClients_cfi::local, maxlayer_, or, CosmicsPD_Skims::radius, theSpots_, and trans_.

Referenced by HGCalEgammaIDHelper::energyPerLayer().

260  {
261  if (debug_)
262  checkIteration();
263  std::set<int> layers;
264  float radius2 = radius * radius;
265  std::vector<float> energyPerLayer(maxlayer_ + 1, 0.f);
266  math::XYZVector mainAxis(axis_);
267  mainAxis.unit();
268  math::XYZVector phiAxis(barycenter_.x(), barycenter_.y(), 0);
269  math::XYZVector udir(mainAxis.Cross(phiAxis));
270  udir = udir.unit();
273  Point(barycenter_ + udir),
274  Point(0, 0, 0),
275  Point(0., 0., 1.),
276  Point(1., 0., 0.));
277  float energyEE = 0.;
278  float energyFH = 0.;
279  float energyBH = 0.;
280 
281  for (const auto& spot : theSpots_) {
282  if (!withHalo && !spot.isCore())
283  continue;
284  math::XYZPoint local = trans_(Point(spot.row()[0], spot.row()[1], spot.row()[2]));
285  if (local.Perp2() > radius2)
286  continue;
287  energyPerLayer[spot.layer()] += spot.energy();
288  layers.insert(spot.layer());
289  if (spot.detId().det() == DetId::HGCalEE or spot.subdet() == HGCEE) {
290  energyEE += spot.energy();
291  } else if (spot.detId().det() == DetId::HGCalHSi or spot.subdet() == HGCHEF) {
292  energyFH += spot.energy();
293  } else if (spot.detId().det() == DetId::HGCalHSc or spot.subdet() == HGCHEB) {
294  energyBH += spot.energy();
295  }
296  }
297  return LongDeps(radius, energyPerLayer, energyEE, energyFH, energyBH, layers);
298 }
math::XYZPoint barycenter_
LongDeps energyPerLayer(float radius, bool withHalo=true)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
double f[11][100]
std::vector< Spot > theSpots_
ROOT::Math::Transform3D Transform3D
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
math::XYZVector axis_
ROOT::Math::Transform3D::Point Point

◆ findZFirstLayer()

float EGammaPCAHelper::findZFirstLayer ( const LongDeps ld) const
private

Definition at line 314 of file EgammaPCAHelper.cc.

References hgcal::LongDeps::energyPerLayer(), hgcal::RecHitTools::getPositionLayer(), maxlayer_, recHitTools_, and PV3DBase< T, PVType, FrameType >::z().

Referenced by clusterDepthCompatibility().

314  {
315  unsigned int firstLayer = 0;
316  for (unsigned il = 1; il <= maxlayer_; ++il) {
317  if (ld.energyPerLayer()[il] > 0.) {
318  firstLayer = il;
319  break;
320  }
321  }
322  // Make dummy DetId to get abs(z) for layer
323  return recHitTools_->getPositionLayer(firstLayer).z();
324 }
T z() const
Definition: PV3DBase.h:61
const std::vector< float > & energyPerLayer() const
Definition: LongDeps.h:28
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:152
const hgcal::RecHitTools * recHitTools_

◆ getHitMap()

const std::unordered_map<DetId, const unsigned int>* hgcal::EGammaPCAHelper::getHitMap ( )
inline

Definition at line 47 of file EgammaPCAHelper.h.

References hitMap_.

47 { return hitMap_; }
const std::unordered_map< DetId, const unsigned int > * hitMap_

◆ pcaInitialComputation()

void hgcal::EGammaPCAHelper::pcaInitialComputation ( )
inline

Definition at line 56 of file EgammaPCAHelper.h.

References computePCA().

Referenced by HGCalEgammaIDHelper::computeHGCAL().

56 { computePCA(-1., false); }
void computePCA(float radius, bool withHalo=true)

◆ pcaResult()

const TPrincipal& hgcal::EGammaPCAHelper::pcaResult ( )

◆ printHits()

void EGammaPCAHelper::printHits ( float  radius) const

Definition at line 300 of file EgammaPCAHelper.cc.

References gather_cfg::cout, mps_fire::i, DTRecHitClients_cfi::local, CosmicsPD_Skims::radius, hgcal::Spot::row(), mathSSE::sqrt(), theSpots_, and trans_.

Referenced by ntuplePrintersDiff.TrackingParticlePrinter::__call__(), ntuplePrintersDiff.SeedPrinter::diff(), ntuplePrintersDiff.TrackPrinter::diff(), ntuplePrintersDiff.TrackingParticlePrinter::diff(), HGCalEgammaIDHelper::printHits(), ntuplePrintersDiff.SeedPrinter::printSeed(), and ntuplePrintersDiff.TrackPrinter::printTrack().

300  {
301  unsigned nSpots = theSpots_.size();
302  float radius2 = radius * radius;
303  for (unsigned i = 0; i < nSpots; ++i) {
304  Spot spot(theSpots_[i]);
305  math::XYZPoint local = trans_(Point(spot.row()[0], spot.row()[1], spot.row()[2]));
306  if (local.Perp2() < radius2) {
307  std::cout << i << " " << theSpots_[i].detId().rawId() << " " << theSpots_[i].layer() << " "
308  << theSpots_[i].energy() << " " << theSpots_[i].isCore();
309  std::cout << " " << std::sqrt(local.Perp2()) << std::endl;
310  }
311  }
312 }
T sqrt(T t)
Definition: SSEVec.h:23
std::vector< Spot > theSpots_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
ROOT::Math::Transform3D::Point Point

◆ setdEdXWeights()

void hgcal::EGammaPCAHelper::setdEdXWeights ( const std::vector< double > &  dEdX)
inline

Definition at line 54 of file EgammaPCAHelper.h.

References HGCalRecHit_cfi::dEdX, and dEdXWeights_.

Referenced by HGCalEgammaIDHelper::HGCalEgammaIDHelper().

54 { dEdXWeights_ = dEdX; }
std::vector< double > dEdXWeights_

◆ setHitMap()

void EGammaPCAHelper::setHitMap ( const std::unordered_map< DetId, const unsigned int > *  hitMap)

to set once per event

Definition at line 27 of file EgammaPCAHelper.cc.

References hitMap_, and pcaIteration_.

Referenced by HGCalEgammaIDHelper::eventInit().

27  {
28  hitMap_ = hitMap;
29  pcaIteration_ = 0;
30 }
const std::unordered_map< DetId, const unsigned int > * hitMap_

◆ setRecHits()

void EGammaPCAHelper::setRecHits ( edm::Handle< HGCRecHitCollection recHitHandleEE,
edm::Handle< HGCRecHitCollection recHitHandleFH,
edm::Handle< HGCRecHitCollection recHitHandleBH 
)

Definition at line 32 of file EgammaPCAHelper.cc.

References JetHT_cfg::firstIndex, patZpeak::handle, hits_, mps_fire::i, and edm::SortedCollection< T, SORT >::size().

Referenced by HGCalEgammaIDHelper::eventInit().

34  {
35  unsigned int total_size = recHitHandleEE->size() + recHitHandleFH->size() + recHitHandleBH->size();
36  hits_.resize(total_size);
37  unsigned int firstIndex = 0;
38 
39  for (const auto& handle : {recHitHandleEE, recHitHandleFH, recHitHandleBH}) {
40  unsigned int collection_size = handle->size();
41  for (unsigned int i = 0; i < collection_size; ++i) {
42  hits_[firstIndex + i] = &(*handle)[i];
43  }
44  firstIndex += collection_size;
45  }
46 }
std::vector< const HGCRecHit * > hits_
size_type size() const
dictionary firstIndex
Definition: JetHT_cfg.py:140

◆ setRecHitTools()

void EGammaPCAHelper::setRecHitTools ( const hgcal::RecHitTools recHitTools)

Definition at line 48 of file EgammaPCAHelper.cc.

References hgcal::RecHitTools::lastLayerBH(), maxlayer_, and recHitTools_.

Referenced by HGCalEgammaIDHelper::eventInit().

48  {
49  recHitTools_ = recHitTools;
51 }
unsigned int lastLayerBH() const
Definition: RecHitTools.h:79
const hgcal::RecHitTools * recHitTools_

◆ sigmaEE()

double hgcal::EGammaPCAHelper::sigmaEE ( ) const
inline

Definition at line 66 of file EgammaPCAHelper.h.

References checkIteration(), and sige_.

Referenced by HGCalEgammaIDHelper::sigmaEE().

66 { return checkIteration() ? sige_ : -1.; }

◆ sigmaPP()

double hgcal::EGammaPCAHelper::sigmaPP ( ) const
inline

Definition at line 67 of file EgammaPCAHelper.h.

References checkIteration(), and sigp_.

Referenced by HGCalEgammaIDHelper::sigmaPP().

67 { return checkIteration() ? sigp_ : -1.; }

◆ sigmas()

const TVectorD& hgcal::EGammaPCAHelper::sigmas ( ) const
inline

Definition at line 70 of file EgammaPCAHelper.h.

References pca_.

Referenced by HGCalEgammaIDHelper::sigmas().

70 { return *pca_->GetSigmas(); }
std::unique_ptr< TPrincipal > pca_

◆ sigmaUU()

double hgcal::EGammaPCAHelper::sigmaUU ( ) const
inline

Definition at line 64 of file EgammaPCAHelper.h.

References checkIteration(), and sigu_.

Referenced by HGCalEgammaIDHelper::sigmaUU().

64 { return checkIteration() ? sigu_ : -1.; }

◆ sigmaVV()

double hgcal::EGammaPCAHelper::sigmaVV ( ) const
inline

Definition at line 65 of file EgammaPCAHelper.h.

References checkIteration(), and sigv_.

Referenced by HGCalEgammaIDHelper::sigmaVV().

65 { return checkIteration() ? sigv_ : -1.; }

◆ storeRecHits() [1/3]

void EGammaPCAHelper::storeRecHits ( const reco::CaloCluster theCluster)

Definition at line 63 of file EgammaPCAHelper.cc.

References reco::CaloCluster::hitsAndFractions(), and theCluster_.

Referenced by HGCalEgammaIDHelper::computeHGCAL(), and storeRecHits().

63  {
64  theCluster_ = &cluster;
65  storeRecHits(cluster.hitsAndFractions());
66 }
void storeRecHits(const reco::CaloCluster &theCluster)
const reco::CaloCluster * theCluster_

◆ storeRecHits() [2/3]

void EGammaPCAHelper::storeRecHits ( const reco::HGCalMultiCluster cluster)

Definition at line 53 of file EgammaPCAHelper.cc.

References reco::HGCalMultiCluster::begin(), reco::HGCalMultiCluster::end(), photonIsolationHIProducer_cfi::hf, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, mps_fire::result, storeRecHits(), and theCluster_.

53  {
54  theCluster_ = &cluster;
55  std::vector<std::pair<DetId, float>> result;
56  for (reco::HGCalMultiCluster::component_iterator it = cluster.begin(); it != cluster.end(); it++) {
57  const std::vector<std::pair<DetId, float>>& hf = (*it)->hitsAndFractions();
58  result.insert(result.end(), hf.begin(), hf.end());
59  }
61 }
void storeRecHits(const reco::CaloCluster &theCluster)
component_iterator end() const
component_iterator begin() const
const reco::CaloCluster * theCluster_

◆ storeRecHits() [3/3]

void EGammaPCAHelper::storeRecHits ( const std::vector< std::pair< DetId, float >> &  hf)
private

Definition at line 68 of file EgammaPCAHelper.cc.

References gather_cfg::cout, debug_, dEdXWeights_, DetId::det(), dqmdumpme::first, HLT_2024v14_cff::fraction, hgcal::RecHitTools::getLayerWithOffset(), hgcal::RecHitTools::getPosition(), hgcal::RecHitTools::getSiThickIndex(), photonIsolationHIProducer_cfi::hf, hitMap_, hits_, invThicknessCorrection_, dqmiolumiharvest::j, pcaIteration_, DetId::rawId(), recHitTools_, sige_, sigp_, sigu_, sigv_, theSpots_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

68  {
69  std::vector<double> pcavars;
70  pcavars.resize(3, 0.);
71  theSpots_.clear();
72  pcaIteration_ = 0;
73 
74  sigu_ = 0.;
75  sigv_ = 0.;
76  sigp_ = 0.;
77  sige_ = 0.;
78 
79  unsigned hfsize = hf.size();
80  if (debug_)
81  std::cout << "The seed cluster constains " << hfsize << " hits " << std::endl;
82 
83  if (hfsize == 0)
84  return;
85 
86  for (unsigned int j = 0; j < hfsize; j++) {
87  unsigned int layer = recHitTools_->getLayerWithOffset(hf[j].first);
88 
89  const DetId rh_detid = hf[j].first;
90  std::unordered_map<DetId, const unsigned int>::const_iterator itcheck = hitMap_->find(rh_detid);
91  if (itcheck == hitMap_->end()) {
92  edm::LogWarning("EgammaPCAHelper") << " Big problem, unable to find a hit " << rh_detid.rawId() << " "
93  << rh_detid.det() << " " << HGCalDetId(rh_detid) << std::endl;
94  continue;
95  }
96 
97  if (debug_) {
98  const HGCRecHit* hit = hits_[itcheck->second];
99  std::cout << "DetId " << rh_detid.rawId() << " " << layer << " " << hit->energy() << std::endl;
100  std::cout << " Hit " << hit << " " << hit->energy() << std::endl;
101  }
102  float fraction = hf[j].second;
103 
104  int thickIndex = recHitTools_->getSiThickIndex(rh_detid);
105  double mip = dEdXWeights_[layer] * 0.001; // convert in GeV
106  if (thickIndex > -1 and thickIndex < 3)
107  mip *= invThicknessCorrection_[thickIndex];
108 
109  pcavars[0] = recHitTools_->getPosition(rh_detid).x();
110  pcavars[1] = recHitTools_->getPosition(rh_detid).y();
111  pcavars[2] = recHitTools_->getPosition(rh_detid).z();
112  if (pcavars[2] == 0.)
113  edm::LogWarning("EgammaPCAHelper") << " Problem, hit with z =0 ";
114  else {
115  const HGCRecHit* hit = hits_[itcheck->second];
116  Spot mySpot(rh_detid, hit->energy(), pcavars, layer, fraction, mip);
117  theSpots_.push_back(mySpot);
118  }
119  }
120  if (debug_) {
121  std::cout << " Stored " << theSpots_.size() << " hits " << std::endl;
122  }
123 }
std::vector< const HGCRecHit * > hits_
T z() const
Definition: PV3DBase.h:61
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint getPosition(const DetId &id) const
Definition: RecHitTools.cc:140
std::vector< Spot > theSpots_
const std::unordered_map< DetId, const unsigned int > * hitMap_
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::vector< double > invThicknessCorrection_
std::vector< double > dEdXWeights_
Log< level::Warning, false > LogWarning
int getSiThickIndex(const DetId &) const
Definition: RecHitTools.cc:216
const hgcal::RecHitTools * recHitTools_
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:381

Member Data Documentation

◆ axis_

math::XYZVector hgcal::EGammaPCAHelper::axis_
private

Definition at line 98 of file EgammaPCAHelper.h.

Referenced by axis(), clusterDepthCompatibility(), computePCA(), and energyPerLayer().

◆ barycenter_

math::XYZPoint hgcal::EGammaPCAHelper::barycenter_
private

◆ debug_

bool hgcal::EGammaPCAHelper::debug_
private

Definition at line 84 of file EgammaPCAHelper.h.

Referenced by checkIteration(), computePCA(), energyPerLayer(), and storeRecHits().

◆ dEdXWeights_

std::vector<double> hgcal::EGammaPCAHelper::dEdXWeights_
private

Definition at line 87 of file EgammaPCAHelper.h.

Referenced by setdEdXWeights(), and storeRecHits().

◆ hitMap_

const std::unordered_map<DetId, const unsigned int>* hgcal::EGammaPCAHelper::hitMap_
private

Definition at line 91 of file EgammaPCAHelper.h.

Referenced by getHitMap(), setHitMap(), and storeRecHits().

◆ hits_

std::vector<const HGCRecHit *> hgcal::EGammaPCAHelper::hits_
private

Definition at line 108 of file EgammaPCAHelper.h.

Referenced by setRecHits(), and storeRecHits().

◆ invThicknessCorrection_

std::vector<double> hgcal::EGammaPCAHelper::invThicknessCorrection_
private

Definition at line 88 of file EgammaPCAHelper.h.

Referenced by storeRecHits().

◆ maxlayer_

unsigned int hgcal::EGammaPCAHelper::maxlayer_
private

Definition at line 94 of file EgammaPCAHelper.h.

Referenced by energyPerLayer(), findZFirstLayer(), and setRecHitTools().

◆ pca_

std::unique_ptr<TPrincipal> hgcal::EGammaPCAHelper::pca_
private

Definition at line 104 of file EgammaPCAHelper.h.

Referenced by computePCA(), eigenValues(), and sigmas().

◆ pcaIteration_

int hgcal::EGammaPCAHelper::pcaIteration_
private

Definition at line 93 of file EgammaPCAHelper.h.

Referenced by checkIteration(), clear(), computePCA(), setHitMap(), and storeRecHits().

◆ recHitsStored_

bool hgcal::EGammaPCAHelper::recHitsStored_
private

Definition at line 83 of file EgammaPCAHelper.h.

◆ recHitTools_

const hgcal::RecHitTools* hgcal::EGammaPCAHelper::recHitTools_
private

Definition at line 105 of file EgammaPCAHelper.h.

Referenced by computePCA(), findZFirstLayer(), setRecHitTools(), and storeRecHits().

◆ showerDepth_

ShowerDepth hgcal::EGammaPCAHelper::showerDepth_
private

Definition at line 106 of file EgammaPCAHelper.h.

Referenced by clusterDepthCompatibility().

◆ sige_

double hgcal::EGammaPCAHelper::sige_
private

Definition at line 101 of file EgammaPCAHelper.h.

Referenced by clear(), computeShowerWidth(), sigmaEE(), and storeRecHits().

◆ sigp_

double hgcal::EGammaPCAHelper::sigp_
private

Definition at line 101 of file EgammaPCAHelper.h.

Referenced by clear(), computeShowerWidth(), sigmaPP(), and storeRecHits().

◆ sigu_

double hgcal::EGammaPCAHelper::sigu_
private

Definition at line 101 of file EgammaPCAHelper.h.

Referenced by clear(), computeShowerWidth(), sigmaUU(), and storeRecHits().

◆ sigv_

double hgcal::EGammaPCAHelper::sigv_
private

Definition at line 101 of file EgammaPCAHelper.h.

Referenced by clear(), computeShowerWidth(), sigmaVV(), and storeRecHits().

◆ theCluster_

const reco::CaloCluster* hgcal::EGammaPCAHelper::theCluster_
private

Definition at line 90 of file EgammaPCAHelper.h.

Referenced by computeShowerWidth(), and storeRecHits().

◆ theSpots_

std::vector<Spot> hgcal::EGammaPCAHelper::theSpots_
private

◆ trans_

Transform3D hgcal::EGammaPCAHelper::trans_
private

Definition at line 100 of file EgammaPCAHelper.h.

Referenced by computePCA(), computeShowerWidth(), energyPerLayer(), and printHits().