Project
Loading...
Searching...
No Matches
TDCCalibEPN.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 <TPad.h>
15#include <TString.h>
16#include <TStyle.h>
17#include <TDirectory.h>
18#include <TPaveStats.h>
19#include <TAxis.h>
23#include "ZDCCalib/TDCCalib.h"
26#include "ZDCReconstruction/ZDCTDCParam.h" //added by me
27#include "Framework/Logger.h"
28
29using namespace o2::zdc;
30
32{
33 if (mTDCCalibConfig == nullptr) {
34 LOG(fatal) << "o2::zdc::TDCCalibEPN: missing configuration object";
35 return -1;
36 }
37
38 // Inspect calibration parameters
39 const auto& opt = CalibParamZDC::Instance();
40 opt.print();
41 if (opt.debugOutput == true) {
43 }
44
45 clear();
46 auto* cfg = mTDCCalibConfig;
47 int ih;
48 // clang-format off
49 for (int iTDC = 0; iTDC < NTDC; iTDC++) {
50 mTDC[iTDC] = new o2::dataformats::FlatHisto1D<float>(cfg->nb1[iTDC], cfg->amin1[iTDC], cfg->amax1[iTDC]);
51 if(mSaveDebugHistos){
52 mTDCSum[iTDC] = new o2::dataformats::FlatHisto1D<float>(cfg->nb1[iTDC], cfg->amin1[iTDC], cfg->amax1[iTDC]);
53 }
54 }
55 // clang-format on
56 mInitDone = true;
57 return 0;
58}
59
60//----//
61
62int TDCCalibEPN::process(const gsl::span<const o2::zdc::BCRecData>& RecBC,
63 const gsl::span<const o2::zdc::ZDCEnergy>& Energy,
64 const gsl::span<const o2::zdc::ZDCTDCData>& TDCData,
65 const gsl::span<const uint16_t>& Info)
66{
67 if (!mInitDone) {
68 init();
69 }
70 if (mVerbosity > DbgMinimal) {
71 LOG(info) << "o2::zdc::TDCCalibEPN processing " << RecBC.size() << " b.c. @ TS " << mData.mCTimeBeg << " : " << mData.mCTimeEnd;
72 }
74 ev.init(RecBC, Energy, TDCData, Info);
75 while (ev.next()) {
76 if (ev.getNInfo() > 0) {
77 auto& decodedInfo = ev.getDecodedInfo();
78 for (uint16_t info : decodedInfo) {
79 uint8_t ch = (info >> 10) & 0x1f;
80 uint16_t code = info & 0x03ff;
81 // hmsg->Fill(ch, code);
82 }
83 if (mVerbosity > DbgMinimal) {
84 ev.print();
85 }
86 // Need clean data (no messages)
87 // We are sure there is no pile-up in any channel (too restrictive?)
88 continue;
89 }
90 if (ev.getNEnergy() > 0 && ev.mCurB.triggers == 0) {
91 LOGF(info, "%9u.%04u Untriggered bunch", ev.mCurB.ir.orbit, ev.mCurB.ir.bc);
92 // Skip!
93 continue;
94 }
95
96 // Fill 1d histograms with tdc values. Check if channel is acquired or not
97 for (int itdc = 0; itdc < NTDC; itdc++) { // loop over all TDCs
98 int nhits = ev.NtdcV(itdc);
99
100 if (nhits > 0) {
101 // call fill function to fill histo
102 fill1D(itdc, nhits, ev);
103 }
104 }
105 }
106 return 0;
107}
108
109//----//
110
112{
113 if (mVerbosity > DbgZero) {
114 LOGF(info, "TDCCalibEPN::endOfRun ts (%llu:%llu)", mData.mCTimeBeg, mData.mCTimeEnd);
115 if (mVerbosity > DbgMinimal) {
116 for (int ih = 0; ih < NTDC; ih++) {
117 LOGF(info, "%s %i events and cuts (%g:%g)", TDCCalibData::CTDC[ih], mData.entries[ih], mTDCCalibConfig->cutLow[ih], mTDCCalibConfig->cutHigh[ih]);
118 }
119 }
120 }
121 if (mSaveDebugHistos) {
122 write();
123 }
124 return 0;
125}
126
127//----//
128
130{
131 for (int32_t ii = 0; ii < NTDC; ii++) {
132 if (mTDC[ii]) {
133 mTDC[ii]->clear();
134 }
135 mData.entries[ii] = 0;
136 }
137 mData.mCTimeBeg = 0;
138 mData.mCTimeEnd = 0;
139}
140
141//----//
142
143void TDCCalibEPN::fill1D(int iTDC, int nHits, o2::zdc::RecEventFlat ev)
144{
145 // Get TDC values
146 float tdcVal[nHits];
147 for (int i = 0; i < nHits; i++) {
148 tdcVal[i] = ev.tdcV(iTDC, i);
149 }
150
151 // Fill histo
152 for (int hit = 0; hit < nHits; hit++) {
153 mTDC[iTDC]->fill(tdcVal[hit]);
154 if (mSaveDebugHistos) {
155 mTDCSum[iTDC]->fill(tdcVal[hit]);
156 }
157 }
158 mData.entries[iTDC] += nHits;
159}
160
161//----//
162
163int TDCCalibEPN::write(const std::string fn)
164{
165 if (mVerbosity > DbgZero) {
166 LOG(info) << "Saving EPN debug histograms on file " << fn;
167 }
168 TDirectory* cwd = gDirectory;
169 TFile* f = new TFile(fn.data(), "recreate");
170 if (f->IsZombie()) {
171 LOG(error) << "Cannot create file: " << fn;
172 return 1;
173 }
174 for (int32_t ih = 0; ih < NTDC; ih++) {
175 if (mTDCSum[ih]) {
176 auto p = mTDCSum[ih]->createTH1F(TDCCalibData::CTDC[ih]);
177 p->SetTitle(TDCCalibData::CTDC[ih]);
178 p->Write("", TObject::kOverwrite);
179 if (mVerbosity > DbgMinimal) {
180 LOG(info) << p->GetName() << " entries: " << p->GetEntries();
181 }
182 }
183 }
184 f->Close();
185 cwd->cd();
186 return 0;
187}
ZDC calibration common parameters.
unsigned char uint8_t
unsigned short int uint16_t
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]
TDC calibration intermediate data.
ZDC Energy calibration.
Parameters to correct TDCs (produced by QA)
ZDC Tower calibration.
int write(const std::string fn="ZDCTDCCalibEPN.root")
void fill1D(int iTDC, int nHits, o2::zdc::RecEventFlat ev)
TDCCalibData mData
Definition TDCCalibEPN.h:66
std::array< o2::dataformats::FlatHisto1D< float > *, NTDC > mTDC
Definition TDCCalibEPN.h:68
std::array< o2::dataformats::FlatHisto1D< float > *, NTDC > mTDCSum
Definition TDCCalibEPN.h:69
int process(const gsl::span< const o2::zdc::BCRecData > &bcrec, const gsl::span< const o2::zdc::ZDCEnergy > &energy, const gsl::span< const o2::zdc::ZDCTDCData > &tdc, const gsl::span< const uint16_t > &info)
static constexpr int NTDC
Definition TDCCalibEPN.h:50
GLdouble f
Definition glcorearb.h:310
constexpr int DbgMinimal
Definition Constants.h:208
constexpr int DbgZero
Definition Constants.h:207
uint32_t orbit
LHC orbit.
uint16_t bc
bunch crossing ID of interaction
uint32_t triggers
Definition BCRecData.h:34
o2::InteractionRecord ir
Definition BCRecData.h:32
int NtdcV(uint8_t ich) const
float tdcV(uint8_t ich, uint64_t ipos) const
BCRecData mCurB
End of sequence.
NElem getNEnergy() const
void init(const std::vector< o2::zdc::BCRecData > *RecBC, const std::vector< o2::zdc::ZDCEnergy > *Energy, const std::vector< o2::zdc::ZDCTDCData > *TDCData, const std::vector< uint16_t > *Info)
Trigger mask for printout.
const std::vector< uint16_t > & getDecodedInfo()
NElem getNInfo() const
double cutLow[NTDCChannels]
double cutHigh[NTDCChannels]
uint64_t mCTimeBeg
ZNAC, ZNAS, ZPAC, ZPAS, ZEM1, ZEM2, ZNCC, ZNCS, ZPCC, ZPCS.
uint64_t mCTimeEnd
Time of processed time frame.
static constexpr const char * CTDC[NTDC]
Time of processed time frame.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"