Project
Loading...
Searching...
No Matches
GRPLHCIFfileSpec.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
13
16#include "Framework/Logger.h"
18#include "CCDB/CcdbApi.h"
19#include "CCDB/CcdbObjectInfo.h"
22#include "CommonTypes/Units.h"
23
24#include <chrono>
25#include <cstdint>
26
27using namespace o2::framework;
28using HighResClock = std::chrono::high_resolution_clock;
29using Duration = std::chrono::duration<double, std::ratio<1, 1>>;
31
32namespace o2
33{
34namespace grp
35{
36
38{
39 mVerbose = ic.options().get<bool>("use-verbose-mode");
40 LOG(info) << " ************************* Verbose?" << mVerbose;
41}
42
43//__________________________________________________________________
44
46{
47 auto configBuff = pc.inputs().get<gsl::span<char>>("inputConfig");
48 auto configFileName = pc.inputs().get<std::string>("inputConfigFileName");
49 auto timer = std::chrono::duration_cast<std::chrono::milliseconds>(HighResClock::now().time_since_epoch()).count();
50 LOG(info) << "got input file " << configFileName << " of size " << configBuff.size();
51 mReader.loadLHCIFfile(configBuff);
52 std::vector<std::pair<long, std::vector<int32_t>>> beamEnergy;
53 std::vector<std::pair<long, std::vector<std::string>>> injScheme;
54 std::vector<std::pair<long, std::vector<std::string>>> fillNb;
55 std::vector<std::pair<long, std::vector<int32_t>>> atomicNbB1;
56 std::vector<std::pair<long, std::vector<int32_t>>> atomicNbB2;
57 std::vector<std::pair<long, std::vector<o2::units::AngleRad_t>>> crossAngle;
58 std::vector<std::pair<long, std::vector<int32_t>>> bunchConfigB1;
59 std::vector<std::pair<long, std::vector<int32_t>>> bunchConfigB2;
60
61 int nEle = 0;
62 int nMeas = 0;
63 std::string type{""};
64
65 GRPLHCIFData lhcifdata;
66
67 // Beam Energy
68 mReader.readValue<int32_t>("BEAM_ENERGY", type, nEle, nMeas, beamEnergy);
69 if (nMeas == 0) {
70 LOG(warn) << "Beam energy not present/empty"; // RS: in absence of the beam it is empty, don't produce an error
71 }
72 if (nEle > 1 || nMeas > 1) {
73 LOGP(warn, "More than one value/measurement {}/{} found for Beam Energy, keeping the last one", nEle, nMeas);
74 }
75 if (!beamEnergy.empty()) {
76 lhcifdata.setBeamEnergyPerZWithTime(beamEnergy.back().first, beamEnergy.back().second.back());
77 }
78 // Injection scheme
79 mReader.readValue<std::string>("INJECTION_SCHEME", type, nEle, nMeas, injScheme);
80 if (nMeas == 0) {
81 LOG(warn) << "Injection scheme not present/empty"; // RS: same comment
82 }
83 if (nEle > 1 || nMeas > 1) {
84 LOGP(warn, "More than one value/measurement {}/{} found for Injection Scheme, keeping the last one", nEle, nMeas);
85 }
86 if (!injScheme.empty()) {
87 lhcifdata.setInjectionSchemeWithTime(injScheme.back().first, injScheme.back().second.back());
88 }
89
90 // fill number
91 mReader.readValue<std::string>("FILL_NUMBER", type, nEle, nMeas, fillNb);
92 if (nMeas == 0) {
93 LOG(warn) << "Fill Number not present/empty";
94 }
95 if (nEle > 1 || nMeas > 1) {
96 LOG(warn) << "More than one value/measurement found for Fill Number, keeping the last one";
97 }
98 if (!fillNb.empty()) {
99 lhcifdata.setFillNumberWithTime(fillNb.back().first, atoi(fillNb.back().second.back().c_str()));
100 }
101
102 // Atomic Number (Z) for B1
103 mReader.readValue<int32_t>("ATOMIC_NUMBER_B1", type, nEle, nMeas, atomicNbB1);
104 if (nMeas == 0) {
105 LOG(warn) << "Atomic Number Beam 1 (clockwise) not present/empty"; // RS same comment
106 }
107 if (nEle > 1 || nMeas > 1) {
108 LOGP(warn, "More than one value/measurement {}/{} found for Atomic Number Beam 1 (clockwise), keeping the last one", nEle, nMeas);
109 }
110 if (!atomicNbB1.empty()) {
111 lhcifdata.setAtomicNumberB1WithTime(atomicNbB1.back().first, atomicNbB1.back().second.back());
112 }
113
114 // Atomic Number (Z) for B2
115 mReader.readValue<int32_t>("ATOMIC_NUMBER_B2", type, nEle, nMeas, atomicNbB2);
116 if (nMeas == 0) {
117 LOG(warn) << "Atomic Number Beam 2 (anticlockwise) not present/empty";
118 }
119 if (nEle > 1 || nMeas > 1) {
120 LOGP(warn, "More than one value/measurement {}/{} found for Atomic Number Beam 2 (anticlockwise), keeping the last one", nEle, nMeas);
121 }
122 if (!atomicNbB2.empty()) {
123 lhcifdata.setAtomicNumberB2WithTime(atomicNbB2.back().first, atomicNbB2.back().second.back());
124 }
125
126 // Crossing Angle
127 mReader.readValue<float>("IP2_XING_V_MURAD", type, nEle, nMeas, crossAngle);
128 if (nMeas == 0) {
129 LOG(warn) << "Crossing Angle not present/empty";
130 }
131 if (nEle > 1 || nMeas > 1) {
132 LOGP(warn, "More than one value/measurement {}/{} found for Crossing Angle, keeping the last one", nEle, nMeas);
133 }
134 if (!crossAngle.empty()) {
135 lhcifdata.setCrossingAngleWithTime(crossAngle.back().first, crossAngle.back().second.back());
136 }
137
138 // Bunch Config for B1
139 mReader.readValue<int>("CIRCULATING_BUNCH_CONFIG_BEAM1", type, nEle, nMeas, bunchConfigB1);
140 if (nMeas == 0) {
141 LOG(warn) << "Bunch Config Beam 1 not present/empty";
142 }
143 if (nMeas > 1) {
144 LOGP(warn, "More than one measurement {} found for Bunch Config Beam 1, keeping the last one", nMeas);
145 }
146
147 // Bunch Config for B2
148 mReader.readValue<int>("CIRCULATING_BUNCH_CONFIG_BEAM2", type, nEle, nMeas, bunchConfigB2);
149 if (nMeas == 0) {
150 LOG(warn) << "Bunch Config Beam 2 not present/empty";
151 }
152 if (nMeas > 1) {
153 LOGP(warn, "More than one measurement {} found for Bunch Config Beam 2, keeping the last one", nMeas);
154 }
155
156 // Building Bunch Filling
157 if (!bunchConfigB1.empty() && !bunchConfigB2.empty()) {
158 o2::BunchFilling bunchFilling;
159 bunchFilling.buckets2BeamPattern(bunchConfigB1.back().second, 0);
160 bunchFilling.buckets2BeamPattern(bunchConfigB2.back().second, 1);
161 bunchFilling.setInteractingBCsFromBeams();
162 lhcifdata.setBunchFillingWithTime((bunchConfigB1.back().first + bunchConfigB2.back().first) / 2, bunchFilling);
163 }
164
165 lhcifdata.setBeamAZ();
166
167 if (mVerbose) {
168 LOG(info) << " **** Beam Energy ****";
169 for (auto& el : beamEnergy) {
170 for (auto elVect : el.second) {
171 std::cout << el.first << " --> " << elVect << std::endl;
172 }
173 }
174 LOG(info) << " **** Injection Scheme ****";
175 for (auto& el : injScheme) {
176 for (auto elVect : el.second) {
177 std::cout << el.first << " --> " << elVect << std::endl;
178 }
179 }
180 LOG(info) << " **** Fill Number ****";
181 for (auto& el : fillNb) {
182 for (auto elVect : el.second) {
183 std::cout << el.first << " --> " << elVect << std::endl;
184 }
185 }
186 LOG(info) << " **** Atomic Number Beam 1 (clockwise) ****";
187 for (auto& el : atomicNbB1) {
188 for (auto elVect : el.second) {
189 std::cout << el.first << " --> " << elVect << std::endl;
190 }
191 }
192 LOG(info) << " **** Atomic Number B2 (anticlockwise) ****";
193 for (auto& el : atomicNbB2) {
194 for (auto elVect : el.second) {
195 std::cout << el.first << " --> " << elVect << std::endl;
196 }
197 }
198 LOG(info) << " **** Crossing Angle ****";
199 for (auto& el : crossAngle) {
200 for (auto elVect : el.second) {
201 std::cout << el.first << " --> " << elVect << std::endl;
202 }
203 }
204 }
205
206 sendOutput(pc.outputs(), timer, lhcifdata);
207}
208
209//__________________________________________________________________
210
214
215//__________________________________________________________________
216
217void GRPLHCIFfileProcessor::sendOutput(DataAllocator& output, long start, const GRPLHCIFData& lhcifdata)
218{
219 // sending output to CCDB
220
222 auto clName = o2::utils::MemFileHelper::getClassName(lhcifdata);
223 auto flName = o2::ccdb::CcdbApi::generateFileName(clName);
224 std::map<std::string, std::string> md;
225 md.emplace("created_by", "dpl");
226 if (lhcifdata.getFillNumberTime()) {
227 md.emplace("fillNumber", fmt::format("{}", lhcifdata.getFillNumber()));
228 }
229 o2::ccdb::CcdbObjectInfo info("GLO/Config/GRPLHCIF", clName, flName, md, start, start + o2::ccdb::CcdbObjectInfo::MONTH);
230 auto image = o2::ccdb::CcdbApi::createObjectImage(&lhcifdata, &info);
231 LOG(info) << "Sending object " << info.getPath() << "/" << info.getFileName() << " of size " << image->size()
232 << " bytes, valid for " << info.getStartValidityTimestamp() << " : " << info.getEndValidityTimestamp();
233 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "GRP_LHCIFData", 0}, *image.get()); // vector<char>
234 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "GRP_LHCIFData", 0}, info); // root-serialized
235}
236
237} // namespace grp
238
239namespace framework
240{
241DataProcessorSpec getGRPLHCIFfileSpec()
242{
243 std::vector<OutputSpec> outputs;
244 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "GRP_LHCIFData"}, Lifetime::Sporadic);
245 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "GRP_LHCIFData"}, Lifetime::Sporadic);
246 return DataProcessorSpec{
247 "grp-lhc-if-file-processor",
248 Inputs{{"inputConfig", "GRP", "DCS_CONFIG_FILE", Lifetime::Sporadic},
249 {"inputConfigFileName", "GRP", "DCS_CONFIG_NAME", Lifetime::Sporadic}},
250 outputs,
251 AlgorithmSpec{adaptFromTask<o2::grp::GRPLHCIFfileProcessor>()},
252 Options{{"use-verbose-mode", VariantType::Bool, false, {"Use verbose mode"}}}};
253}
254
255} // namespace framework
256} // namespace o2
Utils and constants for calibration and related workflows.
std::chrono::duration< double, std::ratio< 1, 1 > > Duration
std::chrono::high_resolution_clock HighResClock
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
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
Header to collect definitions for different units.
void setInteractingBCsFromBeams()
void buckets2BeamPattern(const std::vector< int > &buckets, int ibeam)
static std::string generateFileName(const std::string &inp)
Definition CcdbApi.cxx:905
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
Definition CcdbApi.h:109
static constexpr long MONTH
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void readValue(const std::string &alias, std::string &type, int &nel, int &nmeas, std::vector< std::pair< long, std::vector< T > > > &meas)
void loadLHCIFfile(const std::string &fileName)
void setBeamAZ(int a, int z, beamDirection beam)
void setBunchFillingWithTime(std::pair< long, o2::BunchFilling > p)
void setBeamEnergyPerZWithTime(std::pair< long, int32_t > p)
void setCrossingAngleWithTime(std::pair< long, o2::units::AngleRad_t > p)
void setAtomicNumberB1WithTime(std::pair< long, int32_t > p)
void setFillNumberWithTime(std::pair< long, int32_t > p)
int32_t getFillNumber() const
void setInjectionSchemeWithTime(std::pair< long, std::string > p)
void setAtomicNumberB2WithTime(std::pair< long, int32_t > p)
GLeglImageOES image
Definition glcorearb.h:4021
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< InputSpec > Inputs
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
Definition Utils.h:44
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
Definition Utils.h:43
static std::string getClassName(const T &obj)
get the class name of the object
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"