ATLAS Offline Software
v40_write_FullEventFragment.cxx
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 
19 #include "v40_FullEventFragment.h"
20 #include "eformat/HeaderMarker.h"
21 #include "eformat/Status.h"
22 #include "eformat/Issue.h"
23 #include "eformat/checksum.h"
24 
26 {
27  m_header[0] = eformat::FULL_EVENT; //marker
28  m_header[1] = 21; //this header size + status size
29  m_header[2] = 21; //this header size + status size
30  eformat::helper::Version version(0, eformat::MAJOR_V40_VERSION);
31  m_header[3] = version.code(); //format version
32  m_header[4] = 0; //source identifier
33  m_header[5] = 1; //number of status
34  m_header[6] = eformat::NO_CHECKSUM; //check sum
35  m_header[7] = 0; //bc time seconds
36  m_header[8] = 0; //bc time nanoseconds
37  m_header[9] = 0; //global identifier
38  m_header[10] = 0; //run type
39  m_header[11] = 0; //run number
40  m_header[12] = 0; //luminosity block number
41  m_header[13] = 0; //LVL1 identifiery
42  m_header[14] = 0; //bunch crossing identifier
43  m_header[15] = 0; //LVL1 trigger type
44  m_header[16] = 0; //number of LVL1 info words
45  m_header[17] = 0; //number of LVL2 info words
46  m_header[18] = 0; //number of EF info words
47  m_header[19] = 0; //number of Stream Tag words
48 
49  //now initialize pages
50  set(m_node[0], m_header, 6, &m_node[1]);
51  set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
52  set(m_node[2], &m_header[6], 11, &m_node[3]);
53  set(m_node[3], 0, 0, &m_node[4]); //no LVL1 info yet
54  set(m_node[4], &m_header[17], 1, &m_node[5]);
55  set(m_node[5], 0, 0, &m_node[6]); //no LVL2 info yet
56  set(m_node[6], &m_header[18], 1, &m_node[7]);
57  set(m_node[7], 0, 0, &m_node[8]); //no EF info yet
58  set(m_node[8], &m_header[19], 1, &m_node[9]);
59  set(m_node[9], 0, 0, 0); //no stream tag yet
60 
61  //optional extra payload
62  set(m_node[10], 0, 0, 0);
63 
64  //optional checksum stuff (trailer)
65  m_checksum = 0;
66  set(m_node[11], &m_checksum, 1, 0);
67 
68  //our unchecked data
69  m_n_unchecked = 0;
70  set(m_unchecked[0], 0, 0, 0);
71 
72  m_child = 0;
73  m_last = 0;
74 }
75 
77 (uint32_t source_id, uint32_t bc_time_secs, uint32_t bc_time_nsec,
78  uint32_t global_id, uint32_t run_type,
79  uint32_t run_no, uint16_t lumi_block,
80  uint32_t lvl1_id, uint16_t bc_id, uint8_t lvl1_type)
81 {
82  initialize();
83  this->source_id(source_id);
84  bc_time_seconds(bc_time_secs);
85  bc_time_nanoseconds(bc_time_nsec);
86  this->global_id(global_id);
87  this->run_type(run_type);
88  this->run_no(run_no);
89  this->lumi_block(lumi_block);
90  this->lvl1_id(lvl1_id);
91  this->bc_id(bc_id);
92  lvl1_trigger_type(lvl1_type);
93 }
94 
96 {
97  initialize();
98  copy_header(fe);
100  if (read.payload_size_word() > 0) {
101  const uint32_t* tmp;
102  m_node[9].next = &m_node[10];
103  read.payload(tmp);
104  set(m_node[10], tmp, read.payload_size_word(), 0);
105  m_header[1] += read.payload_size_word();
106  }
107 }
108 
110 {
111  initialize();
112 }
113 
115 {
116 }
117 
119 {
121  read.check(); //this gives us a good start-up scenario
122  eformat::helper::Version fe_ver(read.version());
123  minor_version(fe_ver.minor_version());
124  source_id(read.source_id());
125  bc_time_seconds(read.bc_time_seconds());
126  bc_time_nanoseconds(read.bc_time_nanoseconds());
127  global_id(read.global_id());
128  run_type(read.run_type());
129  run_no(read.run_no());
130  lumi_block(read.lumi_block());
131  lvl1_id(read.lvl1_id());
132  bc_id(read.bc_id());
133  lvl1_trigger_type(read.lvl1_trigger_type());
134  const uint32_t* tmp;
135  read.status(tmp);
136  status(read.nstatus(), tmp);
137  read.lvl1_trigger_info(tmp);
138  lvl1_trigger_info(read.nlvl1_trigger_info(), tmp);
139  read.lvl2_trigger_info(tmp);
140  lvl2_trigger_info(read.nlvl2_trigger_info(), tmp);
141  read.event_filter_info(tmp);
142  event_filter_info(read.nevent_filter_info(), tmp);
143  read.stream_tag(tmp);
144  stream_tag(read.nstream_tag(), tmp);
145  checksum_type(read.checksum_type());
146 }
147 
150 {
151  minor_version(other.minor_version());
152  source_id(other.source_id());
153  bc_time_seconds(other.bc_time_seconds());
154  bc_time_nanoseconds(other.bc_time_nanoseconds());
155  global_id(other.global_id());
156  run_type(other.run_type());
157  run_no(other.run_no());
158  lumi_block(other.lumi_block());
159  lvl1_id(other.lvl1_id());
160  bc_id(other.bc_id());
161  lvl1_trigger_type(other.lvl1_trigger_type());
162  status(other.nstatus(), other.status());
163  lvl1_trigger_info(other.nlvl1_trigger_info(), other.lvl1_trigger_info());
164  lvl2_trigger_info(other.nlvl2_trigger_info(), other.lvl2_trigger_info());
165  event_filter_info(other.nevent_filter_info(), other.event_filter_info());
166  stream_tag(other.nstream_tag(), other.stream_tag());
167  checksum_type(other.checksum_type());
168 }
169 
171 (uint32_t n, const uint32_t* status)
172 {
173  m_node[0].base[1] -= m_node[0].base[5]; //remove count from previous status
174  m_node[0].base[2] -= m_node[0].base[5]; //remove count from previous status
175  m_node[1].size_word = m_node[0].base[5] = n; //set new values
176  m_node[0].base[1] += n;
177  m_node[0].base[2] += n;
178  // FIXME: I'm assuming that these are ok.
179  // Probably can't avoid this as long as we're using node_t from eformat.
180  uint32_t* status_nc ATLAS_THREAD_SAFE = const_cast<uint32_t*>(status);
181  m_node[1].base = status_nc;
182 }
183 
185 (uint32_t n, const uint32_t* data)
186 {
187  m_node[0].base[1] -= nlvl1_trigger_info(); //remove previous count
188  m_node[0].base[2] -= nlvl1_trigger_info(); //remove previous count
189  m_node[3].size_word = m_node[2].base[10] = n; //set new values
190  m_node[0].base[1] += n; //fragment size
191  m_node[0].base[2] += n; //header size
192  // FIXME: I'm assuming that these are ok.
193  // Probably can't avoid this as long as we're using node_t from eformat.
194  uint32_t* data_nc ATLAS_THREAD_SAFE = const_cast<uint32_t*>(data);
195  m_node[3].base = data_nc;
196 }
197 
199 (uint32_t n, const uint32_t* data)
200 {
201  m_node[0].base[1] -= nlvl2_trigger_info(); //remove previous count
202  m_node[0].base[2] -= nlvl2_trigger_info(); //remove previous count
203  m_node[5].size_word = m_node[4].base[0] = n; //set new values
204  m_node[0].base[1] += n; //fragment size
205  m_node[0].base[2] += n; //header size
206  // FIXME: I'm assuming that these are ok.
207  // Probably can't avoid this as long as we're using node_t from eformat.
208  uint32_t* data_nc ATLAS_THREAD_SAFE = const_cast<uint32_t*>(data);
209  m_node[5].base = data_nc;
210 }
211 
213 (uint32_t n, const uint32_t* data)
214 {
215  m_node[0].base[1] -= nevent_filter_info(); //remove previous count
216  m_node[0].base[2] -= nevent_filter_info(); //remove previous count
217  m_node[7].size_word = m_node[6].base[0] = n; //set new values
218  m_node[0].base[1] += n; //fragment size
219  m_node[0].base[2] += n; //header size
220  // FIXME: I'm assuming that these are ok.
221  // Probably can't avoid this as long as we're using node_t from eformat.
222  uint32_t* data_nc ATLAS_THREAD_SAFE = const_cast<uint32_t*>(data);
223  m_node[7].base = data_nc;
224 }
225 
227 (uint32_t n, const uint32_t* data)
228 {
229  m_node[0].base[1] -= nstream_tag(); //remove previous count
230  m_node[0].base[2] -= nstream_tag(); //remove previous count
231  m_node[9].size_word = m_node[8].base[0] = n; //set new values
232  m_node[0].base[1] += n; //fragment size
233  m_node[0].base[2] += n; //header size
234  // FIXME: I'm assuming that these are ok.
235  // Probably can't avoid this as long as we're using node_t from eformat.
236  uint32_t* data_nc ATLAS_THREAD_SAFE = const_cast<uint32_t*>(data);
237  m_node[9].base = data_nc;
238 }
239 
242 {
243  rob->parent(this);
244  rob->next(0); //reset any previous relationship
245  m_node[0].base[1] += rob->size_word();
246 
247  //adjust `m_last' and `m_child' to point to the new last ROB
248  if (m_last) m_last->next(rob);
249  else m_child = rob;
250  m_last = rob;
251 }
252 
254 {
255  if (m_n_unchecked == MAX_UNCHECKED_FRAGMENTS)
256  throw EFORMAT_TOO_MANY_UNCHECKED(MAX_UNCHECKED_FRAGMENTS);
257  v40::ROBFragment frag(rob);
258  if (m_n_unchecked) //more fragments are available before this one
259  m_unchecked[m_n_unchecked-1].next = &m_unchecked[m_n_unchecked];
260  set(m_unchecked[m_n_unchecked++], rob, frag.fragment_size_word(), 0);
261  m_node[0].base[1] += frag.fragment_size_word();
262 }
263 
265 {
266  uint32_t retval = 10 + (m_node[9].next?1:0) + (checksum_type()?1:0);
267  for (const v40_write::ROBFragment* curr = m_child; curr; curr = curr->next())
268  retval += curr->page_count();
269  return retval+m_n_unchecked;
270 }
271 
272 const eformat::write::node_t*
274 {
275  //the header is already concatenated by construction
276  eformat::write::node_t* last = &m_node[9];
277  eformat::write::node_t* payload = last; //buffer for an instant...
278  if (m_node[10].size_word) last = last->next; //advance one node
279  last->next = 0; //potentially remove old checksum
280 
281  //iterate over the attached children
282  for (v40_write::ROBFragment* curr = m_child; curr; curr = curr->next()) {
283  last->next = curr->bind();
284  while (last->next) last = last->next; //advance until end
285  }
286 
287  //make sure the last page of the last attached children points to the first
288  //unchecked page, but only if we have unchecked ROB fragments appended
289  if (m_n_unchecked) {
290  last->next = m_unchecked;
291  last = &m_unchecked[m_n_unchecked-1];
292  last->next = 0; //potentially remove old checksum
293  }
294 
295  //calculate the checksum if it was requested and we have data
296  //in this part of the code "payload" points to 1 node before the begin
297  if (checksum_type() != eformat::NO_CHECKSUM) {
298  payload = payload->next; //position cursor at payload start
299  if (!payload) {
300  eformat::write::node_t null;
301  set(null, 0, 0, 0);
302  m_checksum = eformat::write::checksum(checksum_type(), &null);
303  }
304  else
305  m_checksum = eformat::write::checksum(checksum_type(), payload);
306  last->next = &m_node[11];
307  }
308 
309  return m_node;
310 }
311 
313 {
314  if (m_node[2].base[0] == eformat::NO_CHECKSUM && s != eformat::NO_CHECKSUM) {
315  //Going from no checksum to having a checksum: update sizes
316  m_node[0].base[1] += 1;
317  }
318  else if (m_node[2].base[0] != eformat::NO_CHECKSUM &&
319  s == eformat::NO_CHECKSUM) {
320  //Going from having a checksum to no checksum: update sizes
321  m_node[0].base[1] -= 1;
322  }
323  m_node[2].base[0] = s;
324 }
325 
327 (uint32_t n) const
328 {
329  return m_unchecked[n].base;
330 }
read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
base
std::string base
Definition: hcg.cxx:78
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
offline_eformat::v40_write::FullEventFragment::m_checksum
uint32_t m_checksum
My payload's checksum, if asked.
Definition: v40_write_FullEventFragment.h:503
offline_eformat::v40_write::FullEventFragment::m_unchecked
eformat::write::node_t m_unchecked[MAX_UNCHECKED_FRAGMENTS]
Unchecked nodes.
Definition: v40_write_FullEventFragment.h:505
v40_write_FullEventFragment.h
offline_eformat::v40_write::ROBFragment::next
void next(ROBFragment *n)
Sets the next sibling.
Definition: v40_write_ROBFragment.h:507
offline_eformat::v40::ROBFragment
Describes how to access the contents of a subdetector fragment, as prescribed by the event format not...
Definition: v40_ROBFragment.h:35
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
offline_eformat::v40_write::FullEventFragment::FullEventFragment
FullEventFragment()
Builds a new empty FullEventFragment, otherwise invalid.
Definition: v40_write_FullEventFragment.cxx:109
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
offline_eformat::v40_write::FullEventFragment::m_last
v40_write::ROBFragment * m_last
my last child
Definition: v40_write_FullEventFragment.h:502
offline_eformat::v40_write::FullEventFragment::m_header
uint32_t m_header[20]
The FullEvent Header.
Definition: v40_write_FullEventFragment.h:499
initialize
void initialize()
Definition: run_EoverP.cxx:894
offline_eformat::v40_write::ROBFragment::size_word
uint32_t size_word(void) const
Returns the total size for this fragment, in words.
Definition: v40_write_ROBFragment.h:427
offline_eformat::v40_write::FullEventFragment::copy_header
void copy_header(const uint32_t *other)
Copies the header (meta data information) from another existing FullEvent Fragment.
Definition: v40_write_FullEventFragment.cxx:118
offline_eformat::v40_write::ROBFragment::parent
void parent(v40_write::FullEventFragment *ros)
This sets the parent fragment.
Definition: v40_write_ROBFragment.h:494
offline_eformat::v40_write::MAX_UNCHECKED_FRAGMENTS
const uint32_t MAX_UNCHECKED_FRAGMENTS
Maximum number of unchecked fragments a writeable FullEventFragment may have.
Definition: v40_write_FullEventFragment.h:33
offline_eformat::v40_write::FullEventFragment::stream_tag
const uint32_t * stream_tag(void) const
Returns a pointer to the first stream tag word to be used by this fragment.
Definition: v40_write_FullEventFragment.h:387
RunTileTBRec.run_type
run_type
Definition: RunTileTBRec.py:65
offline_eformat::v40_write::FullEventFragment::append_unchecked
void append_unchecked(const uint32_t *rob)
Appends an unchecked (read-only) ROB fragment to the current FullEvent.
Definition: v40_write_FullEventFragment.cxx:253
offline_eformat::v40_write::FullEventFragment::bind
const eformat::write::node_t * bind(void)
Returns the first node of a list of nodes that represent the fragment you have constructed.
Definition: v40_write_FullEventFragment.cxx:273
v40_FullEventFragment.h
LArCellBinning_test.retval
def retval
Definition: LArCellBinning_test.py:112
offline_eformat::v40_write::FullEventFragment::checksum_type
uint32_t checksum_type(void) const
Returns the check sum type of this fragment.
Definition: v40_write_FullEventFragment.h:165
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
offline_eformat::v40_write::FullEventFragment::m_child
v40_write::ROBFragment * m_child
my children
Definition: v40_write_FullEventFragment.h:501
beamspotman.n
n
Definition: beamspotman.py:731
offline_eformat::v40_write::FullEventFragment::initialize
void initialize(void)
Initializes the internal fields of this ROB fragment with the standard values.
Definition: v40_write_FullEventFragment.cxx:25
offline_eformat::v40_write::FullEventFragment
Defines a helper class to aid the creation of FullEvent fragments.
Definition: v40_write_FullEventFragment.h:39
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
offline_eformat::v40_write::FullEventFragment::status
const uint32_t * status(void) const
Returns a pointer to the first status word to be used by this fragment.
Definition: v40_write_FullEventFragment.h:120
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
offline_eformat::v40_write::FullEventFragment::unchecked_fragment
const uint32_t * unchecked_fragment(uint32_t n) const
Returns a particular unchecked ROB fragment.
Definition: v40_write_FullEventFragment.cxx:327
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
offline_eformat::v40_write::FullEventFragment::m_node
eformat::write::node_t m_node[12]
Node representation.
Definition: v40_write_FullEventFragment.h:500
offline_eformat::v40_write::FullEventFragment::append
void append(v40_write::ROBFragment *rob)
Appends a new ROB fragment to this FullEvent fragment.
Definition: v40_write_FullEventFragment.cxx:241
get_generator_info.version
version
Definition: get_generator_info.py:33
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
offline_eformat::v40_write::FullEventFragment::m_n_unchecked
uint32_t m_n_unchecked
The number of unchecked nodes attached.
Definition: v40_write_FullEventFragment.h:504
offline_eformat::v40_write::FullEventFragment::page_count
uint32_t page_count(void) const
Returns the total number of (raw memory) pages this fragment is composed of.
Definition: v40_write_FullEventFragment.cxx:264
offline_eformat::v40_write::ROBFragment
Defines a helper class to aid the creation of ROB fragments.
Definition: v40_write_ROBFragment.h:35
merge.status
status
Definition: merge.py:17
offline_eformat::v40::FullEventFragment
Describes how to access the contents of an event fragment, as prescribed by the event format note.
Definition: v40_FullEventFragment.h:35
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
offline_eformat::v40_write::FullEventFragment::lvl2_trigger_info
const uint32_t * lvl2_trigger_info(void) const
Returns a pointer to the first LVL2 trigger info to be used by this fragment.
Definition: v40_write_FullEventFragment.h:338
offline_eformat::v40_write::FullEventFragment::event_filter_info
const uint32_t * event_filter_info(void) const
Returns a pointer to the first EF trigger info to be used by this fragment.
Definition: v40_write_FullEventFragment.h:360
offline_eformat::v40::Header::fragment_size_word
uint32_t fragment_size_word() const
Returns the size, in words, of the current fragment.
Definition: v40_Header.cxx:47
offline_eformat::v40_write::FullEventFragment::~FullEventFragment
virtual ~FullEventFragment()
Base destructor.
Definition: v40_write_FullEventFragment.cxx:114
offline_eformat::v40_write::FullEventFragment::lvl1_trigger_info
const uint32_t * lvl1_trigger_info(void) const
Returns a pointer to the first LVL1 trigger info to be used by this fragment.
Definition: v40_write_FullEventFragment.h:316