diff --git a/Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/CheckResidSpec.h b/Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/CheckResidSpec.h index fceba6cb000fd..3cae8e94b8e68 100644 --- a/Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/CheckResidSpec.h +++ b/Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/CheckResidSpec.h @@ -19,7 +19,7 @@ namespace o2::checkresid { /// create a processor spec -o2::framework::DataProcessorSpec getCheckResidSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool drawOnly); +o2::framework::DataProcessorSpec getCheckResidSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool drawOnly, bool postProcOnly); } // namespace o2::checkresid diff --git a/Detectors/GlobalTrackingWorkflow/study/src/CheckResidSpec.cxx b/Detectors/GlobalTrackingWorkflow/study/src/CheckResidSpec.cxx index ff73be857346f..01ec999fce1eb 100644 --- a/Detectors/GlobalTrackingWorkflow/study/src/CheckResidSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/study/src/CheckResidSpec.cxx @@ -75,8 +75,8 @@ using timeEst = o2::dataformats::TimeStampWithError; class CheckResidSpec : public Task { public: - CheckResidSpec(std::shared_ptr dr, std::shared_ptr gr, GTrackID::mask_t src, bool drawOnly) - : mDataRequest(dr), mGGCCDBRequest(gr), mTracksSrc(src), mDrawOnly(drawOnly) + CheckResidSpec(std::shared_ptr dr, std::shared_ptr gr, GTrackID::mask_t src, bool drawOnly, bool postProcOnly) + : mDataRequest(dr), mGGCCDBRequest(gr), mTracksSrc(src), mDrawOnly(drawOnly), mPostProcOnly(postProcOnly) { } ~CheckResidSpec() final = default; @@ -110,6 +110,7 @@ class CheckResidSpec : public Task GTrackID::mask_t mTracksSrc{}; bool mDrawOnly = false; + bool mPostProcOnly = false; bool mDraw = false; bool mFillHistos = true; bool mFillTree = true; @@ -179,8 +180,17 @@ void CheckResidSpec::init(InitContext& ic) void CheckResidSpec::run(ProcessingContext& pc) { + bool quit = false; + if (mPostProcOnly) { + + postProcessHistos(); + quit = true; + } if (mDrawOnly) { drawHistos(); + quit = true; + } + if (quit) { pc.services().get().endOfStream(); pc.services().get().readyToQuit(QuitRequest::Me); return; @@ -689,43 +699,53 @@ void CheckResidSpec::bookHistos() void CheckResidSpec::postProcessHistos() { printf("Fitting histos\n"); + if (!mHMan) { + if (mHManV.empty()) { + LOGP(warn, "nothing to process"); + return; + } + mHMan = mHManV[0].get(); + } const auto& params = o2::checkresid::CheckResidConfig::Instance(); auto gs = new TF1("gs", "gaus", -1, 1); + int maxH = mPostProcOnly ? mHManV.size() : 1; TObjArray arr; - auto* histm = mHMan; - auto fitSlices = [&](int id) { - auto h2 = histm->getHisto2F(id); - if (!h2 || h2->GetEntries() < params.minHistoStat2Fit) { - return; - } - h2->FitSlicesY(gs, 0, -1, 0, "QNR", &arr); - arr.SetOwner(true); - TH1* hmean = (TH1*)arr.RemoveAt(1); - if (hmean) { - hmean->SetTitle(Form("<%s>", h2->GetTitle())); - histm->addHisto(hmean, id + 1); - } - TH1* hsig = (TH1*)arr.RemoveAt(2); - if (hsig) { - hsig->SetTitle(Form("#sigma(%s)", h2->GetTitle())); - histm->addHisto(hsig, id + 2); - } - }; - for (int ioffs = 0; ioffs <= 3; ioffs++) { // vs phi, Z, pT, tgl - int offs = ioffs * 1000; - for (int iht = 0; iht < 2; iht++) { // resid, pull - int offsV = iht == 0 ? 0 : 5; - for (int il = 0; il < 8; il++) { - for (int iyz = 0; iyz < 2; iyz++) { - fitSlices(il * 10 + iyz * 100 + offsV + offs); - } + for (int ihm = 0; ihm < maxH; ihm++) { + auto* histm = mHManV[ihm].get(); + auto fitSlices = [&](int id) { + auto h2 = histm->getHisto2F(id); + if (!h2 || h2->GetEntries() < params.minHistoStat2Fit) { + return; + } + h2->FitSlicesY(gs, 0, -1, 0, "QNR", &arr); + arr.SetOwner(true); + TH1* hmean = (TH1*)arr.RemoveAt(1); + if (hmean) { + hmean->SetTitle(Form("<%s>", h2->GetTitle())); + histm->addHisto(hmean, id + 1); + } + TH1* hsig = (TH1*)arr.RemoveAt(2); + if (hsig) { + hsig->SetTitle(Form("#sigma(%s)", h2->GetTitle())); + histm->addHisto(hsig, id + 2); } - for (int ip = 0; ip < 5; ip++) { - fitSlices(10000 + ip * 10 + offsV + offs); + }; + for (int ioffs = 0; ioffs <= 3; ioffs++) { // vs phi, Z, pT, tgl + int offs = ioffs * 1000; + for (int iht = 0; iht < 2; iht++) { // resid, pull + int offsV = iht == 0 ? 0 : 5; + for (int il = 0; il < 8; il++) { + for (int iyz = 0; iyz < 2; iyz++) { + fitSlices(il * 10 + iyz * 100 + offsV + offs); + } + } + for (int ip = 0; ip < 5; ip++) { + fitSlices(10000 + ip * 10 + offsV + offs); + } } } + histm->write(); } - histm->write(); delete gs; } @@ -922,11 +942,11 @@ void CheckResidSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) } } -DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool drawOnly) +DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool drawOnly, bool postProcOnly) { std::vector outputs; auto dataRequest = std::make_shared(); - if (!drawOnly) { + if (!drawOnly && !postProcOnly) { bool useMC = false; dataRequest->requestTracks(srcTracks, useMC); dataRequest->requestClusters(srcClusters, useMC); @@ -954,7 +974,7 @@ DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t "check-resid", dataRequest->inputs, outputs, - AlgorithmSpec{adaptFromTask(dataRequest, ggRequest, srcTracks, drawOnly)}, + AlgorithmSpec{adaptFromTask(dataRequest, ggRequest, srcTracks, drawOnly, postProcOnly)}, opts}; } diff --git a/Detectors/GlobalTrackingWorkflow/study/src/check-resid-workflow.cxx b/Detectors/GlobalTrackingWorkflow/study/src/check-resid-workflow.cxx index 72188eb5f06c6..0791d72474ad3 100644 --- a/Detectors/GlobalTrackingWorkflow/study/src/check-resid-workflow.cxx +++ b/Detectors/GlobalTrackingWorkflow/study/src/check-resid-workflow.cxx @@ -38,6 +38,7 @@ void customize(std::vector& workflowOptions) // option allowing to set parameters std::vector options{ {"draw-external-only", VariantType::Bool, false, {"just draw content of comma-separated list of histomanagers from checkresid.ext_hm_list"}}, + {"postproc-external-only", VariantType::Bool, false, {"just post-process raw content of comma-separated list of histomanagers from checkresid.ext_hm_list"}}, {"track-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of track sources to use"}}, {"cluster-sources", VariantType::String, "ITS", {"comma-separated list of cluster sources to use"}}, {"disable-root-input", VariantType::Bool, false, {"disable root-files input reader"}}, @@ -57,7 +58,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) WorkflowSpec specs; bool drawOnly = configcontext.options().get("draw-external-only"); - + bool postProcOnly = configcontext.options().get("postproc-external-only"); GID::mask_t allowedSourcesTrc = GID::getSourcesMask("ITS,TPC,ITS-TPC,ITS-TPC-TRD,ITS-TPC-TOF,ITS-TPC-TRD-TOF"); GID::mask_t allowedSourcesClus = GID::getSourcesMask("ITS"); @@ -74,7 +75,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) allowedSourcesTrc = {}; allowedSourcesClus = {}; } - specs.emplace_back(o2::checkresid::getCheckResidSpec(srcTrc, srcCls, drawOnly)); + specs.emplace_back(o2::checkresid::getCheckResidSpec(srcTrc, srcCls, drawOnly, postProcOnly)); // configure dpl timer to inject correct firstTForbit: start from the 1st orbit of TF containing 1st sampled orbit if (!drawOnly) {