Skip to content

Commit 01b5987

Browse files
committed
ZDC digitization in continuous mode
1 parent 1bf400e commit 01b5987

File tree

12 files changed

+463
-136
lines changed

12 files changed

+463
-136
lines changed

DataFormats/common/src/InteractionRecord.cxx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,27 @@
1313
namespace o2
1414
{
1515

16+
std::ostream& operator<<(std::ostream& stream, o2::InteractionRecord const& ir)
17+
{
18+
stream << "BCid: " << ir.bc << " Orbit: " << ir.orbit;
19+
return stream;
20+
}
21+
22+
std::ostream& operator<<(std::ostream& stream, o2::InteractionTimeRecord const& ir)
23+
{
24+
stream << "BCid: " << ir.bc << " Orbit: " << ir.orbit << " T(ns): " << ir.timeNS;
25+
return stream;
26+
}
27+
1628
void InteractionRecord::print() const
1729
{
18-
std::cout << "BCid: " << bc << " Orbit: " << orbit << std::endl;
30+
std::cout << (*this) << std::endl;
1931
}
2032

33+
2134
void InteractionTimeRecord::print() const
2235
{
23-
std::cout << "BCid: " << bc << " Orbit: " << orbit << " T(ns): " << timeNS << std::endl;
36+
std::cout << (*this) << std::endl;
2437
}
2538

2639
} // namespace o2
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
#ifndef ALICEO2_ZDC_CONSTANTS_H
12+
#define ALICEO2_ZDC_CONSTANTS_H
13+
14+
#include "CommonConstants/PhysicsConstants.h"
15+
16+
namespace o2
17+
{
18+
namespace zdc
19+
{
20+
21+
enum DetectorID { DetIDOffs = 1,
22+
ZNA = 1,
23+
ZPA = 2,
24+
ZEM = 3,
25+
ZNC = 4,
26+
ZPC = 5 }; // IDs of subdetector
27+
enum ChannelTypeZNP { Common,
28+
Ch1,
29+
Ch2,
30+
Ch3,
31+
Ch4,
32+
Sum }; // channel IDs for ZN and ZP
33+
enum ChannelTypeZEM { ZEMCh1,
34+
ZEMCh2 }; // channel IDs for ZEMs
35+
36+
constexpr int NTimeBinsPerBC = 12; //< number of samples per BC
37+
constexpr int NBCBefore = 1; //< number of BCs read before the triggered BC
38+
constexpr int NBCAfter = 2; //< number of BCs read after the triggered BC
39+
constexpr int NBCReadOut = 1 + NBCBefore + NBCAfter; // N BCs read out per trigger
40+
41+
constexpr int NChannelsZN = 6; //< number of channels stored per ZN
42+
constexpr int NChannelsZP = 6; //< number of channels stored per ZP
43+
constexpr int NChannelsZEM = 2; //< number of channels stored per ZEM
44+
45+
constexpr float ChannelTimeBinNS = 2.; //< bin length in NS
46+
constexpr float SampleLenghtNS = NTimeBinsPerBC * ChannelTimeBinNS;
47+
48+
constexpr int NChannels = 2 * (NChannelsZN + NChannelsZP) + NChannelsZEM;
49+
50+
//< get detector TOF correction in ns
51+
constexpr float getTOFCorrection(int det)
52+
{
53+
constexpr float TOFCorr[5] = {
54+
11253.3 / o2::constants::physics::LightSpeedCm2NS,
55+
11251.8 / o2::constants::physics::LightSpeedCm2NS,
56+
760. / o2::constants::physics::LightSpeedCm2NS,
57+
11261.3 / o2::constants::physics::LightSpeedCm2NS,
58+
11253.3 / o2::constants::physics::LightSpeedCm2NS
59+
};
60+
return TOFCorr[det - DetIDOffs];
61+
}
62+
63+
//< map detector/tower to continuous channel ID
64+
constexpr int toChannel(int det, int tower)
65+
{
66+
constexpr int DetChMap[5][6] = { { 0, 1, 2, 3, 4, 5 }, // ZNA
67+
{ 6, 7, 8, 9, 10, 11 }, // ZPA
68+
{ 12, 13, -1, -1, -1, -1 }, // ZEM
69+
{ 14, 15, 16, 17, 18, 19 }, // ZNC
70+
{ 20, 21, 22, 23, 24, 25 } }; // ZPC
71+
return DetChMap[det - 1][tower];
72+
}
73+
74+
//< map channelID to detector/tower
75+
constexpr int toDet(int channel, int& tower)
76+
{
77+
if (channel < toChannel(ZNC, 0)) {
78+
tower = channel % NChannelsZN;
79+
return DetIDOffs + channel / NChannelsZP;
80+
} else {
81+
channel -= toChannel(ZNC, 0);
82+
tower = channel % NChannelsZN;
83+
return ZNC + channel / NChannelsZP;
84+
}
85+
}
86+
87+
} // namespace zdc
88+
} // namespace o2
89+
90+
#endif

Detectors/ZDC/simulation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ O2_SETUP(NAME ${MODULE_NAME})
55
set(SRCS
66
src/Detector.cxx
77
src/Digitizer.cxx
8+
src/Digit.cxx
89
)
910
set(HEADERS
1011
include/${MODULE_NAME}/Hit.h

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

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,54 @@
1414
#ifndef ALICEO2_ZDC_DIGIT_H_
1515
#define ALICEO2_ZDC_DIGIT_H_
1616

17-
#include "CommonDataFormat/TimeStamp.h"
17+
#include "CommonDataFormat/InteractionRecord.h"
18+
#include "ZDCBase/Constants.h"
19+
#include <array>
1820

1921
namespace o2
2022
{
2123
namespace zdc
2224
{
23-
using DigitBase = o2::dataformats::TimeStamp<double>;
24-
class Digit : public DigitBase
25+
26+
struct ChannelBCData {
27+
std::array<uint16_t, NTimeBinsPerBC> data = { 0 };
28+
};
29+
30+
struct ChannelData {
31+
std::array<ChannelBCData, NBCReadOut> data = {};
32+
};
33+
34+
class Digit
2535
{
2636
public:
2737
Digit() = default;
2838

29-
void add(short adc) { mADC += adc; }
30-
void setDetInfo(char detID, char sectorID)
31-
{
32-
mDetID = detID;
33-
mSecID = sectorID;
34-
}
35-
short getADC() const { return mADC; }
36-
short getDetID() const { return mDetID; }
37-
short getSector() const { return mSecID; }
39+
const ChannelBCData& getChannel(int ch, int bc) const { return mChannels[ch].data[bc]; }
40+
ChannelBCData& getChannel(int ch, int bc) { return mChannels[ch].data[bc]; }
41+
42+
const ChannelBCData& getZNA(int twr, int bc) const { return mChannels[toChannel(ZNA, twr)].data[bc]; }
43+
ChannelBCData& getZNA(int twr, int bc) { return mChannels[toChannel(ZNA, twr)].data[bc]; }
44+
45+
const ChannelBCData& getZPA(int twr, int bc) const { return mChannels[toChannel(ZPA, twr)].data[bc]; }
46+
ChannelBCData& getZPA(int twr, int bc) { return mChannels[toChannel(ZPA, twr)].data[bc]; }
47+
48+
const ChannelBCData& getZNC(int twr, int bc) const { return mChannels[toChannel(ZNC, twr)].data[bc]; }
49+
ChannelBCData& getZNC(int twr, int bc) { return mChannels[toChannel(ZNC, twr)].data[bc]; }
50+
51+
const ChannelBCData& getZPC(int twr, int bc) const { return mChannels[toChannel(ZPC, twr)].data[bc]; }
52+
ChannelBCData& getZPC(int twr, int bc) { return mChannels[toChannel(ZPC, twr)].data[bc]; }
53+
54+
const ChannelBCData& getZEM(int twr, int bc) const { return mChannels[toChannel(ZEM, twr)].data[bc]; }
55+
ChannelBCData& getZEM(int twr, int bc) { return mChannels[toChannel(ZEM, twr)].data[bc]; }
56+
57+
const o2::InteractionRecord& getInteractionRecord() const { return mIntRecord; }
58+
o2::InteractionRecord& getInteractionRecord() { return mIntRecord; }
59+
60+
void print() const;
3861

3962
private:
40-
short mADC = 0; // adc amplitude value ~ charge
41-
// potentially generalize to have complete signal shape
42-
char mDetID = -1;
43-
char mSecID = -1; // sector x channel information where this digit is recorded ((0 to 4) x (0 to 5))
63+
std::array<ChannelData, NChannels> mChannels = {};
64+
o2::InteractionRecord mIntRecord;
4465

4566
ClassDefNV(Digit, 1);
4667
};

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

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
#include "ZDCSimulation/Digit.h"
1515
#include "ZDCSimulation/Hit.h" // for the hit
16+
#include "ZDCSimulation/MCLabel.h"
1617
#include "SimulationDataFormat/MCTruthContainer.h"
17-
#include "SimulationDataFormat/MCCompLabel.h"
18+
#include "CommonDataFormat/InteractionRecord.h"
1819
#include <vector>
20+
#include <deque>
1921

2022
namespace o2
2123
{
@@ -25,46 +27,41 @@ namespace zdc
2527
class Digitizer
2628
{
2729
public:
30+
struct ChannelBCDataF { // float (accumulable) version of the ChannelBCData
31+
std::array<float, NTimeBinsPerBC> data = { 0.f };
32+
};
33+
struct ChannelDataF { // float (accumulable) version of the ChannelData
34+
std::array<ChannelBCDataF, NBCReadOut> data = {};
35+
};
36+
struct BCCache {
37+
std::array<ChannelBCDataF, NChannels> bcdata;
38+
std::vector<o2::zdc::MCLabel> labels;
39+
o2::InteractionRecord intRecord;
40+
};
41+
2842
// set event time
29-
void setEventTime(double timeNS) { mEventTime = timeNS; }
3043
void setEventID(int eventID) { mEventID = eventID; }
3144
void setSrcID(int sID) { mSrcID = sID; }
45+
void setInteractionRecord(const o2::InteractionTimeRecord& ir) { mIR = ir; }
3246

33-
// user can pass a label container to be filled ... this activates the label mechanism
34-
// the passed label container can be readout after call to process
35-
void setLabelContainer(o2::dataformats::MCTruthContainer<o2::MCCompLabel>* labels)
36-
{
37-
mRegisteredLabelContainer = labels;
38-
}
39-
40-
short fromPhotoelectronsToACD(int nphotoelectrons) const { return nphotoelectrons * (-0.0333333); } // TODO: implement real conversion method
47+
void process(const std::vector<o2::zdc::Hit>& hits,
48+
std::vector<o2::zdc::Digit>& digits,
49+
o2::dataformats::MCTruthContainer<o2::zdc::MCLabel>& labels);
4150

42-
int toChannel(char detID, char secID) const { return detID * 5 + secID; }
51+
void flush(std::vector<o2::zdc::Digit>& digits, o2::dataformats::MCTruthContainer<o2::zdc::MCLabel>& labels);
4352

44-
// this will process hits and fill the digit vector with digits which are finalized
45-
void process(std::vector<o2::zdc::Hit> const&, std::vector<o2::zdc::Digit>& digit);
46-
47-
void zeroSuppress(std::vector<o2::zdc::Digit> const& digits, std::vector<o2::zdc::Digit>& newdigits,
48-
o2::dataformats::MCTruthContainer<o2::MCCompLabel> const& labels,
49-
o2::dataformats::MCTruthContainer<o2::MCCompLabel>* newlabels);
53+
private:
54+
void phe2Sample(int nphe, double timeInSample, ChannelBCDataF& sample) const;
55+
int createDigit(std::vector<o2::zdc::Digit>& digits, o2::dataformats::MCTruthContainer<o2::zdc::MCLabel>& labels, int cachedID);
56+
BCCache& getCreateBCCache(const o2::InteractionRecord& ir);
5057

51-
// flush accumulated digits into the given container
52-
void flush(std::vector<o2::zdc::Digit>& digit);
53-
// reset internal data structures
54-
void reset();
58+
bool NeedToTrigger(const BCCache& bc) const; // TODO
5559

56-
private:
57-
double mEventTime = 0;
5860
int mEventID = 0;
5961
int mSrcID = 0;
62+
o2::InteractionTimeRecord mIR;
6063

61-
std::vector<o2::zdc::Digit> mDigits; // internal store for digits
62-
63-
// other stuff needed for digitization
64-
o2::dataformats::MCTruthContainer<o2::MCCompLabel> mTmpLabelContainer; // temp label container as workspace
65-
o2::dataformats::MCTruthContainer<o2::MCCompLabel>* mRegisteredLabelContainer = nullptr; // label container to be filled
66-
67-
float getThreshold(o2::zdc::Digit const& digiti) const;
64+
std::deque<BCCache> mCache; // cached BCs data
6865

6966
ClassDefNV(Digitizer, 1);
7067
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Hit : public o2::BasicXYZEHit<Float_t, Float_t>
5252
void setPMQLightYield(float val) { mNphePMQ = val; }
5353
void setNoNumContributingSteps(int val) { mNoContributingSteps = val; }
5454

55+
int getParentID() const { return mParentID; }
5556
int getSector() const { return mSectorID; }
5657
float getPMCLightYield() const { return mNphePMC; }
5758
float getPMQLightYield() const { return mNphePMQ; }
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
// Declaration of a transient MC label class for ZDC
12+
13+
#ifndef ALICEO2_ZDC_MCLABEL_H_
14+
#define ALICEO2_ZDC_MCLABEL_H_
15+
16+
#include "SimulationDataFormat/MCCompLabel.h"
17+
18+
namespace o2
19+
{
20+
namespace zdc
21+
{
22+
class MCLabel : public o2::MCCompLabel
23+
{
24+
private:
25+
Int_t mChannel = -1;
26+
27+
public:
28+
MCLabel() = default;
29+
MCLabel(Int_t trackID, Int_t eventID, Int_t srcID, Int_t chID)
30+
: o2::MCCompLabel(trackID, eventID, srcID), mChannel(chID) {}
31+
32+
Int_t getChannel() const { return mChannel; }
33+
34+
ClassDefNV(MCLabel, 1);
35+
};
36+
} // namespace zdc
37+
} // namespace o2
38+
39+
#endif
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
#include "ZDCSimulation/Digit.h"
12+
#include "ZDCBase/Constants.h"
13+
14+
/// \file Digit.cxx
15+
16+
using namespace o2::zdc;
17+
18+
void Digit::print() const
19+
{
20+
21+
const char* nameDet[] = { "ZNA", "ZPA", "ZEM", "ZNC", "ZPC" };
22+
const char* namesZH[] = { "Com", "Ch1", "Ch2", "Ch3", "Ch4", "Sum" };
23+
const char* namesZE[] = { "Ch1", "Ch2" };
24+
25+
mIntRecord.print();
26+
27+
for (int id = 0; id < 5; id++) {
28+
int idet = id + 1;
29+
const char** nameChan = idet == ZEM ? namesZE : namesZH;
30+
int nChan = idet == ZEM ? NChannelsZEM : NChannelsZN;
31+
32+
for (int ic = 0; ic < nChan; ic++) {
33+
for (int slot = 0; slot < 4; slot++) {
34+
const auto& slotData = getChannel(toChannel(idet, ic), slot);
35+
printf("%3s:%-3s/%d |", nameDet[id], nameChan[ic], slot);
36+
for (int ib = 0; ib < NTimeBinsPerBC; ib++) {
37+
printf("%5d ", slotData.data[ib]);
38+
}
39+
printf("\n");
40+
}
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)