From bdf2b49f498458a29af2553c0347c80d5bdb707c Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Mon, 11 Dec 2023 14:40:25 +0100 Subject: [PATCH 1/6] first steps --- docs/core/reconstruction/track_fitting.md | 82 ++++++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/docs/core/reconstruction/track_fitting.md b/docs/core/reconstruction/track_fitting.md index 659ae7d87f1..afbe2f7e0ab 100644 --- a/docs/core/reconstruction/track_fitting.md +++ b/docs/core/reconstruction/track_fitting.md @@ -126,10 +126,88 @@ The {class}`Acts::AtlasBetheHeitlerApprox` is constructed with two parameterizat * *R Frühwirth*, A Gaussian-mixture approximation of the Bethe–Heitler model of electron energy loss by bremsstrahlung, 2003, see [here](https://doi.org/10.1016/S0010-4655(03)00292-3) (gx2f_core)= -## Global Chi-Square Fitter (GX2F) [wip] +## Global Chi-Square Fitter (GX2F) +In general the GX2F is a weighted least squares fit, minimising the $\chi^2$ +$$ +\chi^2 = \sum_i \frac{r_i^2}{\sigma_i^2} +$$ +of a track. +Here, $r_i$ are our residuals that we weight with $\sigma_i^2$, the covariance of the measurement (a detector property). +Unlike the KF and the GSF, the GX2F looks at all measurements at the same time and iteratively minimises the starting parameters. + +With the GX2F we can obtain the final parameters $\vec\alpha_n$ from starting parameters $\vec\alpha_0$. +We set the $\chi^2 = \chi^2(\vec\alpha)$ as a function of the track parameters, but the $\chi^2$-minimisation could be used for many other problems. +Even in the context of track fitting, we are quite free on how to use the GX2F. +Especially the residuals $r_i$ can have many interpretations. +Most of the time we will see them as the distance between a measurement and our prediction. +But we can also use scattering angles, energy loss, ... as residuals. + +This chapter on the GX2F guides through: +- Mathematical description of the base algorithm +- Mathematical description of the multiple scattering [wip] +- (coming soon) Mathematical description of the energy loss +- Implementation in ACTS[wip] +- Pros/Cons [wip] + +### Mathematical description of the algorithm + +To begin with, there will be a short overview on the algorithm. +Later in this section, each step is described in more detail. +1. Minimise the $\chi^2$ function +2. Update the initial parameters (iteratively) +3. Calculate the covariance for the final parameters + +#### 1. Minimise the $\chi^2$ function + +We expect the minimum of the $\chi^2$ function at +$$ +\frac{\partial\chi^2(\vec\alpha)}{\partial\vec\alpha} = 0. +$$ +To find the zero(s) of this function we could use any method but we will stick to a modified [Newton-Raphson method](https://en.wikipedia.org/wiki/Newton%27s_method), +since it requires just another derivative of the $\chi^2$ function. + +TODO: + + +#### 2. Update the initial parameters (iteratively) + +Since we are using the Newton-Raphson method to find the minimum of the $\chi^2$ function, we need to iterate. + + +#### 3. Calculate the covariance for the final parameters + +The calculation of the covariance of the final parameters is quite simple compared to the steps before: +$$ +cov_{\vec\alpha} = [a_{kl}]^{-1} +$$ +Since it only depends on the $[a_{kl}]$ of the last iteration, the GX2F does not need an initial estimate for the covariance. + + +### Mathematical description of the multiple scattering [wip] + +:::{todo} +Write GX2F: Mathematical description of the multiple scattering +::: + +### (coming soon) Mathematical description of the energy loss [wip] + +:::{todo} +Write GX2F: Mathematical description of the energy loss + +The development work on the energy loss has not finished yet. +::: + + +### Implementation in ACTS [wip] + +:::{todo} +Write GX2F: Implementation in ACTS +::: + +### Pros/Cons [wip] :::{todo} -Write GX2F documentation +Write GX2F: Pros/Cons ::: [^billoir]: https://twiki.cern.ch/twiki/pub/LHCb/ParametrizedKalman/paramKalmanV01.pdf From 1dee56a599786720cdc94703fc21d4ce02b8b7cf Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Mon, 11 Dec 2023 14:42:12 +0100 Subject: [PATCH 2/6] Revert "first steps" This reverts commit bdf2b49f498458a29af2553c0347c80d5bdb707c. --- docs/core/reconstruction/track_fitting.md | 82 +---------------------- 1 file changed, 2 insertions(+), 80 deletions(-) diff --git a/docs/core/reconstruction/track_fitting.md b/docs/core/reconstruction/track_fitting.md index afbe2f7e0ab..659ae7d87f1 100644 --- a/docs/core/reconstruction/track_fitting.md +++ b/docs/core/reconstruction/track_fitting.md @@ -126,88 +126,10 @@ The {class}`Acts::AtlasBetheHeitlerApprox` is constructed with two parameterizat * *R Frühwirth*, A Gaussian-mixture approximation of the Bethe–Heitler model of electron energy loss by bremsstrahlung, 2003, see [here](https://doi.org/10.1016/S0010-4655(03)00292-3) (gx2f_core)= -## Global Chi-Square Fitter (GX2F) +## Global Chi-Square Fitter (GX2F) [wip] -In general the GX2F is a weighted least squares fit, minimising the $\chi^2$ -$$ -\chi^2 = \sum_i \frac{r_i^2}{\sigma_i^2} -$$ -of a track. -Here, $r_i$ are our residuals that we weight with $\sigma_i^2$, the covariance of the measurement (a detector property). -Unlike the KF and the GSF, the GX2F looks at all measurements at the same time and iteratively minimises the starting parameters. - -With the GX2F we can obtain the final parameters $\vec\alpha_n$ from starting parameters $\vec\alpha_0$. -We set the $\chi^2 = \chi^2(\vec\alpha)$ as a function of the track parameters, but the $\chi^2$-minimisation could be used for many other problems. -Even in the context of track fitting, we are quite free on how to use the GX2F. -Especially the residuals $r_i$ can have many interpretations. -Most of the time we will see them as the distance between a measurement and our prediction. -But we can also use scattering angles, energy loss, ... as residuals. - -This chapter on the GX2F guides through: -- Mathematical description of the base algorithm -- Mathematical description of the multiple scattering [wip] -- (coming soon) Mathematical description of the energy loss -- Implementation in ACTS[wip] -- Pros/Cons [wip] - -### Mathematical description of the algorithm - -To begin with, there will be a short overview on the algorithm. -Later in this section, each step is described in more detail. -1. Minimise the $\chi^2$ function -2. Update the initial parameters (iteratively) -3. Calculate the covariance for the final parameters - -#### 1. Minimise the $\chi^2$ function - -We expect the minimum of the $\chi^2$ function at -$$ -\frac{\partial\chi^2(\vec\alpha)}{\partial\vec\alpha} = 0. -$$ -To find the zero(s) of this function we could use any method but we will stick to a modified [Newton-Raphson method](https://en.wikipedia.org/wiki/Newton%27s_method), -since it requires just another derivative of the $\chi^2$ function. - -TODO: - - -#### 2. Update the initial parameters (iteratively) - -Since we are using the Newton-Raphson method to find the minimum of the $\chi^2$ function, we need to iterate. - - -#### 3. Calculate the covariance for the final parameters - -The calculation of the covariance of the final parameters is quite simple compared to the steps before: -$$ -cov_{\vec\alpha} = [a_{kl}]^{-1} -$$ -Since it only depends on the $[a_{kl}]$ of the last iteration, the GX2F does not need an initial estimate for the covariance. - - -### Mathematical description of the multiple scattering [wip] - -:::{todo} -Write GX2F: Mathematical description of the multiple scattering -::: - -### (coming soon) Mathematical description of the energy loss [wip] - -:::{todo} -Write GX2F: Mathematical description of the energy loss - -The development work on the energy loss has not finished yet. -::: - - -### Implementation in ACTS [wip] - -:::{todo} -Write GX2F: Implementation in ACTS -::: - -### Pros/Cons [wip] :::{todo} -Write GX2F: Pros/Cons +Write GX2F documentation ::: [^billoir]: https://twiki.cern.ch/twiki/pub/LHCb/ParametrizedKalman/paramKalmanV01.pdf From 413523f5dce90de19ebff3160e35b9836c4d5b57 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:48:21 +0200 Subject: [PATCH 3/6] Update ConvertDD4hepDetector.cpp --- Plugins/DD4hep/src/ConvertDD4hepDetector.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp index 82d1a3cd4ec..7fbfd16a632 100644 --- a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp +++ b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp @@ -167,7 +167,7 @@ std::shared_ptr volumeBuilder_dd4hep( << subDetType << "], compound: " << (subDetector.type() == "compound" ? "yes" : "no")); if (subDetector.type() == "compound") { - ACTS_VERBOSE("Subdetector : '" << subDetector.name() + ACTS_VERBOSE("Subdetector: '" << subDetector.name() << "' has type compound "); ACTS_VERBOSE( "handling as a compound volume (a hierarchy of a " @@ -196,7 +196,7 @@ std::shared_ptr volumeBuilder_dd4hep( bool pEndCap = false; bool barrel = false; for (auto& volumeDetElement : compounds) { - ACTS_VERBOSE("Volume : '" + ACTS_VERBOSE("Volume: '" << subDetector.name() << "' is a compound volume -> resolve the sub volumes"); @@ -219,7 +219,7 @@ std::shared_ptr volumeBuilder_dd4hep( dd4hep::DetType type{volumeDetElement.typeFlag()}; if (type.is(dd4hep::DetType::ENDCAP)) { - ACTS_VERBOSE(std::string("Subvolume : '") + volumeDetElement.name() + + ACTS_VERBOSE(std::string("Subvolume: '") + volumeDetElement.name() + std::string("' is marked ENDCAP")); if (zPos < 0.) { if (nEndCap) { @@ -532,8 +532,8 @@ std::shared_ptr volumeBuilder_dd4hep( logger.clone(std::string("D2A_V:") + subDetector.name())); return cylinderVolumeBuilder; } else { - ACTS_INFO( - "Subdetector with name : '" + ACTS_WARNING( + "Subdetector with name: '" << subDetector.name() << "' has inconsistent information for translation and is not of type " "'compound'. If you want to have this DetElement be translated " From bd1688e4a22b1608218ee83a0e6eba5b3fb22abd Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Wed, 10 Apr 2024 10:07:20 +0200 Subject: [PATCH 4/6] format --- Plugins/DD4hep/src/ConvertDD4hepDetector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp index 8a1fb03b29d..cc5288e005e 100644 --- a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp +++ b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp @@ -168,7 +168,7 @@ std::shared_ptr volumeBuilder_dd4hep( if (subDetector.type() == "compound") { ACTS_VERBOSE("Subdetector: '" << subDetector.name() - << "' has type compound "); + << "' has type compound "); ACTS_VERBOSE( "handling as a compound volume (a hierarchy of a " "barrel-endcap structure) and resolving the " From 3d1c4262334c1e9d30220c7c28f3ea83cc2b4196 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Wed, 10 Apr 2024 10:55:51 +0200 Subject: [PATCH 5/6] fix other ' : ' --- Plugins/DD4hep/src/ConvertDD4hepDetector.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp index cc5288e005e..8d9e23486c1 100644 --- a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp +++ b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp @@ -293,8 +293,8 @@ std::shared_ptr volumeBuilder_dd4hep( "hierarchy."); } barrel = true; - ACTS_VERBOSE("Subvolume : " << volumeDetElement.name() - << " is marked as BARREL"); + ACTS_VERBOSE("Subvolume: " << volumeDetElement.name() + << " is marked as BARREL"); ACTS_VERBOSE("-> collecting layers"); collectLayers_dd4hep(volumeDetElement, centralLayers, logger); // Fill the volume material for barrel case @@ -391,8 +391,8 @@ std::shared_ptr volumeBuilder_dd4hep( return cylinderVolumeBuilder; } else if (subDetType.is(dd4hep::DetType::BEAMPIPE) || getParamOr("passive_layer", subDetector, false)) { - ACTS_VERBOSE("Subdetector : " << subDetector.name() - << " - building a passive cylinder."); + ACTS_VERBOSE("Subdetector: " << subDetector.name() + << " - building a passive cylinder."); if (subDetType.is(dd4hep::DetType::BEAMPIPE)) { ACTS_VERBOSE("This is the beam pipe - will be built to r -> 0."); From 13b3101345aed4b81d195a128b35233ffc3fc6b7 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Wed, 10 Apr 2024 10:59:33 +0200 Subject: [PATCH 6/6] remove std::string from logger --- Plugins/DD4hep/src/ConvertDD4hepDetector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp index 8d9e23486c1..ed783e8f8ef 100644 --- a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp +++ b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp @@ -219,8 +219,8 @@ std::shared_ptr volumeBuilder_dd4hep( dd4hep::DetType type{volumeDetElement.typeFlag()}; if (type.is(dd4hep::DetType::ENDCAP)) { - ACTS_VERBOSE(std::string("Subvolume: '") + volumeDetElement.name() + - std::string("' is marked ENDCAP")); + ACTS_VERBOSE("Subvolume: '" << volumeDetElement.name() + << "' is marked ENDCAP"); if (zPos < 0.) { if (nEndCap) { throw std::logic_error(