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_TOF_DIGITIZER_H_
13#define ALICEO2_TOF_DIGITIZER_H_
14
15#include "TOFBase/Geo.h"
16#include "TOFBase/Digit.h"
17#include "TOFBase/Strip.h"
19#include "TOFSimulation/Detector.h"
22#include "TOFBase/CalibTOFapi.h"
23
24namespace o2
25{
26namespace tof
27{
28
29class Digitizer : public WindowFiller
30{
32
33 public:
34 Digitizer(Int_t mode = 0) : WindowFiller(), mMode(mode) { init(); };
35 ~Digitizer() = default;
36
37 void init();
38
39 int process(const std::vector<HitType>* hits, std::vector<Digit>* digits);
40
41 void setCalibApi(CalibApi* calibApi) { mCalibApi = calibApi; }
42
44 {
45 mMCTruthOutputContainer = truthcontainer;
46 }
47
48 std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>* getMCTruthPerTimeFrame() { return &mMCTruthOutputContainerPerTimeFrame; }
49
50 void fillOutputContainer(std::vector<Digit>& digits);
51 void flushOutputContainer(std::vector<Digit>& digits); // flush all residual buffered data
52
53 // Method used for digitization
54 void initParameters();
55 void printParameters();
56 Double_t getShowerTimeSmeared(Double_t time, Float_t charge);
63
64 Float_t getTimeLastHit(Int_t idigit) const { return mTimeLastHit[idigit]; }
65 Float_t getTotLastHit(Int_t idigit) const { return mTotLastHit[idigit]; }
66 Int_t getXshift(Int_t idigit) const { return mXLastShift[idigit]; }
67 Int_t getZshift(Int_t idigit) const { return mZLastShift[idigit]; }
68 void setEventID(Int_t id) { mEventID = id; }
69 void setSrcID(Int_t id) { mSrcID = id; }
70
71 void runFullTestExample(const char* geo = "");
72 void test(const char* geo = "");
73 void testFromHits(const char* geo = "", const char* hits = "AliceO2_TGeant3.tof.mc_10_event.root");
74
75 void setShowerSmearing();
76 void setResolution(float val)
77 {
78 mTOFresolution = val;
80 }
81 void setEffCenter(float val) { mEffCenter = val; }
82 void setEffBoundary1(float val) { mEffBoundary1 = val; }
83 void setEffBoundary2(float val) { mEffBoundary2 = val; }
84 void setEffBoundary3(float val) { mEffBoundary3 = val; }
85
86 // determines the readout window id, given a time in nanoseconds (relative
87 // to orbit-reset)
88 uint64_t getReadoutWindow(double timeNS) const
89 {
90 // event time shifted by 2 BC as safe margin before to change current readout window to account for decalibration
91 return uint64_t((timeNS - Geo::BC_TIME * (Geo::OVERLAP_IN_BC + 2)) * Geo::READOUTWINDOW_INV);
92 }
93
94 private:
95 // parameters
96 Int_t mMode;
97 Float_t mBound1;
98 Float_t mBound2;
99 Float_t mBound3;
100 Float_t mBound4;
101 Float_t mTOFresolution;
102 Float_t mShowerResolution;
103 Float_t mDigitResolution;
104 Float_t mTimeSlope;
105 Float_t mTimeDelay;
106 Float_t mTimeDelayCorr;
107 Float_t mTimeWalkeSlope;
108 Float_t mEffCenter;
109 Float_t mEffBoundary1;
110 Float_t mEffBoundary2;
111 Float_t mEffBoundary3;
112
113 // info TOF timewindow for MC
114 Int_t mEventID = 0;
115 Int_t mSrcID = 0;
116
117 // digit info
118 //std::vector<Digit>* mDigits;
119
120 // final vector of tof readout window MC
121 std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> mMCTruthOutputContainerPerTimeFrame;
122
123 // temporary MC info in the current tof readout windows
125 o2::dataformats::MCTruthContainer<o2::tof::MCLabel>* mMCTruthContainerCurrent = &mMCTruthContainer[0];
128
129 // arrays with digit and MCLabels out of the current readout windows (stored to fill future readout window)
130 std::vector<int> mFutureIevent;
131 std::vector<int> mFutureIsource;
132 std::vector<int> mFutureItrackID;
133
135
136 CalibApi* mCalibApi = nullptr;
137
138 void fillDigitsInStrip(std::vector<Strip>* strips, o2::dataformats::MCTruthContainer<o2::tof::MCLabel>* mcTruthContainer, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, Int_t trackID, Int_t eventID, Int_t sourceID, float geanttime = 0, double t0 = 0.0);
139
140 Int_t processHit(const HitType& hit, Double_t event_time);
141 void addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x, Float_t z, Float_t charge, Int_t iX, Int_t iZ, Int_t padZfired,
142 Int_t trackID, float geanttime = 0, double t0 = 0.0);
143
144 void checkIfReuseFutureDigits();
145
146 int mNLastHit = 0;
147 float mTimeLastHit[10];
148 float mTotLastHit[10];
149 Int_t mXLastShift[10];
150 Int_t mZLastShift[10];
151 ClassDefNV(Digitizer, 1);
152};
153} // namespace tof
154} // namespace o2
155#endif
Class to use TOF calibration (decalibration, calibration)
int16_t charge
Definition RawEventData.h:5
int16_t time
Definition RawEventData.h:4
Definition of a container to keep Monte Carlo truth external to simulation objects.
A container to hold and manage MC truth information/labels.
void setResolution(float val)
Definition Digitizer.h:76
Float_t getEffX(Float_t x)
void setEffCenter(float val)
Definition Digitizer.h:81
void flushOutputContainer(std::vector< Digit > &digits)
Double_t getShowerTimeSmeared(Double_t time, Float_t charge)
void setSrcID(Int_t id)
Definition Digitizer.h:69
Int_t getXshift(Int_t idigit) const
Definition Digitizer.h:66
void fillOutputContainer(std::vector< Digit > &digits)
Float_t getEffZ(Float_t z)
void setEffBoundary2(float val)
Definition Digitizer.h:83
void runFullTestExample(const char *geo="")
void setMCTruthContainer(o2::dataformats::MCTruthContainer< o2::MCCompLabel > *truthcontainer)
Definition Digitizer.h:43
void testFromHits(const char *geo="", const char *hits="AliceO2_TGeant3.tof.mc_10_event.root")
void setEffBoundary3(float val)
Definition Digitizer.h:84
void setEffBoundary1(float val)
Definition Digitizer.h:82
~Digitizer()=default
std::vector< o2::dataformats::MCTruthContainer< o2::MCCompLabel > > * getMCTruthPerTimeFrame()
Definition Digitizer.h:48
Bool_t isFired(Float_t x, Float_t z, Float_t charge)
Double_t getDigitTimeSmeared(Double_t time, Float_t x, Float_t z, Float_t charge)
uint64_t getReadoutWindow(double timeNS) const
Definition Digitizer.h:88
Float_t getTotLastHit(Int_t idigit) const
Definition Digitizer.h:65
Float_t getCharge(Float_t eDep)
Float_t getTimeLastHit(Int_t idigit) const
Definition Digitizer.h:64
Int_t getZshift(Int_t idigit) const
Definition Digitizer.h:67
void setCalibApi(CalibApi *calibApi)
Definition Digitizer.h:41
void setEventID(Int_t id)
Definition Digitizer.h:68
Digitizer(Int_t mode=0)
Definition Digitizer.h:34
Float_t getFractionOfCharge(Float_t x, Float_t z)
static constexpr Double_t READOUTWINDOW_INV
Definition Geo.h:167
static constexpr Double_t BC_TIME
Definition Geo.h:101
static constexpr Int_t OVERLAP_IN_BC
Definition Geo.h:175
static const int MAXWINDOWS
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum mode
Definition glcorearb.h:266
GLuint GLfloat * val
Definition glcorearb.h:1582
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition glcorearb.h:5034
GLuint id
Definition glcorearb.h:650
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
FIXME: do not use data model tables.
std::vector< Digit > digits