Skip to content

Commit bc2f134

Browse files
committed
Add loadSCCorrMap option to loadCalibsFromCCDB, fetch the MC time gain calibration when
isMC is set, remove MC kinematics reader from dEdx calculation macro
1 parent a0af1e3 commit bc2f134

3 files changed

Lines changed: 17 additions & 27 deletions

File tree

Detectors/TPC/calibration/include/TPCCalibration/CalculatedEdx.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,9 @@ class CalculatedEdx
211211

212212
/// load calibration objects from CCDB
213213
/// \param runNumberOrTimeStamp run number or time stamp
214-
/// \param isMC set if dEdx space-charge corrections will be loaded for MC or real data
215-
void loadCalibsFromCCDB(long runNumberOrTimeStamp, const bool isMC = false);
214+
/// \param isMC set if dEdx residual and space-charge corrections will be loaded for MC or real data
215+
/// \param loadSCCorrMap set to false to skip loading the space-charge correction maps
216+
void loadCalibsFromCCDB(long runNumberOrTimeStamp, const bool isMC = false, const bool loadSCCorrMap = true);
216217

217218
/// load calibration objects from local CCDB folder
218219
/// \param localCCDBFolder local CCDB folder

Detectors/TPC/calibration/macro/calculatedEdx.C

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
#include "DataFormatsTPC/ClusterNative.h"
4141
#include "DataFormatsTPC/ClusterNativeHelper.h"
4242
#include "SimulationDataFormat/MCCompLabel.h"
43-
#include "SimulationDataFormat/MCTrack.h"
44-
#include "Steer/MCKinematicsReader.h"
4543
#include "TPCCalibration/CalculatedEdx.h"
4644
#endif
4745

@@ -91,14 +89,13 @@ std::pair<std::unique_ptr<TFile>, std::unique_ptr<TTree>> openTreeOrNull(const s
9189
/// \param propagateParams propagate only the track parameters (fastest option, no material corrections); only used if useRefit and propagateTrack are both false
9290
/// \param debug enable the CalculatedEdx debug streamer, additionally writing one dEdxDebug_t<i>.root file with per-cluster information per worker thread
9391
/// \param nThreads number of worker threads used to process the tracks of one event in parallel
94-
/// \param isMC set to true for MC productions to read the true MC track (TPCTracksMCTruth branch + mcKineFileName) for each track into an additional "mctrack" branch
92+
/// \param isMC set to true for MC productions to read the true MC track label (TPCTracksMCTruth branch) for each track into an additional "mcLabel" branch
9593
/// \param isMatchedToITS set to true to also read o2trac_its.root/o2match_itstpc.root and restrict the dE/dx calculation to TPC tracks matched to an ITS track
9694
/// \param tfIDFileName name of the optional timeframe ID file; if found in dir, its per-entry time stamp is used for the CCDB instead of runNumberOrTimeStamp
9795
/// \param tpcTracksFileName name of the file with the TPC tracks
9896
/// \param clusterNativeFileName name of the file with the TPC native clusters
9997
/// \param itsTracksFileName name of the file with the ITS tracks; only used if isMatchedToITS is true
10098
/// \param matchFileName name of the file with the TPC-ITS match information; only used if isMatchedToITS is true
101-
/// \param mcKineFileName base name (without extension) of the MC kinematics file used to resolve MC track labels; only used if isMC is true
10299
void calculatedEdx(const std::string dir = ".",
103100
const long runNumberOrTimeStamp = 0,
104101
const std::string outFile = "dEdxCalc.root",
@@ -120,8 +117,7 @@ void calculatedEdx(const std::string dir = ".",
120117
const std::string tpcTracksFileName = "tpctracks.root",
121118
const std::string clusterNativeFileName = "tpc-native-clusters.root",
122119
const std::string itsTracksFileName = "o2trac_its.root",
123-
const std::string matchFileName = "o2match_itstpc.root",
124-
const std::string mcKineFileName = "o2sim")
120+
const std::string matchFileName = "o2match_itstpc.root")
125121
{
126122
ROOT::EnableThreadSafety();
127123

@@ -164,18 +160,12 @@ void calculatedEdx(const std::string dir = ".",
164160
tpcTree->SetBranchAddress("ClusRefs", &tpcTrackClIdxVecInput);
165161

166162
std::vector<o2::MCCompLabel> tpcMCTruth, *tpcMCTruthPtr = &tpcMCTruth;
167-
o2::steer::MCKinematicsReader mcReader;
168163
if (isMC) {
169164
if (!tpcTree->GetBranch("TPCTracksMCTruth")) {
170165
LOGP(error, "Branch 'TPCTracksMCTruth' not found in {}/{}, cannot resolve MC truth", dir, tpcTracksFileName);
171166
return;
172167
}
173168
tpcTree->SetBranchAddress("TPCTracksMCTruth", &tpcMCTruthPtr);
174-
const auto kineFileName = fmt::format("{}/{}", dir, mcKineFileName);
175-
if (!mcReader.initFromKinematics(kineFileName)) {
176-
LOGP(error, "Could not initialize MCKinematicsReader from {}", kineFileName);
177-
return;
178-
}
179169
}
180170

181171
std::unique_ptr<TFile> itsFile;
@@ -260,7 +250,8 @@ void calculatedEdx(const std::string dir = ".",
260250
for (auto& calcdEdx : calcdEdxPerThread) {
261251
calcdEdx.setMembers(tpcTrackClIdxVecInput, clusterIndex, &tpcTracks);
262252
if (localCCDBFolder.empty()) {
263-
calcdEdx.loadCalibsFromCCDB(timeStamp, isMC);
253+
const bool loadSCCorrMap = (correctionMask & CorrectionFlags::dEdxSC) == CorrectionFlags::dEdxSC;
254+
calcdEdx.loadCalibsFromCCDB(timeStamp, isMC, loadSCCorrMap);
264255
} else {
265256
calcdEdx.loadCalibsFromLocalCCDBFolder(localCCDBFolder.data());
266257
}
@@ -338,11 +329,7 @@ void calculatedEdx(const std::string dir = ".",
338329
}
339330
if (isMC) {
340331
const auto& label = mcLabelOut[iThread][i];
341-
const auto* mcTrack = label.isValid() ? mcReader.getTrack(label) : nullptr;
342332
row << "mcLabel=" << label;
343-
if (mcTrack) {
344-
row << "mctrack=" << *mcTrack;
345-
}
346333
}
347334
row << "\n";
348335
}

Detectors/TPC/calibration/src/CalculatedEdx.cxx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ bool CalculatedEdx::isInStackBoundaries(int stackNumber, unsigned char rowIndex,
645645
return false;
646646
}
647647

648-
void CalculatedEdx::loadCalibsFromCCDB(long runNumberOrTimeStamp, const bool isMC)
648+
void CalculatedEdx::loadCalibsFromCCDB(long runNumberOrTimeStamp, const bool isMC, const bool loadSCCorrMap)
649649
{
650650
// setup CCDB manager
651651
auto& cm = o2::ccdb::BasicCCDBManager::instance();
@@ -675,7 +675,7 @@ void CalculatedEdx::loadCalibsFromCCDB(long runNumberOrTimeStamp, const bool isM
675675
mCalibCont.setGainMapResidual(gainMapResidual);
676676

677677
// set the residual dEdx correction
678-
o2::tpc::CalibdEdxCorrection* residualObj = cm.getForTimeStamp<o2::tpc::CalibdEdxCorrection>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalTimeGain), tRun);
678+
o2::tpc::CalibdEdxCorrection* residualObj = isMC ? cm.getForTimeStamp<o2::tpc::CalibdEdxCorrection>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalTimeGainMC), tRun) : cm.getForTimeStamp<o2::tpc::CalibdEdxCorrection>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalTimeGain), tRun);
679679

680680
const auto* residualCorr = static_cast<o2::tpc::CalibdEdxCorrection*>(residualObj);
681681
mCalibCont.setResidualCorrection(*residualCorr);
@@ -696,14 +696,16 @@ void CalculatedEdx::loadCalibsFromCCDB(long runNumberOrTimeStamp, const bool isM
696696
const o2::base::MatLayerCylSet* matLut = o2::base::MatLayerCylSet::rectifyPtrFromFile(cm.get<o2::base::MatLayerCylSet>("GLO/Param/MatLUT"));
697697
propagator->setMatLUT(matLut);
698698

699-
// load sc correction maps
700-
auto avgMap = isMC ? cm.getForTimeStamp<o2::gpu::TPCFastTransform>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalCorrMapMC), tRun) : cm.getForTimeStamp<o2::gpu::TPCFastTransform>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalCorrMap), tRun);
701-
avgMap->rectifyAfterReadingFromFile();
699+
// load sc correction maps; skip if not needed
700+
if (loadSCCorrMap) {
701+
auto avgMap = isMC ? cm.getForTimeStamp<o2::gpu::TPCFastTransform>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalCorrMapMC), tRun) : cm.getForTimeStamp<o2::gpu::TPCFastTransform>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalCorrMap), tRun);
702+
avgMap->rectifyAfterReadingFromFile();
702703

703-
auto derMap = isMC ? cm.getForTimeStamp<o2::gpu::TPCFastTransform>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalCorrDerivMapMC), tRun) : cm.getForTimeStamp<o2::gpu::TPCFastTransform>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalCorrDerivMap), tRun);
704-
derMap->rectifyAfterReadingFromFile();
704+
auto derMap = isMC ? cm.getForTimeStamp<o2::gpu::TPCFastTransform>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalCorrDerivMapMC), tRun) : cm.getForTimeStamp<o2::gpu::TPCFastTransform>(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalCorrDerivMap), tRun);
705+
derMap->rectifyAfterReadingFromFile();
705706

706-
mSCdEdxCorrection.setCorrectionMaps(avgMap, derMap);
707+
mSCdEdxCorrection.setCorrectionMaps(avgMap, derMap);
708+
}
707709

708710
// set the dead channel map
709711
o2::tpc::DeadChannelMapCreator deadCMCreator;

0 commit comments

Comments
 (0)