Skip to content

Commit

Permalink
Undo previous timeGain corrections to allow for residual calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
wiechula committed Jun 3, 2024
1 parent a2c661f commit ffb0d99
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 8 deletions.
8 changes: 6 additions & 2 deletions Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class CalibdEdx

const CalibdEdxCorrection& getCalib() const { return mCalib; }

/// calibration used during reconstruction
void setCalibrationInput(const CalibdEdxCorrection& calib) { mCalibIn = calib; }

/// Return the number of hist entries of the gem stack with less statistics
int minStackEntries() const;

Expand Down Expand Up @@ -152,8 +155,9 @@ class CalibdEdx
float mFitLowCutFactor = 1.5; ///< dEdx cut multiplier for the lower dE/dx range
int mFitPasses = 3; ///< number of fit passes used to remove electron tracks

Hist mHist; ///< dEdx multidimensional histogram
CalibdEdxCorrection mCalib{}; ///< Calibration output
Hist mHist; ///< dEdx multidimensional histogram
CalibdEdxCorrection mCalib{}; ///< Calibration output
CalibdEdxCorrection mCalibIn{}; ///< Calibration output

o2::base::Propagator::MatCorrType mMatType{}; ///< material type for track propagation

Expand Down
14 changes: 11 additions & 3 deletions Detectors/TPC/calibration/src/CalibdEdx.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,21 @@ void CalibdEdx::fill(const TrackTPC& track)
}
}
const float snp = cpTrack.getSnp();
const float scaledTgl = scaleTgl(std::abs(cpTrack.getTgl()), roc);
const float tgl = cpTrack.getTgl();
const float scaledTgl = scaleTgl(std::abs(tgl), roc);
if (track.hasCSideClusters()) {
sector += SECTORSPERSIDE;
}

mHist(dEdxMax[roc] * dEdxScale, scaledTgl, snp, sector, roc, ChargeType::Max);
mHist(dEdxTot[roc] * dEdxScale, scaledTgl, snp, sector, roc, ChargeType::Tot);
// undo previously done corrections, to allow for residual corrections
// output will still be the full correction
float corrMax = mCalibIn.getCorrection(StackID{static_cast<int>(sector), roc}, ChargeType::Max, tgl, snp);
float corrTot = mCalibIn.getCorrection(StackID{static_cast<int>(sector), roc}, ChargeType::Tot, tgl, snp);
corrMax = (corrMax > 0.1f) ? 1.f / corrMax : 1.f;
corrTot = (corrTot > 0.1f) ? 1.f / corrTot : 1.f;

mHist(dEdxMax[roc] * dEdxScale * corrMax, scaledTgl, snp, sector, roc, ChargeType::Max);
mHist(dEdxTot[roc] * dEdxScale * corrTot, scaledTgl, snp, sector, roc, ChargeType::Tot);
}
}

Expand Down
20 changes: 19 additions & 1 deletion Detectors/TPC/workflow/src/CalibdEdxSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "Framework/Task.h"
#include "Framework/DataProcessorSpec.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/CCDBParamSpec.h"
#include "TPCCalibration/CalibdEdx.h"
#include "TPCWorkflow/ProcessingHelpers.h"
#include "TPCBase/CDBInterface.h"
Expand Down Expand Up @@ -69,12 +70,18 @@ class CalibdEdxDevice : public Task

void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final
{
o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj);
if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
return;
}
if (matcher == ConcreteDataMatcher("TPC", "TIMEGAIN", 0)) {
mCalib->setCalibrationInput(*(o2::tpc::CalibdEdxCorrection*)obj);
}
}

void run(ProcessingContext& pc) final
{
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
checkUpdates(pc);
const auto tfcounter = o2::header::get<DataProcessingHeader*>(pc.inputs().get("tracks").header)->startTime;
const auto tracks = pc.inputs().get<gsl::span<TrackTPC>>("tracks");

Expand Down Expand Up @@ -115,6 +122,15 @@ class CalibdEdxDevice : public Task
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TPC_CalibdEdx", 0}, info);
}

void checkUpdates(ProcessingContext& pc) const
{
if (pc.inputs().isValid("tpctimegain")) {
pc.inputs().get<o2::tpc::CalibdEdxCorrection*>("tpctimegain");
} else {
return;
}
}

std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
const o2::base::Propagator::MatCorrType mMatType{};
int mDumpToFile{};
Expand All @@ -130,6 +146,8 @@ DataProcessorSpec getCalibdEdxSpec(const o2::base::Propagator::MatCorrType matTy
outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TPC_CalibdEdx"}, Lifetime::Sporadic);
outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TPC_CalibdEdx"}, Lifetime::Sporadic);
std::vector<InputSpec> inputs{{"tracks", "TPC", "MIPS", Lifetime::Sporadic}};
inputs.emplace_back("tpctimegain", "TPC", "TIMEGAIN", 0, Lifetime::Condition, ccdbParamSpec(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalTimeGain), {}, 1)); // time-dependent

auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(true, // orbitResetTime
false, // GRPECS=true
false, // GRPLHCIF
Expand Down
23 changes: 21 additions & 2 deletions Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Framework/Task.h"
#include "Framework/DataProcessorSpec.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/CCDBParamSpec.h"
#include "TPCCalibration/CalibratordEdx.h"
#include "TPCWorkflow/ProcessingHelpers.h"
#include "DetectorsBase/GRPGeomHelper.h"
Expand Down Expand Up @@ -81,14 +82,21 @@ class CalibratordEdxDevice : public Task

void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final
{
o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj);
if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
return;
}
if (matcher == ConcreteDataMatcher("TPC", "TIMEGAIN", 0)) {
auto& slotTF = mCalibrator->getSlotForTF(mCalibrator->getCurrentTFInfo().tfCounter);
slotTF.getContainer()->setCalibrationInput(*(o2::tpc::CalibdEdxCorrection*)obj);
}
}

void run(ProcessingContext& pc) final
{
o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo());
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
checkUpdates(pc);
const auto tracks = pc.inputs().get<gsl::span<tpc::TrackTPC>>("tracks");
o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo());
LOGP(detail, "Processing TF {} with {} tracks", mCalibrator->getCurrentTFInfo().tfCounter, tracks.size());
mRunNumber = mCalibrator->getCurrentTFInfo().runNumber;
mCalibrator->process(tracks);
Expand Down Expand Up @@ -127,6 +135,15 @@ class CalibratordEdxDevice : public Task
mCalibrator->initOutput(); // empty the outputs after they are send
}

void checkUpdates(ProcessingContext& pc) const
{
if (pc.inputs().isValid("tpctimegain")) {
pc.inputs().get<o2::tpc::CalibdEdxCorrection*>("tpctimegain");
} else {
return;
}
}

std::unique_ptr<CalibratordEdx> mCalibrator;
const o2::base::Propagator::MatCorrType mMatType{};
std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
Expand All @@ -140,6 +157,8 @@ DataProcessorSpec getCalibratordEdxSpec(const o2::base::Propagator::MatCorrType
outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TPC_CalibdEdx"}, Lifetime::Sporadic);
outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TPC_CalibdEdx"}, Lifetime::Sporadic);
std::vector<InputSpec> inputs{{"tracks", "TPC", "MIPS", Lifetime::Sporadic}};
inputs.emplace_back("tpctimegain", "TPC", "TIMEGAIN", 0, Lifetime::Condition, ccdbParamSpec(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalTimeGain), {}, 1)); // time-dependent

auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(true, // orbitResetTime
true, // GRPECS=true
false, // GRPLHCIF
Expand Down

0 comments on commit ffb0d99

Please sign in to comment.