Project
Loading...
Searching...
No Matches
NoiseCalib.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 <TROOT.h>
13#include <TFile.h>
14#include <TH1.h>
15#include <TString.h>
16#include <TStyle.h>
17#include <TDirectory.h>
19#include "ZDCCalib/NoiseCalib.h"
20#include "Framework/Logger.h"
22#include "CCDB/CcdbApi.h"
23
24using namespace o2::zdc;
25
27{
28 // Inspect calibration parameters
29 const auto& opt = CalibParamZDC::Instance();
30 opt.print();
31 if (opt.debugOutput == true) {
33 }
34
35 int nbx = 4096 * NTimeBinsPerBC - NTimeBinsPerBC + 1;
36 double xmin = -2048 * NTimeBinsPerBC - 0.5;
37 double xmax = 2047 * NTimeBinsPerBC + 0.5;
38
39 for (int isig = 0; isig < NChannels; isig++) {
40 // Baseline single samples
41 if (mH[0][isig] == nullptr) {
42 mH[0][isig] = new o2::dataformats::FlatHisto1D<double>(4096, -2048.5, 2047.5);
43 } else {
44 mH[0][isig]->clear();
45 }
46 // Bunch average of baseline samples
47 if (mH[1][isig] == nullptr) {
48 mH[1][isig] = new o2::dataformats::FlatHisto1D<double>(nbx, xmin, xmax);
49 } else {
50 mH[1][isig]->clear();
51 }
52 // Difference between single samples and average
53 if (mH[2][isig] == nullptr) {
54 mH[2][isig] = new o2::dataformats::FlatHisto1D<double>(nbx, xmin / double(NTimeBinsPerBC), xmax / double(NTimeBinsPerBC));
55 } else {
56 mH[2][isig]->clear();
57 }
58 }
59
60 clear();
61 mInitDone = true;
62 return 0;
63}
64
65//______________________________________________________________________________
67{
68 mData.clear();
69}
70
71//______________________________________________________________________________
73{
74 if (!mInitDone) {
75 init();
76 }
77 if (mVerbosity >= DbgFull) {
78 data->print();
79 }
80 mData += data;
81 if (mVerbosity >= DbgFull) {
82 mData.print();
83 }
84 return 0;
85}
86
87//______________________________________________________________________________
88// Add histograms
90{
91 if (!mInitDone) {
92 init();
93 }
94 if (ih >= 0 && ih < NChannels && iarr >= 0 && iarr < NHA) {
95 mH[iarr][ih]->add(h1);
96 } else {
97 LOG(error) << "InterCalib::add: unsupported FlatHisto1D ih=" << ih << " iarr=" << iarr;
98 }
99}
100
101//______________________________________________________________________________
102// Create calibration object
104{
105 if (mVerbosity > DbgZero) {
106 LOGF(info, "Finalizing NoiseCalibData object");
107 mData.print();
108 }
109 if (mSaveDebugHistos) {
111 }
112
113 for (int isig = 0; isig < NChannels; isig++) {
114 uint64_t en = 0;
115 double mean = 0, var = 0;
116 // N.B. Histogram is used to evaluate mean variance -> OK to use mean!
117 mData.getStat(isig, en, mean, var);
118 if (en > 0) {
119 double stdev = std::sqrt(mean / double(NTimeBinsPerBC) / double(NTimeBinsPerBC - 1));
120 mParam.setCalib(isig, stdev);
121 mParam.entries[isig] = en;
122 }
123 }
124
125 if (mVerbosity > DbgZero) {
126 mParam.print();
127 }
128
129 // Creating calibration object and info
130 auto clName = o2::utils::MemFileHelper::getClassName(mParam);
131 mInfo.setObjectType(clName);
132 auto flName = o2::ccdb::CcdbApi::generateFileName(clName);
133 mInfo.setFileName(flName);
135
136 const auto& opt = CalibParamZDC::Instance();
137 std::map<std::string, std::string> md;
138 md["config"] = opt.descr;
139 mInfo.setMetaData(md);
140 uint64_t starting = mData.mCTimeBeg;
141 if (starting >= 10000) {
142 starting = starting - 10000; // start 10 seconds before
143 }
144 uint64_t stopping = mData.mCTimeEnd + 10000; // stop 10 seconds after
145 mInfo.setStartValidityTimestamp(starting);
146 mInfo.setEndValidityTimestamp(stopping);
147 mInfo.setAdjustableEOV();
148 LOGF(info, "Validity: %llu:%llu", starting, stopping);
149
150 return 0;
151}
152
153//______________________________________________________________________________
154int NoiseCalib::saveDebugHistos(const std::string fn)
155{
156 LOG(info) << "Saving debug histograms on file " << fn;
157 int ierr = mData.saveDebugHistos(fn);
158 if (ierr != 0) {
159 return ierr;
160 }
161 TDirectory* cwd = gDirectory;
162 TFile* f = new TFile(fn.data(), "update");
163 if (f->IsZombie()) {
164 LOG(error) << "Cannot update file: " << fn;
165 return 1;
166 }
167 for (int32_t is = 0; is < NChannels; is++) {
168 auto p = mH[0][is]->createTH1F(TString::Format("hs%d", is).Data());
169 p->SetTitle(TString::Format("Baseline samples %s", ChannelNames[is].data()));
170 p->Write("", TObject::kOverwrite);
171 }
172 for (int32_t is = 0; is < NChannels; is++) {
173 auto p = mH[1][is]->createTH1F(TString::Format("hss%d", is).Data());
174 p->SetTitle(TString::Format("Bunch sum of samples %s", ChannelNames[is].data()));
175 p->Write("", TObject::kOverwrite);
176 }
177 for (int32_t is = 0; is < NChannels; is++) {
178 auto p = mH[2][is]->createTH1F(TString::Format("hsd%d", is).Data());
179 p->SetTitle(TString::Format("Baseline estimation difference %s", ChannelNames[is].data()));
180 p->Write("", TObject::kOverwrite);
181 }
182 f->Close();
183 cwd->cd();
184 return 0;
185}
ZDC calibration common parameters.
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
char error[CURL_ERROR_SIZE]
static std::string generateFileName(const std::string &inp)
Definition CcdbApi.cxx:905
void setStartValidityTimestamp(long start)
void setFileName(const std::string &nm)
void setPath(const std::string &path)
void setEndValidityTimestamp(long end)
void setObjectType(const std::string &tp)
void setMetaData(const std::map< std::string, std::string > &md)
void add(int ih, int iarr, o2::dataformats::FlatHisto1D< double > &h1)
void setSaveDebugHistos()
Definition NoiseCalib.h:43
static constexpr int NHA
Definition NoiseCalib.h:54
int process(const o2::zdc::NoiseCalibSummaryData *data)
std::array< std::array< o2::dataformats::FlatHisto1D< double > *, NChannels >, NHA > mH
Definition NoiseCalib.h:55
int saveDebugHistos(const std::string fn="ZDCNoiseCalib.root")
GLdouble f
Definition glcorearb.h:310
constexpr int NTimeBinsPerBC
Definition Constants.h:53
constexpr int NChannels
Definition Constants.h:65
constexpr int DbgFull
Definition Constants.h:210
constexpr int DbgZero
Definition Constants.h:207
constexpr std::string_view ChannelNames[]
Definition Constants.h:147
const std::string CCDBPathNoiseCalib
Definition Constants.h:231
static std::string getClassName(const T &obj)
get the class name of the object
int saveDebugHistos(const std::string fn, bool is_epn=false)
uint64_t mCTimeEnd
Time of processed time frame.
int getStat(int is, uint64_t &en, double &mean, double &var) const
uint64_t entries[NChannels]
Definition NoiseParam.h:31
void setCalib(uint32_t ich, float val)
void print() const
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"