Skip to content

Commit

Permalink
FT0: Use dead channel map in digitizer (#12340)
Browse files Browse the repository at this point in the history
* FT0: Use dead channel map in digitizer

Enables the use of the dead channel map from CCDB in the FT0 digitizer as default.
Hits in dead channels will not be processed. To disable checking the dead channel map,
pass `--FT0Digitizer --disable-dead-channel-map` to the digitizer workflow.

* FDD: Use dead channel map in digitizer

Enables the use of the dead channel map from CCDB in the FDD digitizer as default. Hits in dead channels will not be processed. To disable checking the dead channel map, pass --FDDDigitizer --disable-dead-channel-map to the digitizer workflow.
  • Loading branch information
andreasmolander authored Dec 1, 2023
1 parent 114b4f3 commit d0913a7
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "DataFormatsFDD/ChannelData.h"
#include "DataFormatsFDD/Digit.h"
#include "DataFormatsFDD/MCLabel.h"
#include "DataFormatsFIT/DeadChannelMap.h"
#include "FDDSimulation/Detector.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include "FDDSimulation/DigitizationParameters.h"
Expand Down Expand Up @@ -87,6 +88,8 @@ class Digitizer
void init();
void finish();

void setDeadChannelMap(o2::fit::DeadChannelMap const* deadChannelMap) { mDeadChannelMap = deadChannelMap; };

private:
static constexpr int BCCacheMin = -1, BCCacheMax = 10, NBC2Cache = 1 + BCCacheMax - BCCacheMin;

Expand Down Expand Up @@ -125,6 +128,8 @@ class Digitizer
static Double_t PMResponse(Double_t* x, Double_t*);
static Double_t SinglePhESpectrum(Double_t* x, Double_t* par);

o2::fit::DeadChannelMap const* mDeadChannelMap = nullptr;

ClassDefNV(Digitizer, 4);
};
} // namespace fdd
Expand Down
8 changes: 7 additions & 1 deletion Detectors/FIT/FDD/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ void Digitizer::process(const std::vector<o2::fdd::Hit>& hits,
// LOG(info) << "Pulse";
// Conversion of hits to the analogue pulse shape
for (auto& hit : sorted_hits) {
int iChannel = hit.GetDetectorID();

// If the dead channel map is used, and the channel with ID 'hit_ch' is dead, don't process this hit.
if (mDeadChannelMap && !mDeadChannelMap->isChannelAlive(iChannel)) {
continue;
}

if (hit.GetTime() > 20e3) {
const int maxWarn = 10;
static int warnNo = 0;
Expand All @@ -60,7 +67,6 @@ void Digitizer::process(const std::vector<o2::fdd::Hit>& hits,
}

std::array<o2::InteractionRecord, NBC2Cache> cachedIR;
int iChannel = hit.GetDetectorID();
int nPhotoElectrons = simulateLightYield(iChannel, hit.GetNphot());

double delayScintillator = mRndScintDelay.getNextValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define ALICEO2_FT0_DIGITIZER_H

#include "CommonDataFormat/InteractionRecord.h"
#include "DataFormatsFIT/DeadChannelMap.h"
#include "DataFormatsFT0/Digit.h"
#include "DataFormatsFT0/ChannelData.h"
#include "DataFormatsFT0/MCLabel.h"
Expand Down Expand Up @@ -73,6 +74,7 @@ class Digitizer

void SetChannelOffset(o2::ft0::FT0ChannelTimeCalibrationObject const*
caliboffsets) { mCalibOffset = caliboffsets; };
void setDeadChannelMap(o2::fit::DeadChannelMap const* deadChannelMap) { mDeadChannelMap = deadChannelMap; };
double getTimeOffsetWrtBC() const { return mIntRecord.getTimeOffsetWrtBC(); }

struct CFDOutput {
Expand Down Expand Up @@ -165,6 +167,7 @@ class Digitizer
o2::dataformats::MCTruthContainer<o2::ft0::MCLabel>& labels);

o2::ft0::FT0ChannelTimeCalibrationObject const* mCalibOffset = nullptr;
o2::fit::DeadChannelMap const* mDeadChannelMap = nullptr;

ClassDefNV(Digitizer, 3);
};
Expand Down
13 changes: 12 additions & 1 deletion Detectors/FIT/FT0/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,16 @@ void Digitizer::process(const std::vector<o2::ft0::HitType>* hits,
if (hit.GetEnergyLoss() > 0) {
continue;
}
const auto& params = FT0DigParam::Instance();

Int_t hit_ch = hit.GetDetectorID();

// If the dead channel map is used, and the channel with ID 'hit_ch' is dead, don't process this hit.
if (mDeadChannelMap && !mDeadChannelMap->isChannelAlive(hit_ch)) {
continue;
}

const auto& params = FT0DigParam::Instance();

Bool_t is_A_side = (hit_ch < 4 * mGeometry.NCellsA);
Float_t time_compensate = is_A_side ? params.mA_side_cable_cmps : params.mC_side_cable_cmps;
Double_t hit_time = hit.GetTime() - time_compensate;
Expand Down Expand Up @@ -248,6 +256,9 @@ void Digitizer::storeBC(BCCache& bc,
auto channel_begin = channel_end;
channel_end = std::find_if(channel_begin, particles.end(),
[ipmt](BCCache::particle const& p) { return p.hit_ch != ipmt; });

// The hits between 'channel_begin' and 'channel_end' now contains all hits for channel 'ipmt'

if (channel_end - channel_begin < params.mAmp_trsh) {
continue;
}
Expand Down
31 changes: 29 additions & 2 deletions Steer/DigitizerWorkflow/src/FDDDigitizerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "FDDDigitizerSpec.h"
#include "TChain.h"
#include "Framework/CCDBParamSpec.h"
#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/DataProcessorSpec.h"
Expand All @@ -28,6 +29,7 @@
#include "DataFormatsFDD/Digit.h"
#include "DataFormatsFDD/ChannelData.h"
#include "DataFormatsFDD/MCLabel.h"
#include "DataFormatsFIT/DeadChannelMap.h"

using namespace o2::framework;
using SubSpecificationType = o2::framework::DataAllocator::SubSpecificationType;
Expand All @@ -49,7 +51,18 @@ class FDDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
//mDigitizer.setCCDBServer(dopt.ccdb);
mDigitizer.init();
//mROMode = mDigitizer.isContinuous() ? o2::parameters::GRPObject::CONTINUOUS : o2::parameters::GRPObject::PRESENT;
mUseDeadChannelMap = !ic.options().get<bool>("disable-dead-channel-map");
mUpdateDeadChannelMap = mUseDeadChannelMap;
}

void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
{
// Initialize the dead channel map only once
if (matcher == ConcreteDataMatcher("FDD", "DeadChannelMap", 0)) {
mUpdateDeadChannelMap = false;
}
}

void run(framework::ProcessingContext& pc)
{
if (mFinished) {
Expand All @@ -70,6 +83,12 @@ class FDDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
LOG(info) << "FDD TIME RECEIVED " << record.getTimeNS();
}

// Initialize the dead channel map
if (mUpdateDeadChannelMap && mUseDeadChannelMap) {
auto deadChannelMap = pc.inputs().get<o2::fit::DeadChannelMap*>("fdddeadchannelmap");
mDigitizer.setDeadChannelMap(deadChannelMap.get());
}

auto& eventParts = context->getEventParts();

// loop over all composite collisions given from context
Expand Down Expand Up @@ -128,6 +147,9 @@ class FDDDPLDigitizerTask : public o2::base::BaseDPLDigitizer

// RS: at the moment using hardcoded flag for continuous readout
o2::parameters::GRPObject::ROMode mROMode = o2::parameters::GRPObject::ROMode(o2::parameters::GRPObject::CONTINUOUS | o2::parameters::GRPObject::TRIGGERING); // readout mode

bool mUseDeadChannelMap = true;
bool mUpdateDeadChannelMap = true;
};

o2::framework::DataProcessorSpec getFDDDigitizerSpec(int channel, bool mctruth)
Expand All @@ -137,6 +159,11 @@ o2::framework::DataProcessorSpec getFDDDigitizerSpec(int channel, bool mctruth)
// input description
// algorithmic description (here a lambda getting called once to setup the actual processing function)
// options that can be used for this processor (here: input file names where to take the hits)
std::vector<InputSpec> inputs;
inputs.emplace_back("collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe);
inputs.emplace_back("fdddeadchannelmap", "FDD", "DeadChannelMap", 0,
Lifetime::Condition,
ccdbParamSpec("FDD/Calib/DeadChannelMap", {}, -1));
std::vector<OutputSpec> outputs;
outputs.emplace_back("FDD", "DIGITSBC", 0, Lifetime::Timeframe);
outputs.emplace_back("FDD", "DIGITSCH", 0, Lifetime::Timeframe);
Expand All @@ -148,10 +175,10 @@ o2::framework::DataProcessorSpec getFDDDigitizerSpec(int channel, bool mctruth)

return DataProcessorSpec{
"FDDDigitizer",
Inputs{InputSpec{"collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast<SubSpecificationType>(channel), Lifetime::Timeframe}},
inputs,
outputs,
AlgorithmSpec{adaptFromTask<FDDDPLDigitizerTask>()},
Options{}};
Options{{"disable-dead-channel-map", VariantType::Bool, false, {"Don't mask dead channels"}}}};
}
} // namespace fdd
} // namespace o2
25 changes: 23 additions & 2 deletions Steer/DigitizerWorkflow/src/FT0DigitizerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Headers/DataHeader.h"
#include "Steer/HitProcessingManager.h" // for DigitizationContext
#include "FT0Simulation/Digitizer.h"
#include "DataFormatsFIT/DeadChannelMap.h"
#include "DataFormatsFT0/ChannelData.h"
#include "DataFormatsFT0/HitType.h"
#include "DataFormatsFT0/Digit.h"
Expand Down Expand Up @@ -58,13 +59,19 @@ class FT0DPLDigitizerTask : public o2::base::BaseDPLDigitizer
mDigitizer.init();
mROMode = o2::parameters::GRPObject::ROMode(o2::parameters::GRPObject::TRIGGERING | (mDigitizer.isContinuous() ? o2::parameters::GRPObject::CONTINUOUS : o2::parameters::GRPObject::PRESENT));
mDisableQED = ic.options().get<bool>("disable-qed");
mUseDeadChannelMap = !ic.options().get<bool>("disable-dead-channel-map");
mUpdateDeadChannelMap = mUseDeadChannelMap;
}

void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
{
if (matcher == ConcreteDataMatcher("FT0", "TimeOffset", 0)) {
mUpdateCCDB = false;
return;
}

// Initialize the dead channel map only once
if (matcher == ConcreteDataMatcher("FT0", "DeadChannelMap", 0)) {
mUpdateDeadChannelMap = false;
}
}

Expand All @@ -85,6 +92,13 @@ class FT0DPLDigitizerTask : public o2::base::BaseDPLDigitizer
auto caliboffsets = pc.inputs().get<o2::ft0::FT0ChannelTimeCalibrationObject*>("ft0offsets");
mDigitizer.SetChannelOffset(caliboffsets.get());
}

// Initialize the dead channel map
if (mUpdateDeadChannelMap && mUseDeadChannelMap) {
auto deadChannelMap = pc.inputs().get<o2::fit::DeadChannelMap*>("ft0deadchannelmap");
mDigitizer.setDeadChannelMap(deadChannelMap.get());
}

// if there is nothing to do ... return
if (timesview.size() == 0) {
return;
Expand Down Expand Up @@ -158,6 +172,8 @@ class FT0DPLDigitizerTask : public o2::base::BaseDPLDigitizer
bool mDisableQED = false;
bool mUseCCDB = true;
bool mUpdateCCDB = true;
bool mUseDeadChannelMap = true;
bool mUpdateDeadChannelMap = true;
std::vector<TChain*> mSimChains;
};

Expand All @@ -183,13 +199,18 @@ o2::framework::DataProcessorSpec getFT0DigitizerSpec(int channel, bool mctruth,
Lifetime::Condition,
ccdbParamSpec("FT0/Calib/ChannelTimeOffset"));
}
inputs.emplace_back("ft0deadchannelmap", "FT0", "DeadChannelMap", 0,
Lifetime::Condition,
ccdbParamSpec("FT0/Calib/DeadChannelMap", {}, -1));

return DataProcessorSpec{
"FT0Digitizer",
inputs,
outputs,
AlgorithmSpec{adaptFromTask<FT0DPLDigitizerTask>(useCCDB)},
Options{{"pileup", VariantType::Int, 1, {"whether to run in continuous time mode"}},
{"disable-qed", o2::framework::VariantType::Bool, false, {"disable QED handling"}}}};
{"disable-qed", VariantType::Bool, false, {"disable QED handling"}},
{"disable-dead-channel-map", VariantType::Bool, false, {"Don't mask dead channels"}}}};
}

} // namespace ft0
Expand Down

0 comments on commit d0913a7

Please sign in to comment.