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::Transform3DPJ::Point Point
 
typedef ROOT::Math::Transform3DPJ 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)
 
void fillHitMap (const HGCRecHitCollection &HGCEERecHits, const HGCRecHitCollection &HGCFHRecHits, const HGCRecHitCollection &HGCBHRecHits)
 to compute from inside - once per event More...
 
std::map< DetId, const HGCRecHit * > * getHitMap ()
 
void pcaInitialComputation ()
 
const TPrincipal & pcaResult ()
 
void printHits (float radius) const
 
void setdEdXWeights (const std::vector< double > &dEdX)
 
void setHitMap (std::map< DetId, const HGCRecHit * > *hitMap)
 to set from outside - once per event More...
 
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)
 
 ~EGammaPCAHelper ()
 

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_
 
std::map< DetId, const HGCRecHit * > * hitMap_
 
int hitMapOrigin_
 
std::vector< double > invThicknessCorrection_
 
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

Definition at line 37 of file EgammaPCAHelper.h.

Definition at line 36 of file EgammaPCAHelper.h.

Constructor & Destructor Documentation

EGammaPCAHelper::EGammaPCAHelper ( )

Definition at line 17 of file EgammaPCAHelper.cc.

17  :
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  hitMapOrigin_ = 0;
24  hitMap_ = new std::map<DetId, const HGCRecHit *>();
25  debug_ = false;
26 }
std::map< DetId, const HGCRecHit * > * hitMap_
std::unique_ptr< TPrincipal > pca_
std::vector< double > invThicknessCorrection_
EGammaPCAHelper::~EGammaPCAHelper ( )

Definition at line 28 of file EgammaPCAHelper.cc.

References hitMap_, and hitMapOrigin_.

28  {
29  if (hitMapOrigin_ == 2) delete hitMap_;
30 }
std::map< DetId, const HGCRecHit * > * hitMap_

Member Function Documentation

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

Definition at line 66 of file EgammaPCAHelper.h.

References axis_, and computeShowerWidth().

Referenced by HGCalEgammaIDHelper::axis().

66 {return axis_;}
const math::XYZPoint& hgcal::EGammaPCAHelper::barycenter ( ) const
inline

Definition at line 65 of file EgammaPCAHelper.h.

References barycenter_.

Referenced by HGCalEgammaIDHelper::barycenter().

65 {return barycenter_;}
math::XYZPoint barycenter_
bool EGammaPCAHelper::checkIteration ( ) const
private

Definition at line 235 of file EgammaPCAHelper.cc.

References gather_cfg::cout, debug_, and pcaIteration_.

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

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

Definition at line 252 of file EgammaPCAHelper.cc.

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

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

252  {
253  theSpots_.clear();
254  pcaIteration_ = 0;
255  sigu_ = 0.;
256  sigv_ = 0.;
257  sigp_ = 0.;
258  sige_ = 0.;
259 }
std::vector< Spot > theSpots_
float EGammaPCAHelper::clusterDepthCompatibility ( const LongDeps ld,
float &  measuredDepth,
float &  expectedDepth,
float &  expectedSigma 
)

Definition at line 321 of file EgammaPCAHelper.cc.

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

Referenced by HGCalEgammaIDHelper::clusterDepthCompatibility(), and sigmas().

321  {
322  expectedDepth = -999.;
323  expectedSigma = -999.;
324  measuredDepth = -999.;
325  if (!checkIteration()) return -999.;
326 
327  float z = findZFirstLayer(ld);
328  math::XYZVector dir=axis_.unit();
329  measuredDepth = std::abs((z-std::abs(barycenter_.z()))/dir.z());
330  return showerDepth_.getClusterDepthCompatibility(measuredDepth,ld.energyEE(), expectedDepth,expectedSigma);
331 }
math::XYZPoint barycenter_
float energyEE() const
Definition: LongDeps.h:20
float findZFirstLayer(const LongDeps &) const
float getClusterDepthCompatibility(float measuredDepth, float emEnergy, float &expectedDepth, float &expectedSigma) const
Definition: ShowerDepth.cc:6
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
bool checkIteration() const
dbl *** dir
Definition: mlp_gen.cc:35
void EGammaPCAHelper::computePCA ( float  radius,
bool  withHalo = true 
)

Definition at line 135 of file EgammaPCAHelper.cc.

References axis_, barycenter_, gather_cfg::cout, debug_, mps_fire::i, hgcal::RecHitTools::lastLayerEE(), LayerTriplets::layers(), DTRecHitQuality_cfi::local, pca_, pcaIteration_, TCMET_cfi::radius, recHitTools_, theSpots_, and trans_.

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

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

Definition at line 196 of file EgammaPCAHelper.cc.

References hiPixelPairStep_cff::deltaPhi, reco::CaloCluster::eta(), DTRecHitQuality_cfi::local, reco::CaloCluster::phi(), TCMET_cfi::radius, sige_, sigp_, sigu_, sigv_, mathSSE::sqrt(), theCluster_, theSpots_, and trans_.

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

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

Definition at line 75 of file EgammaPCAHelper.h.

References pca_.

Referenced by HGCalEgammaIDHelper::eigenValues().

75 {return *pca_->GetEigenValues();}
std::unique_ptr< TPrincipal > pca_
LongDeps EGammaPCAHelper::energyPerLayer ( float  radius,
bool  withHalo = true 
)

Definition at line 261 of file EgammaPCAHelper.cc.

References axis_, barycenter_, checkIteration(), debug_, f, HGCEE, HGCHEB, HGCHEF, LayerTriplets::layers(), DTRecHitQuality_cfi::local, HGCalImagingAlgo::maxlayer, TCMET_cfi::radius, theSpots_, and trans_.

Referenced by HGCalEgammaIDHelper::energyPerLayer(), and sigmas().

261  {
262  if (debug_) checkIteration();
263  std::set<int> layers;
264  float radius2 = radius*radius;
265  std::vector<float> energyPerLayer(HGCalImagingAlgo::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();
272  Point(0., 0., 1.), Point(1., 0., 0.));
273  float energyEE = 0.;
274  float energyFH = 0.;
275  float energyBH = 0.;
276 
277  for (const auto& spot : theSpots_) {
278  if (!withHalo && ! spot.isCore())
279  continue;
280  math::XYZPoint local = trans_(Point( spot.row()[0],spot.row()[1],spot.row()[2]));
281  if (local.Perp2() > radius2) continue;
282  energyPerLayer[spot.layer()] += spot.energy();
283  layers.insert(spot.layer());
284  if (spot.subdet() == HGCEE) { energyEE += spot.energy();}
285  else if (spot.subdet() == HGCHEF) { energyFH += spot.energy();}
286  else if (spot.subdet() == HGCHEB) { energyBH += spot.energy();}
287 
288  }
289  return LongDeps(radius,energyPerLayer,energyEE,energyFH,energyBH,layers);
290 }
math::XYZPoint barycenter_
static const unsigned int maxlayer
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
LongDeps energyPerLayer(float radius, bool withHalo=true)
ROOT::Math::Transform3DPJ Transform3D
ROOT::Math::Transform3DPJ::Point Point
double f[11][100]
std::vector< Spot > theSpots_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool checkIteration() const
void EGammaPCAHelper::fillHitMap ( const HGCRecHitCollection HGCEERecHits,
const HGCRecHitCollection HGCFHRecHits,
const HGCRecHitCollection HGCBHRecHits 
)

to compute from inside - once per event

Definition at line 42 of file EgammaPCAHelper.cc.

References hitMap_, hitMapOrigin_, and pcaIteration_.

Referenced by HGCalEgammaIDHelper::eventInit().

44  {
45  hitMap_->clear();
46  for (const auto& hit : rechitsEE) {
47  hitMap_->emplace_hint(hitMap_->end(), hit.detid(), &hit);
48  }
49 
50  for (const auto& hit : rechitsFH) {
51  hitMap_->emplace_hint(hitMap_->end(), hit.detid(), &hit);
52  }
53 
54  for (const auto& hit : rechitsBH) {
55  hitMap_->emplace_hint(hitMap_->end(), hit.detid(), &hit);
56  }
57 
58  pcaIteration_ = 0;
59  hitMapOrigin_ = 2;
60 }
std::map< DetId, const HGCRecHit * > * hitMap_
float EGammaPCAHelper::findZFirstLayer ( const LongDeps ld) const
private

Definition at line 305 of file EgammaPCAHelper.cc.

References hgcal::LongDeps::energyPerLayer(), hgcal::RecHitTools::getPosition(), HcalEndcap, HGCEE, HGCHEF, hcalTTPDigis_cfi::id, hgcal::RecHitTools::lastLayerEE(), hgcal::RecHitTools::lastLayerFH(), HGCalImagingAlgo::maxlayer, recHitTools_, and PV3DBase< T, PVType, FrameType >::z().

Referenced by clusterDepthCompatibility(), and sigmas().

305  {
306  unsigned int firstLayer = 0;
307  for(unsigned il=1;il<=HGCalImagingAlgo::maxlayer;++il) {
308  if (ld.energyPerLayer()[il] > 0.) {
309  firstLayer = il;
310  break;
311  }
312  }
313  // Make dummy DetId to get abs(z) for layer
314  DetId id;
315  if (firstLayer <= recHitTools_->lastLayerEE()) id = HGCalDetId(ForwardSubdetector::HGCEE, 1, firstLayer, 1, 50, 1);
316  else if (firstLayer <= recHitTools_->lastLayerFH()) id = HGCalDetId(ForwardSubdetector::HGCHEF, 1, firstLayer - recHitTools_->lastLayerEE(), 1, 50, 1);
317  else id = HcalDetId(HcalSubdetector::HcalEndcap, 50, 100, firstLayer - recHitTools_->lastLayerFH());
318  return recHitTools_->getPosition(id).z();
319 }
static const unsigned int maxlayer
T z() const
Definition: PV3DBase.h:64
unsigned int lastLayerEE() const
Definition: RecHitTools.h:52
Definition: DetId.h:18
const std::vector< float > & energyPerLayer() const
Definition: LongDeps.h:23
GlobalPoint getPosition(const DetId &id) const
Definition: RecHitTools.cc:77
const hgcal::RecHitTools * recHitTools_
unsigned int lastLayerFH() const
Definition: RecHitTools.h:53
std::map<DetId,const HGCRecHit *>* hgcal::EGammaPCAHelper::getHitMap ( )
inline

Definition at line 54 of file EgammaPCAHelper.h.

References hitMap_, and setRecHitTools().

54 {return hitMap_;}
std::map< DetId, const HGCRecHit * > * hitMap_
void hgcal::EGammaPCAHelper::pcaInitialComputation ( )
inline

Definition at line 60 of file EgammaPCAHelper.h.

References computePCA(), and TCMET_cfi::radius.

Referenced by HGCalEgammaIDHelper::computeHGCAL().

60  {
61  computePCA(-1.,false);
62  }
void computePCA(float radius, bool withHalo=true)
const TPrincipal& hgcal::EGammaPCAHelper::pcaResult ( )
void EGammaPCAHelper::printHits ( float  radius) const

Definition at line 292 of file EgammaPCAHelper.cc.

References gather_cfg::cout, mps_fire::i, DTRecHitQuality_cfi::local, TCMET_cfi::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(), ntuplePrintersDiff.TrackPrinter::printTrack(), and sigmas().

292  {
293  unsigned nSpots = theSpots_.size();
294  float radius2=radius*radius;
295  for ( unsigned i =0; i< nSpots ; ++i) {
296  Spot spot(theSpots_[i]);
297  math::XYZPoint local = trans_(Point( spot.row()[0],spot.row()[1],spot.row()[2]));
298  if (local.Perp2() < radius2 ) {
299  std::cout << i << " " << theSpots_[i].detId().rawId() << " " << theSpots_[i].layer() << " " << theSpots_[i].energy() << " " <<theSpots_[i].isCore() ;
300  std::cout << " " << std::sqrt(local.Perp2()) << std::endl;
301  }
302  }
303 }
ROOT::Math::Transform3DPJ::Point Point
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< Spot > theSpots_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void hgcal::EGammaPCAHelper::setdEdXWeights ( const std::vector< double > &  dEdX)
inline

Definition at line 58 of file EgammaPCAHelper.h.

References dEdXWeights_.

Referenced by HGCalEgammaIDHelper::HGCalEgammaIDHelper().

58 { dEdXWeights_ = dEdX;}
std::vector< double > dEdXWeights_
void EGammaPCAHelper::setHitMap ( std::map< DetId, const HGCRecHit * > *  hitMap)

to set from outside - once per event

Definition at line 32 of file EgammaPCAHelper.cc.

References hitMap_, hitMapOrigin_, and pcaIteration_.

32  {
33  hitMapOrigin_ = 1;
34  hitMap_ = hitMap ;
35  pcaIteration_ = 0;
36 }
std::map< DetId, const HGCRecHit * > * hitMap_
void EGammaPCAHelper::setRecHitTools ( const hgcal::RecHitTools recHitTools)

Definition at line 38 of file EgammaPCAHelper.cc.

References recHitTools_.

Referenced by HGCalEgammaIDHelper::eventInit(), and getHitMap().

38  {
39  recHitTools_ = recHitTools;
40 }
const hgcal::RecHitTools * recHitTools_
double hgcal::EGammaPCAHelper::sigmaEE ( ) const
inline

Definition at line 72 of file EgammaPCAHelper.h.

References checkIteration(), and sige_.

Referenced by HGCalEgammaIDHelper::sigmaEE().

72 { return checkIteration()? sige_ : -1. ;}
bool checkIteration() const
double hgcal::EGammaPCAHelper::sigmaPP ( ) const
inline

Definition at line 73 of file EgammaPCAHelper.h.

References checkIteration(), and sigp_.

Referenced by HGCalEgammaIDHelper::sigmaPP().

73 { return checkIteration()? sigp_ : -1. ;}
bool checkIteration() const
const TVectorD& hgcal::EGammaPCAHelper::sigmas ( ) const
inline
double hgcal::EGammaPCAHelper::sigmaUU ( ) const
inline

Definition at line 70 of file EgammaPCAHelper.h.

References checkIteration(), and sigu_.

Referenced by HGCalEgammaIDHelper::sigmaUU().

70 { return checkIteration()? sigu_ : -1. ;}
bool checkIteration() const
double hgcal::EGammaPCAHelper::sigmaVV ( ) const
inline

Definition at line 71 of file EgammaPCAHelper.h.

References checkIteration(), and sigv_.

Referenced by HGCalEgammaIDHelper::sigmaVV().

71 { return checkIteration()? sigv_ : -1. ;}
bool checkIteration() const
void EGammaPCAHelper::storeRecHits ( const reco::CaloCluster theCluster)

Definition at line 73 of file EgammaPCAHelper.cc.

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

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

73  {
74  theCluster_ = &cluster;
75  storeRecHits(cluster.hitsAndFractions());
76 }
void storeRecHits(const reco::CaloCluster &theCluster)
const reco::CaloCluster * theCluster_
void EGammaPCAHelper::storeRecHits ( const reco::HGCalMultiCluster cluster)

Definition at line 62 of file EgammaPCAHelper.cc.

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

62  {
63  theCluster_ = &cluster;
64  std::vector<std::pair<DetId, float>> result;
65  for (reco::HGCalMultiCluster::component_iterator it = cluster.begin(); it != cluster.end();
66  it++) {
67  const std::vector<std::pair<DetId, float>> &hf = (*it)->hitsAndFractions();
68  result.insert(result.end(),hf.begin(),hf.end());
69  }
70  storeRecHits(result);
71 }
component_iterator begin() const
void storeRecHits(const reco::CaloCluster &theCluster)
component_iterator end() const
const reco::CaloCluster * theCluster_
void EGammaPCAHelper::storeRecHits ( const std::vector< std::pair< DetId, float >> &  hf)
private

Definition at line 78 of file EgammaPCAHelper.cc.

References gather_cfg::cout, debug_, dEdXWeights_, DetId::det(), plotBeamSpotDB::first, DetId::Forward, dedxEstimators_cff::fraction, hgcal::RecHitTools::getLayerWithOffset(), hgcal::RecHitTools::getPosition(), hgcal::RecHitTools::getSiThickness(), photonIsolationHIProducer_cfi::hf, hitMap_, invThicknessCorrection_, 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().

78  {
79  std::vector<double> pcavars;
80  pcavars.resize(3,0.);
81  theSpots_.clear();
82  pcaIteration_ = 0;
83 
84  sigu_ = 0.;
85  sigv_ = 0.;
86  sigp_ = 0.;
87  sige_ = 0.;
88 
89  unsigned hfsize = hf.size();
90  if (debug_)
91  std::cout << "The seed cluster constains " << hfsize << " hits " << std::endl;
92 
93  if (hfsize == 0) return;
94 
95 
96  for (unsigned int j = 0; j < hfsize; j++) {
97  unsigned int layer = recHitTools_->getLayerWithOffset(hf[j].first);
98 
99  const DetId rh_detid = hf[j].first;
100  std::map<DetId,const HGCRecHit *>::const_iterator itcheck= hitMap_->find(rh_detid);
101  if (itcheck == hitMap_->end()) {
102  edm::LogWarning("EgammaPCAHelper") << " Big problem, unable to find a hit " << rh_detid.rawId() << " " << rh_detid.det() << " " << HGCalDetId(rh_detid) << std::endl;
103  continue;
104  }
105  if (debug_) {
106  std::cout << "DetId " << rh_detid.rawId() << " " << layer << " " << itcheck->second->energy() <<std::endl;
107  std::cout << " Hit " << itcheck->second << " " << itcheck->second->energy() << std::endl;
108  }
109  float fraction = hf[j].second;
110 
111  double thickness = (DetId::Forward == DetId(rh_detid).det()) ? recHitTools_->getSiThickness(rh_detid) : -1;
112  double mip = dEdXWeights_[layer] * 0.001; // convert in GeV
113  if (thickness > 99. && thickness < 101)
114  mip *= invThicknessCorrection_[0];
115  else if (thickness > 199 && thickness < 201)
116  mip *= invThicknessCorrection_[1];
117  else if (thickness > 299 && thickness < 301)
118  mip *= invThicknessCorrection_[2];
119 
120  pcavars[0] = recHitTools_->getPosition(rh_detid).x();
121  pcavars[1] = recHitTools_->getPosition(rh_detid).y();
122  pcavars[2] = recHitTools_->getPosition(rh_detid).z();
123  if (pcavars[2] == 0.)
124  edm::LogWarning("EgammaPCAHelper") << " Problem, hit with z =0 ";
125  else {
126  Spot mySpot(rh_detid,itcheck->second->energy(),pcavars,layer,fraction,mip);
127  theSpots_.push_back(mySpot);
128  }
129  }
130  if (debug_) {
131  std::cout << " Stored " << theSpots_.size() << " hits " << std::endl;
132  }
133 }
std::map< DetId, const HGCRecHit * > * hitMap_
T y() const
Definition: PV3DBase.h:63
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T z() const
Definition: PV3DBase.h:64
std::vector< Spot > theSpots_
std::float_t getSiThickness(const DetId &) const
Definition: RecHitTools.cc:103
Definition: DetId.h:18
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:176
GlobalPoint getPosition(const DetId &id) const
Definition: RecHitTools.cc:77
std::vector< double > invThicknessCorrection_
std::vector< double > dEdXWeights_
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
T x() const
Definition: PV3DBase.h:62
const hgcal::RecHitTools * recHitTools_

Member Data Documentation

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

Definition at line 104 of file EgammaPCAHelper.h.

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

math::XYZPoint hgcal::EGammaPCAHelper::barycenter_
private
bool hgcal::EGammaPCAHelper::debug_
private

Definition at line 90 of file EgammaPCAHelper.h.

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

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

Definition at line 93 of file EgammaPCAHelper.h.

Referenced by setdEdXWeights(), and storeRecHits().

std::map<DetId, const HGCRecHit *>* hgcal::EGammaPCAHelper::hitMap_
private

Definition at line 98 of file EgammaPCAHelper.h.

Referenced by fillHitMap(), getHitMap(), setHitMap(), storeRecHits(), and ~EGammaPCAHelper().

int hgcal::EGammaPCAHelper::hitMapOrigin_
private

Definition at line 96 of file EgammaPCAHelper.h.

Referenced by fillHitMap(), setHitMap(), and ~EGammaPCAHelper().

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

Definition at line 94 of file EgammaPCAHelper.h.

Referenced by storeRecHits().

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

Definition at line 110 of file EgammaPCAHelper.h.

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

int hgcal::EGammaPCAHelper::pcaIteration_
private
bool hgcal::EGammaPCAHelper::recHitsStored_
private

Definition at line 89 of file EgammaPCAHelper.h.

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

Definition at line 111 of file EgammaPCAHelper.h.

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

ShowerDepth hgcal::EGammaPCAHelper::showerDepth_
private

Definition at line 112 of file EgammaPCAHelper.h.

Referenced by clusterDepthCompatibility().

double hgcal::EGammaPCAHelper::sige_
private

Definition at line 107 of file EgammaPCAHelper.h.

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

double hgcal::EGammaPCAHelper::sigp_
private

Definition at line 107 of file EgammaPCAHelper.h.

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

double hgcal::EGammaPCAHelper::sigu_
private

Definition at line 107 of file EgammaPCAHelper.h.

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

double hgcal::EGammaPCAHelper::sigv_
private

Definition at line 107 of file EgammaPCAHelper.h.

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

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

Definition at line 97 of file EgammaPCAHelper.h.

Referenced by computeShowerWidth(), and storeRecHits().

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

Definition at line 106 of file EgammaPCAHelper.h.

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