Skip to content

Commit a425eea

Browse files
cortesepshahor02
authored andcommitted
Multiple fixes for ZDC, raw data creation (former PR4658 from P.Cortese)
Cleaned up, rebased to dev and squashed
1 parent eca708b commit a425eea

File tree

15 files changed

+1266
-18
lines changed

15 files changed

+1266
-18
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
//
11+
// DataFormats/Detectors/ZDC/include/DataFormatsZDC/RawEventData.h
12+
13+
#ifndef ALICEO2_ZDC_RAWEVENTDATA_H_
14+
#define ALICEO2_ZDC_RAWEVENTDATA_H_
15+
#include "CommonDataFormat/InteractionRecord.h"
16+
#include "CommonDataFormat/RangeReference.h"
17+
#include "ZDCBase/Constants.h"
18+
#include <Rtypes.h>
19+
#include <iostream>
20+
#include <gsl/span>
21+
22+
/// \file RawEventData.h
23+
/// \brief Container of ZDC raw data
24+
/// \author pietro.cortese@cern.ch
25+
26+
namespace o2
27+
{
28+
namespace zdc
29+
{
30+
31+
constexpr unsigned short Id_w0 = 0x0;
32+
constexpr unsigned short Id_w1 = 0x1;
33+
constexpr unsigned short Id_w2 = 0x2;
34+
constexpr int NWPerGBTW = 4;
35+
36+
struct __attribute__((__packed__)) ChannelDataV0 {
37+
// First GBT word
38+
unsigned fixed_0 : 2;
39+
unsigned board : 4;
40+
unsigned ch : 2;
41+
unsigned offset : 16;
42+
unsigned hits : 12;
43+
unsigned bc : 12;
44+
unsigned orbit : 32;
45+
unsigned empty_0 : 16;
46+
unsigned empty_1 : 32;
47+
48+
// Second GBT word
49+
unsigned fixed_1 : 2;
50+
unsigned error : 2;
51+
unsigned Alice_0 : 1;
52+
unsigned Alice_1 : 1;
53+
unsigned Alice_2 : 1;
54+
unsigned Alice_3 : 1;
55+
unsigned s00 : 12;
56+
unsigned s01 : 12;
57+
unsigned s02 : 12;
58+
unsigned s03 : 12;
59+
unsigned s04 : 12;
60+
unsigned s05 : 12;
61+
unsigned empty_2 : 16;
62+
unsigned empty_3 : 32;
63+
64+
// Third GBT word
65+
unsigned fixed_2 : 2;
66+
unsigned Hit : 1;
67+
unsigned Auto_m : 1;
68+
unsigned Auto_0 : 1;
69+
unsigned Auto_1 : 1;
70+
unsigned Auto_2 : 1;
71+
unsigned Auto_3 : 1;
72+
unsigned s06 : 12;
73+
unsigned s07 : 12;
74+
unsigned s08 : 12;
75+
unsigned s09 : 12;
76+
unsigned s10 : 12;
77+
unsigned s11 : 12;
78+
unsigned empty_4 : 16;
79+
unsigned empty_5 : 32;
80+
};
81+
82+
struct EventData {
83+
union {
84+
UInt_t w[NWPerBc][NWPerGBTW];
85+
struct ChannelDataV0 f;
86+
} data[NModules][NChPerModule] = {0};
87+
void print() const;
88+
void reset();
89+
ClassDefNV(EventData, 1);
90+
};
91+
92+
} // namespace zdc
93+
} // namespace o2
94+
#endif

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct RecEvent {
3131

3232
o2::InteractionRecord ir;
3333
uint32_t flags; /// reconstruction flags
34-
std::array<float, NChannelsZEM> eneregyZEM; /// signal in the electromagnetic ZDCs
34+
std::array<float, NChannelsZEM> energyZEM; /// signal in the electromagnetic ZDCs
3535
std::array<float, NChannelsZN> energyZNA; /// reco E in 5 ZNA sectors + sum
3636
std::array<float, NChannelsZN> energyZNC; /// reco E in 5 ZNC sectors + sum
3737
std::array<float, NChannelsZP> energyZPA; /// reco E in 5 ZPA sectors + sum

DataFormats/Detectors/ZDC/src/BCData.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ using namespace o2::zdc;
1616

1717
void BCData::print() const
1818
{
19-
ir.print();
20-
printf("%d channels starting from %d\n", ref.getEntries(), ref.getFirstEntry());
19+
printf("Orbit %9u bc %4u nch %2d pos %d\n", ir.orbit, ir.bc, ref.getEntries(), ref.getFirstEntry());
2120
printf("Read:");
2221
for (int ic = 0; ic < NDigiChannels; ic++) {
2322
if (ic % NChPerModule == 0) {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
// DataFormats/Detectors/ZDC/src/RawEventData.cxx
11+
#include "DataFormatsZDC/RawEventData.h"
12+
13+
using namespace o2::zdc;
14+
15+
//ClassImp(EventData);
16+
17+
//______________________________________________________________________________
18+
void EventData::print() const
19+
{
20+
for (Int_t im = 0; im < o2::zdc::NModules; im++) {
21+
for (Int_t ic = 0; ic < o2::zdc::NChPerModule; ic++) {
22+
if (data[im][ic].f.fixed_0 == Id_w0 && data[im][ic].f.fixed_1 == Id_w1 && data[im][ic].f.fixed_2 == Id_w2) {
23+
// Not empty event
24+
auto f = data[im][ic].f;
25+
// Word 0
26+
printf("%04x %08x %08x ", data[im][ic].w[0][2], data[im][ic].w[0][1], data[im][ic].w[0][0]);
27+
printf("orbit %-9u bc %-4u hits %-4u offset %+6i Board %2u Ch %1u\n", f.orbit, f.bc, f.hits, f.offset, f.ch, f.board);
28+
// Word 1
29+
printf("%04x %08x %08x ", data[im][ic].w[1][2], data[im][ic].w[1][1], data[im][ic].w[1][0]);
30+
printf(" %s %s %s %s 0-5 ", f.Alice_0 ? "A0" : " ", f.Alice_1 ? "A1" : " ", f.Alice_2 ? "A2" : " ", f.Alice_3 ? "A3" : " ");
31+
printf(" %5d %5d %5d %5d %5d %5d EC=%u\n", f.s00, f.s01, f.s02, f.s03, f.s04, f.s05, f.error);
32+
// Word 2
33+
printf("%04x %08x %08x ", data[im][ic].w[2][2], data[im][ic].w[2][1], data[im][ic].w[2][0]);
34+
printf("%s %s %s %s %s %s 6-b ", f.Hit ? "H" : " ", f.Auto_m ? "TM" : " ", f.Auto_0 ? "T0" : " ", f.Auto_1 ? "T1" : " ", f.Auto_2 ? "T2" : " ", f.Auto_3 ? "T3" : " ");
35+
printf(" %5d %5d %5d %5d %5d %5d\n", f.s06, f.s07, f.s08, f.s09, f.s10, f.s11);
36+
} else if (data[im][ic].f.fixed_0 == 0 && data[im][ic].f.fixed_1 == 0 && data[im][ic].f.fixed_2 == 0) {
37+
// Empty channel
38+
} else {
39+
// Wrong data format. Insert warning.
40+
}
41+
}
42+
}
43+
}
44+
45+
//______________________________________________________________________________
46+
void EventData::reset()
47+
{
48+
static constexpr int payloadSize = NModules * NChPerModule * NWPerGBTW * sizeof(UInt_t);
49+
memset((void*)&data[0][0], 0, payloadSize);
50+
}

Detectors/ZDC/base/include/ZDCBase/Constants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ constexpr uint8_t ALICETriggerMask = 0x1;
5555

5656
constexpr int NModules = 8;
5757
constexpr int NChPerModule = 4;
58+
constexpr int NLinks = NModules * 2;
5859
constexpr int NDigiChannels = NModules * NChPerModule;
5960
constexpr int NWPerBc = 3;
6061
constexpr int MaxTriggerChannels = NChannels;
62+
constexpr int ADCMin = -2048, ADCMax = 2047, ADCRange = 4096; // 12 bit ADC
6163

6264
constexpr int MaxTDCValues = 5; // max number of TDC values to store in reconstructed event
6365
constexpr int NTDCChannels = 10; // max number of TDC values to store in reconstructed event

Detectors/ZDC/base/include/ZDCBase/ModuleConfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ struct Module {
3434
static constexpr int MaxChannels = 4, MaxTriggChannels = 2;
3535
int id = -1; // not active
3636
std::array<int8_t, MaxChannels> channelID = {IdDummy, IdDummy, IdDummy, IdDummy};
37-
std::array<int16_t, MaxChannels> linkID = {-1, -1, -1, -1};
37+
std::array<int16_t, MaxChannels> feeID = {-1, -1, -1, -1};
3838
std::array<bool, MaxChannels> readChannel = {false};
3939
std::array<bool, MaxChannels> trigChannel = {false};
4040
std::array<TriggerChannelConfig, MaxChannels> trigChannelConf;
4141

42-
void setChannel(int slot, int8_t chID, int16_t lID, bool read, bool trig = false, int tF = 0, int tL = 0, int tS = 0, int tT = 0);
42+
void setChannel(int slot, int8_t chID, int16_t fID, bool read, bool trig = false, int tF = 0, int tL = 0, int tS = 0, int tT = 0);
4343
void print() const;
4444
void printCh() const;
4545
void printTrig() const;

Detectors/ZDC/base/src/ModuleConfig.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ using namespace o2::zdc;
1616

1717
void Module::printCh() const
1818
{
19-
printf("Module %d [ChID/LinkID R:T ]", id);
19+
printf("Module %d [ChID/FEEID R:T ]", id);
2020
for (int ic = 0; ic < MaxChannels; ic++) {
21-
printf("[%s{%2d}/L%02d %c:%c ]", channelName(channelID[ic]), channelID[ic], linkID[ic], readChannel[ic] ? 'R' : ' ', trigChannel[ic] ? 'T' : ' ');
21+
printf("[%s{%2d}/L%02d %c:%c ]", channelName(channelID[ic]), channelID[ic], feeID[ic], readChannel[ic] ? 'R' : ' ', trigChannel[ic] ? 'T' : ' ');
2222
}
2323
printf("\n");
2424
}
@@ -78,13 +78,13 @@ void Module::check() const
7878
}
7979
}
8080

81-
void Module::setChannel(int slot, int8_t chID, int16_t lID, bool read, bool trig, int tF, int tL, int tS, int tT)
81+
void Module::setChannel(int slot, int8_t chID, int16_t fID, bool read, bool trig, int tF, int tL, int tS, int tT)
8282
{
8383
if (slot < 0 || slot >= MaxChannels || chID < 0 || chID > NChannels) {
84-
LOG(FATAL) << "Improper module channel settings" << slot << ' ' << chID << ' ' << lID << ' ' << read << ' ' << trig
84+
LOG(FATAL) << "Improper module channel settings" << slot << ' ' << chID << ' ' << fID << ' ' << read << ' ' << trig
8585
<< ' ' << tF << ' ' << tL << ' ' << tS << ' ' << tT;
8686
}
87-
linkID[slot] = lID;
87+
feeID[slot] = fID;
8888
channelID[slot] = chID;
8989
readChannel[slot] = read;
9090
// In the 2020 firmware implementation, autotrigger bits are computed for each channel

Detectors/ZDC/macro/CreateModuleConfig.C

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ void CreateModuleConfig(long tmin = 0, long tmax = -1,
3333

3434
//-------------------------------------------
3535
// Up to 8 modules with four channels
36-
// setChannel(int slot, int8_t chID, int16_t lID, bool read, bool trig = false, int tF = 0, int tL = 0, int tS = 0, int tT = 0)
36+
// setChannel(int slot, int8_t chID, int16_t fID, bool read, bool trig = false, int tF = 0, int tL = 0, int tS = 0, int tT = 0)
3737
// module id must be in the range 0-7
3838
// channel id must be in range 0-3
39+
// frontend id must be in range 0-15 and identify the pair of channels connected to
40+
// each fibre
3941
{
4042
modID = 0;
4143
auto& module = conf.modules[modID];

Detectors/ZDC/simulation/CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
o2_add_library(ZDCSimulation
1212
SOURCES src/Detector.cxx src/Digitizer.cxx src/SimCondition.cxx
13-
src/ZDCSimParam.cxx src/SpatialPhotonResponse.cxx
14-
PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat O2::ZDCBase
15-
O2::DataFormatsZDC O2::CCDB O2::SimConfig)
13+
src/ZDCSimParam.cxx src/SpatialPhotonResponse.cxx src/Digits2Raw.cxx
14+
PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat O2::ZDCBase
15+
O2::DataFormatsZDC O2::CCDB O2::SimConfig
16+
O2::DetectorsRaw O2::Headers)
1617

1718
o2_target_root_dictionary(ZDCSimulation
1819
HEADERS include/ZDCSimulation/Hit.h
@@ -23,3 +24,12 @@ o2_target_root_dictionary(ZDCSimulation
2324
include/ZDCSimulation/SpatialPhotonResponse.h)
2425

2526
o2_data_file(COPY data DESTINATION Detectors/ZDC/simulation)
27+
28+
o2_add_executable(digi2raw
29+
COMPONENT_NAME zdc
30+
SOURCES src/digi2raw.cxx
31+
PUBLIC_LINK_LIBRARIES O2::ZDCSimulation
32+
O2::DetectorsRaw
33+
O2::DetectorsCommonDataFormats
34+
O2::CommonUtils
35+
Boost::program_options)

Detectors/ZDC/simulation/include/ZDCSimulation/Digitizer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ class Digitizer
110110

111111
private:
112112
static constexpr int BCCacheMin = -1, BCCacheMax = 5, NBC2Cache = 1 + BCCacheMax - BCCacheMin;
113-
static constexpr int ADCMin = -2048, ADCMax = 2047; // 12 bit ADC
114113

115114
std::bitset<NChannels> chanPattern(uint32_t v) const
116115
{

0 commit comments

Comments
 (0)