@@ -26,9 +26,7 @@ void customize(std::vector<o2::framework::CompletionPolicy>& policies)
2626void customize (std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
2727{
2828 // option allowing to set parameters
29- std::vector<ConfigParamSpec> options{
30- ConfigParamSpec{" dataspec" , VariantType::String, " tfidinfo:FLP/DISTSUBTIMEFRAME/0xccdb" , {" spec from which the TFIDInfo will be extracted" }},
31- ConfigParamSpec{" configKeyValues" , VariantType::String, " " , {" Semicolon separated key=value strings" }}};
29+ std::vector<ConfigParamSpec> options{ConfigParamSpec{" configKeyValues" , VariantType::String, " " , {" Semicolon separated key=value strings" }}};
3230
3331 std::swap (workflowOptions, options);
3432}
@@ -37,7 +35,10 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
3735#include " Framework/DataProcessingHeader.h"
3836#include " Framework/Task.h"
3937#include " CommonDataFormat/TFIDInfo.h"
38+ #include " CommonUtils/TreeStreamRedirector.h"
4039#include " CommonUtils/NameConf.h"
40+ #include " CommonConstants/LHCConstants.h"
41+ #include " Framework/CCDBParamSpec.h"
4142#include < vector>
4243#include < TFile.h>
4344
@@ -53,17 +54,31 @@ class TFIDInfoWriter : public o2::framework::Task
5354
5455 void run (o2::framework::ProcessingContext& pc) final
5556 {
57+ const auto & tinfo = pc.services ().get <o2::framework::TimingInfo>();
58+ if (tinfo.globalRunNumberChanged ) { // new run is starting
59+ auto v = pc.inputs ().get <std::vector<Long64_t>*>(" orbitReset" );
60+ mOrbitReset = (*v)[0 ];
61+ }
5662 o2::base::TFIDInfoHelper::fillTFIDInfo (pc, mData .emplace_back ());
5763 }
5864
5965 void endOfStream (EndOfStreamContext& ec) final
6066 {
67+ o2::utils::TreeStreamRedirector pcstream;
6168 TFile fl (mOutFileName .c_str (), " recreate" );
6269 fl.WriteObjectAny (&mData , " std::vector<o2::dataformats::TFIDInfo>" , " tfidinfo" );
63- LOGP (info, " Wrote TFIDInfo vector with {} entries to {}" , mData .size (), fl.GetName ());
70+ pcstream.SetFile (&fl);
71+ for (const auto & info : mData ) {
72+ long ts = (mOrbitReset + long (info.firstTForbit * o2::constants::lhc::LHCOrbitMUS)) / 1000 ;
73+ pcstream << " tfidTree"
74+ << " tfidinfo=" << info << " ts=" << ts << " \n " ;
75+ }
76+ pcstream.Close ();
77+ LOGP (info, " Wrote tfidinfo vector and tfidTree with {} entries to {}" , mData .size (), fl.GetName ());
6478 }
6579
6680 private:
81+ long mOrbitReset = 0 ;
6782 std::string mOutFileName {};
6883 std::vector<o2::dataformats::TFIDInfo> mData ;
6984};
@@ -72,8 +87,10 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
7287{
7388 WorkflowSpec wf;
7489 o2::conf::ConfigurableParam::updateFromString (cfgc.options ().get <std::string>(" configKeyValues" ));
75- wf.emplace_back (DataProcessorSpec{" tfid-info-writer" , o2::framework::select (cfgc.options ().get <std::string>(" dataspec" ).c_str ()),
76- std::vector<OutputSpec>{}, AlgorithmSpec{adaptFromTask<TFIDInfoWriter>()},
90+ wf.emplace_back (DataProcessorSpec{" tfid-info-writer" ,
91+ {{" orbitReset" , " CTP" , " ORBITRESET" , 0 , Lifetime::Condition, ccdbParamSpec (" CTP/Calib/OrbitReset" )}},
92+ std::vector<OutputSpec>{},
93+ AlgorithmSpec{adaptFromTask<TFIDInfoWriter>()},
7794 Options{{" tfidinfo-file-name" , VariantType::String, o2::base::NameConf::getTFIDInfoFileName (), {" output file for TFIDInfo" }}}});
7895 return wf;
7996}
0 commit comments