Skip to content

Commit d800da6

Browse files
commit 2: updated digitisation at the chip level (still need to figure out the proper way to clean up the extra digits)
1 parent fb06b06 commit d800da6

9 files changed

Lines changed: 342 additions & 57 deletions

File tree

Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef ALICEO2_IOTOF_DIGIT_H
2020
#define ALICEO2_IOTOF_DIGIT_H
2121

22+
#include "SimulationDataFormat/MCCompLabel.h"
2223
#include "DataFormatsITSMFT/Digit.h"
2324

2425
namespace o2::iotof
@@ -28,7 +29,7 @@ class Digit : public o2::itsmft::Digit
2829
public:
2930
~Digit() = default;
3031
Digit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0, double time = 0.)
31-
: o2::itsmft::Digit(chipindex, row, col, charge), mTime(time) {};
32+
: o2::itsmft::Digit(chipindex, row, col, charge), mTime(time){};
3233

3334
// Setters
3435
void setTime(double time) { mTime = time; }
@@ -46,5 +47,29 @@ class Digit : public o2::itsmft::Digit
4647
ClassDefNV(Digit, 1);
4748
};
4849

50+
// McLabelRef is used to store the MC label of the hit contributing to a digit, and eventually link to extra contributions to the same pixel
51+
struct McLabelRef {
52+
o2::MCCompLabel mLabel; ///< hit label
53+
int mNext = -1; ///< eventual next contribution to the same pixel
54+
McLabelRef(o2::MCCompLabel label = 0, int next = -1) : mLabel(label), mNext(next) {}
55+
56+
ClassDefNV(McLabelRef, 1);
57+
};
58+
59+
class LabeledDigit : public Digit
60+
{
61+
public:
62+
LabeledDigit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0, double time = 0.,
63+
o2::MCCompLabel label = 0)
64+
: Digit(chipindex, row, col, charge, time), mLabel(label) {}
65+
66+
void setLabel(McLabelRef label) { mLabel = label; }
67+
McLabelRef getLabel() const { return mLabel; }
68+
69+
private:
70+
McLabelRef mLabel; ///< label of the hit contributing to the digit, and eventually reference to extra contributions to the same pixel
71+
ClassDefNV(LabeledDigit, 1);
72+
};
73+
4974
} // namespace o2::iotof
5075
#endif // ALICEO2_IOTOF_DIGIT_H

Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/src/DataFormatsIOTOFLinkDef.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@
1818
#pragma link C++ class o2::iotof::Digit + ;
1919
#pragma link C++ class std::vector < o2::iotof::Digit> + ;
2020

21+
#pragma link C++ class o2::iotof::McLabelRef + ;
22+
#pragma link C++ class std::vector < o2::iotof::McLabelRef> + ;
23+
24+
#pragma link C++ class o2::iotof::LabeledDigit + ;
25+
#pragma link C++ class std::vector < o2::iotof::LabeledDigit> + ;
26+
2127
#endif
Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2-
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3-
# All rights not expressly granted are reserved.
1+
#Copyright 2019 - 2020 CERN and copyright holders of ALICE O2.
2+
#See https: // alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
#All rights not expressly granted are reserved.
44
#
5-
# This software is distributed under the terms of the GNU General Public
6-
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
5+
#This software is distributed under the terms of the GNU General Public
6+
#License v3(GPL Version 3), copied verbatim in the file "COPYING".
77
#
8-
# In applying this license CERN does not waive the privileges and immunities
9-
# granted to it by virtue of its status as an Intergovernmental Organization
8+
#In applying this license CERN does not waive the privileges and immunities
9+
#granted to it by virtue of its status as an Intergovernmental Organization
1010
# or submit itself to any jurisdiction.
1111

1212
o2_add_library(IOTOFSimulation
13-
SOURCES src/Layer.cxx
14-
src/Detector.cxx
15-
src/Digitizer.cxx
16-
src/DPLDigitizerParam.cxx
17-
# src/IOTOFServices.cxx
18-
src/Segmentation.cxx
19-
PUBLIC_LINK_LIBRARIES O2::IOTOFBase
20-
O2::DataFormatsIOTOF
21-
O2::ITSMFTSimulation)
13+
SOURCES src /
14+
Layer.cxx
15+
src /
16+
Chip.cxx
17+
src /
18+
Detector.cxx
19+
src /
20+
Digitizer.cxx
21+
src /
22+
DPLDigitizerParam.cxx
23+
#src / IOTOFServices.cxx
24+
src /
25+
Segmentation.cxx
26+
PUBLIC_LINK_LIBRARIES O2::IOTOFBase
27+
O2::DataFormatsIOTOF
28+
O2::ITSMFTSimulation)
2229

23-
o2_target_root_dictionary(IOTOFSimulation
24-
HEADERS include/IOTOFSimulation/Detector.h
25-
include/IOTOFSimulation/Layer.h
26-
include/IOTOFSimulation/Digitizer.h
27-
include/IOTOFSimulation/DPLDigitizerParam.h
28-
# include/IOTOFSimulation/IOTOFServices.h
29-
include/IOTOFSimulation/Segmentation.h
30-
)
30+
o2_target_root_dictionary(IOTOFSimulation
31+
HEADERS include /
32+
IOTOFSimulation / Detector.h include / IOTOFSimulation / Chip.h include / IOTOFSimulation / Layer.h include / IOTOFSimulation / Digitizer.h include / IOTOFSimulation / DPLDigitizerParam.h
33+
#include / IOTOFSimulation / IOTOFServices.h
34+
include /
35+
IOTOFSimulation / Segmentation.h)
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
//
13+
// TOF Chip class: it will be used to store the digits at TOF that
14+
// fall in the same Chip
15+
//
16+
17+
////////////////////////////////////
18+
// To put in O2/Detectors/Upgrades/ALICE3/IOTOF/base/include/IOTOFBase/Chip.h
19+
20+
#ifndef ALICEO2_IOTOF_CHIP_H_
21+
#define ALICEO2_IOTOF_CHIP_H_
22+
23+
#include <DataFormatsIOTOF/Digit.h>
24+
#include <TObject.h>
25+
#include <exception>
26+
#include <map>
27+
#include <sstream>
28+
#include <vector>
29+
#include "MathUtils/Cartesian.h"
30+
31+
namespace o2::iotof
32+
{
33+
34+
/// @class Chip
35+
/// @brief Container for similated points connected to a given TOF Chip
36+
/// This will be used in order to allow a more efficient clusterization
37+
/// that can happen only between digits that belong to the same Chip
38+
///
39+
40+
class Chip
41+
{
42+
43+
public:
44+
/// Default constructor
45+
Chip() = default;
46+
47+
/// Destructor
48+
~Chip() = default;
49+
50+
/// Main constructor
51+
/// @param Chipindex Index of the Chip
52+
/// @param mat Transformation matrix
53+
Chip(Int_t index);
54+
55+
/// Copy constructor
56+
/// @param ref Reference for the copy
57+
Chip(const Chip& ref) = default;
58+
59+
/// Empties the point container
60+
/// @param option unused
61+
void clear() { mDigits.clear(); }
62+
63+
std::map<ULong64_t, o2::iotof::LabeledDigit>& getDigits() { return mDigits; }
64+
bool isEmpty() const { return mDigits.empty(); }
65+
66+
void setChipIndex(Int_t index) { mChipIndex = index; }
67+
Int_t getChipIndex() const { return mChipIndex; }
68+
69+
void disable(bool disable) { mDisabled = disable; }
70+
bool isDisabled() const { return mDisabled; }
71+
72+
/// Get the number of point assigned to the chip
73+
/// @return Number of points assigned to the chip
74+
Int_t getNumberOfDigits() const { return mDigits.size(); }
75+
76+
/// reset points container
77+
o2::iotof::LabeledDigit* findDigit(ULong64_t key);
78+
79+
void addDigit(UShort_t row, UShort_t col, Int_t charge, double time);
80+
81+
protected:
82+
Int_t mChipIndex = -1; ///< Chip ID
83+
bool mDisabled = false; ///< Flag to indicate if the chip is disabled (e.g. due to dead channels)
84+
std::map<ULong64_t, o2::iotof::LabeledDigit> mDigits; ///< Map of fired digits, possibly in multiple frames
85+
86+
ClassDefNV(Chip, 1);
87+
};
88+
89+
inline o2::iotof::LabeledDigit* Chip::findDigit(ULong64_t key)
90+
{
91+
// finds the digit corresponding to global key
92+
auto digitentry = mDigits.find(key);
93+
return digitentry != mDigits.end() ? &(digitentry->second) : nullptr;
94+
}
95+
96+
} // namespace o2::iotof
97+
98+
#endif /* defined(ALICEO2_IOTOF_CHIP_H_) */

Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Digitizer.h

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@
1919
#ifndef ALICEO2_IOTOF_DIGITIZER_H
2020
#define ALICEO2_IOTOF_DIGITIZER_H
2121

22+
#include <vector>
23+
#include <deque>
24+
#include <memory>
25+
26+
#include "Rtypes.h" // for Digitizer::Class
27+
#include "TObject.h" // for TObject
28+
2229
#include "ITSMFTSimulation/Hit.h"
23-
#include "DataFormatsITSMFT/Digit.h"
2430
#include "DataFormatsIOTOF/Digit.h"
31+
#include "IOTOFSimulation/Chip.h"
2532
#include "DataFormatsITSMFT/ROFRecord.h"
2633
#include "CommonDataFormat/InteractionRecord.h"
2734
#include "SimulationDataFormat/MCCompLabel.h"
@@ -40,7 +47,7 @@ namespace o2::iotof
4047
/// - Converting energy loss to charge
4148
/// - Applying charge threshold
4249
/// - Managing readout frames (ROF)
43-
class Digitizer
50+
class Digitizer : public TObject
4451
{
4552
public:
4653
void setDigits(std::vector<o2::iotof::Digit>* dig) { mDigits = dig; }
@@ -81,6 +88,10 @@ class Digitizer
8188
/// Process a single hit
8289
void processHit(const o2::itsmft::Hit& hit, int evID, int srcID);
8390

91+
/// Register digits in a given chip
92+
void registerDigits(Chip& chip, uint32_t roFrame, float timeInitROF, int nROF,
93+
uint16_t row, uint16_t col, int nElectrons, o2::MCCompLabel& label);
94+
8495
/// Apply time smearing to simulate detector resolution
8596
double smearTime(double time) const;
8697

@@ -90,10 +101,27 @@ class Digitizer
90101
/// Check if the hit passes efficiency cut
91102
bool isEfficient() const;
92103

104+
std::vector<o2::iotof::McLabelRef>* getExtraLabelBuffer(uint32_t roFrame)
105+
{
106+
// if (mROFrameMin > roFrame) {
107+
// return nullptr; // nothing to do
108+
// }
109+
// int index = roFrame - mROFrameMin;
110+
111+
int index = roFrame;
112+
while (index >= int(mExtraLabelBuffer.size())) {
113+
mExtraLabelBuffer.emplace_back(std::make_unique<std::vector<o2::iotof::McLabelRef>>());
114+
}
115+
return mExtraLabelBuffer[index].get();
116+
}
117+
93118
static constexpr float sec2ns = 1e9f; ///< seconds to nanoseconds conversion
94119

95120
const o2::iotof::GeometryTGeo* mGeometry = nullptr; ///< IOTOF geometry
96121

122+
std::vector<o2::iotof::Chip> mChips; //! Chips in the detector, indexed by chip ID
123+
std::deque<std::unique_ptr<std::vector<o2::iotof::McLabelRef>>> mExtraLabelBuffer; //! buffer for multiple mc labels to the same pixel
124+
97125
std::vector<o2::iotof::Digit>* mDigits = nullptr; //! output digits
98126
std::vector<o2::itsmft::ROFRecord>* mROFRecords = nullptr; //! output ROF records
99127
o2::dataformats::MCTruthContainer<o2::MCCompLabel>* mMCLabels = nullptr; //! output labels
@@ -108,6 +136,8 @@ class Digitizer
108136
float mEnergyToCharge = 3.6e-9f; ///< energy loss to electrons conversion (3.6 eV per e-h pair in Si)
109137

110138
static o2::iotof::Segmentation* sSegmentation; ///< IOTOF segmentation instance (singleton)
139+
140+
ClassDefNV(Digitizer, 1);
111141
};
112142
} // namespace o2::iotof
113143

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
//
13+
// Chip.cxx: structure to store the TOF digits in Chips - useful
14+
// for clusterization purposes
15+
// ALICEO2
16+
//
17+
#include <cstring>
18+
#include <tuple>
19+
20+
#include <TMath.h>
21+
#include <TObjArray.h>
22+
23+
#include "IOTOFSimulation/Chip.h"
24+
25+
using namespace o2::iotof;
26+
27+
ClassImp(o2::iotof::Chip);
28+
29+
//_______________________________________________________________________
30+
Chip::Chip(Int_t index)
31+
: mChipIndex(index)
32+
{
33+
}
34+
//_______________________________________________________________________
35+
void Chip::addDigit(UShort_t row, UShort_t col, Int_t charge, double time)
36+
{
37+
ULong64_t key = Digit::getOrderingKey(mChipIndex, row, col);
38+
mDigits.emplace(std::make_pair(key, LabeledDigit(mChipIndex, row, col, charge, time)));
39+
}

0 commit comments

Comments
 (0)