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 (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_
 

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_DEFAULT_OFFSET = 30
 
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES = 64
 
static constexpr float SAMPIC_SAMPLING_PERIOD_NS = 1. / 7.695
 

Detailed Description

Definition at line 22 of file TotemTimingConversions.h.

Constructor & Destructor Documentation

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

Definition at line 16 of file TotemTimingConversions.cc.

16  :
17  calibration_(calibration), mergeTimePeaks_(mergeTimePeaks),
19 {}
const std::string & formula() const
reco::FormulaEvaluator calibrationFunction_
PPSTimingCalibration calibration_

Member Function Documentation

float TotemTimingConversions::timeOfFirstSample ( const TotemTimingDigi digi) const

Definition at line 24 of file TotemTimingConversions.cc.

References ACCEPTED_TIME_RADIUS, calibration_, CELL0_MASK, TotemTimingDigi::getCellInfo(), TotemTimingDigi::getEventInfo(), TotemTimingDigi::getFPGATimestamp(), TotemTimingDigi::getHardwareBoardId(), TotemTimingDigi::getHardwareChannelId(), TotemTimingDigi::getHardwareSampicId(), TotemTimingEventInfo::getL1ALatency(), TotemTimingEventInfo::getL1ATimestamp(), TotemTimingEventInfo::getOffsetOfSamples(), TotemTimingDigi::getTimestampA(), TotemTimingDigi::getTimestampB(), mergeTimePeaks_, SAMPIC_DEFAULT_OFFSET, SAMPIC_MAX_NUMBER_OF_SAMPLES, SAMPIC_SAMPLING_PERIOD_NS, protons_cff::t, PPSTimingCalibration::timeOffset(), and cond::timestamp.

Referenced by timeSamples(), and triggerTime().

25 {
26  unsigned int offsetOfSamples = digi.getEventInfo().getOffsetOfSamples();
27  if (offsetOfSamples == 0)
28  offsetOfSamples = SAMPIC_DEFAULT_OFFSET; // FW 0 is not sending this, FW > 0 yes
29 
30  unsigned int timestamp = (digi.getCellInfo() <= SAMPIC_MAX_NUMBER_OF_SAMPLES/2)
31  ? digi.getTimestampA()
32  : digi.getTimestampB();
33 
34  int cell0TimeClock = timestamp +
36  - digi.getEventInfo().getL1ATimestamp()
37  + digi.getEventInfo().getL1ALatency();
38 
39  // time of first cell
40  float cell0TimeInstant = SAMPIC_MAX_NUMBER_OF_SAMPLES * SAMPIC_SAMPLING_PERIOD_NS * cell0TimeClock;
41 
42  // time of triggered cell
43  float firstCellTimeInstant = (digi.getCellInfo() < offsetOfSamples)
44  ? cell0TimeInstant + digi.getCellInfo() * SAMPIC_SAMPLING_PERIOD_NS
46 
47  int db = digi.getHardwareBoardId();
48  int sampic = digi.getHardwareSampicId();
49  int channel = digi.getHardwareChannelId();
50  float t = firstCellTimeInstant + calibration_.timeOffset(db, sampic, channel);
51  //NOTE: If no time offset is set, timeOffset returns 0
52 
53  if (mergeTimePeaks_) {
54  if (t < -ACCEPTED_TIME_RADIUS)
56  if (t > ACCEPTED_TIME_RADIUS)
58  }
59  return t;
60 }
TotemTimingEventInfo getEventInfo() const
static constexpr unsigned long CELL0_MASK
double timeOffset(int key1, int key2, int key3, int key4=-1) const
unsigned int getTimestampA() const
static constexpr float SAMPIC_SAMPLING_PERIOD_NS
unsigned int getFPGATimestamp() const
static constexpr int SAMPIC_DEFAULT_OFFSET
unsigned int getL1ALatency() const
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
unsigned int getTimestampB() const
unsigned int getCellInfo() const
unsigned int getL1ATimestamp() const
unsigned int getHardwareChannelId() const
PPSTimingCalibration calibration_
unsigned int getHardwareBoardId() const
unsigned int getHardwareSampicId() const
unsigned int getOffsetOfSamples() const
static constexpr int ACCEPTED_TIME_RADIUS
float TotemTimingConversions::timePrecision ( const TotemTimingDigi digi) const

Definition at line 77 of file TotemTimingConversions.cc.

References calibration_, TotemTimingDigi::getHardwareBoardId(), TotemTimingDigi::getHardwareChannelId(), TotemTimingDigi::getHardwareSampicId(), and PPSTimingCalibration::timePrecision().

78 {
79  int db = digi.getHardwareBoardId();
80  int sampic = digi.getHardwareSampicId();
81  int channel = digi.getHardwareChannelId();
82  return calibration_.timePrecision(db, sampic, channel);
83 }
unsigned int getHardwareChannelId() const
PPSTimingCalibration calibration_
unsigned int getHardwareBoardId() const
unsigned int getHardwareSampicId() 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 88 of file TotemTimingConversions.cc.

References TotemTimingDigi::getNumberOfSamples(), mps_fire::i, SAMPIC_SAMPLING_PERIOD_NS, protons_cff::time, and timeOfFirstSample().

89 {
90  std::vector<float> time(digi.getNumberOfSamples());
91  for (unsigned int i = 0; i < time.size(); ++i)
93  return time;
94 }
static constexpr float SAMPIC_SAMPLING_PERIOD_NS
unsigned int getNumberOfSamples() const
float timeOfFirstSample(const TotemTimingDigi &digi) const
float TotemTimingConversions::triggerTime ( const TotemTimingDigi digi) const

Definition at line 65 of file TotemTimingConversions.cc.

References TotemTimingDigi::getEventInfo(), TotemTimingEventInfo::getOffsetOfSamples(), SAMPIC_MAX_NUMBER_OF_SAMPLES, SAMPIC_SAMPLING_PERIOD_NS, and timeOfFirstSample().

66 {
67  unsigned int offsetOfSamples = digi.getEventInfo().getOffsetOfSamples();
68  if (offsetOfSamples == 0)
69  offsetOfSamples = 30; // FW 0 is not sending this, FW > 0 yes
70 
72 }
TotemTimingEventInfo getEventInfo() const
static constexpr float SAMPIC_SAMPLING_PERIOD_NS
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
float timeOfFirstSample(const TotemTimingDigi &digi) const
unsigned int getOffsetOfSamples() const
std::vector< float > TotemTimingConversions::voltSamples ( const TotemTimingDigi digi) const

Definition at line 100 of file TotemTimingConversions.cc.

References calibration_, calibrationFunction_, data, reco::FormulaEvaluator::evaluate(), TotemTimingDigi::getCellInfo(), TotemTimingDigi::getHardwareBoardId(), TotemTimingDigi::getHardwareChannelId(), TotemTimingDigi::getHardwareSampicId(), TotemTimingDigi::getSamples(), reco::FormulaEvaluator::numberOfParameters(), reco::FormulaEvaluator::numberOfVariables(), PPSTimingCalibration::parameters(), SAMPIC_ADC_V, SAMPIC_MAX_NUMBER_OF_SAMPLES, and simplePhotonAnalyzer_cfi::sample.

101 {
102  std::vector<float> data;
104  for (const auto& sample : digi.getSamples())
105  data.emplace_back(SAMPIC_ADC_V * sample);
106  else {
107  unsigned int db = digi.getHardwareBoardId();
108  unsigned int sampic = digi.getHardwareSampicId();
109  unsigned int channel = digi.getHardwareChannelId();
110  unsigned int cell = digi.getCellInfo();
111  for (const auto& sample : digi.getSamples()) {
112  // ring buffer on Sampic, so accounting for samples register boundary
113  const unsigned short sample_cell = (cell++) % SAMPIC_MAX_NUMBER_OF_SAMPLES;
114  auto parameters = calibration_.parameters(db, sampic, channel, sample_cell);
116  throw cms::Exception("TotemTimingConversions:voltSamples")
117  << "Invalid calibrations retrieved for Sampic digi"
118  << " (" << db << ", " << sampic << ", " << channel << ", " << sample_cell << ")!";
119  data.emplace_back(calibrationFunction_.evaluate(std::vector<double>{(double)sample}, parameters));
120  }
121  }
122  return data;
123 }
unsigned int numberOfParameters() const
reco::FormulaEvaluator calibrationFunction_
static constexpr float SAMPIC_ADC_V
std::vector< double > parameters(int key1, int key2, int key3, int key4) const
std::vector< uint8_t > getSamples() const
unsigned int numberOfVariables() const
double evaluate(V const &iVariables, P const &iParameters) const
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
unsigned int getCellInfo() const
unsigned int getHardwareChannelId() const
PPSTimingCalibration calibration_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
unsigned int getHardwareBoardId() const
unsigned int getHardwareSampicId() const

Member Data Documentation

constexpr int TotemTimingConversions::ACCEPTED_TIME_RADIUS = 4
staticprivate

Definition at line 38 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

PPSTimingCalibration TotemTimingConversions::calibration_
private

Definition at line 41 of file TotemTimingConversions.h.

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

reco::FormulaEvaluator TotemTimingConversions::calibrationFunction_
private

Definition at line 43 of file TotemTimingConversions.h.

Referenced by voltSamples().

constexpr unsigned long TotemTimingConversions::CELL0_MASK = 0xfffffff000
staticprivate

Definition at line 39 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

bool TotemTimingConversions::mergeTimePeaks_
private

Definition at line 42 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

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

Definition at line 35 of file TotemTimingConversions.h.

Referenced by voltSamples().

constexpr int TotemTimingConversions::SAMPIC_DEFAULT_OFFSET = 30
staticprivate

Definition at line 37 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

constexpr int TotemTimingConversions::SAMPIC_MAX_NUMBER_OF_SAMPLES = 64
staticprivate

Definition at line 36 of file TotemTimingConversions.h.

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

constexpr float TotemTimingConversions::SAMPIC_SAMPLING_PERIOD_NS = 1. / 7.695
staticprivate

Definition at line 34 of file TotemTimingConversions.h.

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