Skip to content

Calculate cluster direction from longitudinal samplings#193

Open
giovannimarchiori wants to merge 18 commits intoHEP-FCC:mainfrom
giovannimarchiori:gmarchio-main-clusterbary-20250618
Open

Calculate cluster direction from longitudinal samplings#193
giovannimarchiori wants to merge 18 commits intoHEP-FCC:mainfrom
giovannimarchiori:gmarchio-main-clusterbary-20250618

Conversation

@giovannimarchiori
Copy link
Contributor

@giovannimarchiori giovannimarchiori commented Nov 5, 2025

BEGINRELEASENOTES
Use longitudinal samplings of shower to refine cluster barycentre and calculate cluster direction

In addition, make cluster decoration tool work also for clusters in the turbine ecal endcap, so that clusters can be decorated with energy fractions and barycentre vs z layer, and their theta/phi can also be set.
ENDRELEASENOTES

Screenshot of decorations for EMEC clusters, with Elayer/Etot, r_layer, theta_layer, phi_layer, (x10 layers), n_cells
Screenshot 2025-11-14 at 13 42 15

Screenshot of reconstructed phi (20 GeV photon in endcap, phi=45, slight bias observed but no correction and linear energy weighting of cells..)
Screenshot 2025-11-14 at 13 04 33

Screenshot of reconstructed theta (20 GeV photon in endcap, theta=160, no correction and linear energy weighting of cells..)
Screenshot 2025-11-14 at 13 04 14

A couple of screenshots of the reconstructed direction for one 20 GeV photon in endcap)
Screenshot 2025-11-14 at 13 52 31
Screenshot 2025-11-14 at 13 53 11

@giovannimarchiori
Copy link
Contributor Author

@BrieucF MR ready for you

@BrieucF
Copy link
Contributor

BrieucF commented Jan 15, 2026

Hi Giovanni, thanks for this! For this one, fitting by eye gives a quite different result, or is it me?
Screenshot 2026-01-15 at 9 49 21 AM

@pjanot
Copy link

pjanot commented Jan 15, 2026 via email

@giovannimarchiori
Copy link
Contributor Author

Hi @BrieucF , I agree with you. And in fact, in my initial comment, I wrote "slight bias observed but no correction and linear energy weighting of cells..". This is for the endcap OOTB... As I said in the past, the performance of the algorithm has to be studied, understood and improved. This PR does not mean to provide a final solution, but an initial piece of code (basically ported from Pandora) to allow such studies and refining the algorithm. BTW, the algorithm itself does not use the red dots (G4 steps) as input but the digitised cells

@BrieucF
Copy link
Contributor

BrieucF commented Jan 15, 2026

Ok, let's then add a disclaimer (and what this PR does) in the docstring of the header file.


/** @class AugmentClustersFCCee
*
* Add to the cluster shape parameters the sum of the cluster cells energy and barycenter theta/phi coordinates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reflect the modifications from this PR in the doc string?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a disclaimer saying it should be improved

//------------------------------------------------------------------------------------------------------------------------------------------

// fit the layer centroids
// loop over cluster, retrieve (pseudo)layers, loop over cells in layers, add each cell to list of fit points, and fit.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is no longer looping over clusters

3, numLayersTotal-2,
clusterBarycenter, clusterDirection);
newCluster.setITheta(clusterDirection.Theta());
newCluster.setPhi(clusterDirection.Phi());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be deprecated soon, please use setIPhi() (https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L424)

double weightLog =
std::max(0., m_thetaRecalcLayerWeights[k][layer] + log(eCell / sumEnLayer[layer + startPositionToFill]));
TVector3 v = TVector3(cell->getPosition().x, cell->getPosition().y, cell->getPosition().z);
std::max(0., m_thetaRecalcLayerWeights[k][layer] + log(eCell / sumEnLayer[layerToFill]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a possible bias could come from this

  /// Weights for each detector layer for theta position log-weighting
  Gaudi::Property<std::vector<std::vector<double>>> m_thetaRecalcLayerWeights{
      this,
      "thetaRecalcWeights",
      {{-1, 3.0, 3.0, 3.0, 4.25, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0}},
      "Weights for each detector layer for theta position log-weighting. If negative use linear weight."};

but ok, we can leave the tuning of the method for a later PR, provided that it is clearly stated that it was not tuned yet.

sumEnLayer,
3, numLayersTotal-2,
clusterBarycenter, clusterDirection);
newCluster.setITheta(clusterDirection.Theta());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should'nt we also update the cluster position?

@BrieucF
Copy link
Contributor

BrieucF commented Jan 15, 2026

Hi @BrieucF , I agree with you. And in fact, in my initial comment, I wrote "slight bias observed but no correction and linear energy weighting of cells..". This is for the endcap OOTB... As I said in the past, the performance of the algorithm has to be studied, understood and improved. This PR does not mean to provide a final solution, but an initial piece of code (basically ported from Pandora) to allow such studies and refining the algorithm. BTW, the algorithm itself does not use the red dots (G4 steps) as input but the digitised cells

Are you sure it is not with the logE weights already? From there

        if (m_thetaRecalcLayerWeights[k][layer] < 0) {
          sumThetaLayer[layerToFill] += (eCell * theta);
          layerCentroids[layerToFill] += (eCell * v);
        }
        else {
          sumThetaLayer[layerToFill] += (weightLog * theta);
          layerCentroids[layerToFill] += (weightLog * v);
        }

and the values of m_thetaRecalcLayerWeights it seems to me that we are using the logE weights.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants