Skip to content

Commit

Permalink
TPC: Using weights as default for IDC scaling
Browse files Browse the repository at this point in the history
- automatically set integration time when weights are used
  • Loading branch information
matthias-kleiner authored and shahor02 committed Jan 12, 2024
1 parent 99d40d8 commit d40b3a0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
25 changes: 24 additions & 1 deletion Detectors/TPC/workflow/src/TPCScalerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TPCScalerSpec : public Task
{
o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest);
mIonDriftTimeMS = ic.options().get<float>("ion-drift-time");
mMaxTimeWeightsMS = ic.options().get<float>("max-time-for-weights");
}

void run(ProcessingContext& pc) final
Expand Down Expand Up @@ -83,13 +84,20 @@ 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)) {
LOGP(info, "Updating TPC scaler weights");
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();
}
}
}

Expand All @@ -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)
Expand Down Expand Up @@ -126,7 +148,8 @@ o2::framework::DataProcessorSpec getTPCScalerSpec(bool enableWeights)
outputs,
AlgorithmSpec{adaptFromTask<TPCScalerSpec>(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
Expand Down
4 changes: 2 additions & 2 deletions Detectors/TPC/workflow/src/tpc-scaler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
// option allowing to set parameters
std::vector<ConfigParamSpec> 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);
}

Expand All @@ -33,7 +33,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config)
{
WorkflowSpec workflow;
o2::conf::ConfigurableParam::updateFromString(config.options().get<std::string>("configKeyValues"));
const bool enableWeights = config.options().get<bool>("enableWeights");
const bool enableWeights = !(config.options().get<bool>("disableWeights"));
workflow.emplace_back(o2::tpc::getTPCScalerSpec(enableWeights));
return workflow;
}

0 comments on commit d40b3a0

Please sign in to comment.