CMS 3D CMS Logo

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

#include <TotemTimingConversions.h>

Public Member Functions

float timeOfFirstSample (const TotemTimingDigi &digi) const
 
float timePrecision (const TotemTimingDigi &digi) const
 
std::vector< float > timeSamples (const TotemTimingDigi &digi) const
 
 TotemTimingConversions (double sampicSamplingPeriodNs, bool mergeTimePeaks, const PPSTimingCalibration &calibration)
 
float triggerTime (const TotemTimingDigi &digi) const
 
std::vector< float > voltSamples (const TotemTimingDigi &digi) const
 

Private Attributes

PPSTimingCalibration calibration_
 
reco::FormulaEvaluator calibrationFunction_
 
bool mergeTimePeaks_
 
double sampicSamplingPeriodNs_
 

Static Private Attributes

static constexpr int ACCEPTED_TIME_RADIUS = 4
 
static constexpr unsigned long CELL0_MASK = 0xfffffff000
 
static constexpr float SAMPIC_ADC_V = 1. / 256
 
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES = 64
 

Detailed Description

Definition at line 23 of file TotemTimingConversions.h.

Constructor & Destructor Documentation

◆ TotemTimingConversions()

TotemTimingConversions::TotemTimingConversions ( double  sampicSamplingPeriodNs,
bool  mergeTimePeaks,
const PPSTimingCalibration calibration 
)

Definition at line 17 of file TotemTimingConversions.cc.

Member Function Documentation

◆ timeOfFirstSample()

float TotemTimingConversions::timeOfFirstSample ( const TotemTimingDigi digi) const

Definition at line 27 of file TotemTimingConversions.cc.

References ACCEPTED_TIME_RADIUS, calibration_, CELL0_MASK, TotemTimingDigi::cellInfo(), dqmiodatasetharvest::db, TotemTimingDigi::eventInfo(), TotemTimingDigi::fpgaTimestamp(), TotemTimingDigi::hardwareBoardId(), TotemTimingDigi::hardwareChannelId(), TotemTimingDigi::hardwareSampicId(), TotemTimingEventInfo::l1ALatency(), TotemTimingEventInfo::l1ATimestamp(), mergeTimePeaks_, TotemTimingEventInfo::offsetOfSamples(), SAMPIC_MAX_NUMBER_OF_SAMPLES, sampicSamplingPeriodNs_, submitPVValidationJobs::t, PPSTimingCalibration::timeOffset(), cond::timestamp, TotemTimingDigi::timestampA(), and TotemTimingDigi::timestampB().

Referenced by timeSamples(), and triggerTime().

27  {
28  unsigned int offsetOfSamples = digi.eventInfo().offsetOfSamples();
29 
30  unsigned int timestamp =
31  (digi.cellInfo() <= SAMPIC_MAX_NUMBER_OF_SAMPLES / 2) ? digi.timestampA() : digi.timestampB();
32 
33  int cell0TimeClock = timestamp + ((digi.fpgaTimestamp() - timestamp) & CELL0_MASK) - digi.eventInfo().l1ATimestamp() +
34  digi.eventInfo().l1ALatency();
35 
36  // time of first cell
37  float cell0TimeInstant = SAMPIC_MAX_NUMBER_OF_SAMPLES * sampicSamplingPeriodNs_ * cell0TimeClock;
38 
39  // time of triggered cell
40  float firstCellTimeInstant =
41  (digi.cellInfo() < offsetOfSamples)
42  ? cell0TimeInstant + digi.cellInfo() * sampicSamplingPeriodNs_
43  : cell0TimeInstant - (SAMPIC_MAX_NUMBER_OF_SAMPLES - digi.cellInfo()) * sampicSamplingPeriodNs_;
44 
45  int db = digi.hardwareBoardId();
46  int sampic = digi.hardwareSampicId();
47  int channel = digi.hardwareChannelId();
48  float t = firstCellTimeInstant + calibration_.timeOffset(db, sampic, channel);
49  //NOTE: If no time offset is set, timeOffset returns 0
50 
51  if (mergeTimePeaks_) {
52  if (t < -ACCEPTED_TIME_RADIUS)
54  if (t > ACCEPTED_TIME_RADIUS)
56  }
57 
58  return t;
59 }
unsigned int timestampA() const
unsigned int l1ALatency() const
double timeOffset(int key1, int key2, int key3, int key4=-1) const
unsigned int timestampB() const
static constexpr unsigned long CELL0_MASK
unsigned int fpgaTimestamp() const
unsigned int l1ATimestamp() const
unsigned int offsetOfSamples() const
unsigned int hardwareSampicId() const
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
unsigned int hardwareChannelId() const
TotemTimingEventInfo eventInfo() const
PPSTimingCalibration calibration_
unsigned int hardwareBoardId() const
unsigned int cellInfo() const
static constexpr int ACCEPTED_TIME_RADIUS

◆ timePrecision()

float TotemTimingConversions::timePrecision ( const TotemTimingDigi digi) const

Definition at line 70 of file TotemTimingConversions.cc.

References calibration_, dqmiodatasetharvest::db, TotemTimingDigi::hardwareBoardId(), TotemTimingDigi::hardwareChannelId(), TotemTimingDigi::hardwareSampicId(), and PPSTimingCalibration::timePrecision().

70  {
71  int db = digi.hardwareBoardId();
72  int sampic = digi.hardwareSampicId();
73  int channel = digi.hardwareChannelId();
74  return calibration_.timePrecision(db, sampic, channel);
75 }
unsigned int hardwareSampicId() const
double timePrecision(int key1, int key2, int key3, int key4=-1) const
unsigned int hardwareChannelId() const
PPSTimingCalibration calibration_
unsigned int hardwareBoardId() const

◆ timeSamples()

std::vector< float > TotemTimingConversions::timeSamples ( const TotemTimingDigi digi) const

Definition at line 79 of file TotemTimingConversions.cc.

References mps_fire::i, TotemTimingDigi::numberOfSamples(), sampicSamplingPeriodNs_, hcalRecHitTable_cff::time, and timeOfFirstSample().

79  {
80  std::vector<float> time(digi.numberOfSamples());
81  for (unsigned int i = 0; i < time.size(); ++i)
83  return time;
84 }
unsigned int numberOfSamples() const
float timeOfFirstSample(const TotemTimingDigi &digi) const

◆ triggerTime()

float TotemTimingConversions::triggerTime ( const TotemTimingDigi digi) const

Definition at line 63 of file TotemTimingConversions.cc.

References TotemTimingDigi::eventInfo(), TotemTimingEventInfo::offsetOfSamples(), SAMPIC_MAX_NUMBER_OF_SAMPLES, sampicSamplingPeriodNs_, and timeOfFirstSample().

63  {
64  unsigned int offsetOfSamples = digi.eventInfo().offsetOfSamples();
65  return timeOfFirstSample(digi) + (SAMPIC_MAX_NUMBER_OF_SAMPLES - offsetOfSamples) * sampicSamplingPeriodNs_;
66 }
unsigned int offsetOfSamples() const
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
float timeOfFirstSample(const TotemTimingDigi &digi) const
TotemTimingEventInfo eventInfo() const

◆ voltSamples()

std::vector< float > TotemTimingConversions::voltSamples ( const TotemTimingDigi digi) const

Definition at line 89 of file TotemTimingConversions.cc.

References calibration_, calibrationFunction_, TotemTimingDigi::cellInfo(), data, dqmiodatasetharvest::db, reco::FormulaEvaluator::evaluate(), TotemTimingDigi::hardwareBoardId(), TotemTimingDigi::hardwareChannelId(), TotemTimingDigi::hardwareSampicId(), reco::FormulaEvaluator::numberOfParameters(), reco::FormulaEvaluator::numberOfVariables(), PPSTimingCalibration::parameters(), SAMPIC_ADC_V, SAMPIC_MAX_NUMBER_OF_SAMPLES, ecalGpuTask_cfi::sample, and TotemTimingDigi::samples().

89  {
90  std::vector<float> data;
92  for (const auto& sample : digi.samples())
93  data.emplace_back(SAMPIC_ADC_V * sample);
94  else {
95  unsigned int db = digi.hardwareBoardId();
96  unsigned int sampic = digi.hardwareSampicId();
97  unsigned int channel = digi.hardwareChannelId();
98  unsigned int cell = digi.cellInfo();
99  for (const auto& sample : digi.samples()) {
100  // ring buffer on Sampic, so accounting for samples register boundary
101  const unsigned short sample_cell = (cell++) % SAMPIC_MAX_NUMBER_OF_SAMPLES;
102  auto parameters = calibration_.parameters(db, sampic, channel, sample_cell);
104  throw cms::Exception("TotemTimingConversions:voltSamples")
105  << "Invalid calibrations retrieved for Sampic digi"
106  << " (" << db << ", " << sampic << ", " << channel << ", " << sample_cell << ")!";
107  data.emplace_back(calibrationFunction_.evaluate(std::vector<double>{(double)sample}, parameters));
108  }
109  }
110  return data;
111 }
double evaluate(V const &iVariables, P const &iParameters) const
reco::FormulaEvaluator calibrationFunction_
static constexpr float SAMPIC_ADC_V
unsigned int hardwareSampicId() const
std::vector< uint8_t > samples() const
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
unsigned int numberOfParameters() const
std::vector< double > parameters(int key1, int key2, int key3, int key4) const
unsigned int hardwareChannelId() const
PPSTimingCalibration calibration_
unsigned int hardwareBoardId() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
unsigned int cellInfo() const
unsigned int numberOfVariables() const

Member Data Documentation

◆ ACCEPTED_TIME_RADIUS

constexpr int TotemTimingConversions::ACCEPTED_TIME_RADIUS = 4
staticprivate

Definition at line 36 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

◆ calibration_

PPSTimingCalibration TotemTimingConversions::calibration_
private

Definition at line 39 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample(), timePrecision(), and voltSamples().

◆ calibrationFunction_

reco::FormulaEvaluator TotemTimingConversions::calibrationFunction_
private

Definition at line 42 of file TotemTimingConversions.h.

Referenced by voltSamples().

◆ CELL0_MASK

constexpr unsigned long TotemTimingConversions::CELL0_MASK = 0xfffffff000
staticprivate

Definition at line 37 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

◆ mergeTimePeaks_

bool TotemTimingConversions::mergeTimePeaks_
private

Definition at line 41 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

◆ SAMPIC_ADC_V

constexpr float TotemTimingConversions::SAMPIC_ADC_V = 1. / 256
staticprivate

Definition at line 34 of file TotemTimingConversions.h.

Referenced by voltSamples().

◆ SAMPIC_MAX_NUMBER_OF_SAMPLES

constexpr int TotemTimingConversions::SAMPIC_MAX_NUMBER_OF_SAMPLES = 64
staticprivate

Definition at line 35 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample(), triggerTime(), and voltSamples().

◆ sampicSamplingPeriodNs_

double TotemTimingConversions::sampicSamplingPeriodNs_
private

Definition at line 40 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample(), timeSamples(), and triggerTime().