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 21 of file TotemTimingConversions.h.

Constructor & Destructor Documentation

◆ TotemTimingConversions()

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

Member Function Documentation

◆ timeOfFirstSample()

float TotemTimingConversions::timeOfFirstSample ( const TotemTimingDigi digi) const

Definition at line 20 of file TotemTimingConversions.cc.

21  {
22  unsigned int offsetOfSamples = digi.eventInfo().offsetOfSamples();
23  if (offsetOfSamples == 0)
24  offsetOfSamples = SAMPIC_DEFAULT_OFFSET; // FW 0 is not sending this, FW > 0 yes
25 
26  unsigned int timestamp =
27  (digi.cellInfo() <= SAMPIC_MAX_NUMBER_OF_SAMPLES / 2) ? digi.timestampA() : digi.timestampB();
28 
29  int cell0TimeClock = timestamp + ((digi.fpgaTimestamp() - timestamp) & CELL0_MASK) - digi.eventInfo().l1ATimestamp() +
30  digi.eventInfo().l1ALatency();
31 
32  // time of first cell
33  float cell0TimeInstant = SAMPIC_MAX_NUMBER_OF_SAMPLES * SAMPIC_SAMPLING_PERIOD_NS * cell0TimeClock;
34 
35  // time of triggered cell
36  float firstCellTimeInstant =
37  (digi.cellInfo() < offsetOfSamples)
38  ? cell0TimeInstant + digi.cellInfo() * SAMPIC_SAMPLING_PERIOD_NS
39  : cell0TimeInstant - (SAMPIC_MAX_NUMBER_OF_SAMPLES - digi.cellInfo()) * SAMPIC_SAMPLING_PERIOD_NS;
40 
41  int db = digi.hardwareBoardId();
42  int sampic = digi.hardwareSampicId();
43  int channel = digi.hardwareChannelId();
44  float t = firstCellTimeInstant + calibration_.timeOffset(db, sampic, channel);
45  //NOTE: If no time offset is set, timeOffset returns 0
46 
47  if (mergeTimePeaks_) {
48  if (t < -ACCEPTED_TIME_RADIUS)
50  if (t > ACCEPTED_TIME_RADIUS)
52  }
53  return t;

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_DEFAULT_OFFSET, SAMPIC_MAX_NUMBER_OF_SAMPLES, SAMPIC_SAMPLING_PERIOD_NS, submitPVValidationJobs::t, PPSTimingCalibration::timeOffset(), cond::timestamp, TotemTimingDigi::timestampA(), and TotemTimingDigi::timestampB().

Referenced by timeSamples(), and triggerTime().

◆ timePrecision()

float TotemTimingConversions::timePrecision ( const TotemTimingDigi digi) const

◆ timeSamples()

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

Definition at line 76 of file TotemTimingConversions.cc.

77  {
78  std::vector<float> time(digi.numberOfSamples());
79  for (unsigned int i = 0; i < time.size(); ++i)
81  return time;

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

◆ triggerTime()

float TotemTimingConversions::triggerTime ( const TotemTimingDigi digi) const

Definition at line 57 of file TotemTimingConversions.cc.

58  {
59  unsigned int offsetOfSamples = digi.eventInfo().offsetOfSamples();
60  if (offsetOfSamples == 0)
61  offsetOfSamples = 30; // FW 0 is not sending this, FW > 0 yes
62 

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

◆ voltSamples()

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

Definition at line 86 of file TotemTimingConversions.cc.

87  {
88  std::vector<float> data;
90  for (const auto& sample : digi.samples())
91  data.emplace_back(SAMPIC_ADC_V * sample);
92  else {
93  unsigned int db = digi.hardwareBoardId();
94  unsigned int sampic = digi.hardwareSampicId();
95  unsigned int channel = digi.hardwareChannelId();
96  unsigned int cell = digi.cellInfo();
97  for (const auto& sample : digi.samples()) {
98  // ring buffer on Sampic, so accounting for samples register boundary
99  const unsigned short sample_cell = (cell++) % SAMPIC_MAX_NUMBER_OF_SAMPLES;
100  auto parameters = calibration_.parameters(db, sampic, channel, sample_cell);
102  throw cms::Exception("TotemTimingConversions:voltSamples")
103  << "Invalid calibrations retrieved for Sampic digi"
104  << " (" << db << ", " << sampic << ", " << channel << ", " << sample_cell << ")!";
105  data.emplace_back(calibrationFunction_.evaluate(std::vector<double>{(double)sample}, parameters));
106  }
107  }
108  return data;

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, simplePhotonAnalyzer_cfi::sample, and TotemTimingDigi::samples().

Member Data Documentation

◆ ACCEPTED_TIME_RADIUS

constexpr int TotemTimingConversions::ACCEPTED_TIME_RADIUS = 4
staticconstexprprivate

Definition at line 43 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

◆ calibration_

PPSTimingCalibration TotemTimingConversions::calibration_
private

Definition at line 46 of file TotemTimingConversions.h.

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

◆ calibrationFunction_

reco::FormulaEvaluator TotemTimingConversions::calibrationFunction_
private

Definition at line 48 of file TotemTimingConversions.h.

Referenced by voltSamples().

◆ CELL0_MASK

constexpr unsigned long TotemTimingConversions::CELL0_MASK = 0xfffffff000
staticconstexprprivate

Definition at line 44 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

◆ mergeTimePeaks_

bool TotemTimingConversions::mergeTimePeaks_
private

Definition at line 47 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

◆ SAMPIC_ADC_V

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

Definition at line 40 of file TotemTimingConversions.h.

Referenced by voltSamples().

◆ SAMPIC_DEFAULT_OFFSET

constexpr int TotemTimingConversions::SAMPIC_DEFAULT_OFFSET = 30
staticconstexprprivate

Definition at line 42 of file TotemTimingConversions.h.

Referenced by timeOfFirstSample().

◆ SAMPIC_MAX_NUMBER_OF_SAMPLES

constexpr int TotemTimingConversions::SAMPIC_MAX_NUMBER_OF_SAMPLES = 64
staticconstexprprivate

Definition at line 41 of file TotemTimingConversions.h.

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

◆ SAMPIC_SAMPLING_PERIOD_NS

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

Definition at line 39 of file TotemTimingConversions.h.

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

TotemTimingEventInfo::l1ATimestamp
unsigned int l1ATimestamp() const
Definition: TotemTimingEventInfo.h:47
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
mps_fire.i
i
Definition: mps_fire.py:428
TotemTimingConversions::SAMPIC_SAMPLING_PERIOD_NS
static constexpr float SAMPIC_SAMPLING_PERIOD_NS
Definition: TotemTimingConversions.h:39
TotemTimingDigi::timestampA
unsigned int timestampA() const
Definition: TotemTimingDigi.h:48
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
TotemTimingDigi::hardwareBoardId
unsigned int hardwareBoardId() const
Definition: TotemTimingDigi.h:40
TotemTimingConversions::SAMPIC_MAX_NUMBER_OF_SAMPLES
static constexpr int SAMPIC_MAX_NUMBER_OF_SAMPLES
Definition: TotemTimingConversions.h:41
TotemTimingDigi::fpgaTimestamp
unsigned int fpgaTimestamp() const
Definition: TotemTimingDigi.h:46
protons_cff.time
time
Definition: protons_cff.py:35
TotemTimingDigi::hardwareSampicId
unsigned int hardwareSampicId() const
Definition: TotemTimingDigi.h:42
TotemTimingConversions::mergeTimePeaks_
bool mergeTimePeaks_
Definition: TotemTimingConversions.h:47
PPSTimingCalibration::formula
const std::string & formula() const
Definition: PPSTimingCalibration.h:46
TotemTimingDigi::numberOfSamples
unsigned int numberOfSamples() const
Definition: TotemTimingDigi.h:60
dqmiodatasetharvest.db
db
Definition: dqmiodatasetharvest.py:119
cond::timestamp
Definition: Time.h:19
PPSTimingCalibration::timeOffset
double timeOffset(int key1, int key2, int key3, int key4=-1) const
Definition: PPSTimingCalibration.cc:40
TotemTimingConversions::calibration_
PPSTimingCalibration calibration_
Definition: TotemTimingConversions.h:46
PPSTimingCalibration::timePrecision
double timePrecision(int key1, int key2, int key3, int key4=-1) const
Definition: PPSTimingCalibration.cc:48
Phase1L1TJetCalibrator_9x9Jets_cfi.calibration
calibration
Definition: Phase1L1TJetCalibrator_9x9Jets_cfi.py:2
reco::FormulaEvaluator::numberOfVariables
unsigned int numberOfVariables() const
Definition: FormulaEvaluator.h:84
TotemTimingDigi::cellInfo
unsigned int cellInfo() const
Definition: TotemTimingDigi.h:52
PPSTimingCalibration::parameters
std::vector< double > parameters(int key1, int key2, int key3, int key4) const
Definition: PPSTimingCalibration.cc:32
reco::FormulaEvaluator::numberOfParameters
unsigned int numberOfParameters() const
Definition: FormulaEvaluator.h:83
TotemTimingConversions::SAMPIC_ADC_V
static constexpr float SAMPIC_ADC_V
Definition: TotemTimingConversions.h:40
TotemTimingConversions::ACCEPTED_TIME_RADIUS
static constexpr int ACCEPTED_TIME_RADIUS
Definition: TotemTimingConversions.h:43
TotemTimingConversions::SAMPIC_DEFAULT_OFFSET
static constexpr int SAMPIC_DEFAULT_OFFSET
Definition: TotemTimingConversions.h:42
TotemTimingEventInfo::l1ALatency
unsigned int l1ALatency() const
Definition: TotemTimingEventInfo.h:57
reco::FormulaEvaluator::evaluate
double evaluate(V const &iVariables, P const &iParameters) const
Definition: FormulaEvaluator.h:73
TotemTimingDigi::hardwareChannelId
unsigned int hardwareChannelId() const
Definition: TotemTimingDigi.h:44
TotemTimingConversions::timeOfFirstSample
float timeOfFirstSample(const TotemTimingDigi &digi) const
Definition: TotemTimingConversions.cc:20
TotemTimingEventInfo::offsetOfSamples
unsigned int offsetOfSamples() const
Definition: TotemTimingEventInfo.h:61
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cms::Exception
Definition: Exception.h:70
TotemTimingConversions::CELL0_MASK
static constexpr unsigned long CELL0_MASK
Definition: TotemTimingConversions.h:44
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
TotemTimingDigi::timestampB
unsigned int timestampB() const
Definition: TotemTimingDigi.h:50
TotemTimingConversions::calibrationFunction_
reco::FormulaEvaluator calibrationFunction_
Definition: TotemTimingConversions.h:48
TotemTimingDigi::eventInfo
TotemTimingEventInfo eventInfo() const
Definition: TotemTimingDigi.h:69
TotemTimingDigi::samples
std::vector< uint8_t > samples() const
Definition: TotemTimingDigi.h:54