Skip to content

Commit 728364c

Browse files
committed
Provide stored channels for BC as a span
1 parent 6f80796 commit 728364c

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

DataFormats/Detectors/ZDC/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ o2_add_library(DataFormatsZDC
1313
src/OrbitRawData.cxx src/OrbitRecData.cxx
1414
PUBLIC_LINK_LIBRARIES O2::CommonConstants O2::CommonDataFormat
1515
O2::ZDCBase ROOT::MathCore FairRoot::Base
16-
O2::MathUtils)
16+
O2::MathUtils ms_gsl::ms_gsl)
1717

1818
o2_target_root_dictionary(DataFormatsZDC
1919
HEADERS include/DataFormatsZDC/BCData.h include/DataFormatsZDC/ChannelData.h

DataFormats/Detectors/ZDC/include/DataFormatsZDC/BCData.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "CommonDataFormat/RangeReference.h"
1616
#include "ZDCBase/Constants.h"
1717
#include <Rtypes.h>
18+
#include <gsl/span>
1819

1920
/// \file BCData.h
2021
/// \brief Class to describe fired triggered and/or stored channels for the BC and to refer to channel data
@@ -24,6 +25,7 @@ namespace o2
2425
{
2526
namespace zdc
2627
{
28+
class ChannelData;
2729

2830
struct BCData {
2931
/// we are going to refer to at most 26 channels, so 5 bits for the NChannels and 27 for the reference
@@ -41,6 +43,8 @@ struct BCData {
4143
channels = chSto;
4244
triggers = chTrig;
4345
}
46+
47+
gsl::span<const ChannelData> getBunchChannelData(const gsl::span<const ChannelData> tfdata) const;
4448
void print() const;
4549

4650
ClassDefNV(BCData, 1);

DataFormats/Detectors/ZDC/src/BCData.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// or submit itself to any jurisdiction.
1010

1111
#include "DataFormatsZDC/BCData.h"
12+
#include "DataFormatsZDC/ChannelData.h"
1213
#include <bitset>
1314

1415
using namespace o2::zdc;
@@ -31,3 +32,9 @@ void BCData::print() const
3132
}
3233
printf("]\n");
3334
}
35+
36+
gsl::span<const ChannelData> BCData::getBunchChannelData(const gsl::span<const ChannelData> tfdata) const
37+
{
38+
// extract the span of channel data for this bunch from the whole TF data
39+
return gsl::span<const ChannelData>(&tfdata[ref.getFirstEntry()], ref.getEntries());
40+
}

Detectors/ZDC/macro/readZDCDigits.C

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,18 @@ void readZDCDigits(std::string digiFName = "zdcdigits.root")
5757
}
5858
bcd.print();
5959
//
60+
auto channels = bcd.getBunchChannelData(zdcChData);
61+
int nch = channels.size();
62+
for (int ich = 0; ich < nch; ich++) {
63+
channels[ich].print();
64+
}
65+
/* // alternative way:
6066
int chEnt = bcd.ref.getFirstEntry();
6167
for (int ic = 0; ic < bcd.ref.getEntries(); ic++) {
6268
const auto& chd = zdcChData[chEnt++];
6369
chd.print();
6470
}
71+
*/
6572
if (labelsPtr) {
6673
const auto lbl = labelsPtr->getLabels(ibc);
6774
for (int lb = 0; lb < lbl.size(); lb++) {

0 commit comments

Comments
 (0)