Skip to content

Commit

Permalink
option to store dia TOF calib directly from digits
Browse files Browse the repository at this point in the history
  • Loading branch information
noferini committed Feb 6, 2024
1 parent f4af221 commit 766ad2f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "DetectorsRaw/HBFUtilsInitializer.h"
#include "Framework/CallbacksPolicy.h"
#include "Framework/CompletionPolicyHelpers.h"
#include "TOFWorkflowIO/TOFCalibWriterSpec.h"

#include <string>
#include <stdexcept>
Expand Down Expand Up @@ -71,6 +72,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
{"orbits-per-tf", VariantType::Int, -1, {"default(-1) from GRP/CCDB, a valid value is required to run compressor for epn"}},
{"calib-cluster", VariantType::Bool, false, {"to enable calib info production from clusters"}},
{"for-calib", VariantType::Bool, false, {"to disable check on problematic, otherwise masked for new calibrations"}},
{"calib-dia", VariantType::Bool, false, {"enabling writing calib for diagnostics"}},
{"cosmics", VariantType::Bool, false, {"to enable cosmics utils"}}};
o2::raw::HBFUtilsInitializer::addConfigOption(options);
std::swap(workflowOptions, options);
Expand Down Expand Up @@ -147,6 +149,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
auto orbitPerTF = cfgc.options().get<int>("orbits-per-tf");
auto ccdb_url = o2::base::NameConf::getCCDBServer();
auto isForCalib = cfgc.options().get<bool>("for-calib");
auto writingDia = cfgc.options().get<bool>("calib-dia");

LOG(debug) << "TOF RECO WORKFLOW configuration";
LOG(debug) << "TOF input = " << cfgc.options().get<std::string>("input-type");
Expand Down Expand Up @@ -205,6 +208,10 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
}
}

if (writingDia) {
specs.emplace_back(o2::tof::getTOFCalibWriterSpec("o2calib_tof.root", false, true, true));
}

LOG(debug) << "Number of active devices = " << specs.size();

// configure dpl timer to inject correct firstTForbit: start from the 1st orbit of TF containing 1st sampled orbit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace tof

/// create a processor spec
/// write TOF calbi info in a root file
o2::framework::DataProcessorSpec getTOFCalibWriterSpec(const char* outdef = "o2calib_tof.root", bool toftpc = false, bool addDia = false);
o2::framework::DataProcessorSpec getTOFCalibWriterSpec(const char* outdef = "o2calib_tof.root", bool toftpc = false, bool addDia = false, bool onlyDia = false);

} // namespace tof
} // namespace o2
Expand Down
7 changes: 7 additions & 0 deletions Detectors/TOF/workflowIO/src/DigitReaderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "TOFWorkflowIO/DigitReaderSpec.h"
#include "DataFormatsParameters/GRPObject.h"
#include "CommonUtils/NameConf.h"
#include "DetectorsBase/TFIDInfoHelper.h"

using namespace o2::framework;
using namespace o2::tof;
Expand Down Expand Up @@ -79,6 +80,12 @@ void DigitReader::run(ProcessingContext& pc)
mFiller.setReadoutWindowData(mRow, mPatterns);
mFiller.fillDiagnosticFrequency();
mDiagnostic = mFiller.getDiagnosticFrequency();
auto creationTime = pc.services().get<o2::framework::TimingInfo>().creation;
mDiagnostic.setTimeStamp(creationTime / 1000);
// add TFIDInfo
o2::dataformats::TFIDInfo tfinfo;
o2::base::TFIDInfoHelper::fillTFIDInfo(pc, tfinfo);
mDiagnostic.setTFIDInfo(tfinfo);

// add digits loaded in the output snapshot
pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "DIGITS", 0}, mDigits);
Expand Down
7 changes: 5 additions & 2 deletions Detectors/TOF/workflowIO/src/TOFCalibWriterSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ template <typename T>
using BranchDefinition = MakeRootTreeWriterSpec::BranchDefinition<T>;
using CalibInfosType = std::vector<o2::dataformats::CalibInfoTOF>;
using CalibDiaType = o2::tof::Diagnostic;
DataProcessorSpec getTOFCalibWriterSpec(const char* outdef, bool toftpc, bool addDia)
DataProcessorSpec getTOFCalibWriterSpec(const char* outdef, bool toftpc, bool addDia, bool onlyDia)
{
if (!addDia) {
onlyDia = false;
}
// A spectator for logging
auto logger = [](CalibInfosType const& indata) {
LOG(debug) << "RECEIVED MATCHED SIZE " << indata.size();
Expand All @@ -55,7 +58,7 @@ DataProcessorSpec getTOFCalibWriterSpec(const char* outdef, bool toftpc, bool ad
BranchDefinition<CalibInfosType>{InputSpec{"input", o2::header::gDataOriginTOF, ddCalib, 0},
"TOFCalibInfo",
"calibinfo-branch-name",
1,
!onlyDia,
logger},
BranchDefinition<CalibDiaType>{InputSpec{"inputDia", o2::header::gDataOriginTOF, ddCalibDia, 0},
"TOFDiaInfo",
Expand Down

0 comments on commit 766ad2f

Please sign in to comment.