From 45ba3a518e5ef20ba1e38bd13e2f057de8d31aa3 Mon Sep 17 00:00:00 2001 From: Dmitri Peresunko Date: Thu, 11 Mar 2021 18:03:01 +0300 Subject: [PATCH] MCLabels in clusters; Fix to read full raw payload --- .../PHOS/include/DataFormatsPHOS/Cluster.h | 6 +- .../PHOS/reconstruction/src/AltroDecoder.cxx | 7 +- .../PHOS/reconstruction/src/Clusterer.cxx | 14 +- Detectors/PHOS/workflow/CMakeLists.txt | 1 - .../include/PHOSWorkflow/PublisherSpec.h | 46 ----- .../PHOS/workflow/src/ClusterizerSpec.cxx | 6 - Detectors/PHOS/workflow/src/PublisherSpec.cxx | 179 ------------------ Detectors/PHOS/workflow/src/RecoWorkflow.cxx | 4 +- 8 files changed, 9 insertions(+), 254 deletions(-) delete mode 100644 Detectors/PHOS/workflow/include/PHOSWorkflow/PublisherSpec.h delete mode 100644 Detectors/PHOS/workflow/src/PublisherSpec.cxx diff --git a/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cluster.h b/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cluster.h index 34cb5d2391c1b..6cab0d2f4719e 100644 --- a/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cluster.h +++ b/DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cluster.h @@ -64,14 +64,10 @@ class Cluster float getTime() const { return mTime; } - int getLabel() const { return mLabel; } //Index in MCContainer entry - void setLabel(int l) { mLabel = l; } - protected: char mMulDigit = 0; ///< Digit nultiplicity char mModule = 0; ///< Module number char mNExMax = -1; ///< number of (Ex-)maxima before unfolding - int mLabel = -1; ///< Ref to entry in MCTruthContainer with list of labels float mLocalPosX = 0.; ///< Center of gravity position in local module coordunates (phi direction) float mLocalPosZ = 0.; ///< Center of gravity position in local module coordunates (z direction) float mFullEnergy = 0.; ///< full energy of a shower @@ -82,7 +78,7 @@ class Cluster float mTime = 0.; ///< Time of the digit with maximal energy deposition float mDistToBadChannel = 999; ///< Distance to nearest bad crystal - ClassDefNV(Cluster, 1); + ClassDefNV(Cluster, 2); }; } // namespace phos } // namespace o2 diff --git a/Detectors/PHOS/reconstruction/src/AltroDecoder.cxx b/Detectors/PHOS/reconstruction/src/AltroDecoder.cxx index 5547ececcd2f0..c3bb280da368b 100644 --- a/Detectors/PHOS/reconstruction/src/AltroDecoder.cxx +++ b/Detectors/PHOS/reconstruction/src/AltroDecoder.cxx @@ -66,13 +66,14 @@ void AltroDecoder::readChannels() int currentpos = 0; auto& buffer = mRawReader.getPayload().getPayloadWords(); - int payloadend = mRCUTrailer.getPayloadSize(); + int payloadend = buffer.size() - mRCUTrailer.getTrailerSize(); //mRCUTrailer.getPayloadSize() was not updated in case of merged pages. while (currentpos < payloadend) { auto currentword = buffer[currentpos++]; ChannelHeader header = {currentword}; - if (header.mMark != 1) { - LOG(ERROR) << "Channel header mark not found"; + if (currentword != 0) { + LOG(ERROR) << "Channel header mark not found, header word " << currentword; + } continue; } // starting a new channel diff --git a/Detectors/PHOS/reconstruction/src/Clusterer.cxx b/Detectors/PHOS/reconstruction/src/Clusterer.cxx index b91f7fe6db6d5..24458b3fc359e 100644 --- a/Detectors/PHOS/reconstruction/src/Clusterer.cxx +++ b/Detectors/PHOS/reconstruction/src/Clusterer.cxx @@ -44,6 +44,7 @@ void Clusterer::process(gsl::span digits, gsl::spanclear(); //final out list of clusters trigRec->clear(); cluMC->clear(); + mProcessMC = (dmc != nullptr); for (const auto& tr : dtr) { mFirstDigitInEvent = tr.getFirstEntry(); @@ -104,9 +105,7 @@ void Clusterer::processCells(gsl::span cells, gsl::spanclear(); mProcessMC = (dmc != nullptr); miCellLabel = 0; - printf("start clustering \n"); for (const auto& tr : ctr) { - printf(" tf=%d, %d \n", tr.getFirstEntry(), tr.getNumberOfObjects()); int firstCellInEvent = tr.getFirstEntry(); int lastCellInEvent = firstCellInEvent + tr.getNumberOfObjects(); int indexStart = clusters->size(); @@ -116,10 +115,8 @@ void Clusterer::processCells(gsl::span cells, gsl::span cells, gsl::spansize(); @@ -440,7 +432,6 @@ void Clusterer::evalCluProperties(gsl::span digits, std::vectorgetEnergy() < 1.e-4) { //Marked earlier for removal ++clu; continue; @@ -498,7 +489,6 @@ void Clusterer::evalCluProperties(gsl::span digits, std::vectorback().setLabel(labelIndex); labelIndex++; } // Work with MC } diff --git a/Detectors/PHOS/workflow/CMakeLists.txt b/Detectors/PHOS/workflow/CMakeLists.txt index 43ac0c51cf17d..531935fae0c06 100644 --- a/Detectors/PHOS/workflow/CMakeLists.txt +++ b/Detectors/PHOS/workflow/CMakeLists.txt @@ -10,7 +10,6 @@ o2_add_library(PHOSWorkflow SOURCES src/RecoWorkflow.cxx - src/PublisherSpec.cxx src/ReaderSpec.cxx src/CellConverterSpec.cxx src/RawToCellConverterSpec.cxx diff --git a/Detectors/PHOS/workflow/include/PHOSWorkflow/PublisherSpec.h b/Detectors/PHOS/workflow/include/PHOSWorkflow/PublisherSpec.h deleted file mode 100644 index f79d38432cfeb..0000000000000 --- a/Detectors/PHOS/workflow/include/PHOSWorkflow/PublisherSpec.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". -// -// See http://alice-o2.web.cern.ch/license for full licensing information. -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#include "Framework/DataProcessorSpec.h" -#include "Framework/OutputSpec.h" -#include -#include - -namespace o2 -{ - -namespace phos -{ - -using OutputSpec = framework::OutputSpec; - -struct PublisherConf { - struct BranchOptionConfig { - std::string option; - std::string defval; - std::string help; - }; - - std::string processName; - std::string defaultTreeName; - BranchOptionConfig databranch; - BranchOptionConfig datatrbranch; - BranchOptionConfig mcbranch; - BranchOptionConfig mcmapbranch; - OutputSpec dataoutput; - OutputSpec datatroutput; - OutputSpec mcoutput; - OutputSpec mcmapoutput; -}; - -framework::DataProcessorSpec getPublisherSpec(PublisherConf const& config, bool propagateMC = true, bool createMCMap = false); - -} // namespace phos -} // end namespace o2 diff --git a/Detectors/PHOS/workflow/src/ClusterizerSpec.cxx b/Detectors/PHOS/workflow/src/ClusterizerSpec.cxx index 77f5c87f0f465..de4e715c42b82 100644 --- a/Detectors/PHOS/workflow/src/ClusterizerSpec.cxx +++ b/Detectors/PHOS/workflow/src/ClusterizerSpec.cxx @@ -53,21 +53,16 @@ void ClusterizerSpec::run(framework::ProcessingContext& ctx) LOG(DEBUG) << "PHOSClusterizer - run run on cells called"; - printf("Getting cells \n"); auto cells = ctx.inputs().get>("cells"); // auto cells = ctx.inputs().get>("cells"); LOG(DEBUG) << "[PHOSClusterizer - run] Received " << cells.size() << " cells, running clusterizer ..."; - printf("Getting TR \n"); // auto cellsTR = ctx.inputs().get>("cellTriggerRecords"); auto cellsTR = ctx.inputs().get>("cellTriggerRecords"); if (mPropagateMC) { - printf("Getting MC \n"); std::unique_ptr> truthcont(ctx.inputs().get*>("cellsmctr")); // truthmap = ctx.inputs().get>("cellssmcmap"); - printf("Clustering \n"); mClusterizer.processCells(cells, cellsTR, truthcont.get(), &mOutputClusters, &mOutputClusterTrigRecs, &mOutputTruthCont); // Find clusters on digits (pass by ref) } else { - printf("Clustering2 \n"); mClusterizer.processCells(cells, cellsTR, nullptr, &mOutputClusters, &mOutputClusterTrigRecs, &mOutputTruthCont); // Find clusters on digits (pass by ref) } } @@ -82,7 +77,6 @@ void ClusterizerSpec::run(framework::ProcessingContext& ctx) if (mPropagateMC) { ctx.outputs().snapshot(o2::framework::Output{"PHS", "CLUSTERTRUEMC", 0, o2::framework::Lifetime::Timeframe}, mOutputTruthCont); } - LOG(INFO) << "Finished "; ctx.services().get().readyToQuit(framework::QuitRequest::Me); } diff --git a/Detectors/PHOS/workflow/src/PublisherSpec.cxx b/Detectors/PHOS/workflow/src/PublisherSpec.cxx deleted file mode 100644 index a170eb8aa73fd..0000000000000 --- a/Detectors/PHOS/workflow/src/PublisherSpec.cxx +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". -// -// See http://alice-o2.web.cern.ch/license for full licensing information. -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#include "DataFormatsPHOS/PHOSBlockHeader.h" -#include "PHOSWorkflow/PublisherSpec.h" -#include "Framework/ConfigParamRegistry.h" -#include "Framework/ControlService.h" -#include "Headers/DataHeader.h" -#include "DPLUtils/RootTreeReader.h" -#include "Framework/DataSpecUtils.h" -#include -#include - -namespace o2 -{ - -namespace phos -{ - -o2::framework::DataProcessorSpec getPublisherSpec(PublisherConf const& config, bool propagateMC, bool createMCMap) -{ - struct ProcessAttributes { - std::shared_ptr reader; - std::string datatype; - bool terminateOnEod; - bool finished; - }; - - auto initFunction = [config, propagateMC, createMCMap](o2::framework::InitContext& ic) { - // get the option from the init context - auto filename = ic.options().get("infile"); - auto treename = ic.options().get("treename"); - auto dtbrName = ic.options().get(config.databranch.option.c_str()); // databranch name - auto dttrbrName = ic.options().get(config.datatrbranch.option.c_str()); // datatrigrec name - auto mcbrName = ic.options().get(config.mcbranch.option.c_str()); // mcbranch name - auto mcmapbrName = ic.options().get(config.mcmapbranch.option.c_str()); // mc map branch name - auto nofEvents = ic.options().get("nevents"); - // auto publishingMode = nofEvents == -1 ? o2::framework::RootTreeReader::PublishingMode::Single : o2::framework::RootTreeReader::PublishingMode::Loop; - auto publishingMode = o2::framework::RootTreeReader::PublishingMode::Single; - - auto processAttributes = std::make_shared(); - { - processAttributes->terminateOnEod = ic.options().get("terminate-on-eod"); - processAttributes->finished = false; - processAttributes->datatype = config.databranch.defval; - auto dto = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.dataoutput); - auto dttro = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.datatroutput); - auto mco = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.mcoutput); - auto mcmapo = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.mcmapoutput); - constexpr auto persistency = o2::framework::Lifetime::Timeframe; - o2::header::DataHeader::SubSpecificationType subSpec = 0; - if (propagateMC) { - if (!createMCMap) { - processAttributes->reader = std::make_shared(treename.c_str(), // tree name - filename.c_str(), // input file name - nofEvents, // number of entries to publish - publishingMode, - o2::framework::Output{dto.origin, dto.description, subSpec, persistency}, - dtbrName.c_str(), // name of data branch - o2::framework::Output{dttro.origin, dttro.description, subSpec, persistency}, - dttrbrName.c_str(), // name of data triggerrecords branch - o2::framework::Output{mco.origin, mco.description, subSpec, persistency}, - mcbrName.c_str() // name of mc label branch - ); - } else { - processAttributes->reader = std::make_shared(treename.c_str(), // tree name - filename.c_str(), // input file name - nofEvents, // number of entries to publish - publishingMode, - o2::framework::Output{dto.origin, dto.description, subSpec, persistency}, - dtbrName.c_str(), // name of data branch - o2::framework::Output{dttro.origin, dttro.description, subSpec, persistency}, - dttrbrName.c_str(), // name of data triggerrecords branch - o2::framework::Output{mco.origin, mco.description, subSpec, persistency}, - mcbrName.c_str(), // name of mc label branch - o2::framework::Output{mcmapo.origin, mcmapo.description, subSpec, persistency}, - mcmapbrName.c_str() // name of mc label branch - ); - } - } else { - processAttributes->reader = std::make_shared(treename.c_str(), // tree name - filename.c_str(), // input file name - nofEvents, // number of entries to publish - publishingMode, - o2::framework::Output{dto.origin, dto.description, subSpec, persistency}, - dtbrName.c_str(), // name of data branch - o2::framework::Output{dttro.origin, dttro.description, subSpec, persistency}, - dttrbrName.c_str() // name of data tr branch - ); - } - } - - auto processFunction = [processAttributes, propagateMC, createMCMap](o2::framework::ProcessingContext& pc) { - if (processAttributes->finished) { - return; - } - - auto publish = [&processAttributes, &pc, propagateMC, createMCMap]() { - o2::phos::PHOSBlockHeader phosheader(true); - if (processAttributes->reader->next()) { - (*processAttributes->reader)(pc, phosheader); - } else { - processAttributes->reader.reset(); - return false; - } - return true; - }; - - bool active(true); - if (!publish()) { - active = false; - // Send dummy header with no payload option - o2::phos::PHOSBlockHeader dummyheader(false); - pc.outputs().snapshot(o2::framework::OutputRef{"output", 0, {dummyheader}}, 0); - pc.outputs().snapshot(o2::framework::OutputRef{"outputTR", 0, {dummyheader}}, 0); - if (propagateMC) { - pc.outputs().snapshot(o2::framework::OutputRef{"outputMC", 0, {dummyheader}}, 0); - if (createMCMap) { - pc.outputs().snapshot(o2::framework::OutputRef{"outputMCmap", 0, {dummyheader}}, 0); - } - } - } - if ((processAttributes->finished = (active == false)) && processAttributes->terminateOnEod) { - pc.services().get().endOfStream(); - pc.services().get().readyToQuit(framework::QuitRequest::Me); - } - }; - - return processFunction; - }; - - auto createOutputSpecs = [&config, propagateMC, createMCMap]() { - std::vector outputSpecs; - auto dto = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.dataoutput); - auto dttro = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.datatroutput); - auto mco = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.mcoutput); - auto mcmapo = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.mcmapoutput); - outputSpecs.emplace_back(o2::framework::OutputSpec{{"output"}, dto.origin, dto.description, 0, o2::framework::Lifetime::Timeframe}); - outputSpecs.emplace_back(o2::framework::OutputSpec{{"outputTR"}, dttro.origin, dttro.description, 0, o2::framework::Lifetime::Timeframe}); - if (propagateMC) { - outputSpecs.emplace_back(o2::framework::OutputSpec{{"outputMC"}, mco.origin, mco.description, 0, o2::framework::Lifetime::Timeframe}); - if (createMCMap) { - outputSpecs.emplace_back(o2::framework::OutputSpec{{"outputMCmap"}, mcmapo.origin, mcmapo.description, 0, o2::framework::Lifetime::Timeframe}); - } - } - return std::move(outputSpecs); - }; - - auto& dtb = config.databranch; - auto& dttrb = config.datatrbranch; - auto& mcb = config.mcbranch; - auto& mcmapb = config.mcmapbranch; - return o2::framework::DataProcessorSpec{ - config.processName.c_str(), - o2::framework::Inputs{}, // no inputs - {createOutputSpecs()}, - o2::framework::AlgorithmSpec(initFunction), - o2::framework::Options{ - {"infile", o2::framework::VariantType::String, "phosdigits.root", {"Name of the input file"}}, - {"treename", o2::framework::VariantType::String, config.defaultTreeName.c_str(), {"Name of input tree"}}, - {dtb.option.c_str(), o2::framework::VariantType::String, dtb.defval.c_str(), {dtb.help.c_str()}}, - {dttrb.option.c_str(), o2::framework::VariantType::String, dttrb.defval.c_str(), {dttrb.help.c_str()}}, - {mcb.option.c_str(), o2::framework::VariantType::String, mcb.defval.c_str(), {mcb.help.c_str()}}, - {mcmapb.option.c_str(), o2::framework::VariantType::String, mcmapb.defval.c_str(), {mcmapb.help.c_str()}}, - {"nevents", o2::framework::VariantType::Int, -1, {"number of events to run"}}, - {"terminate-on-eod", o2::framework::VariantType::Bool, true, {"terminate on end-of-data"}}, - }}; -} - -} // namespace phos - -} // namespace o2 diff --git a/Detectors/PHOS/workflow/src/RecoWorkflow.cxx b/Detectors/PHOS/workflow/src/RecoWorkflow.cxx index 5bd0359bbd0e6..a970a6c3d4c16 100644 --- a/Detectors/PHOS/workflow/src/RecoWorkflow.cxx +++ b/Detectors/PHOS/workflow/src/RecoWorkflow.cxx @@ -89,9 +89,9 @@ o2::framework::WorkflowSpec getWorkflow(bool disableRootInp, } if (isEnabled(OutputType::Clusters)) { specs.emplace_back(o2::phos::reco_workflow::getRawToCellConverterSpec()); - specs.emplace_back(o2::phos::reco_workflow::getClusterizerSpec(false)); //no MC propagation + specs.emplace_back(o2::phos::reco_workflow::getCellClusterizerSpec(false)); //no MC propagation if (!disableRootOut) { - specs.emplace_back(o2::phos::getClusterWriterSpec(propagateMC)); + specs.emplace_back(o2::phos::getClusterWriterSpec(false)); } } }