Skip to content

Commit e94538d

Browse files
peressounkosawenzel
authored andcommitted
Moving MCLabels from digits to global stack (AliceO2Group#2133)
* Moving MCLabels from digits to global stack * Adding MCLabel branch to tree
1 parent 276c973 commit e94538d

26 files changed

Lines changed: 637 additions & 432 deletions

Detectors/CPV/base/include/CPVBase/Digit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ class Digit : public DigitBase
8383
if (idx < kMaxLabels) {
8484
return mLabels[idx];
8585
} else {
86-
return Label();
86+
return -1;
8787
}
8888
}
8989
/// \brief Proportion of charge deposited by particle idx
9090
/// \param idx index in a list of a particles, max length kMaxLabels
9191
/// \return Proportion of energy from this particle.
92-
double getLabelEProp(int idx) const
92+
Label getLabelEProp(int idx) const
9393
{
9494
if (idx < kMaxLabels) {
9595
return mEProp[idx];

Detectors/PHOS/base/include/PHOSBase/Digit.h

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class Digit : public DigitBase
3030
using Label = o2::MCCompLabel;
3131

3232
public:
33-
static constexpr int kMaxLabels = 3; // Maximal number of MC labels associated with digit
3433
static constexpr int kTimeGate = 25; // Time in ns between digits to be added as one signal.
3534
// Should it be readout time (6000 ns???): to be tested
3635

@@ -44,7 +43,7 @@ class Digit : public DigitBase
4443
/// \brief Digit constructor from Hit
4544
/// \param PHOS Hit
4645
/// \return constructed Digit
47-
Digit(Hit hit);
46+
Digit(Hit hit, int label);
4847

4948
~Digit() = default; // override
5049

@@ -75,57 +74,36 @@ class Digit : public DigitBase
7574
void setAbsId(Int_t cellId) { mAbsId = cellId; }
7675

7776
/// \brief Energy deposited in a cell
78-
Double_t getAmplitude() const { return mAmplitude; }
79-
void setAmplitude(Double_t amplitude) { mAmplitude = amplitude; }
77+
float getAmplitude() const { return mAmplitude; }
78+
void setAmplitude(float amplitude) { mAmplitude = amplitude; }
8079

8180
/// \brief time measured in digit w.r.t. photon to PHOS arrival
82-
Double_t getTime() const { return mTime; }
83-
void setTime(Double_t time) { mTime = time; }
81+
float getTime() const { return mTime; }
82+
void setTime(float time) { mTime = time; }
8483

8584
/// \brief Checks if this digit is produced in High Gain or Low Gain channels
86-
Double_t isHighGain() const { return mIsHighGain; }
85+
bool isHighGain() const { return mIsHighGain; }
8786
void setHighGain(Bool_t isHG) { mIsHighGain = isHG; }
8887

89-
/// \brief Label of a particle made energy deposition
90-
/// \param idx index in a list of a particles, max length kMaxLabels
91-
/// \return lable of a particle. Lables are sorted according to energy deposited by each of them
92-
Label getLabel(Int_t idx) const
93-
{
94-
if (idx < kMaxLabels)
95-
return mLabels[idx];
96-
else
97-
return Label();
98-
}
99-
/// \brief Proportion of energy deposited by particle idx
100-
/// \param idx index in a list of a particles, max length kMaxLabels
101-
/// \return Proportion of energy from this particle.
102-
double getLabelEProp(Int_t idx) const
103-
{
104-
if (idx < kMaxLabels)
105-
return mEProp[idx];
106-
else
107-
return 0.;
108-
}
109-
/// \brief Number of particles assosiated with this digit
110-
int getNLabels() const { return mNlabels; }
88+
/// \brief index of entry in MCLabels array
89+
/// \return ndex of entry in MCLabels array
90+
int getLabel() const { return mLabel; }
11191

11292
void PrintStream(std::ostream& stream) const;
11393

11494
private:
11595
// friend class boost::serialization::access;
11696

117-
int mAbsId; ///< cell index (absolute cell ID)
118-
double mAmplitude; ///< Amplitude
119-
double mTime; ///< Time
120-
int mNlabels; ///< Number of actual labels in this digit
121-
Label mLabels[kMaxLabels]; ///< Particle labels associated to this digit
122-
double mEProp[kMaxLabels]; ///< Proportion of total energy deposited by given primary
123-
bool mIsHighGain; ///< High Gain or Low Gain channel (for calibration)
97+
int mAbsId; ///< cell index (absolute cell ID)
98+
int mLabel; ///< Index of the corresponding entry/entries in the MC label array
99+
float mAmplitude; ///< Amplitude
100+
float mTime; ///< Time
101+
bool mIsHighGain; ///< High Gain or Low Gain channel (for calibration)
124102

125103
ClassDefNV(Digit, 1);
126104
};
127105

128106
std::ostream& operator<<(std::ostream& stream, const Digit& dig);
129-
} // namespace PHOS
107+
} // namespace phos
130108
} // namespace o2
131109
#endif

Detectors/PHOS/base/src/Digit.cxx

Lines changed: 3 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,18 @@ using namespace o2::phos;
1515

1616
ClassImp(Digit);
1717

18-
constexpr int Digit::kMaxLabels;
19-
2018
Digit::Digit(Int_t absId, Double_t amplitude, Double_t time, Int_t label)
21-
: DigitBase(time), mAbsId(absId), mAmplitude(amplitude), mTime(time), mNlabels(0)
19+
: DigitBase(time), mAbsId(absId), mAmplitude(amplitude), mTime(time), mLabel(label)
2220
{
23-
if (label >= 0) {
24-
mLabels[0] = label; // sofar there is no lables, no need to to sort
25-
mEProp[0] = 1.;
26-
mNlabels = 1;
27-
}
2821
}
29-
Digit::Digit(Hit hit) : mAbsId(hit.GetDetectorID()), mAmplitude(hit.GetEnergyLoss()), mTime(hit.GetTime()), mNlabels(0)
22+
Digit::Digit(Hit hit, int label) : mAbsId(hit.GetDetectorID()), mAmplitude(hit.GetEnergyLoss()), mTime(hit.GetTime()), mLabel(label)
3023
{
31-
mLabels[0] = hit.GetTrackID(); // so far there is no lables, no need to to sort
32-
mEProp[0] = 1.;
33-
for (Int_t i = 1; i < kMaxLabels; i++) {
34-
mLabels[i] = -1;
35-
mEProp[i] = 0.;
36-
}
3724
}
3825
void Digit::FillFromHit(Hit hit)
3926
{
4027
mAbsId = hit.GetDetectorID();
4128
mAmplitude = hit.GetEnergyLoss();
4229
mTime = hit.GetTime();
43-
if (hit.GetTrackID() >= 0) {
44-
mLabels[0] = hit.GetTrackID(); // so far there is no lables, no need to to sort
45-
mEProp[0] = 1.;
46-
mNlabels = 1;
47-
} else {
48-
mNlabels = 0;
49-
}
50-
for (Int_t i = 1; i < kMaxLabels; i++) {
51-
mLabels[i] = 0;
52-
mEProp[i] = 0.;
53-
}
5430
}
5531

5632
bool Digit::operator<(const Digit& other) const
@@ -79,64 +55,7 @@ bool Digit::canAdd(const Digit other) const
7955
Digit& Digit::operator+=(const Digit& other)
8056
{
8157

82-
// Adds the amplitude of digits and completes the list of primary particles
83-
double scaleThis = mAmplitude / (mAmplitude + other.mAmplitude);
84-
double scaleOther = other.mAmplitude / (mAmplitude + other.mAmplitude);
85-
for (Int_t i = 0; i < mNlabels; i++) {
86-
mEProp[i] *= scaleThis;
87-
}
88-
if (other.mNlabels > 0) {
89-
// copy and scale EProp of other digit
90-
double otherEProp[kMaxLabels];
91-
for (Int_t i = 0; i < other.mNlabels; i++) {
92-
otherEProp[i] = scaleOther * other.mEProp[i];
93-
}
94-
double tmpEProp[kMaxLabels];
95-
Label tmpLabels[kMaxLabels];
96-
97-
// Now find largest Energy Proportion
98-
int i1 = 0, i2 = 0, i = 0;
99-
while (i < kMaxLabels) {
100-
if (i1 >= mNlabels) {
101-
while (i2 < other.mNlabels) {
102-
tmpEProp[i] = otherEProp[i2];
103-
tmpLabels[i] = other.mLabels[i2];
104-
i++;
105-
i2++;
106-
}
107-
break;
108-
}
109-
if (i2 >= other.mNlabels) {
110-
while (i1 < mNlabels) {
111-
tmpEProp[i] = mEProp[i1];
112-
tmpLabels[i] = mLabels[i1];
113-
i++;
114-
i1++;
115-
}
116-
break;
117-
}
118-
119-
if (mEProp[i1] > otherEProp[i2]) {
120-
tmpEProp[i] = mEProp[i1];
121-
tmpLabels[i] = mLabels[i1];
122-
i++;
123-
i1++;
124-
} else {
125-
tmpEProp[i] = otherEProp[i2];
126-
tmpLabels[i] = other.mLabels[i2];
127-
i++;
128-
i2++;
129-
}
130-
}
131-
// Copy to current digit
132-
for (Int_t ii = 0; ii < i; ii++) {
133-
mEProp[ii] = tmpEProp[ii];
134-
mLabels[ii] = tmpLabels[ii];
135-
}
136-
}
137-
138-
mNlabels = std::min(kMaxLabels, other.mNlabels + mNlabels);
139-
58+
// Adds the amplitude of digits
14059
// TODO: What about time? Should we assign time of more energetic digit? More complicated treatment?
14160
if (mAmplitude < other.mAmplitude) {
14261
mTime = other.mTime;

Detectors/PHOS/reconstruction/src/Cluster.cxx

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -326,26 +326,13 @@ void Cluster::EvalPrimaries(const std::vector<Digit>* digits)
326326
continue;
327327
}
328328

329-
for (int iPrim = 0; iPrim < (*foundIt).getNLabels(); iPrim++) {
330-
Label lab = (*foundIt).getLabel(iPrim);
331-
double eProp = (*foundIt).getLabelEProp(iPrim);
332-
// look through list of primaries, add proportion of energy if already there, else create new entry
333-
int primListSize = mLabels.size();
334-
bool found = false;
335-
for (int inPrimList = 0; inPrimList < primListSize; inPrimList++) {
336-
if (lab == mLabels[inPrimList]) { // already exist, increase proportin of energy
337-
mLabelsEProp[inPrimList] += eProp * foundIt->getAmplitude() / mFullEnergy;
338-
found = true;
339-
break;
340-
}
341-
}
342-
if (!found) {
343-
mLabelsEProp.push_back(lab);
344-
mLabelsEProp.push_back(eProp * ((*foundIt).getAmplitude()) / mFullEnergy);
345-
}
346-
}
329+
//int lab = (*foundIt).getLabel(); //index of entry in MCLabels array
330+
//Add Labels to list of primaries
331+
//....
332+
//TODO!!!!
347333
}
348334
// Vectors will not be modified any more.
335+
//TODO: sort and add labels
349336
mLabels.shrink_to_fit();
350337
mLabelsEProp.shrink_to_fit();
351338
}

Detectors/PHOS/simulation/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010

1111
o2_add_library(PHOSSimulation
1212
SOURCES src/Detector.cxx src/GeometryParams.cxx src/Digitizer.cxx
13-
src/DigitizerTask.cxx
13+
src/DigitizerTask.cxx src/PHOSSimParams.cxx
1414
PUBLIC_LINK_LIBRARIES O2::DetectorsBase O2::PHOSBase)
1515

1616
o2_target_root_dictionary(PHOSSimulation
1717
HEADERS include/PHOSSimulation/Detector.h
1818
include/PHOSSimulation/GeometryParams.h
1919
include/PHOSSimulation/Digitizer.h
20-
include/PHOSSimulation/DigitizerTask.h)
20+
include/PHOSSimulation/DigitizerTask.h
21+
include/PHOSSimulation/PHOSSimParams.h
22+
include/PHOSSimulation/MCLabel.h)

Detectors/PHOS/simulation/include/PHOSSimulation/Detector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ class Detector : public o2::base::DetImpl<Detector>
193193
friend class o2::base::DetImpl;
194194
ClassDefOverride(Detector, 1)
195195
};
196-
}
197-
}
196+
} // namespace phos
197+
} // namespace o2
198198

199199
#ifdef USESHM
200200
namespace o2

Detectors/PHOS/simulation/include/PHOSSimulation/Digitizer.h

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "PHOSBase/Digit.h"
1515
#include "PHOSBase/Geometry.h"
1616
#include "PHOSBase/Hit.h"
17+
#include "PHOSSimulation/MCLabel.h"
18+
#include "SimulationDataFormat/MCTruthContainer.h"
1719

1820
namespace o2
1921
{
@@ -31,7 +33,7 @@ class Digitizer : public TObject
3133
void finish();
3234

3335
/// Steer conversion of hits to digits
34-
void process(const std::vector<Hit>& hits, std::vector<Digit>& digits);
36+
void process(const std::vector<Hit>& hits, std::vector<Digit>& digits, o2::dataformats::MCTruthContainer<o2::phos::MCLabel>& labels);
3537

3638
void setEventTime(double t);
3739
double getEventTime() const { return mEventTime; }
@@ -51,41 +53,24 @@ class Digitizer : public TObject
5153
void setCoeffToNanoSecond(double c) { mCoeffToNanoSecond = c; }
5254

5355
protected:
54-
Double_t NonLinearity(Double_t e);
55-
Double_t DigitizeEnergy(Double_t e);
56-
Double_t Decalibrate(Double_t e);
57-
Double_t TimeResolution(Double_t time, Double_t e);
58-
Double_t SimulateNoiseEnergy();
59-
Double_t SimulateNoiseTime();
56+
double NonLinearity(double e);
57+
double DigitizeEnergy(double e);
58+
double Decalibrate(double e);
59+
double TimeResolution(double time, double e);
60+
double SimulateNoiseEnergy();
61+
double SimulateNoiseTime();
6062

6163
private:
6264
const Geometry* mGeometry = nullptr; //! PHOS geometry
6365
double mEventTime = 0; ///< global event time
6466
double mCoeffToNanoSecond = 1.0; ///< coefficient to convert event time (Fair) to ns
6567
bool mContinuous = false; ///< flag for continuous simulation
66-
UInt_t mROFrameMin = 0; ///< lowest RO frame of current digits
67-
UInt_t mROFrameMax = 0; ///< highest RO frame of current digits
68+
uint mROFrameMin = 0; ///< lowest RO frame of current digits
69+
uint mROFrameMax = 0; ///< highest RO frame of current digits
6870
int mCurrSrcID = 0; ///< current MC source from the manager
6971
int mCurrEvID = 0; ///< current event ID from the manager
70-
bool mApplyNonLinearity = true; ///< if Non-linearity will be applied
71-
bool mApplyDigitization = true; ///< if energy digitization should be applied
72-
bool mApplyDecalibration = false; ///< if de-calibration should be applied
73-
bool mApplyTimeResolution = true; ///< if Hit time should be smeared
74-
double mZSthreshold = 0.005; ///< Zero Suppression threshold
75-
double maNL = 0.04; ///< Parameter a for Non-Linearity
76-
double mbNL = 0.2; ///< Parameter b for Non-Linearity
77-
double mcNL = 1.; ///< Parameter c for Non-Linearity
78-
double mADCWidth = 0.005; ///< Widht of ADC channel used for energy digitization
79-
double mTimeResolutionA = 2.; ///< Time resolution parameter A (in ns)
80-
double mTimeResolutionB = 2.; ///< Time resolution parameter B (in ns/GeV)
81-
double mTimeResThreshold = 0.5; ///< threshold for time resolution calculation (in GeV)
82-
double mAPDNoise = 0.005; ///< Electronics (and APD) noise (in GeV)
83-
double mMinNoiseTime = -200.; ///< minimum time in noise channels (in ns)
84-
double mMaxNoiseTime = 2000.; ///< minimum time in noise channels (in ns)
8572

86-
// std::unordered_map<Int_t, std::deque<Digit>> mDigits; ///< used to sort digits by tower
87-
88-
ClassDefOverride(Digitizer, 1);
73+
ClassDefOverride(Digitizer, 2);
8974
};
9075
} // namespace phos
9176
} // namespace o2

Detectors/PHOS/simulation/include/PHOSSimulation/DigitizerTask.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ class DigitizerTask : public FairTask
3838
double getFairTimeUnitInNS() const { return mFairTimeUnitInNS; }
3939

4040
private:
41-
double mFairTimeUnitInNS = 1; ///< Fair time unit in ns
42-
Int_t mSourceID = 0; ///< current source
43-
Int_t mEventID = 0; ///< current event id from the source
44-
Digitizer mDigitizer; ///< Digitizer
45-
const std::vector<Hit>* mHitsArray = nullptr; ///< Array of MC hits
46-
std::vector<Digit>* mDigitsArray = nullptr; ///< Array of digits
47-
48-
ClassDefOverride(DigitizerTask, 1);
41+
double mFairTimeUnitInNS = 1; ///< Fair time unit in ns
42+
Int_t mSourceID = 0; ///< current source
43+
Int_t mEventID = 0; ///< current event id from the source
44+
Digitizer mDigitizer; ///< Digitizer
45+
const std::vector<Hit>* mHitsArray = nullptr; ///< Array of MC hits
46+
std::vector<Digit>* mDigitsArray = nullptr; ///< Array of digits
47+
o2::dataformats::MCTruthContainer<o2::phos::MCLabel>* mLabels = nullptr; ///< Array of digit labels
48+
49+
ClassDefOverride(DigitizerTask, 2);
4950
};
5051
} // namespace phos
5152
} // namespace o2

0 commit comments

Comments
 (0)