43 TPCScalerSpec(std::shared_ptr<o2::base::GRPGeomRequest> req,
const o2::tpc::CorrectionMapsGloOpts& sclOpts,
bool enableIDCs,
bool enableMShape) : mCCDBRequest(req), mEnableIDCs(enableIDCs), mEnableMShape(enableMShape), mGlobOpts(sclOpts)
53 mIonDriftTimeMS = ic.options().get<
float>(
"ion-drift-time");
54 mMaxTimeWeightsMS = ic.options().get<
float>(
"max-time-for-weights");
55 mMShapeScalingFac = ic.options().get<
float>(
"m-shape-scaling-factor");
56 mEnableWeights = !(ic.options().get<
bool>(
"disableWeights"));
57 const bool enableStreamer = ic.options().get<
bool>(
"enableStreamer");
58 const int mshapeThreads = ic.options().get<
int>(
"n-threads");
59 mKnotsYMshape = ic.options().get<
int>(
"n-knots-y");
60 mKnotsZMshape = ic.options().get<
int>(
"n-knots-z");
65 mStreamer = std::make_unique<o2::utils::TreeStreamRedirector>(
"M_Shape.root",
"recreate");
67 mTPCCorrMapsLoader.
init(ic, mEnableIDCs);
85 if (mEnableIDCs && pc.inputs().isValid(
"tpcscaler")) {
86 pc.inputs().get<TTree*>(
"tpcscaler");
89 if (mEnableWeights && mEnableIDCs) {
90 if (pc.inputs().isValid(
"tpcscalerw")) {
94 if (mEnableMShape && pc.inputs().isValid(
"mshape")) {
95 pc.inputs().get<TTree*>(
"mshape");
103 static int runWarningMS = -1;
104 if ((mMShapeTPCScaler.
getRun() != -1) && currRun != mMShapeTPCScaler.
getRun() && runWarningMS != currRun) {
106 runWarningMS = currRun;
110 if (!boundaryPotential.mPotential.empty()) {
111 LOGP(info,
"Calculating M-shape correction from input boundary potential");
114 for (
int iz = 0; iz < mMShapeTPCScaler.
getMShapes().mZ; ++iz) {
115 for (
int iphi = 0; iphi < mMShapeTPCScaler.
getMShapes().mPhi; ++iphi) {
116 const float pot = mMShapeScalingFac * boundaryPotential.mPotential[iz];
125 std::function<
void(
int,
double,
double,
double,
double&,
double&,
double&)> getCorrections = [&sc = sc](
const int roc,
double x,
double y,
double z,
double& dx,
double& dy,
double& dz) {
142 (*mStreamer) <<
"treeMShape"
143 <<
"firstTFOrbit=" << firstTFOrbit
144 <<
"timestamp=" << timestamp
145 <<
"boundaryPotential=" << boundaryPotential
146 <<
"mMShapeScalingFac=" << mMShapeScalingFac
151 float tpcScaler = -1.f;
153 static int runWarningIDC = -1;
156 runWarningIDC = currRun;
160 float meanScaler = (scalerA + scalerC) / 2;
161 tpcScaler = meanScaler;
163 (*mStreamer) <<
"treeIDC"
164 <<
"scalerA=" << scalerA
165 <<
"scalerC=" << scalerC
166 <<
"firstTFOrbit=" << firstTFOrbit
167 <<
"timestamp=" << timestamp
177 LOGP(info,
"Publishing CTP Lumi: {} for timestamp: {}, firstTFOrbit: {}", lumiCTP, timestamp, firstTFOrbit);
187 auto* corrMap = mTPCCorrMapsLoader.
getCorrMap();
195 const float lumiScale = mTPCCorrMapsLoader.
getLumiScale();
196 std::vector<std::pair<const o2::gpu::TPCFastSpaceChargeCorrection*, float>> additionalCorrections;
200 const std::vector<std::pair<const o2::gpu::TPCFastSpaceChargeCorrection*, float>> step0{{&(corrMapRef->getCorrection()), -1.f}};
205 const std::vector<std::pair<const o2::gpu::TPCFastSpaceChargeCorrection*, float>> step1{{&(corrMapRef->getCorrection()), 1.f}};
209 additionalCorrections.emplace_back(&(corrMapRef->getCorrection()), lumiScale);
214 LOGP(info,
"Adding M-shape correction to the final map with scaling factor {}", mMShapeScalingFac);
218 if (!additionalCorrections.empty()) {
236 LOGP(info,
"Updating TPC scaler");
238 if (mIonDriftTimeMS > 0) {
239 LOGP(info,
"Setting ion drift time to: {}", mIonDriftTimeMS);
242 if (mScalerWeights.
isValid()) {
243 LOGP(info,
"Setting TPC scaler weights");
246 if (mIonDriftTimeMS == -1) {
247 overWriteIntegrationTime();
252 LOGP(info,
"Updating TPC scaler weights");
257 if (mIonDriftTimeMS == -1) {
258 overWriteIntegrationTime();
262 LOGP(info,
"Updating M-shape TPC scaler");
264 if (mMShapeTPCScaler.
getRun() == -1) {
265 LOGP(info,
"Loaded default M-Shape correction object from CCDB");
274 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
275 const bool mEnableIDCs{
true};
276 const bool mEnableMShape{
false};
278 bool mEnableWeights{
false};
279 TPCScalerWeights mScalerWeights{};
280 float mIonDriftTimeMS{-1};
281 float mMaxTimeWeightsMS{500};
283 float mMShapeScalingFac{0};
284 TPCMShapeCorrection mMShapeTPCScaler;
285 int mKnotsYMshape{4};
286 int mKnotsZMshape{4};
287 std::unique_ptr<o2::utils::TreeStreamRedirector> mStreamer;
291 void overWriteIntegrationTime()
294 if (integrationTime <= 0) {
297 if (integrationTime > mMaxTimeWeightsMS) {
298 integrationTime = mMaxTimeWeightsMS;
300 LOGP(info,
"Setting maximum integration time for weights to: {}", integrationTime);
301 mTPCScaler.setIonDriftTimeMS(integrationTime);
307 std::vector<InputSpec> inputs;
309 LOGP(info,
"Publishing IDC scalers for space-charge distortion fluctuation correction");
314 LOGP(info,
"Publishing M-shape correction map");
318 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(
true,
326 std::vector<OutputSpec> outputs;
338 AlgorithmSpec{adaptFromTask<TPCScalerSpec>(ccdbRequest, sclOpts, enableIDCs, enableMShape)},
340 {
"ion-drift-time", VariantType::Float, -1.f, {
"Overwrite ion drift time if a value >0 is provided"}},
341 {
"max-time-for-weights", VariantType::Float, 500.f, {
"Maximum possible integration time in ms when weights are used"}},
342 {
"m-shape-scaling-factor", VariantType::Float, 1.f, {
"Scale M-shape scaler with this value"}},
343 {
"disableWeights", VariantType::Bool,
false, {
"Disable weights for TPC scalers"}},
344 {
"enableStreamer", VariantType::Bool,
false, {
"Enable streaming of M-shape scalers"}},
345 {
"n-threads", VariantType::Int, 4, {
"Number of threads used for the M-shape correction"}},
346 {
"n-knots-y", VariantType::Int, 4, {
"Number of knots in y-direction used for the M-shape correction"}},
347 {
"n-knots-z", VariantType::Int, 4, {
"Number of knots in z-direction used for the M-shape correction"}}}};
Simple interface to the CDB manager.
Helper class to access load maps from CCDB.
Helper for geometry and GRP related CCDB requests.
This class contains the algorithms for calculation the distortions and corrections.
class to create TPC fast space charge correction
Helper class to extract VDrift from different sources.
auto getOrbitResetTimeMS() const
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
o2::pmr::FairMQMemoryResource * getMemoryResource(const Output &spec)
CacheId adoptContainer(const Output &, ContainerT &, CacheStrategy, o2::header::SerializationMethod)
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
float getLumiScale() const
void setLumiScaleType(tpc::LumiScaleType v)
void setLumiScaleMode(tpc::LumiScaleMode v)
const o2::gpu::TPCFastTransform * getCorrMapMShape() const
const o2::gpu::TPCFastTransform * getCorrMap() const
void setCheckCTPIDCConsistency(bool v)
void setCorrMapMShape(std::unique_ptr< o2::gpu::TPCFastTransform > &&m)
bool isCorrMapMShapeDummy() const
return returns if the correction map for the M-shape correction is a dummy spline object
const o2::gpu::TPCFastTransform * getCorrMapRef() const
float getInstLumiCTP() const
tpc::LumiScaleMode getLumiScaleMode() const
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher &matcher, void *obj)
void extractCCDBInputs(o2::framework::ProcessingContext &pc, float tpcScaler=-1.f)
void init(o2::framework::InitContext &ic, bool idcsAvailable)
static void requestCCDBInputs(std::vector< o2::framework::InputSpec > &inputs, const o2::tpc::CorrectionMapsGloOpts &gloOpts)
static void setNThreads(const int nThreads)
set the number of threads used for some of the calculations
void getCorrections(const DataT x, const DataT y, const DataT z, const Side side, DataT &corrX, DataT &corrY, DataT &corrZ) const
NumericalFields< DataT > getElectricFieldsInterpolator(const Side side) const
void calcEField(const Side side)
void setPotential(int iz, int ir, int iphi, Side side, float val)
setting the potential directly for given vertex
void calcGlobalCorrections(const Fields &formulaStruct, const int type=3)
void poissonSolver(const Side side, const DataT stoppingConvergence=1e-6, const int symmetry=0)
std::unique_ptr< TPCFastSpaceChargeCorrection > createFromGlobalCorrection(std::function< void(int roc, double gx, double gy, double gz, double &dgx, double &dgy, double &dgz)> correctionGlobal, const int nKnotsY=10, const int nKnotsZ=20)
creates TPCFastSpaceChargeCorrection object from a continious space charge correction in global coord...
void setNthreads(int n)
_______________ Settings ________________________
void mergeCorrections(o2::gpu::TPCFastSpaceChargeCorrection &mainCorrection, float scale, const std::vector< std::pair< const o2::gpu::TPCFastSpaceChargeCorrection *, float > > &additionalCorrections, bool prn)
static TPCFastSpaceChargeCorrectionHelper * instance()
Singleton.
BoundaryPotentialIFC getBoundaryPotential(const double timestamp) const
const auto & getMShapes() const
void setFromTree(TTree &tpcMShapeTree)
set this object from input tree
void endOfStream(EndOfStreamContext &eos) final
TPCScalerSpec(std::shared_ptr< o2::base::GRPGeomRequest > req, const o2::tpc::CorrectionMapsGloOpts &sclOpts, bool enableIDCs, bool enableMShape)
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void run(ProcessingContext &pc) final
void init(framework::InitContext &ic) final
void buildMap(ProcessingContext &pc)
float getMeanScaler(double timestamp, o2::tpc::Side side) const
void setIonDriftTimeMS(float ionDriftTimeMS)
void useWeights(bool useWeights)
enable usage of weights
void setFromTree(TTree &tpcScalerTree)
set this object from input tree
void setScalerWeights(const TPCScalerWeights &weights)
setting the weights for the scalers
static void requestCCDBInputs(std::vector< o2::framework::InputSpec > &inputs, bool laser=true, bool itstpcTgl=true)
void extractCCDBInputs(o2::framework::ProcessingContext &pc, bool laser=true, bool itstpcTgl=true)
const VDriftCorrFact & getVDriftObject() const
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher &matcher, void *obj)
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLdouble GLdouble GLdouble z
constexpr o2::header::DataOrigin gDataOriginCTP
constexpr o2::header::DataOrigin gDataOriginTPC
constexpr double LHCOrbitMUS
Defining ITS Vertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
std::vector< T, fair::mq::pmr::polymorphic_allocator< T > > vector
@ DerivativeMap
map(lumi) = mean_map + lumiScale * (derivativeMap) where derivativeMap = (mean_map_A - mean_map_B)
@ Linear
map(lumi) = (mean_map - referenceMap) * lumiScale + referenceMap
@ DerivativeMapMC
same DerivativeMap, but for MC
const std::unordered_map< CDBType, const std::string > CDBTypeMap
Storage name in CCDB for each calibration and parameter type.
@ TPCScaler
use TPC scaler for scaling
o2::framework::DataProcessorSpec getTPCScalerSpec(bool enableIDCs, bool enableMShape, const o2::tpc::CorrectionMapsGloOpts &sclOpts)
@ CalScaler
Scaler from IDCs or combined estimator.
@ CalScalerWeights
Weights for scalers.
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LumiScaleType lumiType
what estimator to used for corrections scaling: 0: no scaling, 1: CTP, 2: IDC
bool checkCTPIDCconsistency
check the selected CTP or IDC scaling source being consistent with mean scaler of the map
bool requestCTPLumi
request CTP Lumi regardless of what is used for corrections scaling
LumiScaleMode lumiMode
what corrections method to use: 0: classical scaling, 1: Using of the derivative map,...
float mFirstTimeStampMS
first timestamp