HIPO  4.3.0
High Performance Output data format for experimental physics
tuple.cpp
Go to the documentation of this file.
1 //******************************************************************************
2 //* ██╗ ██╗██╗██████╗ ██████╗ ██╗ ██╗ ██████╗ *
3 //* ██║ ██║██║██╔══██╗██╔═══██╗ ██║ ██║ ██╔═████╗ *
4 //* ███████║██║██████╔╝██║ ██║ ███████║ ██║██╔██║ *
5 //* ██╔══██║██║██╔═══╝ ██║ ██║ ╚════██║ ████╔╝██║ *
6 //* ██║ ██║██║██║ ╚██████╔╝ ██║██╗╚██████╔╝ *
7 //* ╚═╝ ╚═╝╚═╝╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═════╝ *
8 //************************ Jefferson National Lab (2017) ***********************
9 /*
10  * Copyright (c) 2017. Jefferson Lab (JLab). All rights reserved. Permission
11  * to use, copy, modify, and distribute this software and its documentation
12  * for educational, research, and not-for-profit purposes, without fee and
13  * without a signed licensing agreement.
14  *
15  * IN NO EVENT SHALL JLAB BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL
16  * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
17  * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JLAB HAS
18  * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19  *
20  * JLAB SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE. THE HIPO DATA FORMAT SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
23  * ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". JLAB HAS NO OBLIGATION TO
24  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25  *
26  * This software was developed under the United States Government license.
27  * For more information contact author at gavalian@jlab.org
28  * Department of Experimental Nuclear Physics, Jefferson Lab.
29  */
30  /*
31  * File: event.h
32  * Author: gavalian
33  *
34  * Created on August 15, 2022, 17:04 PM
35  */
36 
41 #include "tuple.h"
42 
43 namespace hipo {
44 
45 
47 
48  }
49 
50  tuple::tuple(const char *format){
51  }
52 
54  for(auto& branch : branches) {
55  if(branch) delete branch;
56  }
57  branches.clear();
58  }
59 
60  void tuple::initBranches(int size){
61  for(int i = 0; i < size; i++) branches.push_back(new hipo::structure());
62  for(int i = 0; i < branches.size(); i++) branches[i]->initStructureBySize(120,1,4,800);
63  currentPosition = 0;
64  }
65 
66  void tuple::fill(const float *array){
67  for(int i = 0; i < branches.size(); i++) branches[i]->putFloatAt(currentPosition*4,array[i]);
68  currentPosition++;
69  if(currentPosition>=200){
70  writeAndUpdate(); currentPosition = 0;
71  }
72  }
73 
74  void tuple::open(const char *file){
75  writer.open(file);
76  }
77 
78  void tuple::close(){
79  writer.close();
80  }
81 
83  for(int i = 0; i < branches.size(); i++){
84  event.reset();
85  event.setTag(i+1);
86  event.addStructure(*branches[i]);
88  }
89  }
90 }
Represents a HIPO event, a container for multiple structures/banks.
Definition: event.h:77
Low-level data structure representing a HIPO structure.
Definition: bank.h:64
virtual ~tuple()
Definition: tuple.cpp:53
void fill(const float *array)
Fill a row of values into the tuple.
Definition: tuple.cpp:66
void close()
Close the output file.
Definition: tuple.cpp:78
void open(const char *file)
Open an output HIPO file.
Definition: tuple.cpp:74
void initBranches(int size)
Initialize internal branch structures.
Definition: tuple.cpp:60
tuple()
Default constructor.
Definition: tuple.cpp:46
void writeAndUpdate()
Write the current event and prepare for the next one.
Definition: tuple.cpp:82
Writer for creating HIPO files.
Definition: writer.h:156
void open(const char *filename)
Open a file for writing.
Definition: writer.cpp:45
void addEvent(hipo::event &hevent)
Add an event to the current record buffer.
Definition: writer.cpp:130
void close()
Close the file, flushing remaining events and writing the trailer.
Definition: writer.cpp:216
Definition: bank.cpp:47
N-tuple writer for columnar float data serialization to HIPO files.