Project
Loading...
Searching...
No Matches
DataOutputDirector.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef o2_framework_DataOutputDirector_H_INCLUDED
12#define o2_framework_DataOutputDirector_H_INCLUDED
13
14#include "TFile.h"
15
17#include "Framework/InputSpec.h"
18
19#include "rapidjson/fwd.h"
20
21class TFile;
22
23namespace o2::framework
24{
25using namespace rapidjson;
26
27struct FileAndFolder {
28 TFile* file = nullptr;
29 std::string folderName = "";
30};
31
36
37 std::string tablename;
38 std::string treename;
39 std::string version;
40 std::vector<std::string> colnames;
41 std::unique_ptr<data_matcher::DataDescriptorMatcher> matcher;
42
43 DataOutputDescriptor(std::string sin);
44
45 void setFilenameBase(std::string fn) { mfilenameBase = fn; }
46 void setFilenameBase(std::string* fnptr) { mfilenameBasePtr = fnptr; }
47 std::string getFilenameBase();
48
49 void printOut();
50
51 private:
52 std::string mfilenameBase;
53 std::string* mfilenameBasePtr = nullptr;
54};
55
60
62 void reset();
63
64 // fill the DataOutputDirector with information from a
65 // keep-string
66 void readString(std::string const& keepString);
67
68 // fill the DataOutputDirector with information from a
69 // list of InputSpec
70 void readSpecs(std::vector<InputSpec> inputs);
71
72 // fill the DataOutputDirector with information from a json file
73 std::tuple<std::string, std::string, std::string, float, int> readJson(std::string const& fnjson);
74 std::tuple<std::string, std::string, std::string, float, int> readJsonString(std::string const& stjson);
75
76 // read/write private members
77 int getNumberTimeFramesToMerge() { return mnumberTimeFramesToMerge; }
78 void setNumberTimeFramesToMerge(int ntfmerge) { mnumberTimeFramesToMerge = ntfmerge > 0 ? ntfmerge : 1; }
79 std::string getFileMode() { return mfileMode; }
80 void setFileMode(std::string filemode) { mfileMode = filemode; }
81
82 // get matching DataOutputDescriptors
83 std::vector<DataOutputDescriptor*> getDataOutputDescriptors(header::DataHeader dh);
84 std::vector<DataOutputDescriptor*> getDataOutputDescriptors(InputSpec spec);
85
86 // get the matching TFile
87 FileAndFolder getFileFolder(DataOutputDescriptor* dodesc, uint64_t folderNumber, std::string parentFileName, int compression);
88
89 // check file sizes
90 bool checkFileSizes();
91 // close all files
92 void closeDataFiles();
93
94 // setters
95 void setResultDir(std::string resDir);
96 void setFilenameBase(std::string dfn);
97 void setMaximumFileSize(float maxfs);
98
99 void printOut();
100
101 private:
102 std::string mresultDirectory{"."};
103 std::string mfilenameBase;
104 std::string* const mfilenameBasePtr = &mfilenameBase;
105 std::vector<DataOutputDescriptor*> mDataOutputDescriptors;
106 std::vector<std::string> mtreeFilenames;
107 std::vector<std::string> mfilenameBases;
108 std::vector<TFile*> mfilePtrs;
109 std::vector<TMap*> mParentMaps;
110 bool mdebugmode = false;
111 int mfileCounter = 1;
112 float mmaxfilesize = -1.;
113 int mnumberTimeFramesToMerge = 1;
114 std::string mfileMode = "RECREATE";
115
116 std::tuple<std::string, std::string, std::string, float, int> readJsonDocument(Document* doc);
117 const std::tuple<std::string, std::string, std::string, float, int> memptyanswer = std::make_tuple(std::string(""), std::string(""), std::string(""), -1., -1);
118};
119
120} // namespace o2::framework
121
122#endif // o2_framework_DataOutputDirector_H_INCLUDED
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< std::string > colnames
void setFilenameBase(std::string *fnptr)
std::unique_ptr< data_matcher::DataDescriptorMatcher > matcher
void setFileMode(std::string filemode)
void readString(std::string const &keepString)
FileAndFolder getFileFolder(DataOutputDescriptor *dodesc, uint64_t folderNumber, std::string parentFileName, int compression)
void readSpecs(std::vector< InputSpec > inputs)
std::tuple< std::string, std::string, std::string, float, int > readJson(std::string const &fnjson)
std::tuple< std::string, std::string, std::string, float, int > readJsonString(std::string const &stjson)
void setNumberTimeFramesToMerge(int ntfmerge)
std::vector< DataOutputDescriptor * > getDataOutputDescriptors(header::DataHeader dh)
the main header struct
Definition DataHeader.h:618