@@ -59,35 +59,36 @@ using RDH = o2::header::RDHAny;
5959class DataDecoderTask
6060{
6161 public:
62+ DataDecoderTask (std::string spec) : mInputSpec (spec) {}
63+
6264 // _________________________________________________________________________________________________
6365 void init (framework::InitContext& ic)
6466 {
6567 SampaChannelHandler channelHandler;
6668 RdhHandler rdhHandler;
6769
6870 auto ds2manu = ic.options ().get <bool >(" ds2manu" );
69- mPrint = ic.options ().get <bool >(" print " );
71+ mDebug = ic.options ().get <bool >(" debug " );
7072 auto mapCRUfile = ic.options ().get <std::string>(" cru-map" );
7173 auto mapFECfile = ic.options ().get <std::string>(" fec-map" );
7274
73- mDecoder = new DataDecoder (channelHandler, rdhHandler, mapCRUfile, mapFECfile, ds2manu, mPrint );
75+ mDecoder = new DataDecoder (channelHandler, rdhHandler, mapCRUfile, mapFECfile, ds2manu, mDebug );
7476 }
7577
7678 // _________________________________________________________________________________________________
77- // the decodeTF() function processes the the messages generated by the (sub)TimeFrame builder
79+ // the decodeTF() function processes the messages generated by the (sub)TimeFrame builder
7880 void decodeTF (framework::ProcessingContext& pc)
7981 {
8082 // get the input buffer
8183 auto & inputs = pc.inputs ();
82- DPLRawParser parser (inputs, o2::framework::select (" TF:MCH/RAWDATA " ));
84+ DPLRawParser parser (inputs, o2::framework::select (mInputSpec . c_str () ));
8385
8486 for (auto it = parser.begin (), end = parser.end (); it != end; ++it) {
85- auto const * rdh = it.get_if <RDH>();
8687 auto const * raw = it.raw ();
87- size_t payloadSize = it.size ();
88- if (payloadSize == 0 ) {
88+ if (!raw) {
8989 continue ;
9090 }
91+ size_t payloadSize = it.size ();
9192
9293 gsl::span<const std::byte> buffer (reinterpret_cast <const std::byte*>(raw), sizeof (RDH) + payloadSize);
9394 mDecoder ->decodeBuffer (buffer);
@@ -113,7 +114,7 @@ class DataDecoderTask
113114 // size of payload
114115 size_t payloadSize = header->payloadSize ;
115116
116- if (mPrint ) {
117+ if (mDebug ) {
117118 std::cout << nFrame << " payloadSize=" << payloadSize << std::endl;
118119 }
119120 nFrame += 1 ;
@@ -156,7 +157,7 @@ class DataDecoderTask
156157 auto & digits = mDecoder ->getOutputDigits ();
157158 auto & orbits = mDecoder ->getOrbits ();
158159
159- if (mPrint ) {
160+ if (mDebug ) {
160161 for (auto d : digits) {
161162 std::cout << " DE# " << d.getDetID () << " PadId " << d.getPadID () << " ADC " << d.getADC () << " time " << d.getTime ().sampaTime << std::endl;
162163 }
@@ -173,19 +174,21 @@ class DataDecoderTask
173174 }
174175
175176 private:
176- bool mPrint = {false };
177- DataDecoder* mDecoder = {nullptr };
177+ std::string mInputSpec ; // / selection string for the input data
178+ bool mDebug = {false }; // / flag to enable verbose output
179+ DataDecoder* mDecoder = {nullptr }; // / pointer to the data decoder instance
178180};
179181
180182// _________________________________________________________________________________________________
181183o2::framework::DataProcessorSpec getDecodingSpec (std::string inputSpec)
182184{
185+ o2::mch::raw::DataDecoderTask task (inputSpec);
183186 return DataProcessorSpec{
184187 " DataDecoder" ,
185188 o2::framework::select (inputSpec.c_str ()),
186189 Outputs{OutputSpec{" MCH" , " DIGITS" , 0 , Lifetime::Timeframe}, OutputSpec{" MCH" , " ORBITS" , 0 , Lifetime::Timeframe}},
187- AlgorithmSpec{adaptFromTask<DataDecoderTask>()},
188- Options{{" print " , VariantType::Bool, false , {" print digits " }},
190+ AlgorithmSpec{adaptFromTask<DataDecoderTask>(std::move (task) )},
191+ Options{{" debug " , VariantType::Bool, false , {" enable verbose output " }},
189192 {" cru-map" , VariantType::String, " " , {" custom CRU mapping" }},
190193 {" fec-map" , VariantType::String, " " , {" custom FEC mapping" }},
191194 {" ds2manu" , VariantType::Bool, false , {" convert channel numbering from Run3 to Run1-2 order" }}}};
0 commit comments