diff --git a/Detectors/TPC/calibration/include/TPCCalibration/TPCFastSpaceChargeCorrectionHelper.h b/Detectors/TPC/calibration/include/TPCCalibration/TPCFastSpaceChargeCorrectionHelper.h index 6aefd7ffa6b6a..eff4972679ed8 100644 --- a/Detectors/TPC/calibration/include/TPCCalibration/TPCFastSpaceChargeCorrectionHelper.h +++ b/Detectors/TPC/calibration/include/TPCCalibration/TPCFastSpaceChargeCorrectionHelper.h @@ -101,7 +101,7 @@ class TPCFastSpaceChargeCorrectionHelper void initInverse(o2::gpu::TPCFastSpaceChargeCorrection& correction, bool prn); /// initialise inverse transformation from linear combination of several input corrections - void initInverse(std::vector& corrections, const std::vector scaling, bool prn); + void initInverse(std::vector& corrections, const std::vector& scaling, bool prn); private: /// geometry initialization diff --git a/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx b/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx index 71cdde756ae1a..46eeedf2244fb 100644 --- a/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx +++ b/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx @@ -72,7 +72,8 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc) auto mshapescaler = pc.inputs().get>("mshape"); float potential = mshapescaler.first; float deltaPotPos = mshapescaler.second; - setMShapeScaler(potential); + // setMShapeScaler(potential); + setMShapeScaler(1); // not needed or as some custom scaling if (potential != 0) { LOGP(info, "Recalculating M-shape correction map for z position of delta potential {}", deltaPotPos); // update analytical map! @@ -81,11 +82,10 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc) o2::tpc::SpaceCharge::setNThreads(nthreads); const Side side = Side::A; int field = 5; - o2::tpc::SpaceCharge sc = o2::tpc::SpaceCharge(field, 257, 257, 45); + o2::tpc::SpaceCharge sc = o2::tpc::SpaceCharge(field, 129, 129, 5); - float deltaPot = 100; - sc.setIFCChargeUpFallingPot(deltaPot, deltaPotPos, 0, 250, 0, side); // 1/x - sc.setIFCChargeUpRisingPot(deltaPot, deltaPotPos, 0, 0, 0, side); + sc.setIFCChargeUpFallingPot(potential, deltaPotPos, 0, 250, 0, side); + sc.setIFCChargeUpRisingPot(potential, deltaPotPos, 0, 0, 0, side); sc.poissonSolver(side); sc.calcEField(side); diff --git a/Detectors/TPC/calibration/src/TPCFastSpaceChargeCorrectionHelper.cxx b/Detectors/TPC/calibration/src/TPCFastSpaceChargeCorrectionHelper.cxx index 980f1bda2aad1..e2960c73e4d50 100644 --- a/Detectors/TPC/calibration/src/TPCFastSpaceChargeCorrectionHelper.cxx +++ b/Detectors/TPC/calibration/src/TPCFastSpaceChargeCorrectionHelper.cxx @@ -658,7 +658,7 @@ void TPCFastSpaceChargeCorrectionHelper::initInverse(o2::gpu::TPCFastSpaceCharge initInverse(corr, std::vector{1}, prn); } -void TPCFastSpaceChargeCorrectionHelper::initInverse(std::vector& corrections, const std::vector scaling, bool prn) +void TPCFastSpaceChargeCorrectionHelper::initInverse(std::vector& corrections, const std::vector& scaling, bool prn) { /// initialise inverse transformation TStopwatch watch; diff --git a/Detectors/TPC/reconstruction/macro/createTPCSpaceChargeCorrection.C b/Detectors/TPC/reconstruction/macro/createTPCSpaceChargeCorrection.C index 723cf2ee30491..562eb63521b4f 100644 --- a/Detectors/TPC/reconstruction/macro/createTPCSpaceChargeCorrection.C +++ b/Detectors/TPC/reconstruction/macro/createTPCSpaceChargeCorrection.C @@ -212,7 +212,7 @@ void createTPCSpaceChargeCorrectionAnalytical( const int debug = 0) { // initialize space-charge object - spaceCharge = std::make_unique(); + spaceCharge = std::make_unique(5, 129, 129, 5); // default analytical formulas for distortions and corrections AnalyticalDistCorr formula; @@ -223,17 +223,45 @@ void createTPCSpaceChargeCorrectionAnalytical( formula.mDlZFormula = mDistZ; */ - spaceCharge->setDistortionsCorrectionsAnalytical(formula); - spaceCharge->setUseAnalyticalDistCorr(true); + // spaceCharge->setDistortionsCorrectionsAnalytical(formula); + // spaceCharge->setUseAnalyticalDistCorr(true); // dumping the space-charge object to file to apply it during the TPC digitizer simulation - TFile fSC("distortions_analytical.root", "RECREATE"); - spaceCharge->dumpAnalyticalCorrectionsDistortions(fSC); + // TFile fSC("distortions_analytical.root", "RECREATE"); + // spaceCharge->dumpAnalyticalCorrectionsDistortions(fSC); + + float deltaPot = 100; + float deltaPotPos = 240; + int nthreads = 10; + spaceCharge->setIFCChargeUpFallingPot(deltaPot, deltaPotPos, 0, 250, 0, Side::A); // 1/x + spaceCharge->setIFCChargeUpRisingPot(deltaPot, deltaPotPos, 0, 0, 0, Side::A); + + spaceCharge->poissonSolver(Side::A); + spaceCharge->calcEField(Side::A); + const auto numEFields = spaceCharge->getElectricFieldsInterpolator(Side::A); + spaceCharge->calcGlobalCorrections(numEFields); + + std::function getCorrections = [&spaceCharge = spaceCharge](const int roc, double x, double y, double z, double& dx, double& dy, double& dz) { + Side side = roc < 18 ? Side::A : Side::C; + if (side == Side::A) { + spaceCharge->getCorrections(x, y, z, side, dx, dy, dz); + } else { + dx = 1.2; + dy = 1.2; + dz = 1.2; + } + }; - TPCFastSpaceChargeCorrectionHelper::instance()->setNthreadsToMaximum(); - std::unique_ptr spCorrection = TPCFastSpaceChargeCorrectionHelper::instance()->createFromLocalCorrection(getLocalSpaceChargeCorrection); + TPCFastSpaceChargeCorrectionHelper::instance()->setNthreads(nthreads); + const int nKnotsY = 5; + const int nKnotsZ = 5; + std::unique_ptr spCorrection = TPCFastSpaceChargeCorrectionHelper::instance()->createFromGlobalCorrection(getCorrections, nKnotsY, nKnotsZ); std::unique_ptr fastTransform(TPCFastTransformHelperO2::instance()->create(0, *spCorrection)); + // TPCFastSpaceChargeCorrectionHelper::instance()->setNthreadsToMaximum(); + // std::unique_ptr spCorrection = TPCFastSpaceChargeCorrectionHelper::instance()->createFromLocalCorrection(getLocalSpaceChargeCorrection); + // std::unique_ptr fastTransform(TPCFastTransformHelperO2::instance()->create(0, *spCorrection)); + fastTransform->writeToFile(outputFileName, "ccdb_object"); if (debug > 0) { @@ -397,8 +425,8 @@ void debugInterpolation(utils::TreeStreamRedirector& pcstream, const o2::gpu::TPCFastTransformGeo& geo, TPCFastTransform* fastTransform) { - for (int slice = 0; slice < geo.getNumberOfSlices(); slice += 1) { - // for (int slice = 21; slice < 22; slice += 1) { + // for (int slice = 0; slice < geo.getNumberOfSlices(); slice += 1) { + for (int slice = 17; slice < 18; slice += 1) { std::cout << "debug slice " << slice << " ... " << std::endl; const o2::gpu::TPCFastTransformGeo::SliceInfo& sliceInfo = geo.getSliceInfo(slice); diff --git a/Detectors/TPC/workflow/src/TPCScalerSpec.cxx b/Detectors/TPC/workflow/src/TPCScalerSpec.cxx index 9578ffdbf8d0c..e776c0284f475 100644 --- a/Detectors/TPC/workflow/src/TPCScalerSpec.cxx +++ b/Detectors/TPC/workflow/src/TPCScalerSpec.cxx @@ -43,7 +43,7 @@ class TPCScalerSpec : public Task o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); mIonDriftTimeMS = ic.options().get("ion-drift-time"); mMaxTimeWeightsMS = ic.options().get("max-time-for-weights"); - mVShapeScalingFac = ic.options().get("v-shape-scaling-factor"); + mMShapeScalingFac = ic.options().get("m-shape-scaling-factor"); mEnableWeights = !(ic.options().get("disableWeights")); } @@ -54,17 +54,13 @@ class TPCScalerSpec : public Task pc.inputs().get("tpcscaler"); } - if (mEnableWeights) { + if (mEnableWeights && mEnableIDCs) { if (pc.inputs().isValid("tpcscalerw")) { pc.inputs().get("tpcscalerw"); } } - if (mEnableMShape && pc.inputs().isValid("vshape")) { - pc.inputs().get("vshape"); - } - - if (pc.services().get().runNumber != mTPCScaler.getRun()) { - LOGP(error, "Run number {} of processed data and run number {} of loaded TPC scaler doesnt match!", pc.services().get().runNumber, mTPCScaler.getRun()); + if (mEnableMShape && pc.inputs().isValid("mshape")) { + pc.inputs().get("mshape"); } const auto orbitResetTimeMS = o2::base::GRPGeomHelper::instance().getOrbitResetTimeMS(); @@ -72,6 +68,9 @@ class TPCScalerSpec : public Task const double timestamp = orbitResetTimeMS + firstTFOrbit * o2::constants::lhc::LHCOrbitMUS * 0.001; if (mEnableIDCs) { + if (pc.services().get().runNumber != mTPCScaler.getRun()) { + LOGP(error, "Run number {} of processed data and run number {} of loaded TPC scaler doesnt match!", pc.services().get().runNumber, mTPCScaler.getRun()); + } float scalerA = mTPCScaler.getMeanScaler(timestamp, o2::tpc::Side::A); float scalerC = mTPCScaler.getMeanScaler(timestamp, o2::tpc::Side::C); float meanScaler = (scalerA + scalerC) / 2; @@ -80,16 +79,14 @@ class TPCScalerSpec : public Task } if (mEnableMShape) { - // double tsMiddleTF = timestamp + o2::base::GRPGeomHelper::instance().getNHBFPerTF() / 2 * o2::constants::lhc::LHCOrbitMUS * 0.001; - // // float vshapescaler = mVShapeScalingFac * mVShapeTPCScaler.getScaler(tsMiddleTF); - // // LOGP(info, "Publishing TPC V-shape scaler: {} for timestamp {}, firstTFOrbit: {} with VShapeScalingFac: {}", vshapescaler, long(timestamp), firstTFOrbit, mVShapeScalingFac); - // // pc.outputs().snapshot(Output{header::gDataOriginTPC, "TPCMShapeScaler"}, vshapescaler); - double tsMiddleTF = timestamp + o2::base::GRPGeomHelper::instance().getNHBFPerTF() / 2 * o2::constants::lhc::LHCOrbitMUS * 0.001; - const auto scalers = mVShapeTPCScaler.getScaler(tsMiddleTF); - float vshapescaler = mVShapeScalingFac * scalers.first; + if (pc.services().get().runNumber != mMShapeTPCScaler.getRun()) { + LOGP(error, "Run number {} of processed data and run number {} of loaded TPC M-shape scaler doesnt match!", pc.services().get().runNumber, mMShapeTPCScaler.getRun()); + } + const auto scalers = mMShapeTPCScaler.getScaler(timestamp); + float mshapescaler = mMShapeScalingFac * scalers.first; float zPos = scalers.first; - LOGP(info, "Publishing TPC V-shape scaler: {} for timestamp {}, firstTFOrbit: {} with VShapeScalingFac: {}", vshapescaler, long(timestamp), firstTFOrbit, mVShapeScalingFac); - pc.outputs().snapshot(Output{header::gDataOriginTPC, "TPCMShapeScaler"}, dataformats::Pair{vshapescaler, zPos}); + LOGP(info, "Publishing TPC M-shape scaler: {} for timestamp {}, firstTFOrbit: {} with MShapeScalingFac: {}", mshapescaler, long(timestamp), firstTFOrbit, mMShapeScalingFac); + pc.outputs().snapshot(Output{header::gDataOriginTPC, "TPCMShapeScaler"}, dataformats::Pair{mshapescaler, zPos}); } } @@ -121,9 +118,9 @@ class TPCScalerSpec : public Task if (mIonDriftTimeMS == -1) { overWriteIntegrationTime(); } - } else if (matcher == ConcreteDataMatcher(o2::header::gDataOriginTPC, "VSHAPESCALERCCDB", 0)) { - LOGP(info, "Updating V-shape TPC scaler"); - mVShapeTPCScaler.setFromTree(*((TTree*)obj)); + } else if (matcher == ConcreteDataMatcher(o2::header::gDataOriginTPC, "MSHAPESCALERCCDB", 0)) { + LOGP(info, "Updating M-shape TPC scaler"); + mMShapeTPCScaler.setFromTree(*((TTree*)obj)); } } @@ -136,8 +133,8 @@ class TPCScalerSpec : public Task float mIonDriftTimeMS{-1}; ///< ion drift time float mMaxTimeWeightsMS{500}; ///< maximum integration time when weights are used TPCScaler mTPCScaler; ///< tpc scaler - float mVShapeScalingFac{0}; ///< scale v-shape scalers with this value - TPCMShapeScaler mVShapeTPCScaler; ///< TPC V-shape scalers + float mMShapeScalingFac{0}; ///< scale m-shape scalers with this value + TPCMShapeScaler mMShapeTPCScaler; ///< TPC M-shape scalers void overWriteIntegrationTime() { @@ -162,12 +159,12 @@ o2::framework::DataProcessorSpec getTPCScalerSpec(bool enableIDCs, bool enableMS inputs.emplace_back("tpcscalerw", o2::header::gDataOriginTPC, "TPCSCALERWCCDB", 0, Lifetime::Condition, ccdbParamSpec(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalScalerWeights), {}, 0)); // non time-dependent } if (enableMShape) { - LOGP(info, "Publishing V-shape scalers for V-shape distortion fluctuation correction"); - inputs.emplace_back("vshape", o2::header::gDataOriginTPC, "VSHAPESCALERCCDB", 0, Lifetime::Condition, ccdbParamSpec(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalMShape), {}, 1)); // time-dependent + LOGP(info, "Publishing M-shape scalers for M-shape distortion fluctuation correction"); + inputs.emplace_back("mshape", o2::header::gDataOriginTPC, "MSHAPESCALERCCDB", 0, Lifetime::Condition, ccdbParamSpec(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalMShape), {}, 1)); // time-dependent } auto ccdbRequest = std::make_shared(true, // orbitResetTime - enableMShape, // GRPECS=true for nHBF per TF + false, // GRPECS=true for nHBF per TF false, // GRPLHCIF false, // GRPMagField false, // askMatLUT @@ -175,7 +172,9 @@ o2::framework::DataProcessorSpec getTPCScalerSpec(bool enableIDCs, bool enableMS inputs); std::vector outputs; - outputs.emplace_back(o2::header::gDataOriginTPC, "TPCSCALER", 0, Lifetime::Timeframe); + if (enableIDCs) { + outputs.emplace_back(o2::header::gDataOriginTPC, "TPCSCALER", 0, Lifetime::Timeframe); + } if (enableMShape) { outputs.emplace_back(o2::header::gDataOriginTPC, "TPCMShapeScaler", 0, Lifetime::Timeframe); } @@ -188,7 +187,7 @@ o2::framework::DataProcessorSpec getTPCScalerSpec(bool enableIDCs, bool enableMS Options{ {"ion-drift-time", VariantType::Float, -1.f, {"Overwrite ion drift time if a value >0 is provided"}}, {"max-time-for-weights", VariantType::Float, 500.f, {"Maximum possible integration time in ms when weights are used"}}, - {"v-shape-scaling-factor", VariantType::Float, 1.f, {"Scale V-shape scaler with this value"}}, + {"m-shape-scaling-factor", VariantType::Float, 1.f, {"Scale M-shape scaler with this value"}}, {"disableWeights", VariantType::Bool, false, {"Disable weights for TPC scalers"}}}}; } diff --git a/Detectors/TPC/workflow/src/tpc-scaler.cxx b/Detectors/TPC/workflow/src/tpc-scaler.cxx index cf0b0e21c1736..598687c7dff41 100644 --- a/Detectors/TPC/workflow/src/tpc-scaler.cxx +++ b/Detectors/TPC/workflow/src/tpc-scaler.cxx @@ -24,8 +24,7 @@ void customize(std::vector& workflowOptions) std::vector options{ ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}, {"enable-M-shape-correction", VariantType::Bool, false, {"Enable M-shape distortion correction"}}, - {"disable-IDC-scalers", VariantType::Bool, false, {"Disable TPC scalers for space-charge distortion fluctuation correction"}}, - {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}}; + {"disable-IDC-scalers", VariantType::Bool, false, {"Disable TPC scalers for space-charge distortion fluctuation correction"}}}; std::swap(workflowOptions, options); }