forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigit.cxx
More file actions
94 lines (81 loc) · 2.61 KB
/
Digit.cxx
File metadata and controls
94 lines (81 loc) · 2.61 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "DataFormatsTRD/Digit.h"
#include <iostream>
#include <algorithm>
#include "fairlogger/Logger.h"
namespace o2::trd
{
using namespace constants;
Digit::Digit(int det, int row, int pad, ArrayADC adc, int pretrigphase)
{
setDetector(det);
setROB(row, pad);
setMCM(row, pad);
setADC(adc);
setChannel(NADCMCM - 2 - (pad % NCOLMCM));
setPreTrigPhase(pretrigphase);
}
Digit::Digit(int det, int row, int pad) // add adc data in a seperate step
{
setDetector(det);
setROB(row, pad);
setMCM(row, pad);
setChannel(NADCMCM - 2 - (pad % NCOLMCM));
}
Digit::Digit(int det, int rob, int mcm, int channel, ArrayADC adc, int pretrigphase)
{
setDetector(det);
setROB(rob);
setMCM(mcm);
setChannel(channel);
setADC(adc);
setPreTrigPhase(pretrigphase);
}
Digit::Digit(int det, int rob, int mcm, int channel, int pretrigphase) // add adc data in a seperate step
{
setDetector(det);
setROB(rob);
setMCM(mcm);
setChannel(channel);
setPreTrigPhase(pretrigphase);
}
void Digit::setPreTrigPhase(int phase)
{
mDetector = ((((phase) & 0x3) << 12) | (mDetector & 0xfff));
}
bool Digit::isSharedDigit() const
{
if (mChannel == 0 || mChannel == 1 || mChannel == NADCMCM - 1) {
return 1;
} else {
return 0;
}
}
bool Digit::isNeighbour(const Digit& other) const
{
return (getDetector() == other.getDetector() && getROB() == other.getROB() && getMCM() == other.getMCM() && std::abs(getChannel() - other.getChannel()) == 1);
}
ADC_t Digit::getADCmax(int& idx) const
{
auto itMax = std::max_element(mADC.begin(), mADC.end());
idx = std::distance(mADC.begin(), itMax);
return *itMax;
}
std::ostream& operator<<(std::ostream& stream, const Digit& d)
{
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:";
for (int i = 0; i < constants::TIMEBINS; i++) {
stream << "[" << d.getADC()[i] << "]";
}
return stream;
}
} // namespace o2::trd