Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions Detectors/TPC/simulation/include/TPCSimulation/Digitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ class Digitizer
/// \param nRBins number of grid points in r, must be (2**N)+1
void setUseSCDistortions(const SCDistortionType& distortionType, const TH3* hisInitialSCDensity);
/// Enable the use of space-charge distortions and provide SpaceCharge object as input
/// \param spaceCharge unique pointer to spaceCharge object
/// \param spaceCharge spaceCharge object, not owned: the caller (e.g. the DPL CCDB cache) keeps it alive
void setUseSCDistortions(SC* spaceCharge);

/// \param spaceCharge unique pointer to spaceCharge object
/// \param spaceCharge spaceCharge object of the derivative map, not owned: the caller keeps it alive
void setSCDistortionsDerivative(SC* spaceCharge);

/// Enable the use of space-charge distortions by providing global distortions and global corrections stored in a ROOT file
Expand All @@ -142,20 +142,21 @@ class Digitizer
void recalculateDistortions();

private:
DigitContainer mDigitContainer; ///< Container for the Digits
std::unique_ptr<SC> mSpaceCharge; ///< Handler of full distortions (static + IR dependant)
std::unique_ptr<SC> mSpaceChargeDer; ///< Handler of reference static distortions
Sector mSector = -1; ///< ID of the currently processed sector
double mEventTime = 0.f; ///< Time of the currently processed event
double mOutputDigitTimeOffset = 0; ///< Time of the first IR sampled in the digitizer
float mVDrift = 0; ///< VDrift for current timestamp
float mTDriftOffset = 0; ///< drift time additive offset in \mus
bool mIsContinuous; ///< Switch for continuous readout
bool mUseSCDistortions = false; ///< Flag to switch on the use of space-charge distortions
int mDistortionScaleType = 0; ///< type=0: no scaling of distortions, type=1 distortions without any scaling, type=2 distortions scaling with lumi
float mLumiScaleFactor = 0; ///< value used to scale the derivative map
bool mUseScaledDistortions = false; ///< whether the distortions are already scaled
ClassDefNV(Digitizer, 3);
DigitContainer mDigitContainer; ///< Container for the Digits
std::unique_ptr<SC> mSpaceChargeOwned; //!< Distortions created by the digitizer itself
SC* mSpaceCharge = nullptr; //!< Handler of full distortions (static + IR dependant), owned by mSpaceChargeOwned or by the caller
SC* mSpaceChargeDer = nullptr; //!< Handler of reference static distortions, owned by the caller
Sector mSector = -1; ///< ID of the currently processed sector
double mEventTime = 0.f; ///< Time of the currently processed event
double mOutputDigitTimeOffset = 0; ///< Time of the first IR sampled in the digitizer
float mVDrift = 0; ///< VDrift for current timestamp
float mTDriftOffset = 0; ///< drift time additive offset in \mus
bool mIsContinuous; ///< Switch for continuous readout
bool mUseSCDistortions = false; ///< Flag to switch on the use of space-charge distortions
int mDistortionScaleType = 0; ///< type=0: no scaling of distortions, type=1 distortions without any scaling, type=2 distortions scaling with lumi
float mLumiScaleFactor = 0; ///< value used to scale the derivative map
bool mUseScaledDistortions = false; ///< whether the distortions are already scaled
ClassDefNV(Digitizer, 4);
};
} // namespace tpc
} // namespace o2
Expand Down
17 changes: 11 additions & 6 deletions Detectors/TPC/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void Digitizer::process(const std::vector<o2::tpc::HitGroup>& hits,
if (mDistortionScaleType == 1) {
mSpaceCharge->distortElectron(posEle);
} else if (mDistortionScaleType == 2) {
mSpaceCharge->distortElectron(posEle, (mUseScaledDistortions ? nullptr : mSpaceChargeDer.get()), mLumiScaleFactor);
mSpaceCharge->distortElectron(posEle, (mUseScaledDistortions ? nullptr : mSpaceChargeDer), mLumiScaleFactor);
}

/// Remove electrons that end up more than three sigma of the hit's average diffusion away from the current sector
Expand Down Expand Up @@ -182,7 +182,8 @@ void Digitizer::setUseSCDistortions(const SCDistortionType& distortionType, cons
{
mUseSCDistortions = true;
if (!mSpaceCharge) {
mSpaceCharge = std::make_unique<SC>();
mSpaceChargeOwned = std::make_unique<SC>();
mSpaceCharge = mSpaceChargeOwned.get();
}
mSpaceCharge->setSCDistortionType(distortionType);
if (hisInitialSCDensity) {
Expand All @@ -194,14 +195,17 @@ void Digitizer::setUseSCDistortions(const SCDistortionType& distortionType, cons
void Digitizer::setUseSCDistortions(SC* spaceCharge)
{
mUseSCDistortions = true;
mSpaceCharge.reset(spaceCharge);
if (spaceCharge != mSpaceChargeOwned.get()) {
mSpaceChargeOwned.reset();
}
mSpaceCharge = spaceCharge;
mSpaceCharge->initAfterReadingFromFile();
mSpaceCharge->printMetaData();
}

void Digitizer::setSCDistortionsDerivative(SC* spaceCharge)
{
mSpaceChargeDer.reset(spaceCharge);
mSpaceChargeDer = spaceCharge;
mSpaceChargeDer->initAfterReadingFromFile();
mSpaceChargeDer->printMetaData();
}
Expand All @@ -210,7 +214,8 @@ void Digitizer::setUseSCDistortions(std::string_view finp)
{
mUseSCDistortions = true;
if (!mSpaceCharge) {
mSpaceCharge = std::make_unique<SC>();
mSpaceChargeOwned = std::make_unique<SC>();
mSpaceCharge = mSpaceChargeOwned.get();
}

// in case analytical distortions are loaded from file they are applied
Expand Down Expand Up @@ -268,7 +273,7 @@ void Digitizer::recalculateDistortions()
mSpaceChargeDer->calcGlobalCorrWithGlobalDistIterative(side, nullptr, 0);

LOGP(info, "Calculating scaled distortions with scaling factor {}", mLumiScaleFactor);
mSpaceCharge->calcGlobalDistWithGlobalCorrIterativeLinearCartesian(side, mSpaceChargeDer.get(), mLumiScaleFactor);
mSpaceCharge->calcGlobalDistWithGlobalCorrIterativeLinearCartesian(side, mSpaceChargeDer, mLumiScaleFactor);
}
// set new lumi of avg map
mSpaceCharge->setMeanLumi(CorrMapParam::Instance().lumiInst);
Expand Down
Loading