From c17d7e3a97a61a0d04d5ecdcefa36df3daa4fa33 Mon Sep 17 00:00:00 2001 From: "se.gorbunov" <se.gorbunov@gsi.de> Date: Tue, 17 Oct 2023 14:26:45 +0000 Subject: [PATCH] Ca: bugfix in fit Qa --- algo/ca/core/pars/CaField.cxx | 1 + reco/KF/ParticleFitter/CbmL1PFFitter.cxx | 3 +++ reco/L1/CMakeLists.txt | 1 + reco/L1/CbmL1.cxx | 22 ++++------------ reco/L1/catools/CaToolsField.h | 33 ++++++++++++++++++++++++ reco/L1/qa/CbmCaTrackFitQa.cxx | 3 +++ 6 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 reco/L1/catools/CaToolsField.h diff --git a/algo/ca/core/pars/CaField.cxx b/algo/ca/core/pars/CaField.cxx index bb1f2051b1..f970e5fc26 100644 --- a/algo/ca/core/pars/CaField.cxx +++ b/algo/ca/core/pars/CaField.cxx @@ -20,6 +20,7 @@ using namespace cbm::algo::ca; bool FieldRegion::fgForceUseOfOriginalField = false; std::function<std::tuple<double, double, double>(double x, double y, double z)> FieldRegion::fgOdiginalField([](double, double, double) { + assert(false && "ca::FieldRegion: The original field is not set, use cbm::ca::tools::SetCbmField()"); return std::tuple(constants::Undef<double>, constants::Undef<double>, constants::Undef<double>); }); diff --git a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx index 50aad26d2f..1ace3e267e 100644 --- a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx +++ b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx @@ -36,6 +36,7 @@ #include "CaField.h" #include "CaStation.h" +#include "CaToolsField.h" #include "CaTrackFit.h" #include "CaTrackParam.h" #include "KFParticleDatabase.h" @@ -122,6 +123,8 @@ inline void CbmL1PFFitter::Initialize() if (fNmvdStationsActive > 0) { fMvdHitArray = static_cast<TClonesArray*>(manager->GetObject("MvdHit")); } if (fNstsStationsActive > 0) { fStsHitArray = static_cast<TClonesArray*>(manager->GetObject("StsHit")); } + cbm::ca::tools::SetOriginalCbmField(); + fIsInitialised = true; } diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt index edaf394a9c..d86fb29b54 100644 --- a/reco/L1/CMakeLists.txt +++ b/reco/L1/CMakeLists.txt @@ -97,6 +97,7 @@ set(HEADERS catools/CaToolsDef.h #utils/CbmCaIdealHitProducer.h catools/CaToolsMaterialHelper.h + catools/CaToolsField.h qa/CbmCaInputQaBase.h qa/CbmCaHitQaData.h ) diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 2bfe768487..79f9218e4f 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -64,8 +64,8 @@ #include <iostream> #include <list> -#include "CaField.h" #include "CaHit.h" +#include "CaToolsField.h" #include "L1Algo/L1Algo.h" using namespace cbm::algo; // TODO: remove this line @@ -178,6 +178,8 @@ InitStatus CbmL1::Init() cout << endl << endl; } + cbm::ca::tools::SetOriginalCbmField(); + fHistoDir = gROOT->mkdir("L1"); fHistoDir->mkdir("Input"); fHistoDir->mkdir("Fit"); @@ -255,7 +257,7 @@ InitStatus CbmL1::Init() fTimeSlice = (CbmTimeSlice*) fairManager->GetObject("TimeSlice."); if (!fTimeSlice) { LOG(fatal) << GetName() << ": No time slice branch in the tree!"; } - fpStsClusters = dynamic_cast<TClonesArray*>(fairManager->GetObject("StsCluster")); + fpStsClusters = dynamic_cast<TClonesArray*>(fairManager->GetObject("StsCluster")); fpStsHits = dynamic_cast<TClonesArray*>(fairManager->GetObject("StsHit")); @@ -312,7 +314,7 @@ InitStatus CbmL1::Init() } if (fUseSTS) { - fpStsPoints = mcManager->InitBranch("StsPoint"); + fpStsPoints = mcManager->InitBranch("StsPoint"); fpStsHitMatches = dynamic_cast<TClonesArray*>(fairManager->GetObject("StsHitMatch")); fpStsClusterMatches = dynamic_cast<TClonesArray*>(fairManager->GetObject("StsClusterMatch")); if (nullptr == fpStsPoints) LOG(fatal) << GetName() << ": No StsPoint data!"; @@ -659,20 +661,6 @@ InitStatus CbmL1::Init() fpAlgo->Init(fTrackingMode); - /// pass the original magnetic field to L1Algo - - { - static auto fld = [&](double x, double y, double z) { - assert(FairRunAna::Instance()); - double pos[3] = {x, y, z}; - double B[3] = {0., 0., 0.}; - if (FairRunAna::Instance()->GetField()) { FairRunAna::Instance()->GetField()->GetFieldValue(pos, B); } - return std::tuple(B[0], B[1], B[2]); - }; - ca::FieldRegion::SetOriginalField(fld); - } - - // // ** Send formed parameters object to L1Algo instance ** // diff --git a/reco/L1/catools/CaToolsField.h b/reco/L1/catools/CaToolsField.h new file mode 100644 index 0000000000..07d82f2e26 --- /dev/null +++ b/reco/L1/catools/CaToolsField.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov[committer] */ + +/// \file CaToolsField.h +/// \brief Tracking Field class (header) +/// \since 17.10.2023 +/// \author S.Gorbunov + +#pragma once // include this header only once per compilation unit + +#include "FairField.h" +#include "FairRunAna.h" + +#include "CaField.h" + +namespace cbm::ca::tools +{ + /// pass the original magnetic field to L1Algo + inline void SetOriginalCbmField() + { + static auto fld = [&](double x, double y, double z) { + assert(FairRunAna::Instance()); + assert(FairRunAna::Instance()->GetField()); + double pos[3] = {x, y, z}; + double B[3] = {0., 0., 0.}; + FairRunAna::Instance()->GetField()->GetFieldValue(pos, B); + return std::tuple(B[0], B[1], B[2]); + }; + ca::FieldRegion::SetOriginalField(fld); + } + +} // namespace cbm::ca::tools diff --git a/reco/L1/qa/CbmCaTrackFitQa.cxx b/reco/L1/qa/CbmCaTrackFitQa.cxx index ca7df7c883..7a8f8b3ee7 100644 --- a/reco/L1/qa/CbmCaTrackFitQa.cxx +++ b/reco/L1/qa/CbmCaTrackFitQa.cxx @@ -21,6 +21,7 @@ #include <algorithm> #include "CaField.h" +#include "CaToolsField.h" #include "CaToolsMCData.h" #include "CaTrackFit.h" #include "L1Utils.h" @@ -90,6 +91,8 @@ void TrackFitQa::Init() // Init default distribution properties SetDefaultProperties(); + cbm::ca::tools::SetOriginalCbmField(); + auto CreateResidualHisto = [&](ETrackParType t, const char* name, const char* title) { if (fvbParIgnored[t]) { return; } TString sPrefix = (fsTitle.Length() > 0) ? fsTitle + " point residual for " : "residual for "; -- GitLab