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 coreShowerLength (const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry) const
 
float eMax (const l1t::HGCalMulticluster &c3d) const
 
void eventSetup (const edm::EventSetup &es)
 
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
 
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
 
 ~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
 
template<typename Delta = std::minus<float>>
float sigmaXX (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

Definition at line 14 of file HGCalShowerShape.h.

Constructor & Destructor Documentation

HGCalShowerShape::HGCalShowerShape ( )
inline

Definition at line 16 of file HGCalShowerShape.h.

16 : threshold_(0.) {}
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
HGCalShowerShape::~HGCalShowerShape ( )
inline

Definition at line 19 of file HGCalShowerShape.h.

19 {}

Member Function Documentation

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, hgcalTopologyTester_cfi::layers, HGCalTriggerTools::layers(), nlayers, pass(), HGCalTriggerGeometryBase::triggerLayer(), and triggerTools_.

Referenced by fillShapes(), and showerLength().

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 (layer == 0 || layer > nlayers)
91  continue;
92  layers[layer - 1] = true; //layer 0 doesn't exist, so shift by -1
93  }
94  int length = 0;
95  int maxlength = 0;
96  for (bool layer : layers) {
97  if (layer)
98  length++;
99  else
100  length = 0;
101  if (length > maxlength)
102  maxlength = length;
103  }
104  return maxlength;
105 }
bool pass(const T &obj, const Tref &ref) const
HGCalTriggerTools triggerTools_
virtual unsigned triggerLayer(const unsigned id) const =0
unsigned layers(ForwardSubdetector type) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::eMax ( const l1t::HGCalMulticluster c3d) const

Definition at line 391 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

391  {
392  std::unordered_map<int, float> layer_energy;
393 
394  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
395 
396  for (const auto& id_clu : clustersPtrs) {
397  if (!pass(*id_clu.second, c3d))
398  continue;
399  unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId());
400  layer_energy[layer] += id_clu.second->energy();
401  }
402 
403  float EMax = 0;
404 
405  for (const auto& layer : layer_energy) {
406  if (layer.second > EMax)
407  EMax = layer.second;
408  }
409 
410  return EMax;
411 }
bool pass(const T &obj, const Tref &ref) const
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
void HGCalShowerShape::eventSetup ( const edm::EventSetup es)
inline
void HGCalShowerShape::fillShapes ( l1t::HGCalMulticluster c3d,
const HGCalTriggerGeometryBase triggerGeometry 
) const

Definition at line 505 of file HGCalShowerShape.cc.

References coreShowerLength(), l1t::HGCalClusterT< C >::coreShowerLength(), eMax(), l1t::HGCalClusterT< C >::eMax(), firstLayer(), l1t::HGCalClusterT< C >::firstLayer(), l1t::HGCalClusterT< C >::layer10percent(), l1t::HGCalClusterT< C >::layer50percent(), l1t::HGCalClusterT< C >::layer90percent(), maxLayer(), l1t::HGCalClusterT< C >::maxLayer(), meanZ(), percentileLayer(), percentileTriggerCells(), showerLength(), l1t::HGCalClusterT< C >::showerLength(), sigmaEtaEtaMax(), l1t::HGCalClusterT< C >::sigmaEtaEtaMax(), sigmaEtaEtaTot(), l1t::HGCalClusterT< C >::sigmaEtaEtaTot(), sigmaPhiPhiMax(), l1t::HGCalClusterT< C >::sigmaPhiPhiMax(), sigmaPhiPhiTot(), l1t::HGCalClusterT< C >::sigmaPhiPhiTot(), sigmaRRMax(), l1t::HGCalClusterT< C >::sigmaRRMax(), sigmaRRMean(), l1t::HGCalClusterT< C >::sigmaRRMean(), sigmaRRTot(), l1t::HGCalClusterT< C >::sigmaRRTot(), sigmaZZ(), l1t::HGCalClusterT< C >::sigmaZZ(), l1t::HGCalClusterT< C >::triggerCells67percent(), l1t::HGCalClusterT< C >::triggerCells90percent(), and l1t::HGCalClusterT< C >::zBarycenter().

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

505  {
506  c3d.showerLength(showerLength(c3d));
507  c3d.coreShowerLength(coreShowerLength(c3d, triggerGeometry));
508  c3d.firstLayer(firstLayer(c3d));
509  c3d.maxLayer(maxLayer(c3d));
510  c3d.sigmaEtaEtaTot(sigmaEtaEtaTot(c3d));
511  c3d.sigmaEtaEtaMax(sigmaEtaEtaMax(c3d));
512  c3d.sigmaPhiPhiTot(sigmaPhiPhiTot(c3d));
513  c3d.sigmaPhiPhiMax(sigmaPhiPhiMax(c3d));
514  c3d.sigmaZZ(sigmaZZ(c3d));
515  c3d.sigmaRRTot(sigmaRRTot(c3d));
516  c3d.sigmaRRMax(sigmaRRMax(c3d));
517  c3d.sigmaRRMean(sigmaRRMean(c3d));
518  c3d.eMax(eMax(c3d));
519  c3d.zBarycenter(meanZ(c3d));
520  c3d.layer10percent(percentileLayer(c3d, triggerGeometry, 0.10));
521  c3d.layer50percent(percentileLayer(c3d, triggerGeometry, 0.50));
522  c3d.layer90percent(percentileLayer(c3d, triggerGeometry, 0.90));
525 }
float meanZ(const l1t::HGCalMulticluster &c3d) const
float layer10percent() const
float sigmaRRMax(const l1t::HGCalMulticluster &c3d) const
int maxLayer() const
float sigmaPhiPhiTot() const
float triggerCells90percent() const
float sigmaEtaEtaMax() const
float sigmaRRTot() const
int coreShowerLength(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry) const
float sigmaRRTot(const l1t::HGCalMulticluster &c3d) const
float sigmaPhiPhiTot(const l1t::HGCalMulticluster &c3d) const
int firstLayer(const l1t::HGCalMulticluster &c3d) const
float sigmaZZ() const
float percentileLayer(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry, float quantile=0.5) const
float sigmaRRMean(const l1t::HGCalMulticluster &c3d, float radius=5.) const
int showerLength() const
float layer90percent() const
float sigmaEtaEtaMax(const l1t::HGCalMulticluster &c3d) const
float percentileTriggerCells(const l1t::HGCalMulticluster &c3d, float quantile=0.5) const
float sigmaEtaEtaTot() const
float eMax() const
int coreShowerLength() const
float layer50percent() const
int firstLayer() const
int showerLength(const l1t::HGCalMulticluster &c3d) const
float sigmaRRMean() const
float triggerCells67percent() const
float sigmaZZ(const l1t::HGCalMulticluster &c3d) const
float sigmaRRMax() const
float sigmaPhiPhiMax(const l1t::HGCalMulticluster &c3d) const
int maxLayer(const l1t::HGCalMulticluster &c3d) const
float zBarycenter() const
float sigmaPhiPhiMax() const
float eMax(const l1t::HGCalMulticluster &c3d) const
float sigmaEtaEtaTot(const l1t::HGCalMulticluster &c3d) const
int HGCalShowerShape::firstLayer ( const l1t::HGCalMulticluster c3d) const

Definition at line 30 of file HGCalShowerShape.cc.

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

Referenced by eventSetup(), 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 }
bool pass(const T &obj, const Tref &ref) const
HGCalTriggerTools triggerTools_
int firstLayer(const l1t::HGCalMulticluster &c3d) const
unsigned layerWithOffset(const DetId &) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
int HGCalShowerShape::lastLayer ( const l1t::HGCalMulticluster c3d) const

Definition at line 65 of file HGCalShowerShape.cc.

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

Referenced by eventSetup(), and 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 }
bool pass(const T &obj, const Tref &ref) const
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
int lastLayer(const l1t::HGCalMulticluster &c3d) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
int HGCalShowerShape::maxLayer ( const l1t::HGCalMulticluster c3d) const

Definition at line 46 of file HGCalShowerShape.cc.

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

Referenced by eventSetup(), and 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 }
bool pass(const T &obj, const Tref &ref) const
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
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(), showerLength(), sigmaRRMax(), sigmaRRMean(), sigmaRRTot(), and sigmaZZ().

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 }
float HGCalShowerShape::meanZ ( const l1t::HGCalMulticluster c3d) const

Definition at line 413 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

413  {
414  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
415 
416  std::vector<std::pair<float, float>> tc_energy_z;
417 
418  for (const auto& id_clu : clustersPtrs) {
419  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
420 
421  for (const auto& id_tc : triggerCells) {
422  if (!pass(*id_tc.second, c3d))
423  continue;
424  tc_energy_z.emplace_back(id_tc.second->energy(), id_tc.second->position().z());
425  }
426  }
427 
428  return meanX(tc_energy_z);
429 }
bool pass(const T &obj, const Tref &ref) const
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:50
template<typename T , typename Tref >
bool HGCalShowerShape::pass ( const T obj,
const Tref &  ref 
) const
inlineprivate

Definition at line 85 of file HGCalShowerShape.h.

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

Referenced by coreShowerLength(), eMax(), firstLayer(), lastLayer(), maxLayer(), meanZ(), percentileLayer(), percentileTriggerCells(), sigmaEtaEtaMax(), sigmaEtaEtaTot(), sigmaPhiPhiMax(), sigmaPhiPhiTot(), sigmaRRMax(), sigmaRRMean(), sigmaRRTot(), and sigmaZZ().

85  {
86  bool pass_threshold = (obj.mipPt() > threshold_);
87  GlobalPoint proj(Basic3DVector<float>(obj.position()) / std::abs(obj.position().z()));
88  bool pass_distance = ((proj - ref.centreProj()).mag() < distance_);
89  return pass_threshold && pass_distance;
90  }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float HGCalShowerShape::percentileLayer ( const l1t::HGCalMulticluster c3d,
const HGCalTriggerGeometryBase triggerGeometry,
float  quantile = 0.5 
) const

Definition at line 107 of file HGCalShowerShape.cc.

References l1t::HGCalClusterT< C >::constituents(), ForwardEmpty, hgcalTopologyTester_cfi::layers, HGCalTriggerTools::layers(), nlayers, pass(), DiDispStaMuonMonitor_cfi::pt, HLT_2018_cff::pt1, SusyPostProcessor_cff::quantile, caloTruthCellsProducer_cfi::triggerCells, HGCalTriggerGeometryBase::triggerLayer(), and triggerTools_.

Referenced by fillShapes(), and showerLength().

109  {
110  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
112  std::vector<double> layers(nlayers, 0);
113  for (const auto& id_clu : clustersPtrs) {
114  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
115 
116  for (const auto& id_tc : triggerCells) {
117  if (!pass(*id_tc.second, c3d))
118  continue;
119  unsigned layer = triggerGeometry.triggerLayer(id_tc.second->detId());
120  if (layer == 0 || layer > nlayers)
121  continue;
122  layers[layer - 1] += id_tc.second->pt(); //layer 0 doesn't exist, so shift by -1
123  }
124  }
125  std::partial_sum(layers.begin(), layers.end(), layers.begin());
126  double pt_threshold = layers.back() * quantile;
127  int percentile = 0;
128  for (double pt : layers) {
129  if (pt > pt_threshold) {
130  break;
131  }
132  percentile++;
133  }
134  // Linear interpolation of percentile value
135  double pt0 = (percentile > 0 ? layers[percentile - 1] : 0.);
136  double pt1 = layers[percentile];
137  return percentile + (pt1 - pt0 > 0. ? (pt_threshold - pt0) / (pt1 - pt0) : 0.);
138 }
bool pass(const T &obj, const Tref &ref) const
HGCalTriggerTools triggerTools_
virtual unsigned triggerLayer(const unsigned id) const =0
unsigned layers(ForwardSubdetector type) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::percentileTriggerCells ( const l1t::HGCalMulticluster c3d,
float  quantile = 0.5 
) const

Definition at line 140 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

140  {
141  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
142  std::set<double> ordered_tcs;
143  double pt_sum = 0.;
144  for (const auto& id_clu : clustersPtrs) {
145  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
146 
147  for (const auto& id_tc : triggerCells) {
148  if (!pass(*id_tc.second, c3d))
149  continue;
150  ordered_tcs.emplace(id_tc.second->pt());
151  pt_sum += id_tc.second->pt();
152  }
153  }
154  double pt_threshold = pt_sum * quantile;
155  double partial_sum = 0.;
156  double partial_sum_prev = 0.;
157  int ntc = 0;
158  for (auto itr = ordered_tcs.rbegin(); itr != ordered_tcs.rend(); ++itr) {
159  partial_sum_prev = partial_sum;
160  partial_sum += *itr;
161  ntc++;
162  if (partial_sum > pt_threshold) {
163  break;
164  }
165  }
166  // Linear interpolation of ntc
167  return ntc - 1 +
168  (partial_sum - partial_sum_prev > 0. ? (pt_threshold - partial_sum_prev) / (partial_sum - partial_sum_prev)
169  : 0.);
170 }
bool pass(const T &obj, const Tref &ref) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
int HGCalShowerShape::showerLength ( const l1t::HGCalMulticluster c3d) const
inline

Definition at line 26 of file HGCalShowerShape.h.

References coreShowerLength(), eMax(), fillShapes(), firstLayer(), lastLayer(), meanX(), meanZ(), percentileLayer(), percentileTriggerCells(), SusyPostProcessor_cff::quantile, CosmicsPD_Skims::radius, sigmaEtaEtaMax(), sigmaEtaEtaTot(), sigmaPhiPhiMax(), sigmaPhiPhiTot(), sigmaRRMax(), sigmaRRMean(), sigmaRRTot(), and sigmaZZ().

Referenced by fillShapes().

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

Definition at line 237 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

237  {
238  std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_eta;
239  std::unordered_map<int, LorentzVector> layer_LV;
240 
241  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
242 
243  for (const auto& id_clu : clustersPtrs) {
244  unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId());
245 
246  layer_LV[layer] += id_clu.second->p4();
247 
248  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
249 
250  for (const auto& id_tc : triggerCells) {
251  if (!pass(*id_tc.second, c3d))
252  continue;
253  tc_layer_energy_eta[layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta()));
254  }
255  }
256 
257  float SigmaEtaEtaMax = 0;
258 
259  for (auto& tc_iter : tc_layer_energy_eta) {
260  const std::vector<std::pair<float, float>>& energy_eta_layer = tc_iter.second;
261  const LorentzVector& LV_layer = layer_LV[tc_iter.first];
262  float SigmaEtaEtaLayer = sigmaXX(energy_eta_layer, LV_layer.eta()); //RMS wrt layer eta, not wrt c3d eta
263  if (SigmaEtaEtaLayer > SigmaEtaEtaMax)
264  SigmaEtaEtaMax = SigmaEtaEtaLayer;
265  }
266 
267  return SigmaEtaEtaMax;
268 }
bool pass(const T &obj, const Tref &ref) const
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
math::XYZTLorentzVector LorentzVector
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::sigmaEtaEtaTot ( const l1t::HGCalMulticluster c3d) const

Definition at line 172 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

172  {
173  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
174 
175  std::vector<std::pair<float, float>> tc_energy_eta;
176 
177  for (const auto& id_clu : clustersPtrs) {
178  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
179 
180  for (const auto& id_tc : triggerCells) {
181  if (!pass(*id_tc.second, c3d))
182  continue;
183  tc_energy_eta.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta()));
184  }
185  }
186 
187  float SeeTot = sigmaXX(tc_energy_eta, c3d.eta());
188 
189  return SeeTot;
190 }
double eta() const final
momentum pseudorapidity
bool pass(const T &obj, const Tref &ref) const
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::sigmaEtaEtaTot ( const l1t::HGCalCluster c2d) const

Definition at line 452 of file HGCalShowerShape.cc.

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

452  {
453  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.constituents();
454 
455  std::vector<std::pair<float, float>> tc_energy_eta;
456 
457  for (const auto& id_cell : cellsPtrs) {
458  if (!pass(*id_cell.second, c2d))
459  continue;
460  tc_energy_eta.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->eta()));
461  }
462 
463  float See = sigmaXX(tc_energy_eta, c2d.eta());
464 
465  return See;
466 }
double eta() const final
momentum pseudorapidity
bool pass(const T &obj, const Tref &ref) const
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::sigmaPhiPhi ( const std::vector< pair< float, float >> &  energy_phi_tc,
const float  phi_cluster 
) const
inlineprivate

Definition at line 81 of file HGCalShowerShape.h.

Referenced by sigmaPhiPhiMax(), and sigmaPhiPhiTot().

81  {
82  return sigmaXX<DeltaPhi<float>>(energy_phi_tc, phi_cluster);
83  }
float HGCalShowerShape::sigmaPhiPhiMax ( const l1t::HGCalMulticluster c3d) const

Definition at line 270 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

270  {
271  std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_phi;
272  std::unordered_map<int, LorentzVector> layer_LV;
273 
274  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
275 
276  for (const auto& id_clu : clustersPtrs) {
277  unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId());
278 
279  layer_LV[layer] += id_clu.second->p4();
280 
281  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
282 
283  for (const auto& id_tc : triggerCells) {
284  if (!pass(*id_tc.second, c3d))
285  continue;
286  tc_layer_energy_phi[layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi()));
287  }
288  }
289 
290  float SigmaPhiPhiMax = 0;
291 
292  for (auto& tc_iter : tc_layer_energy_phi) {
293  const std::vector<std::pair<float, float>>& energy_phi_layer = tc_iter.second;
294  const LorentzVector& LV_layer = layer_LV[tc_iter.first];
295  float SigmaPhiPhiLayer = sigmaPhiPhi(energy_phi_layer, LV_layer.phi()); //RMS wrt layer phi, not wrt c3d phi
296  if (SigmaPhiPhiLayer > SigmaPhiPhiMax)
297  SigmaPhiPhiMax = SigmaPhiPhiLayer;
298  }
299 
300  return SigmaPhiPhiMax;
301 }
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
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
math::XYZTLorentzVector LorentzVector
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::sigmaPhiPhiTot ( const l1t::HGCalMulticluster c3d) const

Definition at line 192 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

192  {
193  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
194 
195  std::vector<std::pair<float, float>> tc_energy_phi;
196 
197  for (const auto& id_clu : clustersPtrs) {
198  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
199 
200  for (const auto& id_tc : triggerCells) {
201  if (!pass(*id_tc.second, c3d))
202  continue;
203  tc_energy_phi.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi()));
204  }
205  }
206 
207  float SppTot = sigmaPhiPhi(tc_energy_phi, c3d.phi());
208 
209  return SppTot;
210 }
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
double phi() const final
momentum azimuthal angle
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::sigmaPhiPhiTot ( const l1t::HGCalCluster c2d) const

Definition at line 468 of file HGCalShowerShape.cc.

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

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_phi;
472 
473  for (const auto& id_cell : cellsPtrs) {
474  if (!pass(*id_cell.second, c2d))
475  continue;
476  tc_energy_phi.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->phi()));
477  }
478 
479  float Spp = sigmaPhiPhi(tc_energy_phi, c2d.phi());
480 
481  return Spp;
482 }
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
double phi() const final
momentum azimuthal angle
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::sigmaRRMax ( const l1t::HGCalMulticluster c3d) const

Definition at line 303 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

303  {
304  std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_r;
305 
306  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
307 
308  for (const auto& id_clu : clustersPtrs) {
309  unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId());
310 
311  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
312 
313  for (const auto& id_tc : triggerCells) {
314  if (!pass(*id_tc.second, c3d))
315  continue;
316  float r = (id_tc.second->position().z() != 0.
317  ? std::sqrt(pow(id_tc.second->position().x(), 2) + pow(id_tc.second->position().y(), 2)) /
318  std::abs(id_tc.second->position().z())
319  : 0.);
320  tc_layer_energy_r[layer].emplace_back(std::make_pair(id_tc.second->energy(), r));
321  }
322  }
323 
324  float SigmaRRMax = 0;
325 
326  for (auto& tc_iter : tc_layer_energy_r) {
327  const std::vector<std::pair<float, float>>& energy_r_layer = tc_iter.second;
328  float r_mean_layer = meanX(energy_r_layer);
329  float SigmaRRLayer = sigmaXX(energy_r_layer, r_mean_layer);
330  if (SigmaRRLayer > SigmaRRMax)
331  SigmaRRMax = SigmaRRLayer;
332  }
333 
334  return SigmaRRMax;
335 }
bool pass(const T &obj, const Tref &ref) const
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::sigmaRRMean ( const l1t::HGCalMulticluster c3d,
float  radius = 5. 
) const

Definition at line 337 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

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

Definition at line 212 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

212  {
213  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
214 
215  std::vector<std::pair<float, float>> tc_energy_r;
216 
217  for (const auto& id_clu : clustersPtrs) {
218  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
219 
220  for (const auto& id_tc : triggerCells) {
221  if (!pass(*id_tc.second, c3d))
222  continue;
223  float r = (id_tc.second->position().z() != 0.
224  ? std::sqrt(pow(id_tc.second->position().x(), 2) + pow(id_tc.second->position().y(), 2)) /
225  std::abs(id_tc.second->position().z())
226  : 0.);
227  tc_energy_r.emplace_back(std::make_pair(id_tc.second->energy(), r));
228  }
229  }
230 
231  float r_mean = meanX(tc_energy_r);
232  float Szz = sigmaXX(tc_energy_r, r_mean);
233 
234  return Szz;
235 }
bool pass(const T &obj, const Tref &ref) const
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
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
float HGCalShowerShape::sigmaRRTot ( const l1t::HGCalCluster c2d) const

Definition at line 484 of file HGCalShowerShape.cc.

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

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_r;
488 
489  for (const auto& id_cell : cellsPtrs) {
490  if (!pass(*id_cell.second, c2d))
491  continue;
492  float r = (id_cell.second->position().z() != 0.
493  ? std::sqrt(pow(id_cell.second->position().x(), 2) + pow(id_cell.second->position().y(), 2)) /
494  std::abs(id_cell.second->position().z())
495  : 0.);
496  tc_energy_r.emplace_back(std::make_pair(id_cell.second->energy(), r));
497  }
498 
499  float r_mean = meanX(tc_energy_r);
500  float Srr = sigmaXX(tc_energy_r, r_mean);
501 
502  return Srr;
503 }
bool pass(const T &obj, const Tref &ref) const
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
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
Definition: HGCalClusterT.h:50
template<typename Delta = std::minus<float>>
float HGCalShowerShape::sigmaXX ( const std::vector< pair< float, float >> &  energy_X_tc,
const float  X_cluster 
) const
inlineprivate

Definition at line 62 of file HGCalShowerShape.h.

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

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

62  {
63  Delta delta;
64  float Etot = 0;
65  float deltaX2_sum = 0;
66  for (const auto& energy_X : energy_X_tc) {
67  deltaX2_sum += energy_X.first * pow(delta(energy_X.second, X_cluster), 2);
68  Etot += energy_X.first;
69  }
70  float X_MSE = 0;
71  if (Etot > 0)
72  X_MSE = deltaX2_sum / Etot;
73  float X_RMS = sqrt(X_MSE);
74  return X_RMS;
75  }
T sqrt(T t)
Definition: SSEVec.h:19
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
float HGCalShowerShape::sigmaZZ ( const l1t::HGCalMulticluster c3d) const

Definition at line 431 of file HGCalShowerShape.cc.

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

Referenced by fillShapes(), and showerLength().

431  {
432  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.constituents();
433 
434  std::vector<std::pair<float, float>> tc_energy_z;
435 
436  for (const auto& id_clu : clustersPtrs) {
437  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& triggerCells = id_clu.second->constituents();
438 
439  for (const auto& id_tc : triggerCells) {
440  if (!pass(*id_tc.second, c3d))
441  continue;
442  tc_energy_z.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->position().z()));
443  }
444  }
445 
446  float z_mean = meanX(tc_energy_z);
447  float Szz = sigmaXX(tc_energy_z, z_mean);
448 
449  return Szz;
450 }
bool pass(const T &obj, const Tref &ref) const
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
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:50

Member Data Documentation

double HGCalShowerShape::distance_ = 1.
private

Definition at line 94 of file HGCalShowerShape.h.

Referenced by pass().

double HGCalShowerShape::threshold_ = 0.
private

Definition at line 93 of file HGCalShowerShape.h.

Referenced by pass().

HGCalTriggerTools HGCalShowerShape::triggerTools_
private