Project
Loading...
Searching...
No Matches
Digitizer.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_TRD_DIGITIZER_H_
13#define ALICEO2_TRD_DIGITIZER_H_
14
16
17#include "TRDBase/Geometry.h"
18#include "TRDBase/PadResponse.h"
21
28
31
32#include <array>
33#include <deque>
34#include <unordered_map>
35#include <vector>
36#include <string>
37
38namespace o2
39{
40namespace trd
41{
42
43class Geometry;
44class SimParam;
45
46using DigitContainer = std::vector<Digit>;
47using SignalContainer = std::unordered_map<int, SignalArray>;
49
51{
52 public:
53 Digitizer() = default;
54 ~Digitizer() = default;
55 void init(); // setup everything
56
57 void process(std::vector<Hit> const&);
60 void pileup();
61 void clearPileupSignals() { mPileupSignals.clear(); }
62 const std::deque<std::array<SignalContainer, constants::MAXCHAMBER>>& getPileupSignals() const { return mPileupSignals; }
63 void setEventTime(double timeNS) { mTime = timeNS; }
64 void setTriggerTime(double t) { mCurrentTriggerTime = t; }
65 void setEventID(int entryID) { mEventID = entryID; }
66 void setSrcID(int sourceID) { mSrcID = sourceID; }
67 void setCalVdriftExB(const CalVdriftExB* calVdriftExB) { mCalVdriftExB = calVdriftExB; }
68 void setFedChamberStatus(int det, int value)
69 {
70 if (det >= constants::MAXCHAMBER) {
71 return;
72 }
73 mFedChamberStatus[det] = value;
74 }
75 void setCalGain(const CalGain* calGain) { mCalGain = calGain; }
76 void setLocalGainFactor(const LocalGainFactor* localGain) { mLocalGainFactor = localGain; }
77 void setPadStatus(const PadStatus* padStatus) { mPadStatus = padStatus; }
78 void setCreateSharedDigits(bool flag) { mCreateSharedDigits = flag; }
79 int getEventTime() const { return mTime; }
80 int getEventID() const { return mEventID; }
81 int getSrcID() const { return mSrcID; }
82 bool getCreateSharedDigits() const { return mCreateSharedDigits; }
84 {
85 if (det >= constants::MAXCHAMBER) {
86 return -1.;
87 }
88 return mFedChamberStatus[det];
89 }
90 std::string dumpFlaggedChambers() const;
91
92 private:
93 Geometry* mGeo = nullptr; // access to Geometry
94 PadResponse mPRF{}; // access to PadResponse
95 SimParam mSimParam{}; // simulation parameters
96 const CalVdriftExB* mCalVdriftExB = nullptr; // access to time-dependent calibrations CalVdriftExB in CCDB
97 const CalGain* mCalGain = nullptr; // access to time-dependent calibrations CalGain in CCDB
98 const PadStatus* mPadStatus = nullptr; // access to time-dependent calibrations PadStatus in CCDB
99 const LocalGainFactor* mLocalGainFactor = nullptr; // access to time-dependent calibrations LocalGainFactor in CCDB
100 std::array<int, constants::MAXCHAMBER> mFedChamberStatus{}; // access to time-dependent FED chamber status in CCDB
101 PileupTool pileupTool;
102
103 // number of digitizer threads
104 int mNumThreads = 1;
105
106 // we create one such service structure per thread
107 std::vector<math_utils::RandomRing<>> mGausRandomRings; // pre-generated normal distributed random numbers
108 std::vector<math_utils::RandomRing<>> mFlatRandomRings; // pre-generated flat distributed random numbers
109 std::vector<math_utils::RandomRing<>> mLogRandomRings; // pre-generated exp distributed random number
110 std::vector<DiffusionAndTimeStructEstimator> mDriftEstimators; // use one estimator per thread (works on different chamber with possibly different vDrift and profits from cached values)
111
112 double mTime = 0.; // time in nanoseconds of the hits currently being processed
113 double mCurrentTriggerTime = 0.; // time in nanoseconds of the current trigger
114 int mEventID = 0; // event id
115 int mSrcID = 0; // source id
116
117 // Digitization parameters
118 static constexpr float AmWidth = Geometry::amThick(); // Width of the amplification region
119 static constexpr float DrWidth = Geometry::drThick(); // Width of the drift retion
120 static constexpr float DrMin = -0.5 * AmWidth; // Drift + Amplification region
121 static constexpr float DrMax = DrWidth + 0.5 * AmWidth; // Drift + Amplification region
122 float mSamplingRate = 0; // The sampling rate
123 float mElAttachProp = 0; // Propability for electron attachment (for 1m)
124 int mNpad = 0; // Number of pads included in the pad response
125 int mTimeBinTRFend = 0; // time bin TRF ends
126 int mMaxTimeBins = 30; // Maximum number of time bins for processing signals, usually set at 30 tb = 3 microseconds
127 int mMaxTimeBinsTRAP = 30; // Maximum number of time bins for processing adcs; should be read from the CCDB or the TRAP config
128 bool mCreateSharedDigits = true; // flag if copies should be created of digits from pads which are shared between MCMs
129
130 // Digitization containers
131 std::vector<Hit> mHitContainer; // the container of hits in a given detector
132 std::vector<MCLabel> mMergedLabels; // temporary label container
133 std::array<SignalContainer, constants::MAXCHAMBER> mSignalsMapCollection; // container for caching signals over a timeframe
134 std::deque<std::array<SignalContainer, constants::MAXCHAMBER>> mPileupSignals; // container for piled up signals
135 std::array<bool, constants::MAXCHAMBER> mFlagVdriftOutOfRange{}; // flag chambers in which the drift velocity is out of range for which a parameterization exists
136
137 void getHitContainerPerDetector(const std::vector<Hit>&, std::array<std::vector<Hit>, constants::MAXCHAMBER>&);
138 void setSimulationParameters();
139
140 // Digitization chain methods
141 int triggerEventProcessing(DigitContainer&, o2::dataformats::MCTruthContainer<MCLabel>&);
142 SignalContainer addSignalsFromPileup();
143 void clearContainers();
144 bool convertHits(const int, const std::vector<Hit>&, SignalContainer&, int thread = 0); // True if hit-to-signal conversion is successful
145 bool convertSignalsToADC(SignalContainer&, DigitContainer&, int thread = 0); // True if signal-to-ADC conversion is successful
146 void addLabel(const int&, std::vector<MCLabel>&, std::unordered_set<int>&); // add a MC label, check if trackId is already registered
147 bool diffusion(float, float, float, float, float, float, double&, double&, double&, int thread = 0); // True if diffusion is applied successfully
148
149 // Helpers for signal handling
150 static constexpr int KEY_MIN = 0;
151 static constexpr int KEY_MAX = 2211727;
152 int calculateKey(const int det, const int row, const int col)
153 {
154 int key = ((det << 12) | (row << 8) | col);
155 assert(!(key < KEY_MIN || key > KEY_MAX));
156 return key;
157 }
158 int getDetectorFromKey(const int key) { return (key >> 12) & 0xFFF; }
159 int getRowFromKey(const int key) { return (key >> 8) & 0xF; }
160 int getColFromKey(const int key) { return key & 0xFF; }
161};
162} // namespace trd
163} // namespace o2
164#endif
Object with MPV dEdx values per chamber to be written into the CCDB.
Object with vDrift and ExB values per chamber to be written into the CCDB.
Global TRD definitions and constants.
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 process
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h trd
Definition of a container to keep Monte Carlo truth external to simulation objects.
Aliases for calibration values stored on a per-pad basis.
uint32_t col
Definition RawData.h:4
StringRef key
A container to hold and manage MC truth information/labels.
~Digitizer()=default
void setCreateSharedDigits(bool flag)
Definition Digitizer.h:78
void setSrcID(int sourceID)
Definition Digitizer.h:66
void setTriggerTime(double t)
Definition Digitizer.h:64
void setPadStatus(const PadStatus *padStatus)
Definition Digitizer.h:77
void setEventID(int entryID)
Definition Digitizer.h:65
const std::deque< std::array< SignalContainer, constants::MAXCHAMBER > > & getPileupSignals() const
Definition Digitizer.h:62
void dumpLabels(const SignalContainer &, o2::dataformats::MCTruthContainer< MCLabel > &)
int getEventTime() const
Definition Digitizer.h:79
void setLocalGainFactor(const LocalGainFactor *localGain)
Definition Digitizer.h:76
void flush(DigitContainer &, o2::dataformats::MCTruthContainer< MCLabel > &)
Definition Digitizer.cxx:84
void setFedChamberStatus(int det, int value)
Definition Digitizer.h:68
void setEventTime(double timeNS)
Definition Digitizer.h:63
void clearPileupSignals()
Definition Digitizer.h:61
void setCalVdriftExB(const CalVdriftExB *calVdriftExB)
Definition Digitizer.h:67
int getFedChamberStatus(int det)
Definition Digitizer.h:83
int getSrcID() const
Definition Digitizer.h:81
void setCalGain(const CalGain *calGain)
Definition Digitizer.h:75
std::string dumpFlaggedChambers() const
bool getCreateSharedDigits() const
Definition Digitizer.h:82
int getEventID() const
Definition Digitizer.h:80
GLsizei const GLfloat * value
Definition glcorearb.h:819
std::unordered_map< int, SignalArray > SignalContainer
Definition Digitizer.h:47
std::vector< Digit > DigitContainer
Definition Digitizer.h:46
PadCalibrations< float > LocalGainFactor
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< int > row