forked from mgmarino/OrcaROOT
-
Notifications
You must be signed in to change notification settings - Fork 1
/
OR1DHistoHistogramsDecoder.cc
51 lines (43 loc) · 1.24 KB
/
OR1DHistoHistogramsDecoder.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// OR1DHistoHistogramsDecoder.cc
#include <vector>
#include "OR1DHistoHistogramsDecoder.hh"
#include "ORUtils.hh"
void OR1DHistoHistogramsDecoder::Swap(UInt_t* dataRecord)
{
if(LengthOf(dataRecord)<2) return;
/* Swapping everything but the title. */
ORUtils::Swap(dataRecord[1]);
for(size_t iWord=2+NKeyWordsOf(dataRecord);iWord<LengthOf(dataRecord);iWord++) {
ORUtils::Swap(dataRecord[iWord]);
}
}
std::string OR1DHistoHistogramsDecoder::KeysOf(UInt_t* record)
{
std::string keys((char*)(record + 2), NKeyCharactersOf(record));
return keys;
}
size_t OR1DHistoHistogramsDecoder::NKeysOf(UInt_t* record)
{
size_t keyLength = NKeyCharactersOf(record);
std::string keys = KeysOf(record);
size_t nKeys = 1;
for(size_t i=0; i<keyLength; i++) {
if(keys[i] == '/') nKeys++;
}
return nKeys;
}
std::string OR1DHistoHistogramsDecoder::IthKeyOf(UInt_t* record, size_t iKey)
{
size_t currentIKey=0;
size_t iStart = 0;
std::string keys = KeysOf(record);
while(currentIKey<iKey) {
if(keys[iStart] == '/') currentIKey++;
iStart++;
}
size_t iStop = iStart;
while(iStop < NKeyCharactersOf(record) && keys[iStop] != '/') iStop++;
std::string key;
for(size_t i=iStart; i<iStop; i++) key.push_back(keys[i]);
return key;
}