Skip to content

Commit

Permalink
TRD tracklet transformer does not reed ITS frames from file by default
Browse files Browse the repository at this point in the history
- disable trigger record reading for digits in global workflows, they come from the tracklet reader
  • Loading branch information
martenole committed Oct 28, 2023
1 parent 1cc195d commit 6487bc8
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 25 deletions.
6 changes: 0 additions & 6 deletions Detectors/TRD/qc/src/Tracking.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ void Tracking::init()

void Tracking::setInput(const o2::globaltracking::RecoContainer& input)
{
// mRecoCont = &input;
mTracksTPC = input.getTPCTracks();
mTracksITSTPC = input.getTPCITSTracks();
mTracksITSTPCTRD = input.getITSTPCTRDTracks<TrackTRD>();
mTracksTPCTRD = input.getTPCTRDTracks<TrackTRD>();
mTrackletsRaw = input.getTRDTracklets();
mTrackletsCalib = input.getTRDCalibratedTracklets();
if (mTracksTPC.size() > 0) {
LOG(info) << "Checking first TPC track";
auto trk = mTracksTPC[0];
LOG(info) << "Track has X of " << trk.getX();
}
}

void Tracking::run()
Expand Down
4 changes: 2 additions & 2 deletions Detectors/TRD/reconstruction/src/CruRawReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ bool CruRawReader::processHalfCRU(int iteration)
int halfCruIdx = cruIdx * 2 + mFEEID.endpoint; // endpoint (0 or 1) defines half-CRU
int linkIdxGlobal = halfCruIdx * NLINKSPERHALFCRU + currentlinkindex; // global link ID [0..1079]
int halfChamberId = mLinkMap->getHCID(linkIdxGlobal);
mEventRecords.getCurrentEventRecord().getCounters().mLinkWords[halfChamberId] = mCurrentHalfCRULinkLengths[currentlinkindex];
mEventRecords.getCurrentEventRecord().getCounters().mLinkErrorFlag[halfChamberId] = mCurrentHalfCRULinkErrorFlags[currentlinkindex];
mEventRecords.getCurrentEventRecord().getCounters().mLinkWords[halfChamberId] += mCurrentHalfCRULinkLengths[currentlinkindex];
mEventRecords.getCurrentEventRecord().getCounters().mLinkErrorFlag[halfChamberId] |= mCurrentHalfCRULinkErrorFlags[currentlinkindex];
mEventRecords.incLinkErrorFlags(halfChamberId, mCurrentHalfCRULinkErrorFlags[currentlinkindex]); // TODO maybe has more meaning on a per event basis?
mEventRecords.incLinkWords(halfChamberId, mCurrentHalfCRULinkLengths[currentlinkindex]);
uint32_t currentlinksize32 = mCurrentHalfCRULinkLengths[currentlinkindex] * 8; // x8 to go from 256 bits to 32 bit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ namespace trd
class TRDDigitReaderSpec : public o2::framework::Task
{
public:
TRDDigitReaderSpec(bool useMC) : mUseMC(useMC) {}
TRDDigitReaderSpec(bool useMC, bool useTriggerRecords, int subSpec) : mUseMC(useMC), mUseTriggerRecords(useTriggerRecords), mSubSpec(subSpec) {}
~TRDDigitReaderSpec() override = default;
void init(o2::framework::InitContext& ic) override;
void run(o2::framework::ProcessingContext& pc) override;

private:
void connectTree();
bool mUseMC = false;
bool mUseTriggerRecords = true;
unsigned int mSubSpec = 1;
std::unique_ptr<TFile> mFile;
std::unique_ptr<TTree> mTreeDigits;
std::string mFileName = "trddigits.root";
Expand All @@ -52,7 +54,7 @@ class TRDDigitReaderSpec : public o2::framework::Task
o2::dataformats::IOMCTruthContainerView* mLabels = nullptr;
};

o2::framework::DataProcessorSpec getTRDDigitReaderSpec(bool useMC);
o2::framework::DataProcessorSpec getTRDDigitReaderSpec(bool useMC, bool trigRec = true, int dataSubspec = 1);

} // end namespace trd
} // end namespace o2
Expand Down
24 changes: 15 additions & 9 deletions Detectors/TRD/workflow/io/src/TRDDigitReaderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ void TRDDigitReaderSpec::connectTree()
mTreeDigits.reset((TTree*)mFile->Get(mDigitTreeName.c_str()));
assert(mTreeDigits);
mTreeDigits->SetBranchAddress(mDigitBranchName.c_str(), &mDigitsPtr);
mTreeDigits->SetBranchAddress(mTriggerRecordBranchName.c_str(), &mTriggerRecordsPtr);
if (mUseTriggerRecords) {
mTreeDigits->SetBranchAddress(mTriggerRecordBranchName.c_str(), &mTriggerRecordsPtr);
}
if (mUseMC) {
mTreeDigits->SetBranchAddress(mMCLabelsBranchName.c_str(), &mLabels);
}
Expand All @@ -55,10 +57,12 @@ void TRDDigitReaderSpec::run(ProcessingContext& pc)
auto currEntry = mTreeDigits->GetReadEntry() + 1;
assert(currEntry < mTreeDigits->GetEntries()); // this should not happen
mTreeDigits->GetEntry(currEntry);
LOG(info) << "Pushing " << mTriggerRecords.size() << " TRD trigger records at entry " << currEntry;
pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "TRKTRGRD", 1, Lifetime::Timeframe}, mTriggerRecords);
LOG(info) << "Pushing " << mDigits.size() << " digits for these trigger records";
pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "DIGITS", 1, Lifetime::Timeframe}, mDigits);
LOGP(info, "Pushing {} digits for tree entry {}", mDigits.size(), currEntry);
pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "DIGITS", mSubSpec, Lifetime::Timeframe}, mDigits);
if (mUseTriggerRecords) {
LOGP(info, "Pushing {} trigger records for tree entry {}", mTriggerRecords.size(), currEntry);
pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "TRKTRGRD", mSubSpec, Lifetime::Timeframe}, mTriggerRecords);
}
if (mUseMC) {
auto& sharedlabels = pc.outputs().make<o2::dataformats::ConstMCTruthContainer<o2::MCCompLabel>>(Output{o2::header::gDataOriginTRD, "LABELS", 0, Lifetime::Timeframe});
mLabels->copyandflatten(sharedlabels);
Expand All @@ -69,18 +73,20 @@ void TRDDigitReaderSpec::run(ProcessingContext& pc)
}
}

DataProcessorSpec getTRDDigitReaderSpec(bool useMC)
DataProcessorSpec getTRDDigitReaderSpec(bool useMC, bool trigRec, int dataSubspec)
{
std::vector<OutputSpec> outputs;
outputs.emplace_back("TRD", "DIGITS", 1, Lifetime::Timeframe);
outputs.emplace_back("TRD", "TRKTRGRD", 1, Lifetime::Timeframe);
outputs.emplace_back("TRD", "DIGITS", dataSubspec, Lifetime::Timeframe);
if (trigRec) {
outputs.emplace_back("TRD", "TRKTRGRD", dataSubspec, Lifetime::Timeframe);
}
if (useMC) {
outputs.emplace_back("TRD", "LABELS", 0, Lifetime::Timeframe);
}
return DataProcessorSpec{"TRDDIGITREADER",
Inputs{},
outputs,
AlgorithmSpec{adaptFromTask<TRDDigitReaderSpec>(useMC)},
AlgorithmSpec{adaptFromTask<TRDDigitReaderSpec>(useMC, trigRec, dataSubspec)},
Options{
{"digitsfile", VariantType::String, "trddigits.root", {"Input data file containing TRD digits"}},
{"input-dir", VariantType::String, "none", {"Input directory"}}}};
Expand Down
8 changes: 6 additions & 2 deletions Detectors/TRD/workflow/io/src/digit-reader-workflow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
{
// option allowing to set parameters
std::vector<o2::framework::ConfigParamSpec> options{
{"disable-mc", o2::framework::VariantType::Bool, true, {"disable MC propagation"}},
{"disable-mc", VariantType::Bool, true, {"disable MC propagation"}},
{"disable-trigrec", VariantType::Bool, false, {"disable trigger record reading when these come from tracklet reader"}},
{"digit-subspec", VariantType::Int, 1, {"allow overwriting default output data subspec"}},
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}};
o2::raw::HBFUtilsInitializer::addConfigOption(options);
std::swap(workflowOptions, options);
Expand All @@ -39,7 +41,9 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));

auto useMC = !configcontext.options().get<bool>("disable-mc");
auto sendTriggerRecords = !configcontext.options().get<bool>("disable-trigrec");
auto dataSubspec = configcontext.options().get<int>("digit-subspec");
WorkflowSpec specs;
specs.emplace_back(o2::trd::getTRDDigitReaderSpec(useMC));
specs.emplace_back(o2::trd::getTRDDigitReaderSpec(useMC, sendTriggerRecords, dataSubspec));
return specs;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
{
std::vector<o2::framework::ConfigParamSpec> options{
{"disable-mc", o2::framework::VariantType::Bool, false, {"Disable MC labels"}},
{"disable-irframe-reader", o2::framework::VariantType::Bool, false, {"Don't read ITS IR frames from file"}},
{"disable-root-input", o2::framework::VariantType::Bool, false, {"disable root-files input reader"}},
{"disable-root-output", o2::framework::VariantType::Bool, false, {"disable root-files output writer"}},
{"filter-trigrec", o2::framework::VariantType::Bool, false, {"ignore interaction records without ITS data"}},
Expand All @@ -61,7 +62,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
}

auto trigRecFilterActive = configcontext.options().get<bool>("filter-trigrec");
if (trigRecFilterActive) {
if (trigRecFilterActive && !configcontext.options().get<bool>("disable-irframe-reader")) {
o2::globaltracking::InputHelper::addInputSpecsIRFramesITS(configcontext, spec);
}

Expand Down
6 changes: 3 additions & 3 deletions prodtests/full-system-test/dpl-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ if [[ ! -z ${WORKFLOW_DETECTORS_USE_GLOBAL_READER} ]]; then
has_detector MCH && has_detector_from_global_reader MCH && add_W o2-mch-digits-reader-workflow "$DISABLE_MC --hbfutils-config o2_tfidinfo.root --infile mchdigits.root"
has_detector MCH && has_detector_from_global_reader MCH && add_W o2-mch-clusters-reader-workflow "--hbfutils-config o2_tfidinfo.root" "" 0
has_detector MCH && has_detector_from_global_reader MCH && add_W o2-mch-preclusters-reader-workflow "--hbfutils-config o2_tfidinfo.root" "" 0
has_detector TRD && has_detector_from_global_reader TRD && add_W o2-trd-digit-reader-workflow "--hbfutils-config o2_tfidinfo.root"
has_detector TRD && has_detector_from_global_reader TRD && add_W o2-trd-digit-reader-workflow "$DISABLE_MC --digit-subspec 0 --disable-trigrec --hbfutils-config o2_tfidinfo.root"
has_detector TOF && has_detector_from_global_reader TOF && add_W o2-tof-reco-workflow "$DISABLE_MC --input-type digits --output-type NONE --hbfutils-config o2_tfidinfo.root"
fi

Expand Down Expand Up @@ -463,7 +463,7 @@ fi
(has_detector_reco TOF || has_detector_ctf TOF) && ! has_detector_from_global_reader TOF && add_W o2-tof-reco-workflow "$TOF_CONFIG --input-type $TOF_INPUT --output-type $TOF_OUTPUT $DISABLE_DIGIT_ROOT_INPUT $DISABLE_ROOT_OUTPUT $DISABLE_MC --pipeline $(get_N tof-compressed-decoder TOF RAW 1),$(get_N TOFClusterer TOF REST 1)"
has_detector_reco ITS && ! has_detector_from_global_reader ITS && add_W o2-its-reco-workflow "--trackerCA $ITS_CONFIG $DISABLE_MC $DISABLE_DIGIT_CLUSTER_INPUT $DISABLE_ROOT_OUTPUT --pipeline $(get_N its-tracker ITS REST 1 ITSTRK)" "$ITS_CONFIG_KEY;$ITSMFT_STROBES;$ITSEXTRAERR"
has_detector_reco FT0 && ! has_detector_from_global_reader FT0 && add_W o2-ft0-reco-workflow "$DISABLE_DIGIT_ROOT_INPUT $DISABLE_ROOT_OUTPUT $DISABLE_MC --pipeline $(get_N ft0-reconstructor FT0 REST 1)"
has_detector_reco TRD && ! has_detector_from_global_reader TRD && add_W o2-trd-tracklet-transformer "$DISABLE_DIGIT_ROOT_INPUT $DISABLE_ROOT_OUTPUT $DISABLE_MC $TRD_FILTER_CONFIG --pipeline $(get_N TRDTRACKLETTRANSFORMER TRD REST 1 TRDTRKTRANS)"
has_detector_reco TRD && (has_detector_matching ITSTPCTRD || has_detector_matching TPCTRD) && ! has_detector_from_global_reader TRD && add_W o2-trd-tracklet-transformer "--disable-irframe-reader $DISABLE_DIGIT_ROOT_INPUT $DISABLE_ROOT_OUTPUT $DISABLE_MC $TRD_FILTER_CONFIG --pipeline $(get_N TRDTRACKLETTRANSFORMER TRD REST 1 TRDTRKTRANS)"
has_detectors_reco ITS TPC && has_detector_matching ITSTPC && add_W o2-tpcits-match-workflow "$DISABLE_ROOT_INPUT $DISABLE_ROOT_OUTPUT $DISABLE_MC $SEND_ITSTPC_DTGL $TPC_CORR_SCALING --nthreads $ITSTPC_THREADS --pipeline $(get_N itstpc-track-matcher MATCH REST $ITSTPC_THREADS TPCITS)" "$ITSTPC_CONFIG_KEY;$INTERACTION_TAG_CONFIG_KEY;$ITSMFT_STROBES;$ITSEXTRAERR"
has_detector_reco TRD && [[ ! -z "$TRD_SOURCES" ]] && add_W o2-trd-global-tracking "$DISABLE_ROOT_INPUT $DISABLE_ROOT_OUTPUT $DISABLE_MC $TRD_CONFIG $TRD_FILTER_CONFIG $TPC_CORR_SCALING --track-sources $TRD_SOURCES --pipeline $(get_N trd-globaltracking_TPC_ITS-TPC_ TRD REST 1 TRDTRK),$(get_N trd-globaltracking_TPC_FT0_ITS-TPC_ TRD REST 1 TRDTRK),$(get_N trd-globaltracking_TPC_FT0_ITS-TPC_CTP_ TRD REST 1 TRDTRK)" "$TRD_CONFIG_KEY;$INTERACTION_TAG_CONFIG_KEY;$ITSMFT_STROBES;$ITSEXTRAERR"
has_detector_reco TOF && [[ ! -z "$TOF_SOURCES" ]] && add_W o2-tof-matcher-workflow "$DISABLE_ROOT_INPUT $DISABLE_ROOT_OUTPUT $DISABLE_MC $TPC_CORR_SCALING --track-sources $TOF_SOURCES --pipeline $(get_N tof-matcher TOF REST 1 TOFMATCH)" "$ITSMFT_STROBES;$ITSEXTRAERR"
Expand Down Expand Up @@ -492,7 +492,7 @@ has_detectors_reco MFT MCH && has_detector_matching MFTMCH && add_W o2-globalfwd

# ---------------------------------------------------------------------------------------------------------------------
# Writers for detectors whose reco workflow cannot write the output
has_detector_reco TRD && ( [[ -z "$DISABLE_ROOT_OUTPUT" ]] || needs_root_output o2-trd-digittracklet-writer ) && ! has_detector_from_global_reader TRD && add_W o2-trd-digittracklet-writer
[[ $CTFINPUT == 1 ]] || [[ $DIGITINPUT == 1 ]] && has_detector_reco TRD && ( [[ -z "$DISABLE_ROOT_OUTPUT" ]] || needs_root_output o2-trd-digittracklet-writer ) && ! has_detector_from_global_reader TRD && add_W o2-trd-digittracklet-writer
has_detector_reco TPC && [[ "0${TPC_CONVERT_LINKZS_TO_RAW:-}" == "01" ]] && ( [[ -z "$DISABLE_ROOT_OUTPUT" ]] || needs_root_output o2-gpu-reco-workflow ) && ! has_detector_from_global_reader TPC && add_W o2-tpc-reco-workflow "--input-type digitizer --output-type digits $DISABLE_MC"
has_detector_reco CPV && ( [[ -z "$DISABLE_ROOT_OUTPUT" ]] || needs_root_output o2-cpv-cluster-writer-workflow ) && ! has_detector_from_global_reader CPV && add_W o2-cpv-cluster-writer-workflow "$DISABLE_MC"
( workflow_has_parameter AOD || [[ -z "$DISABLE_ROOT_OUTPUT" ]] || needs_root_output o2-emcal-cell-writer-workflow ) && ! has_detector_from_global_reader EMC && has_detector EMC && add_W o2-emcal-cell-writer-workflow "$DISABLE_MC --subspec 10 --cell-writer-name emcal-led-cells-writer --emcal-led-cells-writer \"--outfile emcledcells.root\""
Expand Down

0 comments on commit 6487bc8

Please sign in to comment.