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, float rofLengthNS);
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, float rofLengthNS)
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) {
100 maxCols = o2::trk::constants::VD::petal::layer::nCols;
101 } else {
104 }
105 mean = params->getNoisePerPixel() * rofLengthNS * 1e-9 * maxRows * maxCols; // hits per ROF in the chip, calculated from the noise rate in hits/s
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 float toa = gRandom->Uniform(0.f, rofLengthNS); // noise fires uniformly in the ROF
125 addDigit(key, rof, row, col, nel, o2::MCCompLabel(true), toa);
126 }
127 }
128 }
129}
130
131#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
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
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
static int getNRowsVD(int layer)
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)
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.
void addNoise(UInt_t rofMin, UInt_t rofMax, const o2::trkft3::DigiParams< DetID > *params, int subDetID, int layer, float rofLengthNS)
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