1717#include < vector>
1818#include < string>
1919#include < chrono>
20+ #include < fmt/format.h>
2021
2122#include " Framework/Task.h"
2223#include " Framework/ControlService.h"
2324#include " Framework/Logger.h"
2425#include " Framework/ConfigParamRegistry.h"
26+ #include " Framework/DataProcessorSpec.h"
2527
28+ #include " CommonUtils/MemFileHelper.h"
2629#include " Headers/DataHeader.h"
27- #include " CCDB/CcdbApi.h"
2830#include " DetectorsCalibration/Utils.h"
2931
3032#include " TPCBase/CDBInterface.h"
@@ -38,13 +40,13 @@ using clbUtils = o2::calibration::Utils;
3840
3941namespace o2
4042{
41- namespace calibration
43+ namespace tpc
4244{
4345
4446class TPCCalibPedestalDevice : public o2 ::framework::Task
4547{
4648 public:
47- TPCCalibPedestalDevice (bool skipCalib ) : mSkipCalib (skipCalib ) {}
49+ TPCCalibPedestalDevice (int lane, const std::vector< int >& sectors ) : mLane {lane}, mSectors (sectors ) {}
4850
4951 void init (o2::framework::InitContext& ic) final
5052 {
@@ -74,7 +76,7 @@ class TPCCalibPedestalDevice : public o2::framework::Task
7476 }
7577
7678 auto & reader = mRawReader .getReaders ()[0 ];
77- calib_processing_helper::processRawData (pc.inputs (), reader, mUseOldSubspec );
79+ calib_processing_helper::processRawData (pc.inputs (), reader, mUseOldSubspec , mSectors );
7880
7981 mCalibPedestal .incrementNEvents ();
8082 LOGP (info, " Number of processed events: {} ({})" , mCalibPedestal .getNumberOfProcessedEvents (), mMaxEvents );
@@ -96,51 +98,37 @@ class TPCCalibPedestalDevice : public o2::framework::Task
9698 {
9799 LOGP (info, " endOfStream" );
98100 dumpCalibData ();
99- if (!mSkipCalib ) {
100- sendOutput (ec.outputs ());
101- }
101+ sendOutput (ec.outputs ());
102102 ec.services ().get <ControlService>().readyToQuit (QuitRequest::Me);
103103 }
104104
105105 private:
106106 CalibPedestal mCalibPedestal ;
107107 rawreader::RawReaderCRUManager mRawReader ;
108- uint32_t mMaxEvents {100 };
109- bool mReadyToQuit {false };
110- bool mCalibDumped {false };
111- bool mUseOldSubspec {false };
112- bool mForceQuit {false };
113- bool mDirectFileDump {false };
114- bool mSkipCalib {false };
108+ uint32_t mMaxEvents {100 }; // /< maximum number of events to process
109+ int mLane {0 }; // /< lane number of processor
110+ std::vector<int > mSectors {}; // /< sectors to process in this instance
111+ bool mReadyToQuit {false }; // /< if processor is ready to quit
112+ bool mCalibDumped {false }; // /< if calibration object already dumped
113+ bool mUseOldSubspec {false }; // /< use the old subspec definition
114+ bool mForceQuit {false }; // /< for quit after processing finished
115+ bool mDirectFileDump {false }; // /< directly dump the calibration data to file
115116
116117 // ____________________________________________________________________________
117118 void sendOutput (DataAllocator& output)
118119 {
119- CDBStorage::MetaData_t md;
120-
121- // perhaps should be changed to time of the run
122- const auto now = std::chrono::system_clock::now ();
123- long timeStart = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch ()).count ();
124- long timeEnd = 99999999999999 ;
125120
126121 std::array<const CalDet<float >*, 2 > data = {&mCalibPedestal .getPedestal (), &mCalibPedestal .getNoise ()};
127122 std::array<CDBType, 2 > dataType = {CDBType::CalPedestal, CDBType::CalNoise};
128123
129124 for (size_t i = 0 ; i < data.size (); ++i) {
130125 auto cal = data[i];
131- o2::ccdb::CcdbObjectInfo w;
132- auto image = o2::ccdb::CcdbApi::createObjectImage (cal, &w);
133-
134- w.setPath (CDBTypeMap.at (dataType[i]));
135- w.setStartValidityTimestamp (timeStart);
136- w.setEndValidityTimestamp (timeEnd);
137-
138- LOG (INFO) << " Sending object " << w.getPath () << " /" << w.getFileName () << " of size " << image->size ()
139- << " bytes, valid for " << w.getStartValidityTimestamp () << " : " << w.getEndValidityTimestamp ();
126+ auto image = o2::utils::MemFileHelper::createFileImage (cal, typeid (*cal), cal->getName (), " data" );
127+ int type = int (dataType[i]);
140128
141129 header::DataHeader::SubSpecificationType subSpec{(header::DataHeader::SubSpecificationType)i};
142- output.snapshot (Output{clbUtils::gDataOriginCLB , clbUtils:: gDataDescriptionCLBPayload , subSpec}, *image.get ());
143- output.snapshot (Output{clbUtils::gDataOriginCLB , clbUtils:: gDataDescriptionCLBInfo , subSpec}, w );
130+ output.snapshot (Output{clbUtils::gDataOriginCLB , " TPCCLBPART " , subSpec}, *image.get ());
131+ output.snapshot (Output{clbUtils::gDataOriginCLB , " TPCCLBPARTINFO " , subSpec}, type );
144132 }
145133 }
146134
@@ -150,32 +138,24 @@ class TPCCalibPedestalDevice : public o2::framework::Task
150138 if (mDirectFileDump && !mCalibDumped ) {
151139 LOGP (info, " Dumping output" );
152140 mCalibPedestal .analyse ();
153- mCalibPedestal .dumpToFile (" pedestals .root" );
141+ mCalibPedestal .dumpToFile (fmt::format ( " pedestals_{:02} .root" , mLane ) );
154142 mCalibDumped = true ;
155143 }
156144 }
157145};
158146
159- } // namespace calibration
160-
161- namespace framework
147+ DataProcessorSpec getTPCCalibPedestalSpec (const std::string inputSpec, int ilane = 0 , std::vector<int > sectors = {})
162148{
149+ std::vector<o2::framework::OutputSpec> outputs;
150+ outputs.emplace_back (ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB , " TPCCLBPART" });
151+ outputs.emplace_back (ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB , " TPCCLBPARTINFO" });
163152
164- DataProcessorSpec getTPCCalibPedestalSpec (const std::string inputSpec, bool skipCalib)
165- {
166- using device = o2::calibration::TPCCalibPedestalDevice;
167-
168- std::vector<OutputSpec> outputs;
169- if (!skipCalib) {
170- outputs.emplace_back (ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB , clbUtils::gDataDescriptionCLBPayload });
171- outputs.emplace_back (ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB , clbUtils::gDataDescriptionCLBInfo });
172- }
173-
153+ const auto id = fmt::format (" calib-tpc-pedestal-{:02}" , ilane);
174154 return DataProcessorSpec{
175- " calib-tpc-pedestal " ,
155+ id. data () ,
176156 select (inputSpec.data ()),
177157 outputs,
178- AlgorithmSpec{adaptFromTask<device>(skipCalib )},
158+ AlgorithmSpec{adaptFromTask<TPCCalibPedestalDevice>(ilane, sectors )},
179159 Options{
180160 {" max-events" , VariantType::Int, 100 , {" maximum number of events to process" }},
181161 {" use-old-subspec" , VariantType::Bool, false , {" use old subsecifiation definition" }},
@@ -185,7 +165,7 @@ DataProcessorSpec getTPCCalibPedestalSpec(const std::string inputSpec, bool skip
185165 }; // end DataProcessorSpec
186166}
187167
188- } // namespace framework
168+ } // namespace tpc
189169} // namespace o2
190170
191171#endif
0 commit comments