@@ -49,25 +49,19 @@ using MCLabelContainer = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;
4949// / MC labels are received as MCLabelContainers
5050DataProcessorSpec getClusterDecoderRawSpec (bool sendMC)
5151{
52+ using DataDescription = o2::header::DataDescription;
5253 std::string processorName = " tpc-cluster-decoder" ;
5354
54- auto initFunction = [sendMC ](InitContext& ic) {
55+ auto initFunction = [](InitContext& ic) {
5556 // there is nothing to init at the moment
5657 auto verbosity = 0 ;
5758 auto decoder = std::make_shared<HardwareClusterDecoder>();
5859
59- auto processingFct = [verbosity, decoder, sendMC](ProcessingContext& pc) {
60- static bool finished = false ;
61- if (finished) {
62- return ;
63- }
60+ auto processSectorFunction = [verbosity, decoder](ProcessingContext& pc, std::string inputKey, std::string labelKey) -> bool {
6461 // this will return a span of TPC clusters
65- const auto & ref = pc.inputs ().get (" rawin " );
62+ const auto & ref = pc.inputs ().get (inputKey. c_str () );
6663 auto size = o2::framework::DataRefUtils::getPayloadSize (ref);
67- if (ref.payload == nullptr ) {
68- return ;
69- }
70- auto const * dataHeader = DataRefUtils::getHeader<o2::header::DataHeader*>(pc.inputs ().get (" rawin" ));
64+ auto const * dataHeader = DataRefUtils::getHeader<o2::header::DataHeader*>(pc.inputs ().get (inputKey.c_str ()));
7165 o2::header::DataHeader::SubSpecificationType fanSpec = dataHeader->subSpecification ;
7266
7367 // init the stacks for forwarding the sector header
@@ -76,28 +70,23 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC)
7670 o2::header::Stack rawHeaderStack;
7771 o2::header::Stack mcHeaderStack;
7872 o2::TPC ::TPCSectorHeader const * sectorHeaderMC = nullptr ;
79- if (sendMC ) {
80- sectorHeaderMC = DataRefUtils::getHeader<o2::TPC ::TPCSectorHeader*>(pc.inputs ().get (" mclblin " ));
73+ if (!labelKey. empty () ) {
74+ sectorHeaderMC = DataRefUtils::getHeader<o2::TPC ::TPCSectorHeader*>(pc.inputs ().get (labelKey. c_str () ));
8175 if (sectorHeaderMC) {
8276 o2::header::Stack actual{ *sectorHeaderMC };
8377 std::swap (mcHeaderStack, actual);
8478 if (sectorHeaderMC->sector < 0 ) {
85- pc.outputs ().snapshot (OutputRef{ " mclblout " , fanSpec, std::move (mcHeaderStack) }, fanSpec);
79+ pc.outputs ().snapshot (Output{ gDataOriginTPC , DataDescription ( " CLNATIVEMCLBL " ) , fanSpec, Lifetime::Timeframe , std::move (mcHeaderStack) }, fanSpec);
8680 }
8781 }
8882 }
89- auto const * sectorHeader = DataRefUtils::getHeader<o2::TPC ::TPCSectorHeader*>(pc.inputs ().get (" rawin " ));
83+ auto const * sectorHeader = DataRefUtils::getHeader<o2::TPC ::TPCSectorHeader*>(pc.inputs ().get (inputKey. c_str () ));
9084 if (sectorHeader) {
9185 o2::header::Stack actual{ *sectorHeader };
9286 std::swap (rawHeaderStack, actual);
9387 if (sectorHeader->sector < 0 ) {
94- pc.outputs ().snapshot (OutputRef{ " clusterout" , fanSpec, std::move (rawHeaderStack) }, fanSpec);
95- if (sectorHeader->sector == -1 ) {
96- // got EOD
97- finished = true ;
98- pc.services ().get <ControlService>().readyToQuit (false );
99- }
100- return ;
88+ pc.outputs ().snapshot (Output{ gDataOriginTPC , DataDescription (" CLUSTERNATIVE" ), fanSpec, Lifetime::Timeframe, std::move (rawHeaderStack) }, fanSpec);
89+ return (sectorHeader->sector == -1 );
10190 }
10291 }
10392 assert (sectorHeaderMC == nullptr || sectorHeader->sector == sectorHeaderMC->sector );
@@ -113,8 +102,8 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC)
113102 // in the raw pages
114103 std::vector<MCLabelContainer> mcinCopies;
115104 std::unique_ptr<const MCLabelContainer> mcin;
116- if (sendMC ) {
117- mcin = std::move (pc.inputs ().get <MCLabelContainer*>(" mclblin " ));
105+ if (!labelKey. empty () ) {
106+ mcin = std::move (pc.inputs ().get <MCLabelContainer*>(labelKey. c_str () ));
118107 mcinCopies.resize (nPages);
119108 if (verbosity > 0 ) {
120109 LOG (INFO ) << " Decoder input: " << size << " , " << nPages << " pages, " << mcin->getIndexedSize () << " MC label sets" ;
@@ -171,7 +160,7 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC)
171160 totalSize += coll.getFlatSize () + sizeof (ClusterGroupHeader) - sizeof (ClusterGroupAttribute);
172161 }
173162
174- auto * target = pc.outputs ().newChunk (OutputRef{ " clusterout " , fanSpec, std::move (rawHeaderStack) }, totalSize).data ;
163+ auto * target = pc.outputs ().newChunk (Output{ gDataOriginTPC , DataDescription ( " CLUSTERNATIVE " ) , fanSpec, Lifetime::Timeframe , std::move (rawHeaderStack) }, totalSize).data ;
175164
176165 for (const auto & coll : cont) {
177166 if (verbosity > 1 ) {
@@ -185,14 +174,48 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC)
185174 memcpy (target, coll.data (), coll.getFlatSize () - sizeof (ClusterGroupAttribute));
186175 target += coll.getFlatSize () - sizeof (ClusterGroupAttribute);
187176 }
188- if (sendMC ) {
177+ if (!labelKey. empty () ) {
189178 if (verbosity > 0 ) {
190179 LOG (INFO ) << " sending " << mcoutList.size () << " MC label container(s) with in total "
191180 << std::accumulate (mcoutList.begin (), mcoutList.end (), size_t (0 ), [](size_t l, auto const & r) { return l + r.getIndexedSize (); })
192181 << " label object(s)" << std::endl;
193182 }
194183 // serialize the complete list of MC label containers
195- pc.outputs ().snapshot (OutputRef{ " mclblout" , fanSpec, std::move (mcHeaderStack) }, mcoutList);
184+ pc.outputs ().snapshot (Output{ gDataOriginTPC , DataDescription (" CLNATIVEMCLBL" ), fanSpec, Lifetime::Timeframe, std::move (mcHeaderStack) }, mcoutList);
185+ }
186+ return false ;
187+ };
188+
189+ auto processingFct = [verbosity, decoder, processSectorFunction](ProcessingContext& pc) {
190+ static bool finished = false ;
191+ if (finished) {
192+ return ;
193+ }
194+
195+ struct SectorInputDesc {
196+ std::string inputKey = " " ;
197+ std::string labelKey = " " ;
198+ };
199+ std::map<o2::header::DataHeader::SubSpecificationType, SectorInputDesc> inputs;
200+ for (auto const & inputRef : pc.inputs ()) {
201+ auto const * dataHeader = DataRefUtils::getHeader<o2::header::DataHeader*>(inputRef);
202+ assert (dataHeader);
203+ if (dataHeader->dataOrigin == gDataOriginTPC && dataHeader->dataDescription == DataDescription (" CLUSTERHW" )) {
204+ inputs[dataHeader->subSpecification ].inputKey = inputRef.spec ->binding ;
205+ } else if (dataHeader->dataOrigin == gDataOriginTPC && dataHeader->dataDescription == DataDescription (" CLUSTERHWMCLBL" )) {
206+ inputs[dataHeader->subSpecification ].labelKey = inputRef.spec ->binding ;
207+ }
208+ }
209+ // will stay true if all inputs signal finished
210+ // this implies that all inputs are always processed together, when changing this policy the
211+ // status of each input needs to be kept individually
212+ finished = true ;
213+ for (auto const & input : inputs) {
214+ finished = finished & processSectorFunction (pc, input.second .inputKey , input.second .labelKey );
215+ }
216+ if (finished) {
217+ // got EOD on all inputs
218+ pc.services ().get <ControlService>().readyToQuit (false );
196219 }
197220 };
198221
0 commit comments