diff --git a/DataFormats/Detectors/TRD/include/DataFormatsTRD/Tracklet64.h b/DataFormats/Detectors/TRD/include/DataFormatsTRD/Tracklet64.h index 90a0f76800955..95c0ed0cd3194 100644 --- a/DataFormats/Detectors/TRD/include/DataFormatsTRD/Tracklet64.h +++ b/DataFormats/Detectors/TRD/include/DataFormatsTRD/Tracklet64.h @@ -28,6 +28,7 @@ #include "GPUCommonDef.h" #include "GPUCommonRtypes.h" +#include "DataFormatsTRD/Constants.h" namespace o2 { @@ -155,10 +156,40 @@ class Tracklet64 ClassDefNV(Tracklet64, 1); }; +GPUdi() float Tracklet64::getUncalibratedY() const +{ + int padLocalBin = getPosition(); + int padLocal = 0; + if (padLocalBin & (1 << (constants::NBITSTRKLPOS - 1))) { + padLocal = -((~(padLocalBin - 1)) & ((1 << constants::NBITSTRKLPOS) - 1)); + } else { + padLocal = padLocalBin & ((1 << constants::NBITSTRKLPOS) - 1); + } + int mcmCol = (getMCM() % constants::NMCMROBINCOL) + constants::NMCMROBINCOL * (getROB() % 2); + float offset = -63.f + ((float)constants::NCOLMCM) * mcmCol; + float padWidth = 0.635f + 0.03f * (getDetector() % constants::NLAYER); + return (offset + padLocal * constants::GRANULARITYTRKLPOS) * padWidth; +} + +GPUdi() float Tracklet64::getUncalibratedDy(float nTbDrift) const +{ + float dy; + int dyLocalBin = getSlope(); + if (dyLocalBin & (1 << (constants::NBITSTRKLSLOPE - 1))) { + dy = (~(dyLocalBin - 1)) & ((1 << constants::NBITSTRKLSLOPE) - 1); + dy *= -1.f; + } else { + dy = dyLocalBin & ((1 << constants::NBITSTRKLSLOPE) - 1); + } + float padWidth = 0.635f + 0.03f * (getDetector() % constants::NLAYER); + return dy * constants::GRANULARITYTRKLSLOPE * padWidth * nTbDrift; +} + #ifndef GPUCA_GPUCODE_DEVICE std::ostream& operator<<(std::ostream& stream, const Tracklet64& trg); #endif // GPUCA_GPUCODE_DEVICE } //namespace trd } //namespace o2 + #endif diff --git a/DataFormats/Detectors/TRD/src/Tracklet64.cxx b/DataFormats/Detectors/TRD/src/Tracklet64.cxx index 6e6eb43146776..73af94f4ea2d0 100644 --- a/DataFormats/Detectors/TRD/src/Tracklet64.cxx +++ b/DataFormats/Detectors/TRD/src/Tracklet64.cxx @@ -22,35 +22,6 @@ namespace trd using namespace constants; -GPUd() float Tracklet64::getUncalibratedY() const -{ - int padLocalBin = getPosition(); - int padLocal = 0; - if (padLocalBin & (1 << (NBITSTRKLPOS - 1))) { - padLocal = -((~(padLocalBin - 1)) & ((1 << NBITSTRKLPOS) - 1)); - } else { - padLocal = padLocalBin & ((1 << NBITSTRKLPOS) - 1); - } - int mcmCol = (getMCM() % NMCMROBINCOL) + NMCMROBINCOL * (getROB() % 2); - float offset = -63.f + ((float)NCOLMCM) * mcmCol; - float padWidth = 0.635f + 0.03f * (getDetector() % NLAYER); - return (offset + padLocal * GRANULARITYTRKLPOS) * padWidth; -} - -GPUd() float Tracklet64::getUncalibratedDy(float nTbDrift) const -{ - float dy; - int dyLocalBin = getSlope(); - if (dyLocalBin & (1 << (NBITSTRKLSLOPE - 1))) { - dy = (~(dyLocalBin - 1)) & ((1 << NBITSTRKLSLOPE) - 1); - dy *= -1.f; - } else { - dy = dyLocalBin & ((1 << NBITSTRKLSLOPE) - 1); - } - float padWidth = 0.635f + 0.03f * (getDetector() % NLAYER); - return dy * GRANULARITYTRKLSLOPE * padWidth * nTbDrift; -} - #ifndef GPUCA_GPUCODE_DEVICE void Tracklet64::printStream(std::ostream& stream) const { diff --git a/Detectors/TRD/workflow/include/TRDWorkflow/TRDDigitReaderSpec.h b/Detectors/TRD/workflow/include/TRDWorkflow/TRDDigitReaderSpec.h index 2837bd004e363..0e4b5da6c360c 100644 --- a/Detectors/TRD/workflow/include/TRDWorkflow/TRDDigitReaderSpec.h +++ b/Detectors/TRD/workflow/include/TRDWorkflow/TRDDigitReaderSpec.h @@ -29,7 +29,7 @@ namespace trd class TRDDigitReaderSpec : public o2::framework::Task { public: - TRDDigitReaderSpec(int channels) : mChannels(channels){}; + TRDDigitReaderSpec(int channels, bool useMC) : mChannels(channels), mUseMC(useMC) {} ~TRDDigitReaderSpec() override = default; void init(o2::framework::InitContext& ic) override; void run(o2::framework::ProcessingContext& pc) override; @@ -39,6 +39,7 @@ class TRDDigitReaderSpec : public o2::framework::Task int mState = 0; bool mUseRun2 = false; int mChannels; + bool mUseMC = false; std::unique_ptr mFile = nullptr; //std::unique_ptr DPLTree; std::string mInputFileName = ""; @@ -48,7 +49,7 @@ class TRDDigitReaderSpec : public o2::framework::Task std::string mMCLabelsBranchName = "TRDMCLabels"; }; -o2::framework::DataProcessorSpec getTRDDigitReaderSpec(int channels); +o2::framework::DataProcessorSpec getTRDDigitReaderSpec(int channels, bool useMC); } // end namespace trd } // end namespace o2 diff --git a/Detectors/TRD/workflow/include/TRDWorkflow/TRDTrackletWriterSpec.h b/Detectors/TRD/workflow/include/TRDWorkflow/TRDTrackletWriterSpec.h index 915623afcf0db..292f0a5c38a85 100644 --- a/Detectors/TRD/workflow/include/TRDWorkflow/TRDTrackletWriterSpec.h +++ b/Detectors/TRD/workflow/include/TRDWorkflow/TRDTrackletWriterSpec.h @@ -31,7 +31,7 @@ namespace o2 namespace trd { -o2::framework::DataProcessorSpec getTRDTrackletWriterSpec(); +o2::framework::DataProcessorSpec getTRDTrackletWriterSpec(bool useMC); } // end namespace trd } // end namespace o2 diff --git a/Detectors/TRD/workflow/include/TRDWorkflow/TRDTrapSimulatorSpec.h b/Detectors/TRD/workflow/include/TRDWorkflow/TRDTrapSimulatorSpec.h index bbb13dda0ede5..b1fb37b92ab1c 100644 --- a/Detectors/TRD/workflow/include/TRDWorkflow/TRDTrapSimulatorSpec.h +++ b/Detectors/TRD/workflow/include/TRDWorkflow/TRDTrapSimulatorSpec.h @@ -34,7 +34,7 @@ class TRDDPLTrapSimulatorTask : public o2::framework::Task { public: - TRDDPLTrapSimulatorTask() = default; + TRDDPLTrapSimulatorTask(bool useMC) : mUseMC(useMC) {} void init(o2::framework::InitContext& ic) override; void run(o2::framework::ProcessingContext& pc) override; @@ -46,6 +46,7 @@ class TRDDPLTrapSimulatorTask : public o2::framework::Task unsigned long mRunNumber = 297595; //run number to anchor simulation to. int mShowTrackletStats = 1; // show some statistics for each run bool mEnableOnlineGainCorrection{false}; + bool mUseMC{false}; // whether or not to use MC labels bool mEnableTrapConfigDump{false}; bool mShareDigitsManually{true}; // duplicate digits connected to shared pads if digitizer did not do so std::string mTrapConfigName; // the name of the config to be used. @@ -57,10 +58,10 @@ class TRDDPLTrapSimulatorTask : public o2::framework::Task void loadTrapConfig(); void loadDefaultTrapConfig(); void setOnlineGainTables(); - void processTRAPchips(int currDetector, int& nTrackletsInTrigRec, std::vector& trapTrackletsAccum, o2::dataformats::MCTruthContainer& trackletMCLabels, const o2::dataformats::ConstMCTruthContainer& digitMCLabels); + void processTRAPchips(int currDetector, int& nTrackletsInTrigRec, std::vector& trapTrackletsAccum, o2::dataformats::MCTruthContainer& lblTracklets, const o2::dataformats::ConstMCTruthContainer* lblDigits); }; -o2::framework::DataProcessorSpec getTRDTrapSimulatorSpec(); +o2::framework::DataProcessorSpec getTRDTrapSimulatorSpec(bool useMC); } // end namespace trd } // end namespace o2 diff --git a/Detectors/TRD/workflow/src/TRDDigitReaderSpec.cxx b/Detectors/TRD/workflow/src/TRDDigitReaderSpec.cxx index 9931ad0269fa2..1fc93483de10e 100644 --- a/Detectors/TRD/workflow/src/TRDDigitReaderSpec.cxx +++ b/Detectors/TRD/workflow/src/TRDDigitReaderSpec.cxx @@ -97,14 +97,17 @@ void TRDDigitReaderSpec::run(ProcessingContext& pc) }; getFromBranch(mDigitBranchName.c_str(), (void**)&digits); getFromBranch(mTriggerRecordBranchName.c_str(), (void**)&triggerRecords); - getFromBranch(mMCLabelsBranchName.c_str(), (void**)&ioLabels); + if (mUseMC) { + getFromBranch(mMCLabelsBranchName.c_str(), (void**)&ioLabels); + // publish labels in shared memory + auto& sharedlabels = pc.outputs().make>(Output{"TRD", "LABELS", 0, Lifetime::Timeframe}); + ioLabels->copyandflatten(sharedlabels); + LOG(info) << "TRDDigitReader labels size (in bytes) = " << sharedlabels.size(); + } - // publish labels in shared memory - auto& sharedlabels = pc.outputs().make>(Output{"TRD", "LABELS", 0, Lifetime::Timeframe}); - ioLabels->copyandflatten(sharedlabels); pc.outputs().snapshot(Output{"TRD", "DIGITS", 0, Lifetime::Timeframe}, *digits); pc.outputs().snapshot(Output{"TRD", "TRGRDIG", 0, Lifetime::Timeframe}, *triggerRecords); - LOG(info) << "TRDDigitReader digits size=" << digits->size() << " triggerrecords size=" << triggerRecords->size() << " mc labels size (in bytes) = " << sharedlabels.size(); + LOG(info) << "TRDDigitReader digits size=" << digits->size() << " triggerrecords size=" << triggerRecords->size(); } //delete DPLTree; // next line will delete the pointer as well. mFile->Close(); @@ -115,17 +118,18 @@ void TRDDigitReaderSpec::run(ProcessingContext& pc) pc.services().get().readyToQuit(QuitRequest::Me); } -DataProcessorSpec getTRDDigitReaderSpec(int channels) +DataProcessorSpec getTRDDigitReaderSpec(int channels, bool useMC) { - + std::vector outputs; + outputs.emplace_back("TRD", "DIGITS", 0, Lifetime::Timeframe); + outputs.emplace_back("TRD", "TRGRDIG", 0, Lifetime::Timeframe); + if (useMC) { + outputs.emplace_back("TRD", "LABELS", 0, Lifetime::Timeframe); + } return DataProcessorSpec{"TRDDIGITREADER", Inputs{}, - Outputs{ - OutputSpec{"TRD", "DIGITS", 0, Lifetime::Timeframe}, - OutputSpec{"TRD", "TRGRDIG", 0, Lifetime::Timeframe}, - OutputSpec{"TRD", "LABELS", 0, Lifetime::Timeframe}}, - // outputs, - AlgorithmSpec{adaptFromTask(channels)}, + outputs, + AlgorithmSpec{adaptFromTask(channels, useMC)}, Options{ {"digitsfile", VariantType::String, "trddigits.root", {"Input data file containing run3 digitizer going into Trap Simulator"}}, {"run2digitsfile", VariantType::String, "run2digits.root", {"Input data file containing run2 digitis going into Trap Simulator"}}}}; diff --git a/Detectors/TRD/workflow/src/TRDTrackletWriterSpec.cxx b/Detectors/TRD/workflow/src/TRDTrackletWriterSpec.cxx index 0fd41821ce10c..e95fd7369ef36 100644 --- a/Detectors/TRD/workflow/src/TRDTrackletWriterSpec.cxx +++ b/Detectors/TRD/workflow/src/TRDTrackletWriterSpec.cxx @@ -34,7 +34,7 @@ namespace trd template using BranchDefinition = framework::MakeRootTreeWriterSpec::BranchDefinition; -o2::framework::DataProcessorSpec getTRDTrackletWriterSpec() +o2::framework::DataProcessorSpec getTRDTrackletWriterSpec(bool useMC) { // using InputSpec = framework::InputSpec; using MakeRootTreeWriterSpec = framework::MakeRootTreeWriterSpec; @@ -52,7 +52,7 @@ o2::framework::DataProcessorSpec getTRDTrackletWriterSpec() "trdtracklets.root", "o2sim", BranchDefinition>{InputSpec{"tracklets", "TRD", "TRACKLETS"}, "Tracklet"}, - BranchDefinition>{InputSpec{"trklabels", "TRD", "TRKLABELS"}, "TRKLabels"}, + BranchDefinition>{InputSpec{"trklabels", "TRD", "TRKLABELS"}, "TRKLabels", (useMC ? 1 : 0), "TRKLABELS"}, BranchDefinition>{InputSpec{"tracklettrigs", "TRD", "TRKTRGRD"}, "TrackTrg"})(); }; diff --git a/Detectors/TRD/workflow/src/TRDTrapSimulatorSpec.cxx b/Detectors/TRD/workflow/src/TRDTrapSimulatorSpec.cxx index 9d50b6ba8c568..a1be85d49d7a9 100644 --- a/Detectors/TRD/workflow/src/TRDTrapSimulatorSpec.cxx +++ b/Detectors/TRD/workflow/src/TRDTrapSimulatorSpec.cxx @@ -11,6 +11,7 @@ #include "TRDWorkflow/TRDTrapSimulatorSpec.h" #include +#include #include #include "TFile.h" @@ -142,7 +143,7 @@ void TRDDPLTrapSimulatorTask::setOnlineGainTables() } } -void TRDDPLTrapSimulatorTask::processTRAPchips(int currDetector, int& nTrackletsInTrigRec, std::vector& trapTrackletsAccum, o2::dataformats::MCTruthContainer& trackletMCLabels, const o2::dataformats::ConstMCTruthContainer& digitMCLabels) +void TRDDPLTrapSimulatorTask::processTRAPchips(int currDetector, int& nTrackletsInTrigRec, std::vector& trapTrackletsAccum, o2::dataformats::MCTruthContainer& lblTracklets, const o2::dataformats::ConstMCTruthContainer* lblDigits) { // Loop over all TRAP chips of detector number currDetector. // TRAP chips without input data are skipped @@ -159,36 +160,38 @@ void TRDDPLTrapSimulatorTask::processTRAPchips(int currDetector, int& nTracklets auto trackletsOut = mTrapSimulator[iTrap].getTrackletArray64(); int nTrackletsOut = trackletsOut.size(); nTrackletsInTrigRec += nTrackletsOut; - auto digitCountOut = mTrapSimulator[iTrap].getTrackletDigitCount(); // number of digits contributing to each tracklet - auto digitIndicesOut = mTrapSimulator[iTrap].getTrackletDigitIndices(); // global indices of the digits composing the tracklets - int currDigitIndex = 0; // count the total number of digits which are associated to tracklets for this TRAP - int trkltIdxStart = trapTrackletsAccum.size(); - for (int iTrklt = 0; iTrklt < nTrackletsOut; ++iTrklt) { - // for each tracklet of this TRAP check the MC labels of the digits which contribute to the tracklet - int tmp = currDigitIndex; - for (int iDigitIndex = tmp; iDigitIndex < tmp + digitCountOut[iTrklt]; ++iDigitIndex) { - if (iDigitIndex == tmp) { - // for the first digit composing the tracklet we don't need to check for duplicate labels - trackletMCLabels.addElements(trkltIdxStart + iTrklt, digitMCLabels.getLabels(digitIndicesOut[iDigitIndex])); - } else { - // in case more than one digit composes the tracklet we add only the labels - // from the additional digit(s) which are not already contained in the previous - // digit(s) - auto currentLabels = trackletMCLabels.getLabels(trkltIdxStart + iTrklt); - auto newLabels = digitMCLabels.getLabels(digitIndicesOut[iDigitIndex]); - for (const auto& newLabel : newLabels) { - bool isAlreadyIn = false; - for (const auto& currLabel : currentLabels) { - if (currLabel.compare(newLabel)) { - isAlreadyIn = true; + if (mUseMC) { + auto digitCountOut = mTrapSimulator[iTrap].getTrackletDigitCount(); // number of digits contributing to each tracklet + auto digitIndicesOut = mTrapSimulator[iTrap].getTrackletDigitIndices(); // global indices of the digits composing the tracklets + int currDigitIndex = 0; // count the total number of digits which are associated to tracklets for this TRAP + int trkltIdxStart = trapTrackletsAccum.size(); + for (int iTrklt = 0; iTrklt < nTrackletsOut; ++iTrklt) { + // for each tracklet of this TRAP check the MC labels of the digits which contribute to the tracklet + int tmp = currDigitIndex; + for (int iDigitIndex = tmp; iDigitIndex < tmp + digitCountOut[iTrklt]; ++iDigitIndex) { + if (iDigitIndex == tmp) { + // for the first digit composing the tracklet we don't need to check for duplicate labels + lblTracklets.addElements(trkltIdxStart + iTrklt, lblDigits->getLabels(digitIndicesOut[iDigitIndex])); + } else { + // in case more than one digit composes the tracklet we add only the labels + // from the additional digit(s) which are not already contained in the previous + // digit(s) + auto currentLabels = lblTracklets.getLabels(trkltIdxStart + iTrklt); + auto newLabels = lblDigits->getLabels(digitIndicesOut[iDigitIndex]); + for (const auto& newLabel : newLabels) { + bool isAlreadyIn = false; + for (const auto& currLabel : currentLabels) { + if (currLabel.compare(newLabel)) { + isAlreadyIn = true; + } + } + if (!isAlreadyIn) { + lblTracklets.addElement(trkltIdxStart + iTrklt, newLabel); } - } - if (!isAlreadyIn) { - trackletMCLabels.addElement(trkltIdxStart + iTrklt, newLabel); } } + ++currDigitIndex; } - ++currDigitIndex; } } trapTrackletsAccum.insert(trapTrackletsAccum.end(), trackletsOut.begin(), trackletsOut.end()); @@ -221,25 +224,32 @@ void TRDDPLTrapSimulatorTask::run(o2::framework::ProcessingContext& pc) // input auto inputDigits = pc.inputs().get>("digitinput"); // block of TRD digits - auto digitMCLabels = pc.inputs().get>("labelinput"); // MC labels associated to the input digits auto inputTriggerRecords = pc.inputs().get>("triggerrecords"); // time and number of digits for each collision if (inputDigits.size() == 0 || inputTriggerRecords.size() == 0) { LOG(warn) << "Did not receive any digits, trigger records, or neither one nor the other. Aborting."; return; } LOG(debug) << "Read in " << inputDigits.size() << " digits"; - LOG(debug) << "Labels contain " << digitMCLabels.getNElements() << " elements with and indexed size of " << digitMCLabels.getIndexedSize(); - LOG(debug) << "Trigger records are available for " << inputTriggerRecords.size() << " collisions"; - if (digitMCLabels.getIndexedSize() != inputDigits.size()) { - LOG(warn) << "Digits and Labels coming into TrapSimulator are of differing sizes, labels will be jibberish. " << digitMCLabels.getIndexedSize() << "!=" << inputDigits.size(); + + const o2::dataformats::ConstMCTruthContainer* lblDigitsPtr = nullptr; + using lblType = std::decay_t>(""))>; + std::optional lblDigits; + + if (mUseMC) { + lblDigits.emplace(pc.inputs().get>("labelinput")); // MC labels associated to the input digits + lblDigitsPtr = &lblDigits.value(); + LOG(debug) << "Labels contain " << lblDigitsPtr->getNElements() << " elements with and indexed size of " << lblDigitsPtr->getIndexedSize(); + if (lblDigitsPtr->getIndexedSize() != inputDigits.size()) { + LOG(warn) << "Digits and Labels coming into TrapSimulator are of differing sizes, labels will be jibberish. " << lblDigitsPtr->getIndexedSize() << "!=" << inputDigits.size(); + } } + LOG(debug) << "Trigger records are available for " << inputTriggerRecords.size() << " collisions"; // output std::vector trapTrackletsAccum; // calculated tracklets - o2::dataformats::MCTruthContainer trackletMCLabels; // MC labels for the tracklets, taken from the digits which make up the tracklet (duplicates are removed) // copy from the input to keep the collision times, but the number of objects in here will refer to tracklets instead of digits std::vector trackletTriggerRecords(inputTriggerRecords.begin(), inputTriggerRecords.end()); // time and number of tracklets for each collision - trapTrackletsAccum.reserve(inputDigits.size() / 500); + o2::dataformats::MCTruthContainer lblTracklets; // MC labels for the tracklets, taken from the digits which make up the tracklet (duplicates are removed) // sort digits by chamber ID for each collision and keep track in index vector auto sortStart = std::chrono::high_resolution_clock::now(); @@ -266,7 +276,7 @@ void TRDDPLTrapSimulatorTask::run(o2::framework::ProcessingContext& pc) } if (currDetector != digit->getDetector()) { // we switch to a new chamber, process all TRAPs of the previous chamber which contain data - processTRAPchips(currDetector, nTrackletsInTrigRec, trapTrackletsAccum, trackletMCLabels, digitMCLabels); + processTRAPchips(currDetector, nTrackletsInTrigRec, trapTrackletsAccum, lblTracklets, lblDigitsPtr); currDetector = digit->getDetector(); } // fill the digit data into the corresponding TRAP chip @@ -302,12 +312,14 @@ void TRDDPLTrapSimulatorTask::run(o2::framework::ProcessingContext& pc) mTrapSimulator[trapIdx].setData(digit->getChannel(), digit->getADC(), digitIndices[iDigit]); } // take care of the TRAPs for the last chamber - processTRAPchips(currDetector, nTrackletsInTrigRec, trapTrackletsAccum, trackletMCLabels, digitMCLabels); + processTRAPchips(currDetector, nTrackletsInTrigRec, trapTrackletsAccum, lblTracklets, lblDigitsPtr); trackletTriggerRecords[iTrig].setDataRange(trapTrackletsAccum.size() - nTrackletsInTrigRec, nTrackletsInTrigRec); } LOG(info) << "Trap simulator found " << trapTrackletsAccum.size() << " tracklets from " << inputDigits.size() << " Digits."; - LOG(info) << "In total " << trackletMCLabels.getNElements() << " MC labels are associated to the tracklets"; + if (mUseMC) { + LOG(info) << "In total " << lblTracklets.getNElements() << " MC labels are associated to the tracklets"; + } if (mShowTrackletStats > 0) { std::chrono::duration digitLoopTime = std::chrono::high_resolution_clock::now() - timeDigitLoopStart; LOG(info) << "Trap Simulator done "; @@ -317,21 +329,35 @@ void TRDDPLTrapSimulatorTask::run(o2::framework::ProcessingContext& pc) } pc.outputs().snapshot(Output{"TRD", "TRACKLETS", 0, Lifetime::Timeframe}, trapTrackletsAccum); pc.outputs().snapshot(Output{"TRD", "TRKTRGRD", 0, Lifetime::Timeframe}, trackletTriggerRecords); - pc.outputs().snapshot(Output{"TRD", "TRKLABELS", 0, Lifetime::Timeframe}, trackletMCLabels); + if (mUseMC) { + pc.outputs().snapshot(Output{"TRD", "TRKLABELS", 0, Lifetime::Timeframe}, lblTracklets); + } LOG(debug) << "TRD Trap Simulator Device exiting"; pc.services().get().endOfStream(); pc.services().get().readyToQuit(QuitRequest::Me); } -o2::framework::DataProcessorSpec getTRDTrapSimulatorSpec() +o2::framework::DataProcessorSpec getTRDTrapSimulatorSpec(bool useMC) { - return DataProcessorSpec{"TRAP", Inputs{InputSpec{"digitinput", "TRD", "DIGITS", 0}, InputSpec{"triggerrecords", "TRD", "TRGRDIG", 0}, InputSpec{"labelinput", "TRD", "LABELS", 0}}, + std::vector inputs; + std::vector outputs; + + inputs.emplace_back("digitinput", "TRD", "DIGITS", 0); + inputs.emplace_back("triggerrecords", "TRD", "TRGRDIG", 0); + + outputs.emplace_back("TRD", "TRACKLETS", 0, Lifetime::Timeframe); + outputs.emplace_back("TRD", "TRKTRGRD", 0, Lifetime::Timeframe); + + if (useMC) { + inputs.emplace_back("labelinput", "TRD", "LABELS", 0); + outputs.emplace_back("TRD", "TRKLABELS", 0, Lifetime::Timeframe); + } - Outputs{OutputSpec{"TRD", "TRACKLETS", 0, Lifetime::Timeframe}, // this is the 64 tracklet words - OutputSpec{"TRD", "TRKTRGRD", 0, Lifetime::Timeframe}, - OutputSpec{"TRD", "TRKLABELS", 0, Lifetime::Timeframe}}, - AlgorithmSpec{adaptFromTask()}, + return DataProcessorSpec{"TRAP", + inputs, + outputs, + AlgorithmSpec{adaptFromTask(useMC)}, Options{ {"show-trd-trackletstats", VariantType::Int, 1, {"Display the processing time of the tracklet processing in the TRAPs"}}, {"trd-trapconfig", VariantType::String, "cf_pg-fpnp32_zs-s16-deh_tb30_trkl-b5n-fs1e24-ht200-qs0e24s24e23-pidlinear-pt100_ptrg.r5549", {"Name of the trap config from the CCDB default:cf_pg-fpnp32_zs-s16-deh_tb30_trkl-b5n-fs1e24-ht200-qs0e24s24e23-pidlinear-pt100_ptrg.r5549"}}, diff --git a/Detectors/TRD/workflow/src/TRDTrapSimulatorWorkFlow.cxx b/Detectors/TRD/workflow/src/TRDTrapSimulatorWorkFlow.cxx index 29ed3de45816c..6489db574c73a 100644 --- a/Detectors/TRD/workflow/src/TRDTrapSimulatorWorkFlow.cxx +++ b/Detectors/TRD/workflow/src/TRDTrapSimulatorWorkFlow.cxx @@ -58,6 +58,10 @@ void customize(std::vector& workflowoptions) //limit to a stack in a supermodule std::string trapsimstackhelp("Specify the specific stack to work on [0-5] within the supermodule"); workflowoptions.push_back(ConfigParamSpec{"simStack", VariantType::Int, -1, {trapsimstackhelp}}); + + workflowoptions.push_back(ConfigParamSpec{"disable-mc", o2::framework::VariantType::Bool, false, {"Disable MC labels"}}); + workflowoptions.push_back(ConfigParamSpec{"disable-root-input", o2::framework::VariantType::Bool, false, {"Disable root-files input readers"}}); + workflowoptions.push_back(ConfigParamSpec{"disable-root-output", o2::framework::VariantType::Bool, false, {"Disable root-files output writers"}}); //limit to a stack in a supermodule // the next one is now done inside the trapsim spec. // std::string trapsimconfighelp("Specify the Trap config to use from CCDB yes those long names like cf_pg-fpnp32_zs-s16-deh_tb24_trkl-b2p-fs1e24-ht200-qs0e24s24e23-pidlinear-pt100_ptrg.r5585"); @@ -79,12 +83,16 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) // at the end. This places the processor at the beginning of the // workflow in the upper left corner of the GUI. // - return WorkflowSpec{ - //?? maybe a read spec to define the input in the case of my text run2 data and possible a proper data input reader. - o2::trd::getTRDDigitReaderSpec(1), - //o2::trd::getTRDDigitReaderSpec(1), - // connect the TRD digitization - o2::trd::getTRDTrapSimulatorSpec(), - // connect the TRD digit writer - o2::trd::getTRDTrackletWriterSpec()}; + WorkflowSpec specs; + auto useMC = !configcontext.options().get("disable-mc"); + auto disableRootInput = configcontext.options().get("disable-root-input"); + auto disableRootOutput = configcontext.options().get("disable-root-output"); + if (!disableRootInput) { + specs.emplace_back(o2::trd::getTRDDigitReaderSpec(1, useMC)); + } + specs.emplace_back(o2::trd::getTRDTrapSimulatorSpec(useMC)); + if (!disableRootOutput) { + specs.emplace_back(o2::trd::getTRDTrackletWriterSpec(useMC)); + } + return std::move(specs); } diff --git a/Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx b/Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx index 14008ca99351e..d98fb1caf8399 100644 --- a/Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx +++ b/Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx @@ -536,9 +536,9 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) auto enableTrapSim = configcontext.options().get("enable-trd-trapsim"); if (enableTrapSim) { // connect the TRD Trap SimulatorA - specs.emplace_back(o2::trd::getTRDTrapSimulatorSpec()); + specs.emplace_back(o2::trd::getTRDTrapSimulatorSpec(mctruth)); // connect to the device to write out the tracklets. - specs.emplace_back(o2::trd::getTRDTrackletWriterSpec()); + specs.emplace_back(o2::trd::getTRDTrackletWriterSpec(mctruth)); } }