ATLAS Offline Software
Enumerations | Functions
CTPResultUtils Namespace Reference

Utility functions for xAOD::CTPResult objects that rely on tdaq-common. More...

Enumerations

enum  WordType {
  WordType::TIP, WordType::TBP, WordType::TAP, WordType::TAV,
  WordType::Extra
}
 Enum describing the different word types in the CTP result. More...
 

Functions

void initialize (xAOD::CTPResult &ctpRes, uint32_t ctpVersionNumber, const uint32_t nBCs=1, uint32_t nExtraWords=0)
 Initialize with a number of bunch crossings of the readout window. More...
 
void initialize (xAOD::CTPResult &ctpRes, uint32_t ctpVersionNumber, const std::vector< uint32_t > &data, uint32_t nExtraWords=0)
 Initialize with raw data words from one or more bunch crossings. More...
 
uint32_t getTimeSec (const xAOD::CTPResult &ctpRes)
 Get the time in seconds. More...
 
void setTimeSec (xAOD::CTPResult &ctpRes, const uint32_t sec)
 Set the time in seconds. More...
 
uint32_t getTimeNanoSec (const xAOD::CTPResult &ctpRes)
 Get the time in nanoseconds. More...
 
void setTimeNanoSec (xAOD::CTPResult &ctpRes, const uint32_t nano)
 Set the time in nanoseconds. More...
 
void setNumberOfBunches (xAOD::CTPResult &ctpRes, const uint32_t nBCs)
 Set the number of bunch crossings. More...
 
void setNumberOfAdditionalWords (xAOD::CTPResult &ctpRes, const uint32_t nExtraWords)
 Set the number of additional data words. More...
 
std::vector< uint32_t > getTIPWords (const xAOD::CTPResult &ctpRes)
 Get the TIP (Trigger Inputs to the CTP) words (in Run3 512 items) More...
 
std::vector< uint32_t > getTBPWords (const xAOD::CTPResult &ctpRes)
 Get the TBP (Trigger Before Prescale) words. More...
 
std::vector< uint32_t > getTAPWords (const xAOD::CTPResult &ctpRes)
 Get the TAP (Trigger After Prescale) words. More...
 
std::vector< uint32_t > getTAVWords (const xAOD::CTPResult &ctpRes)
 Get the TAV (Trigger After Veto) words. More...
 
std::vector< uint32_t > getExtraWords (const xAOD::CTPResult &ctpRes)
 Get additional words. More...
 
std::vector< uint32_t > getWords (const xAOD::CTPResult &ctpRes, CTPResultUtils::WordType type)
 Helper to retrieve specific words. More...
 
uint32_t getTimeSinceLastL1A (const xAOD::CTPResult &ctpRes)
 Get the time since the last 1 accept. More...
 

Detailed Description

Utility functions for xAOD::CTPResult objects that rely on tdaq-common.

Declared here as tdaq-common is used in TrigT1Interfaces and not xAODTrigger. Prevents using XAOD_ANALYSIS macro in xAOD class.

Enumeration Type Documentation

◆ WordType

Enum describing the different word types in the CTP result.

  • TIP: Trigger inputs to the CTP.
  • TBP: Trigger Before Prescale.
  • TAP: Trigger After Prescale.
  • TAV: Trigger After Veto.
  • Extra: Additional data words beyond the standard categories.
Enumerator
TIP 
TBP 
TAP 
TAV 
Extra 

Definition at line 27 of file CTPResultUtils.h.

27 {TIP, TBP, TAP, TAV, Extra};

Function Documentation

◆ getExtraWords()

std::vector< uint32_t > CTPResultUtils::getExtraWords ( const xAOD::CTPResult ctpRes)

Get additional words.

Returns
Vector of extra words.

Definition at line 120 of file CTPResultUtils.cxx.

120 {return getWords(ctpRes, WordType::Extra);}

◆ getTAPWords()

std::vector< uint32_t > CTPResultUtils::getTAPWords ( const xAOD::CTPResult ctpRes)

Get the TAP (Trigger After Prescale) words.

Returns
Vector of TAP words.

Definition at line 114 of file CTPResultUtils.cxx.

114 {return getWords(ctpRes, WordType::TAP);}

◆ getTAVWords()

std::vector< uint32_t > CTPResultUtils::getTAVWords ( const xAOD::CTPResult ctpRes)

Get the TAV (Trigger After Veto) words.

Returns
Vector of TAV words.

Definition at line 117 of file CTPResultUtils.cxx.

117 {return getWords(ctpRes, WordType::TAV);}

◆ getTBPWords()

std::vector< uint32_t > CTPResultUtils::getTBPWords ( const xAOD::CTPResult ctpRes)

Get the TBP (Trigger Before Prescale) words.

Returns
Vector of TBP words.

Definition at line 111 of file CTPResultUtils.cxx.

111 {return getWords(ctpRes, WordType::TBP);}

◆ getTimeNanoSec()

uint32_t CTPResultUtils::getTimeNanoSec ( const xAOD::CTPResult ctpRes)

Get the time in nanoseconds.

Returns
Time in nanoseconds.

Definition at line 65 of file CTPResultUtils.cxx.

65  {
66  CTPdataformatVersion ctpDataFormat(ctpRes.ctpVersionNumber());
67  if(ctpRes.dataWords().size() <= ctpDataFormat.getTimeNanosecondsPos()) {
68  return 0;
69  }
70  return (ctpRes.dataWords().at(ctpDataFormat.getTimeNanosecondsPos() ) >> ctpDataFormat.getTimeNanosecondsOffset() ) * ctpDataFormat.getTimeNanosecondsTicks();
71  }

◆ getTimeSec()

uint32_t CTPResultUtils::getTimeSec ( const xAOD::CTPResult ctpRes)

Get the time in seconds.

Returns
Time in seconds.

Definition at line 46 of file CTPResultUtils.cxx.

46  {
47  CTPdataformatVersion ctpDataFormat(ctpRes.ctpVersionNumber());
48  if(ctpRes.dataWords().size() <= ctpDataFormat.getTimeSecondsPos()){
49  return 0;
50  }
51  return ctpRes.dataWords().at(ctpDataFormat.getTimeSecondsPos());
52  }

◆ getTimeSinceLastL1A()

uint32_t CTPResultUtils::getTimeSinceLastL1A ( const xAOD::CTPResult ctpRes)

Get the time since the last 1 accept.

Returns
Time since the last L1 accept.

◆ getTIPWords()

std::vector< uint32_t > CTPResultUtils::getTIPWords ( const xAOD::CTPResult ctpRes)

Get the TIP (Trigger Inputs to the CTP) words (in Run3 512 items)

Returns
Vector of TIP words.

Definition at line 108 of file CTPResultUtils.cxx.

108 {return getWords(ctpRes, WordType::TIP);}

◆ getWords()

std::vector< uint32_t > CTPResultUtils::getWords ( const xAOD::CTPResult ctpRes,
CTPResultUtils::WordType  type 
)

Helper to retrieve specific words.

Parameters
typeThe word type to retrieve.
Returns
Vector of words of the specified type.

Definition at line 123 of file CTPResultUtils.cxx.

123  {
124  unsigned int nWords = 0;
125  unsigned int offset = 0;
126  std::vector<uint32_t> vec;
127  vec.clear();
128  CTPdataformatVersion ctpDataFormat(ctpRes.ctpVersionNumber());
129  switch (type) {
130  case WordType::TIP:
131  nWords = ctpDataFormat.getTIPwords();
132  offset = ctpDataFormat.getTIPpos();
133  break;
134  case WordType::TBP:
135  nWords = ctpDataFormat.getTBPwords();
136  offset = ctpDataFormat.getTBPpos();
137  break;
138  case WordType::TAP:
139  nWords = ctpDataFormat.getTAPwords();
140  offset = ctpDataFormat.getTAPpos();
141  break;
142  case WordType::TAV:
143  nWords = ctpDataFormat.getTAVwords();
144  offset = ctpDataFormat.getTAVpos();
145  break;
146  case WordType::Extra:
147  vec.assign(ctpRes.dataWords().begin() + (ctpRes.dataWords().size()-ctpRes.numberOfAdditionalWords()), ctpRes.dataWords().end());
148  return vec;
149  break;
150  default:
151  break;
152  }
153  for(unsigned int bunch = 0 ; bunch < ctpRes.numberOfBunches() ; ++bunch) {
154  for(unsigned int tbp = 0; tbp < nWords; ++tbp) {
155  // take offset of TBPwords into account
156  unsigned int index = offset + tbp;
157  // go to the correct bunch
158  index += (bunch * ctpDataFormat.getDAQwordsPerBunch());
159  if( index < ctpRes.dataWords().size() ) {
160  vec.push_back(ctpRes.dataWords()[index]);
161  }
162  }
163  }
164  // this is now a list of consecutive data words for all bunches
165  return vec;
166  }

◆ initialize() [1/2]

void CTPResultUtils::initialize ( xAOD::CTPResult ctpRes,
uint32_t  ctpVersionNumber,
const std::vector< uint32_t > &  data,
uint32_t  nExtraWords = 0 
)

Initialize with raw data words from one or more bunch crossings.

Parameters
ctpVersionNumberThe version number of the CTP data format.
dataVector of raw data words.
nExtraWordsNumber of extra data words.

Definition at line 30 of file CTPResultUtils.cxx.

30  {
31  CTPdataformatVersion ctpDataFormat(ctpVersionNumber);
32  ctpRes.setCtpVersionNumber(ctpVersionNumber);
33  ctpRes.setDataWords(data);
34  setNumberOfAdditionalWords(ctpRes, nExtraWords);
35 
36  //additional initialisation
37  if (!ctpRes.dataWords().size()) {
38  setNumberOfBunches(ctpRes, 0u);
39  } else {
40  uint32_t words = static_cast<uint32_t>(ctpRes.dataWords().size()) - ctpDataFormat.getNumberTimeWords() - nExtraWords;
41  setNumberOfBunches(ctpRes, words / ctpDataFormat.getDAQwordsPerBunch());
42  }
43  }

◆ initialize() [2/2]

void CTPResultUtils::initialize ( xAOD::CTPResult ctpRes,
uint32_t  ctpVersionNumber,
const uint32_t  nBCs = 1,
uint32_t  nExtraWords = 0 
)

Initialize with a number of bunch crossings of the readout window.

Parameters
ctpVersionNumberThe version number of the CTP data format.
nBCsNumber of bunch crossings in the readout window.
nExtraWordsNumber of extra data words.

Definition at line 17 of file CTPResultUtils.cxx.

17  {
18  CTPdataformatVersion ctpDataFormat(ctpVersionNumber);
19  ctpRes.setCtpVersionNumber(ctpVersionNumber);
20  setNumberOfBunches(ctpRes, nBCs);
21  setNumberOfAdditionalWords(ctpRes, nExtraWords);
22 
23  // create correct length, zero filled data member
24  std::vector<uint32_t> words;
25  words.resize(ctpDataFormat.getNumberTimeWords()+(nBCs*ctpDataFormat.getDAQwordsPerBunch() )+nExtraWords);
26  ctpRes.setDataWords(words);
27  }

◆ setNumberOfAdditionalWords()

void CTPResultUtils::setNumberOfAdditionalWords ( xAOD::CTPResult ctpRes,
const uint32_t  nExtraWords 
)

Set the number of additional data words.

Parameters
nExtraWordsNumber of extra words.

Definition at line 96 of file CTPResultUtils.cxx.

96  {
97  if(nExtraWords > ctpRes.numberOfAdditionalWords()) {
98  CTPdataformatVersion ctpDataFormat(ctpRes.ctpVersionNumber());
99  std::vector<uint32_t> words = ctpRes.dataWords();
100  words.resize(ctpRes.dataWords().size()+nExtraWords-ctpRes.numberOfAdditionalWords());
101  ctpRes.setDataWords(words);
102  }
103  static const SG::AuxElement::Accessor< uint32_t > acc("numberOfAdditionalWords");
104  acc(ctpRes) = nExtraWords;
105  }

◆ setNumberOfBunches()

void CTPResultUtils::setNumberOfBunches ( xAOD::CTPResult ctpRes,
const uint32_t  nBCs 
)

Set the number of bunch crossings.

Parameters
nBCsNumber of bunch crossings.

Definition at line 84 of file CTPResultUtils.cxx.

84  {
85  if(nBCs > ctpRes.numberOfBunches()) {
86  static const SG::AuxElement::Accessor< uint32_t > acc("numberOfBunches");
87  acc(ctpRes) = nBCs;
88  CTPdataformatVersion ctpDataFormat(ctpRes.ctpVersionNumber());
89  std::vector<uint32_t> words = ctpRes.dataWords();
90  words.resize(ctpDataFormat.getNumberTimeWords()+(nBCs*ctpDataFormat.getDAQwordsPerBunch())+ctpRes.numberOfAdditionalWords());
91  ctpRes.setDataWords(words);
92  }
93  }

◆ setTimeNanoSec()

void CTPResultUtils::setTimeNanoSec ( xAOD::CTPResult ctpRes,
const uint32_t  nano 
)

Set the time in nanoseconds.

Parameters
nanoTime in nanoseconds.

Definition at line 74 of file CTPResultUtils.cxx.

74  {
75  CTPdataformatVersion ctpDataFormat(ctpRes.ctpVersionNumber());
76  std::vector<uint32_t> words = ctpRes.dataWords();
77  if(ctpDataFormat.getTimeNanosecondsPos() < words.size()) {
78  words[ctpDataFormat.getTimeNanosecondsPos()] = ((nano/ctpDataFormat.getTimeNanosecondsTicks()) << ctpDataFormat.getTimeNanosecondsOffset());
79  ctpRes.setDataWords(words);
80  }
81  }

◆ setTimeSec()

void CTPResultUtils::setTimeSec ( xAOD::CTPResult ctpRes,
const uint32_t  sec 
)

Set the time in seconds.

Parameters
secTime in seconds.

Definition at line 55 of file CTPResultUtils.cxx.

55  {
56  CTPdataformatVersion ctpDataFormat(ctpRes.ctpVersionNumber());
57  std::vector<uint32_t> words = ctpRes.dataWords();
58  if (ctpDataFormat.getTimeSecondsPos() < words.size()) {
59  words[ctpDataFormat.getTimeSecondsPos()] = sec;
60  ctpRes.setDataWords(words);
61  }
62  }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
CTPResultUtils::WordType::Extra
@ Extra
xAOD::CTPResult_v1::ctpVersionNumber
uint32_t ctpVersionNumber() const
Get the CTP version number.
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
CTPResultUtils::WordType::TBP
@ TBP
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
CTPResultUtils::setNumberOfAdditionalWords
void setNumberOfAdditionalWords(xAOD::CTPResult &ctpRes, const uint32_t nExtraWords)
Set the number of additional data words.
Definition: CTPResultUtils.cxx:96
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
xAOD::CTPResult_v1::numberOfAdditionalWords
uint32_t numberOfAdditionalWords() const
Get the number of additional data words.
CTPResultUtils::setNumberOfBunches
void setNumberOfBunches(xAOD::CTPResult &ctpRes, const uint32_t nBCs)
Set the number of bunch crossings.
Definition: CTPResultUtils.cxx:84
CTPResultUtils::WordType::TIP
@ TIP
PlotCalibFromCool.words
words
Definition: PlotCalibFromCool.py:51
xAOD::CTPResult_v1::setDataWords
void setDataWords(const std::vector< uint32_t > &words)
Set the raw data words.
xAOD::CTPResult_v1::numberOfBunches
uint32_t numberOfBunches() const
Get the number of bunch crossings.
DeMoScan.index
string index
Definition: DeMoScan.py:362
CTPResultUtils::WordType::TAP
@ TAP
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
xAOD::CTPResult_v1::dataWords
const std::vector< uint32_t > & dataWords() const
Get the raw data words.
CTPResultUtils::WordType::TAV
@ TAV
CTPResultUtils::getWords
std::vector< uint32_t > getWords(const xAOD::CTPResult &ctpRes, CTPResultUtils::WordType type)
Helper to retrieve specific words.
Definition: CTPResultUtils.cxx:123
xAOD::CTPResult_v1::setCtpVersionNumber
void setCtpVersionNumber(const uint32_t ctpNumber)
Set the CTP version number.