clas12root
Loading...
Searching...
No Matches
clas12writer.h
Go to the documentation of this file.
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6
7/*
8 * File: clas12writer.h
9 * Author: rtyson
10 *
11 */
12
13#ifndef CLAS12WRITER_H
14#define CLAS12WRITER_H
15
16#include "clas12defs.h"
17#include "clas12reader.h"
18#include <hipo4/writer.h>
19#include <hipo4/bank.h>
20#include <hipo4/event.h>
21#include <hipo4/utils.h>
22#include <hipo4/dictionary.h>
23
24#include <algorithm>
25#include <string>
26#include <iostream>
27
28namespace clas12 {
29 using std::cout;
30 using std::endl;
31
33
34
35 public:
36
37
38 clas12writer()=default;
39 clas12writer(std::string filename);
40 virtual ~clas12writer()=default;
41
42 hipo::writer& getWriter() {return _writer;}
43
44 void writeEvent();
45 void clearEvent();
46 void closeWriter();
47 void addSchemas(hipo::dictionary& factory);
48 void openFile();
49 bool savedBankName(std::string name);
50 void assignReader(clas12reader& c12reader);
51 void writeSpecialBanks(bool specialBanksBool){_specialBanksBool=specialBanksBool;};
52 void processSpecialBanks(std::string inputFilename);
53 void addSchema(std::string schemaName, hipo::dictionary& factory);
54 bool hasSchema(std::string schemaName);
55 void setTag(long tag);
56 void setFile(const std::string& file){_filename=file;}
59 void skipBank(std::string bankName){
60 if(!savedBankName(bankName)){
61 _bankNamesToSkip.push_back(bankName);
62 }
63 }
64 bool isOpen()const {return _isOpen;}
65 private:
66
67 //reader
68 hipo::writer _writer;
69 hipo::event _outEvent;
70 hipo::dictionary _readerDict;
71 std::vector<std::string> _bankNamesToSkip;
72 std::string _filename;
73 std::vector<hipo::bank* > _banks;
74 long _nEvents = 0;
75 long _nSpecialEvents = 0;
76 bool _specialBanksBool = true;
77 bool _isOpen = false;
78
79 };
80
81}
82
83#endif /* CLAS12WRITER_H */
Clas12root HIPO file reader.
Definition clas12reader.h:74
void addSchema(std::string schemaName, hipo::dictionary &factory)
Definition clas12writer.cpp:132
bool savedBankName(std::string name)
checks if the name of a bank is kept in memory to be skipped
Definition clas12writer.cpp:147
void setFile(const std::string &file)
Definition clas12writer.h:56
void setTag(long tag)
Definition clas12writer.cpp:154
void assignReader(clas12reader &c12reader)
Definition clas12writer.cpp:20
void writeSpecialBanks(bool specialBanksBool)
Definition clas12writer.h:51
void writeEvent()
pass bank information to hipo::writer to write out events
Definition clas12writer.cpp:105
void skipBank(std::string bankName)
adds a bank name to the list of banks to skip
Definition clas12writer.h:59
bool isOpen() const
Definition clas12writer.h:64
virtual ~clas12writer()=default
void openFile()
opens file in hipo::writer, only open it once.
Definition clas12writer.cpp:138
void closeWriter()
closes hipo::writer, writes out events still on buffer
Definition clas12writer.cpp:118
void addSchemas(hipo::dictionary &factory)
add schemas to writer
Definition clas12writer.cpp:126
void processSpecialBanks(std::string inputFilename)
Write the special banks (tag 1) to the output hipo file.
Definition clas12writer.cpp:47
hipo::writer & getWriter()
Definition clas12writer.h:42
bool hasSchema(std::string schemaName)
check if the writer contains a given schema
Definition clas12writer.cpp:96
Definition calextras.cpp:10