MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches
BinaryToRoot.cpp
Go to the documentation of this file.
1#include "BinaryToRoot.hpp"
2
4 return Form("DataR_run_%d.header", run);
5}
6
7void BinaryToRoot::WriteHeaderSidecar(Int_t run, UShort_t header) {
8 TString path = IO::GetRootFilesBaseDir() + "/" + HeaderSidecarName(run);
9 gSystem->mkdir(gSystem->DirName(path), kTRUE);
10 std::ofstream f(path.Data());
11 f << "0x" << std::hex << header << std::endl;
12}
13
14Bool_t BinaryToRoot::ReadHeaderSidecar(Int_t run, UShort_t &header) {
15 TString path = IO::GetRootFilesBaseDir() + "/" + HeaderSidecarName(run);
16 if (gSystem->AccessPathName(path))
17 return kFALSE;
18 std::ifstream f(path.Data());
19 std::string s;
20 f >> s;
21 if (s.empty())
22 return kFALSE;
23 header = static_cast<UShort_t>(std::stoul(s, nullptr, 0));
24 return kTRUE;
25}
static Bool_t ReadHeaderSidecar(Int_t run, UShort_t &header)
Read a run's global header back from its sidecar.
static TString HeaderSidecarName(Int_t run)
Sidecar filename for a run.
static void WriteHeaderSidecar(Int_t run, UShort_t header)
Write a run's global header to its sidecar.