Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
DataFormat.cxx
1/*
2 * DataFormat.cxx
3 *
4 * Created on: 25 lis 2020
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "DataFormat.h"
10
11#include <TMath.h>
12#include <TString.h>
13namespace Hal {
14 NamespaceImp(DetectorID) namespace DetectorID {
15 UInt_t GetDetectorID(TString pattern) {
16 if (pattern.Length() > 6) return 0;
17 TString newPattern = pattern;
18 for (int i = pattern.Length(); i < 6; i++) {
19 newPattern = "0" + newPattern;
20 }
21 ULong_t detectorID = 0;
22 for (int i = 0; i < newPattern.Length(); i++) {
23 Char_t x = newPattern[i];
24 UInt_t base = 0;
25 if (x < 58) { // this is 0-9
26 base = x - 48;
27 } else if (x < 91) { // upper case
28 base = x - 55;
29 } else { // lower case
30 base = x - 87;
31 }
32 UInt_t power = (UInt_t) TMath::Power(36, 5 - i);
33 detectorID = detectorID + base * power;
34 }
35 return detectorID;
36 }
37 }
38} // namespace Hal