CMS 3D CMS Logo

TotemTimingConversions.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of CTPPS offline software.
4  * Authors:
5  * Laurent Forthomme (laurent.forthomme@cern.ch)
6  * Nicola Minafra
7  *
8  ****************************************************************************/
9 
11 
12 //----------------------------------------------------------------------------------------------------
13 
15 const float TotemTimingConversions::SAMPIC_ADC_V = 1. / 256;
18 
19 //----------------------------------------------------------------------------------------------------
20 
22  : calibrationFileOk_(false), calibrationFile_("/dev/null") {}
23 
24 //----------------------------------------------------------------------------------------------------
25 
27  : calibrationFileOk_(false), calibrationFile_(calibrationFile) {}
28 
29 //----------------------------------------------------------------------------------------------------
30 
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 }
45 
46 //----------------------------------------------------------------------------------------------------
47 
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 }
80 
81 //----------------------------------------------------------------------------------------------------
82 
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 }
95 
96 //----------------------------------------------------------------------------------------------------
97 
98 std::vector<float> TotemTimingConversions::getTimeSamples(const TotemTimingDigi& digi) const
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 }
109 
110 //----------------------------------------------------------------------------------------------------
111 
112 std::vector<float> TotemTimingConversions::getVoltSamples(const TotemTimingDigi& digi) const
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
TotemTimingEventInfo getEventInfo() const
std::vector< float > getTimeSamples(const TotemTimingDigi &digi) const
std::vector< uint8_t >::const_iterator getSamplesBegin() const
std::vector< float > getVoltSamples(const TotemTimingDigi &digi) const
std::vector< uint8_t >::const_iterator getSamplesEnd() const
const float getTimeOfFirstSample(const TotemTimingDigi &digi) const
void openCalibrationFile(const std::string &calibrationFile="/dev/null")
unsigned int getTimestampA() const
static const int SAMPIC_DEFAULT_OFFSET
const float getTriggerTime(const TotemTimingDigi &digi) const
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 getNumberOfSamples() const
unsigned int getL1ATimestamp() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const int SAMPIC_MAX_NUMBER_OF_SAMPLES
unsigned int getOffsetOfSamples() const