From 467618dfe29d005853669d00ced7eb9096df78a5 Mon Sep 17 00:00:00 2001 From: noferini Date: Wed, 26 Feb 2020 13:04:33 +0100 Subject: [PATCH] finalize multi-frame treatement in tof chain --- Detectors/TOF/simulation/src/Digitizer.cxx | 4 +- .../TOF/workflow/src/TOFDigitWriterSpec.cxx | 21 ++++--- .../src/TOFDigitizerSpec.cxx | 60 ++++++++++--------- 3 files changed, 47 insertions(+), 38 deletions(-) diff --git a/Detectors/TOF/simulation/src/Digitizer.cxx b/Detectors/TOF/simulation/src/Digitizer.cxx index 503c60f430c69..bc205c567529c 100644 --- a/Detectors/TOF/simulation/src/Digitizer.cxx +++ b/Detectors/TOF/simulation/src/Digitizer.cxx @@ -100,8 +100,8 @@ int Digitizer::process(const std::vector* hits, std::vector* dig } // close loop readout window } // close if continuous - if (mReadoutWindowCurrent >= 256 * Geo::NWINDOW_IN_ORBIT) // new TF - return 1; + // if (mReadoutWindowCurrent >= 256 * Geo::NWINDOW_IN_ORBIT) // new TF + // return 1; for (auto& hit : *hits) { //TODO: put readout window counting/selection diff --git a/Detectors/TOF/workflow/src/TOFDigitWriterSpec.cxx b/Detectors/TOF/workflow/src/TOFDigitWriterSpec.cxx index 253e30d9ea548..9d7a0dcbd7a09 100644 --- a/Detectors/TOF/workflow/src/TOFDigitWriterSpec.cxx +++ b/Detectors/TOF/workflow/src/TOFDigitWriterSpec.cxx @@ -35,10 +35,12 @@ template TBranch* getOrMakeBranch(TTree& tree, std::string brname, T* ptr) { if (auto br = tree.GetBranch(brname.c_str())) { - br->SetAddress(static_cast(&ptr)); + printf("Re-use output branch %s\n",brname.c_str()); + br->SetAddress(static_cast(ptr)); return br; } // otherwise make it + printf("Create output branch %s\n",brname.c_str()); return tree.Branch(brname.c_str(), ptr); } @@ -54,9 +56,13 @@ DataProcessorSpec getTOFDigitWriterSpec(bool useMC) auto outputfile = std::make_shared(filename.c_str(), "RECREATE"); auto outputtree = std::make_shared(treename.c_str(), treename.c_str()); + int *nCalls = new int; + *nCalls = 0; + // the callback to be set as hook at stop of processing for the framework - auto finishWriting = [outputfile, outputtree]() { - outputtree->SetEntries(1); + auto finishWriting = [outputfile, outputtree, nCalls]() { + printf("finish writing with %d entries in the tree\n",*nCalls); + outputtree->SetEntries(*nCalls); outputtree->Write(); outputfile->Close(); }; @@ -66,15 +72,16 @@ DataProcessorSpec getTOFDigitWriterSpec(bool useMC) // using by-copy capture of the worker instance shared pointer // the shared pointer makes sure to clean up the instance when the processing // function gets out of scope - auto processingFct = [outputfile, outputtree, useMC](ProcessingContext& pc) { + auto processingFct = [outputfile, outputtree, useMC, nCalls](ProcessingContext& pc) { static bool finished = false; if (finished) { // avoid being executed again when marked as finished; return; } - + (*nCalls)++; // retrieve the digits from the input auto indata = pc.inputs().get*>("tofdigits"); + LOG(INFO) << "Call " << *nCalls; LOG(INFO) << "RECEIVED DIGITS SIZE " << indata->size(); auto row = pc.inputs().get*>("readoutwin"); LOG(INFO) << "RECEIVED READOUT WINDOWS " << row->size(); @@ -100,8 +107,8 @@ DataProcessorSpec getTOFDigitWriterSpec(bool useMC) labelbr->Fill(); } - finished = true; - pc.services().get().readyToQuit(QuitRequest::Me); +// finished = true; +// pc.services().get().readyToQuit(QuitRequest::Me); }; // return the actual processing function as a lambda function using variables diff --git a/Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx b/Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx index 604a5e7e67edd..741efd94c5549 100644 --- a/Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx +++ b/Steer/DigitizerWorkflow/src/TOFDigitizerSpec.cxx @@ -144,34 +144,35 @@ DataProcessorSpec getTOFDigitizerSpec(int channel, bool useCCDB) // call actual digitization procedure labels->clear(); digits->clear(); - if (digitizer->process(&hits, digits.get())) { - // Post Data - if (digitizer->isContinuous()) { - digits->clear(); - labels->clear(); - digitizer->flushOutputContainer(*digits.get()); - } - - std::vector* digitsVector = digitizer->getDigitPerTimeFrame(); - std::vector* readoutwindow = digitizer->getReadoutWindowData(); - std::vector>* mcLabVecOfVec = digitizer->getMCTruthPerTimeFrame(); - - LOG(INFO) << "Post " << digitsVector->size() << " digits in " << readoutwindow->size() << " RO windows"; - - // here we have all digits and we can send them to consumer (aka snapshot it onto output) - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "DIGITS", 0, Lifetime::Timeframe}, *digitsVector); - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "DIGITSMCTR", 0, Lifetime::Timeframe}, *mcLabVecOfVec); - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "READOUTWINDOW", 0, Lifetime::Timeframe}, *readoutwindow); - LOG(INFO) << "TOF: Sending ROMode= " << roMode << " to GRPUpdater"; - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "ROMode", 0, Lifetime::Timeframe}, roMode); - - // go to new TF - digitizer->newTF(); - - digitizer->setEventTime(timesview[collID].timeNS); - - digitizer->process(&hits, digits.get()); - } + digitizer->process(&hits, digits.get()); + // if (digitizer->process(&hits, digits.get())) { + // // Post Data + // if (digitizer->isContinuous()) { + // digits->clear(); + // labels->clear(); + // digitizer->flushOutputContainer(*digits.get()); + // } + + // std::vector* digitsVector = digitizer->getDigitPerTimeFrame(); + // std::vector* readoutwindow = digitizer->getReadoutWindowData(); + // std::vector>* mcLabVecOfVec = digitizer->getMCTruthPerTimeFrame(); + + // LOG(INFO) << "Post " << digitsVector->size() << " digits in " << readoutwindow->size() << " RO windows"; + + // // here we have all digits and we can send them to consumer (aka snapshot it onto output) + // pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "DIGITS", 0, Lifetime::Timeframe}, *digitsVector); + // pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "DIGITSMCTR", 0, Lifetime::Timeframe}, *mcLabVecOfVec); + // pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "READOUTWINDOW", 0, Lifetime::Timeframe}, *readoutwindow); + // LOG(INFO) << "TOF: Sending ROMode= " << roMode << " to GRPUpdater"; + // pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "ROMode", 0, Lifetime::Timeframe}, roMode); + + // // go to new TF + // digitizer->newTF(); + + // digitizer->setEventTime(timesview[collID].timeNS); + + // digitizer->process(&hits, digits.get()); + // } // copy digits into accumulator //std::copy(digits->begin(), digits->end(), std::back_inserter(*digitsAccum.get())); //labelAccum.mergeAtBack(*labels); @@ -201,7 +202,8 @@ DataProcessorSpec getTOFDigitizerSpec(int channel, bool useCCDB) LOG(INFO) << "Digitization took " << timer.CpuTime() << "s"; // we should be only called once; tell DPL that this process is ready to exit - pc.services().get().readyToQuit(QuitRequest::Me); + pc.services().get().endOfStream(); + //pc.services().get().readyToQuit(QuitRequest::Me); finished = true; };