CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
HGCalShowerShape Class Reference

#include <HGCalShowerShape.h>

Classes

struct  DeltaPhi
 

Public Types

typedef math::XYZTLorentzVector LorentzVector
 

Public Member Functions

int bitmap (const l1t::HGCalMulticluster &c3d, int start=1, int end=14, float threshold=0) const
 
int coreShowerLength (const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry) const
 
float eMax (const l1t::HGCalMulticluster &c3d) const
 
void fillShapes (l1t::HGCalMulticluster &, const HGCalTriggerGeometryBase &) const
 
int firstLayer (const l1t::HGCalMulticluster &c3d) const
 
 HGCalShowerShape ()
 
 HGCalShowerShape (const edm::ParameterSet &conf)
 
int lastLayer (const l1t::HGCalMulticluster &c3d) const
 
int maxLayer (const l1t::HGCalMulticluster &c3d) const
 
float meanZ (const l1t::HGCalMulticluster &c3d) const
 
float percentileLayer (const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry, float quantile=0.5) const
 
float percentileTriggerCells (const l1t::HGCalMulticluster &c3d, float quantile=0.5) const
 
void setGeometry (const HGCalTriggerGeometryBase *const geom)
 
int showerLength (const l1t::HGCalMulticluster &c3d) const
 
float sigmaEtaEtaMax (const l1t::HGCalMulticluster &c3d) const
 
float sigmaEtaEtaTot (const l1t::HGCalMulticluster &c3d) const
 
float sigmaEtaEtaTot (const l1t::HGCalCluster &c2d) const
 
float sigmaPhiPhiMax (const l1t::HGCalMulticluster &c3d) const
 
float sigmaPhiPhiTot (const l1t::HGCalMulticluster &c3d) const
 
float sigmaPhiPhiTot (const l1t::HGCalCluster &c2d) const
 
float sigmaRRMax (const l1t::HGCalMulticluster &c3d) const
 
float sigmaRRMean (const l1t::HGCalMulticluster &c3d, float radius=5.) const
 
float sigmaRRTot (const l1t::HGCalMulticluster &c3d) const
 
float sigmaRRTot (const l1t::HGCalCluster &c2d) const
 
float sigmaZZ (const l1t::HGCalMulticluster &c3d) const
 
float sumLayers (const l1t::HGCalMulticluster &c3d, int start=1, int end=0) const
 
float varEtaEta (const l1t::HGCalMulticluster &c3d) const
 
float varPhiPhi (const l1t::HGCalMulticluster &c3d) const
 
float varRR (const l1t::HGCalMulticluster &c3d) const
 
float varZZ (const l1t::HGCalMulticluster &c3d) const
 
 ~HGCalShowerShape ()
 

Private Member Functions

float meanX (const std::vector< pair< float, float >> &energy_X_tc) const
 
template<typename T , typename Tref >
bool pass (const T &obj, const Tref &ref) const
 
float sigmaPhiPhi (const std::vector< pair< float, float >> &energy_phi_tc, const float phi_cluster) const
 
float sigmaXX (const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
 
float varPhiPhi (const std::vector< pair< float, float >> &energy_phi_tc, const float phi_cluster) const
 
template<typename Delta = std::minus<float>>
float varXX (const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
 

Private Attributes

double distance_ = 1.
 
double threshold_ = 0.
 
HGCalTriggerTools triggerTools_
 

Detailed Description

Definition at line 12 of file HGCalShowerShape.h.

Member Typedef Documentation

◆ LorentzVector

Definition at line 14 of file HGCalShowerShape.h.

Constructor & Destructor Documentation

◆ HGCalShowerShape() [1/2]

HGCalShowerShape::HGCalShowerShape ( )
inline

Definition at line 16 of file HGCalShowerShape.h.

16 : threshold_(0.) {}

◆ HGCalShowerShape() [2/2]

HGCalShowerShape::HGCalShowerShape ( const edm::ParameterSet conf)

Definition at line 9 of file HGCalShowerShape.cc.

10  : threshold_(conf.getParameter<double>("shape_threshold")),
11  distance_(conf.getParameter<double>("shape_distance")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307

◆ ~HGCalShowerShape()

HGCalShowerShape::~HGCalShowerShape ( )
inline

Definition at line 19 of file HGCalShowerShape.h.

19 {}

Member Function Documentation

◆ bitmap()

int HGCalShowerShape::bitmap ( const l1t::HGCalMulticluster c3d,
int  start = 1,
int  end = 14,
float  threshold = 0 
) const

Definition at line 552 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), mps_fire::end, HGCalTriggerTools::getTriggerGeometry(), mps_fire::i, HGCalTriggerGeometryBase::lastTriggerLayer(), nano_mu_digi_cff::layer, hgcalTBTopologyTester_cfi::layers, nlayers, pass(), DiMuonV_cfg::threshold, caloTruthCellsProducer_cfi::triggerCells, HGCalTriggerTools::triggerLayer(), and triggerTools_.

Referenced by fillShapes().

552  {
553  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
555  std::vector<double> layers(nlayers, 0);
556  for (const auto& id_clu : clustersPtrs) {
557  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
558 
559  for (const auto& id_tc : triggerCells) {
560  if (!pass(*id_tc.second, c3d))
561  continue;
562  unsigned layer = triggerTools_.triggerLayer(id_tc.second->detId());
563  if (layer == 0 || layer > nlayers)
564  continue;
565  layers[layer - 1] += id_tc.second->pt(); //shift by -1 because layer 0 doesn't exist
566  }
567  }
568  uint32_t bitmap = 0;
569  const int bitmap_size = 32;
570  if (start == 0) {
571  edm::LogWarning("DataNotFound") << "Trying to read layer 0 that doesn't exist, defaulted start to layer 1";
572  start = 1;
573  }
574  if ((end - start) + 1 > bitmap_size) {
575  edm::LogWarning("TooMuchData") << " Specified bounds cannot fit into bitmap size, defaulting to 0.";
576  } else {
577  for (int i = start; i <= end; i++) {
578  bitmap += (layers[i - 1] > threshold) << (end - (i));
579  }
580  }
581  return bitmap;
582 }
Definition: start.py:1
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
virtual unsigned lastTriggerLayer() const =0
const HGCalTriggerGeometryBase * getTriggerGeometry() const
HGCalTriggerTools triggerTools_
bool pass(const T &obj, const Tref &ref) const
unsigned triggerLayer(const unsigned id) const
Log< level::Warning, false > LogWarning
int bitmap(const l1t::HGCalMulticluster &c3d, int start=1, int end=14, float threshold=0) const

◆ coreShowerLength()

int HGCalShowerShape::coreShowerLength ( const l1t::HGCalMulticluster c3d,
const HGCalTriggerGeometryBase triggerGeometry 
) const

Definition at line 81 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), ForwardEmpty, HFNose, HGCalTriggerTools::isNose(), nano_mu_digi_cff::layer, hgcalTBTopologyTester_cfi::layers, HGCalTriggerTools::layers(), nlayers, pass(), HGCalTriggerGeometryBase::triggerLayer(), and triggerTools_.

Referenced by fillShapes().

82  {
83  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
85  std::vector<bool> layers(nlayers);
86  for (const auto& id_cluster : clustersPtrs) {
87  if (!pass(*id_cluster.second, c3d))
88  continue;
89  unsigned layer = triggerGeometry.triggerLayer(id_cluster.second->detId());
90  if (triggerTools_.isNose(id_cluster.second->detId()))
92  else {
94  }
95  if (layer == 0 || layer > nlayers)
96  continue;
97  layers[layer - 1] = true; //layer 0 doesn't exist, so shift by -1
98  }
99  int length = 0;
100  int maxlength = 0;
101  for (bool layer : layers) {
102  if (layer)
103  length++;
104  else
105  length = 0;
106  if (length > maxlength)
107  maxlength = length;
108  }
109  return maxlength;
110 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
virtual unsigned triggerLayer(const unsigned id) const =0
HGCalTriggerTools triggerTools_
bool isNose(const DetId &) const
bool pass(const T &obj, const Tref &ref) const
unsigned layers(ForwardSubdetector type) const

◆ eMax()

float HGCalShowerShape::eMax ( const l1t::HGCalMulticluster c3d) const

Definition at line 407 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), nano_mu_digi_cff::layer, HGCalTriggerTools::layerWithOffset(), pass(), and triggerTools_.

Referenced by fillShapes().

407  {
408  std::unordered_map<int, float> layer_energy;
409 
410  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
411 
412  for (const auto& id_clu : clustersPtrs) {
413  if (!pass(*id_clu.second, c3d))
414  continue;
415  unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId());
416  layer_energy[layer] += id_clu.second->energy();
417  }
418 
419  float EMax = 0;
420 
421  for (const auto& layer : layer_energy) {
422  if (layer.second > EMax)
423  EMax = layer.second;
424  }
425 
426  return EMax;
427 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
bool pass(const T &obj, const Tref &ref) const

◆ fillShapes()

void HGCalShowerShape::fillShapes ( l1t::HGCalMulticluster c3d,
const HGCalTriggerGeometryBase triggerGeometry 
) const

Definition at line 584 of file HGCalShowerShape.cc.

References bitmap(), coreShowerLength(), eMax(), firstLayer(), HGCEE, HGCalTriggerGeometryBase::lastTriggerLayer(), HGCalTriggerTools::layers(), maxLayer(), meanZ(), percentileLayer(), percentileTriggerCells(), l1t::HGCalClusterT< C >::setCoreShowerLength(), l1t::HGCalClusterT< C >::setEbm0(), l1t::HGCalClusterT< C >::setEbm1(), l1t::HGCalClusterT< C >::setEMax(), l1t::HGCalClusterT< C >::setEmax1layers(), l1t::HGCalClusterT< C >::setEmax3layers(), l1t::HGCalClusterT< C >::setEmax5layers(), l1t::HGCalClusterT< C >::setEot(), l1t::HGCalClusterT< C >::setFirst1layers(), l1t::HGCalClusterT< C >::setFirst3layers(), l1t::HGCalClusterT< C >::setFirst5layers(), l1t::HGCalClusterT< C >::setFirstHcal1layers(), l1t::HGCalClusterT< C >::setFirstHcal3layers(), l1t::HGCalClusterT< C >::setFirstHcal5layers(), l1t::HGCalClusterT< C >::setFirstLayer(), l1t::HGCalClusterT< C >::setHbm(), l1t::HGCalClusterT< C >::setLast1layers(), l1t::HGCalClusterT< C >::setLast3layers(), l1t::HGCalClusterT< C >::setLast5layers(), l1t::HGCalClusterT< C >::setLayer10percent(), l1t::HGCalClusterT< C >::setLayer50percent(), l1t::HGCalClusterT< C >::setLayer90percent(), l1t::HGCalClusterT< C >::setMaxLayer(), l1t::HGCalClusterT< C >::setShowerLength(), l1t::HGCalClusterT< C >::setSigmaEtaEtaMax(), l1t::HGCalClusterT< C >::setSigmaEtaEtaTot(), l1t::HGCalClusterT< C >::setSigmaPhiPhiMax(), l1t::HGCalClusterT< C >::setSigmaPhiPhiTot(), l1t::HGCalClusterT< C >::setSigmaRRMax(), l1t::HGCalClusterT< C >::setSigmaRRMean(), l1t::HGCalClusterT< C >::setSigmaRRTot(), l1t::HGCalClusterT< C >::setSigmaZZ(), l1t::HGCalClusterT< C >::setTriggerCells67percent(), l1t::HGCalClusterT< C >::setTriggerCells90percent(), l1t::HGCalClusterT< C >::setVarEtaEta(), l1t::HGCalClusterT< C >::setVarPhiPhi(), l1t::HGCalClusterT< C >::setVarRR(), l1t::HGCalClusterT< C >::setVarZZ(), l1t::HGCalClusterT< C >::setZBarycenter(), showerLength(), sigmaEtaEtaMax(), sigmaEtaEtaTot(), sigmaPhiPhiMax(), sigmaPhiPhiTot(), sigmaRRMax(), sigmaRRMean(), sigmaRRTot(), sigmaZZ(), sumLayers(), triggerTools_, varEtaEta(), varPhiPhi(), varRR(), and varZZ().

Referenced by HGCalMulticlusteringImpl::finalizeClusters(), HGCalHistoClusteringImpl::finalizeClusters(), and CaloTruthCellsProducer::produce().

584  {
585  unsigned hcal_offset = triggerTools_.layers(ForwardSubdetector::HGCEE) / 2;
586  unsigned lastlayer = triggerGeometry.lastTriggerLayer();
587  const unsigned showermaxlayer = 7;
588  c3d.setShowerLength(showerLength(c3d));
589  c3d.setCoreShowerLength(coreShowerLength(c3d, triggerGeometry));
590  c3d.setFirstLayer(firstLayer(c3d));
591  c3d.setMaxLayer(maxLayer(c3d));
594  c3d.setVarEtaEta(varEtaEta(c3d));
597  c3d.setVarPhiPhi(varPhiPhi(c3d));
598  c3d.setSigmaZZ(sigmaZZ(c3d));
599  c3d.setVarZZ(varZZ(c3d));
600  c3d.setSigmaRRTot(sigmaRRTot(c3d));
601  c3d.setVarRR(varRR(c3d));
602  c3d.setSigmaRRMax(sigmaRRMax(c3d));
603  c3d.setSigmaRRMean(sigmaRRMean(c3d));
604  c3d.setEMax(eMax(c3d));
605  c3d.setZBarycenter(meanZ(c3d));
606  c3d.setLayer10percent(percentileLayer(c3d, triggerGeometry, 0.10));
607  c3d.setLayer50percent(percentileLayer(c3d, triggerGeometry, 0.50));
608  c3d.setLayer90percent(percentileLayer(c3d, triggerGeometry, 0.90));
611  c3d.setFirst1layers(sumLayers(c3d, 1, 1));
612  c3d.setFirst3layers(sumLayers(c3d, 1, 3));
613  c3d.setFirst5layers(sumLayers(c3d, 1, 5));
614  c3d.setFirstHcal1layers(sumLayers(c3d, hcal_offset, hcal_offset));
615  c3d.setFirstHcal3layers(sumLayers(c3d, hcal_offset, hcal_offset + 2));
616  c3d.setFirstHcal5layers(sumLayers(c3d, hcal_offset, hcal_offset + 4));
617  c3d.setLast1layers(sumLayers(c3d, lastlayer, lastlayer));
618  c3d.setLast3layers(sumLayers(c3d, lastlayer - 2, lastlayer));
619  c3d.setLast5layers(sumLayers(c3d, lastlayer - 4, lastlayer));
620  c3d.setEmax1layers(sumLayers(c3d, showermaxlayer, showermaxlayer));
621  c3d.setEmax3layers(sumLayers(c3d, showermaxlayer - 1, showermaxlayer + 1));
622  c3d.setEmax5layers(sumLayers(c3d, showermaxlayer - 2, showermaxlayer + 2));
623  c3d.setEot(sumLayers(c3d, 1, hcal_offset));
624  c3d.setEbm0(bitmap(c3d, 1, hcal_offset, 0));
625  c3d.setEbm1(bitmap(c3d, 1, hcal_offset, 1));
626  c3d.setHbm(bitmap(c3d, hcal_offset, lastlayer, 0));
627 }
void setFirst1layers(float first1layers)
void setMaxLayer(int maxLayer)
void setSigmaPhiPhiTot(float sigmaPhiPhiTot)
float varZZ(const l1t::HGCalMulticluster &c3d) const
void setHbm(int hbm)
virtual unsigned lastTriggerLayer() const =0
void setSigmaZZ(float sigmaZZ)
void setVarEtaEta(float varEtaEta)
HGCalTriggerTools triggerTools_
void setSigmaRRMean(float sigmaRRMean)
void setFirst5layers(float first5layers)
float percentileTriggerCells(const l1t::HGCalMulticluster &c3d, float quantile=0.5) const
void setSigmaRRTot(float sigmaRRTot)
float percentileLayer(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry, float quantile=0.5) const
int showerLength(const l1t::HGCalMulticluster &c3d) const
float varEtaEta(const l1t::HGCalMulticluster &c3d) const
float sigmaEtaEtaTot(const l1t::HGCalMulticluster &c3d) const
void setFirstHcal5layers(float firstHcal5layers)
void setCoreShowerLength(int coreShowerLength)
void setEmax5layers(float emax5layers)
void setLayer10percent(float layer10percent)
float sigmaZZ(const l1t::HGCalMulticluster &c3d) const
float eMax(const l1t::HGCalMulticluster &c3d) const
void setEbm1(int ebm1)
void setEbm0(int ebm0)
float sigmaPhiPhiMax(const l1t::HGCalMulticluster &c3d) const
void setLast1layers(float last1layers)
int coreShowerLength(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry) const
void setVarPhiPhi(float varPhiPhi)
void setFirst3layers(float first3layers)
void setEMax(float eMax)
void setLast5layers(float last5layers)
void setEot(float eot)
float varRR(const l1t::HGCalMulticluster &c3d) const
void setEmax1layers(float emax1layers)
void setLast3layers(float last3layers)
void setLayer50percent(float layer50percent)
unsigned layers(ForwardSubdetector type) const
int maxLayer(const l1t::HGCalMulticluster &c3d) const
void setTriggerCells67percent(float triggerCells67percent)
void setFirstLayer(int firstLayer)
void setTriggerCells90percent(float triggerCells90percent)
float sigmaRRMax(const l1t::HGCalMulticluster &c3d) const
void setLayer90percent(float layer90percent)
void setFirstHcal3layers(float firstHcal3layers)
void setSigmaEtaEtaTot(float sigmaEtaEtaTot)
void setSigmaEtaEtaMax(float sigmaEtaEtaMax)
float sigmaRRTot(const l1t::HGCalMulticluster &c3d) const
void setSigmaRRMax(float sigmaRRMax)
void setEmax3layers(float emax3layers)
float sigmaEtaEtaMax(const l1t::HGCalMulticluster &c3d) const
float sigmaPhiPhiTot(const l1t::HGCalMulticluster &c3d) const
float varPhiPhi(const l1t::HGCalMulticluster &c3d) const
void setFirstHcal1layers(float firstHcal1layers)
void setSigmaPhiPhiMax(float sigmaPhiPhiMax)
float sumLayers(const l1t::HGCalMulticluster &c3d, int start=1, int end=0) const
int firstLayer(const l1t::HGCalMulticluster &c3d) const
void setVarZZ(float varZZ)
void setVarRR(float varRR)
float meanZ(const l1t::HGCalMulticluster &c3d) const
void setZBarycenter(float zBarycenter)
void setShowerLength(int showerLength)
float sigmaRRMean(const l1t::HGCalMulticluster &c3d, float radius=5.) const
int bitmap(const l1t::HGCalMulticluster &c3d, int start=1, int end=14, float threshold=0) const

◆ firstLayer()

int HGCalShowerShape::firstLayer ( const l1t::HGCalMulticluster c3d) const

Definition at line 30 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), nano_mu_digi_cff::layer, HGCalTriggerTools::layerWithOffset(), pass(), and triggerTools_.

Referenced by fillShapes(), and showerLength().

30  {
31  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
32 
33  int firstLayer = 999;
34 
35  for (const auto& id_clu : clustersPtrs) {
36  if (!pass(*id_clu.second, c3d))
37  continue;
38  int layer = triggerTools_.layerWithOffset(id_clu.second->detId());
39  if (layer < firstLayer)
40  firstLayer = layer;
41  }
42 
43  return firstLayer;
44 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
bool pass(const T &obj, const Tref &ref) const
int firstLayer(const l1t::HGCalMulticluster &c3d) const

◆ lastLayer()

int HGCalShowerShape::lastLayer ( const l1t::HGCalMulticluster c3d) const

Definition at line 65 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), nano_mu_digi_cff::layer, HGCalTriggerTools::layerWithOffset(), pass(), and triggerTools_.

Referenced by showerLength().

65  {
66  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
67 
68  int lastLayer = -999;
69 
70  for (const auto& id_clu : clustersPtrs) {
71  if (!pass(*id_clu.second, c3d))
72  continue;
73  int layer = triggerTools_.layerWithOffset(id_clu.second->detId());
74  if (layer > lastLayer)
75  lastLayer = layer;
76  }
77 
78  return lastLayer;
79 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
HGCalTriggerTools triggerTools_
int lastLayer(const l1t::HGCalMulticluster &c3d) const
unsigned layerWithOffset(const DetId &) const
bool pass(const T &obj, const Tref &ref) const

◆ maxLayer()

int HGCalShowerShape::maxLayer ( const l1t::HGCalMulticluster c3d) const

Definition at line 46 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), nano_mu_digi_cff::layer, HGCalTriggerTools::layerWithOffset(), pass(), and triggerTools_.

Referenced by fillShapes().

46  {
47  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
48  std::unordered_map<int, float> layers_pt;
49  float max_pt = 0.;
50  int max_layer = 0;
51  for (const auto& id_cluster : clustersPtrs) {
52  if (!pass(*id_cluster.second, c3d))
53  continue;
54  unsigned layer = triggerTools_.layerWithOffset(id_cluster.second->detId());
55  auto itr_insert = layers_pt.emplace(layer, 0.);
56  itr_insert.first->second += id_cluster.second->pt();
57  if (itr_insert.first->second > max_pt) {
58  max_pt = itr_insert.first->second;
59  max_layer = layer;
60  }
61  }
62  return max_layer;
63 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
bool pass(const T &obj, const Tref &ref) const

◆ meanX()

float HGCalShowerShape::meanX ( const std::vector< pair< float, float >> &  energy_X_tc) const
private

Definition at line 15 of file HGCalShowerShape.cc.

Referenced by meanZ(), sigmaRRMax(), sigmaRRMean(), sigmaRRTot(), varRR(), and varZZ().

15  {
16  float Etot = 0;
17  float X_sum = 0;
18 
19  for (const auto& energy_X : energy_X_tc) {
20  X_sum += energy_X.first * energy_X.second;
21  Etot += energy_X.first;
22  }
23 
24  float X_mean = 0;
25  if (Etot > 0)
26  X_mean = X_sum / Etot;
27  return X_mean;
28 }

◆ meanZ()

float HGCalShowerShape::meanZ ( const l1t::HGCalMulticluster c3d) const

Definition at line 429 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), meanX(), pass(), and caloTruthCellsProducer_cfi::triggerCells.

Referenced by fillShapes().

429  {
430  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
431 
432  std::vector<std::pair<float, float>> tc_energy_z;
433 
434  for (const auto& id_clu : clustersPtrs) {
435  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
436 
437  for (const auto& id_tc : triggerCells) {
438  if (!pass(*id_tc.second, c3d))
439  continue;
440  tc_energy_z.emplace_back(id_tc.second->energy(), id_tc.second->position().z());
441  }
442  }
443 
444  return meanX(tc_energy_z);
445 }
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
bool pass(const T &obj, const Tref &ref) const

◆ pass()

template<typename T , typename Tref >
bool HGCalShowerShape::pass ( const T obj,
const Tref &  ref 
) const
inlineprivate

Definition at line 99 of file HGCalShowerShape.h.

References funct::abs(), distance_, mag(), getGTfromDQMFile::obj, amptDefault_cfi::proj, and threshold_.

Referenced by bitmap(), coreShowerLength(), eMax(), firstLayer(), lastLayer(), maxLayer(), meanZ(), percentileLayer(), percentileTriggerCells(), sigmaEtaEtaMax(), sigmaEtaEtaTot(), sigmaPhiPhiMax(), sigmaPhiPhiTot(), sigmaRRMax(), sigmaRRMean(), sigmaRRTot(), sumLayers(), varEtaEta(), varPhiPhi(), varRR(), and varZZ().

99  {
100  bool pass_threshold = (obj.mipPt() > threshold_);
101  GlobalPoint proj(Basic3DVector<float>(obj.position()) / std::abs(obj.position().z()));
102  bool pass_distance = ((proj - ref.centreProj()).mag() < distance_);
103  return pass_threshold && pass_distance;
104  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())

◆ percentileLayer()

float HGCalShowerShape::percentileLayer ( const l1t::HGCalMulticluster c3d,
const HGCalTriggerGeometryBase triggerGeometry,
float  quantile = 0.5 
) const

Definition at line 112 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), ForwardEmpty, HFNose, HGCalTriggerTools::isNose(), nano_mu_digi_cff::layer, hgcalTBTopologyTester_cfi::layers, HGCalTriggerTools::layers(), nlayers, pass(), DiDispStaMuonMonitor_cfi::pt, HLT_2024v13_cff::pt1, SusyPostProcessor_cff::quantile, caloTruthCellsProducer_cfi::triggerCells, HGCalTriggerGeometryBase::triggerLayer(), and triggerTools_.

Referenced by fillShapes().

114  {
115  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
117  std::vector<double> layers(nlayers, 0);
118  for (const auto& id_clu : clustersPtrs) {
119  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
120 
121  for (const auto& id_tc : triggerCells) {
122  if (!pass(*id_tc.second, c3d))
123  continue;
124  unsigned layer = triggerGeometry.triggerLayer(id_tc.second->detId());
125  if (triggerTools_.isNose(id_tc.second->detId()))
127  else {
129  }
130  if (layer == 0 || layer > nlayers)
131  continue;
132  layers[layer - 1] += id_tc.second->pt(); //layer 0 doesn't exist, so shift by -1
133  }
134  }
135  std::partial_sum(layers.begin(), layers.end(), layers.begin());
136  double pt_threshold = layers.back() * quantile;
137  unsigned percentile = 0;
138  for (double pt : layers) {
139  if (pt > pt_threshold) {
140  break;
141  }
142  percentile++;
143  }
144  // Linear interpolation of percentile value
145  double pt0 = (percentile > 0 ? layers[percentile - 1] : 0.);
146  double pt1 = (percentile < layers.size() ? layers[percentile] : layers.back());
147  return percentile + (pt1 - pt0 > 0. ? (pt_threshold - pt0) / (pt1 - pt0) : 0.);
148 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
virtual unsigned triggerLayer(const unsigned id) const =0
HGCalTriggerTools triggerTools_
bool isNose(const DetId &) const
bool pass(const T &obj, const Tref &ref) const
unsigned layers(ForwardSubdetector type) const

◆ percentileTriggerCells()

float HGCalShowerShape::percentileTriggerCells ( const l1t::HGCalMulticluster c3d,
float  quantile = 0.5 
) const

Definition at line 150 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), pass(), SusyPostProcessor_cff::quantile, and caloTruthCellsProducer_cfi::triggerCells.

Referenced by fillShapes().

150  {
151  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
152  std::set<double> ordered_tcs;
153  double pt_sum = 0.;
154  for (const auto& id_clu : clustersPtrs) {
155  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
156 
157  for (const auto& id_tc : triggerCells) {
158  if (!pass(*id_tc.second, c3d))
159  continue;
160  ordered_tcs.emplace(id_tc.second->pt());
161  pt_sum += id_tc.second->pt();
162  }
163  }
164  double pt_threshold = pt_sum * quantile;
165  double partial_sum = 0.;
166  double partial_sum_prev = 0.;
167  int ntc = 0;
168  for (auto itr = ordered_tcs.rbegin(); itr != ordered_tcs.rend(); ++itr) {
169  partial_sum_prev = partial_sum;
170  partial_sum += *itr;
171  ntc++;
172  if (partial_sum > pt_threshold) {
173  break;
174  }
175  }
176  // Linear interpolation of ntc
177  return ntc - 1 +
178  (partial_sum - partial_sum_prev > 0. ? (pt_threshold - partial_sum_prev) / (partial_sum - partial_sum_prev)
179  : 0.);
180 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
bool pass(const T &obj, const Tref &ref) const

◆ setGeometry()

void HGCalShowerShape::setGeometry ( const HGCalTriggerGeometryBase *const  geom)
inline

◆ showerLength()

int HGCalShowerShape::showerLength ( const l1t::HGCalMulticluster c3d) const
inline

Definition at line 26 of file HGCalShowerShape.h.

References firstLayer(), and lastLayer().

Referenced by fillShapes().

26  {
27  return lastLayer(c3d) - firstLayer(c3d) + 1;
28  } //in number of layers
int lastLayer(const l1t::HGCalMulticluster &c3d) const
int firstLayer(const l1t::HGCalMulticluster &c3d) const

◆ sigmaEtaEtaMax()

float HGCalShowerShape::sigmaEtaEtaMax ( const l1t::HGCalMulticluster c3d) const

Definition at line 253 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), nano_mu_digi_cff::layer, HGCalTriggerTools::layerWithOffset(), pass(), sigmaXX(), caloTruthCellsProducer_cfi::triggerCells, and triggerTools_.

Referenced by fillShapes().

253  {
254  std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_eta;
255  std::unordered_map<int, LorentzVector> layer_LV;
256 
257  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
258 
259  for (const auto& id_clu : clustersPtrs) {
260  unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId());
261 
262  layer_LV[layer] += id_clu.second->p4();
263 
264  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
265 
266  for (const auto& id_tc : triggerCells) {
267  if (!pass(*id_tc.second, c3d))
268  continue;
269  tc_layer_energy_eta[layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta()));
270  }
271  }
272 
273  float SigmaEtaEtaMax = 0;
274 
275  for (auto& tc_iter : tc_layer_energy_eta) {
276  const std::vector<std::pair<float, float>>& energy_eta_layer = tc_iter.second;
277  const LorentzVector& LV_layer = layer_LV[tc_iter.first];
278  float SigmaEtaEtaLayer = sigmaXX(energy_eta_layer, LV_layer.eta()); //RMS wrt layer eta, not wrt c3d eta
279  if (SigmaEtaEtaLayer > SigmaEtaEtaMax)
280  SigmaEtaEtaMax = SigmaEtaEtaLayer;
281  }
282 
283  return SigmaEtaEtaMax;
284 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
HGCalTriggerTools triggerTools_
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
math::XYZTLorentzVector LorentzVector
unsigned layerWithOffset(const DetId &) const
bool pass(const T &obj, const Tref &ref) const

◆ sigmaEtaEtaTot() [1/2]

float HGCalShowerShape::sigmaEtaEtaTot ( const l1t::HGCalMulticluster c3d) const

Definition at line 182 of file HGCalShowerShape.cc.

References mathSSE::sqrt(), and varEtaEta().

Referenced by fillShapes().

182 { return sqrt(varEtaEta(c3d)); }
float varEtaEta(const l1t::HGCalMulticluster &c3d) const
T sqrt(T t)
Definition: SSEVec.h:19

◆ sigmaEtaEtaTot() [2/2]

float HGCalShowerShape::sigmaEtaEtaTot ( const l1t::HGCalCluster c2d) const

Definition at line 468 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), reco::LeafCandidate::eta(), pass(), and sigmaXX().

468  {
469  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.constituents();
470 
471  std::vector<std::pair<float, float>> tc_energy_eta;
472 
473  for (const auto& id_cell : cellsPtrs) {
474  if (!pass(*id_cell.second, c2d))
475  continue;
476  tc_energy_eta.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->eta()));
477  }
478 
479  float See = sigmaXX(tc_energy_eta, c2d.eta());
480 
481  return See;
482 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
bool pass(const T &obj, const Tref &ref) const
double eta() const final
momentum pseudorapidity

◆ sigmaPhiPhi()

float HGCalShowerShape::sigmaPhiPhi ( const std::vector< pair< float, float >> &  energy_phi_tc,
const float  phi_cluster 
) const
inlineprivate

Definition at line 87 of file HGCalShowerShape.h.

References mathSSE::sqrt(), and varPhiPhi().

Referenced by sigmaPhiPhiMax(), and sigmaPhiPhiTot().

87  {
88  return sqrt(varPhiPhi(energy_phi_tc, phi_cluster));
89  }
T sqrt(T t)
Definition: SSEVec.h:19
float varPhiPhi(const l1t::HGCalMulticluster &c3d) const

◆ sigmaPhiPhiMax()

float HGCalShowerShape::sigmaPhiPhiMax ( const l1t::HGCalMulticluster c3d) const

Definition at line 286 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), nano_mu_digi_cff::layer, HGCalTriggerTools::layerWithOffset(), pass(), sigmaPhiPhi(), caloTruthCellsProducer_cfi::triggerCells, and triggerTools_.

Referenced by fillShapes().

286  {
287  std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_phi;
288  std::unordered_map<int, LorentzVector> layer_LV;
289 
290  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
291 
292  for (const auto& id_clu : clustersPtrs) {
293  unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId());
294 
295  layer_LV[layer] += id_clu.second->p4();
296 
297  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
298 
299  for (const auto& id_tc : triggerCells) {
300  if (!pass(*id_tc.second, c3d))
301  continue;
302  tc_layer_energy_phi[layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi()));
303  }
304  }
305 
306  float SigmaPhiPhiMax = 0;
307 
308  for (auto& tc_iter : tc_layer_energy_phi) {
309  const std::vector<std::pair<float, float>>& energy_phi_layer = tc_iter.second;
310  const LorentzVector& LV_layer = layer_LV[tc_iter.first];
311  float SigmaPhiPhiLayer = sigmaPhiPhi(energy_phi_layer, LV_layer.phi()); //RMS wrt layer phi, not wrt c3d phi
312  if (SigmaPhiPhiLayer > SigmaPhiPhiMax)
313  SigmaPhiPhiMax = SigmaPhiPhiLayer;
314  }
315 
316  return SigmaPhiPhiMax;
317 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
HGCalTriggerTools triggerTools_
math::XYZTLorentzVector LorentzVector
unsigned layerWithOffset(const DetId &) const
bool pass(const T &obj, const Tref &ref) const
float sigmaPhiPhi(const std::vector< pair< float, float >> &energy_phi_tc, const float phi_cluster) const

◆ sigmaPhiPhiTot() [1/2]

float HGCalShowerShape::sigmaPhiPhiTot ( const l1t::HGCalMulticluster c3d) const

Definition at line 204 of file HGCalShowerShape.cc.

References mathSSE::sqrt(), and varPhiPhi().

Referenced by fillShapes().

204 { return sqrt(varPhiPhi(c3d)); }
T sqrt(T t)
Definition: SSEVec.h:19
float varPhiPhi(const l1t::HGCalMulticluster &c3d) const

◆ sigmaPhiPhiTot() [2/2]

float HGCalShowerShape::sigmaPhiPhiTot ( const l1t::HGCalCluster c2d) const

Definition at line 484 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), pass(), reco::LeafCandidate::phi(), and sigmaPhiPhi().

484  {
485  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.constituents();
486 
487  std::vector<std::pair<float, float>> tc_energy_phi;
488 
489  for (const auto& id_cell : cellsPtrs) {
490  if (!pass(*id_cell.second, c2d))
491  continue;
492  tc_energy_phi.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->phi()));
493  }
494 
495  float Spp = sigmaPhiPhi(tc_energy_phi, c2d.phi());
496 
497  return Spp;
498 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
bool pass(const T &obj, const Tref &ref) const
double phi() const final
momentum azimuthal angle
float sigmaPhiPhi(const std::vector< pair< float, float >> &energy_phi_tc, const float phi_cluster) const

◆ sigmaRRMax()

float HGCalShowerShape::sigmaRRMax ( const l1t::HGCalMulticluster c3d) const

Definition at line 319 of file HGCalShowerShape.cc.

References funct::abs(), l1t::HGCalClusterT< C >::constituents(), nano_mu_digi_cff::layer, HGCalTriggerTools::layerWithOffset(), meanX(), pass(), funct::pow(), alignCSCRings::r, sigmaXX(), mathSSE::sqrt(), caloTruthCellsProducer_cfi::triggerCells, and triggerTools_.

Referenced by fillShapes().

319  {
320  std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_r;
321 
322  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
323 
324  for (const auto& id_clu : clustersPtrs) {
325  unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId());
326 
327  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
328 
329  for (const auto& id_tc : triggerCells) {
330  if (!pass(*id_tc.second, c3d))
331  continue;
332  float r = (id_tc.second->position().z() != 0.
333  ? std::sqrt(pow(id_tc.second->position().x(), 2) + pow(id_tc.second->position().y(), 2)) /
334  std::abs(id_tc.second->position().z())
335  : 0.);
336  tc_layer_energy_r[layer].emplace_back(std::make_pair(id_tc.second->energy(), r));
337  }
338  }
339 
340  float SigmaRRMax = 0;
341 
342  for (auto& tc_iter : tc_layer_energy_r) {
343  const std::vector<std::pair<float, float>>& energy_r_layer = tc_iter.second;
344  float r_mean_layer = meanX(energy_r_layer);
345  float SigmaRRLayer = sigmaXX(energy_r_layer, r_mean_layer);
346  if (SigmaRRLayer > SigmaRRMax)
347  SigmaRRMax = SigmaRRLayer;
348  }
349 
350  return SigmaRRMax;
351 }
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
HGCalTriggerTools triggerTools_
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned layerWithOffset(const DetId &) const
bool pass(const T &obj, const Tref &ref) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ sigmaRRMean()

float HGCalShowerShape::sigmaRRMean ( const l1t::HGCalMulticluster c3d,
float  radius = 5. 
) const

Definition at line 353 of file HGCalShowerShape.cc.

References funct::abs(), l1t::HGCalClusterT< C >::constituents(), PVValHelper::dx, PVValHelper::dy, reco::LeafCandidate::energy(), nano_mu_digi_cff::layer, HGCalTriggerTools::layerWithOffset(), meanX(), pass(), l1t::HGCalTriggerCell::position(), alignCSCRings::r, CosmicsPD_Skims::radius, sigmaXX(), mathSSE::sqrt(), caloTruthCellsProducer_cfi::triggerCells, triggerTools_, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by fillShapes().

353  {
354  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
355  // group trigger cells by layer
356  std::unordered_map<int, std::vector<edm::Ptr<l1t::HGCalTriggerCell>>> layers_tcs;
357  for (const auto& id_clu : clustersPtrs) {
358  unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId());
359  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
360  for (const auto& id_tc : triggerCells) {
361  if (!pass(*id_tc.second, c3d))
362  continue;
363  layers_tcs[layer].emplace_back(id_tc.second);
364  }
365  }
366 
367  // Select trigger cells within X cm of the max TC in the layer
368  std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layers_energy_r;
369  for (const auto& layer_tcs : layers_tcs) {
370  int layer = layer_tcs.first;
371  edm::Ptr<l1t::HGCalTriggerCell> max_tc = layer_tcs.second.front();
372  for (const auto& tc : layer_tcs.second) {
373  if (tc->energy() > max_tc->energy())
374  max_tc = tc;
375  }
376  for (const auto& tc : layer_tcs.second) {
377  double dx = tc->position().x() - max_tc->position().x();
378  double dy = tc->position().y() - max_tc->position().y();
379  double distance_to_max = std::sqrt(dx * dx + dy * dy);
380  if (distance_to_max < radius) {
381  float r = (tc->position().z() != 0.
382  ? std::sqrt(tc->position().x() * tc->position().x() + tc->position().y() * tc->position().y()) /
383  std::abs(tc->position().z())
384  : 0.);
385  tc_layers_energy_r[layer].emplace_back(std::make_pair(tc->energy(), r));
386  }
387  }
388  }
389 
390  // Compute srr layer by layer
391  std::vector<std::pair<float, float>> layers_energy_srr2;
392  for (const auto& layer_energy_r : tc_layers_energy_r) {
393  const auto& energies_r = layer_energy_r.second;
394  float r_mean_layer = meanX(energies_r);
395  float srr = sigmaXX(energies_r, r_mean_layer);
396  double energy_sum = 0.;
397  for (const auto& energy_r : energies_r) {
398  energy_sum += energy_r.first;
399  }
400  layers_energy_srr2.emplace_back(std::make_pair(energy_sum, srr * srr));
401  }
402  // Combine all layer srr
403  float srr2_mean = meanX(layers_energy_srr2);
404  return std::sqrt(srr2_mean);
405 }
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
HGCalTriggerTools triggerTools_
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned layerWithOffset(const DetId &) const
bool pass(const T &obj, const Tref &ref) const
const GlobalPoint & position() const
double energy() const final
energy

◆ sigmaRRTot() [1/2]

float HGCalShowerShape::sigmaRRTot ( const l1t::HGCalMulticluster c3d) const

Definition at line 226 of file HGCalShowerShape.cc.

References mathSSE::sqrt(), and varRR().

Referenced by fillShapes().

226 { return sqrt(varRR(c3d)); }
T sqrt(T t)
Definition: SSEVec.h:19
float varRR(const l1t::HGCalMulticluster &c3d) const

◆ sigmaRRTot() [2/2]

float HGCalShowerShape::sigmaRRTot ( const l1t::HGCalCluster c2d) const

Definition at line 500 of file HGCalShowerShape.cc.

References funct::abs(), l1t::HGCalClusterT< C >::constituents(), meanX(), pass(), funct::pow(), alignCSCRings::r, sigmaXX(), and mathSSE::sqrt().

500  {
501  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.constituents();
502 
503  std::vector<std::pair<float, float>> tc_energy_r;
504 
505  for (const auto& id_cell : cellsPtrs) {
506  if (!pass(*id_cell.second, c2d))
507  continue;
508  float r = (id_cell.second->position().z() != 0.
509  ? std::sqrt(pow(id_cell.second->position().x(), 2) + pow(id_cell.second->position().y(), 2)) /
510  std::abs(id_cell.second->position().z())
511  : 0.);
512  tc_energy_r.emplace_back(std::make_pair(id_cell.second->energy(), r));
513  }
514 
515  float r_mean = meanX(tc_energy_r);
516  float Srr = sigmaXX(tc_energy_r, r_mean);
517 
518  return Srr;
519 }
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool pass(const T &obj, const Tref &ref) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ sigmaXX()

float HGCalShowerShape::sigmaXX ( const std::vector< pair< float, float >> &  energy_X_tc,
const float  X_cluster 
) const
inlineprivate

Definition at line 81 of file HGCalShowerShape.h.

References mathSSE::sqrt(), and varXX().

Referenced by sigmaEtaEtaMax(), sigmaEtaEtaTot(), sigmaRRMax(), sigmaRRMean(), and sigmaRRTot().

81  {
82  float X_RMS = sqrt(varXX(energy_X_tc, X_cluster));
83  return X_RMS;
84  }
T sqrt(T t)
Definition: SSEVec.h:19
float varXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const

◆ sigmaZZ()

float HGCalShowerShape::sigmaZZ ( const l1t::HGCalMulticluster c3d) const

Definition at line 447 of file HGCalShowerShape.cc.

References mathSSE::sqrt(), and varZZ().

Referenced by fillShapes().

447 { return sqrt(varZZ(c3d)); }
float varZZ(const l1t::HGCalMulticluster &c3d) const
T sqrt(T t)
Definition: SSEVec.h:19

◆ sumLayers()

float HGCalShowerShape::sumLayers ( const l1t::HGCalMulticluster c3d,
int  start = 1,
int  end = 0 
) const

Definition at line 521 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), mps_fire::end, DivergingColor::frac, HGCalTriggerTools::getTriggerGeometry(), mps_fire::i, HGCalTriggerGeometryBase::lastTriggerLayer(), nano_mu_digi_cff::layer, hgcalTBTopologyTester_cfi::layers, nlayers, pass(), compareTotals::tot, caloTruthCellsProducer_cfi::triggerCells, HGCalTriggerTools::triggerLayer(), and triggerTools_.

Referenced by fillShapes().

521  {
522  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
524  std::vector<double> layers(nlayers, 0);
525  for (const auto& id_clu : clustersPtrs) {
526  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
527 
528  for (const auto& id_tc : triggerCells) {
529  if (!pass(*id_tc.second, c3d))
530  continue;
531  unsigned layer = triggerTools_.triggerLayer(id_tc.second->detId());
532  if (layer == 0 || layer > nlayers)
533  continue;
534  layers[layer - 1] += id_tc.second->pt(); //shift by -1 because layer 0 doesn't exist
535  }
536  }
537  double sum_pt = 0;
538  for (int i = start - 1; i <= end - 1; i++) { //shift by -1 because layer 1 is layers[0]
539  sum_pt += layers[i];
540  }
541  double tot = 0;
542  for (unsigned i = 0; i < layers.size(); ++i) {
543  tot += layers[i];
544  }
545  float frac = 0;
546  if (tot > 0) {
547  frac = sum_pt / tot;
548  }
549  return frac;
550 }
Definition: start.py:1
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
virtual unsigned lastTriggerLayer() const =0
const HGCalTriggerGeometryBase * getTriggerGeometry() const
HGCalTriggerTools triggerTools_
bool pass(const T &obj, const Tref &ref) const
unsigned triggerLayer(const unsigned id) const

◆ varEtaEta()

float HGCalShowerShape::varEtaEta ( const l1t::HGCalMulticluster c3d) const

Definition at line 184 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), reco::LeafCandidate::eta(), pass(), caloTruthCellsProducer_cfi::triggerCells, and varXX().

Referenced by fillShapes(), and sigmaEtaEtaTot().

184  {
185  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
186 
187  std::vector<std::pair<float, float>> tc_energy_eta;
188 
189  for (const auto& id_clu : clustersPtrs) {
190  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
191 
192  for (const auto& id_tc : triggerCells) {
193  if (!pass(*id_tc.second, c3d))
194  continue;
195  tc_energy_eta.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta()));
196  }
197  }
198 
199  float varee = varXX(tc_energy_eta, c3d.eta());
200 
201  return varee;
202 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
bool pass(const T &obj, const Tref &ref) const
float varXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
double eta() const final
momentum pseudorapidity

◆ varPhiPhi() [1/2]

float HGCalShowerShape::varPhiPhi ( const l1t::HGCalMulticluster c3d) const

Definition at line 206 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), pass(), reco::LeafCandidate::phi(), and caloTruthCellsProducer_cfi::triggerCells.

Referenced by fillShapes(), sigmaPhiPhi(), and sigmaPhiPhiTot().

206  {
207  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
208 
209  std::vector<std::pair<float, float>> tc_energy_phi;
210 
211  for (const auto& id_clu : clustersPtrs) {
212  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
213 
214  for (const auto& id_tc : triggerCells) {
215  if (!pass(*id_tc.second, c3d))
216  continue;
217  tc_energy_phi.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi()));
218  }
219  }
220 
221  float varphiphi = varPhiPhi(tc_energy_phi, c3d.phi());
222 
223  return varphiphi;
224 }
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
bool pass(const T &obj, const Tref &ref) const
float varPhiPhi(const l1t::HGCalMulticluster &c3d) const
double phi() const final
momentum azimuthal angle

◆ varPhiPhi() [2/2]

float HGCalShowerShape::varPhiPhi ( const std::vector< pair< float, float >> &  energy_phi_tc,
const float  phi_cluster 
) const
inlineprivate

Definition at line 94 of file HGCalShowerShape.h.

94  {
95  return varXX<DeltaPhi<float>>(energy_phi_tc, phi_cluster);
96  }

◆ varRR()

float HGCalShowerShape::varRR ( const l1t::HGCalMulticluster c3d) const

Definition at line 228 of file HGCalShowerShape.cc.

References funct::abs(), l1t::HGCalClusterT< C >::constituents(), meanX(), pass(), funct::pow(), alignCSCRings::r, mathSSE::sqrt(), caloTruthCellsProducer_cfi::triggerCells, and varXX().

Referenced by fillShapes(), and sigmaRRTot().

228  {
229  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
230 
231  std::vector<std::pair<float, float>> tc_energy_r;
232 
233  for (const auto& id_clu : clustersPtrs) {
234  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
235 
236  for (const auto& id_tc : triggerCells) {
237  if (!pass(*id_tc.second, c3d))
238  continue;
239  float r = (id_tc.second->position().z() != 0.
240  ? std::sqrt(pow(id_tc.second->position().x(), 2) + pow(id_tc.second->position().y(), 2)) /
241  std::abs(id_tc.second->position().z())
242  : 0.);
243  tc_energy_r.emplace_back(std::make_pair(id_tc.second->energy(), r));
244  }
245  }
246 
247  float r_mean = meanX(tc_energy_r);
248  float vrr = varXX(tc_energy_r, r_mean);
249 
250  return vrr;
251 }
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool pass(const T &obj, const Tref &ref) const
float varXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ varXX()

template<typename Delta = std::minus<float>>
float HGCalShowerShape::varXX ( const std::vector< pair< float, float >> &  energy_X_tc,
const float  X_cluster 
) const
inlineprivate

Definition at line 67 of file HGCalShowerShape.h.

References dumpMFGeometry_cfg::delta, and funct::pow().

Referenced by sigmaXX(), varEtaEta(), varRR(), and varZZ().

67  {
68  Delta delta;
69  float Etot = 0;
70  float deltaX2_sum = 0;
71  for (const auto& energy_X : energy_X_tc) {
72  deltaX2_sum += energy_X.first * pow(delta(energy_X.second, X_cluster), 2);
73  Etot += energy_X.first;
74  }
75  float X_MSE = 0;
76  if (Etot > 0)
77  X_MSE = deltaX2_sum / Etot;
78  return X_MSE;
79  }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ varZZ()

float HGCalShowerShape::varZZ ( const l1t::HGCalMulticluster c3d) const

Definition at line 448 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), meanX(), pass(), caloTruthCellsProducer_cfi::triggerCells, and varXX().

Referenced by fillShapes(), and sigmaZZ().

448  {
449  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
450 
451  std::vector<std::pair<float, float>> tc_energy_z;
452 
453  for (const auto& id_clu : clustersPtrs) {
454  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
455 
456  for (const auto& id_tc : triggerCells) {
457  if (!pass(*id_tc.second, c3d))
458  continue;
459  tc_energy_z.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->position().z()));
460  }
461  }
462 
463  float z_mean = meanX(tc_energy_z);
464  float varzz = varXX(tc_energy_z, z_mean);
465 
466  return varzz;
467 }
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:49
bool pass(const T &obj, const Tref &ref) const
float varXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const

Member Data Documentation

◆ distance_

double HGCalShowerShape::distance_ = 1.
private

Definition at line 108 of file HGCalShowerShape.h.

Referenced by pass().

◆ threshold_

double HGCalShowerShape::threshold_ = 0.
private

Definition at line 107 of file HGCalShowerShape.h.

Referenced by pass().

◆ triggerTools_

HGCalTriggerTools HGCalShowerShape::triggerTools_
private