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
13#include <iostream>
14#include <algorithm>
15#include "fairlogger/Logger.h"
16
17namespace o2::trd
18{
19
20using namespace constants;
21
22Digit::Digit(int det, int row, int pad, ArrayADC adc, int pretrigphase)
23{
24 setDetector(det);
25 setROB(row, pad);
26 setMCM(row, pad);
27 setADC(adc);
28 setChannel(NADCMCM - 2 - (pad % NCOLMCM));
29 setPreTrigPhase(pretrigphase);
30}
31
32Digit::Digit(int det, int row, int pad) // add adc data in a seperate step
33{
34 setDetector(det);
35 setROB(row, pad);
36 setMCM(row, pad);
37 setChannel(NADCMCM - 2 - (pad % NCOLMCM));
38}
39
40Digit::Digit(int det, int rob, int mcm, int channel, ArrayADC adc, int pretrigphase)
41{
42 setDetector(det);
43 setROB(rob);
44 setMCM(mcm);
45 setChannel(channel);
46 setADC(adc);
47 setPreTrigPhase(pretrigphase);
48}
49
50Digit::Digit(int det, int rob, int mcm, int channel, int pretrigphase) // add adc data in a seperate step
51{
52 setDetector(det);
53 setROB(rob);
54 setMCM(mcm);
55 setChannel(channel);
56 setPreTrigPhase(pretrigphase);
57}
58
60{
61 mDetector = ((((phase) & 0x3) << 12) | (mDetector & 0xfff));
62}
63
65{
66 if (mChannel == 0 || mChannel == 1 || mChannel == NADCMCM - 1) {
67 return 1;
68 } else {
69 return 0;
70 }
71}
72
73bool Digit::isNeighbour(const Digit& other) const
74{
75 return (getDetector() == other.getDetector() && getROB() == other.getROB() && getMCM() == other.getMCM() && std::abs(getChannel() - other.getChannel()) == 1);
76}
77
78ADC_t Digit::getADCmax(int& idx) const
79{
80 auto itMax = std::max_element(mADC.begin(), mADC.end());
81 idx = std::distance(mADC.begin(), itMax);
82 return *itMax;
83}
84
85std::ostream& operator<<(std::ostream& stream, const Digit& d)
86{
87 stream << "Digit Det: " << HelperMethods::getSector(d.getDetector()) << "_" << HelperMethods::getStack(d.getDetector()) << "_" << HelperMethods::getLayer(d.getDetector()) << " pad row: " << d.getPadRow() << " pad column: " << d.getPadCol() << " Channel: " << d.getChannel() << " ADCs:";
88 for (int i = 0; i < constants::TIMEBINS; i++) {
89 stream << "[" << d.getADC()[i] << "]";
90 }
91 return stream;
92}
93
94} // namespace o2::trd
uint16_t mcm
uint16_t rob
uint64_t phase
Definition RawEventData.h:7
int32_t i
void setMCM(int mcm)
Definition Digit.h:70
ADC_t getADCmax(int &idx) const
Definition Digit.cxx:78
int getDetector() const
Definition Digit.h:80
int getPadRow() const
Definition Digit.h:83
bool isNeighbour(const Digit &other) const
Definition Digit.cxx:73
bool isSharedDigit() const
Definition Digit.cxx:64
void setADC(ArrayADC const &adc)
Definition Digit.h:75
void setPreTrigPhase(int phase)
Definition Digit.cxx:59
int getChannel() const
Definition Digit.h:88
int getMCM() const
Definition Digit.h:86
ArrayADC const & getADC() const
Definition Digit.h:93
void setROB(int rob)
Definition Digit.h:69
int getROB() const
Definition Digit.h:85
int getPadCol() const
Definition Digit.h:84
Digit()=default
void setDetector(int det)
Definition Digit.h:74
void setChannel(int channel)
Definition Digit.h:73
GLuint GLuint stream
Definition glcorearb.h:1806
constexpr int TIMEBINS
the number of time bins
Definition Constants.h:74
constexpr int NADCMCM
the number of ADC channels per MCM
Definition Constants.h:52
constexpr int NCOLMCM
the number of pads per MCM
Definition Constants.h:53
std::uint16_t ADC_t
Definition Digit.h:31
std::array< ADC_t, constants::TIMEBINS > ArrayADC
Definition Digit.h:32
std::ostream & operator<<(std::ostream &stream, const Digit &d)
Definition Digit.cxx:85
static int getStack(int det)
static int getLayer(int det)
static int getSector(int det)
VectorOfTObjectPtrs other
std::vector< int > row
ArrayADC adc