Project
Loading...
Searching...
No Matches
ChipDigitsContainer.h
Go to the documentation of this file.
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#ifndef ALICEO2_TRK_CHIPDIGITSCONTAINER_
13#define ALICEO2_TRK_CHIPDIGITSCONTAINER_
14
19#include "TRKBase/Specs.h"
21#include <fairlogger/Logger.h>
22#include <TRandom.h>
23
24namespace o2::trkft3
25{
26
29
31{
32 public:
34 explicit ChipDigitsContainer(UShort_t idx = 0);
35
38
39 std::map<ULong64_t, o2::trkft3::PreDigit>& getPreDigits() { return mDigits; }
40 bool isEmpty() const { return mDigits.empty(); }
41 void setNoiseMap(const o2::itsmft::NoiseMap* mp) { mNoiseMap = mp; }
43 void setChipIndex(UShort_t ind) { mChipIndex = ind; }
44 UShort_t getChipIndex() const { return mChipIndex; }
45
47 void addDigit(ULong64_t key, UInt_t roframe, UShort_t row, UShort_t col, int charge, o2::MCCompLabel lbl, float toa = 0.f);
48 template <int DetID>
49 void addNoise(UInt_t rofMin, UInt_t rofMax, const o2::trkft3::DigiParams<DetID>* params, int subDetID, int layer);
50
52 static ULong64_t getOrderingKey(UInt_t roframe, UShort_t row, UShort_t col)
53 {
54 return (static_cast<ULong64_t>(roframe) << (8 * sizeof(UInt_t))) + (static_cast<ULong64_t>(col) << (8 * sizeof(Short_t))) + row;
55 }
56
57 bool isDisabled() const { return mDisabled; }
58 void disable(bool v) { mDisabled = v; }
59
60 protected:
61 UShort_t mChipIndex = 0;
62 bool mDisabled = false;
65 std::map<ULong64_t, o2::trkft3::PreDigit> mDigits;
66
68};
69
70//_______________________________________________________________________
72{
73 // finds the digit corresponding to global key
74 auto digitentry = mDigits.find(key);
75 return digitentry != mDigits.end() ? &(digitentry->second) : nullptr;
76}
77
78//_______________________________________________________________________
79inline void ChipDigitsContainer::addDigit(ULong64_t key, UInt_t roframe, UShort_t row, UShort_t col,
80 int charge, o2::MCCompLabel lbl, float toa)
81{
82 mDigits.emplace(key, o2::trkft3::PreDigit(roframe, row, col, charge, lbl, toa));
83}
84
85} // namespace o2::trkft3
86
87template <int DetID>
88void o2::trkft3::ChipDigitsContainer::addNoise(UInt_t rofMin, UInt_t rofMax, const o2::trkft3::DigiParams<DetID>* params, int subDetID, int layer)
89{
90 UInt_t row = 0;
91 UInt_t col = 0;
92 Int_t nhits = 0;
93 float mean = 0.f;
94 int nel = 0;
95 int maxRows = 0;
96 int maxCols = 0;
97
98 if (subDetID == 0) {
99 maxRows = o2::trk::constants::VD::petal::layer::nRows[layer];
100 maxCols = o2::trk::constants::VD::petal::layer::nCols;
101 } else {
104 }
105 mean = params->getNoisePerPixel() * maxRows * maxCols;
106 nel = static_cast<int>(params->getChargeThreshold() * 1.1);
107
108 LOG(debug) << "Adding noise for chip " << mChipIndex << " with mean " << mean << " and charge " << nel;
109
110 for (UInt_t rof = rofMin; rof <= rofMax; rof++) {
111 nhits = gRandom->Poisson(mean);
112 for (Int_t i = 0; i < nhits; ++i) {
113 row = gRandom->Integer(maxRows);
114 col = gRandom->Integer(maxCols);
115 LOG(debug) << "Generated noise hit at ROF " << rof << ", row " << row << ", col " << col;
116 if (mNoiseMap && mNoiseMap->isNoisy(mChipIndex, row, col)) {
117 continue;
118 }
119 if (mDeadChanMap && mDeadChanMap->isNoisy(mChipIndex, row, col)) {
120 continue;
121 }
122 auto key = getOrderingKey(rof, row, col);
123 if (!findDigit(key)) {
124 addDigit(key, rof, row, col, nel, o2::MCCompLabel(true), 0.f);
125 }
126 }
127 }
128}
129
130#endif /* defined(ALICEO2_TRK_CHIPDIGITSCONTAINER_) */
Simulation parameters for the TRK digitizer. Based on the ITS2 and ITS3 digitizer parameters.
std::ostringstream debug
int16_t charge
Definition RawEventData.h:5
int32_t i
Definition of the ITSMFT NoiseMap.
uint32_t col
Definition RawData.h:4
Definition of the SegmentationChipclass.
specs of the ALICE3 TRK
Definition of the digit contribution from single hit for TRK/FT3 (based on o2::itsmft::PreDigit,...
StringRef key
NoiseMap class for the ITS and MFT.
Definition NoiseMap.h:39
Container for simulated points connected to a given chip.
void addDigit(ULong64_t key, UInt_t roframe, UShort_t row, UShort_t col, int charge, o2::MCCompLabel lbl, float toa=0.f)
const o2::itsmft::NoiseMap * mNoiseMap
std::map< ULong64_t, o2::trkft3::PreDigit > mDigits
Map of fired pixels, possibly in multiple frames.
void setNoiseMap(const o2::itsmft::NoiseMap *mp)
void addNoise(UInt_t rofMin, UInt_t rofMax, const o2::trkft3::DigiParams< DetID > *params, int subDetID, int layer)
std::map< ULong64_t, o2::trkft3::PreDigit > & getPreDigits()
const o2::itsmft::NoiseMap * mDeadChanMap
void setDeadChanMap(const o2::itsmft::NoiseMap *mp)
ClassDefNV(ChipDigitsContainer, 2)
static ULong64_t getOrderingKey(UInt_t roframe, UShort_t row, UShort_t col)
Get global ordering key made of readout frame, column and row.
~ChipDigitsContainer()=default
Destructor.
o2::trkft3::PreDigit * findDigit(ULong64_t key)
const GLdouble * v
Definition glcorearb.h:832
GLenum const GLfloat * params
Definition glcorearb.h:272
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< int > row