Project
Loading...
Searching...
No Matches
WaveformCalibData.cxx
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#include <TH1.h>
13#include <TFile.h>
14#include <TDirectory.h>
15#include "Framework/Logger.h"
17
18using namespace o2::zdc;
19
20//______________________________________________________________________________
22{
23 LOGF(info, "WaveformCalibData mN = %d/%d [%llu : %llu]", mN, NBT, mCTimeBeg, mCTimeEnd);
24 for (int32_t is = 0; is < NChannels; is++) {
25 if (getEntries(is) > 0) {
26 LOGF(info, "WaveformCalibData %2d %s: entries=%d [%d:%d:%d]", is, ChannelNames[is].data(), getEntries(is), getFirstValid(is), mPeak, getLastValid(is));
27 }
28 }
29}
30
31//______________________________________________________________________________
33{
34 if (mN != other.mN) {
35 LOG(fatal) << "Mixing waveform with different configurations mN = " << mN << " != " << other.mN;
36 return *this;
37 }
38 if (mPeak != other.mPeak) {
39 LOG(fatal) << "Mixing waveform with different configurations mPeak = " << mPeak << " != " << other.mPeak;
40 return *this;
41 }
42 if (mCTimeBeg == 0 || other.mCTimeBeg < mCTimeBeg) {
43 mCTimeBeg = other.mCTimeBeg;
44 }
45 if (other.mCTimeEnd > mCTimeEnd) {
46 mCTimeEnd = other.mCTimeEnd;
47 }
48 for (int32_t is = 0; is < NChannels; is++) {
49 mWave[is] += other.mWave[is];
50 }
51#ifdef O2_ZDC_DEBUG
52 LOG(info) << __func__;
53 print();
54#endif
55 return *this;
56}
57
59{
60 if (other.mEntries > 0) {
61 if (other.mFirstValid > mFirstValid) {
62#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
63 printf("WaveformCalibChData::+= mFirstValid %5d -> %5d\n", mFirstValid, other.mFirstValid);
64#endif
65 mFirstValid = other.mFirstValid;
66 }
67 if (other.mLastValid < mLastValid) {
68#ifdef O2_ZDC_WAVEFORMCALIB_DEBUG
69 printf("WaveformCalibChData::+= mLastValid %5d -> %5d\n", mLastValid, other.mLastValid);
70#endif
71 mLastValid = other.mLastValid;
72 }
73 mEntries = mEntries + other.mEntries;
74 for (int32_t i = mFirstValid; i <= mLastValid; i++) {
75 mData[i] = mData[i] + other.mData[i];
76 }
77 }
78 return *this;
79}
80
81//______________________________________________________________________________
83{
84 mCTimeBeg = ctime;
85 mCTimeEnd = ctime;
86#ifdef O2_ZDC_DEBUG
87 LOGF(info, "WaveformCalibData::setCreationTime %llu", ctime);
88#endif
89}
90
91//______________________________________________________________________________
93{
94 if (is < 0 || is >= NChannels) {
95 LOGF(error, "WaveformCalibData::getEntries channel index %d is out of range", is);
96 return 0;
97 }
98 return mWave[is].getEntries();
99}
100
102{
103 return mEntries;
104}
105
106//______________________________________________________________________________
108{
109 if (is < 0 || is >= NChannels) {
110 LOGF(error, "WaveformCalibData::getFirstValid channel index %d is out of range", is);
111 return 0;
112 }
113 return mWave[is].getFirstValid();
114}
115
117{
118 return mFirstValid;
119}
120
121//______________________________________________________________________________
123{
124 if (is < 0 || is >= NChannels) {
125 LOGF(error, "WaveformCalibData::getLastValid channel index %d is out of range", is);
126 return 0;
127 }
128 return mWave[is].getLastValid();
129}
130
132{
133 return mLastValid;
134}
135
136//______________________________________________________________________________
138{
139 if (n > 0 && n <= NBT) {
140 mN = n;
141 for (int is = 0; is < NChannels; is++) {
142 mWave[is].setN(n);
143 }
144 } else {
145 LOG(warn) << "WaveformCalibData " << __func__ << " wrong stored b.c. setting " << n << " not in range [1:" << NBT << "]";
146 }
147}
148
150{
151 if (n > 0 && n <= NBT) {
152 mFirstValid = 0;
153 mLastValid = n * NTimeBinsPerBC * TSN - 1;
154 } else {
155 LOG(warn) << "WaveformCalibChData " << __func__ << " wrong stored b.c. setting " << n << " not in range [1:" << NBT << "]";
156 }
157}
158
159//______________________________________________________________________________
160int WaveformCalibData::saveDebugHistos(const std::string fn)
161{
162 TDirectory* cwd = gDirectory;
163 TFile* f = new TFile(fn.data(), "recreate");
164 if (f->IsZombie()) {
165 LOG(error) << "Cannot create file: " << fn;
166 return 1;
167 }
168 for (int32_t is = 0; is < NChannels; is++) {
169 if (mWave[is].mEntries > 0) {
170 TString n = TString::Format("h%d", is);
171 TString t = TString::Format("Waveform %d %s", is, ChannelNames[is].data());
172 int nbx = mWave[is].mLastValid - mWave[is].mFirstValid + 1;
173 float min = mWave[is].mFirstValid - mPeak - 0.5;
174 float max = mWave[is].mLastValid - mPeak + 0.5;
175 TH1F h(n, t, nbx, min, max);
176 for (int ibx = 0; ibx < nbx; ibx++) {
177 h.SetBinContent(ibx + 1, mWave[is].mData[mWave[is].mFirstValid + ibx]);
178 }
179 h.SetEntries(mWave[is].mEntries);
180 h.Write("", TObject::kOverwrite);
181 } else {
182 LOG(warn) << "WaveformCalibData " << __func__ << " waveform for ch " << is << " has too few entries: " << mWave[is].mEntries;
183 }
184 }
185 f->Close();
186 cwd->cd();
187 return 0;
188}
189
190//______________________________________________________________________________
191int WaveformCalibData::dumpCalib(const std::string fn)
192{
193 TDirectory* cwd = gDirectory;
194 TFile* f = new TFile(fn.data(), "recreate");
195 if (f->IsZombie()) {
196 LOG(error) << "Cannot create file: " << fn;
197 return 1;
198 }
199 f->WriteObjectAny((void*)this, o2::zdc::WaveformCalibData::Class(), "WaveformCalibData");
200 f->Close();
201 cwd->cd();
202 return 0;
203}
204
205//______________________________________________________________________________
207{
208 mCTimeBeg = 0;
209 mCTimeEnd = 0;
210 mN = 0;
211 mPeak = 0;
212 for (int32_t is = 0; is < NChannels; is++) {
213 mWave[is].clear();
214 }
215}
216
217//______________________________________________________________________________
219{
220 mCTimeBeg = 0;
221 mCTimeEnd = 0;
222 for (int32_t is = 0; is < NChannels; is++) {
223 mWave[is].clear();
224 }
225}
226
228{
229 mEntries = 0;
230 mFirstValid = -1;
231 mLastValid = -1;
232 for (int iw = 0; iw < NW; iw++) {
233 mData[iw] = 0;
234 }
235}
int32_t i
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 configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
char error[CURL_ERROR_SIZE]
Waveform calibration intermediate data.
Class for time synchronization of RawReader instances.
GLdouble n
Definition glcorearb.h:1982
GLdouble f
Definition glcorearb.h:310
constexpr int NTimeBinsPerBC
Definition Constants.h:53
constexpr int NChannels
Definition Constants.h:65
constexpr int TSN
Definition Constants.h:94
constexpr std::string_view ChannelNames[]
Definition Constants.h:147
int mLastValid
First bin with valid data.
WaveformCalibChData & operator+=(const WaveformCalibChData &other)
Waveform.
std::array< float, NW > mData
Number of waveforms added.
uint32_t mEntries
Last bin with valid data.
int mPeak
Number of bunches in waveform.
int dumpCalib(const std::string fn)
std::array< WaveformCalibChData, NChannels > mWave
Peak position.
int mN
Time of processed time frame.
uint64_t mCTimeEnd
Time of processed time frame.
WaveformCalibData & operator+=(const WaveformCalibData &other)
int saveDebugHistos(const std::string fn)
void setCreationTime(uint64_t ctime)
constexpr size_t min
constexpr size_t max
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"