Project
Loading...
Searching...
No Matches
BaselineCalibData.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 <TMath.h>
13#include <TH1.h>
14#include <TFile.h>
15#include <TDirectory.h>
16#include "Framework/Logger.h"
18
19using namespace o2::zdc;
20
21//______________________________________________________________________________
23{
24 LOGF(info, "BaselineCalibData::print ts (%llu:%llu)", mCTimeBeg, mCTimeEnd);
25 for (int is = 0; is < NChannels; is++) {
26 uint64_t en = 0;
27 double mean = 0, var = 0;
28 if (getStat(is, en, mean, var) == 0) {
29 LOGF(info, "Baseline %2d %s with %10llu events mean %8.1f rms %8.1f (ch)", is, ChannelNames[is].data(), en, mean, TMath::Sqrt(var));
30 }
31 }
32}
33
34//______________________________________________________________________________
36{
37 if (other.mOverflow) {
38 // Refusing to add an overflow
39 LOG(warn) << "BaselineCalibData" << __func__ << " Refusing to add an overflow. BREAK!";
40 return *this;
41 }
42 for (int32_t is = 0; is < NChannels; is++) {
43 if (other.mHisto[is].mOverflow) {
44 // Refusing to add an overflow histogram
45 LOG(warn) << "BaselineCalibData::" << __func__ << " Refusing to add an overflow histogram for ch " << is << " BREAK!";
46 return *this;
47 }
48 // Check if sum will result into an overflow
49 for (int32_t i = 0; i < BaselineCalibChData::NW; i++) {
50 uint64_t sum = mHisto[is].mData[i] + other.mHisto[is].mData[i];
51 if (sum > 0xffffffff) {
52 LOG(warn) << "BaselineCalibData::" << __func__ << " Addition would result in an overflow for ch " << is << " BREAK!";
53 return *this;
54 }
55 }
56 }
57 // No problems with overflow
58 for (int32_t is = 0; is < NChannels; is++) {
59 for (int32_t i = 0; i < BaselineCalibChData::NW; i++) {
60 mHisto[is].mData[i] = mHisto[is].mData[i] + other.mHisto[is].mData[i];
61 }
62 }
63 if (mCTimeBeg == 0 || other.mCTimeBeg < mCTimeBeg) {
64 mCTimeBeg = other.mCTimeBeg;
65 }
66 if (other.mCTimeEnd > mCTimeEnd) {
67 mCTimeEnd = other.mCTimeEnd;
68 }
69#ifdef O2_ZDC_DEBUG
70 LOG(info) << __func__;
71 print();
72#endif
73 return *this;
74}
75
76//______________________________________________________________________________
78{
79#ifdef O2_ZDC_DEGUG
80 LOGF(info) << "BaselineCalibData assigning BaselineCalibSummaryData" s.print();
81#endif
82 mCTimeBeg = s.mCTimeBeg;
83 mCTimeEnd = s.mCTimeEnd;
84 mOverflow = s.mOverflow;
85 for (int32_t is = 0; is < NChannels; is++) {
86 // Need to clear all bins since summary data have info only on filled channels
87 mHisto[is].clear();
88 mHisto[is].mOverflow = s.mOverflowCh[is];
89 // Cross check
90 if (mHisto[is].mOverflow && mOverflow == false) {
91 LOG(warn) << "Overflow bit set on signal " << is;
92 mOverflow = true;
93 }
94 }
95 for (const BaselineCalibBinData& bin : s.mData) {
96 mHisto[bin.id].mData[bin.ibin] = bin.cont;
97 }
98 return *this;
99}
100
101//______________________________________________________________________________
103{
104 if (s == nullptr) {
105 LOG(error) << "BaselineCalibData::operator+=(const BaselineCalibSummaryData* s): null pointer";
106 return *this;
107 }
108#ifdef O2_ZDC_DEGUG
109 LOGF(info) << "BaselineCalibData cumulating BaselineCalibSummaryData" s.print();
110#endif
111 if (s->mOverflow) {
112 // Refusing to add an overflow
113 LOG(warn) << __func__ << " Refusing to add an overflow BaselineCalibSummaryData BREAK!";
114 s->print();
115 return *this;
116 }
117 for (int32_t is = 0; is < NChannels; is++) {
118 if (s->mOverflowCh[is]) {
119 // Refusing to add an overflow histogram
120 LOG(warn) << __func__ << " Refusing to add an overflow histogram for ch " << is << " BREAK!";
121 s->print();
122 return *this;
123 }
124 }
125 // Check if sum will result into an overflow
126 for (auto& bin : s->mData) {
127 uint64_t sum = mHisto[bin.id].mData[bin.ibin] + bin.cont;
128 if (sum > 0xffffffff) {
129 LOG(warn) << __func__ << " Addition would result in an overflow for ch " << bin.id << " BREAK!";
130 return *this;
131 }
132 }
133 if (mCTimeBeg == 0 || s->mCTimeBeg < mCTimeBeg) {
134 mCTimeBeg = s->mCTimeBeg;
135 }
136 if (s->mCTimeEnd > mCTimeEnd) {
137 mCTimeEnd = s->mCTimeEnd;
138 }
139 for (auto& bin : s->mData) {
140 mHisto[bin.id].mData[bin.ibin] = mHisto[bin.id].mData[bin.ibin] + bin.cont;
141 }
142 return *this;
143}
144
145//______________________________________________________________________________
147{
148 mCTimeBeg = ctime;
149 mCTimeEnd = ctime;
150#ifdef O2_ZDC_DEBUG
151 LOGF(info, "BaselineCalibData::setCreationTime %llu", ctime);
152#endif
153}
154
155//______________________________________________________________________________
157{
158 if (mCTimeBeg == 0 || ctime < mCTimeBeg) {
159 mCTimeBeg = ctime;
160 }
161 if (ctime > mCTimeEnd) {
162 mCTimeEnd = ctime;
163 }
164#ifdef O2_ZDC_DEBUG
165 LOGF(info, "BaselineCalibData::mergeCreationTime %llu", ctime);
166#endif
167}
168
169//______________________________________________________________________________
171{
172 if (is < 0 || is >= NChannels) {
173 LOGF(error, "BaselineCalibData::getEntries channel index %d is out of range", is);
174 return 0;
175 }
176 return mHisto[is].getEntries();
177}
178
180{
181 uint64_t sum = 0;
182 for (int32_t i = 0; i < NW; i++) {
183 sum += mData[i];
184 }
185 return sum;
186}
187
188//______________________________________________________________________________
189int BaselineCalibData::getStat(int is, uint64_t& en, double& mean, double& var) const
190{
191 if (is < 0 || is >= NChannels) {
192 LOGF(error, "BaselineCalibData::getStat channel index %d is out of range", is);
193 return 1;
194 }
195 return mHisto[is].getStat(en, mean, var);
196}
197
198int BaselineCalibChData::getStat(uint64_t& en, double& mean, double& var) const
199{
200 en = 0;
201 uint64_t sum = 0;
202 for (uint64_t i = 0; i < NW; i++) {
203 en += mData[i];
204 sum += i * mData[i];
205 }
206 if (en == 0) {
207 return 1;
208 }
209 mean = double(sum) / double(en);
210 if (en > 1) {
211 double sums = 0;
212 for (int32_t i = 0; i < NW; i++) {
213 double diff = i - mean;
214 sums += (mData[i] * diff * diff);
215 }
216 var = sums / (en - 1);
217 } else {
218 var = 0;
219 }
220 // Convert mean to correct range
221 mean = mean + BaselineMin;
222 return 0;
223}
224
225//______________________________________________________________________________
226int BaselineCalibData::saveDebugHistos(const std::string fn, float factor = 1)
227{
228 TDirectory* cwd = gDirectory;
229 TFile* f = new TFile(fn.data(), "recreate");
230 if (f->IsZombie()) {
231 LOG(error) << "Cannot create file: " << fn;
232 return 1;
233 }
234 for (int32_t is = 0; is < NChannels; is++) {
235 uint64_t nen = mHisto[is].getEntries();
236 if (nen > 0) {
237 TString n = TString::Format("h%d", is);
238 TString t = TString::Format("Baseline %d %s", is, ChannelNames[is].data());
239 TH1F h(n, t, BaselineRange, (BaselineMin - 0.5) * factor, (BaselineMax + 0.5) * factor);
240 for (int ibx = 0; ibx < BaselineRange; ibx++) {
241 h.SetBinContent(ibx + 1, mHisto[is].mData[ibx]);
242 }
243 h.SetEntries(nen);
244 h.Write("", TObject::kOverwrite);
245 }
246 }
247 f->Close();
248 cwd->cd();
249 return 0;
250}
251
252//______________________________________________________________________________
254{
255 mCTimeBeg = 0;
256 mCTimeEnd = 0;
257 mOverflow = false;
258 mSummary.clear();
259 for (int32_t is = 0; is < NChannels; is++) {
260 mHisto[is].clear();
261 }
262}
263
265{
266 mOverflow = false;
267 for (int iw = 0; iw < NW; iw++) {
268 mData[iw] = 0;
269 }
270}
271
273{
274 mCTimeBeg = 0;
275 mCTimeEnd = 0;
276 mOverflow = false;
277 mOverflowCh.fill(false);
278 mData.clear();
279}
280
281//______________________________________________________________________________
283{
284 mSummary.clear();
288 for (int32_t is = 0; is < NChannels; is++) {
290 for (int32_t ib = 0; ib < BaselineRange; ib++) {
291 uint32_t cont = mHisto[is].mData[ib];
292 if (cont > 0) {
293 mSummary.mData.emplace_back(is, ib, cont);
294 }
295 }
296 }
297 return mSummary;
298}
299
300//______________________________________________________________________________
302{
303 LOGF(info, "BaselineCalibSummaryData: %llu:%llu %d bins%s", mCTimeBeg, mCTimeEnd, mData.size(), (mOverflow ? " OVERFLOW_BIT" : ""));
304 if (mOverflow) {
305 printf("OVERFLOW:");
306 for (int ich = 0; ich < NChannels; ich++) {
307 if (mOverflowCh[ich]) {
308 printf(" %s", ChannelNames[ich].data());
309 }
310 }
311 printf("\n");
312 }
313 int nbin[NChannels] = {0}; // Number of bin populated
314 uint64_t ccont[NChannels] = {0}; // Entries in the histogram
315 for (auto& bin : mData) {
316 nbin[bin.id]++;
317 ccont[bin.id] += bin.cont;
318 }
319 for (int32_t is = 0; is < NChannels; is++) {
320 LOGF(info, "Summary ch %2d nbin = %d events = %llu", is, nbin[is], ccont[is]);
321 }
322}
Baseline calibration intermediate data.
unsigned int uint32_t
std::vector< double > sum
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 s
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 Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
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
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 factor
char error[CURL_ERROR_SIZE]
Class for time synchronization of RawReader instances.
GLdouble n
Definition glcorearb.h:1982
GLdouble f
Definition glcorearb.h:310
constexpr int NChannels
Definition Constants.h:65
constexpr int BaselineMax
Definition Constants.h:353
constexpr int BaselineMin
Definition Constants.h:353
constexpr int BaselineRange
Definition Constants.h:353
constexpr std::string_view ChannelNames[]
Definition Constants.h:147
uint64_t getEntries() const
Overflow flag (cannot accept more data)
bool mOverflow
Histogram container.
int getStat(uint64_t &en, double &mean, double &var) const
std::array< uint32_t, NW > mData
2^16 bins
BaselineCalibSummaryData & getSummary()
uint64_t getEntries(int is) const
bool mOverflow
Time of processed time frame.
BaselineCalibData & operator=(const BaselineCalibSummaryData &s)
void setCreationTime(uint64_t ctime)
BaselineCalibData & operator+=(const BaselineCalibData &other)
int saveDebugHistos(const std::string fn, float factor)
BaselineCalibSummaryData mSummary
Histogram for single channel.
int getStat(int is, uint64_t &en, double &mean, double &var) const
uint64_t mCTimeEnd
Time of processed time frame.
BaselineCalibChData mHisto[NChannels]
Overflow at least one ZDC channel.
void mergeCreationTime(uint64_t ctime)
std::vector< BaselineCalibBinData > mData
Channel overflow information.
std::array< bool, NChannels > mOverflowCh
Overflow of one channel.
uint64_t mCTimeEnd
Time of processed time frame.
bool mOverflow
Time of processed time frame.
void clear()
Data of not empty bins.
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"