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

const float getTimeOfFirstSample (const TotemTimingDigi &digi) const
 
std::vector< float > getTimeSamples (const TotemTimingDigi &digi) const
 
const float getTriggerTime (const TotemTimingDigi &digi) const
 
std::vector< float > getVoltSamples (const TotemTimingDigi &digi) const
 
void openCalibrationFile (const std::string &calibrationFile="/dev/null")
 
 TotemTimingConversions ()
 
 TotemTimingConversions (const std::string &calibrationFile)
 

Private Attributes

std::string calibrationFile_
 
bool calibrationFileOk_
 

Static Private Attributes

static const float SAMPIC_ADC_V = 1. / 256
 
static const int SAMPIC_DEFAULT_OFFSET = 30
 
static const int SAMPIC_MAX_NUMBER_OF_SAMPLES = 64
 
static const float SAMPIC_SAMPLING_PERIOD_NS = 1. / 7.8
 

Detailed Description

Definition at line 18 of file TotemTimingConversions.h.

Constructor & Destructor Documentation

TotemTimingConversions::TotemTimingConversions ( )

Definition at line 21 of file TotemTimingConversions.cc.

TotemTimingConversions::TotemTimingConversions ( const std::string &  calibrationFile)

Definition at line 26 of file TotemTimingConversions.cc.

27  : calibrationFileOk_(false), calibrationFile_(calibrationFile) {}

Member Function Documentation

const float TotemTimingConversions::getTimeOfFirstSample ( const TotemTimingDigi digi) const

Definition at line 48 of file TotemTimingConversions.cc.

References TotemTimingDigi::getCellInfo(), TotemTimingDigi::getEventInfo(), TotemTimingDigi::getFPGATimestamp(), TotemTimingEventInfo::getL1ALatency(), TotemTimingEventInfo::getL1ATimestamp(), TotemTimingEventInfo::getOffsetOfSamples(), TotemTimingDigi::getTimestampA(), TotemTimingDigi::getTimestampB(), SAMPIC_DEFAULT_OFFSET, SAMPIC_MAX_NUMBER_OF_SAMPLES, SAMPIC_SAMPLING_PERIOD_NS, and cond::timestamp.

Referenced by getTimeSamples(), and getTriggerTime().

49 {
50  unsigned int offsetOfSamples = digi.getEventInfo().getOffsetOfSamples();
51  if (offsetOfSamples == 0)
52  offsetOfSamples = SAMPIC_DEFAULT_OFFSET; // FW 0 is not sending this, FW > 0 yes
53  int cell0TimeClock;
54  float cell0TimeInstant; // Time of first cell
55  float firstCellTimeInstant; // Time of triggered cell
56 
57  unsigned int timestamp = digi.getCellInfo() <= SAMPIC_MAX_NUMBER_OF_SAMPLES/2 ?
58  digi.getTimestampA()
59  : digi.getTimestampB();
60 
61  cell0TimeClock = timestamp +
62  ((digi.getFPGATimestamp() - timestamp) & 0xFFFFFFF000) -
63  digi.getEventInfo().getL1ATimestamp() +
64  digi.getEventInfo().getL1ALatency();
65 
66  cell0TimeInstant = SAMPIC_MAX_NUMBER_OF_SAMPLES *
67  SAMPIC_SAMPLING_PERIOD_NS * cell0TimeClock;
68 
69  if (digi.getCellInfo() < offsetOfSamples)
70  firstCellTimeInstant =
71  cell0TimeInstant + digi.getCellInfo() * SAMPIC_SAMPLING_PERIOD_NS;
72  else
73  firstCellTimeInstant =
74  cell0TimeInstant -
77 
78  return firstCellTimeInstant;
79 }
TotemTimingEventInfo getEventInfo() const
unsigned int getTimestampA() const
static const int SAMPIC_DEFAULT_OFFSET
static const float SAMPIC_SAMPLING_PERIOD_NS
unsigned int getFPGATimestamp() const
unsigned int getL1ALatency() const
unsigned int getTimestampB() const
unsigned int getCellInfo() const
unsigned int getL1ATimestamp() const
static const int SAMPIC_MAX_NUMBER_OF_SAMPLES
unsigned int getOffsetOfSamples() const
std::vector< float > TotemTimingConversions::getTimeSamples ( const TotemTimingDigi digi) const

Definition at line 98 of file TotemTimingConversions.cc.

References calibrationFileOk_, TotemTimingDigi::getNumberOfSamples(), getTimeOfFirstSample(), mps_fire::i, SAMPIC_SAMPLING_PERIOD_NS, and ntuplemaker::time.

Referenced by TotemTimingRecHitProducerAlgorithm::build().

99 {
100  std::vector<float> time(digi.getNumberOfSamples());
101  // firstCellTimeInstant = 0;
102  if (!calibrationFileOk_)
103  {
104  for (unsigned int i = 0; i < time.size(); ++i)
106  }
107  return time;
108 }
const float getTimeOfFirstSample(const TotemTimingDigi &digi) const
static const float SAMPIC_SAMPLING_PERIOD_NS
unsigned int getNumberOfSamples() const
const float TotemTimingConversions::getTriggerTime ( const TotemTimingDigi digi) const

Definition at line 83 of file TotemTimingConversions.cc.

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

Referenced by TotemTimingRecHitProducerAlgorithm::build().

84 {
85  unsigned int offsetOfSamples = digi.getEventInfo().getOffsetOfSamples();
86  if (offsetOfSamples == 0)
87  offsetOfSamples = 30; // FW 0 is not sending this, FW > 0 yes
88 
89  float triggerCellTimeInstant = getTimeOfFirstSample(digi) +
90  (SAMPIC_MAX_NUMBER_OF_SAMPLES - offsetOfSamples) *
92 
93  return triggerCellTimeInstant;
94 }
TotemTimingEventInfo getEventInfo() const
const float getTimeOfFirstSample(const TotemTimingDigi &digi) const
static const float SAMPIC_SAMPLING_PERIOD_NS
static const int SAMPIC_MAX_NUMBER_OF_SAMPLES
unsigned int getOffsetOfSamples() const
std::vector< float > TotemTimingConversions::getVoltSamples ( const TotemTimingDigi digi) const

Definition at line 112 of file TotemTimingConversions.cc.

References calibrationFileOk_, data, TotemTimingDigi::getSamplesBegin(), TotemTimingDigi::getSamplesEnd(), and SAMPIC_ADC_V.

Referenced by TotemTimingRecHitProducerAlgorithm::build().

113 {
114  std::vector<float> data;
115  if (!calibrationFileOk_)
116  {
117  for (auto it = digi.getSamplesBegin(); it != digi.getSamplesEnd(); ++it)
118  data.emplace_back(SAMPIC_ADC_V * (*it));
119  }
120  return data;
121 }
static const float SAMPIC_ADC_V
std::vector< uint8_t >::const_iterator getSamplesBegin() const
std::vector< uint8_t >::const_iterator getSamplesEnd() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void TotemTimingConversions::openCalibrationFile ( const std::string &  calibrationFile = "/dev/null")

Definition at line 31 of file TotemTimingConversions.cc.

References calibrationFile_, and calibrationFileOk_.

32 {
33  if (calibrationFile!="/dev/null") // if given, the filename here overwrites the filename in the ctor
34  {
35  calibrationFile_ = calibrationFile;
36  }
37 
38  if (calibrationFile_!="/dev/null")
39  {
40  // Open File TODO
41  calibrationFileOk_ = true;
42  }
43 
44 }

Member Data Documentation

std::string TotemTimingConversions::calibrationFile_
private

Definition at line 40 of file TotemTimingConversions.h.

Referenced by openCalibrationFile().

bool TotemTimingConversions::calibrationFileOk_
private

Definition at line 39 of file TotemTimingConversions.h.

Referenced by getTimeSamples(), getVoltSamples(), and openCalibrationFile().

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

Definition at line 35 of file TotemTimingConversions.h.

Referenced by getVoltSamples().

const int TotemTimingConversions::SAMPIC_DEFAULT_OFFSET = 30
staticprivate

Definition at line 37 of file TotemTimingConversions.h.

Referenced by getTimeOfFirstSample().

const int TotemTimingConversions::SAMPIC_MAX_NUMBER_OF_SAMPLES = 64
staticprivate

Definition at line 36 of file TotemTimingConversions.h.

Referenced by getTimeOfFirstSample(), and getTriggerTime().

const float TotemTimingConversions::SAMPIC_SAMPLING_PERIOD_NS = 1. / 7.8
staticprivate

Definition at line 34 of file TotemTimingConversions.h.

Referenced by getTimeOfFirstSample(), getTimeSamples(), and getTriggerTime().