9#include "FemtoSerializationInterface.h"
18 void FemtoSerializationInterface::CopyData1D(std::vector<TH1*>& list,
int bin, ECopyDir dir, Bool_t error) {
20 case ECopyDir::kSerialize: {
23 fArray->
Set(fCounter, h->GetBinError(bin));
26 fArray->
Set(fCounter, h->GetBinContent(bin));
31 case ECopyDir::kDeserialize: {
34 h->SetBinError(bin, fArray->
Get(fCounter));
37 h->SetBinContent(bin, fArray->
Get(fCounter));
46 FemtoSerializationInterface::CopyData3D(std::vector<TH3*>& list,
int binx,
int biny,
int binz, ECopyDir dir, Bool_t error) {
48 case ECopyDir::kSerialize: {
51 fArray->
Set(fCounter++, h->GetBinError(binx, biny, binz));
53 fArray->
Set(fCounter++, h->GetBinContent(binx, biny, binz));
57 case ECopyDir::kDeserialize: {
60 h->SetBinError(binx, biny, binz, fArray->
Get(fCounter++));
62 h->SetBinContent(binx, biny, binz, fArray->
Get(fCounter++));
69 void FemtoSerializationInterface::CopyDataVec(std::vector<std::vector<double>>& list,
int pos, ECopyDir dir) {
71 case ECopyDir::kSerialize: {
72 for (
auto& vec : list) {
73 fArray->
Set(fCounter++, vec[pos]);
76 case ECopyDir::kDeserialize: {
77 for (
auto& vec : list) {
78 vec[pos] = fArray->
Get(fCounter++);
92 if (fBinLow == -1) { std::cout <<
"Cannot serialize, something is wrong with bin ranges" << std::endl; }
93 if (fDataType == EData::kUnkown) {
95 fDataType = EData::kCF;
97 fDataType = EData::kSlice;
99 ECopyDir dir = ECopyDir::kSerialize;
103 case EOption::kFull: ConvertCF(dir);
break;
104 case EOption::kSimple: ConvertCFSimple(dir);
break;
107 case EData::kSlice: {
109 case EOption::kFull: ConvertSlice(dir);
break;
110 case EOption::kSimple: ConvertSliceSimple(dir);
break;
117 void FemtoSerializationInterface::ExpandArrayIfSerialize(Int_t newSize, ECopyDir dir) {
118 if (dir == ECopyDir::kSerialize) fArray->
MakeBigger(newSize);
121 void FemtoSerializationInterface::CopyData1D2(std::vector<TH1*>& listN, std::vector<TH1*>& listD,
int bin, ECopyDir dir) {
122 for (
int i = 0; i < listN.size(); i++) {
125 if (dir == ECopyDir::kSerialize) {
126 fArray->
Set(fCounter++, nH->GetBinContent(bin) / dH->GetBinContent(bin));
128 dH->SetBinContent(bin, fArray->
Get(fCounter++));
129 dH->SetBinContent(bin, 1);
134 void FemtoSerializationInterface::CopyData3D2(std::vector<TH3*>& listN,
135 std::vector<TH3*>& listD,
140 for (
int i = 0; i < listN.size(); i++) {
143 if (dir == ECopyDir::kSerialize) {
144 fArray->
Set(fCounter++, nH->GetBinContent(binx, biny, binz) / dH->GetBinContent(binx, biny, binz));
146 for (
int bin = fBinStart; bin <= fBinStop; bin++) {
147 nH->SetBinContent(binx, biny, binz, fArray->
Get(fCounter++));
148 dH->SetBinContent(binx, biny, binz, 1);
154 void FemtoSerializationInterface::Deserialize(Int_t binLo, Int_t binHi) {
162 if (fBinLow == -1) { std::cout <<
"Cannot deserialize, something is wrong with bin ranges" << std::endl; }
163 if (fDataType == EData::kUnkown) {
165 fDataType = EData::kCF;
166 else if (HaveSlice())
167 fDataType = EData::kSlice;
169 ECopyDir dir = ECopyDir::kDeserialize;
173 case EOption::kFull: ConvertCF(dir);
break;
174 case EOption::kSimple: ConvertCFSimple(dir);
break;
177 case EData::kSlice: {
179 case EOption::kFull: ConvertSlice(dir);
break;
180 case EOption::kSimple: ConvertSliceSimple(dir);
break;
188 Bool_t FemtoSerializationInterface::Init() {
189 if (!HaveCF() && !HaveSlice()) {
190 std::cout << __FILE__ <<
" " << __LINE__ <<
" cannot properly without cf's or slice" << std::endl;
193 if (HaveCF() && HaveSlice()) {
194 std::cout << __FILE__ <<
" " << __LINE__ <<
" cannot properly use cf's and slice" << std::endl;
197 if (HaveCF()) GetBinsNo();
198 if (!fArray)
return kFALSE;
void Set(Int_t index, T val)
void MakeBigger(Int_t new_dim)
virtual void Serialize(Int_t binLo=-1, Int_t binHi=-1)