Project
Loading...
Searching...
No Matches
Digit.cxx
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#include <fairlogger/Logger.h>
12
14#include "PHOSBase/Hit.h"
15#include <iostream>
16
17using namespace o2::phos;
18
20
21Digit::Digit(short absId, float amplitude, float time, int label)
22 : DigitBase(time), mIsHighGain(true), mAbsId(absId), mLabel(label), mAmplitude(amplitude), mTime(time)
23{
24}
25Digit::Digit(short truId, float amplitude, float time, bool isTrigger2x2, int /*dummy*/)
26 : DigitBase(time), mIsHighGain(true), mAbsId(truId), mLabel(-1), mAmplitude(amplitude), mTime(time)
27{
28 setHighGain(isTrigger2x2);
29}
30Digit::Digit(const Hit& hit, int label) : mIsHighGain(true), mAbsId(hit.GetDetectorID()), mLabel(label), mAmplitude(hit.GetEnergyLoss()), mTime(hit.GetTime())
31{
32}
33void Digit::fillFromHit(const Hit& hit)
34{
35 mAbsId = hit.GetDetectorID();
36 mAmplitude = hit.GetEnergyLoss();
37 mTime = hit.GetTime();
38}
39
40bool Digit::canAdd(const Digit other) const
41{
42 return (mAbsId == other.getAbsId() && fabs(getTimeStamp() - other.getTimeStamp()) <= kTimeGate);
43}
44
46{
47
48 // Adds the amplitude of digits
49 // TODO: What about time? Should we assign time of more energetic digit? More complicated treatment?
50 if (mAmplitude < other.mAmplitude) {
51 mTime = other.mTime;
52 }
53
54 if (mLabel == -1) {
55 mLabel = other.mLabel;
56 } else {
57 if (mLabel != other.mLabel && other.mLabel != -1) {
58 // if Label indexes are different, something wrong
59 LOG(error) << "Adding digits with different references to Labels:" << mLabel << " and " << other.mLabel;
60 }
61 }
62
63 mAmplitude += other.mAmplitude;
64
65 return *this;
66}
67void Digit::addEnergyTime(float energy, float time)
68{
69 // Adds the amplitude of digits
70 // TODO: What about time? Should we assign time of more energetic digit? More complicated treatment?
71 if (mAmplitude < energy) {
72 mTime = time;
73 }
74 mAmplitude += energy;
75}
76
77void Digit::PrintStream(std::ostream& stream) const
78{
79 stream << "PHOS Digit: cell absId " << mAbsId << ", Time " << getTimeStamp() << " with amplitude " << mAmplitude;
80}
81
82std::ostream& operator<<(std::ostream& stream, const Digit& digi)
83{
84 digi.PrintStream(stream);
85 return stream;
86}
ClassImp(Digit)
int16_t time
Definition RawEventData.h:4
V GetEnergyLoss() const
Definition BaseHits.h:103
E GetTime() const
Definition BaseHits.h:71
short GetDetectorID() const
Definition BaseHits.h:73
static constexpr int kTimeGate
Definition Digit.h:32
void fillFromHit(const Hit &hit)
Replace content of this digit with new one, from hit.
Definition Digit.cxx:33
bool canAdd(const Digit other) const
Check, if one can add two digits.
Definition Digit.cxx:40
void setHighGain(Bool_t isHG)
Definition Digit.h:122
Digit & operator+=(const Digit &other)
if addable, adds energy and list of primaries.
Definition Digit.cxx:45
void addEnergyTime(float energy, float time)
Definition Digit.cxx:67
Digit()=default
void PrintStream(std::ostream &stream) const
Definition Digit.cxx:77
PHOS simulation hit information.
Definition Hit.h:25
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &in, const BadChannelsMap &bcm)
Printing bad channel map on the stream.
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"