CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
hgcalsimclustertime::ComputeClusterTime Class Reference

#include <ComputeClusterTime.h>

Public Member Functions

 ComputeClusterTime ()
 
 ComputeClusterTime (float Xmix, float Xmax, float Cterm, float Aterm)
 
std::pair< float, float > fixSizeHighestDensity (std::vector< float > &time, std::vector< float > weight=std::vector< float >(), unsigned int minNhits=3, float deltaT=0.210, float timeWidthBy=0.5)
 
float getTimeError (std::string type, float xVal)
 
void setParameters (float Xmix, float Xmax, float Cterm, float Aterm)
 
float timeResolution (float xVal)
 

Private Attributes

float aTerm_
 
float cTerm_
 
float xMax_
 
float xMin_
 

Detailed Description

Definition at line 23 of file ComputeClusterTime.h.

Constructor & Destructor Documentation

◆ ComputeClusterTime() [1/2]

ComputeClusterTime::ComputeClusterTime ( float  Xmix,
float  Xmax,
float  Cterm,
float  Aterm 
)

Definition at line 24 of file ComputeClusterTime.cc.

25  : xMin_(Xmin), xMax_(Xmax), cTerm_(Cterm), aTerm_(Aterm) {
26  if (xMin_ <= 0)
27  xMin_ = 0.1;
28 };

References xMin_.

◆ ComputeClusterTime() [2/2]

ComputeClusterTime::ComputeClusterTime ( )

Definition at line 30 of file ComputeClusterTime.cc.

30 : xMin_(1.), xMax_(5.), cTerm_(0), aTerm_(0){};

Member Function Documentation

◆ fixSizeHighestDensity()

std::pair< float, float > ComputeClusterTime::fixSizeHighestDensity ( std::vector< float > &  time,
std::vector< float >  weight = std::vector<float>(),
unsigned int  minNhits = 3,
float  deltaT = 0.210,
float  timeWidthBy = 0.5 
)

Definition at line 64 of file ComputeClusterTime.cc.

65  {
66  if (time.size() < minNhits)
67  return std::pair<float, float>(-99., -1.);
68 
69  if (weight.empty())
70  weight.resize(time.size(), 1.);
71 
72  std::vector<float> t(time.size(), 0.);
73  std::vector<float> w(time.size(), 0.);
74  std::vector<size_t> sortedIndex = decrease_sorted_indices(time);
75  for (std::size_t i = 0; i < sortedIndex.size(); ++i) {
76  t[i] = time[sortedIndex[i]];
77  w[i] = weight[sortedIndex[i]];
78  }
79 
80  int max_elements = 0;
81  int start_el = 0;
82  int end_el = 0;
83  float timeW = 0.f;
84  float tolerance = 0.05f;
85 
86  for (auto start = t.begin(); start != t.end(); ++start) {
87  const auto startRef = *start;
88  int c = count_if(start, t.end(), [&](float el) { return el - startRef <= deltaT + tolerance; });
89  if (c > max_elements) {
90  max_elements = c;
91  auto last_el = find_if_not(start, t.end(), [&](float el) { return el - startRef <= deltaT + tolerance; });
92  auto valTostartDiff = *(--last_el) - startRef;
93  if (std::abs(deltaT - valTostartDiff) < tolerance) {
94  tolerance = std::abs(deltaT - valTostartDiff);
95  }
96  start_el = distance(t.begin(), start);
97  end_el = distance(t.begin(), last_el);
98  timeW = valTostartDiff;
99  }
100  }
101 
102  // further adjust time width around the chosen one based on the hits density
103  // proved to improve the resolution: get as many hits as possible provided they are close in time
104  float HalfTimeDiff = timeW * timeWidthBy;
105  float sum = 0.;
106  float num = 0;
107  int totSize = t.size();
108 
109  for (int ij = 0; ij <= start_el; ++ij) {
110  if (t[ij] > (t[start_el] - HalfTimeDiff)) {
111  for (int kl = ij; kl < totSize; ++kl) {
112  if (t[kl] < (t[end_el] + HalfTimeDiff)) {
113  sum += t[kl] * w[kl];
114  num += w[kl];
115  } else
116  break;
117  }
118  break;
119  }
120  }
121 
122  if (num == 0) {
123  return std::pair<float, float>(-99., -1.);
124  }
125  return std::pair<float, float>(sum / num, 1. / sqrt(num));
126 }

References funct::abs(), HltBtagPostValidation_cff::c, decrease_sorted_indices(), HLT_FULL_cff::distance, mps_fire::i, EgammaValidation_cff::num, mathSSE::sqrt(), command_line::start, submitPVValidationJobs::t, ntuplemaker::time, tolerance, cms::cuda::totSize, and w.

Referenced by ticl::assignPCAtoTracksters(), RealisticSimClusterMapper::buildClusters(), and HGCalLayerClusterProducer::produce().

◆ getTimeError()

float ComputeClusterTime::getTimeError ( std::string  type,
float  xVal 
)

Definition at line 46 of file ComputeClusterTime.cc.

46  {
47  if (type == "recHit") {
48  //xVal is S/N
49  //time is in ns units
50  if (xVal < xMin_)
51  return timeResolution(xMin_);
52  else if (xVal > xMax_)
53  return cTerm_;
54  else
55  return timeResolution(xVal);
56 
57  return -1;
58  }
59  return -1;
60 }

References cTerm_, timeResolution(), xMax_, and xMin_.

Referenced by HGCalRecHitWorkerSimple::run().

◆ setParameters()

void ComputeClusterTime::setParameters ( float  Xmix,
float  Xmax,
float  Cterm,
float  Aterm 
)

Definition at line 32 of file ComputeClusterTime.cc.

32  {
33  xMin_ = (Xmin > 0) ? Xmin : 0.1;
34  xMax_ = Xmax;
35  cTerm_ = Cterm;
36  aTerm_ = Aterm;
37  return;
38 }

References aTerm_, cTerm_, PixelVTXMonitor_cfi::Xmax, xMax_, PixelVTXMonitor_cfi::Xmin, and xMin_.

◆ timeResolution()

float ComputeClusterTime::timeResolution ( float  xVal)

Definition at line 41 of file ComputeClusterTime.cc.

41  {
42  float funcVal = pow(aTerm_ / x, 2) + pow(cTerm_, 2);
43  return sqrt(funcVal);
44 }

References aTerm_, cTerm_, funct::pow(), and mathSSE::sqrt().

Referenced by getTimeError().

Member Data Documentation

◆ aTerm_

float hgcalsimclustertime::ComputeClusterTime::aTerm_
private

Definition at line 49 of file ComputeClusterTime.h.

Referenced by setParameters(), and timeResolution().

◆ cTerm_

float hgcalsimclustertime::ComputeClusterTime::cTerm_
private

Definition at line 48 of file ComputeClusterTime.h.

Referenced by getTimeError(), setParameters(), and timeResolution().

◆ xMax_

float hgcalsimclustertime::ComputeClusterTime::xMax_
private

Definition at line 47 of file ComputeClusterTime.h.

Referenced by getTimeError(), and setParameters().

◆ xMin_

float hgcalsimclustertime::ComputeClusterTime::xMin_
private

Definition at line 46 of file ComputeClusterTime.h.

Referenced by ComputeClusterTime(), getTimeError(), and setParameters().

mps_fire.i
i
Definition: mps_fire.py:428
start
Definition: start.py:1
cms::cuda::totSize
cudaStream_t T uint32_t const T *__restrict__ const uint32_t *__restrict__ uint32_t totSize
Definition: HistoContainer.h:92
hgcalsimclustertime::ComputeClusterTime::xMin_
float xMin_
Definition: ComputeClusterTime.h:46
DDAxes::x
hgcalsimclustertime::ComputeClusterTime::timeResolution
float timeResolution(float xVal)
Definition: ComputeClusterTime.cc:41
hgcalsimclustertime::ComputeClusterTime::aTerm_
float aTerm_
Definition: ComputeClusterTime.h:49
w
const double w
Definition: UKUtility.cc:23
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:26
PixelVTXMonitor_cfi.Xmax
Xmax
Definition: PixelVTXMonitor_cfi.py:8
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
hgcalsimclustertime::ComputeClusterTime::cTerm_
float cTerm_
Definition: ComputeClusterTime.h:48
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
decrease_sorted_indices
std::vector< size_t > decrease_sorted_indices(const std::vector< float > &v)
Definition: ComputeClusterTime.cc:14
hgcalsimclustertime::ComputeClusterTime::xMax_
float xMax_
Definition: ComputeClusterTime.h:47
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
command_line.start
start
Definition: command_line.py:167
ntuplemaker.time
time
Definition: ntuplemaker.py:310
PixelVTXMonitor_cfi.Xmin
Xmin
Definition: PixelVTXMonitor_cfi.py:8
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7799
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
weight
Definition: weight.py:1