diff --git a/Detectors/TPC/workflow/src/TPCScalerSpec.cxx b/Detectors/TPC/workflow/src/TPCScalerSpec.cxx index 198b42f5be565..752d5bfd7d637 100644 --- a/Detectors/TPC/workflow/src/TPCScalerSpec.cxx +++ b/Detectors/TPC/workflow/src/TPCScalerSpec.cxx @@ -40,6 +40,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"); } void run(ProcessingContext& pc) final @@ -83,6 +84,9 @@ class TPCScalerSpec : public Task LOGP(info, "Setting TPC scaler weights"); mTPCScaler.setScalerWeights(mScalerWeights); mTPCScaler.useWeights(true); + if (mIonDriftTimeMS == -1) { + overWriteIntegrationTime(); + } } } if (matcher == ConcreteDataMatcher(o2::header::gDataOriginTPC, "TPCSCALERWCCDB", 0)) { @@ -90,6 +94,10 @@ class TPCScalerSpec : public Task mScalerWeights = *(TPCScalerWeights*)obj; mTPCScaler.setScalerWeights(mScalerWeights); mTPCScaler.useWeights(true); + // in case ion drift time is not specified it is overwritten by the value in the weight object + if (mIonDriftTimeMS == -1) { + overWriteIntegrationTime(); + } } } @@ -98,7 +106,21 @@ class TPCScalerSpec : public Task const bool mEnableWeights{false}; ///< use weights for TPC scalers TPCScalerWeights mScalerWeights{}; ///< scaler weights float mIonDriftTimeMS{-1}; ///< ion drift time + float mMaxTimeWeightsMS{500}; ///< maximum integration time when weights are used TPCScaler mTPCScaler; ///< tpc scaler + + void overWriteIntegrationTime() + { + float integrationTime = std::abs(mScalerWeights.mFirstTimeStampMS); + if (integrationTime <= 0) { + return; + } + if (integrationTime > mMaxTimeWeightsMS) { + integrationTime = mMaxTimeWeightsMS; + } + LOGP(info, "Setting maximum integration time for weights to: {}", integrationTime); + mTPCScaler.setIonDriftTimeMS(integrationTime); + } }; o2::framework::DataProcessorSpec getTPCScalerSpec(bool enableWeights) @@ -126,7 +148,8 @@ o2::framework::DataProcessorSpec getTPCScalerSpec(bool enableWeights) outputs, AlgorithmSpec{adaptFromTask(ccdbRequest, enableWeights)}, Options{ - {"ion-drift-time", VariantType::Float, -1.f, {"Overwrite ion drift time if a value >0 is provided"}}}}; + {"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"}}}}; } } // namespace tpc diff --git a/Detectors/TPC/workflow/src/tpc-scaler.cxx b/Detectors/TPC/workflow/src/tpc-scaler.cxx index 54034d9e04cbb..e2c2c8ed79c43 100644 --- a/Detectors/TPC/workflow/src/tpc-scaler.cxx +++ b/Detectors/TPC/workflow/src/tpc-scaler.cxx @@ -23,7 +23,7 @@ void customize(std::vector& workflowOptions) // option allowing to set parameters std::vector options{ ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}, - {"enableWeights", VariantType::Bool, false, {"Enable weights for TPC scalers"}}}; + {"disableWeights", VariantType::Bool, false, {"Disable weights for TPC scalers"}}}; std::swap(workflowOptions, options); } @@ -33,7 +33,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config) { WorkflowSpec workflow; o2::conf::ConfigurableParam::updateFromString(config.options().get("configKeyValues")); - const bool enableWeights = config.options().get("enableWeights"); + const bool enableWeights = !(config.options().get("disableWeights")); workflow.emplace_back(o2::tpc::getTPCScalerSpec(enableWeights)); return workflow; }