Project
Loading...
Searching...
No Matches
ZDCEnergy.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ZDC_ENERGY_H
13#define ZDC_ENERGY_H
14
15#include "ZDCBase/Constants.h"
16#include <array>
17#include <cmath>
18#include <Rtypes.h>
19
23
24namespace o2
25{
26namespace zdc
27{
28
29struct ZDCEnergy {
30
31 uint32_t value = 0; // Signal id and energy released in calorimeter
32
33 ZDCEnergy() = default;
34 ZDCEnergy(uint8_t ch, float energy)
35 {
36 set(ch, energy);
37 }
38 inline void set(uint8_t ch, float energy)
39 {
40 double escaled = (energy + EnergyOffset) / EnergyUnit;
41 value = 0;
42 if (escaled > 0) {
43 if (escaled > EnergyMask) {
45 } else {
46 value = std::nearbyint(escaled);
47 }
48 }
49 if (ch >= NChannels) {
50 ch = 0x1f;
51 }
52 value = (value & EnergyMask) | (ch << 27);
53 }
54 float energy() const
55 {
56 return float(value & EnergyMask) * EnergyUnit - EnergyOffset;
57 }
58 uint8_t ch() const
59 {
60 return (value & EnergyChMask) >> 27;
61 }
62
63 void print() const;
64
66};
67} // namespace zdc
68} // namespace o2
69
70#endif
GLsizei const GLfloat * value
Definition glcorearb.h:819
struct o2::upgrades_utils::@463 zdc
structure to keep FT0 information
constexpr float EnergyUnit
Definition Constants.h:84
constexpr float EnergyOffset
Definition Constants.h:83
constexpr uint32_t EnergyMask
Definition Constants.h:85
constexpr int NChannels
Definition Constants.h:65
constexpr uint32_t EnergyChMask
Definition Constants.h:86
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void print() const
Definition ZDCEnergy.cxx:16
void set(uint8_t ch, float energy)
Definition ZDCEnergy.h:38
ClassDefNV(ZDCEnergy, 1)
float energy() const
Definition ZDCEnergy.h:54
uint8_t ch() const
Definition ZDCEnergy.h:58
ZDCEnergy(uint8_t ch, float energy)
Definition ZDCEnergy.h:34