CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ( double  sampicSamplingPeriodNs,
bool  mergeTimePeaks,
const PPSTimingCalibration calibration 
)

Definition at line 17 of file TotemTimingConversions.cc.

20  : calibration_(calibration),
21  sampicSamplingPeriodNs_(sampicSamplingPeriodNs),
22  mergeTimePeaks_(mergeTimePeaks),
const std::string & formula() const
reco::FormulaEvaluator calibrationFunction_
PPSTimingCalibration calibration_

Member Function Documentation

float TotemTimingConversions::timeOfFirstSample ( const TotemTimingDigi digi) const

Definition at line 27 of file TotemTimingConversions.cc.

References ACCEPTED_TIME_RADIUS, calibration_, CELL0_MASK, TotemTimingDigi::cellInfo(), EcalCondDB::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 }
TotemTimingEventInfo eventInfo() const
unsigned int timestampA() const
tuple db
Definition: EcalCondDB.py:153
static constexpr unsigned long CELL0_MASK
unsigned int offsetOfSamples() const
double timeOffset(int key1, int key2, int key3, int key4=-1) const
unsigned int l1ALatency() const
unsigned int hardwareSampicId() const
unsigned int l1ATimestamp() const
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
unsigned int cellInfo() const
unsigned int hardwareBoardId() const
unsigned int fpgaTimestamp() const
PPSTimingCalibration calibration_
unsigned int hardwareChannelId() const
static constexpr int ACCEPTED_TIME_RADIUS
unsigned int timestampB() const
float TotemTimingConversions::timePrecision ( const TotemTimingDigi digi) const

Definition at line 70 of file TotemTimingConversions.cc.

References calibration_, EcalCondDB::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 }
tuple db
Definition: EcalCondDB.py:153
unsigned int hardwareSampicId() const
unsigned int hardwareBoardId() const
PPSTimingCalibration calibration_
unsigned int hardwareChannelId() const
double timePrecision(int key1, int key2, int key3, int key4=-1) const
std::vector< float > TotemTimingConversions::timeSamples ( const TotemTimingDigi digi) const

Definition at line 79 of file TotemTimingConversions.cc.

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

79  {
80  std::vector<float> time(digi.numberOfSamples());
81  for (unsigned int i = 0; i < time.size(); ++i)
82  time.at(i) = timeOfFirstSample(digi) + i * sampicSamplingPeriodNs_;
83  return time;
84 }
unsigned int numberOfSamples() const
float timeOfFirstSample(const TotemTimingDigi &digi) const
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 }
TotemTimingEventInfo eventInfo() const
unsigned int offsetOfSamples() const
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
float timeOfFirstSample(const TotemTimingDigi &digi) const
std::vector< float > TotemTimingConversions::voltSamples ( const TotemTimingDigi digi) const

Definition at line 89 of file TotemTimingConversions.cc.

References calibration_, calibrationFunction_, TotemTimingDigi::cellInfo(), data, EcalCondDB::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, compare_using_db::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 }
unsigned int numberOfParameters() const
tuple db
Definition: EcalCondDB.py:153
reco::FormulaEvaluator calibrationFunction_
static constexpr float SAMPIC_ADC_V
std::vector< double > parameters(int key1, int key2, int key3, int key4) const
unsigned int hardwareSampicId() const
unsigned int numberOfVariables() const
std::vector< uint8_t > samples() const
double evaluate(V const &iVariables, P const &iParameters) const
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
unsigned int cellInfo() const
unsigned int hardwareBoardId() const
PPSTimingCalibration calibration_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
unsigned int hardwareChannelId() const

Member Data Documentation

constexpr int TotemTimingConversions::ACCEPTED_TIME_RADIUS = 4
staticprivate

Definition at line 36 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

PPSTimingCalibration TotemTimingConversions::calibration_
private

Definition at line 39 of file TotemTimingConversions.h.

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

reco::FormulaEvaluator TotemTimingConversions::calibrationFunction_
private

Definition at line 42 of file TotemTimingConversions.h.

Referenced by voltSamples().

constexpr unsigned long TotemTimingConversions::CELL0_MASK = 0xfffffff000
staticprivate

Definition at line 37 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

bool TotemTimingConversions::mergeTimePeaks_
private

Definition at line 41 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

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

Definition at line 34 of file TotemTimingConversions.h.

Referenced by voltSamples().

constexpr int TotemTimingConversions::SAMPIC_MAX_NUMBER_OF_SAMPLES = 64
staticprivate

Definition at line 35 of file TotemTimingConversions.h.

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

double TotemTimingConversions::sampicSamplingPeriodNs_
private

Definition at line 40 of file TotemTimingConversions.h.

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