Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ class CDBInterface
/// \return gain map object
const CalPad& getGainMap();

/// Return the gain map object applied in the simulation
///
/// As getGainMap, but from the CCDB the gain map for MC (TPC/Calib/PadGainFullMC) is used, so that the simulation
/// can apply a different gain map than the one the reconstruction corrects with.
/// \return gain map object
const CalPad& getGainMapMC();

/// Return the ion tail coupling fraction
///
/// \return ion tail fraction
Expand Down
3 changes: 3 additions & 0 deletions Detectors/TPC/baserecsim/include/TPCBaseRecSim/CDBTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ enum class CDBType {
///
DistortionMapMC, ///< full distortions (static + IR dependant) for MC used in the digitizer
DistortionMapDerivMC, ///< derivative distortions for MC used in the digitizer for scaling
CalPadGainFullMC, ///< Full pad gain map for MC used in the digitizer

AltroSyncSignal ///< timing of Altro chip sync. signal
};
Expand Down Expand Up @@ -163,6 +164,8 @@ const std::unordered_map<CDBType, const std::string> CDBTypeMap{
// distortion maps
{CDBType::DistortionMapMC, "TPC/Calib/DistortionMapMC"},
{CDBType::DistortionMapDerivMC, "TPC/Calib/DistortionMapDerivativeMC"},
// gain map for MC
{CDBType::CalPadGainFullMC, "TPC/Calib/PadGainFullMC"},
// AltroSyncSignal
{CDBType::AltroSyncSignal, "TPC/Config/AltroSyncSignal"},
};
Expand Down
11 changes: 11 additions & 0 deletions Detectors/TPC/baserecsim/src/CDBInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ const CalPad& CDBInterface::getGainMap()
return *mGainMap;
}

//______________________________________________________________________________
const CalPad& CDBInterface::getGainMapMC()
{
// a gain map from file or the default one is the same for the simulation and the reconstruction
if (mGainMapFileName.size() || mUseDefaults) {
return getGainMap();
}

return getObjectFromCDB<CalPad>(CDBTypeMap.at(CDBType::CalPadGainFullMC));
}

//______________________________________________________________________________
const CalPad& CDBInterface::getITFraction()
{
Expand Down
4 changes: 4 additions & 0 deletions Detectors/TPC/simulation/include/TPCSimulation/Digitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class Digitizer
/// Whether flush() also flushes the process-wide debug streamer
void setFlushDebugStreamer(bool flush) { mFlushDebugStreamer = flush; }

/// Apply the gain map for MC (TPC/Calib/PadGainFullMC) instead of the one of the reconstruction (TPC/Calib/PadGainFull)
void setUseGainMapMC(bool use) { mUseGainMapMC = use; }

private:
/// Fill the random rings of the sector seeding, if not done yet
void initSectorSeeding();
Expand All @@ -176,6 +179,7 @@ class Digitizer
ULong64_t mSeedingTimeframe = 0; //!< Timeframe identifier for sector seeding
bool mUseSectorSeeding = false; //!< Whether sector seeding is used
bool mFlushDebugStreamer = true; //!< Whether flush() flushes the debug streamer
bool mUseGainMapMC = false; //!< Whether the gain map for MC is applied instead of the one of the reconstruction

DigitContainer mDigitContainer; ///< Container for the Digits
std::vector<float> mSignalArray; //!< Workspace for the shaped signal of one electron
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class GEMAmplification
void setRandomRingPositions(TRandom& rng);

/// Update the OCDB parameters cached in the class. To be called once per event
void updateParameters();
/// \param useGainMapMC apply the gain map for MC (TPC/Calib/PadGainFullMC) instead of the one of the reconstruction (TPC/Calib/PadGainFull)
void updateParameters(bool useGainMapMC = false);

/// Compute the number of electrons after amplification in a full stack of four GEM foils
/// \param nElectrons Number of electrons arriving at the first amplification stage (GEM1)
Expand Down
2 changes: 1 addition & 1 deletion Detectors/TPC/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void Digitizer::init()
mSAMPAProcessing->setRandomRingPositions(rng);
}
auto& gemAmplification = this->gemAmplification();
gemAmplification.updateParameters();
gemAmplification.updateParameters(mUseGainMapMC);
auto& electronTransport = this->electronTransport();
electronTransport.updateParameters(mVDrift);
auto& sampaProcessing = this->sampaProcessing();
Expand Down
4 changes: 2 additions & 2 deletions Detectors/TPC/simulation/src/GEMAmplification.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ void GEMAmplification::setRandomRingPositions(TRandom& rng)
mGainFullStack.setRandomPosition(rng);
}

void GEMAmplification::updateParameters()
void GEMAmplification::updateParameters(bool useGainMapMC)
{
auto& cdb = CDBInterface::instance();
mGEMParam = &(ParameterGEM::Instance());
mGasParam = &(ParameterGas::Instance());
mGainMap = &(cdb.getGainMap());
mGainMap = useGainMapMC ? &(cdb.getGainMapMC()) : &(cdb.getGainMap());
}

int GEMAmplification::getStackAmplification(int nElectrons)
Expand Down
1 change: 1 addition & 0 deletions Steer/DigitizerWorkflow/src/TPCDigitizerMTSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class TPCDPLDigitizerMTTask : public o2::base::BaseDPLDigitizer
worker->id = i;
worker->digitizer.setContinuousReadout(!triggeredMode);
worker->digitizer.setDistortionScaleType(mDistortionType);
worker->digitizer.setUseGainMapMC(mConditions.useGainMapMC());
worker->digitizer.setUseSectorSeeding(sectorSeed);
// the main thread flushes the process-wide debug streamer after the workers
worker->digitizer.setFlushDebugStreamer(false);
Expand Down
1 change: 1 addition & 0 deletions Steer/DigitizerWorkflow/src/TPCDigitizerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class TPCDPLDigitizerTask : public BaseDPLDigitizer

mDigitizer.setContinuousReadout(!triggeredMode);
mDigitizer.setDistortionScaleType(mDistortionType);
mDigitizer.setUseGainMapMC(mConditions.useGainMapMC());

if (ic.options().get<bool>("tpc-sector-seeding")) {
const auto seed = o2::conf::DigiParams::Instance().seed;
Expand Down
12 changes: 11 additions & 1 deletion Steer/DigitizerWorkflow/src/TPCSectorDigitization.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ std::vector<framework::ConfigParamSpec> TPCDigitizerConditions::options()
return {
{"TPCtriggered", VariantType::Bool, false, {"Impose triggered RO mode (default: continuous)"}},
{"TPCuseCCDB", VariantType::Bool, false, {"true: load calibrations from CCDB; false: use random calibratoins"}},
{"TPCuseGainMapMC", VariantType::Bool, false, {"with TPCuseCCDB, true: apply the gain map for MC (TPC/Calib/PadGainFullMC); false: apply TPC/Calib/PadGainFull. A GainMap.root file replaces both"}},
{"meanLumiDistortions", VariantType::Float, -1.f, {"override lumi of distortion object if >=0"}},
{"meanLumiDistortionsDerivative", VariantType::Float, -1.f, {"override lumi of derivative distortion object if >=0"}},
{"do-not-recalculate-distortions", VariantType::Bool, false, {"Do not recalculate the distortions"}},
Expand Down Expand Up @@ -162,9 +163,18 @@ void TPCDigitizerConditions::init(framework::InitContext& ic, int distortionType
mRecalcDistortions = !(ic.options().get<bool>("do-not-recalculate-distortions"));
SpaceCharge<float>::setNThreads(ic.options().get<int>("n-threads-distortions"));
mUseCalibrationsFromCCDB = ic.options().get<bool>("TPCuseCCDB");
mUseGainMapMC = ic.options().get<bool>("TPCuseGainMapMC");
mMeanLumiDistortions = ic.options().get<float>("meanLumiDistortions");
mMeanLumiDistortionsDerivative = ic.options().get<float>("meanLumiDistortionsDerivative");
LOG(info) << "TPC calibrations from CCDB: " << mUseCalibrationsFromCCDB;

if (!mUseCalibrationsFromCCDB) {
if (mUseGainMapMC) {
LOGP(warning, "TPC: TPCuseGainMapMC has no effect without TPCuseCCDB, the digitizer applies the default gain map");
}
} else {
LOGP(info, "TPC: gain map from the CCDB applied in the digitizer: {}", CDBTypeMap.at(mUseGainMapMC ? CDBType::CalPadGainFullMC : CDBType::CalPadGainFull));
}
}

bool TPCDigitizerConditions::finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj, Digitizer& digitizer)
Expand Down Expand Up @@ -237,7 +247,7 @@ void TPCDigitizerConditions::update(framework::ProcessingContext& pc, Digitizer&
}

if (std::filesystem::exists("GainMap.root")) {
LOG(info) << "TPC: Using gain map from 'GainMap.root'";
LOG(info) << "TPC: Using gain map from 'GainMap.root'" << (mUseGainMapMC ? ", TPCuseGainMapMC has no effect" : "");
cdb.setGainMapFromFile("GainMap.root");
}
}
Expand Down
3 changes: 3 additions & 0 deletions Steer/DigitizerWorkflow/src/TPCSectorDigitization.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class TPCDigitizerConditions
static void addInputs(std::vector<framework::InputSpec>& inputs, int distortionType);

void init(framework::InitContext& ic, int distortionType);
/// whether the digitizer applies the gain map for MC (TPC/Calib/PadGainFullMC) instead of TPC/Calib/PadGainFull
bool useGainMapMC() const { return mUseGainMapMC; }
/// pass a CCDB object to the digitizer; true if it was a TPC condition
bool finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj, Digitizer& digitizer);
/// fetch the conditions of a timeframe and prepare the digitizer, which then holds the distortions
Expand All @@ -75,6 +77,7 @@ class TPCDigitizerConditions
VDriftHelper mVDriftHelper{};
int mDistortionType = 0;
bool mUseCalibrationsFromCCDB = false;
bool mUseGainMapMC = false;
bool mRecalcDistortions = false;
float mMeanLumiDistortions = -1;
float mMeanLumiDistortionsDerivative = -1;
Expand Down
Loading