CbmRoot
Loading...
Searching...
No Matches
AccDataSis18.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
5#include "AccDataSis18.h"
6
7#include <Logger.h> // for LOG output
8
9#include <iomanip>
10#include <iostream>
11
12AccTimingEvent::AccTimingEvent(uint64_t ulPlannedUTCIn, uint64_t ulPlannedTAIIn, uint64_t ulRawEventIn,
13 uint64_t ulRawParamsIn, uint32_t uRawTimingFlagsIn, uint64_t ulExecutedUTCIn,
14 uint64_t ulExecutedTAIIn)
15 : fulPlannedUTC {ulPlannedUTCIn}
16 , fulPlannedTAI {ulPlannedTAIIn}
17 , fulRawEvent {ulRawEventIn}
18 , fulRawParams {ulRawParamsIn}
19 , fuRawTimingFlags {uRawTimingFlagsIn}
20 , fulExecutedUTC {ulExecutedUTCIn}
21 , fulExecutedTAI {ulExecutedTAIIn}
22{
23}
24
25AccTimingEvent::AccTimingEvent(std::string sLine, bool bVerbose)
26{
27 /*
28 * Format used to generate the timing files
29 * | std::cout << "Planned UTC: " << setw(20) << deadline.getUTC();
30 * | std::cout << " TAI: " << setw(20) <<deadline.getTAI();
31 * | std::cout << " Raw:" << std::hex << std::setfill('0')
32 * | << " 0x" << std::setw(16) << id
33 * | << " 0x" << std::setw(16) << param
34 * | << " 0x" << std::setw(4) << flags
35 * | << std::dec << std::setfill(' ');
36 * | std::cout << " exec UTC: " << setw(20) <<executed.getUTC();
37 * | std::cout << " TAI: " << setw(20) <<executed.getTAI();
38 * |
39 * | /// Dec Hex Name Meaning
40 * | ///
41 * | /// Spill limits
42 * | /// 46 2E EVT_EXTR_START_SLOW Start of extraction
43 * | /// 51 33 EVT_EXTR_END End of extraction
44 * | /// 78 4E EVT_EXTR_STOP_SLOW End of slow extraction
45 * | ///
46 * | /// Cycle limits
47 * | /// 32 20 EVT_START_CYCLE First Event in a cycle
48 * | /// 55 37 EVT_END_CYCLE End of a cycle
49 * | uint32_t uEventNb = ((id >> 36) & 0xfff);
50 * | switch (uEventNb) {
51 * | case 32:
52 * | std::cout << " => EVT_START_CYCLE ";
53 * | break;
54 * | case 55:
55 * | std::cout << " => EVT_END_CYCLE ";
56 * | break;
57 * | case 46:
58 * | std::cout << " => EVT_EXTR_START_SLOW ";
59 * | break;
60 * | case 51:
61 * | std::cout << " => EVT_EXTR_END ";
62 * | break;
63 * | case 78:
64 * | std::cout << " => EVT_EXTR_STOP_SLOW ";
65 * | break;
66 * | }
67 * | std::cout << tr_formatDate(deadline, pmode);
68 * | std::cout << tr_formatActionFlags(flags, executed - deadline, pmode);
69 * | std::cout << std::endl;
70 */
71
72 std::string sToken = "Planned UTC: ";
73 std::size_t posTok = sLine.find(sToken);
74 sLine = sLine.substr(posTok + sToken.size());
75
76 sToken = " TAI: ";
77 posTok = sLine.find(sToken);
78 fulPlannedUTC = std::stoul(sLine.substr(0, posTok));
79 sLine = sLine.substr(posTok + sToken.size());
80
81 sToken = " Raw: 0x";
82 posTok = sLine.find(sToken);
83 fulPlannedTAI = std::stoul(sLine.substr(0, posTok));
84 sLine = sLine.substr(posTok + sToken.size());
85
86 sToken = " 0x";
87 posTok = sLine.find(sToken);
88 fulRawEvent = std::stoul(sLine.substr(0, posTok), 0, 16);
89 sLine = sLine.substr(posTok + sToken.size());
90
91 sToken = " 0x";
92 posTok = sLine.find(sToken);
93 fulRawParams = std::stoul(sLine.substr(0, posTok), 0, 16);
94 sLine = sLine.substr(posTok + sToken.size());
95
96 sToken = " exec UTC: ";
97 posTok = sLine.find(sToken);
98 fuRawTimingFlags = std::stoul(sLine.substr(0, posTok), 0, 16);
99 sLine = sLine.substr(posTok + sToken.size());
100
101 sToken = " TAI: ";
102 posTok = sLine.find(sToken);
103 fulExecutedUTC = std::stoul(sLine.substr(0, posTok));
104 sLine = sLine.substr(posTok + sToken.size());
105
106 sToken = " => ";
107 posTok = sLine.find(sToken);
108 fulExecutedTAI = std::stoul(sLine.substr(0, posTok));
109 sLine = sLine.substr(posTok + sToken.size());
110
111 if (bVerbose) Print();
112}
113
115{
116 /* clang-format off */
117 LOG(info) << "Planned UTC: " << std::setw(20) << fulPlannedUTC
118 << " TAI: " << std::setw(20) << fulPlannedTAI
119 << " Raw:" << std::hex << std::setfill('0')
120 << " 0x" << std::setw(16) << fulRawEvent
121 << " 0x" << std::setw(16) << fulRawParams
122 << " 0x" << std::setw(4) << fuRawTimingFlags
123 << std::dec << std::setfill(' ')
124 << " exec UTC: " << std::setw(20) << fulExecutedUTC
125 << " TAI: " << std::setw(20) << fulExecutedTAI;
126 /* clang-format on */
127}
128//--------------------------------------------------------------------------------------------------------------------//
129
130bool AccStatusTs::IsSpillOnAtTime(uint64_t uTimeUtc)
131{
132 bool bSpillOn = IsSpillOnAtStart();
133
134 std::vector<AccTimingEvent>::iterator it = fvEventsDuringTS.begin();
135 while (it != fvEventsDuringTS.end() && (*it < uTimeUtc)) {
136
137 if (bSpillOn && it->IsExtractionEnd()) {
139 bSpillOn = false;
140 }
141 else if (!bSpillOn && it->IsExtractionStart()) {
143 bSpillOn = true;
144 }
145 }
146 return bSpillOn;
147}
148
149uint32_t AccStatusTs::GetSpillIdxAtTime(uint64_t uTimeUtc)
150{
151 bool bSpillOn = IsSpillOnAtStart();
152 uint32_t uSpillIdx = fuSpillIndexAtStart;
153
154 std::vector<AccTimingEvent>::iterator it = fvEventsDuringTS.begin();
155 while (it != fvEventsDuringTS.end() && (*it < uTimeUtc)) {
156
157 if (bSpillOn && it->IsExtractionEnd()) {
159 bSpillOn = false;
160 }
161 else if (!bSpillOn && it->IsExtractionStart()) {
163 bSpillOn = true;
164 uSpillIdx++;
165 }
166 }
167 return uSpillIdx;
168}
169//--------------------------------------------------------------------------------------------------------------------//
bool IsSpillOnAtTime(uint64_t uTimeUtc)
std::vector< AccTimingEvent > fvEventsDuringTS
uint32_t GetSpillIdxAtTime(uint64_t uTimeUtc)
bool IsSpillOnAtStart() const
True when we start in the middle of an extraction spill.
uint32_t fuSpillIndexAtStart
Members.
uint64_t fulRawParams
uint64_t fulPlannedTAI
uint64_t fulExecutedUTC
uint64_t fulRawEvent
uint64_t fulExecutedTAI
AccTimingEvent()=default
void Print() const
uint32_t fuRawTimingFlags
uint64_t fulPlannedUTC
Fields.