CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
EcalUncalibRecHitTimingCCAlgo Class Reference

#include <EcalUncalibRecHitTimingCCAlgo.h>

Public Member Functions

double computeTimeCC (const EcalDataFrame &dataFrame, const std::vector< double > &amplitudes, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const FullSampleVector &fullpulse, EcalUncalibratedRecHit &uncalibRecHit, float &errOnTime) const
 
 EcalUncalibRecHitTimingCCAlgo (const float startTime, const float stopTime, const float targetTimePrecision)
 

Private Member Functions

float computeCC (const std::vector< float > &samples, const FullSampleVector &sigmalTemplate, const float t) const
 
FullSampleVector interpolatePulse (const FullSampleVector &fullpulse, const float t=0) const
 

Private Attributes

const float startTime_
 
const float stopTime_
 
const float targetTimePrecision_
 

Static Private Attributes

static constexpr float GLOBAL_TIME_SHIFT = 100
 
static constexpr int MAX_NUM_OF_ITERATIONS = 30
 
static constexpr int MIN_NUM_OF_ITERATIONS = 2
 
static constexpr int TIME_WHEN_NOT_CONVERGING = 100
 

Detailed Description

CrossCorrelation algorithm for timing reconstruction

Author
N. Minafra, J. King, C. Rogan

Definition at line 18 of file EcalUncalibRecHitTimingCCAlgo.h.

Constructor & Destructor Documentation

◆ EcalUncalibRecHitTimingCCAlgo()

EcalUncalibRecHitTimingCCAlgo::EcalUncalibRecHitTimingCCAlgo ( const float  startTime,
const float  stopTime,
const float  targetTimePrecision 
)

Definition at line 3 of file EcalUncalibRecHitTimingCCAlgo.cc.

6  : startTime_(startTime), stopTime_(stopTime), targetTimePrecision_(targetTimePrecision) {}

Member Function Documentation

◆ computeCC()

float EcalUncalibRecHitTimingCCAlgo::computeCC ( const std::vector< float > &  samples,
const FullSampleVector sigmalTemplate,
const float  t 
) const
private

Definition at line 142 of file EcalUncalibRecHitTimingCCAlgo.cc.

144  {
145  constexpr int exclude = 1;
146  float powerSamples = 0.;
147  float powerTemplate = 0.;
148  float cc = 0.;
149  auto interpolated = interpolatePulse(signalTemplate, time);
150  for (int i = exclude; i < int(samples.size() - exclude); ++i) {
151  powerSamples += std::pow(samples[i], 2);
152  powerTemplate += std::pow(interpolated[i], 2);
153  cc += interpolated[i] * samples[i];
154  }
155 
156  float denominator = std::sqrt(powerTemplate * powerSamples);
157  return cc / denominator;
158 }

References HLTTauDQMOffline_cfi::denominator, mps_fire::i, createfilelist::int, interpolatePulse(), funct::pow(), EgammaValidation_cff::samples, mathSSE::sqrt(), and protons_cff::time.

Referenced by computeTimeCC().

◆ computeTimeCC()

double EcalUncalibRecHitTimingCCAlgo::computeTimeCC ( const EcalDataFrame dataFrame,
const std::vector< double > &  amplitudes,
const EcalPedestals::Item aped,
const EcalMGPAGainRatio aGain,
const FullSampleVector fullpulse,
EcalUncalibratedRecHit uncalibRecHit,
float &  errOnTime 
) const

Definition at line 8 of file EcalUncalibRecHitTimingCCAlgo.cc.

14  {
15  constexpr unsigned int nsample = EcalDataFrame::MAXSAMPLES;
16 
17  double maxamplitude = -std::numeric_limits<double>::max();
18  float pulsenorm = 0.;
19 
20  std::vector<float> pedSubSamples(nsample);
21  for (unsigned int iSample = 0; iSample < nsample; iSample++) {
22  const EcalMGPASample& sample = dataFrame.sample(iSample);
23 
24  float amplitude = 0.;
25  int gainId = sample.gainId();
26 
27  double pedestal = 0.;
28  double gainratio = 1.;
29 
30  if (gainId == 0 || gainId == 3) {
31  pedestal = aped->mean_x1;
32  gainratio = aGain->gain6Over1() * aGain->gain12Over6();
33  } else if (gainId == 1) {
34  pedestal = aped->mean_x12;
35  gainratio = 1.;
36  } else if (gainId == 2) {
37  pedestal = aped->mean_x6;
38  gainratio = aGain->gain12Over6();
39  }
40 
41  amplitude = (static_cast<float>(sample.adc()) - pedestal) * gainratio;
42 
43  if (gainId == 0) {
44  //saturation
45  amplitude = (4095. - pedestal) * gainratio;
46  }
47 
48  pedSubSamples[iSample] = amplitude;
49 
50  if (amplitude > maxamplitude) {
51  maxamplitude = amplitude;
52  }
53  pulsenorm += fullpulse(iSample);
54  }
55 
56  int ipulse = -1;
57  for (auto const& amplit : amplitudes) {
58  ipulse++;
59  int bxp3 = ipulse - 2;
60  int firstsamplet = std::max(0, bxp3);
61  int offset = 7 - bxp3;
62 
63  for (unsigned int isample = firstsamplet; isample < nsample; ++isample) {
64  auto const pulse = fullpulse(isample + offset);
65  pedSubSamples[isample] = std::max(0., pedSubSamples[isample] - amplit * pulse / pulsenorm);
66  }
67  }
68 
69  // Start of time computation
70  float tStart = startTime_ + GLOBAL_TIME_SHIFT;
71  float tStop = stopTime_ + GLOBAL_TIME_SHIFT;
72  float tM = (tStart + tStop) / 2;
73 
74  float distStart, distStop;
75  int counter = 0;
76 
77  do {
78  ++counter;
79  distStart = computeCC(pedSubSamples, fullpulse, tStart);
80  distStop = computeCC(pedSubSamples, fullpulse, tStop);
81 
82  if (distStart > distStop) {
83  tStop = tM;
84  } else {
85  tStart = tM;
86  }
87  tM = (tStart + tStop) / 2;
88 
89  } while (tStop - tStart > targetTimePrecision_ && counter < MAX_NUM_OF_ITERATIONS);
90 
91  tM -= GLOBAL_TIME_SHIFT;
92  errOnTime = targetTimePrecision_;
93 
94  if (counter < MIN_NUM_OF_ITERATIONS || counter > MAX_NUM_OF_ITERATIONS - 1) {
96  //Negative error means that there was a problem with the CC
98  }
99 
100  return -tM / ecalPh1::Samp_Period;
101 }

References CustomPhysics_cfi::amplitude, computeCC(), counter, EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), ecalLiteDTU::gainId(), GLOBAL_TIME_SHIFT, SiStripPI::max, MAX_NUM_OF_ITERATIONS, EcalDataFrame::MAXSAMPLES, hltrates_dqm_sourceclient-live_cfg::offset, EcalCondDBWriter_cfi::pedestal, pulse(), ecalPh1::Samp_Period, simplePhotonAnalyzer_cfi::sample, EcalDataFrame::sample(), startTime_, stopTime_, targetTimePrecision_, and TIME_WHEN_NOT_CONVERGING.

◆ interpolatePulse()

FullSampleVector EcalUncalibRecHitTimingCCAlgo::interpolatePulse ( const FullSampleVector fullpulse,
const float  t = 0 
) const
private

Definition at line 103 of file EcalUncalibRecHitTimingCCAlgo.cc.

104  {
105  // t is in ns
107  if (time < 0)
108  shift -= 1;
109  float tt = time / ecalPh1::Samp_Period - shift;
110 
111  FullSampleVector interpPulse;
112  // 2nd poly with avg
113  unsigned int numberOfSamples = fullpulse.size();
114  auto facM1orP2 = 0.25 * tt * (tt - 1);
115  auto fac = (0.25 * (tt - 2) - 0.5 * (tt + 1)) * (tt - 1);
116  auto facP1 = (0.25 * (tt + 1) - 0.5 * (tt - 2)) * tt;
117  for (unsigned int i = 1; i < numberOfSamples - 2; ++i) {
118  float a =
119  facM1orP2 * fullpulse[i - 1] + fac * fullpulse[i] + facP1 * fullpulse[i + 1] + facM1orP2 * fullpulse[i + 2];
120  if (a > 0)
121  interpPulse[i] = a;
122  else
123  interpPulse[i] = 0;
124  }
125  interpPulse[0] = facM1orP2 * fullpulse[0] + facP1 * fullpulse[1] + facM1orP2 * fullpulse[2];
126  interpPulse[numberOfSamples - 2] = facM1orP2 * fullpulse[numberOfSamples - 3] + fac * fullpulse[numberOfSamples - 2] +
127  facP1 * fullpulse[numberOfSamples - 1];
128  interpPulse[numberOfSamples - 1] = 2 * facM1orP2 * fullpulse[numberOfSamples - 2] -
129  4 * facM1orP2 * fullpulse[numberOfSamples - 1] +
130  facP1 * fullpulse[numberOfSamples - 1];
131 
132  FullSampleVector interpPulseShifted;
133  for (int i = 0; i < interpPulseShifted.size(); ++i) {
134  if (i + shift >= 0 && i + shift < interpPulse.size())
135  interpPulseShifted[i] = interpPulse[i + shift];
136  else
137  interpPulseShifted[i] = 0;
138  }
139  return interpPulseShifted;
140 }

References a, mps_fire::i, numberOfSamples, ecalPh1::Samp_Period, edm::shift, protons_cff::time, and groupFilesInBlocks::tt.

Referenced by computeCC().

Member Data Documentation

◆ GLOBAL_TIME_SHIFT

constexpr float EcalUncalibRecHitTimingCCAlgo::GLOBAL_TIME_SHIFT = 100
staticconstexprprivate

Definition at line 37 of file EcalUncalibRecHitTimingCCAlgo.h.

Referenced by computeTimeCC().

◆ MAX_NUM_OF_ITERATIONS

constexpr int EcalUncalibRecHitTimingCCAlgo::MAX_NUM_OF_ITERATIONS = 30
staticconstexprprivate

Definition at line 35 of file EcalUncalibRecHitTimingCCAlgo.h.

Referenced by computeTimeCC().

◆ MIN_NUM_OF_ITERATIONS

constexpr int EcalUncalibRecHitTimingCCAlgo::MIN_NUM_OF_ITERATIONS = 2
staticconstexprprivate

Definition at line 36 of file EcalUncalibRecHitTimingCCAlgo.h.

◆ startTime_

const float EcalUncalibRecHitTimingCCAlgo::startTime_
private

Definition at line 30 of file EcalUncalibRecHitTimingCCAlgo.h.

Referenced by computeTimeCC().

◆ stopTime_

const float EcalUncalibRecHitTimingCCAlgo::stopTime_
private

Definition at line 31 of file EcalUncalibRecHitTimingCCAlgo.h.

Referenced by computeTimeCC().

◆ targetTimePrecision_

const float EcalUncalibRecHitTimingCCAlgo::targetTimePrecision_
private

Definition at line 32 of file EcalUncalibRecHitTimingCCAlgo.h.

Referenced by computeTimeCC().

◆ TIME_WHEN_NOT_CONVERGING

constexpr int EcalUncalibRecHitTimingCCAlgo::TIME_WHEN_NOT_CONVERGING = 100
staticconstexprprivate

Definition at line 34 of file EcalUncalibRecHitTimingCCAlgo.h.

Referenced by computeTimeCC().

EcalDataFrame::MAXSAMPLES
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
EcalDataFrame::sample
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
counter
Definition: counter.py:1
ecalLiteDTU::gainId
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
Definition: EcalLiteDTUSample.h:14
mps_fire.i
i
Definition: mps_fire.py:428
CustomPhysics_cfi.amplitude
amplitude
Definition: CustomPhysics_cfi.py:12
ecalPh1::Samp_Period
static constexpr double Samp_Period
Definition: EcalConstants.h:25
EcalUncalibRecHitTimingCCAlgo::stopTime_
const float stopTime_
Definition: EcalUncalibRecHitTimingCCAlgo.h:31
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
pulse
double pulse(double x, double y, double z, double t)
Definition: SiStripPulseShape.cc:49
protons_cff.time
time
Definition: protons_cff.py:39
EcalUncalibRecHitTimingCCAlgo::TIME_WHEN_NOT_CONVERGING
static constexpr int TIME_WHEN_NOT_CONVERGING
Definition: EcalUncalibRecHitTimingCCAlgo.h:34
EcalUncalibRecHitTimingCCAlgo::targetTimePrecision_
const float targetTimePrecision_
Definition: EcalUncalibRecHitTimingCCAlgo.h:32
EgammaValidation_cff.samples
samples
Definition: EgammaValidation_cff.py:19
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
EcalMGPAGainRatio::gain12Over6
float gain12Over6() const
Definition: EcalMGPAGainRatio.h:19
EcalUncalibRecHitTimingCCAlgo::computeCC
float computeCC(const std::vector< float > &samples, const FullSampleVector &sigmalTemplate, const float t) const
Definition: EcalUncalibRecHitTimingCCAlgo.cc:142
a
double a
Definition: hdecay.h:119
EcalUncalibRecHitTimingCCAlgo::MAX_NUM_OF_ITERATIONS
static constexpr int MAX_NUM_OF_ITERATIONS
Definition: EcalUncalibRecHitTimingCCAlgo.h:35
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
createfilelist.int
int
Definition: createfilelist.py:10
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:18
EcalCondDBWriter_cfi.pedestal
pedestal
Definition: EcalCondDBWriter_cfi.py:49
cc
EcalMGPASample
Definition: EcalMGPASample.h:22
FullSampleVector
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
Definition: EigenMatrixTypes.h:13
EcalUncalibRecHitTimingCCAlgo::startTime_
const float startTime_
Definition: EcalUncalibRecHitTimingCCAlgo.h:30
HLTTauDQMOffline_cfi.denominator
denominator
Definition: HLTTauDQMOffline_cfi.py:180
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
EcalUncalibRecHitTimingCCAlgo::interpolatePulse
FullSampleVector interpolatePulse(const FullSampleVector &fullpulse, const float t=0) const
Definition: EcalUncalibRecHitTimingCCAlgo.cc:103
EcalMGPAGainRatio::gain6Over1
float gain6Over1() const
Definition: EcalMGPAGainRatio.h:20
EcalUncalibRecHitTimingCCAlgo::GLOBAL_TIME_SHIFT
static constexpr float GLOBAL_TIME_SHIFT
Definition: EcalUncalibRecHitTimingCCAlgo.h:37
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
numberOfSamples
Definition: TotemSampicFrame.h:53