41 TPCScalerSpec(std::shared_ptr<o2::base::GRPGeomRequest> req,
bool enableIDCs,
bool enableMShape) : mCCDBRequest(req), mEnableIDCs(enableIDCs), mEnableMShape(enableMShape){};
46 mIonDriftTimeMS = ic.options().get<
float>(
"ion-drift-time");
47 mMaxTimeWeightsMS = ic.options().get<
float>(
"max-time-for-weights");
48 mMShapeScalingFac = ic.options().get<
float>(
"m-shape-scaling-factor");
49 mEnableWeights = !(ic.options().get<
bool>(
"disableWeights"));
50 const bool enableStreamer = ic.options().get<
bool>(
"enableStreamer");
51 const int mshapeThreads = ic.options().get<
int>(
"n-threads");
52 mKnotsYMshape = ic.options().get<
int>(
"n-knots-y");
53 mKnotsZMshape = ic.options().get<
int>(
"n-knots-z");
58 mStreamer = std::make_unique<o2::utils::TreeStreamRedirector>(
"M_Shape.root",
"recreate");
72 if (mEnableIDCs && pc.inputs().isValid(
"tpcscaler")) {
73 pc.inputs().get<TTree*>(
"tpcscaler");
76 if (mEnableWeights && mEnableIDCs) {
77 if (pc.inputs().isValid(
"tpcscalerw")) {
81 if (mEnableMShape && pc.inputs().isValid(
"mshape")) {
82 pc.inputs().get<TTree*>(
"mshape");
90 static int runWarningMS = -1;
91 if ((mMShapeTPCScaler.
getRun() != -1) && currRun != mMShapeTPCScaler.
getRun() && runWarningMS != currRun) {
93 runWarningMS = currRun;
97 if (!boundaryPotential.mPotential.empty()) {
98 LOGP(info,
"Calculating M-shape correction from input boundary potential");
101 for (
int iz = 0; iz < mMShapeTPCScaler.
getMShapes().mZ; ++iz) {
102 for (
int iphi = 0; iphi < mMShapeTPCScaler.
getMShapes().mPhi; ++iphi) {
103 const float pot = mMShapeScalingFac * boundaryPotential.mPotential[iz];
112 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) {
128 LOGP(info,
"Sending default (no) M-shape correction");
134 (*mStreamer) <<
"treeMShape"
135 <<
"firstTFOrbit=" << firstTFOrbit
136 <<
"timestamp=" << timestamp
137 <<
"boundaryPotential=" << boundaryPotential
138 <<
"mMShapeScalingFac=" << mMShapeScalingFac
144 static int runWarningIDC = -1;
147 runWarningIDC = currRun;
151 float meanScaler = (scalerA + scalerC) / 2;
152 LOGP(info,
"Publishing TPC scaler: {} for timestamp: {}, firstTFOrbit: {}", meanScaler, timestamp, firstTFOrbit);
155 (*mStreamer) <<
"treeIDC"
156 <<
"scalerA=" << scalerA
157 <<
"scalerC=" << scalerC
158 <<
"firstTFOrbit=" << firstTFOrbit
159 <<
"timestamp=" << timestamp
169 LOGP(info,
"Updating TPC scaler");
171 if (mIonDriftTimeMS > 0) {
172 LOGP(info,
"Setting ion drift time to: {}", mIonDriftTimeMS);
175 if (mScalerWeights.
isValid()) {
176 LOGP(info,
"Setting TPC scaler weights");
179 if (mIonDriftTimeMS == -1) {
180 overWriteIntegrationTime();
185 LOGP(info,
"Updating TPC scaler weights");
190 if (mIonDriftTimeMS == -1) {
191 overWriteIntegrationTime();
195 LOGP(info,
"Updating M-shape TPC scaler");
197 if (mMShapeTPCScaler.
getRun() == -1) {
198 LOGP(info,
"Loaded default M-Shape correction object from CCDB");
204 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
205 const bool mEnableIDCs{
true};
206 const bool mEnableMShape{
false};
207 bool mEnableWeights{
false};
208 TPCScalerWeights mScalerWeights{};
209 float mIonDriftTimeMS{-1};
210 float mMaxTimeWeightsMS{500};
211 TPCScaler mTPCScaler;
212 float mMShapeScalingFac{0};
213 TPCMShapeCorrection mMShapeTPCScaler;
214 int mKnotsYMshape{4};
215 int mKnotsZMshape{4};
216 std::unique_ptr<o2::utils::TreeStreamRedirector> mStreamer;
218 void overWriteIntegrationTime()
221 if (integrationTime <= 0) {
224 if (integrationTime > mMaxTimeWeightsMS) {
225 integrationTime = mMaxTimeWeightsMS;
227 LOGP(info,
"Setting maximum integration time for weights to: {}", integrationTime);
228 mTPCScaler.setIonDriftTimeMS(integrationTime);
234 std::vector<InputSpec> inputs;
236 LOGP(info,
"Publishing IDC scalers for space-charge distortion fluctuation correction");
241 LOGP(info,
"Publishing M-shape correction map");
245 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(
true,
253 std::vector<OutputSpec> outputs;
265 AlgorithmSpec{adaptFromTask<TPCScalerSpec>(ccdbRequest, enableIDCs, enableMShape)},
267 {
"ion-drift-time", VariantType::Float, -1.f, {
"Overwrite ion drift time if a value >0 is provided"}},
268 {
"max-time-for-weights", VariantType::Float, 500.f, {
"Maximum possible integration time in ms when weights are used"}},
269 {
"m-shape-scaling-factor", VariantType::Float, 1.f, {
"Scale M-shape scaler with this value"}},
270 {
"disableWeights", VariantType::Bool,
false, {
"Disable weights for TPC scalers"}},
271 {
"enableStreamer", VariantType::Bool,
false, {
"Enable streaming of M-shape scalers"}},
272 {
"n-threads", VariantType::Int, 4, {
"Number of threads used for the M-shape correction"}},
273 {
"n-knots-y", VariantType::Int, 4, {
"Number of knots in y-direction used for the M-shape correction"}},
274 {
"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 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
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)
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 ________________________
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
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
TPCScalerSpec(std::shared_ptr< o2::base::GRPGeomRequest > req, bool enableIDCs, bool enableMShape)
void run(ProcessingContext &pc) final
void init(framework::InitContext &ic) final
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
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLdouble GLdouble GLdouble z
constexpr o2::header::DataOrigin gDataOriginTPC
constexpr double LHCOrbitMUS
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getTPCScalerSpec(bool enableIDCs, bool enableMShape)
const std::unordered_map< CDBType, const std::string > CDBTypeMap
Storage name in CCDB for each calibration and parameter type.
@ 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 ...
float mFirstTimeStampMS
first timestamp